add initial barrier function and fix history
This commit is contained in:
		| @@ -186,6 +186,7 @@ shell= | ||||
| [focus] | ||||
| cursor=True | ||||
| highlight=False | ||||
| barrier=True | ||||
|    | ||||
| [review] | ||||
| lineBreak=True | ||||
|   | ||||
| @@ -196,6 +196,7 @@ shell= | ||||
| cursor=True | ||||
| #follow highlighted text changes | ||||
| highlight=False | ||||
| barrier=True | ||||
|    | ||||
| [review] | ||||
| lineBreak=True | ||||
|   | ||||
| @@ -197,6 +197,7 @@ shell= | ||||
| cursor=True | ||||
| #follow highlighted text changes | ||||
| highlight=False | ||||
| barrier=True | ||||
|    | ||||
| [review] | ||||
| lineBreak=True | ||||
|   | ||||
| @@ -142,6 +142,7 @@ shell= | ||||
| cursor=True | ||||
| #follow highlighted text changes | ||||
| highlight=False | ||||
| barrier=True | ||||
|  | ||||
| [review] | ||||
| lineBreak=True | ||||
|   | ||||
| @@ -196,6 +196,7 @@ shell= | ||||
| cursor=True | ||||
| #follow highlighted text changes | ||||
| highlight=False | ||||
| barrier=True | ||||
|    | ||||
| [review] | ||||
| lineBreak=True | ||||
|   | ||||
| @@ -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 | ||||
| @@ -45,7 +45,12 @@ class command(): | ||||
|                 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) | ||||
|             # 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 | ||||
|   | ||||
| @@ -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']]): | ||||
|   | ||||
| @@ -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  | ||||
| @@ -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) | ||||
|   | ||||
| @@ -80,6 +80,7 @@ settingsData = { | ||||
| 'focus':{ | ||||
|   'cursor': True, | ||||
|   'highlight': False, | ||||
|   'barrier': True, | ||||
| }, | ||||
| 'review':{ | ||||
|   'lineBreak': True, | ||||
|   | ||||
| @@ -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)        | ||||
|              | ||||
|   | ||||
		Reference in New Issue
	
	Block a user