mirror of
https://github.com/esp8266/Arduino.git
synced 2025-07-30 16:24:09 +03:00
Fix for full-width space bug.
Imported from Processing development r6687 on http://code.google.com/p/processing Close #1
This commit is contained in:
committed by
Shigeru KANEMOTO
parent
541a7b3575
commit
7b8888a93a
@ -54,6 +54,18 @@ public class CompositionTextManager {
|
|||||||
public boolean getIsInputProcess() {
|
public boolean getIsInputProcess() {
|
||||||
return isInputProcess;
|
return isInputProcess;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Insert full width space
|
||||||
|
*/
|
||||||
|
public void insertFullWidthSpace() {
|
||||||
|
initialCaretPosition = textArea.getCaretPosition();
|
||||||
|
int layoutCaretPosition = initialCaretPosition;
|
||||||
|
try {
|
||||||
|
textArea.getDocument().insertString(layoutCaretPosition, "\u3000", null);
|
||||||
|
} catch (BadLocationException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a user begins input from input method.
|
* Called when a user begins input from input method.
|
||||||
@ -115,7 +127,6 @@ public class CompositionTextManager {
|
|||||||
* @param commited_count Numbers of committed characters in text.
|
* @param commited_count Numbers of committed characters in text.
|
||||||
*/
|
*/
|
||||||
public void endCompositionText(AttributedCharacterIterator text, int committed_count) {
|
public void endCompositionText(AttributedCharacterIterator text, int committed_count) {
|
||||||
isInputProcess = false;
|
|
||||||
/*
|
/*
|
||||||
* If there are no committed characters, remove it all from textarea.
|
* If there are no committed characters, remove it all from textarea.
|
||||||
* This case will happen if a user delete all composing characters by backspace or delete key.
|
* This case will happen if a user delete all composing characters by backspace or delete key.
|
||||||
|
@ -73,6 +73,11 @@ public class InputMethodSupport implements InputMethodRequests,
|
|||||||
public void inputMethodTextChanged(InputMethodEvent event) {
|
public void inputMethodTextChanged(InputMethodEvent event) {
|
||||||
AttributedCharacterIterator text = event.getText();
|
AttributedCharacterIterator text = event.getText();
|
||||||
committed_count = event.getCommittedCharacterCount();
|
committed_count = event.getCommittedCharacterCount();
|
||||||
|
if(isFullWidthSpaceInput(text)){
|
||||||
|
textManager.insertFullWidthSpace();
|
||||||
|
caretPositionChanged(event);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if(isBeginInputProcess(text, textManager)){
|
if(isBeginInputProcess(text, textManager)){
|
||||||
textManager.beginCompositionText(text, committed_count);
|
textManager.beginCompositionText(text, committed_count);
|
||||||
caretPositionChanged(event);
|
caretPositionChanged(event);
|
||||||
@ -86,11 +91,21 @@ public class InputMethodSupport implements InputMethodRequests,
|
|||||||
textManager.endCompositionText(text, committed_count);
|
textManager.endCompositionText(text, committed_count);
|
||||||
caretPositionChanged(event);
|
caretPositionChanged(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isFullWidthSpaceInput(AttributedCharacterIterator text){
|
||||||
|
if(text == null)
|
||||||
|
return false;
|
||||||
|
if(textManager.getIsInputProcess())
|
||||||
|
return false;
|
||||||
|
return (String.valueOf(text.first()).equals("\u3000"));
|
||||||
|
}
|
||||||
|
|
||||||
private boolean isBeginInputProcess(AttributedCharacterIterator text, CompositionTextManager textManager){
|
private boolean isBeginInputProcess(AttributedCharacterIterator text, CompositionTextManager textManager){
|
||||||
if(text == null)
|
if(text == null)
|
||||||
return false;
|
return false;
|
||||||
return (isInputProcess(text) && !textManager.getIsInputProcess());
|
if(textManager.getIsInputProcess())
|
||||||
|
return false;
|
||||||
|
return (isInputProcess(text));
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isInputProcess(AttributedCharacterIterator text){
|
private boolean isInputProcess(AttributedCharacterIterator text){
|
||||||
|
Reference in New Issue
Block a user