markslider python3 upgrades
This commit is contained in:
@@ -10,7 +10,7 @@ class code:
|
||||
M="\033[1;35m"
|
||||
C="\033[1;36m"
|
||||
W="\033[1;37m"
|
||||
|
||||
|
||||
k="\033[0;30m"
|
||||
r="\033[0;31m"
|
||||
g="\033[0;32m"
|
||||
@@ -19,7 +19,7 @@ class code:
|
||||
m="\033[0;35m"
|
||||
c="\033[0;36m"
|
||||
w="\033[0;37m"
|
||||
|
||||
|
||||
bk="\033[40m"
|
||||
br="\033[41m"
|
||||
bg="\033[42m"
|
||||
@@ -42,11 +42,11 @@ class code:
|
||||
CLREND = '\033[K'
|
||||
CLRBEG = '\033[1K'
|
||||
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,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):
|
||||
""" Go to absolute position """
|
||||
return "\033["+str(y)+";"+str(x)+"H"
|
||||
@@ -57,6 +57,7 @@ class code:
|
||||
def posprint(self, y,x,s):
|
||||
""" Print string at a location """
|
||||
sys.stdout.write( self.pos(y,x) + str(s) )
|
||||
self.flush()
|
||||
|
||||
def clear(self):
|
||||
sys.stdout.write( self.CLRSCR+self.pos(0,0) )
|
||||
@@ -77,7 +78,7 @@ class code:
|
||||
sys.stdout.write( "\033["+str(n)+"F" )
|
||||
def down_line(self,n=1):
|
||||
sys.stdout.write( "\033["+str(n)+"E" )
|
||||
|
||||
|
||||
def save(self):
|
||||
""" Save cursor position """
|
||||
sys.stdout.write( "\033[s" )
|
||||
@@ -93,16 +94,17 @@ class code:
|
||||
for i,c in enumerate(self.color_keys):
|
||||
s=s.replace("${"+c+"}","")
|
||||
return self.custom_nocolor(s)
|
||||
|
||||
|
||||
def custom_color(self,s):
|
||||
return self.custom_match.sub('\033[\\2',s)
|
||||
def custom_nocolor(self,s):
|
||||
return self.custom_match.sub('',s)
|
||||
|
||||
|
||||
def get_keys(self):
|
||||
return self.color_keys
|
||||
|
||||
|
||||
def flush(self):
|
||||
sys.stdout.flush()
|
||||
|
||||
|
||||
def demo():
|
||||
@@ -113,7 +115,7 @@ def demo():
|
||||
${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}
|
||||
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
|
||||
@@ -129,15 +131,15 @@ ${S}======${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 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 y;xH .pos() Absolute Position
|
||||
A .up() Up E .up_line() Up line
|
||||
B .down() Down F .down_line() Down line
|
||||
C .left() Left y;xH .pos() Absolute Position
|
||||
D .right() Right """
|
||||
|
||||
print(c.color_string(unformatted))
|
||||
|
||||
Reference in New Issue
Block a user