diff options
author | Felipe Heidrich <fheidric> | 2007-09-24 19:38:58 +0000 |
---|---|---|
committer | Felipe Heidrich <fheidric> | 2007-09-24 19:38:58 +0000 |
commit | 4b7ac62e4c7abc2bdb8c97e1ee5fae6064a184d8 (patch) | |
tree | 60b9b4e08a5a1f5e33284afb7ebc365ccd151b8c /bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextRenderer.java | |
parent | 1cafb9b13b36075eb1d31bd71ad3febbf37de5b5 (diff) | |
download | eclipse.platform.swt-4b7ac62e4c7abc2bdb8c97e1ee5fae6064a184d8.tar.gz eclipse.platform.swt-4b7ac62e4c7abc2bdb8c97e1ee5fae6064a184d8.tar.xz eclipse.platform.swt-4b7ac62e4c7abc2bdb8c97e1ee5fae6064a184d8.zip |
IME object added
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextRenderer.java')
-rw-r--r-- | bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextRenderer.java | 86 |
1 files changed, 43 insertions, 43 deletions
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 a5f7e5c40e..62c1942021 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 @@ -54,10 +54,6 @@ class StyledTextRenderer { int stylesSetCount = 0; final static int BULLET_MARGIN = 8; - /* IME styles*/ - int[] imeRanges; - TextStyle[] imeStyles; - final static boolean COMPACT_STYLES = true; final static boolean MERGE_STYLES = true; @@ -839,45 +835,51 @@ TextLayout getTextLayout(int lineIndex, int orientation, int width, int lineSpac } } if (lastOffset < length) layout.setStyle(null, lastOffset, length); - if (styledText != null) { - int compositionStart = styledText.compositionStart; - int compositionLength = styledText.compositionLength; - if (compositionStart != -1 && compositionLength > 0) { - int compositionLine = content.getLineAtOffset(compositionStart); - if (compositionLine == lineIndex) { - 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); + if (styledText != null && styledText.ime != null) { + IME ime = styledText.ime; + int compositionOffset = ime.getCompositionOffset(); + if (compositionOffset != -1) { + int commitCount = ime.getCommitCount(); + int compositionLength = ime.getText().length(); + if (compositionLength != commitCount) { + int compositionLine = content.getLineAtOffset(compositionOffset); + if (compositionLine == lineIndex) { + int[] imeRanges = ime.getRanges(); + TextStyle[] imeStyles = ime.getStyles(); + if (imeRanges.length > 0) { + for (int i = 0; i < imeStyles.length; i++) { + int start = imeRanges[i*2] + compositionOffset - 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); + } else { + int start = compositionOffset - 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); + } } } } @@ -949,8 +951,6 @@ void reset() { bullets = null; bulletsIndices = null; redrawLines = null; - imeRanges = null; - imeStyles = null; } void reset(int startLine, int lineCount) { int endLine = startLine + lineCount; |