about summary refs log tree commit diff
path: root/contrib/example_escs.py
blob: 1d8ced6988eb5a008e13e53553de178955e098b4 (plain) (blame)
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/usr/bin/env python3

def sgr(*args):
    return '\033[' + ';'.join(map(str,args)) + 'm'

def sgr_extended(*args):
    return '\033[' + ':'.join(map(str,args)) + 'm'

def print_heading(t):
    print('\n{}{}{}\n'.format(sgr(1,4), t, sgr()))

print_heading('text style')

print('{}bold{}'.format(sgr(1), sgr(22)))
print('{}faint{}'.format(sgr(2), sgr(22)))
print('{}italic{}'.format(sgr(3), sgr(23)))
print('{}underline{}'.format(sgr(4), sgr(24)))
print('the following is concealed: {}invisible{}'.format(sgr(8), sgr(28)))
print('{}strikethrough{}'.format(sgr(9), sgr(29)))
print('{}double underline{}'.format(sgr(21), sgr(24)))

for s in [30,90,40,100]:
    print_heading(
        '16 color {}{}'.format(
            'bright ' if s > 50 else '',
            'foreground' if s % 3 == 0 else 'background',
        )
    )

    for c in range(8):
        print(
            '{}|{:2}{}'.format(
                sgr(s + c),
                c,
                sgr()
            ),
            end=''
        )

    print('')

for s in [38, 48]:
    section = 'foreground' if s == 38 else 'background'

    print_heading(
        '16 color {}'.format(section)
    )

    for y in range(2):
        for x in range(8):
            c = x + y * 8
            print(
                '{}|{:>2}{}'.format(
                    sgr_extended(s, 5, c),
                    c,
                    sgr(s + 1)
                ),
                end=''
            )

        print('')

    print_heading('6 * 6 * 6 cube color {}'.format(section))

    for y in range(6):
        for x in range(36):
            c = 16 + x + y * 36
            print(
                '{}|{:>3}{}'.format(
                    sgr_extended(s, 5, c),
                    c,
                    sgr(s + 1)
                ),
                end=''
            )
        print('')

    print_heading('grayscale {}'.format(section))

    for c in range(232, 256):
        print(
            '{}|{:>3}{}'.format(
                sgr_extended(s, 5, c),
                c,
                sgr(s + 1)
            ),
            end=''
        )
    print('')


print_heading('16 color combinations')

print('  |' + '|'.join(map(lambda x: '{:<4}'.format(x), range(16))))
for f in range(16):
    print(f'{f:>2}', end='')

    for b in range(16):
        print(
            '{}{}|test{}'.format(
                sgr_extended(38, 5, f),
                sgr_extended(48, 5, b),
                sgr(39, 49)
            ),
            end=''
        )
    print('')