finalize cleanup in API

This commit is contained in:
chrys 2016-12-03 02:04:38 +01:00
parent 4a5522e384
commit f4b86c37dc
27 changed files with 61 additions and 58 deletions

1
TODO
View File

@ -15,6 +15,7 @@ Known Bugs:
fd = os.open("/dev/tty5", os.O_RDONLY )
os.tcgetpgrp(fd)
- implement onScreenUpdate commands
read highlighted text mode

View File

@ -71,7 +71,7 @@ layout=en
[screen]
driver=linux
encoding=cp850
screenUpdateDelay=0.4
screenUpdateDelay=0.2
suspendingScreen=
autodetectSuspendingScreen=True

View File

@ -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 != '':

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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