-
-
Notifications
You must be signed in to change notification settings - Fork 7k
Add more of OS X's native Emacs keybindings #4743
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
OS X supports many simple Emacs keybindings in native text fields. (It can do this because the system UI uses Cmd instead of Ctrl as its main modifier key.) Add bindings to functions which already exist in DefaultEditorKit. I have a Ctrl-k (cut to end of line) implementation, but it is an additional static RecordableTextAction class. I have not included it.
Interesting, never know that, are those key-bindings standard in OSX? |
@ArduinoBot build this please |
put(KeyStroke.getKeyStroke(KeyEvent.VK_F, ctrl), DefaultEditorKit.forwardAction); | ||
put(KeyStroke.getKeyStroke(KeyEvent.VK_D, ctrl), DefaultEditorKit.deleteNextCharAction); | ||
put(KeyStroke.getKeyStroke(KeyEvent.VK_Y, ctrl), DefaultEditorKit.pasteAction); | ||
put(KeyStroke.getKeyStroke(KeyEvent.VK_W, ctrl), DefaultEditorKit.cutAction); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The 'cut' actions that here is set as Ctrl-W seems to be Ctrl-K instead.
From various sources I see that the mnemonics are:
Ctrl-K -> Kill (cut)
Ctrl-Y -> Yank (paste)
is that right?
All the other shortcuts works as expected.
ok after commenting here https://github.com/arduino/Arduino/pull/4743/files#r57473913 I re-read the OP comment:
and now I've all the pieces together: it seems that Ctrl-K works as "cut to the end of the line" if no text is selected, otherwise it works as a normal "cut". @nopdotcom do you agree? |
tl;dr; Your described behavior is a good improvement; for example, Ctrl-K then Ctrl-Y should put the line back the way it was. The real Ctrl-K is complicated, Long version: I hadn’t realized how complicated it actually is. The native OS X behavior for Ctrl-K mimics Emacs very well, but it is confusing. There is a separate cut buffer used by OS X Ctrl-K and Ctrl-Y, unrelated to the clipboard. Every action taken with Ctrl-K appends to the special buffer:
Ctrl-Y pastes the special buffer. The end effect of this is that:
These are wired into my fingers. But I would find it acceptable for Ctrl-A Ctrl-K Ctrl-Y RETURN C-y to duplicate the current line. Which would work with the mapping you described. |
Would you like me to clean up my Ctrl-K code and add it to this branch? |
@nopdotcom |
for a better explanation see @nopdotcom comment here: #4743 (comment)
@nopdotcom I've merged your commit without the Ctrl+W and Ctrl+Y part, so we can move forward and close this PR. Feel free to open another PR when you have a correct implementation of the Kill/Yank feature! Thank you! |
OS X supports many simple Emacs keybindings in native text fields. (It can do this because the system UI uses
Cmd
instead ofCtrl
as its main modifier key.) Add bindings to functions which already exist inDefaultEditorKit
.I have a
Ctrl-k
(cut to end of line) implementation, but it is an additional staticRecordableTextAction
class. I have not included it.