From 109c5d19efb889df0a4f441a546ef58ccc0ee7df Mon Sep 17 00:00:00 2001 From: chrys Date: Sun, 25 Mar 2018 03:02:18 +0200 Subject: [PATCH] add sticky mode --- src/fenrirscreenreader/core/fenrirManager.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/fenrirscreenreader/core/fenrirManager.py b/src/fenrirscreenreader/core/fenrirManager.py index b7b2586b..ffe58da3 100644 --- a/src/fenrirscreenreader/core/fenrirManager.py +++ b/src/fenrirscreenreader/core/fenrirManager.py @@ -31,6 +31,8 @@ class fenrirManager(): self.modifierInput = False self.singleKeyCommand = False self.command = '' + self.controlMode = True + self.switchCtrlModeOnce = 0 def handleArgs(self): args = None parser = argparse.ArgumentParser(description="Fenrir Help") @@ -84,9 +86,21 @@ class fenrirManager(): self.environment['runtime']['commandManager'].executeDefaultTrigger('onInput') #print('handleInput:',time.time() - startTime) def handleByteInput(self, event): + if not event['Data']: + return if event['Data'] == b'': - return - self.detectByteCommand(event['Data']) + return + self.handleControlMode(event['Data']) + if self.controlMode and not self.switchCtrlModeOnce == 1 or\ + not self.controlMode and self.switchCtrlModeOnce == 1: + self.detectByteCommand(event['Data']) + def handleControlMode(self, escapeSequence): + self.switchCtrlModeOnce -= 1 + if escapeSequence == b'a': + self.controlMode = not self.controlMode + if escapeSequence == b'b': + self.switchCtrlModeOnce = 2 + def handleExecuteCommand(self, event): if event['Data'] == '': return