Browse Source

Merge pull request #246 from ceccopierangiolieugenio/245-bracketed-paste-does-not-works-on-the-web-exporter

fix/improved bracketed paste
pull/248/head
Pier CeccoPierangioliEugenio 2 years ago committed by GitHub
parent
commit
003dc05716
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 29
      TermTk/TTkCore/TTkTerm/input_thread.py

29
TermTk/TTkCore/TTkTerm/input_thread.py

@ -111,20 +111,24 @@ class TTkInput:
TTkInput._inputQueue.put(outq)
TTkInput._inputQueue.put(None)
@staticmethod
def _handleBracketedPaste(stdinRead:str):
if stdinRead.endswith("\033[201~"):
TTkInput._pasteBuffer += stdinRead[:-6]
TTkInput._bracketedPaste = False
# due to the CRNL methos (don't ask me why) the terminal
# is substituting all the \n with \r
_paste = TTkInput._pasteBuffer.replace('\r','\n')
TTkInput._pasteBuffer = ""
return None, None, _paste
else:
TTkInput._pasteBuffer += stdinRead
return None, None, None
@staticmethod
def key_process(stdinRead:str) -> None:
if TTkInput._bracketedPaste:
if stdinRead.endswith("\033[201~"):
TTkInput._pasteBuffer += stdinRead[:-6]
TTkInput._bracketedPaste = False
# due to the CRNL methos (don't ask me why) the terminal
# is substituting all the \n with \r
_paste = TTkInput._pasteBuffer.replace('\r','\n')
TTkInput._pasteBuffer = ""
return None, None, _paste
else:
TTkInput._pasteBuffer += stdinRead
return None, None, None
return TTkInput._handleBracketedPaste(stdinRead)
mevt,kevt = None,None
@ -205,9 +209,8 @@ class TTkInput:
return kevt, mevt, None
if stdinRead.startswith("\033[200~"):
TTkInput._pasteBuffer = stdinRead[6:]
TTkInput._bracketedPaste = True
return None, None, None
return TTkInput._handleBracketedPaste(stdinRead[6:])
hex = [f"0x{ord(x):02x}" for x in stdinRead]
TTkLog.error("UNHANDLED: "+stdinRead.replace("\033","<ESC>") + " - "+",".join(hex))

Loading…
Cancel
Save