From c8e23b8d78d060a3db5fe1f4c379339337cd1349 Mon Sep 17 00:00:00 2001 From: chrys Date: Thu, 22 Dec 2016 23:08:16 +0100 Subject: [PATCH] tweak char and line utils --- src/fenrir/core/outputManager.py | 2 ++ src/fenrir/utils/char_utils.py | 18 +++++++++++++----- src/fenrir/utils/line_utils.py | 8 ++++++-- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/fenrir/core/outputManager.py b/src/fenrir/core/outputManager.py index adf35832..fc108b94 100644 --- a/src/fenrir/core/outputManager.py +++ b/src/fenrir/core/outputManager.py @@ -24,6 +24,8 @@ class outputManager(): self.env['runtime']['settingsManager'].shutdownDriver('brailleDriver') def presentText(self, text, interrupt=True, soundIcon = '', ignorePunctuation=False, announceCapital=False): + if text == '': + return self.env['runtime']['debug'].writeDebugOut("presentText:\nsoundIcon:'"+soundIcon+"'\nText:\n" + text ,debug.debugLevel.INFO) if self.playSoundIcon(soundIcon, interrupt): self.env['runtime']['debug'].writeDebugOut("soundIcon found" ,debug.debugLevel.INFO) diff --git a/src/fenrir/utils/char_utils.py b/src/fenrir/utils/char_utils.py index 0d029631..1dc9d266 100644 --- a/src/fenrir/utils/char_utils.py +++ b/src/fenrir/utils/char_utils.py @@ -15,7 +15,7 @@ def getPrevChar(currX,currY, currText): x = currX y = currY if x - 1 < 0: - if y - 1 > 0: + if y - 1 >= 0: y -= 1 x = len(wrappedLines[y]) - 1 lineBreak = True @@ -24,7 +24,9 @@ def getPrevChar(currX,currY, currText): endOfScreen = True else: x -= 1 - currChar = wrappedLines[y][x] + currChar = '' + if not endOfScreen: + currChar = wrappedLines[y][x] return x, y, currChar, endOfScreen, lineBreak def getCurrentChar(currX,currY, currText): @@ -44,7 +46,9 @@ def getUpChar(currX,currY, currText): currY = 0 else: endOfScreen = True - currChar = wrappedLines[currY][currX] + currChar = '' + if not endOfScreen: + currChar = wrappedLines[currY][currX] return currX, currY, currChar, endOfScreen def getDownChar(currX,currY, currText): @@ -57,7 +61,9 @@ def getDownChar(currX,currY, currText): currY = len(wrappedLines) -1 else: endOfScreen = True - currChar = wrappedLines[currY][currX] + currChar = '' + if not endOfScreen: + currChar = wrappedLines[currY][currX] return currX, currY, currChar, endOfScreen def getLastCharInLine(currY, currText): @@ -89,7 +95,9 @@ def getNextChar(currX,currY, currText): endOfScreen = True else: x += 1 - currChar = wrappedLines[y][x] + currChar = '' + if not endOfScreen: + currChar = wrappedLines[y][x] return x, y, currChar, endOfScreen, lineBreak def getPhonetic(currChar): diff --git a/src/fenrir/utils/line_utils.py b/src/fenrir/utils/line_utils.py index d7f49ac0..7e6340f0 100644 --- a/src/fenrir/utils/line_utils.py +++ b/src/fenrir/utils/line_utils.py @@ -19,7 +19,9 @@ def getPrevLine(currX,currY, currText): else: endOfScreen = True x = 0 - currLine = wrappedLines[y] + currLine = '' + if not endOfScreen: + currLine = wrappedLines[y] return x, y, currLine, endOfScreen def getCurrentLine(currX,currY, currText): @@ -44,5 +46,7 @@ def getNextLine(currX,currY, currText): else: endOfScreen = True x = 0 - currLine = wrappedLines[y] + currLine = '' + if not endOfScreen: + currLine = wrappedLines[y] return x, y, currLine, endOfScreen