Skip to content

Commit 35151e3

Browse files
committed
move input method callback since it's broadly applicable
1 parent 1214fc7 commit 35151e3

File tree

4 files changed

+23
-12
lines changed

4 files changed

+23
-12
lines changed

app/src/processing/app/syntax/PdeInputHandler.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
import processing.app.Platform;
3232
import processing.app.Preferences;
33+
import processing.app.ui.Editor;
3334

3435

3536
/**
@@ -39,7 +40,17 @@
3940
*/
4041
public class PdeInputHandler extends DefaultInputHandler {
4142

42-
public PdeInputHandler() {
43+
/**
44+
* Need the Editor object for Input Method changes, plus most subclasses
45+
* will want a local copy anyway. Changed after Processing 3.1.2, need to
46+
* see if this breaks any other Modes before releasing.
47+
*/
48+
protected Editor editor;
49+
50+
51+
public PdeInputHandler(Editor editor) {
52+
this.editor = editor;
53+
4354
// Use option on mac for text edit controls that are ctrl on Windows/Linux.
4455
// (i.e. ctrl-left/right is option-left/right on OS X)
4556
String mod = Platform.isMacOS() ? "A" : "C";
@@ -253,4 +264,9 @@ public boolean handlePressed(KeyEvent event) {
253264
public boolean handleTyped(KeyEvent event) {
254265
return false;
255266
}
267+
268+
269+
public void handleInputMethodCommit() {
270+
editor.getSketch().setModified(true);
271+
}
256272
}

app/src/processing/app/ui/Editor.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ public void removeToolContrib(ToolContribution tc) {
389389

390390
protected JEditTextArea createTextArea() {
391391
return new JEditTextArea(new PdeTextAreaDefaults(mode),
392-
new PdeInputHandler());
392+
new PdeInputHandler(this));
393393
}
394394

395395

@@ -1770,7 +1770,7 @@ public void beginCompoundEdit() {
17701770
startCompoundEdit();
17711771
super.beginCompoundEdit();
17721772
}
1773-
1773+
17741774
@Override
17751775
public void endCompoundEdit() {
17761776
stopCompoundEdit();
@@ -1805,7 +1805,7 @@ public void insertUpdate(DocumentEvent e) {
18051805
if (!isInserting && !textarea.isOverwriteEnabled() && isDirectEdit()) {
18061806
endTextEditHistory();
18071807
}
1808-
1808+
18091809
if (!textarea.isOverwriteEnabled()) {
18101810
isInserting = true;
18111811
}

java/src/processing/mode/java/JavaInputHandler.java

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,14 @@
4040
* continuing to hack this class.
4141
*/
4242
public class JavaInputHandler extends PdeInputHandler {
43-
private Editor editor;
4443

4544
/** ctrl-alt on windows and linux, cmd-alt on mac os x */
4645
static final int CTRL_ALT = ActionEvent.ALT_MASK |
4746
Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
4847

4948

5049
public JavaInputHandler(Editor editor) {
51-
this.editor = editor;
50+
super(editor);
5251
}
5352

5453

@@ -334,12 +333,6 @@ public boolean handleTyped(KeyEvent event) {
334333
}
335334

336335

337-
@Override
338-
public void handleInputMethodCommit() {
339-
editor.getSketch().setModified(true);
340-
}
341-
342-
343336
/**
344337
* Return the index for the first character on this line.
345338
*/

todo.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
0252 (3.1.3?)
2+
X change PdeInputHandler constructor
3+
_ check whether this breaks other Modes before releasing
24
_ modify line number color when no lines extend that far?
35
_ https://github.com/processing/processing/pull/4560
46
_ text gutter doesn't seem to be hidpi

0 commit comments

Comments
 (0)