fenrir/src/fenrirscreenreader/core/attributeManager.py

79 lines
3.1 KiB
Python
Raw Normal View History

2018-05-24 05:31:21 -04:00
#!/bin/python
# -*- coding: utf-8 -*-
# Fenrir TTY screen reader
# By Chrys, Storm Dragon, and contributers.
from fenrirscreenreader.core import debug
class attributeManager():
def __init__(self):
pass
def initialize(self, environment):
self.env = environment
def shutdown(self):
pass
2018-05-25 06:50:24 -04:00
def isDefaultAttribute(attribute):
defaultAttributes = []
defaultAttributes.append((
'white', # fg
'black', # bg
False, # bold
False, # italics
False, # underscore
False, # strikethrough
False, # reverse
False, # blink
'default', # fontsize
'default' # fontfamily
)) #end attribute
defaultAttributes.append((
'default', # fg
'default', # bg
False, # bold
False, # italics
False, # underscore
False, # strikethrough
False, # reverse
False, # blink
'default', # fontsize
'default' # fontfamily
)) #end attribute
return attribute in defaultAttributes
2018-05-24 05:31:21 -04:00
def formatAttributes(self, attribute, attributeFormatString = None):
if not attributeFormatString:
attributeFormatString = self.env['runtime']['settingsManager'].getSetting('general', 'attributeFormatString')
if not attributeFormatString:
return ''
if attributeFormatString == '':
return ''
try:
attributeFormatString = attributeFormatString.replace('fenrirBGColor', self.env['runtime']['screenDriver'].getFenrirBGColor(attribute))
except Exception as e:
pass
try:
attributeFormatString = attributeFormatString.replace('fenrirFGColor', self.env['runtime']['screenDriver'].getFenrirFGColor(attribute))
except Exception as e:
pass
try:
attributeFormatString = attributeFormatString.replace('fenrirUnderline', self.env['runtime']['screenDriver'].getFenrirUnderline(attribute))
except Exception as e:
pass
try:
attributeFormatString = attributeFormatString.replace('fenrirBold', self.env['runtime']['screenDriver'].getFenrirBold(attribute))
except Exception as e:
pass
try:
attributeFormatString = attributeFormatString.replace('fenrirBlink', self.env['runtime']['screenDriver'].getFenrirBlink(attribute))
except Exception as e:
pass
try:
attributeFormatString = attributeFormatString.replace('fenrirFontSize', self.env['runtime']['screenDriver'].getFenrirFontSize(attribute))
except Exception as e:
pass
try:
attributeFormatString = attributeFormatString.replace('fenrirFont', self.env['runtime']['screenDriver'].getFenrirFont(attribute))
except Exception as e:
pass
2018-05-24 20:56:03 -04:00
return attributeFormatString