speak word when navigating cursor by word with CTRL + B

This commit is contained in:
chrys 2017-09-26 23:26:59 +02:00
parent c07ac6ca3d
commit 52a8342a3c

View File

@ -29,23 +29,27 @@ class command():
# for now no new line # for now no new line
if self.env['runtime']['cursorManager'].isCursorVerticalMove(): if self.env['runtime']['cursorManager'].isCursorVerticalMove():
return return
# currently writing
if self.env['runtime']['screenManager'].isDelta():
return
# get the word # get the word
newContent = self.env['screen']['newContentText'].split('\n')[self.env['screen']['newCursor']['y']] newContent = self.env['screen']['newContentText'].split('\n')[self.env['screen']['newCursor']['y']]
x, y, currWord, endOfScreen, lineBreak = \ x, y, currWord, endOfScreen, lineBreak = \
word_utils.getCurrentWord(self.env['screen']['newCursor']['x'], 0, newContent) word_utils.getCurrentWord(self.env['screen']['newCursor']['x'], 0, newContent)
# currently writing # is there a word?
if self.env['runtime']['screenManager'].isDelta(): if currWord == '':
return return
# navigate prev word # navigate prev word
if self.env['screen']['oldCursor']['x'] - self.env['screen']['newCursor']['x'] > 1: if self.env['screen']['oldCursor']['x'] - self.env['screen']['newCursor']['x'] > 1:
# at the end of a word # at the start of a word
if newContent[self.env['screen']['newCursor']['x']].isspace(): if newContent[self.env['screen']['newCursor']['x']].isspace():
return return
if self.env['screen']['newCursor']['x'] != x: if self.env['screen']['newCursor']['x'] != x:
return return
# next word # navigate next word
else: else:
# at the end of a word # at the end of a word
if not newContent[self.env['screen']['newCursor']['x']].isspace(): if not newContent[self.env['screen']['newCursor']['x']].isspace():
@ -54,8 +58,7 @@ class command():
(x + len(currWord) != self.env['screen']['newCursor']['x']-1): (x + len(currWord) != self.env['screen']['newCursor']['x']-1):
return return
if currWord != '': self.env['runtime']['outputManager'].presentText(currWord, interrupt=True, flush=False)
self.env['runtime']['outputManager'].presentText(currWord, interrupt=True, flush=False)
def setCallback(self, callback): def setCallback(self, callback):
pass pass