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] stop emulation properly
|
||||
[W] attributes
|
||||
[] make pasteing text work again
|
||||
[X] make pasteing text work again
|
||||
https://docs.python.org/3.2/library/pty.html
|
||||
http://sqizit.bartletts.id.au/2011/02/14/pseudo-terminals-in-python/
|
||||
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] create keyboard layout
|
||||
[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)
|
||||
https://git.linux-a11y.org/AIT/pyatspi2/src/master/examples/keypress.py
|
||||
|
||||
|
@ -115,7 +115,7 @@ class commandManager():
|
||||
shortcutKeys = []
|
||||
shortcut = []
|
||||
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)
|
||||
invalid = True
|
||||
break
|
||||
|
@ -90,13 +90,13 @@ class fenrirManager():
|
||||
return
|
||||
if event['Data'] == b'':
|
||||
return
|
||||
|
||||
self.handleControlMode(event['Data'])
|
||||
|
||||
|
||||
isCommand = False
|
||||
if self.controlMode and not self.switchCtrlModeOnce == 1 or\
|
||||
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):
|
||||
convertedEscapeSequence = self.environment['runtime']['byteManager'].unifyEscapeSeq(escapeSequence)
|
||||
if self.switchCtrlModeOnce > 0:
|
||||
@ -108,10 +108,12 @@ class fenrirManager():
|
||||
self.environment['runtime']['outputManager'].presentText(_('Sticky Mode On'), soundIcon='Accept', interrupt=True, flush=True)
|
||||
else:
|
||||
self.environment['runtime']['outputManager'].presentText(_('Sticky Mode On'), soundIcon='Cancel', interrupt=True, flush=True)
|
||||
return True
|
||||
if convertedEscapeSequence == b'^[:':
|
||||
self.switchCtrlModeOnce = 2
|
||||
self.environment['runtime']['outputManager'].presentText(_('bypass'), soundIcon='PTYBypass', interrupt=True, flush=True)
|
||||
|
||||
return True
|
||||
return False
|
||||
def handleExecuteCommand(self, event):
|
||||
if event['Data'] == '':
|
||||
return
|
||||
@ -163,10 +165,14 @@ class fenrirManager():
|
||||
|
||||
def detectByteCommand(self, escapeSequence):
|
||||
convertedEscapeSequence = self.environment['runtime']['byteManager'].unifyEscapeSeq(escapeSequence)
|
||||
command = self.environment['runtime']['inputManager'].getCommandForShortcut(convertedEscapeSequence)
|
||||
self.environment['runtime']['eventManager'].putToEventQueue(fenrirEventType.ExecuteCommand, command)
|
||||
if self.handleControlMode(convertedEscapeSequence):
|
||||
return True
|
||||
self.command = self.environment['runtime']['inputManager'].getCommandForShortcut(convertedEscapeSequence)
|
||||
self.environment['runtime']['eventManager'].putToEventQueue(fenrirEventType.ExecuteCommand, self.command)
|
||||
if self.command != '':
|
||||
self.command = ''
|
||||
return True
|
||||
return False
|
||||
def detectShortcutCommand(self):
|
||||
if self.environment['input']['keyForeward'] > 0:
|
||||
return
|
||||
|
@ -187,6 +187,7 @@ class screenManager():
|
||||
try:
|
||||
self.env['runtime']['screenDriver'].injectTextToScreen(text, screen)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
self.env['runtime']['debug'].writeDebugOut('screenManager:injectTextToScreen ' + str(e),debug.debugLevel.ERROR)
|
||||
|
||||
def changeBrailleScreen(self):
|
||||
|
@ -255,14 +255,19 @@ class settingsManager():
|
||||
|
||||
environment['runtime']['memoryManager'] = memoryManager.memoryManager()
|
||||
environment['runtime']['memoryManager'].initialize(environment)
|
||||
|
||||
environment['runtime']['eventManager'] = eventManager.eventManager()
|
||||
environment['runtime']['eventManager'].initialize(environment)
|
||||
|
||||
environment['runtime']['processManager'] = processManager.processManager()
|
||||
environment['runtime']['processManager'].initialize(environment)
|
||||
environment['runtime']['commandManager'] = commandManager.commandManager()
|
||||
environment['runtime']['commandManager'].initialize(environment)
|
||||
environment['runtime']['processManager'].initialize(environment)
|
||||
|
||||
environment['runtime']['inputManager'] = inputManager.inputManager()
|
||||
environment['runtime']['inputManager'].initialize(environment)
|
||||
|
||||
environment['runtime']['commandManager'] = commandManager.commandManager()
|
||||
environment['runtime']['commandManager'].initialize(environment)
|
||||
|
||||
environment['runtime']['byteManager'] = byteManager.byteManager()
|
||||
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.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.p_out = None
|
||||
signal.signal(signal.SIGWINCH, self.handleSigwinch)
|
||||
def initialize(self, environment):
|
||||
self.env = environment
|
||||
@ -66,8 +67,12 @@ class driver(screenDriver):
|
||||
self.env['screen']['newTTY'] = '1'
|
||||
|
||||
def injectTextToScreen(self, msgBytes, screen = None):
|
||||
#os.write(p_out.fileno(), msgBytes)
|
||||
pass
|
||||
if not screen:
|
||||
screen = self.p_out.fileno()
|
||||
if isinstance(msgBytes, str):
|
||||
msgBytes = bytes(msgBytes, 'UTF-8')
|
||||
os.write(screen, msgBytes)
|
||||
#print(str(msgBytes))
|
||||
|
||||
def getSessionInformation(self):
|
||||
self.env['screen']['autoIgnoreScreens'] = []
|
||||
@ -113,25 +118,25 @@ class driver(screenDriver):
|
||||
lines, columns = self.getTerminalSize(0)
|
||||
if self.command == '':
|
||||
self.command = screen_utils.getShell()
|
||||
terminal, p_pid, p_out = self.openTerminal(columns, lines, self.command)
|
||||
lines, columns = self.resizeTerminal(p_out)
|
||||
terminal, p_pid, self.p_out = self.openTerminal(columns, lines, self.command)
|
||||
lines, columns = self.resizeTerminal(self.p_out)
|
||||
terminal.resize(lines, columns)
|
||||
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
|
||||
if r == []:
|
||||
continue
|
||||
# signals
|
||||
if self.signalPipe[0] in r:
|
||||
os.read(self.signalPipe[0], 1)
|
||||
lines, columns = self.resizeTerminal(p_out)
|
||||
lines, columns = self.resizeTerminal(self.p_out)
|
||||
terminal.resize(lines, columns)
|
||||
# output
|
||||
if p_out in r:
|
||||
if self.p_out in r:
|
||||
if debug:
|
||||
print('pre p_out')
|
||||
try:
|
||||
msgBytes = self.readAll(p_out.fileno())
|
||||
msgBytes = self.readAll(self.p_out.fileno())
|
||||
except (EOFError, OSError):
|
||||
active.value = False
|
||||
break
|
||||
@ -158,7 +163,7 @@ class driver(screenDriver):
|
||||
except (EOFError, OSError):
|
||||
active.value = False
|
||||
break
|
||||
os.write(p_out.fileno(), msgBytes)
|
||||
#self.injectTextToScreen(msgBytes)
|
||||
if debug:
|
||||
print('after stdin')
|
||||
except Exception as e: # Process died?
|
||||
@ -166,7 +171,7 @@ class driver(screenDriver):
|
||||
active.value = False
|
||||
finally:
|
||||
os.kill(p_pid, signal.SIGTERM)
|
||||
p_out.close()
|
||||
self.p_out.close()
|
||||
termios.tcsetattr(sys.stdin, termios.TCSADRAIN, old_attr)
|
||||
eventQueue.put({"Type":fenrirEventType.StopMainLoop,"Data":None})
|
||||
sys.exit(0)
|
||||
|
Loading…
Reference in New Issue
Block a user