add incrementer to thread jumper

pull/4/head
Blake DeMarcy 2017-04-22 18:13:14 -05:00
parent 095bbcfe76
commit b11861b791
1 changed files with 25 additions and 1 deletions

View File

@ -1484,14 +1484,38 @@ class JumpPrompt(Prompt, urwid.IntEdit):
return False 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): def keypress(self, size, key):
keyl = key.lower()
if key == "enter": if key == "enter":
app.remove_overlays() app.remove_overlays()
self.callback(self.value(), *self.args) 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() 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 else: # dont use super because we want to allow zeros in this box
urwid.Edit.keypress(self, (size[0],), key) urwid.Edit.keypress(self, (size[0],), key)