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):
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'
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']

View File

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

View File

@ -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()
}

View File

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

View File

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