Update screen_utils.py
This commit is contained in:
parent
af7d314084
commit
8331173e70
@ -7,7 +7,7 @@
|
||||
from core import debug
|
||||
from collections import Counter
|
||||
import string
|
||||
|
||||
|
||||
def removeNonprintable(text):
|
||||
# Get the difference of all ASCII characters from the set of printable characters
|
||||
nonprintable = set([chr(i) for i in range(128)]).difference(string.printable)
|
||||
@ -17,8 +17,8 @@ def removeNonprintable(text):
|
||||
def insertNewlines(string, every=64):
|
||||
return '\n'.join(string[i:i+every] for i in range(0, len(string), every))
|
||||
|
||||
def splitEvery(string, every=64):
|
||||
return list(string[i:i+every] for i in range(0, len(string), every))
|
||||
def splitEvery(toSplit, every=64):
|
||||
return list(toSplit[i:i+every] for i in range(0, len(toSplit), every))
|
||||
|
||||
def trackHighlights(oldAttr, newAttr, text, lenght):
|
||||
result = ''
|
||||
@ -33,6 +33,7 @@ def trackHighlights(oldAttr, newAttr, text, lenght):
|
||||
new = splitEvery(newAttr,lenght)
|
||||
textLines = text.split('\n')
|
||||
background = []
|
||||
print(len(textLines),len(new),new)
|
||||
if len(textLines) != len(new):
|
||||
return result, currCursor
|
||||
try:
|
||||
@ -43,10 +44,12 @@ def trackHighlights(oldAttr, newAttr, text, lenght):
|
||||
if bgStat[1][1] > 40:
|
||||
background.append(bgStat[1][0])
|
||||
except Exception as e:
|
||||
background.append(chr(7))
|
||||
background.append((1,1,1,1))
|
||||
print(background)
|
||||
for line in range(len(new)):
|
||||
if old[line] != new[line]:
|
||||
for column in range(len(new[line])):
|
||||
print(new[line][column])
|
||||
if old[line][column] != new[line][column]:
|
||||
if not new[line][column] in background:
|
||||
if not currCursor:
|
||||
@ -56,3 +59,11 @@ def trackHighlights(oldAttr, newAttr, text, lenght):
|
||||
result += textLines[line][column]
|
||||
result += ' '
|
||||
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)
|
||||
'''
|
||||
|
Loading…
Reference in New Issue
Block a user