From 3efcc9ec481652b7b91dd648ca55a7618573b752 Mon Sep 17 00:00:00 2001 From: Arturo Vargas Date: Mon, 4 Apr 2016 14:42:40 -0700 Subject: [PATCH 1/2] Change the CTRL+DELETE behavior to restore the next word --- app/src/processing/app/syntax/SketchTextArea.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/src/processing/app/syntax/SketchTextArea.java b/app/src/processing/app/syntax/SketchTextArea.java index ac50a2dc2..ec5734fe7 100644 --- a/app/src/processing/app/syntax/SketchTextArea.java +++ b/app/src/processing/app/syntax/SketchTextArea.java @@ -30,6 +30,8 @@ package processing.app.syntax; +import java.awt.event.KeyEvent; +import javax.swing.KeyStroke; import org.apache.commons.compress.utils.IOUtils; import org.fife.ui.rsyntaxtextarea.*; import org.fife.ui.rsyntaxtextarea.Token; @@ -72,6 +74,7 @@ public class SketchTextArea extends RSyntaxTextArea { public SketchTextArea(PdeKeywords pdeKeywords) throws IOException { this.pdeKeywords = pdeKeywords; installFeatures(); + fixCtrlDeleteBehavior(); } public void setKeywords(PdeKeywords keywords) { @@ -389,4 +392,10 @@ public class SketchTextArea extends RSyntaxTextArea { protected RTextAreaUI createRTextAreaUI() { return new SketchTextAreaUI(this); } + + private void fixCtrlDeleteBehavior() { + KeyStroke keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, + Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()); + getInputMap().put(keyStroke, SketchTextAreaEditorKit.rtaDeleteNextWordAction); + } } From a70bab3ea0a2490fc21f46aa94e5840ec5c581f6 Mon Sep 17 00:00:00 2001 From: Arturo Vargas Date: Wed, 6 Apr 2016 08:25:39 -0700 Subject: [PATCH 2/2] Add suport for OSX (ALT+DELETE) --- app/src/processing/app/syntax/SketchTextArea.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/processing/app/syntax/SketchTextArea.java b/app/src/processing/app/syntax/SketchTextArea.java index ec5734fe7..aace515fb 100644 --- a/app/src/processing/app/syntax/SketchTextArea.java +++ b/app/src/processing/app/syntax/SketchTextArea.java @@ -30,6 +30,7 @@ package processing.app.syntax; +import java.awt.event.InputEvent; import java.awt.event.KeyEvent; import javax.swing.KeyStroke; import org.apache.commons.compress.utils.IOUtils; @@ -58,6 +59,7 @@ import java.net.MalformedURLException; import java.net.URL; import java.util.Map; import java.util.logging.Logger; +import processing.app.helpers.OSUtils; /** * Arduino Sketch code editor based on RSyntaxTextArea (http://fifesoft.com/rsyntaxtextarea) @@ -394,8 +396,8 @@ public class SketchTextArea extends RSyntaxTextArea { } private void fixCtrlDeleteBehavior() { - KeyStroke keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, - Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()); + int modifier = OSUtils.isMacOS()? InputEvent.ALT_MASK : InputEvent.CTRL_MASK; + KeyStroke keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, modifier); getInputMap().put(keyStroke, SketchTextAreaEditorKit.rtaDeleteNextWordAction); } }