blob: 880bbdb3ac0dbe6fa430eeaa62bbd0761f10d85b (
plain)
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
|
;; https://invisible-island.net/xterm/ctlseqs/ctlseqs.html
;; Clear the screen better:
;; https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-The-Alternate-Screen-Buffer
(define csi-lead "\x1b;[")
(define (str-csi . args)
(apply string-append csi-lead args))
(define (csi-command! . args)
(write-string (apply str-csi args))
(flush-output-port))
; These are xterm things, but they are widely adopted
(define (enable-alternate-buffer!)
(csi-command! "?1049h"))
(define (disable-alternate-buffer!)
(csi-command! "?1049l"))
(define (erase-screen!) (csi-command! "2J"))
(define (move-cursor! x y)
"Also valid with CSI<L>;<C>f being <L> and <C> line number and column
number respectively. In ttys, cursor starts at 1,1"
(csi-command! (number->string (+ y 1)) ";" (number->string (+ 1 x)) "H"))
(define (hide-cursor!)
(csi-command! "?25l"))
(define (show-cursor!)
(csi-command! "?25h"))
(define (tui-initialize!)
(enable-alternate-buffer!)
(move-cursor! 0 0))
(define (tui-deinitialize!)
(disable-alternate-buffer!))
|