fix mistakes

This commit is contained in:
chrys 2016-09-24 02:45:12 +02:00
parent f5c31b2406
commit 4500ca76aa
6 changed files with 17 additions and 62 deletions

View File

@ -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

View File

@ -14,16 +14,19 @@ class applicationManager():
def shutdown(self): def shutdown(self):
pass pass
def getCurrentApplication(self): def getCurrentApplication(self):
currApp = self.environment['screenData']['newApplication'].upper() print(self.env['screenData']['newApplication'])
currApp = self.env['screenData']['newApplication'].upper()
if not currApp: if not currApp:
currApp == 'DEFAULT' currApp == 'DEFAULT'
if currApp == '': if currApp == '':
currApp == 'DEFAULT' currApp == 'DEFAULT'
return currApp
def getPrevApplication(self): def getPrevApplication(self):
prevApp = self.environment['screenData']['oldApplication'].upper() prevApp = self.env['screenData']['oldApplication'].upper()
if not prevApp: if not prevApp:
prevApp == 'DEFAULT' prevApp == 'DEFAULT'
if prevApp == '': if prevApp == '':
prevApp == 'DEFAULT' prevApp == 'DEFAULT'
return prevApp
def isApplicationChange(self): def isApplicationChange(self):
return self.environment['screenData']['oldApplication'] != self.environment['screenData']['newApplication'] return self.env['screenData']['oldApplication'] != self.env['screenData']['newApplication']

View File

@ -31,9 +31,9 @@ class cursorManager():
self.env['commandBuffer']['Marks']['2'] = self.env['screenData']['newCursorReview'].copy() self.env['commandBuffer']['Marks']['2'] = self.env['screenData']['newCursorReview'].copy()
def getReviewOrTextCursor(self): def getReviewOrTextCursor(self):
if self.env['screenData']['newCursorReview']: if self.env['screenData']['newCursorReview']:
return = self.env['screenData']['newCursorReview'].copy() return self.env['screenData']['newCursorReview'].copy()
else: else:
return = self.env['screenData']['newCursor'].copy() return self.env['screenData']['newCursor'].copy()
def clearReviewCursor(self): def clearReviewCursor(self):
self.env['screenData']['oldCursorReview'] = None self.env['screenData']['oldCursorReview'] = None
self.env['screenData']['newCursorReview'] = None self.env['screenData']['newCursorReview'] = None

View File

@ -17,7 +17,7 @@ screenData = {
'oldContentBytes': b'', 'oldContentBytes': b'',
'oldContentText': '', 'oldContentText': '',
'oldContentAttrib': b'', 'oldContentAttrib': b'',
'oldApplication': [], 'oldApplication': '',
'oldTTY':'-1', 'oldTTY':'-1',
'newDelta': '', 'newDelta': '',
'newNegativeDelta': '', 'newNegativeDelta': '',
@ -27,6 +27,6 @@ screenData = {
'newContentText': '', 'newContentText': '',
'newContentAttrib': b'', 'newContentAttrib': b'',
'newTTY':'0', 'newTTY':'0',
'newApplication': [], 'newApplication': '',
'lastScreenUpdate': time.time() 'lastScreenUpdate': time.time()
} }

View File

@ -32,4 +32,4 @@ class screenManager():
self.env['runtime']['settingsManager'].getSetting('screen', 'suspendingScreen').split(',')) or self.env['runtime']['settingsManager'].getSetting('screen', 'suspendingScreen').split(',')) or
(currScreen in self.autoIgnoreScreens)) (currScreen in self.autoIgnoreScreens))
def isScreenChange(self): def isScreenChange(self):
return self.environment['screenData']['newTTY'] != self.environment['screenData']['oldTTY'] return self.env['screenData']['newTTY'] != self.env['screenData']['oldTTY']

View File

@ -57,9 +57,10 @@ class fenrir():
self.environment['runtime']['applicationManager'].getCurrentApplication()) self.environment['runtime']['applicationManager'].getCurrentApplication())
self.environment['runtime']['commandManager'].executeDefaultTrigger('onInput') self.environment['runtime']['commandManager'].executeDefaultTrigger('onInput')
if self.environment['runtime']['screenManager'].isScreenChange(): if self.environment['runtime']['screenManager'].isScreenChange():
self.environment['runtime']['commandManager'].executeDefaultTrigger('onScreenUpdate')
else:
self.environment['runtime']['commandManager'].executeDefaultTrigger('onScreenChanged') self.environment['runtime']['commandManager'].executeDefaultTrigger('onScreenChanged')
else:
self.environment['runtime']['commandManager'].executeDefaultTrigger('onScreenUpdate')
self.handleCommands() self.handleCommands()
def prepareCommand(self): def prepareCommand(self):