Add Ctrl+Backspace and Ctrl+Del keybindings to delete to start and end of current word. This is what most people (or at least I) expect in a normal text widget. For some reason, Alt+Backspace and Alt+D are the current keybindings for this, which I find a bit strange. Anyone know why? I've left those as they are.
Also, on my local branch, I use Ctrl+D to quickly close the window, ala a normal terminal. Not sure how others would feel about this. Currently, Ctrl+D is bound to QtCore.Qt.Key_Delete.
I don't suppose keybindings will be user configurable in the near future, will they?
add Ctrl+Backspace and Ctrl+Del keybindings to delete to start and en…
…d of current word
The bindings we have currently were chosen specifically because they are the standard bash keybindings. Since the Qt console is first and foremost a console widget, we would like to keep those as the defaults.
That said, having user configurable keybindings would be a great enhancement. Unfortunately, I don't think that's likely to be done in the near future. At least, I don't have the spare cycles for it.
You are, of course, welcome to take a stab at this yourself. If you'd like some guidance, just ask. Otherwise, feel free to open a feature request issue, and hopefully it will get picked up eventually.
Hm, I don't exactly have lots of spare time, but I think I could actually see myself getting this done fairly quickly. I'm pretty comfortable with Qt and its keybindings from working on my own code.
I would need some guidance though. I guess this would require giving official names to each action, and some kind of dictionary mapping config key names into proper Qt key names. Maybe someone can propose a couple of keybinding examples, like how to designate in a config file (*.py ?) the key command for delete_previous_word, to establish a convention that I could simply extend to all the existing actions.
It seems to me the right way to do this is to wait for #492 to get merged (almost ready). At that point, the Qt console will have a proper config file support, and it will be much easier to experiment.
This is, for example, the format used by LyX:
\bind "C-e" "line-end"
\bind "C-a" "line-begin"
\bind "C-d" "char-delete-forward"
\bind "C-i" "font-emph"
\bind "C-S-t" "buffer-update pdf2"
which follows how Emacs describes keybindings as well.
I don't think the \bind syntax looks particularly nice, but the key descriptions seem fine, and it's just a matter for us of sorting out how to describe actions.
But it seems to me that this should become a separate issue, since your pull request here can be reviewed/merged on its own merits as an existing improvement. So I suggest we clear this PR as-is, and if you're interested in tackling this one, perhaps open an issue for the design discussion, from which you can then link to a PR once you have code ready.
You're also welcome to ping for more feedback on the -dev list, as always (sometimes people don't respond to open issues right away).
OK, I've opened up issue #502 for configuring qt key bindings.
Since #502 will be far more work than simply adding these few lines that will likely make the console more usable for many folks who don't come from Emacs, I'm in favor of merging this for now, so that the 0.11 experience out of the box is as good as possible. Later we'll work on a more generic framework for this.
That's fine by me.
Thanks, @epatters! I'll then go ahead and merge this one now.
Merged; rebased to avoid a long merge handle for just one commit. Thanks for the code!
Great, thanks for the merge!