diff --git a/TODO b/TODO index 0bc77da0..2f670d5f 100644 --- a/TODO +++ b/TODO @@ -15,6 +15,7 @@ Known Bugs: fd = os.open("/dev/tty5", os.O_RDONLY ) os.tcgetpgrp(fd) + - implement onScreenUpdate commands read highlighted text mode diff --git a/config/settings/settings.conf b/config/settings/settings.conf index 0ce3a3f9..0b924aea 100644 --- a/config/settings/settings.conf +++ b/config/settings/settings.conf @@ -71,7 +71,7 @@ layout=en [screen] driver=linux encoding=cp850 -screenUpdateDelay=0.4 +screenUpdateDelay=0.2 suspendingScreen= autodetectSuspendingScreen=True diff --git a/src/fenrir/commands/commands/add_word_to_spell_check.py b/src/fenrir/commands/commands/add_word_to_spell_check.py index 06a0b186..7b0a6277 100644 --- a/src/fenrir/commands/commands/add_word_to_spell_check.py +++ b/src/fenrir/commands/commands/add_word_to_spell_check.py @@ -41,7 +41,7 @@ class command(): cursorPos = self.env['runtime']['cursorManager'].getReviewOrTextCursor() # get the word newContent = self.env['screenData']['newContentText'].split('\n')[cursorPos['y']] - x, y, currWord = word_utils.getCurrentWord(cursorPos['x'], 0, newContent) + x, y, currWord, endOfScreen, lineBreak = word_utils.getCurrentWord(cursorPos['x'], 0, newContent) currWord = currWord.strip(string.whitespace + '!"#$%&\()*+,-./:;<=§>?@[\\]^_{|}~') if currWord != '': diff --git a/src/fenrir/commands/commands/remove_word_from_spell_check.py b/src/fenrir/commands/commands/remove_word_from_spell_check.py index 6799b516..3da3e665 100644 --- a/src/fenrir/commands/commands/remove_word_from_spell_check.py +++ b/src/fenrir/commands/commands/remove_word_from_spell_check.py @@ -43,7 +43,7 @@ class command(): # get the word newContent = self.env['screenData']['newContentText'].split('\n')[cursorPos['y']] - x, y, currWord = word_utils.getCurrentWord(cursorPos['x'], 0, newContent) + x, y, currWord, endOfScreen, lineBreak = word_utils.getCurrentWord(cursorPos['x'], 0, newContent) currWord = currWord.strip(string.whitespace + '!"#$%&\()*+,-./:;<=§>?@[\\]^_{|}~') if not currWord.isspace(): if self.spellChecker.is_removed(currWord): diff --git a/src/fenrir/commands/commands/review_curr_word.py b/src/fenrir/commands/commands/review_curr_word.py index 0d657a6b..880faa50 100644 --- a/src/fenrir/commands/commands/review_curr_word.py +++ b/src/fenrir/commands/commands/review_curr_word.py @@ -20,7 +20,7 @@ class command(): def run(self): self.env['runtime']['cursorManager'].enterReviewModeCurrTextCursor() - self.env['screenData']['newCursorReview']['x'], self.env['screenData']['newCursorReview']['y'], currWord = \ + self.env['screenData']['newCursorReview']['x'], self.env['screenData']['newCursorReview']['y'], currWord, endOfScreen, lineBreak = \ word_utils.getCurrentWord(self.env['screenData']['newCursorReview']['x'], self.env['screenData']['newCursorReview']['y'], self.env['screenData']['newContentText']) if currWord.isspace(): diff --git a/src/fenrir/commands/commands/review_curr_word_phonetic.py b/src/fenrir/commands/commands/review_curr_word_phonetic.py index edf6bc07..e98f4d15 100644 --- a/src/fenrir/commands/commands/review_curr_word_phonetic.py +++ b/src/fenrir/commands/commands/review_curr_word_phonetic.py @@ -20,7 +20,7 @@ class command(): def run(self): self.env['runtime']['cursorManager'].enterReviewModeCurrTextCursor() - self.env['screenData']['newCursorReview']['x'], self.env['screenData']['newCursorReview']['y'], currWord = \ + self.env['screenData']['newCursorReview']['x'], self.env['screenData']['newCursorReview']['y'], currWord, endOfScreen, lineBreak = \ word_utils.getCurrentWord(self.env['screenData']['newCursorReview']['x'], self.env['screenData']['newCursorReview']['y'], self.env['screenData']['newContentText']) if currWord.isspace(): diff --git a/src/fenrir/commands/commands/review_down.py b/src/fenrir/commands/commands/review_down.py index bea47c06..db7137e0 100644 --- a/src/fenrir/commands/commands/review_down.py +++ b/src/fenrir/commands/commands/review_down.py @@ -19,7 +19,7 @@ class command(): def run(self): cursorPos = self.env['runtime']['cursorManager'].getReviewOrTextCursor() - self.env['screenData']['newCursorReview']['x'], self.env['screenData']['newCursorReview']['y'], downChar = \ + self.env['screenData']['newCursorReview']['x'], self.env['screenData']['newCursorReview']['y'], downChar, endOfScreen = \ char_utils.getDownChar(self.env['screenData']['newCursorReview']['x'],self.env['screenData']['newCursorReview']['y'], self.env['screenData']['newContentText']) if downChar.isspace(): self.env['runtime']['outputManager'].presentText("line is empty" ,interrupt=True) diff --git a/src/fenrir/commands/commands/review_line_first_char.py b/src/fenrir/commands/commands/review_line_first_char.py index 6c173b11..61391813 100644 --- a/src/fenrir/commands/commands/review_line_first_char.py +++ b/src/fenrir/commands/commands/review_line_first_char.py @@ -22,16 +22,15 @@ class command(): cursorPos = self.env['runtime']['cursorManager'].getReviewOrTextCursor() x, y, currLine = \ line_utils.getCurrentLine(cursorPos['x'], cursorPos['y'], self.env['screenData']['newContentText']) - - self.env['runtime']['cursorManager'].setReviewCursorPosition((len(currLine) - len(currLine.lstrip())) - ,cursorPos['y']) + if currLine.isspace(): + self.env['runtime']['outputManager'].presentText("line is empty" ,interrupt=True) + return + self.env['runtime']['cursorManager'].setReviewCursorPosition((len(currLine) - len(currLine.lstrip())), cursorPos['y']) self.env['screenData']['newCursorReview']['x'], self.env['screenData']['newCursorReview']['y'], currChar = \ char_utils.getCurrentChar(self.env['screenData']['newCursorReview']['x'], self.env['screenData']['newCursorReview']['y'], self.env['screenData']['newContentText']) - if currChar.isspace(): - self.env['runtime']['outputManager'].presentText("line is empty" ,interrupt=True) - else: - self.env['runtime']['outputManager'].presentText(currChar ,interrupt=True, ignorePunctuation=True, announceCapital=True) - self.env['runtime']['outputManager'].presentText("first char in line indent " + str(len(currLine) - len(currLine.lstrip())), interrupt=False) + + self.env['runtime']['outputManager'].presentText(currChar ,interrupt=True, ignorePunctuation=True, announceCapital=True) + self.env['runtime']['outputManager'].presentText("first char in line indent " + str(len(currLine) - len(currLine.lstrip())), interrupt=False) def setCallback(self, callback): pass diff --git a/src/fenrir/commands/commands/review_next_char.py b/src/fenrir/commands/commands/review_next_char.py index 366e9a70..b5667f4e 100644 --- a/src/fenrir/commands/commands/review_next_char.py +++ b/src/fenrir/commands/commands/review_next_char.py @@ -19,13 +19,13 @@ class command(): def run(self): self.env['runtime']['cursorManager'].enterReviewModeCurrTextCursor() - self.env['screenData']['newCursorReview']['x'], self.env['screenData']['newCursorReview']['y'], currChar = \ + self.env['screenData']['newCursorReview']['x'], self.env['screenData']['newCursorReview']['y'], nextChar, endOfScreen, lineBreak = \ char_utils.getNextChar(self.env['screenData']['newCursorReview']['x'], self.env['screenData']['newCursorReview']['y'], self.env['screenData']['newContentText']) - if currChar.isspace(): + if nextChar.isspace(): self.env['runtime']['outputManager'].presentText("space", interrupt=True) else: - self.env['runtime']['outputManager'].presentText(currChar, interrupt=True, ignorePunctuation=True, announceCapital=True) + self.env['runtime']['outputManager'].presentText(nextChar, interrupt=True, ignorePunctuation=True, announceCapital=True) def setCallback(self, callback): pass diff --git a/src/fenrir/commands/commands/review_next_char_phonetic.py b/src/fenrir/commands/commands/review_next_char_phonetic.py index 73cd2f82..1b76ddd7 100644 --- a/src/fenrir/commands/commands/review_next_char_phonetic.py +++ b/src/fenrir/commands/commands/review_next_char_phonetic.py @@ -20,7 +20,7 @@ class command(): def run(self): self.env['runtime']['cursorManager'].enterReviewModeCurrTextCursor() - self.env['screenData']['newCursorReview']['x'], self.env['screenData']['newCursorReview']['y'], nextChar = \ + self.env['screenData']['newCursorReview']['x'], self.env['screenData']['newCursorReview']['y'], nextChar, endOfScreen, lineBreak = \ char_utils.getNextChar(self.env['screenData']['newCursorReview']['x'], self.env['screenData']['newCursorReview']['y'], self.env['screenData']['newContentText']) if nextChar.isspace(): diff --git a/src/fenrir/commands/commands/review_next_line.py b/src/fenrir/commands/commands/review_next_line.py index 94966046..165508dc 100644 --- a/src/fenrir/commands/commands/review_next_line.py +++ b/src/fenrir/commands/commands/review_next_line.py @@ -22,13 +22,13 @@ class command(): if not self.env['screenData']['newCursorReview']: self.env['screenData']['newCursorReview'] = self.env['screenData']['newCursor'].copy() - self.env['screenData']['newCursorReview']['x'], self.env['screenData']['newCursorReview']['y'], currLine = \ + self.env['screenData']['newCursorReview']['x'], self.env['screenData']['newCursorReview']['y'], nextLine, endOfScreen = \ line_utils.getNextLine(self.env['screenData']['newCursorReview']['x'], self.env['screenData']['newCursorReview']['y'], self.env['screenData']['newContentText']) - if currLine.isspace(): + if nextLine.isspace(): self.env['runtime']['outputManager'].presentText("blank", soundIcon='EmptyLine', interrupt=True) else: - self.env['runtime']['outputManager'].presentText(currLine, interrupt=True) + self.env['runtime']['outputManager'].presentText(nextLine, interrupt=True) def setCallback(self, callback): pass diff --git a/src/fenrir/commands/commands/review_next_word.py b/src/fenrir/commands/commands/review_next_word.py index c41c6f5d..5607c492 100644 --- a/src/fenrir/commands/commands/review_next_word.py +++ b/src/fenrir/commands/commands/review_next_word.py @@ -22,13 +22,13 @@ class command(): if self.env['screenData']['newCursorReview'] == None: self.env['screenData']['newCursorReview'] = self.env['screenData']['newCursor'].copy() - self.env['screenData']['newCursorReview']['x'], self.env['screenData']['newCursorReview']['y'], currWord = \ + self.env['screenData']['newCursorReview']['x'], self.env['screenData']['newCursorReview']['y'], nextWord, endOfScreen, lineBreak = \ word_utils.getNextWord(self.env['screenData']['newCursorReview']['x'], self.env['screenData']['newCursorReview']['y'], self.env['screenData']['newContentText']) - if currWord.isspace(): + if nextWord.isspace(): self.env['runtime']['outputManager'].presentText("blank", interrupt=True) else: - self.env['runtime']['outputManager'].presentText(currWord, interrupt=True) + self.env['runtime']['outputManager'].presentText(nextWord, interrupt=True) def setCallback(self, callback): pass diff --git a/src/fenrir/commands/commands/review_next_word_phonetic.py b/src/fenrir/commands/commands/review_next_word_phonetic.py index f646dbb0..6dea9f1b 100644 --- a/src/fenrir/commands/commands/review_next_word_phonetic.py +++ b/src/fenrir/commands/commands/review_next_word_phonetic.py @@ -20,7 +20,7 @@ class command(): def run(self): self.env['runtime']['cursorManager'].enterReviewModeCurrTextCursor() - self.env['screenData']['newCursorReview']['x'], self.env['screenData']['newCursorReview']['y'], nextWord = \ + self.env['screenData']['newCursorReview']['x'], self.env['screenData']['newCursorReview']['y'], nextWord, endOfScreen, lineBreak = \ word_utils.getNextWord(self.env['screenData']['newCursorReview']['x'], self.env['screenData']['newCursorReview']['y'], self.env['screenData']['newContentText']) if nextWord.isspace(): diff --git a/src/fenrir/commands/commands/review_prev_char.py b/src/fenrir/commands/commands/review_prev_char.py index 6cfb8705..22d8a3cb 100644 --- a/src/fenrir/commands/commands/review_prev_char.py +++ b/src/fenrir/commands/commands/review_prev_char.py @@ -22,13 +22,13 @@ class command(): if not self.env['screenData']['newCursorReview']: self.env['screenData']['newCursorReview'] = self.env['screenData']['newCursor'].copy() - self.env['screenData']['newCursorReview']['x'], self.env['screenData']['newCursorReview']['y'], currChar = \ + self.env['screenData']['newCursorReview']['x'], self.env['screenData']['newCursorReview']['y'], prevChar, endOfScreen, lineBreak = \ char_utils.getPrevChar(self.env['screenData']['newCursorReview']['x'], self.env['screenData']['newCursorReview']['y'], self.env['screenData']['newContentText']) - if currChar.isspace(): + if prevChar.isspace(): self.env['runtime']['outputManager'].presentText("space", interrupt=True) else: - self.env['runtime']['outputManager'].presentText(currChar, interrupt=True, ignorePunctuation=True, announceCapital=True) + self.env['runtime']['outputManager'].presentText(prevChar, interrupt=True, ignorePunctuation=True, announceCapital=True) def setCallback(self, callback): pass diff --git a/src/fenrir/commands/commands/review_prev_char_phonetic.py b/src/fenrir/commands/commands/review_prev_char_phonetic.py index 846cb8de..5340cdde 100644 --- a/src/fenrir/commands/commands/review_prev_char_phonetic.py +++ b/src/fenrir/commands/commands/review_prev_char_phonetic.py @@ -20,14 +20,14 @@ class command(): def run(self): self.env['runtime']['cursorManager'].enterReviewModeCurrTextCursor() - self.env['screenData']['newCursorReview']['x'], self.env['screenData']['newCursorReview']['y'], nextChar = \ + self.env['screenData']['newCursorReview']['x'], self.env['screenData']['newCursorReview']['y'], prevChar, endOfScreen, lineBreak = \ char_utils.getPrevChar(self.env['screenData']['newCursorReview']['x'], self.env['screenData']['newCursorReview']['y'], self.env['screenData']['newContentText']) - if nextChar.isspace(): + if prevChar.isspace(): self.env['runtime']['outputManager'].presentText("blank" ,interrupt=True) else: - nextChar = char_utils.getPhonetic(nextChar) - self.env['runtime']['outputManager'].presentText(nextChar ,interrupt=True, announceCapital=True) + prevChar = char_utils.getPhonetic(prevChar) + self.env['runtime']['outputManager'].presentText(prevChar ,interrupt=True, announceCapital=True) def setCallback(self, callback): pass diff --git a/src/fenrir/commands/commands/review_prev_line.py b/src/fenrir/commands/commands/review_prev_line.py index 16d1f135..85e1803e 100644 --- a/src/fenrir/commands/commands/review_prev_line.py +++ b/src/fenrir/commands/commands/review_prev_line.py @@ -20,13 +20,13 @@ class command(): def run(self): self.env['runtime']['cursorManager'].enterReviewModeCurrTextCursor() - self.env['screenData']['newCursorReview']['x'], self.env['screenData']['newCursorReview']['y'], currLine = \ + self.env['screenData']['newCursorReview']['x'], self.env['screenData']['newCursorReview']['y'], prevLine, endOfScreen = \ line_utils.getPrevLine(self.env['screenData']['newCursorReview']['x'], self.env['screenData']['newCursorReview']['y'], self.env['screenData']['newContentText']) - if currLine.isspace(): + if prevLine.isspace(): self.env['runtime']['outputManager'].presentText("blank", soundIcon='EmptyLine', interrupt=True) else: - self.env['runtime']['outputManager'].presentText(currLine, interrupt=True) + self.env['runtime']['outputManager'].presentText(prevLine, interrupt=True) def setCallback(self, callback): pass diff --git a/src/fenrir/commands/commands/review_prev_word.py b/src/fenrir/commands/commands/review_prev_word.py index 2085492b..d7dfc306 100644 --- a/src/fenrir/commands/commands/review_prev_word.py +++ b/src/fenrir/commands/commands/review_prev_word.py @@ -20,13 +20,13 @@ class command(): def run(self): self.env['runtime']['cursorManager'].enterReviewModeCurrTextCursor() - self.env['screenData']['newCursorReview']['x'], self.env['screenData']['newCursorReview']['y'], currWord = \ + self.env['screenData']['newCursorReview']['x'], self.env['screenData']['newCursorReview']['y'], prevWord, endOfScreen, lineBreak = \ word_utils.getPrevWord(self.env['screenData']['newCursorReview']['x'], self.env['screenData']['newCursorReview']['y'], self.env['screenData']['newContentText']) - if currWord.isspace(): + if prevWord.isspace(): self.env['runtime']['outputManager'].presentText("blank", interrupt=True) else: - self.env['runtime']['outputManager'].presentText(currWord, interrupt=True) + self.env['runtime']['outputManager'].presentText(prevWord, interrupt=True) def setCallback(self, callback): pass diff --git a/src/fenrir/commands/commands/review_prev_word_phonetic.py b/src/fenrir/commands/commands/review_prev_word_phonetic.py index f1f5ba5c..b701d70f 100644 --- a/src/fenrir/commands/commands/review_prev_word_phonetic.py +++ b/src/fenrir/commands/commands/review_prev_word_phonetic.py @@ -20,7 +20,7 @@ class command(): def run(self): self.env['runtime']['cursorManager'].enterReviewModeCurrTextCursor() - self.env['screenData']['newCursorReview']['x'], self.env['screenData']['newCursorReview']['y'], prevWord = \ + self.env['screenData']['newCursorReview']['x'], self.env['screenData']['newCursorReview']['y'], prevWord, endOfScreen, lineBreak = \ word_utils.getPrevWord(self.env['screenData']['newCursorReview']['x'], self.env['screenData']['newCursorReview']['y'], self.env['screenData']['newContentText']) if prevWord.isspace(): diff --git a/src/fenrir/commands/commands/review_up.py b/src/fenrir/commands/commands/review_up.py index 9637f9e2..94d23461 100644 --- a/src/fenrir/commands/commands/review_up.py +++ b/src/fenrir/commands/commands/review_up.py @@ -19,7 +19,7 @@ class command(): def run(self): cursorPos = self.env['runtime']['cursorManager'].getReviewOrTextCursor() - self.env['screenData']['newCursorReview']['x'], self.env['screenData']['newCursorReview']['y'], upChar = \ + self.env['screenData']['newCursorReview']['x'], self.env['screenData']['newCursorReview']['y'], upChar, endOfScreen = \ char_utils.getUpChar(self.env['screenData']['newCursorReview']['x'],self.env['screenData']['newCursorReview']['y'], self.env['screenData']['newContentText']) if upChar.isspace(): self.env['runtime']['outputManager'].presentText("line is empty" ,interrupt=True) diff --git a/src/fenrir/commands/commands/spell_check.py b/src/fenrir/commands/commands/spell_check.py index 363b8624..7d37150a 100644 --- a/src/fenrir/commands/commands/spell_check.py +++ b/src/fenrir/commands/commands/spell_check.py @@ -42,7 +42,7 @@ class command(): # get the word newContent = self.env['screenData']['newContentText'].split('\n')[cursorPos['y']] - x, y, currWord = word_utils.getCurrentWord(cursorPos['x'], 0, newContent) + x, y, currWord, endOfScreen, lineBreak = word_utils.getCurrentWord(cursorPos['x'], 0, newContent) if not currWord.isspace(): if not self.spellChecker.check(currWord): diff --git a/src/fenrir/commands/onInput/50000-char_echo.py b/src/fenrir/commands/onInput/50000-char_echo.py index 114370d0..031f65c1 100644 --- a/src/fenrir/commands/onInput/50000-char_echo.py +++ b/src/fenrir/commands/onInput/50000-char_echo.py @@ -23,7 +23,7 @@ class command(): if self.env['screenData']['newCursor']['x'] <= self.env['screenData']['oldCursor']['x']: return # is there any change? - if not self.environment['runtime']['screenManager'].isDelta(): + if not self.env['runtime']['screenManager'].isDelta(): return # big changes are no char (but the value is bigger than one maybe the differ needs longer than you can type, so a little strange random buffer for now) if len(self.env['screenData']['newDelta']) > 3: diff --git a/src/fenrir/commands/onInput/60000-word_echo.py b/src/fenrir/commands/onInput/60000-word_echo.py index 9b9564ad..2ed2721a 100644 --- a/src/fenrir/commands/onInput/60000-word_echo.py +++ b/src/fenrir/commands/onInput/60000-word_echo.py @@ -36,7 +36,8 @@ class command(): return # get the word newContent = self.env['screenData']['newContentText'].split('\n')[self.env['screenData']['newCursor']['y']] - x, y, currWord = word_utils.getCurrentWord(self.env['screenData']['newCursor']['x'], 0, newContent) + x, y, currWord, endOfScreen, lineBreak = \ + word_utils.getCurrentWord(self.env['screenData']['newCursor']['x'], 0, newContent) # was this a typed word? if self.env['runtime']['screenManager'].isDelta(): # is there a delta bigger than keyecho? diff --git a/src/fenrir/commands/onInput/62000-spell_check.py b/src/fenrir/commands/onInput/62000-spell_check.py index 2024ea4f..cc503e29 100644 --- a/src/fenrir/commands/onInput/62000-spell_check.py +++ b/src/fenrir/commands/onInput/62000-spell_check.py @@ -63,7 +63,7 @@ class command(): # get the word (just for speedup only look at current line newContent = self.env['screenData']['newContentText'].split('\n')[self.env['screenData']['newCursor']['y']] - x, y, currWord, endOfScreen, lineBreak = word_utils.getCurrentWord(self.env['screenData']['newCursor']['x'], 0, newContent) + x, y, currWord, endOfScreen, lineBreak = word_utils.getCurrentWord(self.env['screenData']['newCursor']['x'], 0, newContent) # was this a typed word? if self.env['screenData']['newDelta'] != '': if not(newContent[self.env['screenData']['oldCursor']['x']] in string.whitespace + '!"#$%&()*+,-./:;<=>?@[\\]^_{|}~' and x != self.env['screenData']['oldCursor']['x']): diff --git a/src/fenrir/commands/onInput/65000-char_delete_echo.py b/src/fenrir/commands/onInput/65000-char_delete_echo.py index 2926e210..89c11079 100644 --- a/src/fenrir/commands/onInput/65000-char_delete_echo.py +++ b/src/fenrir/commands/onInput/65000-char_delete_echo.py @@ -26,10 +26,10 @@ class command(): # More than just a deletion happend - if self.environment['runtime']['screenManager'].isDelta(): + if self.env['runtime']['screenManager'].isDelta(): return # no deletion - if not self.environment['runtime']['screenManager'].isNegativeDelta(): + if not self.env['runtime']['screenManager'].isNegativeDelta(): return if self.env['runtime']['inputManager'].noKeyPressed(): return diff --git a/src/fenrir/utils/char_utils.py b/src/fenrir/utils/char_utils.py index 78d1950f..0d029631 100644 --- a/src/fenrir/utils/char_utils.py +++ b/src/fenrir/utils/char_utils.py @@ -10,7 +10,7 @@ def getPrevChar(currX,currY, currText): lineBreak = False endOfScreen = False if currText == '': - return -1, -1, '', endOfScreen + return -1, -1, '', endOfScreen, lineBreak wrappedLines = currText.split('\n') x = currX y = currY @@ -20,6 +20,7 @@ def getPrevChar(currX,currY, currText): x = len(wrappedLines[y]) - 1 lineBreak = True else: + lineBreak = False endOfScreen = True else: x -= 1 @@ -28,7 +29,7 @@ def getPrevChar(currX,currY, currText): def getCurrentChar(currX,currY, currText): if currText == '': - return -1, -1, '', endOfScreen + return -1, -1, '' wrappedLines = currText.split('\n') currChar = wrappedLines[currY][currX] return currX, currY, currChar @@ -62,19 +63,19 @@ def getDownChar(currX,currY, currText): def getLastCharInLine(currY, currText): endOfScreen = False if currText == '': - return -1, -1, '', endOfScreen + return -1, -1, '' wrappedLines = currText.split('\n') currX = len(wrappedLines[currY].rstrip())-1 if currX < 0: currX = 0 currChar = wrappedLines[currY][currX] - return currX, currY, currChar, endOfScreen + return currX, currY, currChar def getNextChar(currX,currY, currText): lineBreak = False endOfScreen = False if currText == '': - return -1, -1, '', endOfScreen + return -1, -1, '', endOfScreen, lineBreak wrappedLines = currText.split('\n') x = currX y = currY @@ -84,11 +85,12 @@ def getNextChar(currX,currY, currText): x = 0 lineBreak = True else: + lineBreak = False endOfScreen = True else: x += 1 currChar = wrappedLines[y][x] - return x, y, currChar, endOfScreen + return x, y, currChar, endOfScreen, lineBreak def getPhonetic(currChar): if len(currChar) != 1: diff --git a/src/fenrir/utils/line_utils.py b/src/fenrir/utils/line_utils.py index ac6b442e..d7f49ac0 100644 --- a/src/fenrir/utils/line_utils.py +++ b/src/fenrir/utils/line_utils.py @@ -24,7 +24,7 @@ def getPrevLine(currX,currY, currText): def getCurrentLine(currX,currY, currText): if currText == '': - return -1, -1, '', endOfScreen + return -1, -1, '' wrappedLines = currText.split('\n') x = currX y = currY diff --git a/src/fenrir/utils/word_utils.py b/src/fenrir/utils/word_utils.py index e2bcdbfb..0df92429 100644 --- a/src/fenrir/utils/word_utils.py +++ b/src/fenrir/utils/word_utils.py @@ -11,10 +11,10 @@ def getPrevWord(currX,currY, currText): lineBreak = False endOfScreen = False if currText == '': - return -1, -1, '', endOfScreen - x, y, currWord, endOfScreen = getCurrentWord(currX,currY,currText) + return -1, -1, '', endOfScreen, lineBreak + x, y, currWord, endOfScreen, lineBreak = getCurrentWord(currX,currY,currText) if endOfScreen: - return x, y, currWord, endOfScreen + return x, y, currWord, endOfScreen, lineBreak wrappedLines = currText.split('\n') return x, y, currWord, endOfScreen, lineBreak @@ -22,7 +22,7 @@ def getCurrentWord(currX,currY, currText): lineBreak = False endOfScreen = False if currText == '': - return -1, -1, '', endOfScreen + return -1, -1, '', endOfScreen, lineBreak x = currX y = currY wrappedLines = currText.split('\n') @@ -34,7 +34,7 @@ def getNextWord(currX,currY, currText): lineBreak = False endOfScreen = False if currText == '': - return -1, -1, '', endOfScreen + return -1, -1, '', endOfScreen, lineBreak x = currX y = currY wrappedLines = currText.split('\n')