package mosaic

  1. Overview
  2. Docs

Module Mosaic_ui.Line_number

Line-number gutter with per-line colours, signs, and custom numbering.

Line number gutter for code display.

A composite container that pairs a line number gutter with a content area. Children are routed to the content area via Renderable.child_target. On render, the gutter discovers the first child with a Line information provider and draws line numbers accordingly.

The gutter renders line numbers, optional signs, and per-line background colors. Content area colors are applied via a render_before callback on the content node. Setting show_line_numbers to false hides the gutter entirely; it then takes no layout space.

Types

type t

The type for line number gutter containers.

type line_color = {
  1. gutter : Ansi.Color.t;
  2. content : Ansi.Color.t option;
}

The type for per-line background colors. gutter colors the gutter area. content colors the content area; when None, defaults to 80 % brightness of gutter.

type line_sign = {
  1. before : string option;
  2. after : string option;
  3. before_color : Ansi.Color.t option;
  4. after_color : Ansi.Color.t option;
}

The type for gutter signs rendered before and after the line number. Before signs are right-aligned within their column for visual consistency.

Props

module Props : sig ... end

Constructors

val create : parent:Renderable.t -> ?index:int -> ?id:string -> ?style:Toffee.Style.t -> ?visible:bool -> ?z_index:int -> ?opacity:float -> ?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_color) list -> ?line_signs:(int * line_sign) list -> ?line_numbers:(int * int) list -> ?hidden_line_numbers:int list -> unit -> t

create ~parent () is a line number gutter container attached to parent. Optional parameters have the same defaults as Props.make.

Accessors

val node : t -> Renderable.t

node t is t's underlying renderable.

Updating

val apply_props : t -> Props.t -> unit

apply_props t props replaces all properties of t with props and schedules a re-render.