module Terminal:sig..end
Terminal library for Objective-Caml
val title : string -> (unit -> 'a) -> 'atitle t f saves the old window title, sets it to a given string t,
and restores it.
In Windows, the parameter should be encoded as the active code page.
val title_utf8 : string -> (unit -> 'a) -> 'atitle_utf8 t f saves the old window title, sets it to a given UTF-8
encoded string t, and restores it.
In POSIX, it's same as set_title.
typecolor = privateint
Color. The representation is not portable.
val system_16 : red:int -> green:int -> blue:int -> intensity:int -> colorThe 16 system colors.
It's discriminated whether each value of red, green, blue, or
intensity is 0 or not.
val black : color
val dark_red : color
val dark_green : color
val dark_yellow : color
val dark_blue : color
val dark_magenta : color
val dark_cyan : color
val gray : color
val dark_gray : color
val blue : color
val green : color
val cyan : color
val red : color
val magenta : color
val yellow : color
val white : color
val supports_256 : unit -> boolCheck whether the terminal supports 256 color.
val rgb : red:float -> green:float -> blue:float -> colorThe RGB colors. The each parameter should be in 0.0 to 1.0.
val grayscale : float -> colorThe grayscale colors. The parameter should be in 0.0 to 1.0.
typeevent = privatestring
Event. One of an inputed char or string, the terminal window is resized, any special key is typed, any mouse button is clicked, or others.
val escape_sequence_of_event : event -> stringRepresent a given event as escape sequence.
val is_char : event -> boolCheck whether a given event contains some char or not.
val char_of_event : event -> charReturn the char of a given event.
val is_string : event -> boolCheck whether a given event contains some string(non-escape sequence) or not.
val string_of_event : event -> stringReturn the string of a given event.
val is_resized : event -> boolCheck whether a given event means the terminal window has been resized.
It installs the sigwinch handler (in POSIX) or change the console mode (in
Windows) when calling size, set_size, view, or screen.
val size_of_event : event -> int * intReturn the new window size of a given event.
typekey =[ `delete
| `down
| `end_key
| `f1
| `f10
| `f11
| `f12
| `f2
| `f3
| `f4
| `f5
| `f6
| `f7
| `f8
| `f9
| `home
| `insert
| `left
| `pagedown
| `pageup
| `right
| `up ]
Key.
typeshift_state = privateint
Set of shift_key.
val is_key : event -> boolCheck whether a given event contains some key or not.
val key_of_event : event ->
[ `delete
| `down
| `end_key
| `f1
| `f10
| `f11
| `f12
| `f2
| `f3
| `f4
| `f5
| `f6
| `f7
| `f8
| `f9
| `home
| `insert
| `left
| `pagedown
| `pageup
| `right
| `unknown
| `up ]Return the key of a given event.
val shift_of_event : event -> shift_stateReturn the shift state of a given event.
shift_of_event works for key events and also mouse button events.
typeshift_key = privateint
One of shift key, control key, or alt(meta) key.
val empty : shift_stateThe empty set.
val shift : shift_key
val meta : shift_key
val control : shift_key
val alt : shift_key
val mem : shift_key -> shift_state -> boolmem a s is true if a is included in s.
val add : shift_key -> shift_state -> shift_stateadd a s returns a set containing all elements of s plus a.
= [ `button1 | `button2 | `button3 | `released | `wheeldown | `wheelup ]
Mouse button.
val is_clicked : event -> boolCheck whether a given event means some mouse button is clicked.
: event ->
[ `button1
| `button2
| `button3
| `released
| `unknown
| `wheeldown
| `wheelup ]Return the clicked mouse button of a given event.
val position_of_event : event -> int * intReturn the pointed position of a given event.
module Descr:sig..end
Operations on Unix.file_descr.
val is_terminal_out : Stdlib.out_channel -> boolis_terminal_out oc returns true if a given output channel is associated
to the terminal.
val size : Stdlib.out_channel -> int * intsize oc gets the size of the current screen buffer.
val set_size : Stdlib.out_channel -> int -> int -> unitset_size oc width height sets the size of the current screen buffer.
val view : Stdlib.out_channel -> int * int * int * intview oc gets the range of the current view port that is a part of the
current screen buffer.
val position : Stdlib.out_channel -> int * intposition oc gets the cursor position in absolute coordinates.
val set_position : Stdlib.out_channel -> int -> int -> unitset_position oc x y moves the cursor in absolute coordinates.
val move : Stdlib.out_channel -> int -> int -> unitmove oc x y moves the cursor in relative coordinates from the current
position.
val move_to_bol : Stdlib.out_channel -> unit -> unitmove_to_bol oc () moves the cursor to the beginning of the line.
val color : Stdlib.out_channel ->
?reset:bool ->
?bold:bool ->
?underscore:bool ->
?blink:bool ->
?reverse:bool ->
?concealed:bool ->
?foreground:color -> ?background:color -> unit -> unitcolor oc ~reset ~bold ~underscore ~blink ~reverse ~concealed ~foreground
~background () sets the color for writing.
val save : Stdlib.out_channel -> (unit -> 'a) -> 'asave oc f saves and restores the current position and the color.
val clear_screen : Stdlib.out_channel -> unit -> unitclear_screen oc () clears all of a given screen buffer.
val clear_eol : Stdlib.out_channel -> unit -> unitclear_eol oc () clears from the cursor position to the end of the line.
val clear_line : Stdlib.out_channel -> unit -> unitclear_line oc () is a combination of move_to_bol oc () and
clear_eol oc ().
val scroll : Stdlib.out_channel -> int -> unitscroll oc y scrolls the contents in the current view port.
val show_cursor : Stdlib.out_channel -> bool -> unitshow_cursor oc flag show or hide the cursor.
val wrap : Stdlib.out_channel -> bool -> unitwrap oc flag enables or disables line wrapping.
val screen : Stdlib.out_channel ->
?size:int * int ->
?cursor:bool -> ?wrap:bool -> (Stdlib.out_channel -> 'a) -> 'ascreen oc ~size ~cursor ~wrap f saves the current screen buffer,
uses new screen buffer, and restores it.
If ~size is given, same as set_size oc size.
If ~cursor is given, same as show_cursor oc cursor.
If ~wrap:w is given, same as wrap oc w.
val output_substring_utf8 : Stdlib.out_channel -> string -> int -> int -> unitWrite a part of a UTF-8 encoded string to a given output channel.
In POSIX, It's same as Pervasives.output.
val output_string_utf8 : Stdlib.out_channel -> string -> unitWrite a UTF-8 encoded string to a given output channel.
In POSIX, It's same as Pervasives.output_string.
val is_terminal_in : Stdlib.in_channel -> boolis_terminal_in ic returns true if a given input channel is associated to
the terminal.
val buffered_in : Stdlib.in_channel -> intReturn the size of the buffered contents of a given input channel that has not been read yet.
val buffered_line_in : Stdlib.in_channel -> intReturn the size of the buffered contents of a given input channel that has
not been read yet, from current position until '\n'.
If a returned value is max_int, no '\n' is in the buffer.
It means the current line is continuing.
Otherwise, all of the current line is buffered.
val mode : Stdlib.in_channel ->
?echo:bool ->
?canonical:bool -> ?control_c:bool -> ?mouse:bool -> (unit -> 'a) -> 'amode ic ~echo ~canonical ~control_c ~mouse f saves, changes, and restores
the mode of a given input channel.
If ~echo is given, enables or disables echoing.
If ~canonical is given, enables or disables line editing.
If ~control_c is given, accepts or ignores Ctrl+C.
(Use Sys.catch_break to handle Ctrl+C as the exception.)
If ~mouse is given, enables or disables mouse button events.
val input_line_utf8 : Stdlib.in_channel -> stringRead from a given input channel until a newline.
And return a UTF-8 encoded string.
In POSIX, It's same as Pervasives.input_line.
val utf8_of_locale : string -> stringIn windows, encode a string from the active code page to UTF-8. In POSIX, It's no effect.
val locale_of_utf8 : string -> stringIn windows, encode a string from UTF-8 to the active code page. In POSIX, It's no effect.