ansi codes printer
This commit is contained in:
7
bin/ansi-codes
Executable file
7
bin/ansi-codes
Executable file
@@ -0,0 +1,7 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import sys,os
|
||||
sys.path.append(os.path.realpath(os.path.join(os.path.dirname(__file__),
|
||||
"..","reporting")))
|
||||
import ansi
|
||||
ansi.demo()
|
||||
@@ -38,13 +38,13 @@ class code:
|
||||
io = '\033[27m'#inverse off
|
||||
st = '\033[9m'#strike on
|
||||
so = '\033[29m'#strike off
|
||||
CLRLIN = '\033[2J'
|
||||
CLR = '\033[2J'
|
||||
CLREND = '\033[K'
|
||||
CLRBEG = '\033[1K'
|
||||
CLRSCR = CLRLIN+"\033[0;0H"
|
||||
CLRSCR = CLR+"\033[0;0H"
|
||||
|
||||
color_keys="K,R,G,B,Y,M,C,W,k,r,g,b,y,m,c,w,S,s,U,u,Z,ic,io,st,so,bk,br,bg,by,bb,bm,bc,bw,CLRLIN,CLREND,CLRBEG,CLRSCR".split(",")
|
||||
color_list=[K,R,G,B,Y,M,C,W,k,r,g,b,y,m,c,w,S,s,U,u,Z,ic,io,st,so,bk,br,bg,by,bb,bm,bc,bw,CLRLIN,CLREND,CLRBEG,CLRSCR]
|
||||
color_keys="K,R,G,B,Y,M,C,W,k,r,g,b,y,m,c,w,S,s,U,u,Z,ic,io,st,so,bk,br,bg,by,bb,bm,bc,bw,CLR,CLREND,CLRBEG,CLRSCR".split(",")
|
||||
color_list=[K,R,G,B,Y,M,C,W,k,r,g,b,y,m,c,w,S,s,U,u,Z,ic,io,st,so,bk,br,bg,by,bb,bm,bc,bw,CLR,CLREND,CLRBEG,CLRSCR]
|
||||
custom_match=re.compile(r'(\${)([0-9;]*[ABCDEFGHJKSTfminsu]+)(})')
|
||||
|
||||
def pos(self,y,x):
|
||||
@@ -101,3 +101,43 @@ class code:
|
||||
|
||||
def get_keys(self):
|
||||
return self.color_keys
|
||||
|
||||
|
||||
|
||||
|
||||
def demo():
|
||||
""" Print all control sequences """
|
||||
c=code()
|
||||
unformatted="""${S}ANSI CODES
|
||||
==========${Z}
|
||||
${S}Fo${U}rm${st}at${u}ti${ic}ng${Z}
|
||||
${S}==========${Z}
|
||||
0 Z Clear format
|
||||
1 S ${S}Strong ${Z} 2 s ${s}Off${Z}
|
||||
4 U ${U}Underline${Z} 24 u Off
|
||||
7 ic ${ic}Inverse${Z} 27 io Off
|
||||
9 st ${st}Strike${Z} 29 so Off
|
||||
${R}Co${G}lo${B}rs${Z}
|
||||
${S}======${Z}
|
||||
30 k ${k}Black ${Z}1 K ${K}Strong ${Z}40 bk ${bk}Background${Z}
|
||||
31 r ${r}Red ${Z}1 R ${R}Strong ${Z}41 br ${br}Background${Z}
|
||||
32 g ${g}Green ${Z}1 G ${G}Strong ${Z}42 bg ${bg}Background${Z}
|
||||
33 y ${y}Yellow ${Z}1 Y ${Y}Strong ${Z}43 by ${by}Background${Z}
|
||||
34 b ${b}Blue ${Z}1 B ${B}Strong ${Z}44 bb ${bb}Background${Z}
|
||||
35 m ${m}Magenta ${Z}1 M ${M}Strong ${Z}45 bm ${bm}Background${Z}
|
||||
36 c ${c}Cyan ${Z}1 C ${C}Strong ${Z}46 bc ${bc}Background${Z}
|
||||
37 w ${w}White ${Z}1 W ${W}Strong ${Z}47 bw ${bw}Background${Z}
|
||||
${S}Clearing and movement
|
||||
${S}=====================${Z}
|
||||
2J CLR Clear screen
|
||||
2J ;H CLRSCR .clear() Clear screen and cursor to upper left
|
||||
K CLREND Clear to end of line
|
||||
1K CLRBEG Clear to beginning of line
|
||||
|
||||
s .save() Save location u .restore() Restore location
|
||||
A .up() Up E .up_line() Up line
|
||||
B .down() Down F .down_line() Down line
|
||||
C .left() Left x;yH .pos() Absolute Position
|
||||
D .right() Right """
|
||||
|
||||
print(c.color_string(unformatted))
|
||||
|
||||
Reference in New Issue
Block a user