Update screen_utils.py

This commit is contained in:
chrys87 2017-07-28 11:47:42 +02:00 committed by GitHub
parent af7d314084
commit 8331173e70

View File

@ -17,8 +17,8 @@ def removeNonprintable(text):
def insertNewlines(string, every=64): def insertNewlines(string, every=64):
return '\n'.join(string[i:i+every] for i in range(0, len(string), every)) return '\n'.join(string[i:i+every] for i in range(0, len(string), every))
def splitEvery(string, every=64): def splitEvery(toSplit, every=64):
return list(string[i:i+every] for i in range(0, len(string), every)) return list(toSplit[i:i+every] for i in range(0, len(toSplit), every))
def trackHighlights(oldAttr, newAttr, text, lenght): def trackHighlights(oldAttr, newAttr, text, lenght):
result = '' result = ''
@ -33,6 +33,7 @@ def trackHighlights(oldAttr, newAttr, text, lenght):
new = splitEvery(newAttr,lenght) new = splitEvery(newAttr,lenght)
textLines = text.split('\n') textLines = text.split('\n')
background = [] background = []
print(len(textLines),len(new),new)
if len(textLines) != len(new): if len(textLines) != len(new):
return result, currCursor return result, currCursor
try: try:
@ -43,10 +44,12 @@ def trackHighlights(oldAttr, newAttr, text, lenght):
if bgStat[1][1] > 40: if bgStat[1][1] > 40:
background.append(bgStat[1][0]) background.append(bgStat[1][0])
except Exception as e: except Exception as e:
background.append(chr(7)) background.append((1,1,1,1))
print(background)
for line in range(len(new)): for line in range(len(new)):
if old[line] != new[line]: if old[line] != new[line]:
for column in range(len(new[line])): for column in range(len(new[line])):
print(new[line][column])
if old[line][column] != new[line][column]: if old[line][column] != new[line][column]:
if not new[line][column] in background: if not new[line][column] in background:
if not currCursor: if not currCursor:
@ -56,3 +59,11 @@ def trackHighlights(oldAttr, newAttr, text, lenght):
result += textLines[line][column] result += textLines[line][column]
result += ' ' result += ' '
return result, currCursor return result, currCursor
'''
t = 'hallo\nwelt!'
old = ((1,1,0,0),(1,1,0,0),(1,1,0,0),(1,1,0,0),(1,1,0,0),(1,1,0,0),(1,1,0,0),(1,1,0,0),(1,1,0,0),(1,1,0,0))
new = ((0,1,1,1),(1,1,1,1),(1,1,1,1),(1,1,1,1),(1,1,1,1),(1,1,0,0),(1,1,0,0),(1,1,0,0),(1,1,0,0),(1,1,0,0))
trackHighlights(old,new,t,5)
'''