Module Stk.TextviewSource

Textview widget.

Widget to display text buffers.

Additional information can be displayed in a gutter on the left: for line numbers and line markers.

Sourcemodule B = Textbuffer

Logging

This module has its own Logs source "stk.textview". See Log.

include Log.LOG
include Logs.LOG

Log functions

val msg : Logs.level -> 'a Logs.log
val app : 'a Logs.log

app is msg App.

val err : 'a Logs.log

err is msg Error.

val warn : 'a Logs.log

warn is msg Warning.

val info : 'a Logs.log

info is msg Info.

val debug : 'a Logs.log

debug is msg Debug.

val kmsg : (unit -> 'b) -> Logs.level -> ('a, 'b) Logs.msgf -> 'b

Logging result value Errors

val on_error : ?level:Logs.level -> ?header:string -> ?tags:Logs.Tag.set -> pp:(Format.formatter -> 'b -> unit) -> use:('b -> 'a) -> ('a, 'b) result -> 'a
val on_error_msg : ?level:Logs.level -> ?header:string -> ?tags:Logs.Tag.set -> use:(unit -> 'a) -> ('a, [ `Msg of string ]) result -> 'a
val set_level : Logs.level option -> unit

Properties

Sourceval show_cursors : bool Props.prop

Property "show_cursors" to indicate whether cursors should be rendered. Default is true. Inherited.

Sourceval css_show_cursors : bool Css.P.prop
Sourcetype wrap_mode =
  1. | Wrap_none
  2. | Wrap_char

Wrap mode for lines longer than available width:

  • Wrap_none: do not wrap lines.
  • Wrap_char: wrap lines on any char.
Sourceval wrap_modes : wrap_mode list
Sourceval string_of_wrap_mode : wrap_mode -> string
Sourceval wrap_mode_of_string : string -> wrap_mode option
Sourceval wrap_mode_wrapper : wrap_mode Ocf.Wrapper.t
Sourceval wrap_mode : wrap_mode Props.prop

Property "wrap_mode". Default is Wrap_none. Not inherited.

Sourceval css_wrap_mode_prop : ?inherited:bool -> ?def:wrap_mode -> wrap_mode Props.prop -> wrap_mode Css.P.prop
Sourceval css_wrap_mode : wrap_mode Css.P.prop
Sourceval wrap_char_codepoint : int Props.prop

Property "wrap_char_codepoint" to specify which character to display to indicate a line wrap. Default is 45 ('-'). Inherited.

Sourceval css_wrap_char_codepoint : int Css.P.prop
Sourceval show_line_numbers : bool Props.prop

Property "show_line_numbers" to specify whether line numbers must be display in the gutter. Default is false. Inherited.

Sourceval css_show_line_numbers : bool Css.P.prop
Sourceval show_line_markers : bool Props.prop

Property "show_line_markers" to specify whether line markers must be display in the gutter. Default is false. Inherited.

Sourceval css_show_line_markers : bool Css.P.prop
Sourceval gutter_props : Props.props Props.prop

Property "gutter_props" to specify gutter properties, typically background and foreground colors. Inherited.

Sourceval highlight_current_line : bool Props.prop

Property "highlight_current_line" to specify whether current line (the line with the insert cursor) should be highlighted. Default is false. Inherited.

Sourceval css_highlight_current_line : bool Css.P.prop

Textview widget

Sourceclass textview : ?classes:string list option -> ?name:string option -> ?props:Props.t option -> ?wdata: Widget.wdata option -> ?buffer:B.t option -> unit -> object ... end

A widget to display the contents of a text buffer. If no buffer is provided, a new one is created.

Sourceval textview : ?classes:string list -> ?name:string -> ?props:Props.t -> ?wdata:Widget.wdata -> ?buffer:B.t -> ?highlight_current_line:bool -> ?show_cursors:bool -> ?show_line_numbers:bool -> ?show_line_markers:bool -> ?wrap_mode:wrap_mode -> ?editable:bool -> ?tagtheme:string -> ?handle_lang_tags:bool -> ?pack:(Widget.widget -> unit) -> unit -> textview

Convenient function to create a textview. An existing buffer to use can be specified with optional argument buffer. Properties highlight_current_line, show_cursors, show_line_markers, show_line_numbers, wrap_mode, tagtheme and Props.editable can be specified with the corresponding optional arguments. handle_lang_tags indicates whether to add Texttag.Lang.tags as handled tags (default is false. See Widget arguments for other arguments.

Sourceval set_default_key_bindings : ?display_state:(after_handler:bool -> Wkey.keyhit_state -> unit) -> textview -> unit

set_default_key_bindings textview add some key bindings to textview. Optional argument display_state is a function to call to display the state of keyboard hitstate tree. The keybindings added are:

  • C-e: move cursor to line end,
  • S/C-a: move cursor to line start,
  • S/C-right: move cursor to next word end,
  • S/C-left: move cursor to previous word start,
  • C-c: copy selection to clipboard,
  • C-x: cut selection to clipboard,
  • C-v: paste clipboard.