Supporting readline bindings in edit mode
Hi,
Interesting project! :)
It would be nice if readline bindings such as Ctrl-H (backspace), Ctrl-W (delete word), Ctrl-U (kill line), Ctrl-B and Ctrl-F (cursor movement) were supported when editing entries. Ideally the best would be to use readline proper (to have all bindings, including the ones from ~/.inputrc). I'm not sure if that's possible, but if it's not it would be nice to reimplement at least the most common ones.
Thanks!
Note that the actions and bindings you've mentioned can be added to the existing relatively easy. Feel free to give it a try yourself :)
If I were to overhaul the item editing code and use a separate library the library should provide:
- Word-wrapping
- Work with wide-char languages (e.g. Japanese)
- Integrate with ncursesw in some reasonable manner
I don't know what API libreadline exposes, so maybe it fits, maybe it doesn't. The second point from the above list would be most important though.
@a3nm 'Ctrl-H' should work in snb. If it doesn't please tell what your terminal emulator is and what's the $TERM variable set to.
I also skimmed some readline docs and I wonder what 'the most common' bindings would be. I might add the Ctrl-B and Ctrl-F, as cursor movement code is already there.
On Thu, Dec 18, 2014 at 05:44:41AM -0800, Piotr Staszewski wrote:
@a3nm 'Ctrl-H' should work in snb. If it doesn't please tell what your terminal emulator is and what's the
$TERMvariable set to.
It doesn't work for me with the latest revision. I'm using urxvt and my $TERM is "rxvt-unicode".
I also skimmed some readline docs and I wonder what 'the most common' bindings would be. I might add the Ctrl-B and Ctrl-F, as cursor movement code is already there.
The ones I use most commonly use are the ones I mentioned in the previous post, also maybe Alt-B and Alt-F (backward and forward for a word). This is only personal preference though.
It looks like integrating readline to a curses program is non-trivial... :/ but there has to be a better way than having to reimplement all bindings yourself... I hope. :/
Antoine Amarilli
Ctrl-H, Ctrl-B and Ctrl-F should work now in edit mode.
If they don't that's probably due to the terminal emulator and $TERM combination, and the fact that using raw bytes for checking the key might not be the best idea...
On Thu, Dec 18, 2014 at 07:23:50AM -0800, Piotr Staszewski wrote:
Ctrl-H, Ctrl-B and Ctrl-F should work now in edit mode.
If they don't that's probably due to the terminal emulator and
$TERMcombination, and the fact that using raw bytes for checking the key might not be the best idea...
Yes, I confirm it works, now. Cool! :)
Antoine Amarilli