consume shortcuts, make paste work with pty, fix bug
This commit is contained in:
parent
03397495cf
commit
bb6fc4d3ab
@ -78,7 +78,7 @@ Driver (screen, input):
|
|||||||
[X] make shell command configurable (or detect it)
|
[X] make shell command configurable (or detect it)
|
||||||
[X] stop emulation properly
|
[X] stop emulation properly
|
||||||
[W] attributes
|
[W] attributes
|
||||||
[] make pasteing text work again
|
[X] make pasteing text work again
|
||||||
https://docs.python.org/3.2/library/pty.html
|
https://docs.python.org/3.2/library/pty.html
|
||||||
http://sqizit.bartletts.id.au/2011/02/14/pseudo-terminals-in-python/
|
http://sqizit.bartletts.id.au/2011/02/14/pseudo-terminals-in-python/
|
||||||
https://blog.konpat.me/pythons-pseudo-terminal-pty-examples/
|
https://blog.konpat.me/pythons-pseudo-terminal-pty-examples/
|
||||||
@ -91,7 +91,7 @@ Driver (screen, input):
|
|||||||
[X] controll modes (vim like mode to not collide with application shortcuts)
|
[X] controll modes (vim like mode to not collide with application shortcuts)
|
||||||
[X] create keyboard layout
|
[X] create keyboard layout
|
||||||
[X]set flag that it is used in emulation
|
[X]set flag that it is used in emulation
|
||||||
[] write/ consume them (controll it at all)
|
[X] write/ consume them (controll it at all)
|
||||||
[] ATK input driver (don't grab on graphical interface)
|
[] ATK input driver (don't grab on graphical interface)
|
||||||
https://git.linux-a11y.org/AIT/pyatspi2/src/master/examples/keypress.py
|
https://git.linux-a11y.org/AIT/pyatspi2/src/master/examples/keypress.py
|
||||||
|
|
||||||
|
@ -115,7 +115,7 @@ class commandManager():
|
|||||||
shortcutKeys = []
|
shortcutKeys = []
|
||||||
shortcut = []
|
shortcut = []
|
||||||
for key in keys:
|
for key in keys:
|
||||||
if not self.env['runtime']['settingsManager'].isValidKey(key.upper()):
|
if not self.env['runtime']['inputManager'].isValidKey(key.upper()):
|
||||||
self.env['runtime']['debug'].writeDebugOut("invalid key : "+ key.upper() + ' command:' +commandName ,debug.debugLevel.WARNING)
|
self.env['runtime']['debug'].writeDebugOut("invalid key : "+ key.upper() + ' command:' +commandName ,debug.debugLevel.WARNING)
|
||||||
invalid = True
|
invalid = True
|
||||||
break
|
break
|
||||||
|
@ -90,13 +90,13 @@ class fenrirManager():
|
|||||||
return
|
return
|
||||||
if event['Data'] == b'':
|
if event['Data'] == b'':
|
||||||
return
|
return
|
||||||
|
|
||||||
self.handleControlMode(event['Data'])
|
isCommand = False
|
||||||
|
|
||||||
if self.controlMode and not self.switchCtrlModeOnce == 1 or\
|
if self.controlMode and not self.switchCtrlModeOnce == 1 or\
|
||||||
not self.controlMode and self.switchCtrlModeOnce == 1:
|
not self.controlMode and self.switchCtrlModeOnce == 1:
|
||||||
self.detectByteCommand(event['Data'])
|
isCommand = self.detectByteCommand(event['Data'])
|
||||||
|
if not isCommand:
|
||||||
|
self.environment['runtime']['screenManager'].injectTextToScreen(event['Data'])
|
||||||
def handleControlMode(self, escapeSequence):
|
def handleControlMode(self, escapeSequence):
|
||||||
convertedEscapeSequence = self.environment['runtime']['byteManager'].unifyEscapeSeq(escapeSequence)
|
convertedEscapeSequence = self.environment['runtime']['byteManager'].unifyEscapeSeq(escapeSequence)
|
||||||
if self.switchCtrlModeOnce > 0:
|
if self.switchCtrlModeOnce > 0:
|
||||||
@ -108,10 +108,12 @@ class fenrirManager():
|
|||||||
self.environment['runtime']['outputManager'].presentText(_('Sticky Mode On'), soundIcon='Accept', interrupt=True, flush=True)
|
self.environment['runtime']['outputManager'].presentText(_('Sticky Mode On'), soundIcon='Accept', interrupt=True, flush=True)
|
||||||
else:
|
else:
|
||||||
self.environment['runtime']['outputManager'].presentText(_('Sticky Mode On'), soundIcon='Cancel', interrupt=True, flush=True)
|
self.environment['runtime']['outputManager'].presentText(_('Sticky Mode On'), soundIcon='Cancel', interrupt=True, flush=True)
|
||||||
|
return True
|
||||||
if convertedEscapeSequence == b'^[:':
|
if convertedEscapeSequence == b'^[:':
|
||||||
self.switchCtrlModeOnce = 2
|
self.switchCtrlModeOnce = 2
|
||||||
self.environment['runtime']['outputManager'].presentText(_('bypass'), soundIcon='PTYBypass', interrupt=True, flush=True)
|
self.environment['runtime']['outputManager'].presentText(_('bypass'), soundIcon='PTYBypass', interrupt=True, flush=True)
|
||||||
|
return True
|
||||||
|
return False
|
||||||
def handleExecuteCommand(self, event):
|
def handleExecuteCommand(self, event):
|
||||||
if event['Data'] == '':
|
if event['Data'] == '':
|
||||||
return
|
return
|
||||||
@ -163,10 +165,14 @@ class fenrirManager():
|
|||||||
|
|
||||||
def detectByteCommand(self, escapeSequence):
|
def detectByteCommand(self, escapeSequence):
|
||||||
convertedEscapeSequence = self.environment['runtime']['byteManager'].unifyEscapeSeq(escapeSequence)
|
convertedEscapeSequence = self.environment['runtime']['byteManager'].unifyEscapeSeq(escapeSequence)
|
||||||
command = self.environment['runtime']['inputManager'].getCommandForShortcut(convertedEscapeSequence)
|
if self.handleControlMode(convertedEscapeSequence):
|
||||||
self.environment['runtime']['eventManager'].putToEventQueue(fenrirEventType.ExecuteCommand, command)
|
return True
|
||||||
|
self.command = self.environment['runtime']['inputManager'].getCommandForShortcut(convertedEscapeSequence)
|
||||||
|
self.environment['runtime']['eventManager'].putToEventQueue(fenrirEventType.ExecuteCommand, self.command)
|
||||||
if self.command != '':
|
if self.command != '':
|
||||||
self.command = ''
|
self.command = ''
|
||||||
|
return True
|
||||||
|
return False
|
||||||
def detectShortcutCommand(self):
|
def detectShortcutCommand(self):
|
||||||
if self.environment['input']['keyForeward'] > 0:
|
if self.environment['input']['keyForeward'] > 0:
|
||||||
return
|
return
|
||||||
|
@ -187,6 +187,7 @@ class screenManager():
|
|||||||
try:
|
try:
|
||||||
self.env['runtime']['screenDriver'].injectTextToScreen(text, screen)
|
self.env['runtime']['screenDriver'].injectTextToScreen(text, screen)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
self.env['runtime']['debug'].writeDebugOut('screenManager:injectTextToScreen ' + str(e),debug.debugLevel.ERROR)
|
self.env['runtime']['debug'].writeDebugOut('screenManager:injectTextToScreen ' + str(e),debug.debugLevel.ERROR)
|
||||||
|
|
||||||
def changeBrailleScreen(self):
|
def changeBrailleScreen(self):
|
||||||
|
@ -255,14 +255,19 @@ class settingsManager():
|
|||||||
|
|
||||||
environment['runtime']['memoryManager'] = memoryManager.memoryManager()
|
environment['runtime']['memoryManager'] = memoryManager.memoryManager()
|
||||||
environment['runtime']['memoryManager'].initialize(environment)
|
environment['runtime']['memoryManager'].initialize(environment)
|
||||||
|
|
||||||
environment['runtime']['eventManager'] = eventManager.eventManager()
|
environment['runtime']['eventManager'] = eventManager.eventManager()
|
||||||
environment['runtime']['eventManager'].initialize(environment)
|
environment['runtime']['eventManager'].initialize(environment)
|
||||||
|
|
||||||
environment['runtime']['processManager'] = processManager.processManager()
|
environment['runtime']['processManager'] = processManager.processManager()
|
||||||
environment['runtime']['processManager'].initialize(environment)
|
environment['runtime']['processManager'].initialize(environment)
|
||||||
environment['runtime']['commandManager'] = commandManager.commandManager()
|
|
||||||
environment['runtime']['commandManager'].initialize(environment)
|
|
||||||
environment['runtime']['inputManager'] = inputManager.inputManager()
|
environment['runtime']['inputManager'] = inputManager.inputManager()
|
||||||
environment['runtime']['inputManager'].initialize(environment)
|
environment['runtime']['inputManager'].initialize(environment)
|
||||||
|
|
||||||
|
environment['runtime']['commandManager'] = commandManager.commandManager()
|
||||||
|
environment['runtime']['commandManager'].initialize(environment)
|
||||||
|
|
||||||
environment['runtime']['byteManager'] = byteManager.byteManager()
|
environment['runtime']['byteManager'] = byteManager.byteManager()
|
||||||
environment['runtime']['byteManager'].initialize(environment)
|
environment['runtime']['byteManager'].initialize(environment)
|
||||||
|
|
||||||
|
@ -56,6 +56,7 @@ class driver(screenDriver):
|
|||||||
self.bgColorNames = {0: _('black'), 1: _('blue'), 2: _('green'), 3: _('cyan'), 4: _('red'), 5: _('Magenta'), 6: _('brown/yellow'), 7: _('white')}
|
self.bgColorNames = {0: _('black'), 1: _('blue'), 2: _('green'), 3: _('cyan'), 4: _('red'), 5: _('Magenta'), 6: _('brown/yellow'), 7: _('white')}
|
||||||
self.fgColorNames = {0: _('Black'), 1: _('Blue'), 2: _('Green'), 3: _('Cyan'), 4: _('Red'), 5: _('Magenta'), 6: _('brown/yellow'), 7: _('Light gray'), 8: _('Dark gray'), 9: _('Light blue'), 10: ('Light green'), 11: _('Light cyan'), 12: _('Light red'), 13: _('Light magenta'), 14: _('Light yellow'), 15: _('White')}
|
self.fgColorNames = {0: _('Black'), 1: _('Blue'), 2: _('Green'), 3: _('Cyan'), 4: _('Red'), 5: _('Magenta'), 6: _('brown/yellow'), 7: _('Light gray'), 8: _('Dark gray'), 9: _('Light blue'), 10: ('Light green'), 11: _('Light cyan'), 12: _('Light red'), 13: _('Light magenta'), 14: _('Light yellow'), 15: _('White')}
|
||||||
self.signalPipe = os.pipe()
|
self.signalPipe = os.pipe()
|
||||||
|
self.p_out = None
|
||||||
signal.signal(signal.SIGWINCH, self.handleSigwinch)
|
signal.signal(signal.SIGWINCH, self.handleSigwinch)
|
||||||
def initialize(self, environment):
|
def initialize(self, environment):
|
||||||
self.env = environment
|
self.env = environment
|
||||||
@ -66,8 +67,12 @@ class driver(screenDriver):
|
|||||||
self.env['screen']['newTTY'] = '1'
|
self.env['screen']['newTTY'] = '1'
|
||||||
|
|
||||||
def injectTextToScreen(self, msgBytes, screen = None):
|
def injectTextToScreen(self, msgBytes, screen = None):
|
||||||
#os.write(p_out.fileno(), msgBytes)
|
if not screen:
|
||||||
pass
|
screen = self.p_out.fileno()
|
||||||
|
if isinstance(msgBytes, str):
|
||||||
|
msgBytes = bytes(msgBytes, 'UTF-8')
|
||||||
|
os.write(screen, msgBytes)
|
||||||
|
#print(str(msgBytes))
|
||||||
|
|
||||||
def getSessionInformation(self):
|
def getSessionInformation(self):
|
||||||
self.env['screen']['autoIgnoreScreens'] = []
|
self.env['screen']['autoIgnoreScreens'] = []
|
||||||
@ -113,25 +118,25 @@ class driver(screenDriver):
|
|||||||
lines, columns = self.getTerminalSize(0)
|
lines, columns = self.getTerminalSize(0)
|
||||||
if self.command == '':
|
if self.command == '':
|
||||||
self.command = screen_utils.getShell()
|
self.command = screen_utils.getShell()
|
||||||
terminal, p_pid, p_out = self.openTerminal(columns, lines, self.command)
|
terminal, p_pid, self.p_out = self.openTerminal(columns, lines, self.command)
|
||||||
lines, columns = self.resizeTerminal(p_out)
|
lines, columns = self.resizeTerminal(self.p_out)
|
||||||
terminal.resize(lines, columns)
|
terminal.resize(lines, columns)
|
||||||
while active.value:
|
while active.value:
|
||||||
r, _, _ = select.select([sys.stdin, p_out, self.signalPipe[0]],[],[],1)
|
r, _, _ = select.select([sys.stdin, self.p_out, self.signalPipe[0]],[],[],1)
|
||||||
# none
|
# none
|
||||||
if r == []:
|
if r == []:
|
||||||
continue
|
continue
|
||||||
# signals
|
# signals
|
||||||
if self.signalPipe[0] in r:
|
if self.signalPipe[0] in r:
|
||||||
os.read(self.signalPipe[0], 1)
|
os.read(self.signalPipe[0], 1)
|
||||||
lines, columns = self.resizeTerminal(p_out)
|
lines, columns = self.resizeTerminal(self.p_out)
|
||||||
terminal.resize(lines, columns)
|
terminal.resize(lines, columns)
|
||||||
# output
|
# output
|
||||||
if p_out in r:
|
if self.p_out in r:
|
||||||
if debug:
|
if debug:
|
||||||
print('pre p_out')
|
print('pre p_out')
|
||||||
try:
|
try:
|
||||||
msgBytes = self.readAll(p_out.fileno())
|
msgBytes = self.readAll(self.p_out.fileno())
|
||||||
except (EOFError, OSError):
|
except (EOFError, OSError):
|
||||||
active.value = False
|
active.value = False
|
||||||
break
|
break
|
||||||
@ -158,7 +163,7 @@ class driver(screenDriver):
|
|||||||
except (EOFError, OSError):
|
except (EOFError, OSError):
|
||||||
active.value = False
|
active.value = False
|
||||||
break
|
break
|
||||||
os.write(p_out.fileno(), msgBytes)
|
#self.injectTextToScreen(msgBytes)
|
||||||
if debug:
|
if debug:
|
||||||
print('after stdin')
|
print('after stdin')
|
||||||
except Exception as e: # Process died?
|
except Exception as e: # Process died?
|
||||||
@ -166,7 +171,7 @@ class driver(screenDriver):
|
|||||||
active.value = False
|
active.value = False
|
||||||
finally:
|
finally:
|
||||||
os.kill(p_pid, signal.SIGTERM)
|
os.kill(p_pid, signal.SIGTERM)
|
||||||
p_out.close()
|
self.p_out.close()
|
||||||
termios.tcsetattr(sys.stdin, termios.TCSADRAIN, old_attr)
|
termios.tcsetattr(sys.stdin, termios.TCSADRAIN, old_attr)
|
||||||
eventQueue.put({"Type":fenrirEventType.StopMainLoop,"Data":None})
|
eventQueue.put({"Type":fenrirEventType.StopMainLoop,"Data":None})
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
Loading…
Reference in New Issue
Block a user