inducer / pudb

Full-screen console debugger for Python
https://documen.tician.de/pudb/
Other
3k stars 230 forks source link

Could you please add more shortcuts in internal shell such as M-backspace? #386

Closed c02y closed 3 years ago

c02y commented 4 years ago

When I'm using the internal shell to debug such as print value of something, I always miss the shortcuts in my system shell or ipython/bpython such as

  1. C-a/e to beginning/end of the prompt (both are already implemented)
  2. C-d to delete current character
  3. Alt-backspace to delete a word backward
  4. C-u/k to delete to the beginning/end of the prompt(C-u is already implemented)

Could you please add these shortcuts?

asmeurer commented 4 years ago

Yeah, we should implement all the common readline stuff. I wonder if we can somehow just re-use readline directly to get everything for free (although there could be issues like https://github.com/inducer/pudb/pull/350).

chedieck commented 3 years ago

I would also like that very much. M-backspace, C-b, C-f, M-b, M-f and C-k would already be heaven.

inducer commented 3 years ago

Not opposed. PRs welcome.

qhuy4119 commented 3 years ago

I found this python module: urwid_readline. The author creates the class urwid_readline.ReadlineEdit by subclassing urwid.Edit. A quick experiment by replacing self.cmdline_edit = urwid.Edit with self.cmdline_edit = urwi_readline.ReadlineEdit in debugger.py shows that a lot of the shell shortcuts being asked here (C-b, C-f, C-k, for example) work successfully. There may be some conflicts with pudb's current shortcuts and the shell shortcuts with Meta prefix don't seem to work.

The shorcuts implemented by urwid_readline image

Should we use it and fix the conflicts from there, or fix this github issue by implementing the shortcuts ourselves as being done currently?

Edit: Shortcuts with Meta have been working from the start. Turns out on my keyboard Meta is the Alt key, not the "window" key

inducer commented 3 years ago

Either way is fine with me. A particular question that arises is how these Emacs-ish keyboard shortcuts will fit with the (somewhat more vi-ish, maybe?) shortcuts throughout pudb.

asmeurer commented 3 years ago

Some shortcuts like Ctrl-p already conflict and are disabled in the shell. I think it would be useful to use a library like this. Although I wonder if readline support couldn't be added to urwid itself.

qhuy4119 commented 3 years ago

Some shortcuts like Ctrl-p already conflict and are disabled in the shell.

Currently this is not the case. When the focus is in the internal shell, Ctrl-p is cmdline_history_prev. I have to Ctrl-x to unfocus internal shell then Ctrl-p to get to the preferences menu. I don't know if this is intended or not but it's not a problem.

Anyway, I submitted a PR for this issues using the urwid_readline library. Adding readline support to urwid itself isn't worth the effort IMO

chedieck commented 3 years ago

Either way is fine with me. A particular question that arises is how these Emacs-ish keyboard shortcuts will fit with the (somewhat more vi-ish, maybe?) shortcuts throughout pudb.

Either way is fine with me. A particular question that arises is how these Emacs-ish keyboard shortcuts will fit with the (somewhat more vi-ish, maybe?) shortcuts throughout pudb.

For me this design is ideal, though I am quite suspicious to say, since I've been using vim + the emacish shell shortcuts for a while now.