attribute structure

This commit is contained in:
chrys 2017-08-13 23:06:45 +02:00
parent c193f7140b
commit da0ffbc3c8
4 changed files with 51 additions and 3 deletions

View File

@ -85,6 +85,7 @@ KEY_FENRIR,KEY_KPASTERISK=toggle_highlight_tracking
KEY_FENRIR,KEY_Q=quit_fenrir
KEY_FENRIR,KEY_T=time
2,KEY_FENRIR,KEY_T=date
#=attribute_cursor
KEY_FENRIR,KEY_S=spell_check
2,KEY_FENRIR,KEY_S=add_word_to_spell_check
KEY_FENRIR,KEY_SHIFT,KEY_S=remove_word_from_spell_check

View File

@ -85,6 +85,7 @@ KEY_FENRIR,KEY_Y=toggle_highlight_tracking
KEY_FENRIR,KEY_Q=quit_fenrir
KEY_FENRIR,KEY_T=time
2,KEY_FENRIR,KEY_T=date
#=attribute_cursor
KEY_FENRIR,KEY_S=spell_check
2,KEY_FENRIR,KEY_S=add_word_to_spell_check
KEY_FENRIR,KEY_SHIFT,KEY_S=remove_word_from_spell_check

View File

@ -35,7 +35,21 @@ class screenManager():
# or len(self.env['screen']['newDelta']) > 6:
# self.env['runtime']['screenDriver'].getCurrApplication()
self.env['screen']['lastScreenUpdate'] = time.time()
def formatAttributes(self, x, y,attribute, attributeFormatString = None):
if not attributeFormatString:
attributeFormatString = self.env['runtime']['settingsManager'].getSetting('general', 'attributeFormatString')
if not attributeFormatString:
return ''
if attributeFormatString == '':
return ''
attributeFormatString = attributeFormatString.replace('fenrirBGColor', self.env['runtime']['screenDriver'].getFenrirBGColor(attribute))
attributeFormatString = attributeFormatString.replace('fenrirFGColor', self.env['runtime']['screenDriver'].getFenrirFGColor(attribute))
attributeFormatString = attributeFormatString.replace('fenrirUnderline', self.env['runtime']['screenDriver'].getFenrirUnderline(attribute))
attributeFormatString = attributeFormatString.replace('fenrirBold', self.env['runtime']['screenDriver'].getFenrirBold(attribute))
attributeFormatString = attributeFormatString.replace('fenrirBlink', self.env['runtime']['screenDriver'].getFenrirBlink(attribute))
attributeFormatString = attributeFormatString.replace('fenrirFont', self.env['runtime']['screenDriver'].getFenrirFont(attribute))
attributeFormatString = attributeFormatString.replace('fenrirFontSize', self.env['runtime']['screenDriver'].getFenrirFontSize(attribute))
return attributeFormatString
def isSuspendingScreen(self, screen = None):
if screen == None:
screen = self.env['screen']['newTTY']

View File

@ -35,6 +35,7 @@ class driver():
self.vcsaDevicePath = '/dev/vcsa'
self.ListSessions = None
self.charmap = {}
self.colorNames {0: _('black'), 1: _('blue'), 2: _('green'), 3: _('cyan'), 4: _('red'), 5: _('purple'), 6: _('brown/yellow'), 7: _('white')}
self.hichar = None
def initialize(self, environment):
self.env = environment
@ -219,6 +220,12 @@ class driver():
attr >>= 1
ink = attr & 0x0F
paper = (attr>>4) & 0x0F
blink = 0
if attr & 1:
blink = 1
bold = 0
if attr & 16:
bold = 1
#if (ink != 7) or (paper != 0):
# print(ink,paper)
if sh & self.hichar:
@ -227,11 +234,36 @@ class driver():
lineText += self.charmap[ch]
except KeyError:
lineText += '?'
lineAttrib.append((attr,ink, paper,0,0,0)) # attribute, ink, paper, blink, bold, underline
lineAttrib.append((attr,ink, paper,blink,bold,0)) # attribute, ink, paper, blink, bold, underline
allText += lineText + '\n'
allAttrib += lineAttrib
return str(allText), allAttrib
def getFenrirBGColor(self, attribute):
try:
return self.colorNames[attribute[1]]
except:
return ''
def getFenrirFGColor(attribute):
try:
return self.colorNames[attribute[0]]
except:
return ''
def getFenrirUnderline(attribute):
if attribute[4] == 1:
return _('underlined')
return ''
def getFenrirBold(attribute):
if attribute[3] == 1:
return _('bold')
return ''
def getFenrirBlink(attribute):
if attribute[2] == 1:
return _('blink')
return ''
def getFenrirFont(attribute):
return 'System Font'
def getFenrirFontSize(attribute):
return 'System Font Size'
def update(self, trigger='onUpdate'):
if trigger == 'onInput': # no need for an update on input for VCSA
return