1
0
mirror of https://github.com/arduino/Arduino.git synced 2024-12-01 12:24:14 +01:00

Change workaround for ctrl-slash handling in RSyntaxTextArea

Previously, there was a handler on the text area that consumed most
KEY_TYPED events with control pressed. This was added a long time ago to
fix a problem with ctrl-slash doing both the toggle comment action and
inserting a /. Further investigation shows that with RSyntaxTextArea
this problem is still present, but is caused by a weird binding on the
slash key that Arduino is not even using. Removing that binding is a
cleaner workaround for this problem, so this commit switches to that
workaround.

Ideally this would be fixed in RSyntaxTextArea, see
https://github.com/bobbylight/RSyntaxTextArea/issues/157
This commit is contained in:
Matthijs Kooijman 2015-12-11 15:23:04 +01:00
parent f06820713e
commit ac66a9c64a
2 changed files with 9 additions and 8 deletions

View File

@ -22,14 +22,6 @@ public class EditorListener implements KeyListener {
private static final int CTRL_SHIFT = InputEvent.SHIFT_MASK | CTRL;
public void keyTyped(KeyEvent event) {
char c = event.getKeyChar();
if ((event.getModifiers() & KeyEvent.CTRL_MASK) != 0) {
// The char is not control code when CTRL key pressed? It should be a shortcut.
if (!Character.isISOControl(c)) {
event.consume();
}
}
}
@Override

View File

@ -23,6 +23,15 @@ public class SketchTextAreaDefaultInputMap extends RSyntaxTextAreaDefaultInputMa
remove(KeyStroke.getKeyStroke(KeyEvent.VK_K, defaultModifier));
// Remove a troublesome binding for the / key. By default, RSyntaxTextArea
// binds the / KEY_TYPED event to insert a / and optionally complete any XML
// tags. However, since this also triggeres on ctrl-slash, this means that
// in addition to toggling comments on ctrl-slash, it also inserts a slash.
// Since we don't need the XML completion feature anyway, just unbind it
// here. A future version of RSyntaxTextArea might fix this, see
// https://github.com/bobbylight/RSyntaxTextArea/issues/157.
remove(KeyStroke.getKeyStroke('/'));
if (PreferencesData.getBoolean("editor.advanced")) {
put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, alt), RTextAreaEditorKit.rtaLineDownAction);
put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, alt), RTextAreaEditorKit.rtaLineUpAction);