54 lines
2.1 KiB
Python
Raw Normal View History

2016-08-07 17:00:54 +02:00
#!/bin/python
from utils import word_utils
class command():
def __init__(self):
pass
def initialize(self, environment):
pass
def shutdown(self, environment):
pass
2016-09-17 02:14:11 +02:00
def getDescription(self, environment):
return ''
2016-09-17 02:14:11 +02:00
2016-08-07 17:00:54 +02:00
def run(self, environment):
if not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'keyboard', 'wordEcho'):
return
2016-08-07 17:00:54 +02:00
# just when cursor move worddetection is needed
if environment['screenData']['newCursor']['x'] == environment['screenData']['oldCursor']['x']:
return
2016-08-07 17:00:54 +02:00
# for now no new line
if environment['screenData']['newCursor']['y'] != environment['screenData']['oldCursor']['y']:
return environment
if len(environment['screenData']['newDelta']) > 1:
return
2016-08-07 17:00:54 +02:00
# TTY Change is no new word
if environment['screenData']['newTTY'] != environment['screenData']['oldTTY']:
return
2016-08-07 17:00:54 +02:00
# first place could not be the end of a word
if environment['screenData']['newCursor']['x'] == 0:
return
2016-08-07 17:00:54 +02:00
# get the word
newContent = environment['screenData']['newContentText'].split('\n')[environment['screenData']['newCursor']['y']]
x, y, currWord = word_utils.getCurrentWord(environment['screenData']['newCursor']['x'], 0, newContent)
2016-08-08 20:59:07 +02:00
# was this a typed word?
if environment['screenData']['newDelta'] != '':
2016-08-28 17:45:16 +02:00
if not(newContent[environment['screenData']['oldCursor']['x']].strip() == '' and x != environment['screenData']['oldCursor']['x']):
return
2016-08-08 20:59:07 +02:00
else:
# or just arrow arround?
2016-08-28 17:45:16 +02:00
if not(newContent[environment['screenData']['newCursor']['x']].strip() == '' and x != environment['screenData']['newCursor']['x']):
return
2016-08-08 20:59:07 +02:00
2016-08-07 17:00:54 +02:00
if currWord != '':
environment['runtime']['outputManager'].presentText(environment, currWord, interrupt=True)
def setCallback(self, callback):
pass