This commit is contained in:
Chrys 2019-11-04 22:31:36 +01:00
parent bed06374f1
commit 6761b6267c
2 changed files with 44 additions and 38 deletions

View File

@ -14,20 +14,20 @@ class attributeManager():
self.currAttributeDelta = '' self.currAttributeDelta = ''
self.currAttributeCursor = None self.currAttributeCursor = None
self.prefAttributeCursor = None self.prefAttributeCursor = None
self.initDefaultAttributes() self.initDefaultAttributes()
self.prevLastCursorAttribute = None self.prevLastCursorAttribute = None
self.currLastCursorAttribute = None self.currLastCursorAttribute = None
def initialize(self, environment): def initialize(self, environment):
self.env = environment self.env = environment
def shutdown(self): def shutdown(self):
pass pass
def setLastCursorAttribute(self, lastCursorAttribute): def setLastCursorAttribute(self, lastCursorAttribute):
self.prevLastCursorAttribute = self.currLastCursorAttribute self.prevLastCursorAttribute = self.currLastCursorAttribute
self.currLastCursorAttribute = lastCursorAttribute self.currLastCursorAttribute = lastCursorAttribute
def resetLastCursorAttribute(self): def resetLastCursorAttribute(self):
self.prevLastCursorAttribute = None self.prevLastCursorAttribute = None
self.currLastCursorAttribute = None self.currLastCursorAttribute = None
def isLastCursorAttributeChange(self): def isLastCursorAttributeChange(self):
if self.prevLastCursorAttribute == None: if self.prevLastCursorAttribute == None:
return False return False
@ -43,32 +43,33 @@ class attributeManager():
def resetAttributeAll(self): def resetAttributeAll(self):
self.resetAttributeDelta() self.resetAttributeDelta()
self.resetAttributeCursor() self.resetAttributeCursor()
def getAttributeDelta(self): def getAttributeDelta(self):
return self.currAttributeDelta return self.currAttributeDelta
def resetAttributeDelta(self): def resetAttributeDelta(self):
self.currAttributeDelta = '' self.currAttributeDelta = ''
def setAttributeDelta(self, currAttributeDelta): def setAttributeDelta(self, currAttributeDelta):
self.currAttributeDelta = currAttributeDelta self.currAttributeDelta = currAttributeDelta
def resetAttributeCursor(self): def resetAttributeCursor(self):
self.currAttributeCursor = None self.currAttributeCursor = None
self.prefAttributeCursor = None self.prefAttributeCursor = None
def setAttributeCursor(self, currAttributeCursor): def setAttributeCursor(self, currAttributeCursor):
self.prefAttributeCursor = self.currAttributeCursor self.prefAttributeCursor = self.currAttributeCursor
self.currAttributeCursor = currAttributeCursor.copy() self.currAttributeCursor = currAttributeCursor.copy()
def resetAttributes(self, currAttributes): def resetAttributes(self, currAttributes):
self.prevAttributes = None self.prevAttributes = None
self.currAttributes = currAttributes self.currAttributes = currAttributes
def setAttributes(self, currAttributes): def setAttributes(self, currAttributes):
self.prevAttributes = self.currAttributes self.prevAttributes = self.currAttributes
self.currAttributes = currAttributes.copy() self.currAttributes = currAttributes.copy()
def getAttributeByXY(self, x, y): def getAttributeByXY(self, x, y):
if not self.currAttributes: if not self.currAttributes:
return None return None
if len(self.currAttributes) < y: if len(self.currAttributes) < y:
return None return None
if len(self.currAttributes[y]) < x - 1: if len(self.currAttributes[y]) < x - 1:
return None return None
try: try:
return self.currAttributes[y][x] return self.currAttributes[y][x]
except KeyError: except KeyError:
try: try:
@ -81,7 +82,7 @@ class attributeManager():
return return
if len(attribute) != 10: if len(attribute) != 10:
return return
self.defaultAttributes.append(attribute) self.defaultAttributes.append(attribute)
def initDefaultAttributes(self): def initDefaultAttributes(self):
self.defaultAttributes = [None] self.defaultAttributes = [None]
self.defaultAttributes.append([ self.defaultAttributes.append([
@ -95,7 +96,7 @@ class attributeManager():
False, # blink False, # blink
'default', # fontsize 'default', # fontsize
'default' # fontfamily 'default' # fontfamily
]) #end attribute ]) #end attribute
def isDefaultAttribute(self,attribute): def isDefaultAttribute(self,attribute):
return attribute in self.defaultAttributes return attribute in self.defaultAttributes
def hasAttributes(self, cursor, update=True): def hasAttributes(self, cursor, update=True):
@ -106,7 +107,7 @@ class attributeManager():
attribute = self.getAttributeByXY( cursorPos['x'], cursorPos['y']) attribute = self.getAttributeByXY( cursorPos['x'], cursorPos['y'])
if update: if update:
self.setLastCursorAttribute(attribute) self.setLastCursorAttribute(attribute)
if not self.isLastCursorAttributeChange(): if not self.isLastCursorAttributeChange():
return False return False
@ -134,10 +135,10 @@ class attributeManager():
# "italics", # "italics",
# "underscore", # "underscore",
# "strikethrough", # "strikethrough",
# "reverse", # "reverse",
# "blink" # "blink"
# "fontsieze" # "fontsieze"
# "fontfamily" # "fontfamily"
if attributeFormatString == '': if attributeFormatString == '':
attributeFormatString = self.env['runtime']['settingsManager'].getSetting('general', 'attributeFormatString') attributeFormatString = self.env['runtime']['settingsManager'].getSetting('general', 'attributeFormatString')
if not attributeFormatString: if not attributeFormatString:
@ -148,7 +149,7 @@ class attributeManager():
return '' return ''
if len(attribute) != 10: if len(attribute) != 10:
return '' return ''
# 0 FG color (name) # 0 FG color (name)
try: try:
attributeFormatString = attributeFormatString.replace('fenrirFGColor', _(attribute[0])) attributeFormatString = attributeFormatString.replace('fenrirFGColor', _(attribute[0]))
@ -169,9 +170,9 @@ class attributeManager():
pass pass
attributeFormatString = attributeFormatString.replace('fenrirBold', '') attributeFormatString = attributeFormatString.replace('fenrirBold', '')
# 3 italics (True/ False) # 3 italics (True/ False)
try: try:
if attribute[3]: if attribute[3]:
attributeFormatString = attributeFormatString.replace('fenrirItalics', _('italic')) attributeFormatString = attributeFormatString.replace('fenrirItalics', _('italic'))
except Exception as e: except Exception as e:
pass pass
@ -195,15 +196,15 @@ class attributeManager():
# 6 reverse (True/ False) # 6 reverse (True/ False)
try: try:
if attribute[6]: if attribute[6]:
attributeFormatString = attributeFormatString.replace('fenrirReverse', _('reverse')) attributeFormatString = attributeFormatString.replace('fenrirReverse', _('reverse'))
except Exception as e: except Exception as e:
pass pass
attributeFormatString = attributeFormatString.replace('fenrirReverse', '') attributeFormatString = attributeFormatString.replace('fenrirReverse', '')
# 7 blink (True/ False) # 7 blink (True/ False)
try: try:
if attribute[7]: if attribute[7]:
attributeFormatString = attributeFormatString.replace('fenrirBlink', _('blink')) attributeFormatString = attributeFormatString.replace('fenrirBlink', _('blink'))
except Exception as e: except Exception as e:
pass pass
@ -236,16 +237,16 @@ class attributeManager():
currCursor = None currCursor = None
# screen change # screen change
if self.prevAttributes == None: if self.prevAttributes == None:
return result, currCursor return result, currCursor
# no change # no change
if self.prevAttributes == self.currAttributes: if self.prevAttributes == self.currAttributes:
return result, currCursor return result, currCursor
# error case # error case
if self.currAttributes == None: if self.currAttributes == None:
return result, currCursor return result, currCursor
# special case for pty if not text exists. # special case for pty if not text exists.
if len(self.currAttributes) == 0: if len(self.currAttributes) == 0:
return result, currCursor return result, currCursor
text = self.env['runtime']['screenManager'].getScreenText() text = self.env['runtime']['screenManager'].getScreenText()
textLines = text.split('\n') textLines = text.split('\n')
@ -268,7 +269,7 @@ class attributeManager():
if line < 0: if line < 0:
return False return False
if line > len(currAttributes): if line > len(currAttributes):
return False return False
useful = False useful = False
if mode == 'default': if mode == 'default':
# non default tracking # non default tracking
@ -278,12 +279,12 @@ class attributeManager():
if line == 0: if line == 0:
useful = (currAttributes[line][column][attribute] != currAttributes[line + 1][column][attribute]) and (currAttributes[line][column][attribute] != currAttributes[line + 2][column][attribute]) useful = (currAttributes[line][column][attribute] != currAttributes[line + 1][column][attribute]) and (currAttributes[line][column][attribute] != currAttributes[line + 2][column][attribute])
elif line >= len(prevAttributes): elif line >= len(prevAttributes):
useful = (currAttributes[line][column][attribute] != currAttributes[line - 1][column][attribute]) and (currAttributes[line][column][attribute] != currAttributes[line - 2][column][attribute]) useful = (currAttributes[line][column][attribute] != currAttributes[line - 1][column][attribute]) and (currAttributes[line][column][attribute] != currAttributes[line - 2][column][attribute])
else: else:
useful = (currAttributes[line][column][attribute] != currAttributes[line + 1][column][attribute]) and (currAttributes[line][column][attribute] != currAttributes[line - 1][column][attribute]) useful = (currAttributes[line][column][attribute] != currAttributes[line + 1][column][attribute]) and (currAttributes[line][column][attribute] != currAttributes[line - 1][column][attribute])
elif mode == 'barrier': elif mode == 'barrier':
# to be implement # to be implement
useful = True useful = True
return useful return useful

View File

@ -212,9 +212,14 @@ class driver(screenDriver):
}, },
'screen': screen, 'screen': screen,
'screenUpdateTime': time.time(), 'screenUpdateTime': time.time(),
'text': '',
'attributes': [],
} }
eventData['text'], eventData['attributes'] =\ try:
self.autoDecodeVCSA(vcsaContent[4:], eventData['lines'], eventData['columns']) eventData['text'], eventData['attributes'] =\
self.autoDecodeVCSA(vcsaContent[4:], eventData['lines'], eventData['columns'])
except:
pass
# VCSU seems to give b' ' instead of b'\x00\x00\x00' (tsp), deactivated until its fixed # VCSU seems to give b' ' instead of b'\x00\x00\x00' (tsp), deactivated until its fixed
if vcsuContent != None: if vcsuContent != None:
try: try: