package lambda-term
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=5b77cbe096d56ae9157cb1fb55fb4e9028c89e841b1d2bfad4f13d8a1395db3c
sha512=d7968ad000c9c7e899ffb7fdd0016009f41c71d9fad4897decbe66ea24140ab1ee8428fd550c7b8016e7f6343f41e7abd53b52b5f2bf6bb85b4de64f12ac9161
doc/lambda-term/LTerm_text/index.html
Module LTerm_text
Source
Styled text.
Type of a string with styles for each characters.
Conversions
Creates a styled string from a string. All characters of the string have no style.
Returns the string part of a styled string.
Creates a styled string from a utf8 string. All characters of the string have no style.
Creates a styled string from a Zed_string. All characters of the string have no style. The string may contain invalid sequences, in which case invalid bytes are escaped with the syntax \yXX
.
Creates a styled string from a string. All characters of the string have no style. The string may contain invalid UTF-8 sequences, in which case invalid bytes are escaped with the syntax \yXX
.
Creates a styled string from a rope.
Returns the string part of a styled string as a rope.
stylise string style
creates a styled string with all styles set to style
.
Parenthesis matching
val stylise_parenthesis :
t ->
?paren:(Zed_char.t * Zed_char.t) list ->
int ->
LTerm_style.t ->
unit
stylise_parenthesis text ?paren pos style
searchs for parenthesis group starting or ending at pos
and apply them the style style
. paren
is the list of parenthesis recognized.
Markup strings
Markup strings are used to conveniently define styled strings.
type item =
| S of Zed_utf8.t
(*A UTF-8 encoded string.
*)| R of Zed_rope.t
(*A rope.
*)| B_bold of bool
(*Begins bold mode.
*)| E_bold
(*Ends bold mode.
*)| B_underline of bool
(*Begins underlined mode.
*)| E_underline
(*Ends underlined mode.
*)| B_blink of bool
(*Begins blinking mode.
*)| E_blink
(*Ends blinking mode.
*)| B_reverse of bool
(*Begins reverse video mode.
*)| E_reverse
(*Ends reverse video mode.
*)| B_fg of LTerm_style.color
(*Begins foreground color.
*)| E_fg
(*Ends foreground color.
*)| B_bg of LTerm_style.color
(*Begins background color.
*)| E_bg
(*Ends background color.
*)
Type of an item in a markup string.
Styled formatters
val make_formatter :
?read_color:(Format.tag -> LTerm_style.t) ->
unit ->
(unit -> t) * Format.formatter
Create a formatter on a styled string. Returns a tuple get_content, fmt
. Calling get_content ()
will flush the formatter and output the resulting styled string.
If a read_color
function is provided, Format's tag are enabled and read_color
is used to transform tags into styles.
val pp_with_style :
(LTerm_style.t -> Format.tag) ->
LTerm_style.t ->
('b, Format.formatter, unit, unit) format4 ->
Format.formatter ->
'b
pp_with_style f
will create a pretty printer analogous to stylise
, using f to encode style into tags. Will only work on a formatter with tag enabled.
val styprintf :
?read_color:(Format.tag -> LTerm_style.t) ->
('a, Format.formatter, unit, t) format4 ->
'a
Equivalent of Format.sprintf
for styled strings.
val kstyprintf :
?read_color:(Format.tag -> LTerm_style.t) ->
(t -> 'a) ->
('b, Format.formatter, unit, 'a) format4 ->
'b
Equivalent of Format.ksprintf
for styled strings.