2021-11-07 02:48:08 +00:00
|
|
|
#!/usr/bin/python
|
2022-07-05 09:40:11 +00:00
|
|
|
# https://stackoverflow.com/questions/4842424/list-of-ansi-color-escape-sequences/33206814#33206814
|
2021-11-07 02:48:08 +00:00
|
|
|
|
|
|
|
print("\\033[XXm")
|
2023-07-27 15:16:41 +00:00
|
|
|
print("-- Use Ctrl-V ESC if not using printf")
|
2021-11-07 02:48:08 +00:00
|
|
|
|
|
|
|
for i in range(30,37+1):
|
2022-07-05 09:40:11 +00:00
|
|
|
print("\033[%dm%d\t\t\033[%dm%d" % (i,i,i+30,i+30));
|
2021-11-07 02:48:08 +00:00
|
|
|
|
2022-02-10 14:59:41 +00:00
|
|
|
print("\033[39m\\033[39m - Reset colour (0 to reset all)")
|
2021-11-07 02:48:08 +00:00
|
|
|
print("\\033[2K - Clear Line")
|
|
|
|
print("\\033[<L>;<C>H OR \\033[<L>;<C>f puts the cursor at line L and column C.")
|
|
|
|
print("\\033[<N>A Move the cursor up N lines")
|
|
|
|
print("\\033[<N>B Move the cursor down N lines")
|
|
|
|
print("\\033[<N>C Move the cursor forward N columns")
|
|
|
|
print("\\033[<N>D Move the cursor backward N columns")
|
|
|
|
print("\\033[2J Clear the screen, move to (0,0)")
|
|
|
|
print("\\033[K Erase to end of line")
|
|
|
|
print("\\033[s Save cursor position")
|
|
|
|
print("\\033[u Restore cursor position")
|
|
|
|
print(" ")
|
2022-07-05 09:40:11 +00:00
|
|
|
|
|
|
|
def illustrate(command, *text):
|
|
|
|
print("\033[", command, "m\\033[", command, "m - ", *text, sep="", end="\t")
|
|
|
|
|
2023-07-27 15:16:41 +00:00
|
|
|
def toggle(command, text, add = 20):
|
2022-07-05 09:40:11 +00:00
|
|
|
illustrate(command, text, " on")
|
2023-07-27 15:16:41 +00:00
|
|
|
illustrate(command + add, text, " off\033[0m")
|
2022-07-05 09:40:11 +00:00
|
|
|
print()
|
2023-07-27 15:16:41 +00:00
|
|
|
toggle(1, "Bold", 21)
|
2022-07-05 09:40:11 +00:00
|
|
|
toggle(2, "Grey")
|
|
|
|
toggle(3, "Italic")
|
|
|
|
toggle(4, "Underline")
|
|
|
|
toggle(7, "Highlight")
|
|
|
|
toggle(9, "Strike")
|