From 14f6ace29bd15fe6c35b173bfeb7bd03e39a7d8f Mon Sep 17 00:00:00 2001 From: chrys Date: Mon, 18 Jun 2018 00:15:35 +0200 Subject: [PATCH] add soundicon for BarrierMode --- .../21000-reset_barrier_change.py | 24 ++++++++ src/fenrirscreenreader/core/barrierManager.py | 59 +++++++++++++++++++ 2 files changed, 83 insertions(+) create mode 100644 src/fenrirscreenreader/commands/onScreenChanged/21000-reset_barrier_change.py create mode 100644 src/fenrirscreenreader/core/barrierManager.py diff --git a/src/fenrirscreenreader/commands/onScreenChanged/21000-reset_barrier_change.py b/src/fenrirscreenreader/commands/onScreenChanged/21000-reset_barrier_change.py new file mode 100644 index 00000000..7e19bada --- /dev/null +++ b/src/fenrirscreenreader/commands/onScreenChanged/21000-reset_barrier_change.py @@ -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 diff --git a/src/fenrirscreenreader/core/barrierManager.py b/src/fenrirscreenreader/core/barrierManager.py new file mode 100644 index 00000000..3346599f --- /dev/null +++ b/src/fenrirscreenreader/core/barrierManager.py @@ -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] +