diff --git a/app/src/processing/app/syntax/InputHandler.java b/app/src/processing/app/syntax/InputHandler.java index 5009dc407..a695be1a0 100644 --- a/app/src/processing/app/syntax/InputHandler.java +++ b/app/src/processing/app/syntax/InputHandler.java @@ -1177,8 +1177,7 @@ public abstract class InputHandler extends KeyAdapter /** * Called when input method support committed a character. - * @param c The input character */ - public void onCommittedFromInputMethodSupport(char c) { + public void handleInputMethodCommit() { } } diff --git a/app/src/processing/app/syntax/JEditTextArea.java b/app/src/processing/app/syntax/JEditTextArea.java index 94ce33c81..2290a3701 100644 --- a/app/src/processing/app/syntax/JEditTextArea.java +++ b/app/src/processing/app/syntax/JEditTextArea.java @@ -192,13 +192,15 @@ public class JEditTextArea extends JComponent public InputMethodRequests getInputMethodRequests() { if (Preferences.getBoolean("editor.input_method_support")) { if (inputMethodSupport == null) { - inputMethodSupport = new InputMethodSupport(this); + inputMethodSupport = new InputMethodSupport(this, inputHandler); + /* inputMethodSupport.setCallback(new InputMethodSupport.Callback() { @Override public void onCommitted(char c) { - inputHandler.onCommittedFromInputMethodSupport(c); + inputHandler.onInputMethodCommit(c); } }); + */ } return inputMethodSupport; } @@ -1379,14 +1381,14 @@ public class JEditTextArea extends JComponent /** * Replaces the selection with the specified text. * @param selectedText The replacement text for the selection - * @param recordCompoundEdit Whether the replacement should be + * @param recordCompoundEdit Whether the replacement should be * recorded as a compound edit */ public void setSelectedText(String selectedText, boolean recordCompoundEdit) { if (!editable) { throw new InternalError("Text component read only"); } - + if (recordCompoundEdit) { document.beginCompoundEdit(); } @@ -1477,7 +1479,7 @@ public class JEditTextArea extends JComponent // Don't overstrike if there is a selection if(!overwrite || selectionStart != selectionEnd) { - // record the whole operation as a compound edit if + // record the whole operation as a compound edit if // selected text is being replaced boolean isSelectAndReplaceOp = (selectionStart != selectionEnd); setSelectedText(str, isSelectAndReplaceOp); diff --git a/app/src/processing/app/syntax/im/InputMethodSupport.java b/app/src/processing/app/syntax/im/InputMethodSupport.java index 2755576ba..e148e5d73 100644 --- a/app/src/processing/app/syntax/im/InputMethodSupport.java +++ b/app/src/processing/app/syntax/im/InputMethodSupport.java @@ -21,6 +21,7 @@ import java.text.AttributedString; import processing.app.Base; import processing.app.Messages; import processing.app.Preferences; +import processing.app.syntax.InputHandler; import processing.app.syntax.JEditTextArea; import processing.app.syntax.TextAreaPainter; @@ -38,29 +39,38 @@ import processing.app.syntax.TextAreaPainter; */ public class InputMethodSupport implements InputMethodRequests, InputMethodListener { + /* public interface Callback { public void onCommitted(char c); } + private Callback callback; + */ + static private final Attribute[] CUSTOM_IM_ATTRIBUTES = { TextAttribute.INPUT_METHOD_HIGHLIGHT, }; - private int committedCount = 0; private JEditTextArea textArea; - private AttributedString composedTextString; - private Callback callback; + private InputHandler inputHandler; - public InputMethodSupport(JEditTextArea textArea) { + private int committedCount = 0; + private AttributedString composedTextString; + + public InputMethodSupport(JEditTextArea textArea, InputHandler inputHandler) { this.textArea = textArea; - this.textArea.enableInputMethods(true); - this.textArea.addInputMethodListener(this); + this.inputHandler = inputHandler; + + textArea.enableInputMethods(true); + textArea.addInputMethodListener(this); } + /* public void setCallback(Callback callback) { this.callback = callback; } + */ ///////////////////////////////////////////////////////////////////////////// @@ -182,9 +192,7 @@ public class InputMethodSupport implements InputMethodRequests, InputMethodListe } // Insert this as a compound edit textArea.setSelectedText(new String(insertion), true); - if (callback != null) { - callback.onCommitted(c); - } + inputHandler.handleInputMethodCommit(); CompositionTextPainter compositionPainter = textArea.getPainter().getCompositionTextpainter(); if (Base.DEBUG) { diff --git a/java/src/processing/mode/java/JavaInputHandler.java b/java/src/processing/mode/java/JavaInputHandler.java index b675c063a..596f35063 100644 --- a/java/src/processing/mode/java/JavaInputHandler.java +++ b/java/src/processing/mode/java/JavaInputHandler.java @@ -335,9 +335,8 @@ public class JavaInputHandler extends PdeInputHandler { @Override - public void onCommittedFromInputMethodSupport(char c) { - Sketch sketch = editor.getSketch(); - sketch.setModified(true); + public void handleInputMethodCommit() { + editor.getSketch().setModified(true); }