make sure spaces are replaced in output

This commit is contained in:
Ville Rantanen
2016-02-25 13:33:22 +02:00
parent bcb562a03d
commit 3bc8ec9902

View File

@@ -51,12 +51,15 @@ class bc:
Z = '\033[0m' Z = '\033[0m'
CLR = '\033[2J' CLR = '\033[2J'
CLREND = '\033[K' CLREND = '\033[K'
CLRBEG = '\033[1K'
color_keys="KRGBYMCWkrgbymcwSUZ" color_keys="KRGBYMCWkrgbymcwSUZ"
color_list=[K,R,G,B,Y,M,C,W,k,r,g,b,y,m,c,w,S,U,Z] color_list=[K,R,G,B,Y,M,C,W,k,r,g,b,y,m,c,w,S,U,Z]
def pos(self,y,x): def pos(self,y,x):
return "\033["+str(y)+";"+str(x)+"H" return "\033["+str(y)+";"+str(x)+"H"
def column(self,x):
return "\033["+str(x)+"G"
def posprint(self, y,x,s): def posprint(self, y,x,s):
sys.stdout.write( self.pos(y,x) + str(s) ) sys.stdout.write( self.pos(y,x) + str(s) )
@@ -65,6 +68,26 @@ class bc:
sys.stdout.write( self.CLR+self.pos(0,0) ) sys.stdout.write( self.CLR+self.pos(0,0) )
def clear_to_end(self): def clear_to_end(self):
sys.stdout.write( self.CLREND ) sys.stdout.write( self.CLREND )
def clear_to_beginning(self):
sys.stdout.write( self.CLRBEG )
def up(self,n=1):
sys.stdout.write( "\033["+str(n)+"A" )
def down(self,n=1):
sys.stdout.write( "\033["+str(n)+"B" )
def right(self,n=1):
sys.stdout.write( "\033["+str(n)+"C" )
def left(self,n=1):
sys.stdout.write( "\033["+str(n)+"D" )
def up_line(self,n=1):
sys.stdout.write( "\033["+str(n)+"F" )
def down_line(self,n=1):
sys.stdout.write( "\033["+str(n)+"E" )
def save(self):
sys.stdout.write( "\033[s" )
def restore(self):
sys.stdout.write( "\033[u" )
def color_string(self,s): def color_string(self,s):
for i,c in enumerate(self.color_keys): for i,c in enumerate(self.color_keys):
@@ -535,8 +558,9 @@ def launch(reader,opts,offset):
if len(output)==1: return [""] if len(output)==1: return [""]
del output[-1] del output[-1]
for y,l in enumerate(output): for y,l in enumerate(output):
bc.posprint(y+offset[1]-offset[0]+2,0,l) bc.posprint(y+offset[1]-offset[0]+2,0,' '*len(l))
bc.clear_to_end() bc.clear_to_end()
bc.posprint(y+offset[1]-offset[0]+2,0,l)
inkey=getch.get() inkey=getch.get()
return return
if run_command != None: if run_command != None: