Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 150521 Details for
Bug 241482
[Bidi] Need to extend BidiSegmentListener
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
TextLayout Patch for platforms other than win32
241482_TL_non_win32.diff (text/plain), 27.48 KB, created by
Lina Kemmel
on 2009-10-26 11:33:15 EDT
(
hide
)
Description:
TextLayout Patch for platforms other than win32
Filename:
MIME Type:
Creator:
Lina Kemmel
Created:
2009-10-26 11:33:15 EDT
Size:
27.48 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.swt >Index: Eclipse SWT/motif/org/eclipse/swt/graphics/TextLayout.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/TextLayout.java,v >retrieving revision 1.72 >diff -u -r1.72 TextLayout.java >--- Eclipse SWT/motif/org/eclipse/swt/graphics/TextLayout.java 1 Jul 2009 14:50:23 -0000 1.72 >+++ Eclipse SWT/motif/org/eclipse/swt/graphics/TextLayout.java 26 Oct 2009 15:14:52 -0000 >@@ -45,6 +45,7 @@ > boolean justify; > int[] tabs; > int[] segments; >+ char[] segmentsChars; > StyleItem[] styles; > > StyleItem[][] runs; >@@ -279,6 +280,8 @@ > lineOffset = null; > lineY = null; > lineWidth = null; >+ segments = null; >+ segmentsChars = null; > } > > /** >@@ -1310,6 +1313,22 @@ > } > > /** >+ * Returns the segments characters of the receiver. >+ * >+ * @return the segments characters >+ * >+ * @exception SWTException <ul> >+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> >+ * </ul> >+ * >+ * @since 3.6 >+ */ >+public char[] getSegmentsChars () { >+ checkLayout(); >+ return segmentsChars; >+} >+ >+/** > * Returns the line spacing of the receiver. > * > * @return the line spacing >@@ -1735,12 +1754,18 @@ > * always be zero and the last one should always be equals to length of > * the text. > * </p> >+ * <p> >+ * When segments characters are set, the segments are the offsets where >+ * the characters are inserted in the text. >+ * <p> > * > * @param segments the text segments offset > * > * @exception SWTException <ul> > * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> > * </ul> >+ * >+ * @see #setSegmentsChars(char[]) > */ > public void setSegments(int[] segments) { > checkLayout(); >@@ -1759,6 +1784,39 @@ > } > > /** >+ * Sets the characters to be used in the segments boundaries. The segments >+ * are set by calling <code>setSegments(int[])</code>. The application can >+ * use this API to insert Unicode Control Characters in the text to control >+ * the display of the text and bidi reordering. The characters are not >+ * accessible by any other API in </code>TextLayout<code>. >+ * >+ * @param segmentsChars the segments characters >+ * >+ * @exception SWTException <ul> >+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> >+ * </ul> >+ * >+ * @see #setSegments(int[]) >+ * >+ * @since 3.6 >+ */ >+public void setSegmentsChars(char[] segmentsChars) { >+ checkLayout(); >+ if (this.segmentsChars == null && segmentsChars == null) return; >+ if (this.segmentsChars != null && segmentsChars != null) { >+ if (this.segmentsChars.length == segmentsChars.length) { >+ int i; >+ for (i = 0; i <segmentsChars.length; i++) { >+ if (this.segmentsChars[i] != segmentsChars[i]) break; >+ } >+ if (i == segmentsChars.length) return; >+ } >+ } >+ freeRuns(); >+ this.segmentsChars = segmentsChars; >+} >+ >+/** > * Sets the style of the receiver for the specified range. Styles previously > * set for that range will be overwritten. The start and end offsets are > * inclusive and will be clamped if out of range. >Index: Eclipse SWT/carbon/org/eclipse/swt/graphics/TextLayout.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/graphics/TextLayout.java,v >retrieving revision 1.93 >diff -u -r1.93 TextLayout.java >--- Eclipse SWT/carbon/org/eclipse/swt/graphics/TextLayout.java 28 Aug 2009 16:25:38 -0000 1.93 >+++ Eclipse SWT/carbon/org/eclipse/swt/graphics/TextLayout.java 26 Oct 2009 15:14:50 -0000 >@@ -274,6 +274,7 @@ > int indentStyle; > int[] tabs; > int[] segments; >+ char[] segmentsChars; > int tabsPtr; > int[] breaks, hardBreaks, lineX, lineWidth, lineHeight, lineAscent; > >@@ -475,6 +476,8 @@ > font = null; > text = null; > styles = null; >+ segments = null; >+ segmentsChars = null; > if (layout != 0) OS.ATSUDisposeTextLayout(layout); > layout = 0; > if (textPtr != 0) OS.DisposePtr(textPtr); >@@ -1550,40 +1553,56 @@ > return segments; > } > >+/** >+ * Returns the segments characters of the receiver. >+ * >+ * @return the segments characters >+ * >+ * @exception SWTException <ul> >+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> >+ * </ul> >+ * >+ * @since 3.6 >+ */ >+public char[] getSegmentsChars () { >+ checkLayout(); >+ return segmentsChars; >+} >+ > String getSegmentsText() { >- if (segments == null) return text; >- int nSegments = segments.length; >- if (nSegments <= 1) return text; > int length = text.length(); > if (length == 0) return text; >- if (nSegments == 2) { >- if (segments[0] == 0 && segments[1] == length) return text; >+ if (segments == null) return text; >+ int nSegments = segments.length; >+ if (nSegments == 0) return text; >+ if (segmentsChars == null) { >+ if (nSegments == 1) return text; >+ if (nSegments == 2) { >+ if (segments[0] == 0 && segments[1] == length) return text; >+ } > } > invalidOffsets = new int[nSegments]; > char[] oldChars = new char[length]; > text.getChars(0, length, oldChars, 0); > char[] newChars = new char[length + nSegments]; > int charCount = 0, segmentCount = 0; >- char separator = getOrientation() == SWT.RIGHT_TO_LEFT ? RTL_MARK : LTR_MARK; >+ char defaultSeparator = orientation == SWT.RIGHT_TO_LEFT ? RTL_MARK : LTR_MARK; > while (charCount < length) { > if (segmentCount < nSegments && charCount == segments[segmentCount]) { > invalidOffsets[segmentCount] = charCount + segmentCount; >+ char separator = segmentsChars != null && segmentsChars.length > segmentCount ? segmentsChars[segmentCount] : defaultSeparator; > newChars[charCount + segmentCount++] = separator; > } else { > newChars[charCount + segmentCount] = oldChars[charCount++]; > } > } >- if (segmentCount < nSegments) { >+ while (segmentCount < nSegments) { > invalidOffsets[segmentCount] = charCount + segmentCount; > segments[segmentCount] = charCount; >+ char separator = segmentsChars != null && segmentsChars.length > segmentCount ? segmentsChars[segmentCount] : defaultSeparator; > newChars[charCount + segmentCount++] = separator; > } >- if (segmentCount != nSegments) { >- int[] tmp = new int [segmentCount]; >- System.arraycopy(invalidOffsets, 0, tmp, 0, segmentCount); >- invalidOffsets = tmp; >- } >- return new String(newChars, 0, Math.min(charCount + segmentCount, newChars.length)); >+ return new String(newChars, 0, newChars.length); > } > > /** >@@ -1956,6 +1975,39 @@ > } > > /** >+ * Sets the characters to be used in the segments boundaries. The segments >+ * are set by calling <code>setSegments(int[])</code>. The application can >+ * use this API to insert Unicode Control Characters in the text to control >+ * the display of the text and bidi reordering. The characters are not >+ * accessible by any other API in </code>TextLayout<code>. >+ * >+ * @param segmentsChars the segments characters >+ * >+ * @exception SWTException <ul> >+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> >+ * </ul> >+ * >+ * @see #setSegments(int[]) >+ * >+ * @since 3.6 >+ */ >+public void setSegmentsChars(char[] segmentsChars) { >+ checkLayout(); >+ if (this.segmentsChars == null && segmentsChars == null) return; >+ if (this.segmentsChars != null && segmentsChars != null) { >+ if (this.segmentsChars.length == segmentsChars.length) { >+ int i; >+ for (i = 0; i <segmentsChars.length; i++) { >+ if (this.segmentsChars[i] != segmentsChars[i]) break; >+ } >+ if (i == segmentsChars.length) return; >+ } >+ } >+ freeRuns(); >+ this.segmentsChars = segmentsChars; >+} >+ >+/** > * Sets the line spacing of the receiver. The line spacing > * is the space left between lines. > * >Index: Eclipse SWT/gtk/org/eclipse/swt/graphics/TextLayout.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/TextLayout.java,v >retrieving revision 1.94 >diff -u -r1.94 TextLayout.java >--- Eclipse SWT/gtk/org/eclipse/swt/graphics/TextLayout.java 28 Aug 2009 16:31:39 -0000 1.94 >+++ Eclipse SWT/gtk/org/eclipse/swt/graphics/TextLayout.java 26 Oct 2009 15:14:52 -0000 >@@ -49,6 +49,7 @@ > String text; > int ascent, descent; > int[] segments; >+ char[] segmentsChars; > int[] tabs; > StyleItem[] styles; > int stylesCount; >@@ -308,6 +309,8 @@ > text = null; > styles = null; > freeRuns(); >+ segments = null; >+ segmentsChars = null; > if (layout != 0) OS.g_object_unref(layout); > layout = 0; > if (context != 0) OS.g_object_unref(context); >@@ -1524,32 +1527,53 @@ > return segments; > } > >+/** >+ * Returns the segments characters of the receiver. >+ * >+ * @return the segments characters >+ * >+ * @exception SWTException <ul> >+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> >+ * </ul> >+ * >+ * @since 3.6 >+ */ >+public char[] getSegmentsChars () { >+ checkLayout(); >+ return segmentsChars; >+} >+ > String getSegmentsText() { >- if (segments == null) return text; >- int nSegments = segments.length; >- if (nSegments <= 1) return text; > int length = text.length(); > if (length == 0) return text; >- if (nSegments == 2) { >- if (segments[0] == 0 && segments[1] == length) return text; >+ if (segments == null) return text; >+ int nSegments = segments.length; >+ if (nSegments == 0) return text; >+ if (segmentsChars == null) { >+ if (nSegments == 1) return text; >+ if (nSegments == 2) { >+ if (segments[0] == 0 && segments[1] == length) return text; >+ } > } > char[] oldChars = new char[length]; > text.getChars(0, length, oldChars, 0); > char[] newChars = new char[length + nSegments]; > int charCount = 0, segmentCount = 0; >- char separator = getOrientation() == SWT.RIGHT_TO_LEFT ? RTL_MARK : LTR_MARK; >+ char defaultSeparator = orientation == SWT.RIGHT_TO_LEFT ? RTL_MARK : LTR_MARK; > while (charCount < length) { > if (segmentCount < nSegments && charCount == segments[segmentCount]) { >+ char separator = segmentsChars != null && segmentsChars.length > segmentCount ? segmentsChars[segmentCount] : defaultSeparator; > newChars[charCount + segmentCount++] = separator; > } else { > newChars[charCount + segmentCount] = oldChars[charCount++]; > } > } >- if (segmentCount < nSegments) { >+ while (segmentCount < nSegments) { > segments[segmentCount] = charCount; >+ char separator = segmentsChars != null && segmentsChars.length > segmentCount ? segmentsChars[segmentCount] : defaultSeparator; > newChars[charCount + segmentCount++] = separator; > } >- return new String(newChars, 0, Math.min(charCount + segmentCount, newChars.length)); >+ return new String(newChars, 0, newChars.length); > } > > /** >@@ -1890,12 +1914,18 @@ > * always be zero and the last one should always be equals to length of > * the text. > * </p> >+ * <p> >+ * When segments characters are set, the segments are the offsets where >+ * the characters are inserted in the text. >+ * <p> > * > * @param segments the text segments offset > * > * @exception SWTException <ul> > * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> > * </ul> >+ * >+ * @see #setSegmentsChars(char[]) > */ > public void setSegments(int[] segments) { > checkLayout(); >@@ -1914,6 +1944,39 @@ > } > > /** >+ * Sets the characters to be used in the segments boundaries. The segments >+ * are set by calling <code>setSegments(int[])</code>. The application can >+ * use this API to insert Unicode Control Characters in the text to control >+ * the display of the text and bidi reordering. The characters are not >+ * accessible by any other API in </code>TextLayout<code>. >+ * >+ * @param segmentsChars the segments characters >+ * >+ * @exception SWTException <ul> >+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> >+ * </ul> >+ * >+ * @see #setSegments(int[]) >+ * >+ * @since 3.6 >+ */ >+public void setSegmentsChars(char[] segmentsChars) { >+ checkLayout(); >+ if (this.segmentsChars == null && segmentsChars == null) return; >+ if (this.segmentsChars != null && segmentsChars != null) { >+ if (this.segmentsChars.length == segmentsChars.length) { >+ int i; >+ for (i = 0; i <segmentsChars.length; i++) { >+ if (this.segmentsChars[i] != segmentsChars[i]) break; >+ } >+ if (i == segmentsChars.length) return; >+ } >+ } >+ freeRuns(); >+ this.segmentsChars = segmentsChars; >+} >+ >+/** > * Sets the style of the receiver for the specified range. Styles previously > * set for that range will be overwritten. The start and end offsets are > * inclusive and will be clamped if out of range. >Index: Eclipse SWT/wpf/org/eclipse/swt/graphics/TextLayout.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/graphics/TextLayout.java,v >retrieving revision 1.26 >diff -u -r1.26 TextLayout.java >--- Eclipse SWT/wpf/org/eclipse/swt/graphics/TextLayout.java 1 Jul 2009 14:49:39 -0000 1.26 >+++ Eclipse SWT/wpf/org/eclipse/swt/graphics/TextLayout.java 26 Oct 2009 15:14:53 -0000 >@@ -45,6 +45,7 @@ > boolean justify; > int[] tabs; > int[] segments; >+ char[] segmentsChars; > StyleItem[] styles; > > int string, defaultTextProperties; >@@ -273,6 +274,8 @@ > segmentsText = null; > tabs = null; > styles = null; >+ segments = null; >+ segmentsChars = null; > // lineOffset = null; > // lineY = null; > // lineWidth = null; >@@ -1237,32 +1240,53 @@ > return segments; > } > >+/** >+ * Returns the segments characters of the receiver. >+ * >+ * @return the segments characters >+ * >+ * @exception SWTException <ul> >+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> >+ * </ul> >+ * >+ * @since 3.6 >+ */ >+public char[] getSegmentsChars () { >+ checkLayout(); >+ return segmentsChars; >+} >+ > String getSegmentsText() { >- if (segments == null) return text; >- int nSegments = segments.length; >- if (nSegments <= 1) return text; > int length = text.length(); > if (length == 0) return text; >- if (nSegments == 2) { >- if (segments[0] == 0 && segments[1] == length) return text; >+ if (segments == null) return text; >+ int nSegments = segments.length; >+ if (nSegments == 0) return text; >+ if (segmentsChars == null) { >+ if (nSegments == 1) return text; >+ if (nSegments == 2) { >+ if (segments[0] == 0 && segments[1] == length) return text; >+ } > } > char[] oldChars = new char[length]; > text.getChars(0, length, oldChars, 0); > char[] newChars = new char[length + nSegments]; > int charCount = 0, segmentCount = 0; >- char separator = orientation == SWT.RIGHT_TO_LEFT ? RTL_MARK : LTR_MARK; >+ char defaultSeparator = orientation == SWT.RIGHT_TO_LEFT ? RTL_MARK : LTR_MARK; > while (charCount < length) { > if (segmentCount < nSegments && charCount == segments[segmentCount]) { >+ char separator = segmentsChars != null && segmentsChars.length > segmentCount ? segmentsChars[segmentCount] : defaultSeparator; > newChars[charCount + segmentCount++] = separator; > } else { > newChars[charCount + segmentCount] = oldChars[charCount++]; > } > } >- if (segmentCount < nSegments) { >+ while (segmentCount < nSegments) { > segments[segmentCount] = charCount; >+ char separator = segmentsChars != null && segmentsChars.length > segmentCount ? segmentsChars[segmentCount] : defaultSeparator; > newChars[charCount + segmentCount++] = separator; > } >- return new String(newChars, 0, Math.min(charCount + segmentCount, newChars.length)); >+ return new String(newChars, 0, newChars.length); > } > > /** >@@ -1613,12 +1637,18 @@ > * always be zero and the last one should always be equals to length of > * the text. > * </p> >+ * <p> >+ * When segments characters are set, the segments are the offsets where >+ * the characters are inserted in the text. >+ * <p> > * > * @param segments the text segments offset > * > * @exception SWTException <ul> > * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> > * </ul> >+ * >+ * @see #setSegmentsChars(char[]) > */ > public void setSegments(int[] segments) { > checkLayout(); >@@ -1637,6 +1667,39 @@ > } > > /** >+ * Sets the characters to be used in the segments boundaries. The segments >+ * are set by calling <code>setSegments(int[])</code>. The application can >+ * use this API to insert Unicode Control Characters in the text to control >+ * the display of the text and bidi reordering. The characters are not >+ * accessible by any other API in </code>TextLayout<code>. >+ * >+ * @param segmentsChars the segments characters >+ * >+ * @exception SWTException <ul> >+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> >+ * </ul> >+ * >+ * @see #setSegments(int[]) >+ * >+ * @since 3.6 >+ */ >+public void setSegmentsChars(char[] segmentsChars) { >+ checkLayout(); >+ if (this.segmentsChars == null && segmentsChars == null) return; >+ if (this.segmentsChars != null && segmentsChars != null) { >+ if (this.segmentsChars.length == segmentsChars.length) { >+ int i; >+ for (i = 0; i <segmentsChars.length; i++) { >+ if (this.segmentsChars[i] != segmentsChars[i]) break; >+ } >+ if (i == segmentsChars.length) return; >+ } >+ } >+ freeRuns(); >+ this.segmentsChars = segmentsChars; >+} >+ >+/** > * Sets the line spacing of the receiver. The line spacing > * is the space left between lines. > * >@@ -1823,7 +1886,7 @@ > > int validadeOffset(int offset, int step) { > offset += step; >- if (segments != null && segments.length > 2) { >+ if (segments != null && (segments.length > 2 || segmentsChars != null)) { > for (int i = 0; i < segments.length; i++) { > if (translateOffset(segments[i]) - 1 == offset) { > offset += step; >@@ -1846,13 +1909,16 @@ > } > > int translateOffset(int offset) { >- if (segments == null) return offset; >- int nSegments = segments.length; >- if (nSegments <= 1) return offset; > int length = text.length(); > if (length == 0) return offset; >- if (nSegments == 2) { >- if (segments[0] == 0 && segments[1] == length) return offset; >+ if (segments == null) return offset; >+ int nSegments = segments.length; >+ if (nSegments == 0) return offset; >+ if (segmentsChars == null) { >+ if (nSegments == 1) return offset; >+ if (nSegments == 2) { >+ if (segments[0] == 0 && segments[1] == length) return offset; >+ } > } > for (int i = 0; i < nSegments && offset - i >= segments[i]; i++) { > offset++; >@@ -1861,13 +1927,16 @@ > } > > int untranslateOffset(int offset) { >- if (segments == null) return offset; >- int nSegments = segments.length; >- if (nSegments <= 1) return offset; > int length = text.length(); > if (length == 0) return offset; >- if (nSegments == 2) { >- if (segments[0] == 0 && segments[1] == length) return offset; >+ if (segments == null) return offset; >+ int nSegments = segments.length; >+ if (nSegments == 0) return offset; >+ if (segmentsChars == null) { >+ if (nSegments == 1) return offset; >+ if (nSegments == 2) { >+ if (segments[0] == 0 && segments[1] == length) return offset; >+ } > } > for (int i = 0; i < nSegments && offset > segments[i]; i++) { > offset--; >Index: Eclipse SWT/cocoa/org/eclipse/swt/graphics/TextLayout.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/TextLayout.java,v >retrieving revision 1.54 >diff -u -r1.54 TextLayout.java >--- Eclipse SWT/cocoa/org/eclipse/swt/graphics/TextLayout.java 14 Oct 2009 19:18:15 -0000 1.54 >+++ Eclipse SWT/cocoa/org/eclipse/swt/graphics/TextLayout.java 26 Oct 2009 15:14:51 -0000 >@@ -48,6 +48,7 @@ > int alignment; > int[] tabs; > int[] segments; >+ char[] segmentsChars; > int wrapWidth; > int orientation; > >@@ -316,6 +317,8 @@ > font = null; > text = null; > styles = null; >+ segments = null; >+ segmentsChars = null; > } > > /** >@@ -1316,40 +1319,56 @@ > return segments; > } > >+/** >+ * Returns the segments characters of the receiver. >+ * >+ * @return the segments characters >+ * >+ * @exception SWTException <ul> >+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> >+ * </ul> >+ * >+ * @since 3.6 >+ */ >+public char[] getSegmentsChars () { >+ checkLayout(); >+ return segmentsChars; >+} >+ > String getSegmentsText() { >- if (segments == null) return text; >- int nSegments = segments.length; >- if (nSegments <= 1) return text; > int length = text.length(); > if (length == 0) return text; >- if (nSegments == 2) { >- if (segments[0] == 0 && segments[1] == length) return text; >+ if (segments == null) return text; >+ int nSegments = segments.length; >+ if (nSegments == 0) return text; >+ if (segmentsChars == null) { >+ if (nSegments == 1) return text; >+ if (nSegments == 2) { >+ if (segments[0] == 0 && segments[1] == length) return text; >+ } > } > invalidOffsets = new int[nSegments]; > char[] oldChars = new char[length]; > text.getChars(0, length, oldChars, 0); > char[] newChars = new char[length + nSegments]; > int charCount = 0, segmentCount = 0; >- char separator = getOrientation() == SWT.RIGHT_TO_LEFT ? RTL_MARK : LTR_MARK; >+ char defaultSeparator = orientation == SWT.RIGHT_TO_LEFT ? RTL_MARK : LTR_MARK; > while (charCount < length) { > if (segmentCount < nSegments && charCount == segments[segmentCount]) { > invalidOffsets[segmentCount] = charCount + segmentCount; >+ char separator = segmentsChars != null && segmentsChars.length > segmentCount ? segmentsChars[segmentCount] : defaultSeparator; > newChars[charCount + segmentCount++] = separator; > } else { > newChars[charCount + segmentCount] = oldChars[charCount++]; > } > } >- if (segmentCount < nSegments) { >+ while (segmentCount < nSegments) { > invalidOffsets[segmentCount] = charCount + segmentCount; > segments[segmentCount] = charCount; >+ char separator = segmentsChars != null && segmentsChars.length > segmentCount ? segmentsChars[segmentCount] : defaultSeparator; > newChars[charCount + segmentCount++] = separator; > } >- if (segmentCount != nSegments) { >- int[] tmp = new int [segmentCount]; >- System.arraycopy(invalidOffsets, 0, tmp, 0, segmentCount); >- invalidOffsets = tmp; >- } >- return new String(newChars, 0, Math.min(charCount + segmentCount, newChars.length)); >+ return new String(newChars, 0, newChars.length); > } > > /** >@@ -1712,17 +1731,23 @@ > * always be zero and the last one should always be equals to length of > * the text. > * </p> >+ * <p> >+ * When segments characters are set, the segments are the offsets where >+ * the characters are inserted in the text. >+ * <p> > * > * @param segments the text segments offset > * > * @exception SWTException <ul> > * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> > * </ul> >+ * >+ * @see #setSegmentsChars(char[]) > */ > public void setSegments(int[] segments) { > checkLayout(); > if (this.segments == null && segments == null) return; >- if (this.segments != null && segments !=null) { >+ if (this.segments != null && segments != null) { > if (this.segments.length == segments.length) { > int i; > for (i = 0; i <segments.length; i++) { >@@ -1742,6 +1767,45 @@ > } > > /** >+ * Sets the characters to be used in the segments boundaries. The segments >+ * are set by calling <code>setSegments(int[])</code>. The application can >+ * use this API to insert Unicode Control Characters in the text to control >+ * the display of the text and bidi reordering. The characters are not >+ * accessible by any other API in </code>TextLayout<code>. >+ * >+ * @param segmentsChars the segments characters >+ * >+ * @exception SWTException <ul> >+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> >+ * </ul> >+ * >+ * @see #setSegments(int[]) >+ * >+ * @since 3.6 >+ */ >+public void setSegmentsChars(char[] segmentsChars) { >+ checkLayout(); >+ if (this.segmentsChars == null && segmentsChars == null) return; >+ if (this.segmentsChars != null && segmentsChars != null) { >+ if (this.segmentsChars.length == segmentsChars.length) { >+ int i; >+ for (i = 0; i <segmentsChars.length; i++) { >+ if (this.segmentsChars[i] != segmentsChars[i]) break; >+ } >+ if (i == segmentsChars.length) return; >+ } >+ } >+ NSAutoreleasePool pool = null; >+ if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init(); >+ try { >+ freeRuns(); >+ this.segmentsChars = segmentsChars; >+ } finally { >+ if (pool != null) pool.release(); >+ } >+} >+ >+/** > * Sets the line spacing of the receiver. The line spacing > * is the space left between lines. > * >Index: Eclipse SWT/emulated/textlayout/org/eclipse/swt/graphics/TextLayout.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.swt/Eclipse SWT/emulated/textlayout/org/eclipse/swt/graphics/TextLayout.java,v >retrieving revision 1.57 >diff -u -r1.57 TextLayout.java >--- Eclipse SWT/emulated/textlayout/org/eclipse/swt/graphics/TextLayout.java 1 Jul 2009 14:50:52 -0000 1.57 >+++ Eclipse SWT/emulated/textlayout/org/eclipse/swt/graphics/TextLayout.java 26 Oct 2009 15:14:51 -0000 >@@ -45,6 +45,7 @@ > boolean justify; > int[] tabs; > int[] segments; >+ char[] segmentsChars; > StyleItem[] styles; > > StyleItem[][] runs; >@@ -255,6 +256,8 @@ > lineOffset = null; > lineY = null; > lineWidth = null; >+ segments = null; >+ segmentsChars = null; > } > > /** >@@ -1154,6 +1157,22 @@ > } > > /** >+ * Returns the segments characters of the receiver. >+ * >+ * @return the segments characters >+ * >+ * @exception SWTException <ul> >+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> >+ * </ul> >+ * >+ * @since 3.6 >+ */ >+public char[] getSegmentsChars () { >+ checkLayout(); >+ return segmentsChars; >+} >+ >+/** > * Gets the style of the receiver at the specified character offset. > * > * @param offset the text offset >@@ -1559,12 +1578,18 @@ > * always be zero and the last one should always be equals to length of > * the text. > * </p> >+ * <p> >+ * When segments characters are set, the segments are the offsets where >+ * the characters are inserted in the text. >+ * <p> > * > * @param segments the text segments offset > * > * @exception SWTException <ul> > * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> > * </ul> >+ * >+ * @see #setSegmentsChars(char[]) > */ > public void setSegments(int[] segments) { > checkLayout(); >@@ -1583,6 +1608,39 @@ > } > > /** >+ * Sets the characters to be used in the segments boundaries. The segments >+ * are set by calling <code>setSegments(int[])</code>. The application can >+ * use this API to insert Unicode Control Characters in the text to control >+ * the display of the text and bidi reordering. The characters are not >+ * accessible by any other API in </code>TextLayout<code>. >+ * >+ * @param segmentsChars the segments characters >+ * >+ * @exception SWTException <ul> >+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> >+ * </ul> >+ * >+ * @see #setSegments(int[]) >+ * >+ * @since 3.6 >+ */ >+public void setSegmentsChars(char[] segmentsChars) { >+ checkLayout(); >+ if (this.segmentsChars == null && segmentsChars == null) return; >+ if (this.segmentsChars != null && segmentsChars != null) { >+ if (this.segmentsChars.length == segmentsChars.length) { >+ int i; >+ for (i = 0; i <segmentsChars.length; i++) { >+ if (this.segmentsChars[i] != segmentsChars[i]) break; >+ } >+ if (i == segmentsChars.length) return; >+ } >+ } >+ freeRuns(); >+ this.segmentsChars = segmentsChars; >+} >+ >+/** > * Sets the style of the receiver for the specified range. Styles previously > * set for that range will be overwritten. The start and end offsets are > * inclusive and will be clamped if out of range.
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 241482
:
149826
|
149827
|
149828
|
150247
|
150475
|
150476
|
150521
|
150529
|
151170
|
151171
|
151175
|
151416
|
151681
|
151813
|
151856
|
151888
|
151889
|
152092
|
152244
|
152384
|
152386
|
152414
|
152419
|
152617
|
152635