Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java7
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextRenderer.java51
2 files changed, 38 insertions, 20 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java
index 14691f1c3c..5620b4999e 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java
@@ -4966,17 +4966,18 @@ void handleCompositionChanged(Event event) {
compositionStart = caretOffset;
compositionLength = 0;
}
+ int oldLength = compositionLength;
+ compositionLength = 0;
renderer.imeRanges = null;
renderer.imeStyles = null;
if (length == event.count) {
- content.replaceTextRange(compositionStart, compositionLength, "");
+ content.replaceTextRange(compositionStart, oldLength, "");
caretOffset = compositionStart;
compositionStart = -1;
- compositionLength = 0;
caretWidth = 0;
caretDirection = SWT.NULL;
} else {
- content.replaceTextRange(compositionStart, compositionLength, text);
+ content.replaceTextRange(compositionStart, oldLength, text);
compositionLength = length;
caretOffset = compositionStart + event.index;
int lineIndex = getCaretLine();
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextRenderer.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextRenderer.java
index ef9f041f4c..778ef79c47 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextRenderer.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextRenderer.java
@@ -840,28 +840,45 @@ TextLayout getTextLayout(int lineIndex, int orientation, int width, int lineSpac
}
}
if (lastOffset < length) layout.setStyle(null, lastOffset, length);
- if (styledText != null && imeRanges != null && imeStyles != null) {
+ if (styledText != null) {
int compositionStart = styledText.compositionStart;
int compositionLength = styledText.compositionLength;
if (compositionStart != -1 && compositionLength > 0) {
int compositionLine = content.getLineAtOffset(compositionStart);
if (compositionLine == lineIndex) {
- for (int i = 0; i < imeStyles.length; i++) {
- int start = imeRanges[i*2] + compositionStart - lineOffset;
- int end = start + imeRanges[i*2+1] - 1;
- TextStyle imeStyle = imeStyles[i], userStyle;
- for (int j = start; j <= end; j++) {
- userStyle = layout.getStyle(j);
- if (userStyle == null && j > 0) userStyle = layout.getStyle(j - 1);
- if (userStyle == null && j + 1 < length) userStyle = layout.getStyle(j + 1);
- if (userStyle == null) {
- layout.setStyle(imeStyle, j, j);
- } else {
- TextStyle newStyle = new TextStyle(imeStyle);
- if (newStyle.font == null) newStyle.font = userStyle.font;
- if (newStyle.foreground == null) newStyle.foreground = userStyle.foreground;
- if (newStyle.background == null) newStyle.background = userStyle.background;
- layout.setStyle(newStyle, j, j);
+ if (imeRanges != null && imeStyles != null) {
+ for (int i = 0; i < imeStyles.length; i++) {
+ int start = imeRanges[i*2] + compositionStart - lineOffset;
+ int end = start + imeRanges[i*2+1] - 1;
+ TextStyle imeStyle = imeStyles[i], userStyle;
+ for (int j = start; j <= end; j++) {
+ userStyle = layout.getStyle(j);
+ if (userStyle == null && j > 0) userStyle = layout.getStyle(j - 1);
+ if (userStyle == null && j + 1 < length) userStyle = layout.getStyle(j + 1);
+ if (userStyle == null) {
+ layout.setStyle(imeStyle, j, j);
+ } else {
+ TextStyle newStyle = new TextStyle(imeStyle);
+ if (newStyle.font == null) newStyle.font = userStyle.font;
+ if (newStyle.foreground == null) newStyle.foreground = userStyle.foreground;
+ if (newStyle.background == null) newStyle.background = userStyle.background;
+ layout.setStyle(newStyle, j, j);
+ }
+ }
+ }
+ } else {
+ int start = compositionStart - lineOffset;
+ int end = start + compositionLength - 1;
+ TextStyle userStyle = layout.getStyle(start);
+ if (userStyle == null) {
+ if (start > 0) userStyle = layout.getStyle(start - 1);
+ if (userStyle == null && end + 1 < length) userStyle = layout.getStyle(end + 1);
+ if (userStyle != null) {
+ TextStyle newStyle = new TextStyle();
+ newStyle.font = userStyle.font;
+ newStyle.foreground = userStyle.foreground;
+ newStyle.background = userStyle.background;
+ layout.setStyle(newStyle, start, end);
}
}
}

Back to the top