Mosaic_ui.SelectVertical list selector with optional descriptions.
Vertical list selector with optional descriptions.
A focusable, keyboard-navigable list where exactly one item is highlighted at a time. Each item has a label and an optional description. The widget automatically scrolls to keep the selected item centered in the viewport; rendering is buffered.
set_fast_scroll_step items).set_on_activate callback).The viewport displays as many items as fit within the available height. When an item is selected the view scrolls to center it. The set_show_scroll_indicator option displays a proportional position indicator in the rightmost column.
A select widget backed by a Renderable.t.
val create :
parent:Renderable.t ->
?index:int ->
?id:string ->
?style:Toffee.Style.t ->
?visible:bool ->
?z_index:int ->
?opacity:float ->
?options: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 ->
unit ->
tcreate ~parent () is a select node attached to parent.
The node is focusable and uses buffered rendering. See Props.make for parameter defaults.
val node : t -> Renderable.tnode t is the underlying renderable.
module Props : sig ... endapply_props t props applies props to t. Only properties that differ from the current state trigger layout recomputation and re-render.
set_options t items replaces the item list. The selection index is clamped to the new valid range. Does not fire the set_on_change callback. Triggers re-render.
val selected_index : t -> intselected_index t is the 0-based index of the selected item.
selected_item t is the currently selected item, or None when the list is empty.
val set_selected_index : t -> int -> unitset_selected_index t i moves the selection to index i, clamped to [0;length - 1]. Fires the set_on_change callback when the clamped index differs from the current selection; no-op otherwise.
val set_show_description : t -> bool -> unitset_show_description t flag shows or hides item description lines. Recalculates layout and triggers re-render when the value changes.
val set_show_scroll_indicator : t -> bool -> unitset_show_scroll_indicator t flag shows or hides the scroll position indicator. Triggers re-render when the value changes.
val set_item_spacing : t -> int -> unitset_item_spacing t n sets vertical spacing between items in cells. n is clamped to minimum 0. Recalculates layout and triggers re-render when the value changes.
val set_wrap_selection : t -> bool -> unitset_wrap_selection t flag enables or disables wrapping to the opposite end when navigating past list boundaries. Triggers re-render when the value changes.
val set_fast_scroll_step : t -> int -> unitset_fast_scroll_step t n sets the number of items to skip with Shift+Up/Down. n is clamped to minimum 1. Triggers re-render when the value changes.
val set_background : t -> Ansi.Color.t -> unitset_background t color sets the unfocused background color.
val set_text_color : t -> Ansi.Color.t -> unitset_text_color t color sets the unfocused text color.
val set_focused_background : t -> Ansi.Color.t -> unitset_focused_background t color sets the focused background color.
val set_focused_text_color : t -> Ansi.Color.t -> unitset_focused_text_color t color sets the focused text color.
val set_selected_background : t -> Ansi.Color.t -> unitset_selected_background t color sets the selected item background color.
val set_selected_text_color : t -> Ansi.Color.t -> unitset_selected_text_color t color sets the selected item text color.
val set_description_color : t -> Ansi.Color.t -> unitset_description_color t color sets the description text color.
val set_selected_description_color : t -> Ansi.Color.t -> unitset_selected_description_color t color sets the selected item description text color.
val set_on_change : t -> (int -> unit) option -> unitset_on_change t callback registers a callback fired when the selected index changes. The callback receives the new index. Pass None to clear. See set_selected_index.
val set_on_activate : t -> (int -> unit) option -> unitset_on_activate t callback registers a callback fired when the current item is activated (Enter or KP_enter). The callback receives the activated item index. Pass None to clear.
val set_style : t -> Toffee.Style.t -> unitset_style t style sets the layout style on the underlying renderable.
val pp : Format.formatter -> t -> unitpp ppf t formats t on ppf for debugging.