Changeset View
Changeset View
Standalone View
Standalone View
tests/line_block_characters_table.py
- This file was added.
Property | Old Value | New Value |
---|---|---|
File Mode | null | 100755 |
1 | #!/usr/bin/python3 | ||||
---|---|---|---|---|---|
2 | | ||||
3 | # Prints tables with all characters supported by LineBlockCharactersDrawer, | ||||
4 | # one for normal weight and one for bold. | ||||
5 | | ||||
6 | first = 0x2500 | ||||
7 | last = 0x259F | ||||
8 | | ||||
9 | cpPerLine = 32 | ||||
10 | | ||||
11 | lineFmt = "\033[48;5;243;38;5;231m" | ||||
12 | | ||||
13 | def fmtLine(text): | ||||
14 | return "{}\033[{}X {}\033[49;39m".format(lineFmt, cpPerLine*2+1, text) | ||||
15 | def fmtCh(text): | ||||
16 | return "\033[48;5;231;38;5;16m{}{}".format(text, lineFmt) | ||||
17 | def fmtRefCh(text): | ||||
18 | return "\033[48;5;252;38;5;16m{}{}".format(text, lineFmt) | ||||
19 | def setNoWrap(enable): | ||||
20 | print("\033[?7l" if enable else "\033[?7h", end="") | ||||
21 | def setBold(enable): | ||||
22 | print("\033[1m" if enable else "\033[21m", end="") | ||||
23 | def fmtBold(text): | ||||
24 | return "\033[1m{}\033[21m".format(text) | ||||
25 | | ||||
26 | refChars = [["|", "│┃"], ["_-", "─━"], ["L", "└┗"], ["+", "┼╋"], ["=F", "╒╬"], | ||||
27 | ["/", "╱"], ["\\", "╲"], ["X", "╳"]] | ||||
28 | boxes = \ | ||||
29 | " +-----------+ ************* ,============, ╲\\ ╱/\n" \ | ||||
30 | " | ┌───────┐ | @ ┏━━━━━━━┓ @ # ╔════════╗ # ╲\\╱/ \n" \ | ||||
31 | " | │ Light │ | @ ┃ Heavy ┃ @ # ║ Double ║ # ╳X \n" \ | ||||
32 | " | └───────┘ | @ ┗━━━━━━━┛ @ # ╚════════╝ # ╱/╲\\ \n" \ | ||||
33 | " +-----------+ ************* \"============\" ╱/ ╲\\\n" \ | ||||
34 | | ||||
35 | lines = [] | ||||
36 | for cp in range(first, last+1): | ||||
37 | columnId = int((cp - first) % cpPerLine) | ||||
38 | lineId = int((cp - first) / cpPerLine) | ||||
39 | if columnId == 0: | ||||
40 | lines.append([]) | ||||
41 | lines[lineId].append(chr(cp)) | ||||
42 | | ||||
43 | setNoWrap(True) | ||||
44 | | ||||
45 | refCharsLine = " ".join(fmtRefCh(rc[0]) + fmtCh(rc[1]) for rc in refChars) | ||||
46 | print(fmtLine("{:8s} line width reference: {}".format("Normal", refCharsLine))) | ||||
47 | | ||||
48 | print(fmtLine("")) | ||||
49 | for line in lines: | ||||
50 | print(fmtLine(" ".join(fmtCh(ch) for ch in line))) | ||||
51 | print(fmtLine("")) | ||||
52 | | ||||
53 | print("\n" + boxes) | ||||
54 | | ||||
55 | setBold(True) | ||||
56 | refCharsLine = " ".join(fmtRefCh(rc[0]) + fmtCh(rc[1]) for rc in refChars) | ||||
57 | print(fmtLine("{:8s} line width reference: {}".format("Bold", refCharsLine))) | ||||
58 | | ||||
59 | print(fmtLine("")) | ||||
60 | for line in lines: | ||||
61 | print(fmtLine(" ".join(fmtCh(ch) for ch in line))) | ||||
62 | print(fmtLine("")) | ||||
63 | | ||||
64 | print("\n" + boxes) | ||||
65 | | ||||
66 | setBold(False) | ||||
67 | setNoWrap(False) |