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