Merge branch 'master' into processing
This commit is contained in:
commit
5acf27f407
@ -18,7 +18,7 @@ screenData = {
|
|||||||
'oldCursor':{'x':0,'y':0},
|
'oldCursor':{'x':0,'y':0},
|
||||||
'oldContentBytes': b'',
|
'oldContentBytes': b'',
|
||||||
'oldContentText': '',
|
'oldContentText': '',
|
||||||
'oldContentAttrib': b'',
|
'oldContentAttrib': None,
|
||||||
'oldApplication': '',
|
'oldApplication': '',
|
||||||
'oldTTY':None,
|
'oldTTY':None,
|
||||||
'newDelta': '',
|
'newDelta': '',
|
||||||
@ -29,9 +29,27 @@ screenData = {
|
|||||||
'newCursor':{'x':0,'y':0},
|
'newCursor':{'x':0,'y':0},
|
||||||
'newContentBytes': b'',
|
'newContentBytes': b'',
|
||||||
'newContentText': '',
|
'newContentText': '',
|
||||||
'newContentAttrib': b'',
|
'newContentAttrib': None,
|
||||||
'newTTY':'0',
|
'newTTY':'0',
|
||||||
'newApplication': '',
|
'newApplication': '',
|
||||||
'lastScreenUpdate': time.time(),
|
'lastScreenUpdate': time.time(),
|
||||||
'autoIgnoreScreens':[],
|
'autoIgnoreScreens':[],
|
||||||
}
|
}
|
||||||
|
'''
|
||||||
|
screenData = {
|
||||||
|
'columns': 0,
|
||||||
|
'lines': 0,
|
||||||
|
'textDelta': '',
|
||||||
|
'negativeDelta': '',
|
||||||
|
'attribDelta': '',
|
||||||
|
'reviewCursor':None, #{'x':0,'y':0}
|
||||||
|
'attribCursor':None, #{'x':0,'y':0}
|
||||||
|
'textCursor':None, #{'x':0,'y':0}
|
||||||
|
'content': None, #{'x':0,'y':0}
|
||||||
|
'Text': '',
|
||||||
|
'Attrib': None,
|
||||||
|
'screen': None,
|
||||||
|
'application': '',
|
||||||
|
'timestamp': time.time(),
|
||||||
|
}
|
||||||
|
'''
|
||||||
|
@ -198,11 +198,11 @@ class driver():
|
|||||||
|
|
||||||
def autoDecodeVCSA(self, allData, rows, cols):
|
def autoDecodeVCSA(self, allData, rows, cols):
|
||||||
allText = ''
|
allText = ''
|
||||||
allAttrib = b''
|
allAttrib = []
|
||||||
i = 0
|
i = 0
|
||||||
for y in range(rows):
|
for y in range(rows):
|
||||||
lineText = ''
|
lineText = ''
|
||||||
lineAttrib = b''
|
lineAttrib = []
|
||||||
for x in range(cols):
|
for x in range(cols):
|
||||||
data = allData[i: i + 2]
|
data = allData[i: i + 2]
|
||||||
i += 2
|
i += 2
|
||||||
@ -211,7 +211,7 @@ class driver():
|
|||||||
#ink = 7
|
#ink = 7
|
||||||
#paper = 0
|
#paper = 0
|
||||||
#ch = ' '
|
#ch = ' '
|
||||||
lineAttrib += b'7'
|
lineAttrib.append((7,7,0,0,0,0)) # attribute, ink, paper, blink, bold, underline
|
||||||
lineText += ' '
|
lineText += ' '
|
||||||
continue
|
continue
|
||||||
(sh,) = unpack("=H", data)
|
(sh,) = unpack("=H", data)
|
||||||
@ -219,7 +219,6 @@ class driver():
|
|||||||
ch = sh & 0xFF
|
ch = sh & 0xFF
|
||||||
if self.hichar == 0x100:
|
if self.hichar == 0x100:
|
||||||
attr >>= 1
|
attr >>= 1
|
||||||
lineAttrib += bytes(attr)
|
|
||||||
ink = attr & 0x0F
|
ink = attr & 0x0F
|
||||||
paper = (attr>>4) & 0x0F
|
paper = (attr>>4) & 0x0F
|
||||||
#if (ink != 7) or (paper != 0):
|
#if (ink != 7) or (paper != 0):
|
||||||
@ -230,6 +229,7 @@ class driver():
|
|||||||
lineText += self.charmap[ch]
|
lineText += self.charmap[ch]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
lineText += chr('?')
|
lineText += chr('?')
|
||||||
|
lineAttrib.append((attr,ink, paper,0,0,0)) # attribute, ink, paper, blink, bold, underline
|
||||||
allText += lineText + '\n'
|
allText += lineText + '\n'
|
||||||
allAttrib += lineAttrib
|
allAttrib += lineAttrib
|
||||||
return str(allText), allAttrib
|
return str(allText), allAttrib
|
||||||
@ -280,7 +280,7 @@ class driver():
|
|||||||
|
|
||||||
if self.env['screen']['newTTY'] != self.env['screen']['oldTTY']:
|
if self.env['screen']['newTTY'] != self.env['screen']['oldTTY']:
|
||||||
self.env['screen']['oldContentBytes'] = b''
|
self.env['screen']['oldContentBytes'] = b''
|
||||||
self.env['screen']['oldContentAttrib'] = b''
|
self.env['screen']['oldContentAttrib'] = None
|
||||||
self.env['screen']['oldContentText'] = ''
|
self.env['screen']['oldContentText'] = ''
|
||||||
self.env['screen']['oldCursor']['x'] = 0
|
self.env['screen']['oldCursor']['x'] = 0
|
||||||
self.env['screen']['oldCursor']['y'] = 0
|
self.env['screen']['oldCursor']['y'] = 0
|
||||||
|
@ -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 = ''
|
||||||
@ -29,11 +29,13 @@ def trackHighlights(oldAttr, newAttr, text, lenght):
|
|||||||
return result, currCursor
|
return result, currCursor
|
||||||
if len(oldAttr) != len(newAttr):
|
if len(oldAttr) != len(newAttr):
|
||||||
return result, currCursor
|
return result, currCursor
|
||||||
|
|
||||||
old = splitEvery(oldAttr,lenght)
|
old = splitEvery(oldAttr,lenght)
|
||||||
new = splitEvery(newAttr,lenght)
|
new = splitEvery(newAttr,lenght)
|
||||||
textLines = text.split('\n')
|
textLines = text.split('\n')
|
||||||
background = []
|
background = []
|
||||||
if len(textLines) != len(new):
|
|
||||||
|
if len(textLines) - 1 != len(new):
|
||||||
return result, currCursor
|
return result, currCursor
|
||||||
try:
|
try:
|
||||||
bgStat = Counter(newAttr).most_common(3)
|
bgStat = Counter(newAttr).most_common(3)
|
||||||
@ -43,10 +45,11 @@ 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((7,7,0,0,0,0))
|
||||||
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)
|
||||||
|
'''
|
||||||
|
Loading…
Reference in New Issue
Block a user