add soundicon for BarrierMode

This commit is contained in:
chrys 2018-06-18 00:15:35 +02:00
parent c3f3aeb2e5
commit 14f6ace29b
2 changed files with 83 additions and 0 deletions

View File

@ -0,0 +1,24 @@
#!/bin/python
# -*- coding: utf-8 -*-
# Fenrir TTY screen reader
# By Chrys, Storm Dragon, and contributers.
from fenrirscreenreader.core import debug
class command():
def __init__(self):
pass
def initialize(self, environment):
self.env = environment
def shutdown(self):
pass
def getDescription(self):
return 'No Description found'
def run(self):
self.env['runtime']['barrierManager'].resetBarrierChange()
def setCallback(self, callback):
pass

View File

@ -0,0 +1,59 @@
#!/bin/python
# -*- coding: utf-8 -*-
# Fenrir TTY screen reader
# By Chrys, Storm Dragon, and contributers.
from fenrirscreenreader.core import debug
import re, string
class barrierManager():
def __init__(self):
self.currIsBarrier = False
self.prefIsBarrier = False
def initialize(self, environment):
self.env = environment
def shutdown(self):
pass
def updateBarrierChange(self, isBarrier):
self.prefIsBarrier = self.currIsBarrier
self.currIsBarrier = isBarrier
def resetBarrierChange(self):
self.currIsBarrier = False
self.prefIsBarrier = False
def isBarrierChange(self):
return self.currIsBarrier != self.prefIsBarrier
def handleLineBarrier(self, line, xCursor, output=True, doInterrupt=True):
isBarrier, sayLine = self.getBarrierText(line, xCursor)
self.updateBarrierChange(isBarrier)
#if self.isBarrierChange():
if isBarrier:
if output:
self.env['runtime']['outputManager'].playSoundIcon(soundIcon='SpeechOn', interrupt=doInterrupt)
return sayLine
def hasBarrier(self, start, end):
# check for corners here
return True
def getBarrierText(self, line, xCursor):
offset = xCursor
# is the cursor at the begin or end of an entry:
#print(line[:offset + 1].count('│'),line[offset:].count('│'))
if line[:offset + 1].count('') > line[offset:].count(''):
offset = xCursor - 1
start = line[:offset + 1].rfind('') + 1
end = line[offset + 1:].find('')
if start == end:
return False, line
if start == -1:
return False, line
if end == -1:
return False, line
else:
end += offset + 1
if not self.hasBarrier(start, end):
return False, line
return True, line[start:end]