pudb icon indicating copy to clipboard operation
pudb copied to clipboard

Enable j/k navigation in the RHS sidebar panels

Open sagittarian opened this issue 8 years ago • 9 comments

I found it very annoying to have to move my hand to the arrow keys to navigate in the sidebar panels. This patch make j/k work for down/up like in the source panel.

sagittarian avatar Aug 23 '16 15:08 sagittarian

Thanks for the patch! I see what you're getting at, but I find the resulting user experience a bit confusing. The cursor keys navigate within and across the RHS panels, but j/k only navigate within the panels. That's a tad weird, and I can see how it would confuse users.

inducer avatar Aug 23 '16 20:08 inducer

I see what you're saying. I reworked it so that j/k in the sidebar area work the same as the up and down arrows.

sagittarian avatar Aug 29 '16 16:08 sagittarian

Crashes:

Traceback (most recent call last):
  File "pudb/__init__.py", line 80, in runscript
    dbg._runscript(mainpyfile)
  File "pudb/debugger.py", line 419, in _runscript
    self.run(statement, globals=globals_, locals=locals_)
  File "/usr/lib/python2.7/bdb.py", line 400, in run
    exec cmd in globals, locals
  File "<string>", line 1, in <module>
  File "debug_me.py", line 1, in <module>
    class MyClass(object):
  File "debug_me.py", line 1, in <module>
    class MyClass(object):
  File "/usr/lib/python2.7/bdb.py", line 49, in trace_dispatch
    return self.dispatch_line(frame)
  File "pudb/debugger.py", line 173, in dispatch_line
    self.user_line(frame)
  File "pudb/debugger.py", line 371, in user_line
    self.interaction(frame)
  File "pudb/debugger.py", line 339, in interaction
    show_exc_dialog=show_exc_dialog)
  File "pudb/debugger.py", line 2092, in call_with_ui
    return f(*args, **kwargs)
  File "pudb/debugger.py", line 2309, in interaction
    self.event_loop()
  File "pudb/debugger.py", line 2275, in event_loop
    toplevel.keypress(self.size, k)
  File "pudb/ui_tools.py", line 96, in keypress
    result = self._w.keypress(size, key)
  File "/home/andreas/pool/local/lib/python2.7/site-packages/urwid/container.py", line 1128, in keypress
    return self.body.keypress( (maxcol, remaining), key )
  File "/home/andreas/pool/local/lib/python2.7/site-packages/urwid/container.py", line 2269, in keypress
    key = w.keypress((mc,) + size[1:], key)
  File "pudb/ui_tools.py", line 96, in keypress
    result = self._w.keypress(size, key)
  File "/home/andreas/pool/local/lib/python2.7/site-packages/urwid/container.py", line 1587, in keypress
    key = self.focus.keypress(tsize, key)
  File "/home/andreas/pool/local/lib/python2.7/site-packages/urwid/container.py", line 1587, in keypress
    key = self.focus.keypress(tsize, key)
  File "pudb/ui_tools.py", line 101, in keypress
    return handler(self, size, key)
  File "pudb/debugger.py", line 720, in rhs_down
    self.rhs_col.keypress(size, "down")
  File "/home/andreas/pool/local/lib/python2.7/site-packages/urwid/container.py", line 1587, in keypress
    key = self.focus.keypress(tsize, key)
  File "/home/andreas/pool/local/lib/python2.7/site-packages/urwid/container.py", line 1587, in keypress
    key = self.focus.keypress(tsize, key)
  File "pudb/ui_tools.py", line 96, in keypress
    result = self._w.keypress(size, key)
  File "/home/andreas/pool/local/lib/python2.7/site-packages/urwid/listbox.py", line 1001, in keypress
    return actual_key(self._keypress_down((maxcol, maxrow)))
  File "/home/andreas/pool/local/lib/python2.7/site-packages/urwid/listbox.py", line 1136, in _keypress_down
    row_offset-rows)
  File "/home/andreas/pool/local/lib/python2.7/site-packages/urwid/listbox.py", line 782, in shift_focus
    raise ListBoxError, "Invalid offset_inset: %r, only %r rows in target!" %(offset_inset, tgt_rows)
ListBoxError: Invalid offset_inset: -1, only 1 rows in target!

To reproduce:

  • ./try-the-debugger.sh
  • Cursor Right
  • j, j

inducer avatar Aug 30 '16 00:08 inducer

Forgot to say: Thank you for your contribution--I like the idea!

inducer avatar Aug 30 '16 00:08 inducer

I actually think the original version was better where it didn't jump between windows with j/k. Any chance we could get that?

brendanator avatar Aug 30 '18 15:08 brendanator

At the very least, this could be configured via a setting option? I have no physical arrow keys on my keyboards (vim binding all the things!), so having the ability to scroll within a sidebar menu with j/k would be awesome.

@inducer: if you're willing to merge this functionality (e.g. enabled with a setting that is disabled by default so as not to confuse users out of the box), I would be willing to adopt this MR and try to implement it.

craftyguy avatar Feb 12 '19 07:02 craftyguy

Sure, I could see merging a competent implementation of the concept, behind a default-off setting.

inducer avatar Feb 12 '19 16:02 inducer

Thanks for offering!

inducer avatar Feb 12 '19 16:02 inducer

@inducer: Here's my first attempt at it: #328

craftyguy avatar Feb 12 '19 19:02 craftyguy