package ansifmt
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=7bd5aff4eb547ca9bbc50cda6fa71af016673fbed0b0913b6c7bf5fce4688459
sha512=1042f4d0ae6d02ab90c1034d839f7b6d30980983b6192cb6c4c18dce030312693a82edbc37e5fa70acf4d1713f0875c3e7e2b5ff12fcac5c64737465c5e72def
doc/ansifmt/Ansifmt/Fmt/index.html
Module Ansifmt.FmtSource
A string which components can be styled with ANSI escape sequences.
include Rich_string.TYPE with type Enricher.t = Ansi.t
module Enricher : Rich_string.ENRICHER with type t = Ansi.tThe enricher.
The type of a rich string.
rs1 = rs2 determines whether rs1 and rs2 are equal.
IMPORTANT: no pruning or optimization is performed. This means that two rich strings that render the same might not be considered equal.
rs1 ++ rs2 appends rs2 at the end of rs1.
It is equivalent to the built-in string operator ^.
# print (String "hello" ++ String "world")
"helloworld"
- : unit = ()string s lifts the built-in string s to the enriched world.
For example, if the enricher is an ANSI style type, this enables the ability to stylize s.
enrich enrichment rs adds the enrichment to the rich string rs.
For example, if the enricher is an ANSI style type, this translates to adding a new style to s.
join ?on:sep rss concatenates all rss into one, separated by sep. By default, sep is a single space.
It is equivalent to the built-in string function String.concat.
flatten rss concatenates all rss into one.
It is equivalent to join~on:Empty rss.
join_lines rss concatenates all rss into one, separated by line feeds.
It is equivalent to join~on:(String "\n") rss.
stylize ansi rs adds the ansi escape sequence to the rich string rs. Synonym of enrich.
prune_styled rs removes every ANSI escape sequence from the rich string rs.
render ~with_styles rs generates a built-in string from the rich string rs that includes ANSI escape sequences if with_styles is true.
val print :
?out:out_channel ->
?ending:t option ->
?with_styles:[< `Always | `Auto | `Never Auto ] ->
t ->
unitprint ?out ?ending ?with_styles rs writes the rich string rs to the out channel (defaults to stdout), optionally appending ending (defaults to a newline), optionally including ANSI escape sequences (defaults to doing it if out is a TTY).