class
TUI::MarkdownView
- TUI::MarkdownView
- Reference
- Object
Overview
Renders a Markdown source string: numbered headings with per-level emphasis (since a terminal can't grow font size), real word-wrapped paragraphs/list items/blockquotes preserving inline styling, nested list indentation with continuation lines aligned under the text (not the marker), and GFM tables with alignment-aware column widths drawn with box-drawing borders. Parsing/wrapping/layout are hand-rolled in TUI::Markdown (this library has zero runtime dependencies) — see TUI::Markdown::Parser/Wrap/Layout for the algorithms; this class is just the Scrollable host: styling properties, caching, and the standard scroll-key handling every other Scrollable already has.
Included Modules
Defined in:
tui/widgets/markdown_view.crConstructors
Instance Method Summary
- #bold_italic_style : Style
- #bold_italic_style=(bold_italic_style : Style)
- #bold_style : Style
- #bold_style=(bold_style : Style)
- #code_style : Style
- #code_style=(code_style : Style)
-
#content_size : Int32
Reports the physical row count for the width this content was LAST actually rendered at (#render_content updates that width every call) — Window#render calls #content_size before it has built the buffer that would tell content this frame's width (confirmed by reading Window#render:
total = @content.content_sizeruns beforeinner = Buffer.new(inner_width, ...)), so there is structurally no way to answer for the CURRENT frame's width here. -
#handle_click(local_row : Int32, local_col : Int32, scroll : ScrollControl) : Bool
A positional (mouse) event, pre-translated by Window into content-local row/col (0,0 = content's own first cell).
-
#handle_key(ev : KeyEvent, scroll : ScrollControl) : Bool
Everything but positional mouse hit-testing.
- #heading_indent_step : Int32
- #heading_indent_step=(heading_indent_step : Int32)
-
#heading_styles : Array(Style)
Heading styles by level (index 0 = h1), decreasing emphasis since Style has no font-size — numbering (see #number_headings) is the primary way level is conveyed, this is a secondary visual cue.
-
#heading_styles=(heading_styles : Array(Style))
Heading styles by level (index 0 = h1), decreasing emphasis since Style has no font-size — numbering (see #number_headings) is the primary way level is conveyed, this is a secondary visual cue.
- #hrule_style : Style
- #hrule_style=(hrule_style : Style)
- #italic_style : Style
- #italic_style=(italic_style : Style)
- #link_style : Style
- #link_style=(link_style : Style)
- #list_bullet_glyphs : Array(String)
- #list_bullet_glyphs=(list_bullet_glyphs : Array(String))
- #list_indent_step : Int32
- #list_indent_step=(list_indent_step : Int32)
- #list_marker_style : Style
- #list_marker_style=(list_marker_style : Style)
-
#load(source : String) : Nil
Replaces the rendered content and invalidates the cached layout (see #content_size for why layout is cached at all) so the next #content_size/#render_content call re-lays-out unconditionally, even if the new document happens to need the same width as the old cached layout.
-
#number_headings=(number_headings : Bool)
Nested-outline numbering ("1.2.3 Title") in front of every heading.
-
#number_headings? : Bool
Nested-outline numbering ("1.2.3 Title") in front of every heading.
- #quote_indent_step : Int32
- #quote_indent_step=(quote_indent_step : Int32)
- #quote_style : Style
- #quote_style=(quote_style : Style)
-
#render_content(buffer : Buffer, scroll : ScrollControl) : Nil
Render into
buffer, a region already sized to the content area (border/scrollbar column already excluded by Window). - #status_hint : String
- #table_border_style : Style
- #table_border_style=(table_border_style : Style)
- #table_header_style : Style
- #table_header_style=(table_header_style : Style)
-
#title : String
Set by a host app (e.g.
-
#title=(title : String)
Set by a host app (e.g.
Instance methods inherited from module TUI::Scrollable
content_size : Int32
content_size,
focus_if(condition : Bool) : Nil
focus_if,
focused=(focused : Bool)
focused=,
focused? : Bool
focused?,
handle_click(local_row : Int32, local_col : Int32, scroll : ScrollControl) : Bool
handle_click,
handle_key(ev : KeyEvent, scroll : ScrollControl) : Bool
handle_key,
header_rows : Int32
header_rows,
render_content(buffer : Buffer, scroll : ScrollControl) : Nil
render_content,
status_hint : String
status_hint,
title : String
title
Constructor Detail
Instance Method Detail
Reports the physical row count for the width this content was LAST
actually rendered at (#render_content updates that width every
call) — Window#render calls #content_size before it has built the
buffer that would tell content this frame's width (confirmed by
reading Window#render: total = @content.content_size runs before
inner = Buffer.new(inner_width, ...)), so there is structurally
no way to answer for the CURRENT frame's width here. This is stale
by exactly one frame during an active resize (used only for
Scroller#clamp's max-offset math) and self-heals the same frame
#render_content next runs with the real width — the same
resize-tolerance philosophy Scroller#clamp itself already relies
on, rather than widening Scrollable's abstract contract for this
one widget's benefit.
A positional (mouse) event, pre-translated by Window into content-local row/col (0,0 = content's own first cell).
Everything but positional mouse hit-testing.
Heading styles by level (index 0 = h1), decreasing emphasis since Style has no font-size — numbering (see #number_headings) is the primary way level is conveyed, this is a secondary visual cue.
Heading styles by level (index 0 = h1), decreasing emphasis since Style has no font-size — numbering (see #number_headings) is the primary way level is conveyed, this is a secondary visual cue.
Replaces the rendered content and invalidates the cached layout (see #content_size for why layout is cached at all) so the next #content_size/#render_content call re-lays-out unconditionally, even if the new document happens to need the same width as the old cached layout.
Nested-outline numbering ("1.2.3 Title") in front of every heading. Disable to keep indentation/styling but drop the prefix.
Nested-outline numbering ("1.2.3 Title") in front of every heading. Disable to keep indentation/styling but drop the prefix.
Render into buffer, a region already sized to the content area
(border/scrollbar column already excluded by Window). Row 0 is
content's own first row.
Set by a host app (e.g. to a document's filename); shown as the hosting Window's border title, same convention as DetailView#title.
Set by a host app (e.g. to a document's filename); shown as the hosting Window's border title, same convention as DetailView#title.