module Lwt_term:sig..end
val with_raw_mode : (unit -> 'a Lwt.t) -> 'a Lwt.twith_raw_mode f executes f while the terminal is in ``raw
mode''. Raw mode means that character are returned as the user
type them (otherwise only complete line are returned to the
program).
If the terminal is already in raw mode, it just calls f.
val raw_mode : unit -> boolval enter_drawing_mode : unit -> unit Lwt.tval leave_drawing_mode : unit -> unit Lwt.tval show_cursor : unit -> unit Lwt.tshow_cursor () makes the cursor visibleval hide_cursor : unit -> unit Lwt.thide_cursor () makes the cursor invisibleval clear_screen : unit -> unit Lwt.tclear_screen () clears the entire screenval clear_line : unit -> unit Lwt.tclear_line () clears the current lineval goto_beginning_of_line : int -> unit Lwt.tgoto_beginning_of_line n put the cursor at the beginning of
the nth previous line.
goto_beginning_of_line 0 goes to the beginning of the current linegoto_beginning_of_line 1 goes to the beginning of the previous linetype size = {
|
lines : |
|
columns : |
val size : size React.signalval columns : int React.signalval lines : int React.signalval parse_key_raw : Text.t Lwt_stream.t -> Text.t Lwt.tparse_key_raw st recognize escape sequence in a stream of
unicode character.
It returns either:
"a", "é", ...type key =
| |
Key of |
(* | A unicode character or an uninterpreted sequence | *) |
| |
Key_up |
|||
| |
Key_down |
|||
| |
Key_left |
|||
| |
Key_right |
|||
| |
Key_f of |
|||
| |
Key_next_page |
|||
| |
Key_previous_page |
|||
| |
Key_home |
|||
| |
Key_end |
|||
| |
Key_insert |
|||
| |
Key_delete |
|||
| |
Key_control of |
(* | A control key | *) |
This list is not exhaustive, but at least it should works on all
terminals:
val string_of_key : key -> stringstring_of_key key string representation of a keyval control_mapping : (int * char) listHere is the list of control keys:
+------+-------+------+------+------+-------+------------------------------------------------+
| Char | Oct | Dec | Name | Hex | Key | Comment |
+------+-------+------+------+------+-------+------------------------------------------------+
| '@' | 0o00 | 0 | NUL | 0x00 | ^@ \0 | Null byte |
| 'a' | 0o01 | 1 | SOH | 0x01 | ^A | Start of heading |
| 'b' | 0o02 | 2 | STX | 0x02 | ^B | Start of text |
| 'c' | 0o03 | 3 | ETX | 0x03 | ^C | End of text |
| 'd' | 0o04 | 4 | EOT | 0x04 | ^D | End of transmission |
| 'e' | 0o05 | 5 | ENQ | 0x05 | ^E | Enquiry |
| 'f' | 0o06 | 6 | ACK | 0x06 | ^F | Acknowledge |
| 'g' | 0o07 | 7 | BEL | 0x07 | ^G | Ring terminal bell |
| 'h' | 0o10 | 8 | BS | 0x08 | ^H \b | Backspace |
| 'i' | 0o11 | 9 | HT | 0x09 | ^I \t | Horizontal tab |
| 'j' | 0o12 | 10 | LF | 0x0a | ^J \n | Line feed |
| 'k' | 0o13 | 11 | VT | 0x0b | ^K | Vertical tab |
| 'l' | 0o14 | 12 | FF | 0x0c | ^L \f | Form feed |
| 'm' | 0o15 | 13 | CR | 0x0d | ^M \r | Carriage return |
| 'n' | 0o16 | 14 | SO | 0x0e | ^N | Shift out |
| 'o' | 0o17 | 15 | SI | 0x0f | ^O | Shift in |
| 'p' | 0o20 | 16 | DLE | 0x10 | ^P | Data link escape |
| 'q' | 0o21 | 17 | DC1 | 0x11 | ^Q | Device control 1 (XON) |
| 'r' | 0o22 | 18 | DC2 | 0x12 | ^R | Device control 2 |
| 's' | 0o23 | 19 | DC3 | 0x13 | ^S | Device control 3 (XOFF) |
| 't' | 0o24 | 20 | DC4 | 0x14 | ^T | Device control 4 |
| 'u' | 0o25 | 21 | NAK | 0x15 | ^U | Negative acknowledge |
| 'v' | 0o26 | 22 | SYN | 0x16 | ^V | Synchronous idle |
| 'w' | 0o27 | 23 | ETB | 0x17 | ^W | End of transmission block |
| 'x' | 0o30 | 24 | CAN | 0x18 | ^X | Cancel |
| 'y' | 0o31 | 25 | EM | 0x19 | ^Y | End of medium |
| 'z' | 0o32 | 26 | SUB | 0x1a | ^Z | Substitute character |
| '[' | 0o33 | 27 | ESC | 0x1b | ^[ | Escape |
| '\' | 0o34 | 28 | FS | 0x1c | ^\ | File separator, Information separator four |
| ']' | 0o35 | 29 | GS | 0x1d | ^] | Group separator, Information separator three |
| '^' | 0o36 | 30 | RS | 0x1e | ^^ | Record separator, Information separator two |
| '_' | 0o37 | 31 | US | 0x1f | ^_ | Unit separator, Information separator one |
| '?' | 0o177 | 127 | DEL | 0x7f | ^? | Delete |
+------+-------+------+------+------+-------+------------------------------------------------+
val key_enter : keykey_enter = Key_control 'j'val key_escape : keykey_escape = Key_control '['val key_tab : keykey_escape = Key_control 'i'val key_backspace : keykey_backspace = Key_control '?'val sequence_mapping : (Text.t * key) listval decode_key : Text.t -> keyval standard_input : Text.t Lwt_stream.tLwt_term.read_keyval read_key : unit -> key Lwt.tLwt_term.standard_inputtypecolor =int
val set_color : color -> int * int * int -> unit Lwt.tset_color num (red, green, blue) sets the three components of
the color number numval default : colorval black : colorval red : colorval green : colorval yellow : colorval blue : colorval magenta : colorval cyan : colorval white : colorval lblack : colorval lred : colorval lgreen : colorval lyellow : colorval lblue : colorval lmagenta : colorval lcyan : colorval lwhite : colortype styled_text_instruction =
| |
Text of |
(* | Some text | *) |
| |
Reset |
(* | Resets all styles to default | *) |
| |
Bold |
|||
| |
Underlined |
|||
| |
Blink |
|||
| |
Inverse |
|||
| |
Hidden |
|||
| |
Foreground of |
|||
| |
Background of |
typestyled_text =styled_text_instruction list
val textf : ('a, unit, string, styled_text_instruction) Pervasives.format4 -> 'atextf fmt formats a texts with fmt and returns Text txtval text : Text.t -> styled_text_instructionval reset : styled_text_instructionval bold : styled_text_instructionval underlined : styled_text_instructionval blink : styled_text_instructionval inverse : styled_text_instruction : styled_text_instructionval fg : color -> styled_text_instructionfg col = Foreground colval bg : color -> styled_text_instructionbg col = Background colval strip_styles : styled_text -> Text.tval styled_length : styled_text -> int
styled_length st = Text.length (strip_styles st)
val write_styled : Lwt_text.output_channel -> styled_text -> unit Lwt.twrite_styled oc st writes st on oc using escape
sequences.val printc : styled_text -> unit Lwt.tprintc st prints the given styled text on standard output. If
stdout is not a tty, then styles are stripped.
The text is encoded to the system encoding before being
output.
val eprintc : styled_text -> unit Lwt.tprintc but prints on stderr.val printlc : styled_text -> unit Lwt.tprintlc st prints st, then reset styles and prints a
newlineval eprintlc : styled_text -> unit Lwt.tprintlc but prints on stderrtype style = {
|
bold : |
|
underlined : |
|
blink : |
|
inverse : |
|
: |
|
foreground : |
|
background : |
type point = {
|
char : |
(* | The character. | *) |
|
style : |
(* | The character style | *) |
val blank : pointval render : point array array -> unit Lwt.tval render_update : point array array -> point array array -> unit Lwt.trender_update displayed to_display does the same as render
to_display but assumes that displayed contains the current
displayed text. This reduces the amount of text sent to the
terminal.module Zone:sig..end
module Draw:sig..end