add input unicode support: urwid py3 still crashes on output...
parent
6e959a510e
commit
a2fae6ba8b
|
@ -1524,40 +1524,52 @@ class ExternalEditor(urwid.Terminal):
|
||||||
|
|
||||||
|
|
||||||
def keypress(self, size, key):
|
def keypress(self, size, key):
|
||||||
if key in ["down", "up", "left", "right"]:
|
"""
|
||||||
# HACK: something somewhere is capturing some keys within
|
The majority of the things the parent keypress method will do is
|
||||||
# the parent keypress method until some other keys are pressed. So when
|
either erroneous or disruptive to my own usage. I've plucked out
|
||||||
# this widget was spawned, it would ignore arrow keys, C-n/C-p, pager keys,
|
the necessary bits and, most importantly, have changed from
|
||||||
# but when some _OTHER_ keys were pressed, this lock was released. Weird shit.
|
ASCII encoding to utf8 when writing to the child process.
|
||||||
# instead of figuring out why lets just //TAKE_THE_REIGNS// #YOLO
|
"""
|
||||||
if self.term_modes.keys_decckm and key in urwid.vterm.KEY_TRANSLATIONS_DECCKM:
|
if self.terminated:
|
||||||
key = urwid.vterm.KEY_TRANSLATIONS_DECCKM.get(key)
|
return
|
||||||
else:
|
|
||||||
key = urwid.vterm.KEY_TRANSLATIONS.get(key, key)
|
|
||||||
key = key.encode('ascii')
|
|
||||||
return os.write(self.master, key)
|
|
||||||
|
|
||||||
elif key.lower() == "ctrl l":
|
|
||||||
wipe_screen()
|
|
||||||
# always do this, and also pass it to the terminal
|
|
||||||
|
|
||||||
|
self.term.scroll_buffer(reset=True)
|
||||||
keyl = key.lower()
|
keyl = key.lower()
|
||||||
if keyl not in ["f1", "f2", "f3", "ctrl z"]:
|
|
||||||
return super(ExternalEditor, self).keypress(size, key)
|
if keyl == "ctrl l":
|
||||||
|
# always do this, and also pass it to the terminal
|
||||||
|
wipe_screen()
|
||||||
|
|
||||||
elif key == "f1":
|
elif key == "f1":
|
||||||
self.terminate()
|
self.terminate()
|
||||||
app.close_editor()
|
app.close_editor()
|
||||||
app.refresh()
|
return app.refresh()
|
||||||
|
|
||||||
elif key == "f2":
|
elif key == "f2":
|
||||||
app.switch_editor()
|
return app.switch_editor()
|
||||||
|
|
||||||
elif key == "f3":
|
elif key == "f3":
|
||||||
app.formatting_help()
|
return app.formatting_help()
|
||||||
|
|
||||||
elif keyl == "ctrl z":
|
elif keyl == "ctrl z":
|
||||||
os.killpg(os.getpgid(os.getpid()), 19)
|
return os.killpg(os.getpgid(os.getpid()), 19)
|
||||||
|
|
||||||
|
if key.startswith("ctrl "):
|
||||||
|
if key[-1].islower():
|
||||||
|
key = chr(ord(key[-1]) - ord('a') + 1)
|
||||||
|
else:
|
||||||
|
key = chr(ord(key[-1]) - ord('A') + 1)
|
||||||
|
else:
|
||||||
|
if self.term_modes.keys_decckm and key in urwid.vterm.KEY_TRANSLATIONS_DECCKM:
|
||||||
|
key = urwid.vterm.KEY_TRANSLATIONS_DECCKM.get(key)
|
||||||
|
else:
|
||||||
|
key = urwid.vterm.KEY_TRANSLATIONS.get(key, key)
|
||||||
|
|
||||||
|
# ENTER transmits both a carriage return and linefeed in LF/NL mode.
|
||||||
|
if self.term_modes.lfnl and key == "\x0d":
|
||||||
|
key += "\x0a"
|
||||||
|
|
||||||
|
os.write(self.master, key.encode('utf8'))
|
||||||
|
|
||||||
|
|
||||||
def __del__(self):
|
def __del__(self):
|
||||||
|
|
Loading…
Reference in New Issue