diff options
author | Blake DeMarcy <ofunknowndescent@gmail.com> | 2017-09-10 13:18:26 -0500 |
---|---|---|
committer | Blake DeMarcy <ofunknowndescent@gmail.com> | 2017-09-10 13:18:26 -0500 |
commit | 41b7311d702c36d0f46ee55c17699e821cb0f23f (patch) | |
tree | 5a235c1b530aae4d651a10e564d0f13e35a6a976 | |
parent | 1ab36bd984ce32dd12762a9b9565fe8175859e61 (diff) | |
download | bbj-41b7311d702c36d0f46ee55c17699e821cb0f23f.tar.gz |
preliminary custom escape key handling in the composer
-rw-r--r-- | clients/urwid/main.py | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/clients/urwid/main.py b/clients/urwid/main.py index a80bcb2..dab2915 100644 --- a/clients/urwid/main.py +++ b/clients/urwid/main.py @@ -194,7 +194,12 @@ default_prefs = { "date": "%Y/%m/%d", "time": "%H:%M", "frame_title": "> > T I L D E T O W N < <", - "max_text_width": 80 + "max_text_width": 80, + "edit_escapes": { + "abort": "f1", + "focus": "f2", + "fhelp": "f3" + } } bars = { @@ -379,7 +384,12 @@ class App(object): attr.reverse() self.loop.widget.footer[0].set_text( - "[F1]Abort [F2]Swap [F3]Formatting Help [save/quit to send] " + focus) + "[{}]Abort [{}]Swap [{}]Formatting Help [save/quit to send] {}".format( + app.prefs["edit_escapes"]["abort"].upper(), + app.prefs["edit_escapes"]["focus"].upper(), + app.prefs["edit_escapes"]["fhelp"].upper(), + focus) + ) # HACK WHY WHY WHY WHYW HWY # this sets the focus color for the editor frame @@ -1369,7 +1379,9 @@ class App(object): if self.mode == "index": self.set_header('Composing "{}"', title) - self.set_footer("[F1]Abort [F3]Formatting Help [Save and quit to submit your thread]") + self.set_footer("[{}]Abort [{}]Formatting Help [Save and quit to submit your thread]".format( + app.prefs["edit_escapes"]["abort"].upper(), app.prefs["edit_escapes"]["fhelp"].upper() + )) self.loop.widget = urwid.Overlay( urwid.LineBox( ExternalEditor("thread_create", title=title), @@ -1650,7 +1662,7 @@ class ExternalEditor(urwid.Terminal): env.update({"LANG": "POSIX"}) command = ["bash", "-c", "{} {}; echo Press any key to kill this window...".format( app.prefs["editor"], self.path)] - super(ExternalEditor, self).__init__(command, env, app.loop, "f1") + super(ExternalEditor, self).__init__(command, env, app.loop, app.prefs["edit_escapes"]["abort"]) urwid.connect_signal(self, "closed", self.exterminate) @@ -1693,15 +1705,15 @@ class ExternalEditor(urwid.Terminal): # always do this, and also pass it to the terminal wipe_screen() - elif key == "f1": + elif key == app.prefs["edit_escapes"]["abort"]: self.terminate() app.close_editor() return app.refresh() - elif key == "f2": + elif key == app.prefs["edit_escapes"]["focus"]: return app.switch_editor() - elif key == "f3": + elif key == app.prefs["edit_escapes"]["fhelp"]: return app.formatting_help() elif keyl == "ctrl z": |