diff --git a/TODO v2.0 b/TODO v2.0 index f69e9192..ba9174c5 100644 --- a/TODO v2.0 +++ b/TODO v2.0 @@ -34,13 +34,6 @@ Imporove attribute handling [] configurable (by char, by word, none) (Easy for contribution) https://github.com/jwilk/vcsapeek/blob/master/linuxvt.py -[W] Barrier Mode - - [X] Initial barrier mode - - [X] add command to toggle barrier mode - - [X] Soundicon on barrier detection - - [] Barrier detection in hilight tracking - - [] valid barriers by window edges - Improved Say all [] speech callbacks [] speech process by word diff --git a/config/keyboard/desktop.conf b/config/keyboard/desktop.conf index 638be423..547fd1fa 100644 --- a/config/keyboard/desktop.conf +++ b/config/keyboard/desktop.conf @@ -88,6 +88,7 @@ KEY_FENRIR,KEY_T=time 2,KEY_FENRIR,KEY_T=date KEY_KPSLASH=toggle_auto_indent KEY_KPMINUS=attribute_cursor +#=toggle_has_attribute KEY_FENRIR,KEY_S=spell_check 2,KEY_FENRIR,KEY_S=add_word_to_spell_check KEY_FENRIR,KEY_SHIFT,KEY_S=remove_word_from_spell_check diff --git a/config/keyboard/laptop.conf b/config/keyboard/laptop.conf index 9d9a15f0..fcc16e14 100644 --- a/config/keyboard/laptop.conf +++ b/config/keyboard/laptop.conf @@ -88,6 +88,7 @@ KEY_FENRIR,KEY_T=time 2,KEY_FENRIR,KEY_T=date KEY_FENRIR,KEY_BACKSLASH=toggle_auto_indent KEY_FENRIR,KEY_MINUS=attribute_cursor +#=toggle_has_attribute KEY_FENRIR,KEY_S=spell_check 2,KEY_FENRIR,KEY_S=add_word_to_spell_check KEY_FENRIR,KEY_SHIFT,KEY_S=remove_word_from_spell_check diff --git a/config/keyboard/pty.conf b/config/keyboard/pty.conf index f70fb948..989688de 100644 --- a/config/keyboard/pty.conf +++ b/config/keyboard/pty.conf @@ -2,6 +2,7 @@ ^[OP=toggle_tutorial_mode # double tap control+end read attributes 2,^[[1;5F=attribute_cursor +#=toggle_has_attribute # escape - stop speech ^[=shut_up # context menu key - stop speech diff --git a/config/settings/espeak.settings.conf b/config/settings/espeak.settings.conf index b74dfb29..665d8289 100644 --- a/config/settings/espeak.settings.conf +++ b/config/settings/espeak.settings.conf @@ -186,7 +186,11 @@ shell= [focus] cursor=True highlight=False -barrier=True + +[barrier] +enabled=True +leftBarriers=│└┌─ +rightBarriers=│┘┐─ [review] lineBreak=True diff --git a/config/settings/settings.conf b/config/settings/settings.conf index 048d2507..8105e537 100644 --- a/config/settings/settings.conf +++ b/config/settings/settings.conf @@ -196,8 +196,12 @@ shell= cursor=True #follow highlighted text changes highlight=False -barrier=True - + +[barrier] +enabled=True +leftBarriers=│└┌─ +rightBarriers=│┘┐─ + [review] lineBreak=True endOfScreen=True diff --git a/config/settings/settings.conf.example b/config/settings/settings.conf.example index 7a9b2b96..9094763b 100644 --- a/config/settings/settings.conf.example +++ b/config/settings/settings.conf.example @@ -197,7 +197,11 @@ shell= cursor=True #follow highlighted text changes highlight=False -barrier=True + +[barrier] +enabled=True +leftBarriers=│└┌─ +rightBarriers=│┘┐─ [review] lineBreak=True diff --git a/config/settings/settings.conf.storm b/config/settings/settings.conf.storm index 0668ae1a..73fb9797 100644 --- a/config/settings/settings.conf.storm +++ b/config/settings/settings.conf.storm @@ -9,10 +9,10 @@ genericFrequencyCommand=play -q -v fenrirVolume -n -c1 synth fenrirDuration sine [speech] enabled=True -driver=speechdDriver -#driver=genericDriver +#driver=speechdDriver +driver=genericDriver serverPath= -rate=0.95 +rate=0.80 pitch=0.5 # Pitch for capital letters capitalPitch=0.9 @@ -133,7 +133,7 @@ commandPath= attributeFormatString=Background fenrirBGColor,Foreground fenrirFGColor,fenrirUnderline,fenrirBold,fenrirBlink, Font fenrirFont,Fontsize fenrirFontSize autoPresentIndent=False # play a sound when attributes are changeing -hasAttributes=True +hasAttributes=False # shell for PTY emulatiun (empty = default shell) shell= @@ -142,7 +142,11 @@ shell= cursor=True #follow highlighted text changes highlight=False -barrier=True + +[barrier] +enabled=True +leftBarriers=│└┌─ +rightBarriers=│┘┐─ [review] lineBreak=True diff --git a/config/settings/speech-dispatcher.settings.conf b/config/settings/speech-dispatcher.settings.conf index 3ee9788c..e936de42 100644 --- a/config/settings/speech-dispatcher.settings.conf +++ b/config/settings/speech-dispatcher.settings.conf @@ -196,7 +196,11 @@ shell= cursor=True #follow highlighted text changes highlight=False -barrier=True + +[barrier] +enabled=True +leftBarriers=│└┌─ +rightBarriers=│┘┐─ [review] lineBreak=True diff --git a/config/sound/default/soundicons.conf b/config/sound/default/soundicons.conf index 830ccb13..8ad2c0ec 100644 --- a/config/sound/default/soundicons.conf +++ b/config/sound/default/soundicons.conf @@ -15,6 +15,10 @@ StartOfLine='StartOfLine.wav' EndOfLine='EndOfLine.wav' # barrier was detected BarrierFound='barrier.wav' +# barrier mode starts +BarrierStart='barrier_start.wav' +# barrier mode ends +BarrierEnd='barrier_end.wav' # the Line is empty EmptyLine='EmptyLine.wav' # Is the first line on the screen. diff --git a/config/sound/template/soundicons.conf b/config/sound/template/soundicons.conf index e5039970..6304abce 100644 --- a/config/sound/template/soundicons.conf +++ b/config/sound/template/soundicons.conf @@ -15,6 +15,10 @@ StartOfLine='' EndOfLine='' # barrier was detected BarrierFound='' +# barrier mode starts +BarrierStart='' +# barrier mode ends +BarrierEnd='' # the Line is empty EmptyLine='' # Is the first line on the screen. diff --git a/play zone/split.txt b/play zone/split.txt new file mode 100644 index 00000000..74dfc21d --- /dev/null +++ b/play zone/split.txt @@ -0,0 +1,34 @@ +./play zone/wrapWord.py:21: wrappedLines = currText.split('\n') +./play zone/wrapWord.py:50: wrappedLines = currText.split('\n') +./play zone/wrapWord.py:93: wrappedLines = currText.split('\n') +./src/fenrirscreenreader/screenDriver/vcsaDriver.py:281: apps = subprocess.Popen('ps -t tty' + currScreen + ' -o comm,tty,stat', shell=True, stdout=subprocess.PIPE).stdout.read().decode()[:-1].split('\n') +./src/fenrirscreenreader/utils/line_utils.py:14: wrappedLines = currText.split('\n') +./src/fenrirscreenreader/utils/line_utils.py:30: wrappedLines = currText.split('\n') +./src/fenrirscreenreader/utils/line_utils.py:41: wrappedLines = currText.split('\n') +./src/fenrirscreenreader/utils/char_utils.py:14: wrappedLines = currText.split('\n') +./src/fenrirscreenreader/utils/char_utils.py:35: wrappedLines = currText.split('\n') +./src/fenrirscreenreader/utils/char_utils.py:43: wrappedLines = currText.split('\n') +./src/fenrirscreenreader/utils/char_utils.py:58: wrappedLines = currText.split('\n') +./src/fenrirscreenreader/utils/char_utils.py:73: wrappedLines = currText.split('\n') +./src/fenrirscreenreader/utils/char_utils.py:85: wrappedLines = currText.split('\n') +./src/fenrirscreenreader/utils/mark_utils.py:13: inText = inText.split('\n') +./src/fenrirscreenreader/utils/mark_utils.py:59: inText = inText.split('\n') +./src/fenrirscreenreader/utils/word_utils.py:20: wrappedLines = currText.split('\n') +./src/fenrirscreenreader/utils/word_utils.py:62: wrappedLines = currText.split('\n') +./src/fenrirscreenreader/utils/word_utils.py:91: wrappedLines = currText.split('\n') +./src/fenrirscreenreader/core/outputManager.py:173: currline = text.split('\n')[offset['y']] +./src/fenrirscreenreader/core/attributeManager.py:250: textLines = text.split('\n') +./src/fenrirscreenreader/core/screenManager.py:166: diffList = ['+ ' + self.env['screen']['newContentText'].split('\n')[self.env['screen']['newCursor']['y']] +'\n'] +./src/fenrirscreenreader/core/screenManager.py:169: diff = self.differ.compare(oldScreenText.split('\n'),\ +./src/fenrirscreenreader/core/screenManager.py:170: newScreenText.split('\n')) +./src/fenrirscreenreader/core/screenManager.py:225: windowList = text.split('\n') +./src/fenrirscreenreader/commands/onCursorChange/62000-spell_check.py:66: newContent = self.env['screen']['newContentText'].split('\n')[self.env['screen']['newCursor']['y']] +./src/fenrirscreenreader/commands/onCursorChange/60000-word_echo_type.py:39: newContent = self.env['screen']['newContentText'].split('\n')[self.env['screen']['newCursor']['y']] +./src/fenrirscreenreader/commands/onCursorChange/50000-present_char_if_cursor_change_horizontal.py:41: newContent = self.env['screen']['newContentText'].split('\n')[self.env['screen']['newCursor']['y']] +./src/fenrirscreenreader/commands/onCursorChange/61000-word_echo_navigation.py:37: newContent = self.env['screen']['newContentText'].split('\n')[self.env['screen']['newCursor']['y']] +./src/fenrirscreenreader/commands/commands/spell_check.py:47: newContent = self.env['screen']['newContentText'].split('\n')[cursorPos['y']] +./src/fenrirscreenreader/commands/commands/remove_word_from_spell_check.py:45: newContent = self.env['screen']['newContentText'].split('\n')[cursorPos['y']] +./src/fenrirscreenreader/commands/commands/add_word_to_spell_check.py:43: newContent = self.env['screen']['newContentText'].split('\n')[cursorPos['y']] +./src/fenrirscreenreader/commands/onScreenUpdate/60000-history.py:38: prevLine = self.env['screen']['oldContentText'].split('\n')[self.env['screen']['newCursor']['y']] +./src/fenrirscreenreader/commands/onScreenUpdate/60000-history.py:39: currLine = self.env['screen']['newContentText'].split('\n')[self.env['screen']['newCursor']['y']] +./TODO v2.0:72: w.fill(i).split('\n') diff --git a/realese nots/1.9.1 b/realese nots/1.9.1 index 35a8563f..b024bb5d 100644 --- a/realese nots/1.9.1 +++ b/realese nots/1.9.1 @@ -1,4 +1,5 @@ - import clipboard from x (xclip) -- initial barrier mode +- barrier mode (respect pseudo cli window borders like used in dialog or pdmenu) - toggle for barrier mode +- soundicon for barrier mode when enter and leave the barrier detection - imporove accuracy of speak history (arrow up/ down in bash) diff --git a/splits.txt b/splits.txt new file mode 100644 index 00000000..74dfc21d --- /dev/null +++ b/splits.txt @@ -0,0 +1,34 @@ +./play zone/wrapWord.py:21: wrappedLines = currText.split('\n') +./play zone/wrapWord.py:50: wrappedLines = currText.split('\n') +./play zone/wrapWord.py:93: wrappedLines = currText.split('\n') +./src/fenrirscreenreader/screenDriver/vcsaDriver.py:281: apps = subprocess.Popen('ps -t tty' + currScreen + ' -o comm,tty,stat', shell=True, stdout=subprocess.PIPE).stdout.read().decode()[:-1].split('\n') +./src/fenrirscreenreader/utils/line_utils.py:14: wrappedLines = currText.split('\n') +./src/fenrirscreenreader/utils/line_utils.py:30: wrappedLines = currText.split('\n') +./src/fenrirscreenreader/utils/line_utils.py:41: wrappedLines = currText.split('\n') +./src/fenrirscreenreader/utils/char_utils.py:14: wrappedLines = currText.split('\n') +./src/fenrirscreenreader/utils/char_utils.py:35: wrappedLines = currText.split('\n') +./src/fenrirscreenreader/utils/char_utils.py:43: wrappedLines = currText.split('\n') +./src/fenrirscreenreader/utils/char_utils.py:58: wrappedLines = currText.split('\n') +./src/fenrirscreenreader/utils/char_utils.py:73: wrappedLines = currText.split('\n') +./src/fenrirscreenreader/utils/char_utils.py:85: wrappedLines = currText.split('\n') +./src/fenrirscreenreader/utils/mark_utils.py:13: inText = inText.split('\n') +./src/fenrirscreenreader/utils/mark_utils.py:59: inText = inText.split('\n') +./src/fenrirscreenreader/utils/word_utils.py:20: wrappedLines = currText.split('\n') +./src/fenrirscreenreader/utils/word_utils.py:62: wrappedLines = currText.split('\n') +./src/fenrirscreenreader/utils/word_utils.py:91: wrappedLines = currText.split('\n') +./src/fenrirscreenreader/core/outputManager.py:173: currline = text.split('\n')[offset['y']] +./src/fenrirscreenreader/core/attributeManager.py:250: textLines = text.split('\n') +./src/fenrirscreenreader/core/screenManager.py:166: diffList = ['+ ' + self.env['screen']['newContentText'].split('\n')[self.env['screen']['newCursor']['y']] +'\n'] +./src/fenrirscreenreader/core/screenManager.py:169: diff = self.differ.compare(oldScreenText.split('\n'),\ +./src/fenrirscreenreader/core/screenManager.py:170: newScreenText.split('\n')) +./src/fenrirscreenreader/core/screenManager.py:225: windowList = text.split('\n') +./src/fenrirscreenreader/commands/onCursorChange/62000-spell_check.py:66: newContent = self.env['screen']['newContentText'].split('\n')[self.env['screen']['newCursor']['y']] +./src/fenrirscreenreader/commands/onCursorChange/60000-word_echo_type.py:39: newContent = self.env['screen']['newContentText'].split('\n')[self.env['screen']['newCursor']['y']] +./src/fenrirscreenreader/commands/onCursorChange/50000-present_char_if_cursor_change_horizontal.py:41: newContent = self.env['screen']['newContentText'].split('\n')[self.env['screen']['newCursor']['y']] +./src/fenrirscreenreader/commands/onCursorChange/61000-word_echo_navigation.py:37: newContent = self.env['screen']['newContentText'].split('\n')[self.env['screen']['newCursor']['y']] +./src/fenrirscreenreader/commands/commands/spell_check.py:47: newContent = self.env['screen']['newContentText'].split('\n')[cursorPos['y']] +./src/fenrirscreenreader/commands/commands/remove_word_from_spell_check.py:45: newContent = self.env['screen']['newContentText'].split('\n')[cursorPos['y']] +./src/fenrirscreenreader/commands/commands/add_word_to_spell_check.py:43: newContent = self.env['screen']['newContentText'].split('\n')[cursorPos['y']] +./src/fenrirscreenreader/commands/onScreenUpdate/60000-history.py:38: prevLine = self.env['screen']['oldContentText'].split('\n')[self.env['screen']['newCursor']['y']] +./src/fenrirscreenreader/commands/onScreenUpdate/60000-history.py:39: currLine = self.env['screen']['newContentText'].split('\n')[self.env['screen']['newCursor']['y']] +./TODO v2.0:72: w.fill(i).split('\n') diff --git a/src/fenrirscreenreader/commands/commands/toggle_barrier.py b/src/fenrirscreenreader/commands/commands/toggle_barrier.py index f8e814ab..fe5925d0 100644 --- a/src/fenrirscreenreader/commands/commands/toggle_barrier.py +++ b/src/fenrirscreenreader/commands/commands/toggle_barrier.py @@ -16,8 +16,8 @@ class command(): return _('enables or disables the barrier mode') def run(self): - self.env['runtime']['settingsManager'].setSetting('focus', 'barrier', str(not self.env['runtime']['settingsManager'].getSettingAsBool('focus', 'barrier'))) - if self.env['runtime']['settingsManager'].getSettingAsBool('focus', 'barrier'): + self.env['runtime']['settingsManager'].setSetting('barrier', 'enabled', str(not self.env['runtime']['settingsManager'].getSettingAsBool('barrier', 'enabled'))) + if self.env['runtime']['settingsManager'].getSettingAsBool('barrier', 'enabled'): self.env['runtime']['outputManager'].presentText(_("barrier mode enabled"), soundIcon='', interrupt=True) else: self.env['runtime']['outputManager'].presentText(_("barrier mode disabled"), soundIcon='', interrupt=True) diff --git a/src/fenrirscreenreader/commands/commands/toggle_has_attribute.py b/src/fenrirscreenreader/commands/commands/toggle_has_attribute.py new file mode 100644 index 00000000..21ae5348 --- /dev/null +++ b/src/fenrirscreenreader/commands/commands/toggle_has_attribute.py @@ -0,0 +1,26 @@ +#!/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 _('enables or disables the announcement of attributes') + + def run(self): + self.env['runtime']['settingsManager'].setSetting('general', 'hasAttributes', str(not self.env['runtime']['settingsManager'].getSettingAsBool('general', 'hasAttributes'))) + if self.env['runtime']['settingsManager'].getSettingAsBool('general', 'hasAttributes'): + self.env['runtime']['outputManager'].presentText(_("announcement of attributes enabled"), soundIcon='', interrupt=True) + else: + self.env['runtime']['outputManager'].presentText(_("announcement of attributes disabled"), soundIcon='', interrupt=True) + + def setCallback(self, callback): + pass 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 b42da4d6..5ccbd0cd 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 @@ -47,8 +47,10 @@ class command(): doInterrupt = False # barrier sayLine = currLine - if self.env['runtime']['settingsManager'].getSettingAsBool('focus', 'barrier'): - sayLine = self.env['runtime']['barrierManager'].handleLineBarrier(sayLine, self.env['screen']['newCursor']['x']) + if self.env['runtime']['settingsManager'].getSettingAsBool('barrier','enabled'): + isBarrier, barrierLine = self.env['runtime']['barrierManager'].handleLineBarrier(self.env['screen']['newContentText'].split('\n'), self.env['screen']['newCursor']['x'],self.env['screen']['newCursor']['y']) + if isBarrier: + sayLine = barrierLine # output self.env['runtime']['outputManager'].presentText(sayLine, interrupt=doInterrupt, flush=False) self.lastIdent = currIdent diff --git a/src/fenrirscreenreader/commands/onScreenChanged/70000-barrier_detect.py b/src/fenrirscreenreader/commands/onScreenChanged/70000-barrier_detect.py new file mode 100644 index 00000000..4f764092 --- /dev/null +++ b/src/fenrirscreenreader/commands/onScreenChanged/70000-barrier_detect.py @@ -0,0 +1,27 @@ +#!/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): + if not self.env['runtime']['settingsManager'].getSettingAsBool('barrier','enabled'): + return + + self.env['runtime']['barrierManager'].handleLineBarrier(self.env['screen']['newContentText'].split('\n'), self.env['screen']['newCursor']['x'],self.env['screen']['newCursor']['y']) + + def setCallback(self, callback): + pass + diff --git a/src/fenrirscreenreader/commands/onScreenUpdate/80000-barrier_detect.py b/src/fenrirscreenreader/commands/onScreenUpdate/80000-barrier_detect.py new file mode 100644 index 00000000..87d119b0 --- /dev/null +++ b/src/fenrirscreenreader/commands/onScreenUpdate/80000-barrier_detect.py @@ -0,0 +1,29 @@ +#!/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): + if not self.env['runtime']['settingsManager'].getSettingAsBool('barrier','enabled'): + return + if not self.env['runtime']['screenManager'].isDelta(ignoreSpace=True): + return + + self.env['runtime']['barrierManager'].handleLineBarrier(self.env['screen']['newContentText'].split('\n'), self.env['screen']['newCursor']['x'],self.env['screen']['newCursor']['y']) + + def setCallback(self, callback): + pass + diff --git a/src/fenrirscreenreader/core/barrierManager.py b/src/fenrirscreenreader/core/barrierManager.py index 169fc0ed..fa4c2d62 100644 --- a/src/fenrirscreenreader/core/barrierManager.py +++ b/src/fenrirscreenreader/core/barrierManager.py @@ -24,36 +24,90 @@ class barrierManager(): 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) + def handleLineBarrier(self, text, xCursor, yCursor, output=True, doInterrupt=True): + isBarrier = False + try: + isBarrier, sayLine = self.getBarrierText(text, xCursor, yCursor) + except Exception as e: + return False, '' + self.updateBarrierChange(isBarrier) - #if self.isBarrierChange(): - if isBarrier: - if output: - self.env['runtime']['outputManager'].playSoundIcon(soundIcon='BarrierFound', interrupt=doInterrupt) - return sayLine + if self.isBarrierChange(): + if output: + if isBarrier: + self.env['runtime']['outputManager'].playSoundIcon(soundIcon='BarrierStart', interrupt=doInterrupt) + else: + self.env['runtime']['outputManager'].playSoundIcon(soundIcon='BarrierEnd', interrupt=doInterrupt) + + if not isBarrier: + sayLine = '' + return isBarrier, sayLine - def hasBarrier(self, start, end): + def hasBorder(self, text, xCursor, yCursor, validBorder, barrierPos): # check for corners here + lastLineNo = len(text) - 1 + if yCursor <= 0: + if not (text[0][barrierPos] in validBorder): + return False + if len(text) > 1: + if not (text[1][barrierPos] in validBorder): + return False + if len(text) > 2: + if not (text[2][barrierPos] in validBorder): + return False + elif yCursor >= lastLineNo: + if not (text[lastLineNo][barrierPos] in validBorder): + return False + if len(text) > 1: + if not (text[lastLineNo - 1][barrierPos] in validBorder): + return False + if len(text) > 2: + if not (text[lastLineNo - 2][barrierPos] in validBorder): + return False + else: + if not (text[yCursor][barrierPos] in validBorder): + return False + if not (text[yCursor - 1][barrierPos] in validBorder): + return False + if not (text[yCursor + 1][barrierPos] in validBorder): + return False return True - def getBarrierText(self, line, xCursor): - offset = xCursor + def getBarrierText(self, text, xCursor, yCursor): + line = text[yCursor] + if not self.env['runtime']['settingsManager'].getSettingAsBool('barrier', 'enabled'): + return False, line + offset = xCursor + + leftBarriers = self.env['runtime']['settingsManager'].getSetting('barrier', 'leftBarriers') + rightBarriers = self.env['runtime']['settingsManager'].getSetting('barrier', 'rightBarriers') # 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('│') + # start + + for b in leftBarriers: + if line[:offset + 1].count(b) > line[offset:].count(b): + offset = xCursor - 1 + start = line[:offset].rfind(b) + if start != -1: + if not self.hasBorder(text, xCursor, yCursor, leftBarriers, start): + start = -1 + else: + start += 1 + break + if start == -1: + return False, line + # end + for b in rightBarriers: + end = line[start:].find(b) + if end != -1: + end = start + end + if not self.hasBorder(text, xCursor, yCursor,rightBarriers, end): + end = -1 + break + if end == -1: + return False, line 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] diff --git a/src/fenrirscreenreader/core/settingsData.py b/src/fenrirscreenreader/core/settingsData.py index e3b0d681..88ae1653 100644 --- a/src/fenrirscreenreader/core/settingsData.py +++ b/src/fenrirscreenreader/core/settingsData.py @@ -80,7 +80,12 @@ settingsData = { 'focus':{ 'cursor': True, 'highlight': False, - 'barrier': True, + +}, +'barrier':{ + 'enabled': True, + 'leftBarriers': '│└┌─', + 'rightBarriers': '│┘┐─', }, 'review':{ 'lineBreak': True, diff --git a/src/fenrirscreenreader/core/textManager.py b/src/fenrirscreenreader/core/textManager.py index 05633f30..f7e701c9 100644 --- a/src/fenrirscreenreader/core/textManager.py +++ b/src/fenrirscreenreader/core/textManager.py @@ -9,6 +9,7 @@ import re, string class textManager(): def __init__(self): + # https://regex101.com/ self.regExSingle = re.compile(r'(([^\w\s])\2{5,})') self.regExDouble = re.compile(r'([^\w\s]{2,}){5,}') def initialize(self, environment):