-
Notifications
You must be signed in to change notification settings - Fork 2
/
ansi_table.py
79 lines (57 loc) · 1.44 KB
/
ansi_table.py
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
# Enable ANSI graphics for Windows DOS prompt
import colorama
colorama.init()
# --- Print a table of ANSI characters
print("Decimal Hex Character")
for i in range(106, 121):
char = chr(i)
print("{:3} 0x{:0x} \x1b(0{}\x1b(B ".format(i, i, char))
print()
print()
# --- Print a sine wave
# Lines down
for i in range(111, 116):
char = chr(i)
print("\x1b(0{}\x1b(B".format(char), end="")
# Lines up
for i in range(115, 110, -1):
char = chr(i)
print("\x1b(0{}\x1b(B".format(char), end="")
# Lines down
for i in range(111, 116):
char = chr(i)
print("\x1b(0{}\x1b(B".format(char), end="")
print()
print()
# --- Print a box with text in it
# Top-right corner
char = chr(108)
print("\x1b(0{}\x1b(B".format(char), end="")
# Horizontal line
for i in range(10):
char = chr(113)
print("\x1b(0{}\x1b(B".format(char), end="")
# Top-left corner
char = chr(107)
print("\x1b(0{}\x1b(B".format(char), end="")
print()
# Vertical line
char = chr(120)
print("\x1b(0{}\x1b(B".format(char), end="")
# Text in the box
print(" ANSI Box ", end="")
# Vertical line
char = chr(120)
print("\x1b(0{}\x1b(B".format(char), end="")
print()
# Bottom-left corner
char = chr(109)
print("\x1b(0{}\x1b(B".format(char), end="")
# Horizontal line
for i in range(10):
char = chr(113)
print("\x1b(0{}\x1b(B".format(char), end="")
# Bottom-right corner
char = chr(106)
print("\x1b(0{}\x1b(B".format(char), end="")
print()