package tty

  1. Overview
  2. Docs
A library for interacting with teletype and terminal emulators

Install

Dune Dependency

Authors

Maintainers

Sources

tty-0.0.1.tbz
sha256=c640c941e1580b6f0eb49abeeb932edc868e9b94d44edac579d18ef0a68cb240
sha512=20875e1eec5e4b78a4416c6235d9eab473f15bc226126eeb8edf355766f7ae9a33541c8518c4022439af1569e3c40b335923e900c56f5f81251d752bdd695e4c

doc/src/tty/escape_seq.ml.html

Source file escape_seq.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
let csi = "\x1b["
let reset_seq = "0"
let bold_seq = "1"
let faint_seq = "2"
let italics_seq = "3"
let underline_seq = "4"
let blink_seq = "5"
let reverse_seq = "7"
let cross_out_seq = "9"
let overline_seq = "53"
let foreground_seq = "38"
let background_seq = "48"
let escape code () = Printf.printf "%s%s%!" csi code

(* Cursor positioning. *)
let cursor_up_seq x = escape (Printf.sprintf "%dA" x)
let cursor_down_seq x = escape (Printf.sprintf "%dB" x)
let cursor_forward_seq x = escape (Printf.sprintf "%dC" x)
let cursor_back_seq x = escape (Printf.sprintf "%dD" x)
let cursor_next_line_seq x = escape (Printf.sprintf "%dE" x)
let cursor_previous_line_seq x = escape (Printf.sprintf "%dF" x)
let cursor_horizontal_seq x = escape (Printf.sprintf "%dG" x)
let cursor_position_seq x y = escape (Printf.sprintf "%d;%dH" x y)
let erase_display_seq x = escape (Printf.sprintf "%dJ" x)
let erase_line_seq x = escape (Printf.sprintf "%dK" x)
let scroll_up_seq x = escape (Printf.sprintf "%dS" x)
let scroll_down_seq x = escape (Printf.sprintf "%dT" x)
let save_cursor_position_seq = escape "s"
let restore_cursor_position_seq = escape "u"
let change_scrolling_region_seq x y = escape (Printf.sprintf "%d;%dr" x y)
let insert_line_seq x = escape (Printf.sprintf "%dL" x)
let delete_line_seq x = escape (Printf.sprintf "%dM" x)

(* Explicit values for EraseLineSeq. *)
let erase_line_right_seq = escape "0K"
let erase_line_left_seq = escape "1K"
let erase_entire_line_seq = escape "2K"

(* Mouse. *)
let enable_mouse_press_seq = escape "?9h"
let disable_mouse_press_seq = escape "?9l"
let enable_mouse_seq = escape "?1000h"
let disable_mouse_seq = escape "?1000l"
let enable_mouse_hilite_seq = escape "?1001h"
let disable_mouse_hilite_seq = escape "?1001l"
let enable_mouse_cell_motion_seq = escape "?1002h"
let disable_mouse_cell_motion_seq = escape "?1002l"
let enable_mouse_all_motion_seq = escape "?1003h"
let disable_mouse_all_motion_seq = escape "?1003l"
let enable_mouse_extended_mode_seq = escape "?1006h"
let disable_mouse_extended_mode_seq = escape "?1006l"
let enable_mouse_pixels_mode_seq = escape "?1016h"
let disable_mouse_pixels_mode_seq = escape "?1016l"

(* Screen. *)
let restore_screen_seq = escape "?47l"
let save_screen_seq = escape "?47h"
let alt_screen_seq = escape "?1049h"
let exit_alt_screen_seq = escape "?1049l"

(* Bracketed paste. *)
let enable_bracketed_paste_seq = escape "?2004h"
let disable_bracketed_paste_seq = escape "?2004l"
let start_bracketed_paste_seq = escape "200~"
let end_bracketed_paste_seq = escape "201~"

(* Session. *)
let set_window_title_seq s = escape (Printf.sprintf "2;%s" s)
let set_foreground_color_seq s = escape (Printf.sprintf "10;%s" s)
let set_background_color_seq s = escape (Printf.sprintf "11;%s" s)
let set_cursor_color_seq s = escape (Printf.sprintf "12;%s" s)
let show_cursor_seq = escape "?25h"
let hide_cursor_seq = escape "?25l"
OCaml

Innovation. Community. Security.