about summary refs log tree commit diff stats
path: root/yolk.cursor.ss
blob: a61aa2fd241489be4bc3fb5eb799f87b89366be5 (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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
;;; (yolk cursor) --- move the cursor around the terminal

(import (scheme base)
        (scheme case-lambda)
        (yolk common))

(define cursor-home
  (csi "H"))

(define (cursor-move/H x y)
  (csi y ";" x "H"))

(define (cursor-move/f x y)
  (csi y ";" x "f"))

(define-esc-alt-wrapper cursor-move cursor-move-proc
  (cursor-move/H x y))

(define (cursor-up n)
  (csi n "A"))

(define (cursor-down n)
  (csi n "B"))

(define (cursor-right n)
  (csi n "C"))

(define (cursor-left n)
   (csi n "D"))

(define (cursor-down-bol n)
  (csi n "E"))

(define (cursor-up-bol n)
   (csi n "F"))

(define (cursor-move-column n)
  (csi n "G"))

(define cursor-save/dec
  (esc 7))

(define cursor-restore/dec
  (esc 8))

(define cursor-save/sco
  (csi "s"))

(define cursor-restore/sco
  (csi "u"))

(define cursor-save
  (make-parameter cursor-save/dec
                  (parameter-assert string? "Not a string")))

(define cursor-restore
  (make-parameter cursor-restore/dec
                  (parameter-assert string? "Not a string")))

;; (define (get-cursor-postion) ...) ; (csi "6n"), reports as (csi r;cR)