fix has attribute

This commit is contained in:
chrys 2018-06-04 06:09:51 +02:00
parent 0c02532dba
commit c25bda45b2
3 changed files with 35 additions and 25 deletions

View File

@ -14,7 +14,7 @@ class attributeManager():
self.currAttributeDelta = ''
self.currAttributeCursor = None
self.prefAttributeCursor = None
self.setDefaultAttributes()
self.initDefaultAttributes()
self.prevLastCursorAttribute = None
self.currLastCursorAttribute = None
@ -30,7 +30,7 @@ class attributeManager():
self.currLastCursorAttribute = None
def isLastCursorAttributeChange(self):
if self.prevLastCursorAttribute == None:
return True
return False
return self.prevLastCursorAttribute != self.currLastCursorAttribute
def getCurrAttributeCursor(self):
return self.currAttributeCursor
@ -76,7 +76,13 @@ class attributeManager():
except:
pass
return None
def setDefaultAttributes(self):
def appendDefaultAttributes(self, attribute):
if not attribute:
return
if len(attribute) != 10:
return
self.defaultAttributes.append(attribute)
def initDefaultAttributes(self):
self.defaultAttributes = [None]
self.defaultAttributes.append([
'default', # fg
@ -90,18 +96,6 @@ class attributeManager():
'default', # fontsize
'default' # fontfamily
]) #end attribute
self.defaultAttributes.append([
'white', # fg
'black', # bg
False, # bold
False, # italics
False, # underscore
False, # strikethrough
False, # reverse
False, # blink
'default', # fontsize
'default' # fontfamily
]) #end attribute
def isDefaultAttribute(self,attribute):
return attribute in self.defaultAttributes
def hasAttributes(self, cursor, update=True):
@ -111,15 +105,18 @@ class attributeManager():
try:
attribute = self.getAttributeByXY( cursorPos['x'], cursorPos['y'])
if self.isDefaultAttribute(attribute):
return False
if update:
self.setLastCursorAttribute(attribute)
if not self.isLastCursorAttributeChange():
return False
if self.isDefaultAttribute(attribute):
return False
except Exception as e:
return False
return True
def formatAttributes(self, attribute, attributeFormatString = ''):
# "black",
# "red",

View File

@ -175,7 +175,6 @@ class screenManager():
self.env['runtime']['attributeManager'].setAttributeCursor(attributeCursor)
self.env['runtime']['attributeManager'].setAttributeDelta(attributeDelta)
except Exception as e:
print(e)
self.env['runtime']['debug'].writeDebugOut('screenManager:update:highlight: ' + str(e),debug.debugLevel.ERROR)
def isSuspendingScreen(self, screen = None):

View File

@ -34,6 +34,18 @@ class driver(screenDriver):
self.hichar = None
def initialize(self, environment):
self.env = environment
self.env['runtime']['attributeManager'].appendDefaultAttributes([
self.fgColorValues[7], # fg
self.bgColorValues[0], # bg
False, # bold
False, # italics
False, # underscore
False, # strikethrough
False, # reverse
False, # blink
'default', # fontsize
'default' # fontfamily
]) #end attribute )
self.env['runtime']['processManager'].addCustomEventThread(self.updateWatchdog, multiprocess=True)
def getCurrScreen(self):
self.env['screen']['oldTTY'] = self.env['screen']['newTTY']
@ -205,8 +217,8 @@ class driver(screenDriver):
#ink = 7
#paper = 0
#ch = ' '
charAttrib = (
self.fgColorValues[15], # fg
charAttrib = [
self.fgColorValues[7], # fg
self.bgColorValues[0], # bg
False, # bold
False, # italics
@ -215,7 +227,7 @@ class driver(screenDriver):
False, # reverse
False, # blink
'default', # fontsize
'default') # fontfamily
'default'] # fontfamily
lineAttrib.append(charAttrib)
lineText += ' '
continue
@ -229,6 +241,8 @@ class driver(screenDriver):
blink = 0
if attr & 1:
blink = 1
# blink seems to be set always, ignore for now
blink = 0
bold = 0
if attr & 16:
bold = 1
@ -240,7 +254,7 @@ class driver(screenDriver):
lineText += self.charmap[ch]
except KeyError:
lineText += '?'
charAttrib = (
charAttrib = [
self.fgColorValues[ink],
self.bgColorValues[paper],
bold == 1, # bold
@ -250,7 +264,7 @@ class driver(screenDriver):
False, # reverse
blink == 1, # blink
'default', # fontsize
'default') # fontfamily
'default'] # fontfamily
lineAttrib.append(charAttrib)
allText += lineText
if y + 1 < rows: