initial say prev,curr,next line

This commit is contained in:
chrys 2016-07-13 21:40:19 +02:00
parent 311e653893
commit 333232d7ce
9 changed files with 38 additions and 22 deletions

File diff suppressed because one or more lines are too long

View File

@ -1,3 +1,8 @@
2-KEY_LEFTCTRL,1-KEY_LEFTSHIFT=curr_line #2-KEY_LEFTCTRL,1-KEY_LEFTSHIFT=curr_line
2-KEY_LEFTCTRL,1-KEY_A=shut_up #2-KEY_LEFTCTRL,1-KEY_S=next_line
#2-KEY_LEFTCTRL,1-KEY_W=prev_line
2-KEY_LEFTCTRL,1-KEY_E=shut_up
1-KEY_KP8=curr_line
1-KEY_KP7=prev_line
1-KEY_KP9=next_line

View File

@ -5,10 +5,15 @@ class command():
pass pass
def run(self, environment): def run(self, environment):
environment['runtime']['speechDriver'].cancel() environment['runtime']['speechDriver'].cancel()
environment['screenData']['oldCursorReview'] = environment['screenData']['newCursorReview']
if environment['screenData']['newCursorReview']['y'] == -1:
environment['screenData']['newCursorReview'] = environment['screenData']['newCursor'].copy()
if environment['screenData']['newContentText'].replace(" ","") == '': if environment['screenData']['newContentText'].replace(" ","") == '':
environment['runtime']['speechDriver'].speak("empty screen") environment['runtime']['speechDriver'].speak("empty line")
else: else:
environment['runtime']['speechDriver'].speak(environment['screenData']['newContentText'].split('\n')[environment['screenData']['newCursor']['y']]) environment['runtime']['speechDriver'].speak(environment['screenData']['newContentText'].split('\n')[environment['screenData']['newCursorReview']['y']])
return environment
def setCallback(self, callback): def setCallback(self, callback):
pass pass
def shutdown(self): def shutdown(self):

View File

@ -29,6 +29,7 @@ class commandManager():
for cmd in sorted(environment['commands'][trigger]): for cmd in sorted(environment['commands'][trigger]):
environment = environment['commands'][trigger][cmd].run(environment) environment = environment['commands'][trigger][cmd].run(environment)
return environment return environment
def executeCommand(self, environment, currCommand, section = 'commands'): def executeCommand(self, environment, currCommand, section = 'commands'):
if self.isCommandDefined(environment): if self.isCommandDefined(environment):
try: try:
@ -38,7 +39,7 @@ class commandManager():
except: except:
pass pass
environment['commandInfo']['currCommand'] = '' environment['commandInfo']['currCommand'] = ''
environment['commandInfo']['lastCommandTime'] = time.time() environment['commandInfo']['lastCommandTime'] = time.time()
return environment return environment
def executeNextCommand(self, environment): def executeNextCommand(self, environment):

View File

@ -11,19 +11,22 @@ class inputManager():
#for dev in self.devices.values(): print(dev) #for dev in self.devices.values(): print(dev)
def getKeyPressed(self, environment): def getKeyPressed(self, environment):
r, w, x = select(self.devices, [], []) try:
currShortcut = environment['input']['currShortcut'] r, w, x = select(self.devices, [], [])
if r != []: currShortcut = environment['input']['currShortcut']
for fd in r: if r != []:
for event in self.devices[fd].read(): for fd in r:
if event.type == evdev.ecodes.EV_KEY: for event in self.devices[fd].read():
if event.value != 0: if event.type == evdev.ecodes.EV_KEY:
currShortcut[str(event.code)] = event.value if event.value != 0:
else: currShortcut[str(event.code)] = event.value
try: else:
del(currShortcut[str(event.code)]) try:
except: del(currShortcut[str(event.code)])
pass except:
pass
except:
pass
environment['input']['currShortcut'] = currShortcut environment['input']['currShortcut'] = currShortcut
environment['input']['currShortcutString'] = self.getShortcutString(environment) environment['input']['currShortcutString'] = self.getShortcutString(environment)
return environment return environment

View File

@ -4,13 +4,13 @@ screenData = {
'columns': 0, 'columns': 0,
'lines': 0, 'lines': 0,
'oldDelta': '', 'oldDelta': '',
'oldCursorReview':{'x':0,'y':0}, 'oldCursorReview':{'x':-1,'y':-1},
'oldCursor':{'x':0,'y':0}, 'oldCursor':{'x':0,'y':0},
'oldContentBytes': b'', 'oldContentBytes': b'',
'oldContentText': '', 'oldContentText': '',
'oldContentAttrib': b'', 'oldContentAttrib': b'',
'newDelta': '', 'newDelta': '',
'newCursorReview':{'x':0,'y':0}, 'newCursorReview':{'x':-1,'y':-1},
'newCursor':{'x':0,'y':0}, 'newCursor':{'x':0,'y':0},
'newContentBytes': b'', 'newContentBytes': b'',
'newContentText': '', 'newContentText': '',

View File

@ -41,6 +41,7 @@ class fenrir():
def proceed(self): def proceed(self):
self.threadHandleInput = Thread(target=self.handleInput, args=()) self.threadHandleInput = Thread(target=self.handleInput, args=())
self.threadHandleInput.start() self.threadHandleInput.start()
self.updateScreen()
while(self.environment['generalInformation']['running']): while(self.environment['generalInformation']['running']):
self.updateScreen() self.updateScreen()
self.shutdown() self.shutdown()

View File

@ -35,7 +35,7 @@ class screen():
return environment return environment
except: except:
return environment return environment
# get metadata like cursor or screensize # get metadata like cursor or screensize
environment['screenData']['lines'] = int( environment['screenData']['newContentBytes'][0]) environment['screenData']['lines'] = int( environment['screenData']['newContentBytes'][0])
environment['screenData']['columns'] = int( environment['screenData']['newContentBytes'][1]) environment['screenData']['columns'] = int( environment['screenData']['newContentBytes'][1])