diff options
author | Blake DeMarcy <ofunknowndescent@gmail.com> | 2017-04-22 18:13:14 -0500 |
---|---|---|
committer | Blake DeMarcy <ofunknowndescent@gmail.com> | 2017-04-22 18:13:14 -0500 |
commit | b11861b79124abbf4ae0d4fa84b01cac30e23120 (patch) | |
tree | b3fbd248d9f11c56fd7a7c102643f9149ed32c75 | |
parent | 095bbcfe76ef13ee09d76b47190f865fa6604498 (diff) | |
download | bbj-b11861b79124abbf4ae0d4fa84b01cac30e23120.tar.gz |
add incrementer to thread jumper
-rw-r--r-- | clients/urwid/main.py | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/clients/urwid/main.py b/clients/urwid/main.py index b26235f..b5202a9 100644 --- a/clients/urwid/main.py +++ b/clients/urwid/main.py @@ -1484,14 +1484,38 @@ class JumpPrompt(Prompt, urwid.IntEdit): return False + def incr(self, direction): + value = self.value() + if direction == "down" and value > 0: + value = str(value - 1) + self.set_edit_text(value) + + elif direction == "up" and value < self.max_length: + value = str(value + 1) + self.set_edit_text(value) + + else: + return + + self.set_edit_pos(len(value)) + + + def keypress(self, size, key): + keyl = key.lower() if key == "enter": app.remove_overlays() self.callback(self.value(), *self.args) - elif key.lower() in ["q", "esc", "ctrl g", "ctrl c"]: + elif keyl in ("q", "esc", "ctrl g", "ctrl c"): app.remove_overlays() + elif keyl in ("down", "ctrl n", "n", "j"): + self.incr("down") + + elif keyl in ("up", "ctrl p", "p", "k"): + self.incr("up") + else: # dont use super because we want to allow zeros in this box urwid.Edit.keypress(self, (size[0],), key) |