package mosaic
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=9e4e90d17f9b2af1b07071fe425bc2c519c849c4f1d1ab73cde512be2d874849
sha512=06e9c4a741590942e81a27738d0b5c0413fafec8cf3b7dae047ad69f155e7b718aa4223818dc161b7d028efffcfd3365905e264d6fd31d453910ddfa91dcf9b9
doc/mosaic.ui/Mosaic_ui/Code/index.html
Module Mosaic_ui.Code
Code display with syntax highlighting, wrapping, and selection.
Syntax-highlighted code display.
A leaf renderable for displaying source code with optional pre-computed syntax highlighting. Uses Text_buffer.t for text storage and Text_surface.t for rendering.
Code differs from Text in its defaults: wrapping defaults to `None, tab width defaults to 4, it accepts pre-computed styled spans, and it registers as a Renderable.line_info provider.
Types
Props
module Props : sig ... endConstructors
val create :
parent:Renderable.t ->
?index:int ->
?id:string ->
?style:Toffee.Style.t ->
?visible:bool ->
?z_index:int ->
?opacity:float ->
?content:string ->
?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 -> unit) ->
unit ->
tcreate ~parent () is a new code display renderable attached to parent with:
indexis the child insertion index inparent.idis an optional identifier for the node.styleis the layout style.visiblecontrols initial visibility.z_indexis the stacking order.opacityis the opacity. Defaults to1.0.contentis the plain source code text. Defaults to"".spansare pre-computed styled spans. Defaults to[].text_styleis the base text style. Defaults toAnsi.Style.default.wrapis the wrapping mode. Defaults to`None.tab_widthis the tab stop width in columns. Defaults to4.truncatecontrols whether long lines are truncated with an ellipsis. Defaults tofalse.selectablecontrols whether text can be selected. Defaults totrue.selection_bgis the selection background color.selection_fgis the selection foreground color.
See also Props.make for the code-specific props.
Accessors
val node : t -> Renderable.tnode t is t's underlying Renderable.t node.
val buffer : t -> Text_buffer.tbuffer t is t's backing Text_buffer.t.
val surface : t -> Text_surface.tsurface t is t's Text_surface.t.
Content
val set_content : t -> string -> unitset_content t s sets the plain code content to s. Clears any existing styled spans.
val set_spans : t -> Text_buffer.span list -> unitset_spans t spans sets pre-computed styled spans. These override plain content display.
val set_on_selection : t -> ((int * int) option -> unit) option -> unitset_on_selection t f sets the selection-change callback used when selectable = true. None clears it.
Props application
apply_props t props applies props to t, updating content, spans, style, and wrapping as specified.
Query
val line_count : t -> intline_count t is the number of logical lines in t.
val display_line_count : t -> intdisplay_line_count t is the number of display lines in t after wrapping.