ANSI Test.ipynb
560 lines
| 94.9 KiB
| text/plain
|
TextLexer
This notebook tests the processing of ANSI and VT100 color escapes
In [5]:
from __future__ import print_function
In [41]:
ESC = '\x1b['
RESET = ESC + "00m"
Plain ANSI 16-color
In [9]:
for bg in range(40,48):
for fg in range(30,38):
print ("{ESC}01;{bg};{fg}mtext {RESET}".format(**locals()), end='')
print ()
256-color¶
In [27]:
t = "{ESC}00;38;5;{i}m{i:03} {RESET}"
for i in range(16):
print (t.format(**locals()), end='')
if i % 8 == 7:
print ()
print ()
for i in range(16,232):
print (t.format(**locals()), end='')
if (i-16) % 6 == 5:
print ()
if (i-16) % 36 == 35:
print ()
print ()
for i in range(232,256):
print (t.format(**locals()), end='')
if (i-232) % 12 == 11:
print ()
print ()
256-color background¶
In [29]:
t = "{ESC}00;48;5;{i}m{i:03} {RESET}"
for i in range(16):
print (t.format(**locals()), end='')
if i % 8 == 7:
print ()
print ()
for i in range(16,232):
print (t.format(**locals()), end='')
if (i-16) % 6 == 5:
print ()
if (i-16) % 36 == 35:
print ()
print ()
for i in range(232,256):
print (t.format(**locals()), end='')
if (i-232) % 12 == 11:
print ()
print ()
256-color background and foreground¶
In [42]:
t = "{ESC}00;48;5;{bg};38;5;{fg}m{fg:03} on {bg:03} {RESET}"
for bg in [2, 57, 160, 246]:
for fg in [165, 102, 252, 9]:
print (t.format(**locals()), end='')
print()
24-bit RGB¶
In [48]:
steps = range(0,256,30)
t = "{ESC}00;38;2;{r};{g};{b}m{r:03}|{g:03}|{b:03} {RESET}"
for r in steps:
for g in steps:
for b in steps:
print (t.format(**locals()), end='')
print()
print()
24-bit RGB background¶
In [47]:
steps = range(0,256,30)
t = "{ESC}00;48;2;{r};{g};{b}m{r:03}|{g:03}|{b:03} {RESET}"
for r in steps:
for g in steps:
for b in steps:
print (t.format(**locals()), end='')
print()
print()