blob: 838b25a8abd8a20ca637b270647c75a65a0389fb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
let cursors = [| '|'; '/'; '-'; '\\' |]
let pos = ref 0
let update_cursor () =
if Unix.(isatty stdout) then (
Printf.printf "%c[?25l%c[1D%c[0K%c" (char_of_int 27) (char_of_int 27)
(char_of_int 27) (Array.get cursors !pos);
pos := (!pos + 1) mod Array.length cursors)
let close_cursor () =
if Unix.(isatty stdout) then
Printf.printf "%c[?25h%c[1D%c[0K\n%!" (char_of_int 27) (char_of_int 27)
(char_of_int 27)
let clear_line () =
if Unix.(isatty stdout) then Printf.printf "%c[2K\r%!" (char_of_int 27)
|