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
@ -89,19 +95,7 @@ class attributeManager():
False, # blink
'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
]) #end attribute
def isDefaultAttribute(self,attribute):
return attribute in self.defaultAttributes
def hasAttributes(self, cursor, update=True):
@ -110,16 +104,19 @@ class attributeManager():
cursorPos = cursor.copy()
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):