From b0bdf08a67d453488792bf023683e9c7fd46c6a8 Mon Sep 17 00:00:00 2001 From: Jay Carlson Date: Tue, 22 Mar 2016 13:28:28 -0400 Subject: [PATCH] Add more of OS X's native Emacs keybindings 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. --- .../app/syntax/SketchTextAreaDefaultInputMap.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/src/processing/app/syntax/SketchTextAreaDefaultInputMap.java b/app/src/processing/app/syntax/SketchTextAreaDefaultInputMap.java index a7f58a9a96c..aff58fb3083 100644 --- a/app/src/processing/app/syntax/SketchTextAreaDefaultInputMap.java +++ b/app/src/processing/app/syntax/SketchTextAreaDefaultInputMap.java @@ -67,8 +67,16 @@ public SketchTextAreaDefaultInputMap() { put(KeyStroke.getKeyStroke(KeyEvent.VK_A, ctrl), DefaultEditorKit.beginLineAction); put(KeyStroke.getKeyStroke(KeyEvent.VK_E, ctrl), DefaultEditorKit.endLineAction); + put(KeyStroke.getKeyStroke(KeyEvent.VK_N, ctrl), DefaultEditorKit.downAction); + put(KeyStroke.getKeyStroke(KeyEvent.VK_P, ctrl), DefaultEditorKit.upAction); + put(KeyStroke.getKeyStroke(KeyEvent.VK_B, ctrl), DefaultEditorKit.backwardAction); + 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); } + // VK_DIVIDE is the keypad; should this be added to VK_SLASH as well? put(KeyStroke.getKeyStroke(KeyEvent.VK_DIVIDE, defaultModifier), RSyntaxTextAreaEditorKit.rstaToggleCommentAction); put(KeyStroke.getKeyStroke(KeyEvent.VK_KP_LEFT, 0), DefaultEditorKit.backwardAction);