From 9b87a34ab049fa09ff846fe83c603606dbdc0dca Mon Sep 17 00:00:00 2001 From: chrys Date: Sun, 10 Jun 2018 14:44:54 +0200 Subject: [PATCH] add initial barrier function and fix history --- config/settings/espeak.settings.conf | 3 +- config/settings/settings.conf | 1 + config/settings/settings.conf.example | 1 + config/settings/settings.conf.storm | 1 + .../settings/speech-dispatcher.settings.conf | 1 + ...-present_line_if_cursor_change_vertical.py | 11 +++- .../commands/onScreenUpdate/60000-history.py | 3 +- .../core/headLineManager.py | 55 ------------------- src/fenrirscreenreader/core/outputManager.py | 2 +- src/fenrirscreenreader/core/settingsData.py | 1 + .../core/settingsManager.py | 6 +- 11 files changed, 20 insertions(+), 65 deletions(-) delete mode 100644 src/fenrirscreenreader/core/headLineManager.py diff --git a/config/settings/espeak.settings.conf b/config/settings/espeak.settings.conf index 4fb506f7..b74dfb29 100644 --- a/config/settings/espeak.settings.conf +++ b/config/settings/espeak.settings.conf @@ -186,7 +186,8 @@ shell= [focus] cursor=True highlight=False - +barrier=True + [review] lineBreak=True endOfScreen=True diff --git a/config/settings/settings.conf b/config/settings/settings.conf index 39ad1e8d..048d2507 100644 --- a/config/settings/settings.conf +++ b/config/settings/settings.conf @@ -196,6 +196,7 @@ shell= cursor=True #follow highlighted text changes highlight=False +barrier=True [review] lineBreak=True diff --git a/config/settings/settings.conf.example b/config/settings/settings.conf.example index bf7e926f..7a9b2b96 100644 --- a/config/settings/settings.conf.example +++ b/config/settings/settings.conf.example @@ -197,6 +197,7 @@ shell= cursor=True #follow highlighted text changes highlight=False +barrier=True [review] lineBreak=True diff --git a/config/settings/settings.conf.storm b/config/settings/settings.conf.storm index bbe429f2..821a1522 100644 --- a/config/settings/settings.conf.storm +++ b/config/settings/settings.conf.storm @@ -142,6 +142,7 @@ shell= cursor=True #follow highlighted text changes highlight=False +barrier=True [review] lineBreak=True diff --git a/config/settings/speech-dispatcher.settings.conf b/config/settings/speech-dispatcher.settings.conf index c2a122eb..3ee9788c 100644 --- a/config/settings/speech-dispatcher.settings.conf +++ b/config/settings/speech-dispatcher.settings.conf @@ -196,6 +196,7 @@ shell= cursor=True #follow highlighted text changes highlight=False +barrier=True [review] lineBreak=True diff --git a/src/fenrirscreenreader/commands/onCursorChange/55000-present_line_if_cursor_change_vertical.py b/src/fenrirscreenreader/commands/onCursorChange/55000-present_line_if_cursor_change_vertical.py index 6c1ed075..9193bb11 100644 --- a/src/fenrirscreenreader/commands/onCursorChange/55000-present_line_if_cursor_change_vertical.py +++ b/src/fenrirscreenreader/commands/onCursorChange/55000-present_line_if_cursor_change_vertical.py @@ -33,10 +33,10 @@ class command(): return x, y, currLine = line_utils.getCurrentLine(self.env['screen']['newCursor']['x'], self.env['screen']['newCursor']['y'], self.env['screen']['newContentText']) - if currLine.isspace(): self.env['runtime']['outputManager'].presentText(_("blank"), soundIcon='EmptyLine', interrupt=True, flush=False) else: + # ident currIdent = len(currLine) - len(currLine.lstrip()) if self.lastIdent == -1: self.lastIdent = currIdent @@ -44,8 +44,13 @@ class command(): if self.env['runtime']['settingsManager'].getSettingAsBool('general', 'autoPresentIndent'): if self.lastIdent != currIdent: self.env['runtime']['outputManager'].presentText(_('indented ') + str(currIdent) + ' ', interrupt=doInterrupt, flush=False) - doInterrupt = False - self.env['runtime']['outputManager'].presentText(currLine, interrupt=doInterrupt, flush=False) + doInterrupt = False + # barrier + sayLine = currLine + if self.env['runtime']['settingsManager'].getSettingAsBool('focus', 'barrier'): + sayLine = self.env['runtime']['textManager'].getBarrierText(sayLine, self.env['screen']['newCursor']['x']) + # output + self.env['runtime']['outputManager'].presentText(sayLine, interrupt=doInterrupt, flush=False) self.lastIdent = currIdent def setCallback(self, callback): pass diff --git a/src/fenrirscreenreader/commands/onScreenUpdate/60000-history.py b/src/fenrirscreenreader/commands/onScreenUpdate/60000-history.py index 97bf9b36..2e3ca3d7 100644 --- a/src/fenrirscreenreader/commands/onScreenUpdate/60000-history.py +++ b/src/fenrirscreenreader/commands/onScreenUpdate/60000-history.py @@ -24,8 +24,7 @@ class command(): return # hack for pdmenu and maybe other dialog apps that place the cursor at last cell/row # this is not to be identified as history - if self.env['screen']['newCursor']['x'] == == self.env['runtime']['screenManager'].getColums() - 1 and\ - self.env['screen']['newCursor']['y'] == self.env['runtime']['screenManager'].getRows() - 1): + if (self.env['screen']['newCursor']['x'] == self.env['runtime']['screenManager'].getColumns() - 1) and (self.env['screen']['newCursor']['y'] == self.env['runtime']['screenManager'].getRows() - 1): return if self.env['runtime']['inputManager'].getShortcutType() in ['KEY']: if not (self.env['runtime']['inputManager'].getLastDeepestInput() in [['KEY_UP'],['KEY_DOWN']]): diff --git a/src/fenrirscreenreader/core/headLineManager.py b/src/fenrirscreenreader/core/headLineManager.py deleted file mode 100644 index c9a081c5..00000000 --- a/src/fenrirscreenreader/core/headLineManager.py +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/python -# -*- coding: utf-8 -*- - -# Fenrir TTY screen reader -# By Chrys, Storm Dragon, and contributers. - -from fenrirscreenreader.core import debug -import re, string - -class headLineManager(): - def __init__(self): - self.regExSingle = re.compile(r'(([^\w\s])\2{5,})') - self.regExDouble = re.compile(r'([^\w\s]{2,}){5,}') - def initialize(self, environment): - self.env = environment - def shutdown(self): - pass - def replaceHeadLines(self, text): - # fast len check for bigger typing echo - if len(text) < 5: - return text - # more strong check, to not match if not needed: - if len(text.strip(string.ascii_letters+string.digits+string.whitespace)) < 5: - return text - result = '' - newText = '' - lastPos = 0 - for match in self.regExDouble.finditer(text): - span = match.span() - newText += text[lastPos:span[0]] - numberOfChars = len(text[span[0]:span[1]]) - name = text[span[0]:span[1]][:2] - if name[0] == name[1]: - newText += ' ' + str(numberOfChars) + ' ' + self.env['runtime']['punctuationManager'].proceedPunctuation(name[0], True) + ' ' - else: - newText += ' ' + str(int(numberOfChars / 2)) + ' ' + self.env['runtime']['punctuationManager'].proceedPunctuation(name, True) + ' ' - lastPos = span[1] - if lastPos != 0: - newText += ' ' - newText += text[lastPos:] - lastPos = 0 - for match in self.regExSingle.finditer(newText): - span = match.span() - result += text[lastPos:span[0]] - numberOfChars = len(newText[span[0]:span[1]]) - name = newText[span[0]:span[1]][:2] - if name[0] == name[1]: - result += ' ' + str(numberOfChars) + ' ' + self.env['runtime']['punctuationManager'].proceedPunctuation(name[0], True) + ' ' - else: - result += ' ' + str(int(numberOfChars / 2)) + ' ' + self.env['runtime']['punctuationManager'].proceedPunctuation(name, True) + ' ' - lastPos = span[1] - if lastPos != 0: - result += ' ' - result += newText[lastPos:] - return result diff --git a/src/fenrirscreenreader/core/outputManager.py b/src/fenrirscreenreader/core/outputManager.py index 5f502985..02cb5501 100644 --- a/src/fenrirscreenreader/core/outputManager.py +++ b/src/fenrirscreenreader/core/outputManager.py @@ -101,7 +101,7 @@ class outputManager(): else: cleanText = text.replace('\n',' ') - cleanText = self.env['runtime']['headLineManager'].replaceHeadLines(cleanText) + cleanText = self.env['runtime']['textManager'].replaceHeadLines(cleanText) cleanText = self.env['runtime']['punctuationManager'].proceedPunctuation(cleanText, ignorePunctuation) cleanText = re.sub(' +$',' ', cleanText) self.env['runtime']['speechDriver'].speak(cleanText) diff --git a/src/fenrirscreenreader/core/settingsData.py b/src/fenrirscreenreader/core/settingsData.py index f17d8947..a0a38ebe 100644 --- a/src/fenrirscreenreader/core/settingsData.py +++ b/src/fenrirscreenreader/core/settingsData.py @@ -80,6 +80,7 @@ settingsData = { 'focus':{ 'cursor': True, 'highlight': False, + 'barrier': True, }, 'review':{ 'lineBreak': True, diff --git a/src/fenrirscreenreader/core/settingsManager.py b/src/fenrirscreenreader/core/settingsManager.py index 7f6cb26a..bab8a94b 100644 --- a/src/fenrirscreenreader/core/settingsManager.py +++ b/src/fenrirscreenreader/core/settingsManager.py @@ -21,7 +21,7 @@ from fenrirscreenreader.core import punctuationManager from fenrirscreenreader.core import cursorManager from fenrirscreenreader.core import applicationManager from fenrirscreenreader.core import helpManager -from fenrirscreenreader.core import headLineManager +from fenrirscreenreader.core import textManager from fenrirscreenreader.core import tableManager from fenrirscreenreader.core import byteManager from fenrirscreenreader.core import attributeManager @@ -323,8 +323,8 @@ class settingsManager(): environment['runtime']['cursorManager'].initialize(environment) environment['runtime']['applicationManager'] = applicationManager.applicationManager() environment['runtime']['applicationManager'].initialize(environment) - environment['runtime']['headLineManager'] = headLineManager.headLineManager() - environment['runtime']['headLineManager'].initialize(environment) + environment['runtime']['textManager'] = textManager.textManager() + environment['runtime']['textManager'].initialize(environment) environment['runtime']['tableManager'] = tableManager.tableManager() environment['runtime']['tableManager'].initialize(environment)