package stk

  1. Overview
  2. Docs

Textview widget.

Widget to display text buffers.

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

module B = Textbuffer

Logging

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

include Log.LOG
val log_src : Logs.Src.t
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

Properties

val show_cursors : bool Props.prop

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

type 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.
val wrap_mode_wrapper : wrap_mode Ocf.Wrapper.t
val wrap_mode : wrap_mode Props.prop

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

val 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.

val 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.

val 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.

val gutter_props : Props.props Props.prop

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

val 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.

Textview widget

class textview : ?class_:string option -> ?name:string option -> ?props:Props.t 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.

val textview : ?class_:string -> ?name:string -> ?props:Props.t -> ?buffer:B.t -> ?highlight_current_line:bool -> ?show_cursors:bool -> ?show_line_numbers:bool -> ?show_line_markers:bool -> ?wrap_mode:wrap_mode -> ?editable:bool -> ?theme:string -> ?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, theme and Props.editable can be specified with the corresponding optional arguments. See widget_arguments for other arguments.

val 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.
OCaml

Innovation. Community. Security.