add intial soundicon for attribute
This commit is contained in:
parent
ac48ecc89b
commit
21bdcdb56e
Binary file not shown.
@ -43,7 +43,7 @@ ErrorSpeech='ErrorSpeech.wav'
|
||||
ErrorBraille='ErrorBraille.wav'
|
||||
ErrorScreen='ErrorScreen.wav'
|
||||
# If you cursor over an text that has attributs (like color)
|
||||
HasAttributes='HasAttributes.wav'
|
||||
HasAttributes='has_attribute.wav'
|
||||
# fenrir can promote strings if they appear on the screen.
|
||||
PromotedText='PromotedText.wav'
|
||||
# missspelled indicator
|
||||
|
@ -0,0 +1,31 @@
|
||||
#!/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Fenrir TTY screen reader
|
||||
# By Chrys, Storm Dragon, and contributers.
|
||||
|
||||
from fenrirscreenreader.core import debug
|
||||
from fenrirscreenreader.utils import screen_utils
|
||||
|
||||
class command():
|
||||
def __init__(self):
|
||||
pass
|
||||
def initialize(self, environment):
|
||||
self.env = environment
|
||||
def shutdown(self):
|
||||
pass
|
||||
def getDescription(self):
|
||||
return _('Reads attributes of current cursor position')
|
||||
def run(self):
|
||||
# is a vertical change?
|
||||
if not (self.env['runtime']['cursorManager'].isCursorVerticalMove() or\
|
||||
self.env['runtime']['cursorManager'].isCursorHorizontalMove()):
|
||||
return
|
||||
|
||||
cursorPos = self.env['screen']['newCursor']
|
||||
|
||||
if not self.env['runtime']['attributeManager'].hasAttributes(cursorPos):
|
||||
return
|
||||
self.env['runtime']['outputManager'].presentText('has attribute', soundIcon='HasAttributes', interrupt=False)
|
||||
def setCallback(self, callback):
|
||||
pass
|
@ -14,11 +14,24 @@ class attributeManager():
|
||||
self.currAttributeDelta = ''
|
||||
self.currAttributeCursor = None
|
||||
self.prefAttributeCursor = None
|
||||
self.setDefaultAttributes()
|
||||
self.setDefaultAttributes()
|
||||
self.prevLastCursorAttribute = None
|
||||
self.currLastCursorAttribute = None
|
||||
|
||||
def initialize(self, environment):
|
||||
self.env = environment
|
||||
def shutdown(self):
|
||||
pass
|
||||
def setLastCursorAttribute(self, lastCursorAttribute):
|
||||
self.prevLastCursorAttribute = self.currLastCursorAttribute
|
||||
self.currLastCursorAttribute = lastCursorAttribute
|
||||
def resetLastCursorAttribute(self, lastCursorAttribute):
|
||||
self.prevLastCursorAttribute = None
|
||||
self.currLastCursorAttribute = None
|
||||
def isLastCursorAttributeChange(self):
|
||||
if self.prevLastCursorAttribute == None:
|
||||
return True
|
||||
return self.prevLastCursorAttribute != self.currLastCursorAttribute
|
||||
def getCurrAttributeCursor(self):
|
||||
return self.currAttributeCursor
|
||||
def isAttributeCursorActive(self):
|
||||
@ -56,7 +69,7 @@ class attributeManager():
|
||||
if len(self.currAttributes[y]) < x - 1:
|
||||
return None
|
||||
try:
|
||||
return self.currAttributes[y][x].copy()
|
||||
return self.currAttributes[y][x]
|
||||
except KeyError:
|
||||
try:
|
||||
return self.defaultAttributes[0]
|
||||
@ -89,8 +102,29 @@ class attributeManager():
|
||||
'default', # fontsize
|
||||
'default' # fontfamily
|
||||
)) #end attribute
|
||||
def isDefaultAttribute(self,attribute):
|
||||
return attribute in self.defaultAttributes
|
||||
def isDefaultAttribute(self,attribute):
|
||||
useAttribute = None
|
||||
if not attribute:
|
||||
useAttribute = self.currAttributes
|
||||
else:
|
||||
useAttribute = attribute
|
||||
return useAttribute in self.defaultAttributes
|
||||
def hasAttributes(self, cursor, update=True):
|
||||
if not cursor:
|
||||
return False
|
||||
cursorPos = cursor.copy()
|
||||
try:
|
||||
attributes = self.getAttributeByXY( cursorPos['x'], cursorPos['y'])
|
||||
|
||||
if self.isDefaultAttribute(attributes):
|
||||
return False
|
||||
if update:
|
||||
self.setLastCursorAttribute(attributes)
|
||||
if not self.isLastCursorAttributeChange():
|
||||
return False
|
||||
except Exception as e:
|
||||
return False
|
||||
return True
|
||||
def formatAttributes(self, attribute, attributeFormatString = None):
|
||||
# "black",
|
||||
# "red",
|
||||
@ -254,7 +288,6 @@ class attributeManager():
|
||||
# background.append(bgStat[1][0])
|
||||
except Exception as e:
|
||||
print(e)
|
||||
#background.append((7,7,0,0,0,0))
|
||||
for line in range(len(self.prevAttributes)):
|
||||
if self.prevAttributes[line] != self.currAttributes[line]:
|
||||
for column in range(len(self.prevAttributes[line])):
|
||||
|
Loading…
Reference in New Issue
Block a user