From 965c850ca2954f14ac921983fc7cd322386fe0b2 Mon Sep 17 00:00:00 2001 From: chrys Date: Sun, 30 Oct 2016 01:16:07 +0200 Subject: [PATCH] sync --- src/fenrir/screenDriver/linux.py | 11 +++++------ src/fenrir/utils/screen_utils.py | 6 +++--- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/fenrir/screenDriver/linux.py b/src/fenrir/screenDriver/linux.py index bd4a8e28..88bafca0 100644 --- a/src/fenrir/screenDriver/linux.py +++ b/src/fenrir/screenDriver/linux.py @@ -17,9 +17,6 @@ class driver(): self.env = environment def shutdown(self): pass - def insert_newlines(self, string, every=64): - return '\n'.join(string[i:i+every] for i in range(0, len(string), every)) - def getCurrScreen(self): self.env['screenData']['oldTTY'] = self.env['screenData']['newTTY'] try: @@ -86,7 +83,7 @@ class driver(): # set new "old" values self.env['screenData']['oldContentBytes'] = self.env['screenData']['newContentBytes'] self.env['screenData']['oldContentText'] = self.env['screenData']['newContentText'] - self.env['screenData']['oldContentTextAttrib'] = self.env['screenData']['newContentAttrib'] + self.env['screenData']['oldContentAttrib'] = self.env['screenData']['newContentAttrib'] self.env['screenData']['oldCursor'] = self.env['screenData']['newCursor'].copy() self.env['screenData']['oldDelta'] = self.env['screenData']['newDelta'] self.env['screenData']['oldAttribDelta'] = self.env['screenData']['newAttribDelta'] @@ -100,7 +97,7 @@ class driver(): # analyze content self.env['screenData']['newContentText'] = self.env['screenData']['newContentBytes'][4:][::2].decode(screenEncoding, "replace").encode('utf-8').decode('utf-8') self.env['screenData']['newContentAttrib'] = self.env['screenData']['newContentBytes'][5:][::2] - self.env['screenData']['newContentText'] = self.insert_newlines(self.env['screenData']['newContentText'], self.env['screenData']['columns']) + self.env['screenData']['newContentText'] = screen_utils.insertNewlines(self.env['screenData']['newContentText'], self.env['screenData']['columns']) if self.env['screenData']['newTTY'] != self.env['screenData']['oldTTY']: self.env['screenData']['oldContentBytes'] = b'' @@ -152,6 +149,8 @@ class driver(): self.env['screenData']['newNegativeDelta'] = ''.join(x[2:] for x in diffList if x[0] == '-') # track highlighted + #print(self.env['screenData']['oldContentAttrib'] , self.env['screenData']['newContentAttrib']) if self.env['screenData']['oldContentAttrib'] != self.env['screenData']['newContentAttrib']: - pass + self.env['screenData']['newAttribDelta'], currCursor = screen_utils.trackHighlights(self.env['screenData']['oldContentAttrib'], self.env['screenData']['newContentAttrib'], self.env['screenData']['newContentText'], self.env['screenData']['columns']) + #print('drin',self.env['screenData']['newAttribDelta']) diff --git a/src/fenrir/utils/screen_utils.py b/src/fenrir/utils/screen_utils.py index d9e22570..979fe657 100644 --- a/src/fenrir/utils/screen_utils.py +++ b/src/fenrir/utils/screen_utils.py @@ -10,7 +10,7 @@ from collections import Counter def insertNewlines(string, every=64): return '\n'.join(string[i:i+every] for i in range(0, len(string), every)) -def splitOnPos(string, every=64): +def splitEvery(string, every=64): return list(string[i:i+every] for i in range(0, len(string), every)) old = b'eeeemmmeeeeeeeee' @@ -26,8 +26,8 @@ def trackHighlights(oldAttr, newAttr, text, lenght): return result, currCursor textLines = insertNewlines(text,lenght) textLines = textLines.split('\n') - old = splitOnPos(oldAttr,lenght) - new = splitOnPos(newAttr,lenght) + old = splitEvery(oldAttr,lenght) + new = splitEvery(newAttr,lenght) if len(old) != len(new): return result, currCursor if len(text) != len(new):