package printbox-text

  1. Overview
  2. Docs
On This Page
  1. Render to Text
Text renderer for printbox, using unicode edges

Install

dune-project
 Dependency

Authors

Maintainers

Sources

v0.6.1.tar.gz
md5=6e065332d7db622572bd963dbd530589
sha512=7c0882333d2b297c235ee73f09e8b95cdd6013909db0f1b7e07a1b90153e6a3e68249715c90030e033ced6ab3a40aab41d4470d686164676acb544ccbe6ba715

doc/printbox-text/PrintBox_text/index.html

Module PrintBox_textSource

Render to Text

This module should be used to output boxes directly to a terminal, or another area of monospace text

Sourceval set_string_len : (String.t -> int -> int -> int) -> unit

Set which function is used to compute string length. Typically to be used with a unicode-sensitive length function. An example of such a function for utf8 encoded strings is the following (it uses the Uutf and Uucp libraries):

  let string_leng s i len =
    Uutf.String.fold_utf_8 ~pos:i ~len
      (fun n _ c -> n+ max 0 (Uucp.Break.tty_width_hint c)) 0 s

Note that this function assumes there is no newline character in the given string.

  • since 0.3, this is also used in [printbox_unicode] to basically install the code above
Sourceval to_string : PrintBox.t -> string

Returns a string representation of the given structure.

  • parameter style

    if true, emit ANSI codes for styling (default true) (@since 0.3)

Sourceval to_string_with : style:bool -> PrintBox.t -> string

Returns a string representation of the given structure, with style.

  • parameter style

    if true, emit ANSI codes for styling

  • since 0.3
Sourceval output : ?style:bool -> ?indent:int -> out_channel -> PrintBox.t -> unit

Outputs the given structure on the channel.

  • parameter indent

    initial indentation to use

  • parameter style

    if true, emit ANSI codes for styling (default true) (@since 0.3)

Pretty-print the box into this formatter.

  • since 0.2
Sourceval pp_with : style:bool -> Format.formatter -> PrintBox.t -> unit

Pretty-print the box into this formatter, with style.

  • parameter style

    if true, emit ANSI codes for styling

  • since 0.3