ansi.w 916 Bytes
Newer Older
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

define ansi [

    0 const black
    1 const red
    2 const green
    3 const yellow
    4 const blue
    5 const magenta
    6 const cyan
    7 const white
    define bright [ upquote call 8 add ]

    define reset        [ "\e[0m" print ]
    define bold         [ "\e[1m" print ]
    define faint        [ "\e[2m" print ]
    define italic       [ "\e[3m" print ]
    define underline    [ "\e[4m" print ]
    define slow-blink   [ "\e[5m" print ]
    define fast-blink   [ "\e[6m" print ]
    define reverse      [ "\e[7m" print ]

    define cursor-save    [ "\e[s" print ]
    define cursor-restore [ "\e[u" print ]

    define fg [
        ->string
        "\e[38;5;" swap string-append
        "m" string-append
        print
    ]

    define bg [
        ->string
        "\e[48;5;" swap string-append
        "m" string-append
        print
    ]

    upquote eval
]
10's avatar
10 committed
42
export-name ansi
43
44
45
46

; vi: ft=scheme