From dce87a8312f47587e727fd0313c4e7cdf2277911 Mon Sep 17 00:00:00 2001 From: Blake DeMarcy Date: Thu, 13 Apr 2017 08:50:05 -0500 Subject: [PATCH] add keybind to wipe the screen --- clients/urwid/main.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/clients/urwid/main.py b/clients/urwid/main.py index 5fc4072..4868111 100644 --- a/clients/urwid/main.py +++ b/clients/urwid/main.py @@ -1265,21 +1265,30 @@ class OptionsMenu(urwid.LineBox): # try to let the base class handle the key, if not, we'll take over elif not super(OptionsMenu, self).keypress(size, key): return + elif key in ["shift down", "J", "N"]: for x in range(5): self.keypress(size, "down") + elif key in ["shift up", "K", "P"]: for x in range(5): self.keypress(size, "up") + elif key.lower() in ["left", "h", "q"]: app.loop.widget = app.loop.widget[0] + elif key.lower() in ["right", "l"]: return self.keypress(size, "enter") + elif key in ["ctrl n", "j", "n"]: return self.keypress(size, "down") + elif key in ["ctrl p", "k", "p"]: return self.keypress(size, "up") + elif key == "ctrl l": + wipe_screen() + class ActionBox(urwid.ListBox): """ @@ -1333,6 +1342,9 @@ class ActionBox(urwid.ListBox): elif key.lower() == "q": app.back(True) + elif key == "ctrl l": + wipe_screen() + def frilly_exit(): """ @@ -1548,6 +1560,17 @@ def ignore(*_, **__): pass +def wipe_screen(*_): + """ + A crude hack to repaint the whole screen. I didnt immediately + see anything to acheive this in the MainLoop methods so this + will do, I suppose. + """ + app.loop.stop() + run("clear", shell=True) + app.loop.start() + + def main(): global app app = App()