X Tutup
Skip to content

Commit fea594f

Browse files
committed
Make up and down keys change the current line instead of scrolling in urwid.
1 parent a3eaab6 commit fea594f

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

bpython/urwid.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,14 @@ def mouse_event(self, *args):
303303
finally:
304304
self._bpy_may_move_cursor = False
305305

306+
class BPythonListBox(urwid.ListBox):
307+
"""Like `urwid.ListBox`, except that it does not eat up and
308+
down keys.
309+
"""
310+
def keypress(self, size, key):
311+
if key not in ["up", "down"]:
312+
return urwid.ListBox.keypress(self, size, key)
313+
return key
306314

307315
class Tooltip(urwid.BoxWidget):
308316

@@ -402,7 +410,7 @@ class URWIDRepl(repl.Repl):
402410
def __init__(self, event_loop, palette, interpreter, config):
403411
repl.Repl.__init__(self, interpreter, config)
404412

405-
self.listbox = urwid.ListBox(urwid.SimpleListWalker([]))
413+
self.listbox = BPythonListBox(urwid.SimpleListWalker([]))
406414

407415
# String is straight from bpython.cli
408416
self.statusbar = Statusbar(

0 commit comments

Comments
 (0)
X Tutup