From 8331173e704dab44111892c7e6e1109b54bf5029 Mon Sep 17 00:00:00 2001 From: chrys87 Date: Fri, 28 Jul 2017 11:47:42 +0200 Subject: [PATCH 1/5] Update screen_utils.py --- src/fenrir/utils/screen_utils.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/fenrir/utils/screen_utils.py b/src/fenrir/utils/screen_utils.py index 4eb81945..ce30f710 100644 --- a/src/fenrir/utils/screen_utils.py +++ b/src/fenrir/utils/screen_utils.py @@ -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) +''' From e4ca5b384ef7a918e4d57617cd19d84e3f545954 Mon Sep 17 00:00:00 2001 From: chrys87 Date: Fri, 28 Jul 2017 11:48:50 +0200 Subject: [PATCH 2/5] Update screen_utils.py --- src/fenrir/utils/screen_utils.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/fenrir/utils/screen_utils.py b/src/fenrir/utils/screen_utils.py index ce30f710..601647e4 100644 --- a/src/fenrir/utils/screen_utils.py +++ b/src/fenrir/utils/screen_utils.py @@ -33,7 +33,6 @@ 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: @@ -45,7 +44,6 @@ def trackHighlights(oldAttr, newAttr, text, lenght): background.append(bgStat[1][0]) except Exception as e: 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])): From ec597d799b12dba8de7f0f87eb310c186d658970 Mon Sep 17 00:00:00 2001 From: chrys87 Date: Fri, 28 Jul 2017 11:56:32 +0200 Subject: [PATCH 3/5] Update screenData.py --- src/fenrir/core/screenData.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/fenrir/core/screenData.py b/src/fenrir/core/screenData.py index 8e5f037c..5838fd54 100644 --- a/src/fenrir/core/screenData.py +++ b/src/fenrir/core/screenData.py @@ -35,3 +35,21 @@ screenData = { 'lastScreenUpdate': time.time(), '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': '', +'timestano': time.time(), +} +''' From d2825556f0db7bd5218d96f893dcae24683c375a Mon Sep 17 00:00:00 2001 From: chrys87 Date: Fri, 28 Jul 2017 12:17:21 +0200 Subject: [PATCH 4/5] Update screenData.py --- src/fenrir/core/screenData.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fenrir/core/screenData.py b/src/fenrir/core/screenData.py index 5838fd54..8d31c5be 100644 --- a/src/fenrir/core/screenData.py +++ b/src/fenrir/core/screenData.py @@ -50,6 +50,6 @@ screenData = { 'Attrib': None, 'screen': None, 'application': '', -'timestano': time.time(), +'timestamp': time.time(), } ''' From 79eb342317e8a7c35717ee080712b413576c0d35 Mon Sep 17 00:00:00 2001 From: chrys Date: Sun, 30 Jul 2017 16:27:24 +0200 Subject: [PATCH 5/5] fix hilight tracking --- src/fenrir/core/screenData.py | 4 ++-- src/fenrir/screenDriver/vcsaDriver.py | 10 +++++----- src/fenrir/utils/screen_utils.py | 6 ++++-- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/fenrir/core/screenData.py b/src/fenrir/core/screenData.py index 8d31c5be..9f4d0a61 100644 --- a/src/fenrir/core/screenData.py +++ b/src/fenrir/core/screenData.py @@ -18,7 +18,7 @@ screenData = { 'oldCursor':{'x':0,'y':0}, 'oldContentBytes': b'', 'oldContentText': '', -'oldContentAttrib': b'', +'oldContentAttrib': None, 'oldApplication': '', 'oldTTY':None, 'newDelta': '', @@ -29,7 +29,7 @@ screenData = { 'newCursor':{'x':0,'y':0}, 'newContentBytes': b'', 'newContentText': '', -'newContentAttrib': b'', +'newContentAttrib': None, 'newTTY':'0', 'newApplication': '', 'lastScreenUpdate': time.time(), diff --git a/src/fenrir/screenDriver/vcsaDriver.py b/src/fenrir/screenDriver/vcsaDriver.py index c98264a3..10cc2fa2 100644 --- a/src/fenrir/screenDriver/vcsaDriver.py +++ b/src/fenrir/screenDriver/vcsaDriver.py @@ -198,11 +198,11 @@ class driver(): def autoDecodeVCSA(self, allData, rows, cols): allText = '' - allAttrib = b'' + allAttrib = [] i = 0 for y in range(rows): lineText = '' - lineAttrib = b'' + lineAttrib = [] for x in range(cols): data = allData[i: i + 2] i += 2 @@ -211,7 +211,7 @@ class driver(): #ink = 7 #paper = 0 #ch = ' ' - lineAttrib += b'7' + lineAttrib.append((7,7,0,0,0,0)) # attribute, ink, paper, blink, bold, underline lineText += ' ' continue (sh,) = unpack("=H", data) @@ -219,7 +219,6 @@ class driver(): ch = sh & 0xFF if self.hichar == 0x100: attr >>= 1 - lineAttrib += bytes(attr) ink = attr & 0x0F paper = (attr>>4) & 0x0F #if (ink != 7) or (paper != 0): @@ -230,6 +229,7 @@ class driver(): lineText += self.charmap[ch] except KeyError: lineText += chr('?') + lineAttrib.append((attr,ink, paper,0,0,0)) # attribute, ink, paper, blink, bold, underline allText += lineText + '\n' allAttrib += lineAttrib return str(allText), allAttrib @@ -280,7 +280,7 @@ class driver(): if self.env['screen']['newTTY'] != self.env['screen']['oldTTY']: self.env['screen']['oldContentBytes'] = b'' - self.env['screen']['oldContentAttrib'] = b'' + self.env['screen']['oldContentAttrib'] = None self.env['screen']['oldContentText'] = '' self.env['screen']['oldCursor']['x'] = 0 self.env['screen']['oldCursor']['y'] = 0 diff --git a/src/fenrir/utils/screen_utils.py b/src/fenrir/utils/screen_utils.py index 601647e4..432f1aac 100644 --- a/src/fenrir/utils/screen_utils.py +++ b/src/fenrir/utils/screen_utils.py @@ -29,11 +29,13 @@ def trackHighlights(oldAttr, newAttr, text, lenght): return result, currCursor if len(oldAttr) != len(newAttr): return result, currCursor + old = splitEvery(oldAttr,lenght) new = splitEvery(newAttr,lenght) textLines = text.split('\n') background = [] - if len(textLines) != len(new): + + if len(textLines) - 1 != len(new): return result, currCursor try: bgStat = Counter(newAttr).most_common(3) @@ -43,7 +45,7 @@ def trackHighlights(oldAttr, newAttr, text, lenght): if bgStat[1][1] > 40: background.append(bgStat[1][0]) except Exception as e: - background.append((1,1,1,1)) + background.append((7,7,0,0,0,0)) for line in range(len(new)): if old[line] != new[line]: for column in range(len(new[line])):