File tree 2 files changed +29
-3
lines changed
app/src/processing/app/syntax/im
2 files changed +29
-3
lines changed Original file line number Diff line number Diff line change @@ -54,6 +54,18 @@ public CompositionTextManager(JEditTextArea textArea) {
54
54
public boolean getIsInputProcess () {
55
55
return isInputProcess ;
56
56
}
57
+ /**
58
+ * Insert full width space
59
+ */
60
+ public void insertFullWidthSpace () {
61
+ initialCaretPosition = textArea .getCaretPosition ();
62
+ int layoutCaretPosition = initialCaretPosition ;
63
+ try {
64
+ textArea .getDocument ().insertString (layoutCaretPosition , "\u3000 " , null );
65
+ } catch (BadLocationException e ) {
66
+ e .printStackTrace ();
67
+ }
68
+ }
57
69
58
70
/**
59
71
* Called when a user begins input from input method.
@@ -115,7 +127,6 @@ private boolean canRemovePreviousInput(int committed_count){
115
127
* @param commited_count Numbers of committed characters in text.
116
128
*/
117
129
public void endCompositionText (AttributedCharacterIterator text , int committed_count ) {
118
- isInputProcess = false ;
119
130
/*
120
131
* If there are no committed characters, remove it all from textarea.
121
132
* This case will happen if a user delete all composing characters by backspace or delete key.
Original file line number Diff line number Diff line change @@ -73,6 +73,11 @@ public AttributedCharacterIterator getSelectedText(
73
73
public void inputMethodTextChanged (InputMethodEvent event ) {
74
74
AttributedCharacterIterator text = event .getText ();
75
75
committed_count = event .getCommittedCharacterCount ();
76
+ if (isFullWidthSpaceInput (text )){
77
+ textManager .insertFullWidthSpace ();
78
+ caretPositionChanged (event );
79
+ return ;
80
+ }
76
81
if (isBeginInputProcess (text , textManager )){
77
82
textManager .beginCompositionText (text , committed_count );
78
83
caretPositionChanged (event );
@@ -86,11 +91,21 @@ public void inputMethodTextChanged(InputMethodEvent event) {
86
91
textManager .endCompositionText (text , committed_count );
87
92
caretPositionChanged (event );
88
93
}
89
-
94
+
95
+ private boolean isFullWidthSpaceInput (AttributedCharacterIterator text ){
96
+ if (text == null )
97
+ return false ;
98
+ if (textManager .getIsInputProcess ())
99
+ return false ;
100
+ return (String .valueOf (text .first ()).equals ("\u3000 " ));
101
+ }
102
+
90
103
private boolean isBeginInputProcess (AttributedCharacterIterator text , CompositionTextManager textManager ){
91
104
if (text == null )
92
105
return false ;
93
- return (isInputProcess (text ) && !textManager .getIsInputProcess ());
106
+ if (textManager .getIsInputProcess ())
107
+ return false ;
108
+ return (isInputProcess (text ));
94
109
}
95
110
96
111
private boolean isInputProcess (AttributedCharacterIterator text ){
You can’t perform that action at this time.
0 commit comments