From 4500ca76aa4447bc521b4cd2ea4ea2bbb6a28249 Mon Sep 17 00:00:00 2001 From: chrys Date: Sat, 24 Sep 2016 02:45:12 +0200 Subject: [PATCH] fix mistakes --- .../commands/commands/bookmark_1.py | 49 ------------------- src/fenrir-package/core/applicationManager.py | 11 +++-- src/fenrir-package/core/cursorManager.py | 6 +-- src/fenrir-package/core/screenData.py | 4 +- src/fenrir-package/core/screenManager.py | 2 +- src/fenrir-package/fenrir.py | 7 +-- 6 files changed, 17 insertions(+), 62 deletions(-) delete mode 100644 src/fenrir-package/commands/commands/bookmark_1.py diff --git a/src/fenrir-package/commands/commands/bookmark_1.py b/src/fenrir-package/commands/commands/bookmark_1.py deleted file mode 100644 index a9b032ba..00000000 --- a/src/fenrir-package/commands/commands/bookmark_1.py +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/python -# -*- coding: utf-8 -*- - -# Fenrir TTY screen reader -# By Chrys, Storm Dragon, and contributers. - -from core import debug -from utils import mark_utils - -class command(): - def __init__(self): - self.ID = '1' - def initialize(self, environment): - self.env = environment - def shutdown(self): - pass - def getDescription(self): - return 'read Bookmark ' + self.ID - - def run(self): - currApp = self.environment['runtime']['applicationManager'].getCurrentApplication() - - if not self.env['commandBuffer']['bookMarks'][self.ID]: - self.env['runtime']['outputManager'].presentText("Bookmark " + self.ID + "not found.", interrupt=True) - return - if not self.env['commandBuffer']['bookMarks'][self.ID][currApp]: - self.env['runtime']['outputManager'].presentText("Bookmark for application " + currApp + "not found.", interrupt=True) - return - if not self.env['commandBuffer']['bookMarks'][self.ID][currApp]['1']: - self.env['runtime']['outputManager'].presentText("No valid bookmark position", interrupt=True) - return - - # set marks - marked = '' - startMark = self.env['commandBuffer']['bookMarks'][self.ID][currApp]['1'].copy() - if self.env['commandBuffer']['bookMarks'][self.ID][currApp]]['2']: - endMark = self.env['commandBuffer']['Marks']['2'].copy() - marked = mark_utils.getTextBetweenMarks(startMark, endMark, self.env['screenData']['newContentText']) - else: - x, y, marked = \ - line_utils.getCurrentLine(startMark['x'], startMark['y'], self.env['screenData']['newContentText']) - - if marked.strip(" \t\n") == '': - self.env['runtime']['outputManager'].presentText("blank", soundIcon='EmptyLine', interrupt=True) - else: - self.env['runtime']['outputManager'].presentText(marked, interrupt=True) - - def setCallback(self, callback): - pass diff --git a/src/fenrir-package/core/applicationManager.py b/src/fenrir-package/core/applicationManager.py index 7205bfd3..8ed5f9d3 100644 --- a/src/fenrir-package/core/applicationManager.py +++ b/src/fenrir-package/core/applicationManager.py @@ -14,16 +14,19 @@ class applicationManager(): def shutdown(self): pass def getCurrentApplication(self): - currApp = self.environment['screenData']['newApplication'].upper() + print(self.env['screenData']['newApplication']) + currApp = self.env['screenData']['newApplication'].upper() if not currApp: currApp == 'DEFAULT' if currApp == '': - currApp == 'DEFAULT' + currApp == 'DEFAULT' + return currApp def getPrevApplication(self): - prevApp = self.environment['screenData']['oldApplication'].upper() + prevApp = self.env['screenData']['oldApplication'].upper() if not prevApp: prevApp == 'DEFAULT' if prevApp == '': prevApp == 'DEFAULT' + return prevApp def isApplicationChange(self): - return self.environment['screenData']['oldApplication'] != self.environment['screenData']['newApplication'] + return self.env['screenData']['oldApplication'] != self.env['screenData']['newApplication'] diff --git a/src/fenrir-package/core/cursorManager.py b/src/fenrir-package/core/cursorManager.py index 139d79e0..afe8c8d5 100644 --- a/src/fenrir-package/core/cursorManager.py +++ b/src/fenrir-package/core/cursorManager.py @@ -25,15 +25,15 @@ class cursorManager(): return self.env['commandBuffer']['Marks']['1'] != None and \ self.env['commandBuffer']['Marks']['2'] != None def setMark(self): - if not self.env['commandBuffer']['Marks']['1']: + if not self.env['commandBuffer']['Marks']['1']: self.env['commandBuffer']['Marks']['1'] = self.env['screenData']['newCursorReview'].copy() else: self.env['commandBuffer']['Marks']['2'] = self.env['screenData']['newCursorReview'].copy() def getReviewOrTextCursor(self): if self.env['screenData']['newCursorReview']: - return = self.env['screenData']['newCursorReview'].copy() + return self.env['screenData']['newCursorReview'].copy() else: - return = self.env['screenData']['newCursor'].copy() + return self.env['screenData']['newCursor'].copy() def clearReviewCursor(self): self.env['screenData']['oldCursorReview'] = None self.env['screenData']['newCursorReview'] = None diff --git a/src/fenrir-package/core/screenData.py b/src/fenrir-package/core/screenData.py index 58bc16bc..28c43bda 100644 --- a/src/fenrir-package/core/screenData.py +++ b/src/fenrir-package/core/screenData.py @@ -17,7 +17,7 @@ screenData = { 'oldContentBytes': b'', 'oldContentText': '', 'oldContentAttrib': b'', -'oldApplication': [], +'oldApplication': '', 'oldTTY':'-1', 'newDelta': '', 'newNegativeDelta': '', @@ -27,6 +27,6 @@ screenData = { 'newContentText': '', 'newContentAttrib': b'', 'newTTY':'0', -'newApplication': [], +'newApplication': '', 'lastScreenUpdate': time.time() } diff --git a/src/fenrir-package/core/screenManager.py b/src/fenrir-package/core/screenManager.py index f0c18832..be344d72 100644 --- a/src/fenrir-package/core/screenManager.py +++ b/src/fenrir-package/core/screenManager.py @@ -32,4 +32,4 @@ class screenManager(): self.env['runtime']['settingsManager'].getSetting('screen', 'suspendingScreen').split(',')) or (currScreen in self.autoIgnoreScreens)) def isScreenChange(self): - return self.environment['screenData']['newTTY'] != self.environment['screenData']['oldTTY'] + return self.env['screenData']['newTTY'] != self.env['screenData']['oldTTY'] diff --git a/src/fenrir-package/fenrir.py b/src/fenrir-package/fenrir.py index c326c5de..f0655678 100755 --- a/src/fenrir-package/fenrir.py +++ b/src/fenrir-package/fenrir.py @@ -49,7 +49,7 @@ class fenrir(): except Exception as e: print(e) self.environment['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR) - + if self.environment['runtime']['applicationManager'].isApplicationChange(): self.environment['runtime']['commandManager'].executeDefaultTrigger('onApplicationChange') self.environment['runtime']['commandManager'].executeSwitchTrigger('onSwitchApplicationProfile', \ @@ -57,9 +57,10 @@ class fenrir(): self.environment['runtime']['applicationManager'].getCurrentApplication()) self.environment['runtime']['commandManager'].executeDefaultTrigger('onInput') if self.environment['runtime']['screenManager'].isScreenChange(): - self.environment['runtime']['commandManager'].executeDefaultTrigger('onScreenUpdate') - else: self.environment['runtime']['commandManager'].executeDefaultTrigger('onScreenChanged') + else: + self.environment['runtime']['commandManager'].executeDefaultTrigger('onScreenUpdate') + self.handleCommands() def prepareCommand(self):