Kitty Graphics Protocol in OCaml
terminal
graphics
ocaml
1type t =
2 [ `All_visible
3 | `By_id of int * int option
4 | `By_number of int * int option
5 | `At_cursor
6 | `At_cell of int * int
7 | `At_cell_z of int * int * int
8 | `By_column of int
9 | `By_row of int
10 | `By_z_index of int
11 | `By_id_range of int * int
12 | `Frames ]
13
14let to_char ~free : t -> char =
15 let base = function
16 | `All_visible -> 'a'
17 | `By_id _ -> 'i'
18 | `By_number _ -> 'n'
19 | `At_cursor -> 'c'
20 | `At_cell _ -> 'p'
21 | `At_cell_z _ -> 'q'
22 | `By_column _ -> 'x'
23 | `By_row _ -> 'y'
24 | `By_z_index _ -> 'z'
25 | `By_id_range _ -> 'r'
26 | `Frames -> 'f'
27 in
28 fun t ->
29 let c = base t in
30 if free then Char.uppercase_ascii c else c