Library
Module
Module type
Parameter
Class
Class type
This module offers basic control of ANSI compliant terminals and the windows shell.
This library is not thread safe.
val black : style
Shortcut for Foreground Black
val red : style
Shortcut for Foreground Black
Shortcut for Foreground Red
val green : style
Shortcut for Foreground Red
Shortcut for Foreground Green
val yellow : style
Shortcut for Foreground Green
Shortcut for Foreground Yellow
val blue : style
Shortcut for Foreground Yellow
Shortcut for Foreground Blue
val magenta : style
Shortcut for Foreground Blue
Shortcut for Foreground Magenta
val cyan : style
Shortcut for Foreground Magenta
Shortcut for Foreground Cyan
val white : style
Shortcut for Foreground Cyan
Shortcut for Foreground White
val default : style
Shortcut for Foreground White
Shortcut for Foreground Default
val on_black : style
Shortcut for Background Black
val on_red : style
Shortcut for Background Black
Shortcut for Background Red
val on_green : style
Shortcut for Background Red
Shortcut for Background Green
val on_yellow : style
Shortcut for Background Green
Shortcut for Background Yellow
val on_blue : style
Shortcut for Background Yellow
Shortcut for Background Blue
val on_magenta : style
Shortcut for Background Blue
Shortcut for Background Magenta
val on_cyan : style
Shortcut for Background Magenta
Shortcut for Background Cyan
val on_white : style
Shortcut for Background Cyan
Shortcut for Background White
val on_default : style
Shortcut for Background White
Shortcut for Background Default
val print_string : style list -> string -> unit
print_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 -> unit
Like print_string
but prints on the standard error.
val printf : style list -> ('a, unit, string, unit) Pervasives.format4 -> 'a
printf 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 erase : loc -> unit
erase 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.
set_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.
move_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
).
move_bol()
moves the cursor to the beginning of the current line. This is useful for progress bars for example.
pos_cursor()
returns a couple (x,y)
giving the current position of the cursor, x >= 1
being the column and y >= 1
the row.
save_cursor()
saves the current position of the cursor.
restore_cursor()
replaces the cursor to the position saved with save_cursor()
.
resize width height
resize the current terminal to the given width
and height
.
size()
returns a pair (width, height)
giving the size of the terminal in character cells.