module ANSITerminal:sig..end
This library is not thread safe.
Author(s): Christophe Troestler (Christophe.Troestler@umons.ac.be), Vincent Hugot (vincent.hugot@gmail.com)
type color =
| |
Black |
|||
| |
Red |
|||
| |
Green |
|||
| |
Yellow |
|||
| |
Blue |
|||
| |
Magenta |
|||
| |
Cyan |
|||
| |
White |
|||
| |
Default |
(* |
Default color of the terminal
| *) |
type style =
| |
Reset |
| |
Bold |
| |
Underlined |
| |
Blink |
| |
Inverse |
| |
Hidden |
| |
Foreground of |
| |
Background of |
Blink and Hidden may not work on
every terminal.val black : styleForeground Blackval red : styleForeground Redval green : styleForeground Greenval yellow : styleForeground Yellowval blue : styleForeground Blueval magenta : styleForeground Magentaval cyan : styleForeground Cyanval white : styleForeground Whiteval default : styleForeground Defaultval on_black : styleBackground Blackval on_red : styleBackground Redval on_green : styleBackground Greenval on_yellow : styleBackground Yellowval on_blue : styleBackground Blueval on_magenta : styleBackground Magentaval on_cyan : styleBackground Cyanval on_white : styleBackground Whiteval on_default : styleBackground Defaultval set_autoreset : bool -> unitval print_string : style list -> string -> unitprint_string attr txt prints the string txt with the
attibutes attr. After printing, the attributes are
automatically reseted to the defaults, unless autoreset is turned
off.val prerr_string : style list -> string -> unitprint_string but prints on the standard error.val printf : style list -> ('a, unit, string, unit) Pervasives.format4 -> 'aprintf attr format arg1 ... argN prints the arguments
arg1,...,argN according to format with the attibutes attr.
After printing, the attributes are automatically reseted to the
defaults, unless autoreset is turned off.val eprintf : style list -> ('a, unit, string, unit) Pervasives.format4 -> 'a
val sprintf : style list -> ('a, unit, string) Pervasives.format -> 'aANSITerminal.printf but returns the result in a string. This only
works on ANSI compliant terminals — for which escape sequences are
used — and not under Windows — where system calls are required.
On Windows, it is identical to the standard sprintf.type loc =
| |
Eol |
| |
Above |
| |
Below |
| |
Screen |
val erase : loc -> uniterase Eol clear from the cursor position to the end of the line
without moving the cursor.
erase Above erases everything before the position of the cursor.
erase Below erases everything after the position of the cursor.
erase Screen erases the whole screen.
This function does not modify the position of the cursor.
val set_cursor : int -> int -> unitset_cursor x y puts the cursor at position (x,y), x
indicating the column (the leftmost one being 1) and y being the
line (the topmost one being 1). If x <= 0, the x coordinate
is unchanged; if y <= 0, the y coordinate is unchanged.val move_cursor : int -> int -> unitmove_cursor x y moves the cursor by x columns (to the right
if x > 0, to the left if x < 0) and by y lines (downwards if
y > 0 and upwards if y < 0).val move_bol : unit -> unitmove_bol() moves the cursor to the beginning of the current
line. This is useful for progress bars for example.val pos_cursor : unit -> int * intpos_cursor() returns a couple (x,y) giving the current
position of the cursor, x >= 1 being the column and y >= 1 the
row.val save_cursor : unit -> unitsave_cursor() saves the current position of the cursor.val restore_cursor : unit -> unitrestore_cursor() replaces the cursor to the position saved
with save_cursor().val resize : int -> int -> unitresize width height resize the current terminal to the given
width and height.val size : unit -> int * intsize() returns a pair (width, height) giving the size of the
terminal in character cells.val scroll : int -> unitscroll n scrolls the terminal by n lines, up (creating new
lines at the bottom) if n > 0 and down if n < 0.