File indexing completed on 2024-04-28 05:51:05

0001 #!/usr/bin/python3
0002 
0003 # Prints tables with all characters supported by LineBlockCharactersDrawer,
0004 # one for normal weight and one for bold.
0005 
0006 first = 0x2500
0007 last = 0x259F
0008 
0009 cpPerLine = 32
0010 
0011 lineFmt = "\033[48;5;243;38;5;231m"
0012 
0013 def fmtLine(text):
0014     return "{}\033[{}X {}\033[49;39m".format(lineFmt, cpPerLine*2+1, text)
0015 def fmtCh(text):
0016     return "\033[48;5;231;38;5;16m{}{}".format(text, lineFmt)
0017 def fmtRefCh(text):
0018     return "\033[48;5;252;38;5;16m{}{}".format(text, lineFmt)
0019 def setNoWrap(enable):
0020     print("\033[?7l" if enable else "\033[?7h", end="")
0021 def setBold(enable):
0022     print("\033[1m" if enable else "\033[21m", end="")
0023 def fmtBold(text):
0024     return "\033[1m{}\033[21m".format(text)
0025 
0026 refChars = [["|", "│┃"], ["_-", "─━"], ["L", "└┗"], ["+", "┼╋"], ["=F", "╒╬"],
0027             ["/", "╱"], ["\\", "╲"], ["X", "╳"]]
0028 boxes = \
0029     "     +-----------+   *************   ,============,   ╲\\  ╱/\n" \
0030     "     | ┌───────┐ |   @ ┏━━━━━━━┓ @   # ╔════════╗ #    ╲\\╱/ \n" \
0031     "     | │ Light │ |   @ ┃ Heavy ┃ @   # ║ Double ║ #     ╳X  \n" \
0032     "     | └───────┘ |   @ ┗━━━━━━━┛ @   # ╚════════╝ #    ╱/╲\\ \n" \
0033     "     +-----------+   *************   \"============\"   ╱/  ╲\\\n" \
0034 
0035 lines = []
0036 for cp in range(first, last+1):
0037     columnId = int((cp - first) % cpPerLine)
0038     lineId = int((cp - first) / cpPerLine)
0039     if columnId == 0:
0040         lines.append([])
0041     lines[lineId].append(chr(cp))
0042 
0043 setNoWrap(True)
0044 
0045 refCharsLine = " ".join(fmtRefCh(rc[0]) + fmtCh(rc[1]) for rc in refChars)
0046 print(fmtLine("{:8s} line width reference: {}".format("Normal", refCharsLine)))
0047 
0048 print(fmtLine(""))
0049 for line in lines:
0050     print(fmtLine(" ".join(fmtCh(ch) for ch in line)))
0051     print(fmtLine(""))
0052 
0053 print("\n" + boxes)
0054 
0055 setBold(True)
0056 refCharsLine = " ".join(fmtRefCh(rc[0]) + fmtCh(rc[1]) for rc in refChars)
0057 print(fmtLine("{:8s} line width reference: {}".format("Bold", refCharsLine)))
0058 
0059 print(fmtLine(""))
0060 for line in lines:
0061     print(fmtLine(" ".join(fmtCh(ch) for ch in line)))
0062     print(fmtLine(""))
0063 
0064 print("\n" + boxes)
0065 
0066 setBold(False)
0067 setNoWrap(False)