package mosaic
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=9e4e90d17f9b2af1b07071fe425bc2c519c849c4f1d1ab73cde512be2d874849
sha512=06e9c4a741590942e81a27738d0b5c0413fafec8cf3b7dae047ad69f155e7b718aa4223818dc161b7d028efffcfd3365905e264d6fd31d453910ddfa91dcf9b9
doc/mosaic.ui/Mosaic_ui/Vnode/index.html
Module Mosaic_ui.VnodeSource
Virtual node tree for declarative UI descriptions.
Virtual node tree for declarative UI descriptions.
A vnode describes what a portion of the UI should look like at a given point in time. The view function returns a 'msg t; the runtime maps message handlers to unit via map before passing the tree to the reconciler.
This module lives in Mosaic_ui so view functions can be tested as pure functions, independently of the reconciler.
Handlers
type 'msg handlers = {on_mouse : (Event.mouse -> 'msg) option;on_key : (Event.key -> 'msg) option;on_paste : (Event.paste -> 'msg) option;
}The type for generic terminal event handlers, parameterised by the message type. These are low-level input events that any widget can receive. Widget-specific semantic callbacks (e.g. slider value changes) live in widget_callbacks.
Element kind
type kind = | Box of Box.Props.t| Text of Text.Props.t| Slider of Slider.Props.t| Text_input of Text_input.Props.t| Select of Select.Props.t| Tab_select of Tab_select.Props.t| Canvas of Canvas.Props.t| Spinner of Spinner.Props.t| Progress_bar of Progress_bar.Props.t| Scroll_bar of Scroll_bar.Props.t| Scroll_box of Scroll_box.Props.t| Textarea of Textarea.Props.t| Table of Table.Props.t| Code of Code.Props.t| Line_number of Line_number.Props.t| Markdown of Markdown.Props.t| Tree of Tree.Props.t(*The type for widget kind and visual configuration. Values are monomorphic — they are shared by reference across
*)mapand used for physical-equality fast paths in the reconciler.
Widget callbacks
type 'msg widget_callbacks = | No_callbacks| Slider_callbacks of {}| Input_callbacks of {on_input : (string -> 'msg) option;on_change : (string -> 'msg) option;on_submit : (string -> 'msg) option;on_cursor : (cursor:int -> selection:(int * int) option -> 'msg) option;
}| Select_callbacks of {}| Tab_select_callbacks of {}| Canvas_callbacks of {on_draw : (Canvas.t -> delta:float -> unit) option;
}| Scroll_bar_callbacks of {}| Scroll_box_callbacks of {}| Textarea_callbacks of {on_input : (string -> 'msg) option;on_change : (string -> 'msg) option;on_submit : (string -> 'msg) option;on_cursor : (cursor:int -> selection:(int * int) option -> 'msg) option;
}| Code_callbacks of {}| Table_callbacks of {}| Tree_callbacks of {on_change : (int -> 'msg) option;on_activate : (int -> 'msg) option;on_expand : (int -> bool -> 'msg) option;
}
Attributes
type attrs = {id : string option;style : Toffee.Style.t;visible : bool;z_index : int;opacity : float;focusable : bool;autofocus : bool;buffered : bool;live : bool;ref : (Renderable.t -> unit) option;
}The type for non-handler element attributes. Grouped for zero-copy sharing across map and physical-equality fast paths in the reconciler.
Virtual nodes
type 'msg t = | Element of 'msg element| Fragment of 'msg t list| Embed of Renderable.t| Empty(*The type for a virtual node in the UI tree.
Elementis a widget with kind, attributes, handlers, and children.Fragmentgroups multiple vnodes without a wrapper element.Embedwraps an existingRenderable.tnode. The node is attached but not managed by the reconciler. Use this as an escape hatch for imperative code.Emptyrenders nothing.
and 'msg element = {kind : kind;key : string option;attrs : attrs;handlers : 'msg handlers;callbacks : 'msg widget_callbacks;children : 'msg t list;
}The type for an element vnode, carrying its kind, an optional reconciliation key, attrs, generic handlers, widget-specific widget_callbacks, and children.
Constructors
fragment children is a Fragment grouping children without a wrapper element.
embed node is an Embed vnode wrapping node. The renderable is attached by the reconciler but not otherwise managed.
val box :
?key:string ->
?id:string ->
?style:Toffee.Style.t ->
?visible:bool ->
?z_index:int ->
?opacity:float ->
?focusable:bool ->
?autofocus:bool ->
?buffered:bool ->
?live:bool ->
?ref:(Renderable.t -> unit) ->
?on_mouse:(Event.mouse -> 'msg) ->
?on_key:(Event.key -> 'msg) ->
?on_paste:(Event.paste -> 'msg) ->
?border:bool ->
?border_style:Grid.Border.t ->
?border_sides:Grid.Border.side list ->
?border_color:Ansi.Color.t ->
?focused_border_color:Ansi.Color.t ->
?background:Ansi.Color.t ->
?fill:bool ->
?title:string ->
?title_alignment:[ `Left | `Center | `Right ] ->
'msg t list ->
'msg tbox children is a box container element holding children.
Common attributes:
keyis the reconciliation key for stable identity across re-renders. Defaults to none.styleis the layout style. Defaults toToffee.Style.default.visiblecontrols visibility. Defaults totrue.z_indexis the rendering order among siblings. Defaults to0.opacityis the opacity in [0.0;1.0]. Defaults to1.0.focusablecontrols whether the node can receive focus. Defaults tofalse.bufferedenables offscreen buffering. Whentrue, the node renders into a private grid that is blitted to the parent. Defaults tofalse.liveenables continuous rendering. Whentrue, the renderer runs every frame rather than only on request. Defaults tofalse.
Box-specific attributes:
borderenables border rendering. Defaults tofalse; also enabled automatically when any border option is set.border_styleis the border character set. Defaults toGrid.Border.single.border_sidesis the set of sides on which the border is drawn. Defaults to all four sides.border_coloris the border color when unfocused.focused_border_coloris the border color when focused.backgroundis the background fill color.fillcontrols whether the background fills the interior. Defaults totrue.titleis the text rendered in the top border.title_alignmentis the alignment of the title text. Defaults to`Left.
val text :
?key:string ->
?id:string ->
?style:Toffee.Style.t ->
?visible:bool ->
?z_index:int ->
?opacity:float ->
?focusable:bool ->
?autofocus:bool ->
?buffered:bool ->
?live:bool ->
?ref:(Renderable.t -> unit) ->
?on_mouse:(Event.mouse -> 'msg) ->
?on_key:(Event.key -> 'msg) ->
?on_paste:(Event.paste -> 'msg) ->
?text_style:Ansi.Style.t ->
?wrap:Text_surface.wrap ->
?selectable:bool ->
?selection_bg:Ansi.Color.t ->
?selection_fg:Ansi.Color.t ->
?tab_width:int ->
?truncate:bool ->
string ->
'msg ttext content is a text leaf element displaying content. Text does not accept children.
Text-specific attributes:
text_styleis the ANSI style applied to the text. Defaults toAnsi.Style.default.wrapis the line-wrapping mode. Defaults to`None.selectablecontrols whether text can be mouse-selected. Defaults totrue.selection_bgis the selection background color.selection_fgis the selection foreground color.tab_widthis the tab-stop width in columns. Defaults to2.truncatecontrols whether overlong lines are truncated with an ellipsis. Defaults tofalse.
val slider :
?key:string ->
?id:string ->
?style:Toffee.Style.t ->
?visible:bool ->
?z_index:int ->
?opacity:float ->
?focusable:bool ->
?autofocus:bool ->
?buffered:bool ->
?live:bool ->
?ref:(Renderable.t -> unit) ->
?on_mouse:(Event.mouse -> 'msg) ->
?on_key:(Event.key -> 'msg) ->
?on_paste:(Event.paste -> 'msg) ->
?orientation:Slider.orientation ->
?value:float ->
?min:float ->
?max:float ->
?viewport_size:float ->
?track_color:Ansi.Color.t ->
?thumb_color:Ansi.Color.t ->
?on_value_change:(float -> 'msg) ->
unit ->
'msg tslider () is a slider leaf element. Slider does not accept children.
Slider-specific attributes:
orientationis the track direction. Defaults to`Horizontal.valueis the current value. Defaults tomin.minis the lower bound. Defaults to0.0.maxis the upper bound. Defaults to100.0.viewport_sizeis the visible-portion size, which controls the thumb length. Defaults to 10% of the range.track_coloris the track background color. Defaults to dark gray.thumb_coloris the thumb foreground color. Defaults to medium gray.on_value_changeis called when the slider value changes.
val input :
?key:string ->
?id:string ->
?style:Toffee.Style.t ->
?visible:bool ->
?z_index:int ->
?opacity:float ->
?focusable:bool ->
?autofocus:bool ->
?buffered:bool ->
?live:bool ->
?ref:(Renderable.t -> unit) ->
?on_mouse:(Event.mouse -> 'msg) ->
?on_key:(Event.key -> 'msg) ->
?on_paste:(Event.paste -> 'msg) ->
?value:string ->
?cursor:int ->
?selection:(int * int) option ->
?placeholder:string ->
?max_length:int ->
?text_color:Ansi.Color.t ->
?background_color:Ansi.Color.t ->
?focused_text_color:Ansi.Color.t ->
?focused_background_color:Ansi.Color.t ->
?placeholder_color:Ansi.Color.t ->
?selection_color:Ansi.Color.t ->
?selection_fg:Ansi.Color.t ->
?cursor_style:[ `Block | `Line | `Underline ] ->
?cursor_color:Ansi.Color.t ->
?cursor_blinking:bool ->
?on_input:(string -> 'msg) ->
?on_change:(string -> 'msg) ->
?on_submit:(string -> 'msg) ->
?on_cursor:(cursor:int -> selection:(int * int) option -> 'msg) ->
unit ->
'msg tinput () is a single-line text input leaf element. Input does not accept children.
Input-specific attributes:
focusablecontrols whether the node can receive focus. Defaults totrue.valueis the initial text content. Defaults to"".cursoris an optional controlled cursor grapheme offset.selectionis an optional controlled selection range.placeholderis the text shown when the input is empty, regardless of focus. Defaults to"".max_lengthis the maximum grapheme cluster count. Defaults to1000.text_coloris the text color when unfocused. Defaults toAnsi.Color.t.White.background_coloris the background color when unfocused.focused_text_coloris the text color when focused. Defaults toAnsi.Color.t.White.focused_background_coloris the background color when focused.placeholder_coloris the placeholder text color. Defaults toAnsi.Color.t.Bright_black.selection_coloris the selection background color. Defaults toAnsi.Color.t.Blue.selection_fgis the selection foreground color. When unset, the normal text color is used.cursor_styleis the cursor shape when focused. Defaults to`Block.cursor_coloris the cursor color when focused. Defaults toAnsi.Color.t.White.cursor_blinkingcontrols whether the cursor blinks. Defaults totrue.on_inputis called after every text change at keystroke-level.on_changeis called when the committed value changes (on blur or submit).on_submitis called when Enter is pressed.on_cursoris called when cursor position or selection changes.
val select :
?key:string ->
?id:string ->
?style:Toffee.Style.t ->
?visible:bool ->
?z_index:int ->
?opacity:float ->
?focusable:bool ->
?autofocus:bool ->
?buffered:bool ->
?live:bool ->
?ref:(Renderable.t -> unit) ->
?on_mouse:(Event.mouse -> 'msg) ->
?on_key:(Event.key -> 'msg) ->
?on_paste:(Event.paste -> 'msg) ->
?options:Select.item list ->
?selected_index:int ->
?background:Ansi.Color.t ->
?text_color:Ansi.Color.t ->
?focused_background:Ansi.Color.t ->
?focused_text_color:Ansi.Color.t ->
?selected_background:Ansi.Color.t ->
?selected_text_color:Ansi.Color.t ->
?description_color:Ansi.Color.t ->
?selected_description_color:Ansi.Color.t ->
?show_description:bool ->
?show_scroll_indicator:bool ->
?wrap_selection:bool ->
?item_spacing:int ->
?fast_scroll_step:int ->
?on_change:(int -> 'msg) ->
?on_activate:(int -> 'msg) ->
unit ->
'msg tselect () is a vertical selection list leaf element. Select does not accept children.
Select-specific attributes:
focusablecontrols whether the node can receive focus. Defaults totrue.optionsis the list of items to display. Defaults to[].selected_indexis the initial selection index. Defaults to0.backgroundis the item background color.text_coloris the item text color.focused_backgroundis the item background color when the widget is focused.focused_text_coloris the item text color when the widget is focused.selected_backgroundis the selected item background color.selected_text_coloris the selected item text color.description_coloris the description text color.selected_description_coloris the selected item description color.show_descriptioncontrols whether description lines are displayed. Defaults totrue.show_scroll_indicatorcontrols whether a scroll indicator is displayed. Defaults tofalse.wrap_selectioncontrols whether selection wraps at list boundaries. Defaults tofalse.item_spacingis the vertical spacing between items in rows. Defaults to0.fast_scroll_stepis the number of items skipped with Shift+Up/Down. Defaults to5.on_changeis called when the selection index changes.on_activateis called when the current item is activated via Enter.
val tab_select :
?key:string ->
?id:string ->
?style:Toffee.Style.t ->
?visible:bool ->
?z_index:int ->
?opacity:float ->
?focusable:bool ->
?autofocus:bool ->
?buffered:bool ->
?live:bool ->
?ref:(Renderable.t -> unit) ->
?on_mouse:(Event.mouse -> 'msg) ->
?on_key:(Event.key -> 'msg) ->
?on_paste:(Event.paste -> 'msg) ->
options:Tab_select.item list ->
?selected:int ->
?tab_width:int ->
?background:Ansi.Color.t ->
?text_color:Ansi.Color.t ->
?focused_background:Ansi.Color.t ->
?focused_text_color:Ansi.Color.t ->
?selected_background:Ansi.Color.t ->
?selected_text_color:Ansi.Color.t ->
?description_color:Ansi.Color.t ->
?selected_description_color:Ansi.Color.t ->
?show_underline:bool ->
?show_description:bool ->
?show_scroll_arrows:bool ->
?wrap_selection:bool ->
?on_change:(int -> 'msg) ->
?on_activate:(int -> 'msg) ->
unit ->
'msg ttab_select ~options () is a horizontal tab selection leaf element. Tab_select does not accept children.
Tab_select-specific attributes:
focusablecontrols whether the node can receive focus. Defaults totrue.optionsis the list of tab items to display. Required.selectedis the initial selection index. Defaults to0.tab_widthis the fixed width of each tab cell in columns. Defaults to12.backgroundis the tab background color.text_coloris the tab text color.focused_backgroundis the tab background color when the widget is focused.focused_text_coloris the tab text color when the widget is focused.selected_backgroundis the selected tab background color.selected_text_coloris the selected tab text color.description_coloris the description text color.selected_description_coloris the selected tab description color.show_underlinecontrols whether a selection underline is displayed. Defaults totrue.show_descriptioncontrols whether the description line below the tabs is displayed. Defaults tofalse.show_scroll_arrowscontrols whether scroll indicator arrows are displayed. Defaults totrue.wrap_selectioncontrols whether selection wraps at tab boundaries. Defaults tofalse.on_changeis called when the selection index changes.on_activateis called when the current tab is activated via Enter.
val canvas :
?key:string ->
?id:string ->
?style:Toffee.Style.t ->
?visible:bool ->
?z_index:int ->
?opacity:float ->
?focusable:bool ->
?autofocus:bool ->
?buffered:bool ->
?live:bool ->
?ref:(Renderable.t -> unit) ->
?on_mouse:(Event.mouse -> 'msg) ->
?on_key:(Event.key -> 'msg) ->
?on_paste:(Event.paste -> 'msg) ->
?respect_alpha:bool ->
?on_draw:(Canvas.t -> delta:float -> unit) ->
unit ->
'msg tcanvas () is a canvas leaf element for custom cell-level drawing. Canvas does not accept children.
The on_draw callback fires each render pass, after the canvas has been resized to match the current layout. Inside the callback, Canvas.width and Canvas.height reflect the current dimensions. Content from previous frames persists; call Canvas.clear first when a full redraw is required.
Canvas-specific attributes:
respect_alphacontrols whether alpha blending is honoured when drawing. Defaults tofalse.on_drawis the render-time drawing callback. The~deltaargument is elapsed time in milliseconds since the last frame. Combine with~live:truefor per-frame animation.
val spinner :
?key:string ->
?id:string ->
?style:Toffee.Style.t ->
?visible:bool ->
?z_index:int ->
?opacity:float ->
?focusable:bool ->
?autofocus:bool ->
?buffered:bool ->
?live:bool ->
?ref:(Renderable.t -> unit) ->
?on_mouse:(Event.mouse -> 'msg) ->
?on_key:(Event.key -> 'msg) ->
?on_paste:(Event.paste -> 'msg) ->
?frame_set:Spinner.frame_set ->
?color:Ansi.Color.t ->
unit ->
'msg tspinner () is an animated spinner leaf element. Spinner does not accept children.
The spinner cycles through Unicode frame strings at a fixed interval driven by the frame-based animation system.
Spinner-specific attributes:
liveenables continuous rendering. Defaults totrue; spinners animate by default.frame_setis the set of animation frames and their interval. Defaults toSpinner.dots.coloris the spinner foreground color. Defaults toAnsi.Color.t.White.
val progress_bar :
?key:string ->
?id:string ->
?style:Toffee.Style.t ->
?visible:bool ->
?z_index:int ->
?opacity:float ->
?focusable:bool ->
?autofocus:bool ->
?buffered:bool ->
?live:bool ->
?ref:(Renderable.t -> unit) ->
?on_mouse:(Event.mouse -> 'msg) ->
?on_key:(Event.key -> 'msg) ->
?on_paste:(Event.paste -> 'msg) ->
?value:float ->
?min:float ->
?max:float ->
?orientation:[ `Horizontal | `Vertical ] ->
?filled_color:Ansi.Color.t ->
?empty_color:Ansi.Color.t ->
unit ->
'msg tprogress_bar () is a progress bar leaf element. Progress_bar does not accept children.
The bar is rendered with sub-cell precision using Unicode half-block characters to show the filled and empty portions.
Progress_bar-specific attributes:
valueis the current progress value. Defaults to0.0.minis the lower bound. Defaults to0.0.maxis the upper bound. Defaults to1.0.orientationis the bar fill direction. Defaults to`Horizontal.filled_coloris the filled portion color. Defaults to medium gray.empty_coloris the empty portion color. Defaults to dark gray.
val scroll_bar :
?key:string ->
?id:string ->
?style:Toffee.Style.t ->
?visible:bool ->
?z_index:int ->
?opacity:float ->
?focusable:bool ->
?autofocus:bool ->
?buffered:bool ->
?live:bool ->
?ref:(Renderable.t -> unit) ->
?on_mouse:(Event.mouse -> 'msg) ->
?on_key:(Event.key -> 'msg) ->
?on_paste:(Event.paste -> 'msg) ->
?orientation:Scroll_bar.orientation ->
?show_arrows:bool ->
?track_color:Ansi.Color.t ->
?thumb_color:Ansi.Color.t ->
?arrow_fg:Ansi.Color.t ->
?arrow_bg:Ansi.Color.t ->
?on_change:(int -> 'msg) ->
unit ->
'msg tscroll_bar () is a scroll bar leaf element. Scroll_bar does not accept children.
Scroll_bar-specific attributes:
orientationis the scroll bar direction. Defaults to`Vertical.show_arrowscontrols whether arrow buttons are displayed at each end. Defaults tofalse.track_coloris the track background color.thumb_coloris the thumb foreground color.arrow_fgis the arrow button foreground color.arrow_bgis the arrow button background color.on_changeis called when the scroll position changes.
val scroll_box :
?key:string ->
?id:string ->
?style:Toffee.Style.t ->
?visible:bool ->
?z_index:int ->
?opacity:float ->
?focusable:bool ->
?autofocus:bool ->
?buffered:bool ->
?live:bool ->
?ref:(Renderable.t -> unit) ->
?on_mouse:(Event.mouse -> 'msg) ->
?on_key:(Event.key -> 'msg) ->
?on_paste:(Event.paste -> 'msg) ->
?scroll_x:bool ->
?scroll_y:bool ->
?sticky_scroll:bool ->
?sticky_start:[ `Top | `Bottom | `Left | `Right ] ->
?background:Ansi.Color.t ->
?on_scroll:(x:int -> y:int -> 'msg) ->
'msg t list ->
'msg tscroll_box children is a scrollable container element. Children are attached to an internal content node.
Scroll_box-specific attributes:
scroll_xenables horizontal scrolling. Defaults tofalse.scroll_yenables vertical scrolling. Defaults totrue.sticky_scrollmakes the viewport stick tosticky_startas content grows. Defaults tofalse.sticky_startis the edge to stick to whensticky_scrollistrue. Defaults to`Bottom.backgroundis the optional background fill color.on_scrollis called when the scroll position changes, receiving the new offsets as~xand~y.
val textarea :
?key:string ->
?id:string ->
?style:Toffee.Style.t ->
?visible:bool ->
?z_index:int ->
?opacity:float ->
?focusable:bool ->
?autofocus:bool ->
?buffered:bool ->
?live:bool ->
?ref:(Renderable.t -> unit) ->
?on_mouse:(Event.mouse -> 'msg) ->
?on_key:(Event.key -> 'msg) ->
?on_paste:(Event.paste -> 'msg) ->
?value:string ->
?cursor:int ->
?selection:(int * int) option ->
?spans:Text_buffer.span list ->
?ghost_text:string ->
?ghost_text_color:Ansi.Color.t ->
?placeholder:string ->
?wrap:Text_surface.wrap ->
?text_color:Ansi.Color.t ->
?background_color:Ansi.Color.t ->
?focused_text_color:Ansi.Color.t ->
?focused_background_color:Ansi.Color.t ->
?placeholder_color:Ansi.Color.t ->
?selection_color:Ansi.Color.t ->
?selection_fg:Ansi.Color.t ->
?cursor_style:[ `Block | `Line | `Underline ] ->
?cursor_color:Ansi.Color.t ->
?cursor_blinking:bool ->
?on_input:(string -> 'msg) ->
?on_change:(string -> 'msg) ->
?on_submit:(string -> 'msg) ->
?on_cursor:(cursor:int -> selection:(int * int) option -> 'msg) ->
unit ->
'msg ttextarea () is a multi-line text editing leaf element. Textarea does not accept children.
Textarea-specific attributes:
focusablecontrols whether the node can receive focus. Defaults totrue.valueis the initial text content. Defaults to"".cursoris an optional controlled cursor grapheme offset.selectionis an optional controlled selection range.spansis optional styled spans used for syntax highlighting. When provided, the span text must matchvalue.ghost_textis optional inline ghost completion rendered at the cursor.ghost_text_coloris the ghost text color.placeholderis the text shown when the textarea is empty, regardless of focus. Defaults to"".wrapis the line-wrapping mode. Defaults to`Word.text_coloris the text color when unfocused. Defaults toAnsi.Color.t.White.background_coloris the background color when unfocused.focused_text_coloris the text color when focused. Defaults toAnsi.Color.t.White.focused_background_coloris the background color when focused.placeholder_coloris the placeholder text color. Defaults toAnsi.Color.t.Bright_black.selection_coloris the selection background color. Defaults toAnsi.Color.t.Blue.selection_fgis the selection foreground color. When unset, the normal text color is used.cursor_styleis the cursor shape when focused. Defaults to`Block.cursor_coloris the cursor color when focused. Defaults toAnsi.Color.t.White.cursor_blinkingcontrols whether the cursor blinks. Defaults totrue.on_inputis called after every text change at keystroke-level.on_changeis called when the committed value changes (on blur or submit).on_submitis called when Cmd+Enter or Ctrl+Enter is pressed.on_cursoris called when cursor position or selection changes.
val table :
?key:string ->
?id:string ->
?style:Toffee.Style.t ->
?visible:bool ->
?z_index:int ->
?opacity:float ->
?focusable:bool ->
?autofocus:bool ->
?buffered:bool ->
?live:bool ->
?ref:(Renderable.t -> unit) ->
?on_mouse:(Event.mouse -> 'msg) ->
?on_key:(Event.key -> 'msg) ->
?on_paste:(Event.paste -> 'msg) ->
?columns:Table.column list ->
?rows:Table.cell array list ->
?selected_row:int ->
?border:bool ->
?border_style:Grid.Border.t ->
?show_header:bool ->
?show_column_separator:bool ->
?show_row_separator:bool ->
?cell_padding:int ->
?header_color:Ansi.Color.t ->
?header_background:Ansi.Color.t ->
?text_color:Ansi.Color.t ->
?background:Ansi.Color.t ->
?selected_text_color:Ansi.Color.t ->
?selected_background:Ansi.Color.t ->
?focused_selected_text_color:Ansi.Color.t ->
?focused_selected_background:Ansi.Color.t ->
?row_styles:Ansi.Style.t list ->
?wrap_selection:bool ->
?fast_scroll_step:int ->
?on_change:(int -> 'msg) ->
?on_activate:(int -> 'msg) ->
unit ->
'msg ttable () is a data table leaf element. Table does not accept children.
Table-specific attributes:
focusablecontrols whether the node can receive focus. Defaults totrue.columnsis the list of column specifications. Defaults to[].rowsis the list of data rows, each acell array. Defaults to[].selected_rowis the initial selection index. Defaults to0.borderenables the outer border and header separator. Defaults totrue.border_styleis the border character set. Defaults toGrid.Border.single.show_headercontrols whether the header row is shown. Defaults totrue.show_column_separatorcontrols whether vertical lines between columns are shown. Defaults tofalse.show_row_separatorcontrols whether horizontal lines between rows are shown. Defaults tofalse.cell_paddingis the horizontal padding per side of each cell in columns. Defaults to0.header_coloris the header text color.header_backgroundis the header background color.text_coloris the row text color.backgroundis the row background color.selected_text_coloris the selected row text color when unfocused.selected_backgroundis the selected row background color when unfocused.focused_selected_text_coloris the selected row text color when focused.focused_selected_backgroundis the selected row background color when focused.row_stylesis a list of styles cycled by modulo across rows for alternating row styling. Defaults to[](no alternation).wrap_selectioncontrols whether selection wraps at row boundaries. Defaults tofalse.fast_scroll_stepis the number of rows skipped with Shift+Up/Down. Defaults to5.on_changeis called when the selected row changes.on_activateis called when the current row is activated via Enter.
val code :
?key:string ->
?id:string ->
?style:Toffee.Style.t ->
?visible:bool ->
?z_index:int ->
?opacity:float ->
?focusable:bool ->
?autofocus:bool ->
?buffered:bool ->
?live:bool ->
?ref:(Renderable.t -> unit) ->
?on_mouse:(Event.mouse -> 'msg) ->
?on_key:(Event.key -> 'msg) ->
?on_paste:(Event.paste -> 'msg) ->
?spans:Text_buffer.span list ->
?text_style:Ansi.Style.t ->
?wrap:Text_surface.wrap ->
?tab_width:int ->
?truncate:bool ->
?selectable:bool ->
?selection_bg:Ansi.Color.t ->
?selection_fg:Ansi.Color.t ->
?on_selection:((int * int) option -> 'msg) ->
string ->
'msg tcode content is a code display leaf element showing content. Code does not accept children.
Code-specific attributes:
spansis the list of pre-computed syntax highlighting spans. Defaults to[].text_styleis the base ANSI style applied to the text. Defaults toAnsi.Style.default.wrapis the line-wrapping mode. Defaults to`None.tab_widthis the tab-stop width in columns. Defaults to4.truncatecontrols whether overlong lines are truncated with an ellipsis. Defaults tofalse.selectablecontrols whether text can be mouse-selected. Defaults totrue.selection_bgis the selection background color.selection_fgis the selection foreground color.on_selectionis called when the current selection changes.
val line_number :
?key:string ->
?id:string ->
?style:Toffee.Style.t ->
?visible:bool ->
?z_index:int ->
?opacity:float ->
?focusable:bool ->
?autofocus:bool ->
?buffered:bool ->
?live:bool ->
?ref:(Renderable.t -> unit) ->
?on_mouse:(Event.mouse -> 'msg) ->
?on_key:(Event.key -> 'msg) ->
?on_paste:(Event.paste -> 'msg) ->
?fg:Ansi.Color.t ->
?bg:Ansi.Color.t ->
?min_width:int ->
?padding_right:int ->
?show_line_numbers:bool ->
?line_number_offset:int ->
?line_colors:(int * Line_number.line_color) list ->
?line_signs:(int * Line_number.line_sign) list ->
?line_numbers:(int * int) list ->
?hidden_line_numbers:int list ->
'msg t ->
'msg tline_number child is a line-number gutter container wrapping child. The gutter discovers the child via a Line information provider and draws line numbers accordingly.
Line_number-specific attributes:
fgis the line number foreground color. Defaults to medium gray.bgis the gutter background color.min_widthis the minimum gutter width in columns. Defaults to3.padding_rightis the padding between the number and the content in columns. Defaults to1.show_line_numberscontrols whether the gutter is visible. Whenfalse, the gutter is hidden entirely and takes no layout space. Defaults totrue.line_number_offsetis added to each logical line index when displaying numbers. Defaults to0.line_colorsis a list of per-line background colors, keyed by logical line index. Defaults to[].line_signsis a list of per-line gutter signs, keyed by logical line index. Defaults to[].line_numbersis a list of custom line number overrides, keyed by logical line index. Defaults to[].hidden_line_numbersis the list of logical line indices whose numbers are hidden. Defaults to[].
val markdown :
?key:string ->
?id:string ->
?style:Toffee.Style.t ->
?visible:bool ->
?z_index:int ->
?opacity:float ->
?focusable:bool ->
?autofocus:bool ->
?buffered:bool ->
?live:bool ->
?ref:(Renderable.t -> unit) ->
?on_mouse:(Event.mouse -> 'msg) ->
?on_key:(Event.key -> 'msg) ->
?on_paste:(Event.paste -> 'msg) ->
?md_style:Markdown.style ->
?conceal:bool ->
?streaming:bool ->
string ->
'msg tmarkdown content is a markdown display leaf element. Parses content as CommonMark and renders headings, paragraphs, code blocks, lists, blockquotes, tables, and inline formatting. Markdown does not accept children.
Markdown-specific attributes:
md_styleis the style resolver for markdown elements. Defaults toMarkdown.default_style.concealcontrols whether markdown syntax characters are hidden. Defaults totrue.streamingenables graceful handling of incomplete trailing content, useful when content arrives incrementally. Defaults tofalse.
val tree :
?key:string ->
?id:string ->
?style:Toffee.Style.t ->
?visible:bool ->
?z_index:int ->
?opacity:float ->
?focusable:bool ->
?autofocus:bool ->
?buffered:bool ->
?live:bool ->
?ref:(Renderable.t -> unit) ->
?on_mouse:(Event.mouse -> 'msg) ->
?on_key:(Event.key -> 'msg) ->
?on_paste:(Event.paste -> 'msg) ->
?items:Tree.item list ->
?selected_index:int ->
?expand_depth:int ->
?indent_size:int ->
?show_guides:bool ->
?guide_style:Grid.Border.t ->
?expand_icon:string ->
?collapse_icon:string ->
?leaf_icon:string ->
?background:Ansi.Color.t ->
?text_color:Ansi.Color.t ->
?selected_background:Ansi.Color.t ->
?selected_text_color:Ansi.Color.t ->
?focused_selected_background:Ansi.Color.t ->
?focused_selected_text_color:Ansi.Color.t ->
?guide_color:Ansi.Color.t ->
?icon_color:Ansi.Color.t ->
?wrap_selection:bool ->
?fast_scroll_step:int ->
?on_change:(int -> 'msg) ->
?on_activate:(int -> 'msg) ->
?on_expand:(int -> bool -> 'msg) ->
unit ->
'msg ttree () is a hierarchical tree leaf element. Tree does not accept children.
Tree-specific attributes:
focusablecontrols whether the node can receive focus. Defaults totrue.itemsis the list of tree items. Defaults to[].selected_indexis the initial selection index. Defaults to0.expand_depthis the initial expansion depth.0means all nodes are collapsed. Defaults to0.indent_sizeis the number of columns per depth level. Defaults to2.show_guidescontrols whether box-drawing guide lines are drawn. Defaults tofalse.guide_styleis the guide character set. Defaults toGrid.Border.single.expand_iconis the icon string for expandable nodes.collapse_iconis the icon string for collapsible nodes.leaf_iconis the icon string for leaf nodes.backgroundis the item background color.text_coloris the item text color.selected_backgroundis the selected item background color when unfocused.selected_text_coloris the selected item text color when unfocused.focused_selected_backgroundis the selected item background color when focused.focused_selected_text_coloris the selected item text color when focused.guide_coloris the guide line color.icon_coloris the icon color.wrap_selectioncontrols whether selection wraps at boundaries. Defaults tofalse.fast_scroll_stepis the number of items skipped with Shift+Up/Down. Defaults to5.on_changeis called when the selected index changes.on_activateis called when the current node is activated via Enter.on_expandis called when a node is expanded or collapsed, receiving the node index and the new expansion state.
Transformation
Layout helpers
px n is a pixel dimension of n columns.
pct n is a percentage dimension. n is in [0;100].
auto is the auto dimension.
size ~width ~height is a pixel size.
gap n is a uniform pixel gap of n columns on both axes.
padding n is a uniform pixel padding of n columns on all sides.
margin n is a uniform pixel margin of n columns on all sides.
inset n is a uniform pixel inset of n columns on all sides.