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 191778 Details for
Bug 65899
[StyledText] StyledText Supplementary/Surrogate character navigation
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Patch for GTK
surrogate.patch (text/plain), 40.48 KB, created by
Felipe Heidrich
on 2011-03-23 14:24:17 EDT
(
hide
)
Description:
Patch for GTK
Filename:
MIME Type:
Creator:
Felipe Heidrich
Created:
2011-03-23 14:24:17 EDT
Size:
40.48 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.swt >Index: Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java,v >retrieving revision 1.540 >diff -u -r1.540 StyledText.java >--- Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java 17 Feb 2011 16:44:03 -0000 1.540 >+++ Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java 23 Mar 2011 18:24:04 -0000 >@@ -5419,7 +5419,8 @@ > TextLayout layout = renderer.getTextLayout(lineIndex); > if (lineLength != 0 && offsetInLine <= lineLength) { > if (offsetInLine == lineLength) { >- point = layout.getLocation(offsetInLine - 1, true); >+ offsetInLine = layout.getPreviousOffset(offsetInLine, SWT.MOVEMENT_CLUSTER); >+ point = layout.getLocation(offsetInLine, true); > } else { > switch (caretAlignment) { > case OFFSET_LEADING: >@@ -5430,7 +5431,8 @@ > if (offsetInLine == 0) { > point = layout.getLocation(offsetInLine, false); > } else { >- point = layout.getLocation(offsetInLine - 1, true); >+ offsetInLine = layout.getPreviousOffset(offsetInLine, SWT.MOVEMENT_CLUSTER); >+ point = layout.getLocation(offsetInLine, true); > } > break; > } >Index: Eclipse SWT PI/gtk/library/os.c >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c,v >retrieving revision 1.307 >diff -u -r1.307 os.c >--- Eclipse SWT PI/gtk/library/os.c 14 Mar 2011 15:00:17 -0000 1.307 >+++ Eclipse SWT PI/gtk/library/os.c 23 Mar 2011 18:24:05 -0000 >@@ -4444,6 +4444,54 @@ > } > #endif > >+#ifndef NO__1g_1utf16_1offset_1to_1pointer >+JNIEXPORT jintLong JNICALL OS_NATIVE(_1g_1utf16_1offset_1to_1pointer) >+ (JNIEnv *env, jclass that, jintLong arg0, jintLong arg1) >+{ >+ jintLong rc = 0; >+ OS_NATIVE_ENTER(env, that, _1g_1utf16_1offset_1to_1pointer_FUNC); >+ rc = (jintLong)g_utf16_offset_to_pointer((const gchar *)arg0, arg1); >+ OS_NATIVE_EXIT(env, that, _1g_1utf16_1offset_1to_1pointer_FUNC); >+ return rc; >+} >+#endif >+ >+#ifndef NO__1g_1utf16_1offset_1to_1utf8_1offset >+JNIEXPORT jintLong JNICALL OS_NATIVE(_1g_1utf16_1offset_1to_1utf8_1offset) >+ (JNIEnv *env, jclass that, jintLong arg0, jintLong arg1) >+{ >+ jintLong rc = 0; >+ OS_NATIVE_ENTER(env, that, _1g_1utf16_1offset_1to_1utf8_1offset_FUNC); >+ rc = (jintLong)g_utf16_offset_to_utf8_offset((const gchar *)arg0, arg1); >+ OS_NATIVE_EXIT(env, that, _1g_1utf16_1offset_1to_1utf8_1offset_FUNC); >+ return rc; >+} >+#endif >+ >+#ifndef NO__1g_1utf16_1pointer_1to_1offset >+JNIEXPORT jintLong JNICALL OS_NATIVE(_1g_1utf16_1pointer_1to_1offset) >+ (JNIEnv *env, jclass that, jintLong arg0, jintLong arg1) >+{ >+ jintLong rc = 0; >+ OS_NATIVE_ENTER(env, that, _1g_1utf16_1pointer_1to_1offset_FUNC); >+ rc = (jintLong)g_utf16_pointer_to_offset((const gchar *)arg0, (const gchar *)arg1); >+ OS_NATIVE_EXIT(env, that, _1g_1utf16_1pointer_1to_1offset_FUNC); >+ return rc; >+} >+#endif >+ >+#ifndef NO__1g_1utf16_1strlen >+JNIEXPORT jintLong JNICALL OS_NATIVE(_1g_1utf16_1strlen) >+ (JNIEnv *env, jclass that, jintLong arg0, jintLong arg1) >+{ >+ jintLong rc = 0; >+ OS_NATIVE_ENTER(env, that, _1g_1utf16_1strlen_FUNC); >+ rc = (jintLong)g_utf16_strlen((const gchar *)arg0, arg1); >+ OS_NATIVE_EXIT(env, that, _1g_1utf16_1strlen_FUNC); >+ return rc; >+} >+#endif >+ > #ifndef NO__1g_1utf16_1to_1utf8 > JNIEXPORT jintLong JNICALL OS_NATIVE(_1g_1utf16_1to_1utf8) > (JNIEnv *env, jclass that, jcharArray arg0, jintLong arg1, jintLongArray arg2, jintLongArray arg3, jintLongArray arg4) >@@ -4501,6 +4549,18 @@ > } > #endif > >+#ifndef NO__1g_1utf8_1offset_1to_1utf16_1offset >+JNIEXPORT jintLong JNICALL OS_NATIVE(_1g_1utf8_1offset_1to_1utf16_1offset) >+ (JNIEnv *env, jclass that, jintLong arg0, jintLong arg1) >+{ >+ jintLong rc = 0; >+ OS_NATIVE_ENTER(env, that, _1g_1utf8_1offset_1to_1utf16_1offset_FUNC); >+ rc = (jintLong)g_utf8_offset_to_utf16_offset((const gchar *)arg0, arg1); >+ OS_NATIVE_EXIT(env, that, _1g_1utf8_1offset_1to_1utf16_1offset_FUNC); >+ return rc; >+} >+#endif >+ > #ifndef NO__1g_1utf8_1pointer_1to_1offset > JNIEXPORT jintLong JNICALL OS_NATIVE(_1g_1utf8_1pointer_1to_1offset) > (JNIEnv *env, jclass that, jintLong arg0, jintLong arg1) >Index: Eclipse SWT PI/gtk/library/os_custom.c >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.c,v >retrieving revision 1.34 >diff -u -r1.34 os_custom.c >--- Eclipse SWT PI/gtk/library/os_custom.c 4 Oct 2010 20:52:18 -0000 1.34 >+++ Eclipse SWT PI/gtk/library/os_custom.c 23 Mar 2011 18:24:05 -0000 >@@ -118,3 +118,72 @@ > } > #endif > >+glong g_utf16_strlen(const gchar *str, glong max) { >+ const gchar *s = str; >+ guchar ch; >+ glong offset = 0; >+ if (!s || max == 0) return 0; >+ if (max < 0) { >+ while (*s) { >+ if (0xf0 <= *(guchar*)s && *(guchar*)s <= 0xfd) offset++; >+ s = g_utf8_next_char (s); >+ offset++; >+ } >+ >+ } else { >+ while (*s) { >+ ch = *(guchar*)s; >+ s = g_utf8_next_char (s); >+ if (s - str > max) break; >+ if (0xf0 <= ch && ch <= 0xfd) offset++; >+ offset++; >+ } >+ } >+ return offset; >+} >+ >+glong g_utf16_pointer_to_offset(const gchar *str, const gchar * pos) { >+ const gchar *s = str; >+ glong offset = 0; >+ if (!s || !pos) return 0; >+ while (s < pos && *s) { >+ if (0xf0 <= *(guchar*)s && *(guchar*)s <= 0xfd) offset++; >+ s = g_utf8_next_char (s); >+ offset++; >+ } >+ return offset; >+} >+ >+gchar* g_utf16_offset_to_pointer(const gchar* str, glong offset) { >+ const gchar *s = str; >+ if (!s) return 0; >+ while (offset-- > 0 && *s) { >+ if (0xf0 <= *(guchar*)s && *(guchar*)s <= 0xfd) offset--; >+ s = g_utf8_next_char (s); >+ } >+ return (gchar *)s; >+} >+ >+glong g_utf16_offset_to_utf8_offset(const gchar* str, glong offset) { >+ glong r = 0; >+ const gchar *s = str; >+ if (!s) return 0; >+ while (offset-- > 0 && *s) { >+ if (0xf0 <= *(guchar*)s && *(guchar*)s <= 0xfd) offset--; >+ s = g_utf8_next_char (s); >+ r++; >+ } >+ return r; >+} >+ >+glong g_utf8_offset_to_utf16_offset(const gchar* str, glong offset) { >+ glong r = 0; >+ const gchar *s = str; >+ if (!s) return 0; >+ while (offset-- > 0 && *s) { >+ if (0xf0 <= *(guchar*)s && *(guchar*)s <= 0xfd) r++; >+ s = g_utf8_next_char (s); >+ r++; >+ } >+ return r; >+} >\ No newline at end of file >Index: Eclipse SWT PI/gtk/library/os_custom.h >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h,v >retrieving revision 1.99 >diff -u -r1.99 os_custom.h >--- Eclipse SWT PI/gtk/library/os_custom.h 3 Mar 2011 18:45:45 -0000 1.99 >+++ Eclipse SWT PI/gtk/library/os_custom.h 23 Mar 2011 18:24:05 -0000 >@@ -353,4 +353,8 @@ > LOAD_FUNCTION(fp, gtk_status_icon_position_menu) \ > rc = (jintLong)fp; > >- >+glong g_utf16_pointer_to_offset(const gchar*, const gchar*); >+gchar* g_utf16_offset_to_pointer(const gchar*, glong); >+glong g_utf16_strlen(const gchar*, glong max); >+glong g_utf16_offset_to_utf8_offset(const gchar*, glong); >+glong g_utf8_offset_to_utf16_offset(const gchar*, glong); >Index: Eclipse SWT PI/gtk/library/os_stats.c >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c,v >retrieving revision 1.214 >diff -u -r1.214 os_stats.c >--- Eclipse SWT PI/gtk/library/os_stats.c 14 Mar 2011 15:00:17 -0000 1.214 >+++ Eclipse SWT PI/gtk/library/os_stats.c 23 Mar 2011 18:24:05 -0000 >@@ -18,8 +18,8 @@ > > #ifdef NATIVE_STATS > >-int OS_nativeFunctionCount = 1384; >-int OS_nativeFunctionCallCount[1384]; >+int OS_nativeFunctionCount = 1389; >+int OS_nativeFunctionCallCount[1389]; > char * OS_nativeFunctionNames[] = { > #ifndef JNI64 > "Call__IIII", >@@ -390,8 +390,13 @@ > "_1g_1type_1parent", > "_1g_1type_1query", > "_1g_1type_1register_1static", >+ "_1g_1utf16_1offset_1to_1pointer", >+ "_1g_1utf16_1offset_1to_1utf8_1offset", >+ "_1g_1utf16_1pointer_1to_1offset", >+ "_1g_1utf16_1strlen", > "_1g_1utf16_1to_1utf8", > "_1g_1utf8_1offset_1to_1pointer", >+ "_1g_1utf8_1offset_1to_1utf16_1offset", > "_1g_1utf8_1pointer_1to_1offset", > "_1g_1utf8_1strlen", > #ifndef JNI64 >Index: Eclipse SWT PI/gtk/library/os_stats.h >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h,v >retrieving revision 1.215 >diff -u -r1.215 os_stats.h >--- Eclipse SWT PI/gtk/library/os_stats.h 14 Mar 2011 15:00:17 -0000 1.215 >+++ Eclipse SWT PI/gtk/library/os_stats.h 23 Mar 2011 18:24:05 -0000 >@@ -398,8 +398,13 @@ > _1g_1type_1parent_FUNC, > _1g_1type_1query_FUNC, > _1g_1type_1register_1static_FUNC, >+ _1g_1utf16_1offset_1to_1pointer_FUNC, >+ _1g_1utf16_1offset_1to_1utf8_1offset_FUNC, >+ _1g_1utf16_1pointer_1to_1offset_FUNC, >+ _1g_1utf16_1strlen_FUNC, > _1g_1utf16_1to_1utf8_FUNC, > _1g_1utf8_1offset_1to_1pointer_FUNC, >+ _1g_1utf8_1offset_1to_1utf16_1offset_FUNC, > _1g_1utf8_1pointer_1to_1offset_FUNC, > _1g_1utf8_1strlen_FUNC, > #ifndef JNI64 >Index: Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java,v >retrieving revision 1.571 >diff -u -r1.571 OS.java >--- Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java 14 Mar 2011 15:00:18 -0000 1.571 >+++ Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java 23 Mar 2011 18:24:07 -0000 >@@ -3325,6 +3325,59 @@ > } > } > /** @param str cast=(const gchar *) */ >+public static final native int /*long*/ _g_utf16_offset_to_pointer(int /*long*/ str, int /*long*/ offset); >+public static final int /*long*/ g_utf16_offset_to_pointer(int /*long*/ str, int /*long*/ offset) { >+ lock.lock(); >+ try { >+ return _g_utf16_offset_to_pointer(str, offset); >+ } finally { >+ lock.unlock(); >+ } >+} >+/** >+ * @param str cast=(const gchar *) >+ * @param pos cast=(const gchar *) >+ */ >+public static final native int /*long*/ _g_utf16_pointer_to_offset(int /*long*/ str, int /*long*/ pos); >+public static final int /*long*/ g_utf16_pointer_to_offset(int /*long*/ str, int /*long*/ pos) { >+ lock.lock(); >+ try { >+ return _g_utf16_pointer_to_offset(str, pos); >+ } finally { >+ lock.unlock(); >+ } >+} >+/** @param str cast=(const gchar *) */ >+public static final native int /*long*/ _g_utf16_strlen(int /*long*/ str, int /*long*/ max); >+public static final int /*long*/ g_utf16_strlen(int /*long*/ str, int /*long*/ max) { >+ lock.lock(); >+ try { >+ return _g_utf16_strlen(str, max); >+ } finally { >+ lock.unlock(); >+ } >+} >+/** @param str cast=(const gchar *) */ >+public static final native int /*long*/ _g_utf8_offset_to_utf16_offset(int /*long*/ str, int /*long*/ offset); >+public static final int /*long*/ g_utf8_offset_to_utf16_offset(int /*long*/ str, int /*long*/ offset) { >+ lock.lock(); >+ try { >+ return _g_utf8_offset_to_utf16_offset(str, offset); >+ } finally { >+ lock.unlock(); >+ } >+} >+/** @param str cast=(const gchar *) */ >+public static final native int /*long*/ _g_utf16_offset_to_utf8_offset(int /*long*/ str, int /*long*/ offset); >+public static final int /*long*/ g_utf16_offset_to_utf8_offset(int /*long*/ str, int /*long*/ offset) { >+ lock.lock(); >+ try { >+ return _g_utf16_offset_to_utf8_offset(str, offset); >+ } finally { >+ lock.unlock(); >+ } >+} >+/** @param str cast=(const gchar *) */ > public static final native int /*long*/ _g_utf8_strlen(int /*long*/ str, int /*long*/ max); > public static final int /*long*/ g_utf8_strlen(int /*long*/ str, int /*long*/ max) { > lock.lock(); >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.103 >diff -u -r1.103 TextLayout.java >--- Eclipse SWT/gtk/org/eclipse/swt/graphics/TextLayout.java 6 Dec 2010 20:15:59 -0000 1.103 >+++ Eclipse SWT/gtk/org/eclipse/swt/graphics/TextLayout.java 23 Mar 2011 18:24:07 -0000 >@@ -142,7 +142,7 @@ > attribute.end_index = bytePos + offset + 6; > OS.memmove (attr, attribute, PangoAttribute.sizeof); > OS.pango_attr_list_insert(attrList, attr); >- int pos = (int)/*64*/OS.g_utf8_pointer_to_offset(ptr, ptr + bytePos); >+ int pos = (int)/*64*/OS.g_utf16_pointer_to_offset(ptr, ptr + bytePos); > chars[pos + lineIndex * 2] = ZWS; > chars[pos + lineIndex * 2 + 1] = ZWNBS; > segmentsText.getChars(oldPos, pos, chars, oldPos + lineIndex * 2); >@@ -184,8 +184,8 @@ > if (style == null) continue; > int start = translateOffset(styleItem.start); > int end = translateOffset(styles[i+1].start - 1); >- int byteStart = (int)/*64*/(OS.g_utf8_offset_to_pointer(ptr, start) - ptr); >- int byteEnd = (int)/*64*/(OS.g_utf8_offset_to_pointer(ptr, end + 1) - ptr); >+ int byteStart = (int)/*64*/(OS.g_utf16_offset_to_pointer(ptr, start) - ptr); >+ int byteEnd = (int)/*64*/(OS.g_utf16_offset_to_pointer(ptr, end + 1) - ptr); > byteStart = Math.min(byteStart, strlen); > byteEnd = Math.min(byteEnd, strlen); > Font font = style.font; >@@ -430,9 +430,9 @@ > OS.pango_layout_iter_get_line_extents(iter, null, rect); > if (OS.pango_layout_iter_next_line(iter)) { > int bytePos = OS.pango_layout_iter_get_index(iter); >- lineEnd = (int)/*64*/OS.g_utf8_pointer_to_offset(ptr, ptr + bytePos); >+ lineEnd = (int)/*64*/OS.g_utf16_pointer_to_offset(ptr, ptr + bytePos); > } else { >- lineEnd = (int)/*64*/OS.g_utf8_strlen(ptr, -1); >+ lineEnd = (int)/*64*/OS.g_utf16_strlen(ptr, -1); > } > boolean extent = false; > if (lineIndex == lineCount - 1 && (flags & SWT.LAST_LINE_SELECTION) != 0) { >@@ -494,7 +494,7 @@ > } else { > selectionStart = Math.min(Math.max(0, selectionStart), length - 1); > selectionEnd = Math.min(Math.max(0, selectionEnd), length - 1); >- length = (int)/*64*/OS.g_utf8_strlen(OS.pango_layout_get_text(layout), -1); >+ length = (int)/*64*/OS.g_utf16_strlen(OS.pango_layout_get_text(layout), -1); > selectionStart = translateOffset(selectionStart); > selectionEnd = translateOffset(selectionEnd); > if (selectionForeground == null) selectionForeground = device.getSystemColor(SWT.COLOR_LIST_SELECTION_TEXT); >@@ -518,8 +518,8 @@ > } > } else { > int /*long*/ ptr = OS.pango_layout_get_text(layout); >- int byteSelStart = (int)/*64*/(OS.g_utf8_offset_to_pointer(ptr, selectionStart) - ptr); >- int byteSelEnd = (int)/*64*/(OS.g_utf8_offset_to_pointer(ptr, selectionEnd + 1) - ptr); >+ int byteSelStart = (int)/*64*/(OS.g_utf16_offset_to_pointer(ptr, selectionStart) - ptr); >+ int byteSelEnd = (int)/*64*/(OS.g_utf16_offset_to_pointer(ptr, selectionEnd + 1) - ptr); > int strlen = OS.strlen(ptr); > byteSelStart = Math.min(byteSelStart, strlen); > byteSelEnd = Math.min(byteSelEnd, strlen); >@@ -599,8 +599,8 @@ > } > start = translateOffset(start); > int end = translateOffset(styles[i+1].start - 1); >- int byteStart = (int)/*64*/(OS.g_utf8_offset_to_pointer(ptr, start) - ptr); >- int byteEnd = (int)/*64*/(OS.g_utf8_offset_to_pointer(ptr, end + 1) - ptr); >+ int byteStart = (int)/*64*/(OS.g_utf16_offset_to_pointer(ptr, start) - ptr); >+ int byteEnd = (int)/*64*/(OS.g_utf16_offset_to_pointer(ptr, end + 1) - ptr); > int[] ranges = new int[]{byteStart, byteEnd}; > int /*long*/ rgn = OS.gdk_pango_layout_get_clip_region(layout, x, y, ranges, ranges.length / 2); > if (rgn != 0) { >@@ -677,8 +677,8 @@ > } > start = translateOffset(start); > int end = translateOffset(styles[i+1].start - 1); >- int byteStart = (int)/*64*/(OS.g_utf8_offset_to_pointer(ptr, start) - ptr); >- int byteEnd = (int)/*64*/(OS.g_utf8_offset_to_pointer(ptr, end + 1) - ptr); >+ int byteStart = (int)/*64*/(OS.g_utf16_offset_to_pointer(ptr, start) - ptr); >+ int byteEnd = (int)/*64*/(OS.g_utf16_offset_to_pointer(ptr, end + 1) - ptr); > int[] ranges = new int[]{byteStart, byteEnd}; > int /*long*/ rgn = OS.gdk_pango_layout_get_clip_region(layout, x, y, ranges, ranges.length / 2); > if (rgn != 0) { >@@ -776,8 +776,8 @@ > } > start = translateOffset(start); > int end = translateOffset(styles[i+1].start - 1); >- int byteStart = (int)/*64*/(OS.g_utf8_offset_to_pointer(ptr, start) - ptr); >- int byteEnd = (int)/*64*/(OS.g_utf8_offset_to_pointer(ptr, end + 1) - ptr); >+ int byteStart = (int)/*64*/(OS.g_utf16_offset_to_pointer(ptr, start) - ptr); >+ int byteEnd = (int)/*64*/(OS.g_utf16_offset_to_pointer(ptr, end + 1) - ptr); > int[] ranges = new int[]{byteStart, byteEnd}; > int /*long*/ rgn = OS.gdk_pango_layout_get_clip_region(layout, x, y, ranges, ranges.length / 2); > if (rgn != 0) { >@@ -946,8 +946,8 @@ > start = translateOffset(start); > end = translateOffset(end); > int /*long*/ ptr = OS.pango_layout_get_text(layout); >- int byteStart = (int)/*64*/(OS.g_utf8_offset_to_pointer (ptr, start) - ptr); >- int byteEnd = (int)/*64*/(OS.g_utf8_offset_to_pointer (ptr, end + 1) - ptr); >+ int byteStart = (int)/*64*/(OS.g_utf16_offset_to_pointer (ptr, start) - ptr); >+ int byteEnd = (int)/*64*/(OS.g_utf16_offset_to_pointer (ptr, end + 1) - ptr); > int strlen = OS.strlen(ptr); > byteStart = Math.min(byteStart, strlen); > byteEnd = Math.min(byteEnd, strlen); >@@ -1086,7 +1086,7 @@ > PangoItem item = new PangoItem(); > PangoLayoutRun run = new PangoLayoutRun(); > int /*long*/ ptr = OS.pango_layout_get_text(layout); >- int /*long*/ byteOffset = OS.g_utf8_offset_to_pointer(ptr, offset) - ptr; >+ int /*long*/ byteOffset = OS.g_utf16_offset_to_pointer(ptr, offset) - ptr; > int strlen = OS.strlen(ptr); > byteOffset = Math.min(byteOffset, strlen); > do { >@@ -1180,7 +1180,7 @@ > offset = translateOffset(offset); > int line = 0; > int /*long*/ ptr = OS.pango_layout_get_text(layout); >- int /*long*/ byteOffset = OS.g_utf8_offset_to_pointer(ptr,offset) - ptr; >+ int /*long*/ byteOffset = OS.g_utf16_offset_to_pointer(ptr,offset) - ptr; > int strlen = OS.strlen(ptr); > byteOffset = Math.min(byteOffset, strlen); > int /*long*/ iter = OS.pango_layout_get_iter(layout); >@@ -1253,7 +1253,7 @@ > for (int i = 0; i < lineCount; i++) { > int /*long*/ linePtr = OS.pango_layout_get_line(layout, i); > OS.memmove(line, linePtr, PangoLayoutLine.sizeof); >- int pos = (int)/*64*/OS.g_utf8_pointer_to_offset(ptr, ptr + line.start_index); >+ int pos = (int)/*64*/OS.g_utf16_pointer_to_offset(ptr, ptr + line.start_index); > offsets[i] = untranslateOffset(pos); > } > offsets[lineCount] = text.length(); >@@ -1283,7 +1283,7 @@ > if (!(0 <= offset && offset <= length)) SWT.error(SWT.ERROR_INVALID_RANGE); > offset = translateOffset(offset); > int /*long*/ ptr = OS.pango_layout_get_text(layout); >- int byteOffset = (int)/*64*/(OS.g_utf8_offset_to_pointer(ptr, offset) - ptr); >+ int byteOffset = (int)/*64*/(OS.g_utf16_offset_to_pointer(ptr, offset) - ptr); > int strlen = OS.strlen(ptr); > byteOffset = Math.min(byteOffset, strlen); > PangoRectangle pos = new PangoRectangle(); >@@ -1337,32 +1337,49 @@ > int[] nAttrs = new int[1]; > OS.pango_layout_get_log_attrs(layout, attrs, nAttrs); > if (attrs[0] == 0) return offset + step; >- length = (int)/*64*/OS.g_utf8_strlen(OS.pango_layout_get_text(layout), -1); >- offset += step; >- int internalOffset = translateOffset(offset); >+ >+ int /*long*/ ptr = OS.pango_layout_get_text(layout); >+ int utf8Offset = (int)/*64*/OS.g_utf16_offset_to_utf8_offset (ptr, translateOffset(offset)); >+ int utf8Length = (int)/*64*/OS.g_utf8_strlen(ptr, -1); >+ utf8Offset += step; > PangoLogAttr logAttr = new PangoLogAttr(); >- while (0 < internalOffset && internalOffset < length) { >- OS.memmove(logAttr, attrs[0] + internalOffset * PangoLogAttr.sizeof, PangoLogAttr.sizeof); >- if (((movement & SWT.MOVEMENT_CLUSTER) != 0) && logAttr.is_cursor_position) break; >+ while (0 <= utf8Offset && utf8Offset <= utf8Length) { >+ OS.memmove(logAttr, attrs[0] + utf8Offset * PangoLogAttr.sizeof, PangoLogAttr.sizeof); >+ boolean found = false; >+ if (((movement & SWT.MOVEMENT_CLUSTER) != 0) && logAttr.is_cursor_position) found = true; > if ((movement & SWT.MOVEMENT_WORD) != 0) { > if (forward) { >- if (logAttr.is_word_end) break; >+ if (logAttr.is_word_end) found = true; > } else { >- if (logAttr.is_word_start) break; >+ if (logAttr.is_word_start) found = true; > } > } > if ((movement & SWT.MOVEMENT_WORD_START) != 0) { >- if (logAttr.is_word_start) break; >- if (logAttr.is_sentence_end) break; >+ if (logAttr.is_word_start) found = true; >+ if (logAttr.is_sentence_end) found = true; > } > if ((movement & SWT.MOVEMENT_WORD_END) != 0) { >- if (logAttr.is_word_end) break; >+ if (logAttr.is_word_end) found = true; >+ } >+ if (found) { >+ int testOffset = (int)/*64*/OS.g_utf8_offset_to_utf16_offset (ptr, utf8Offset); >+ if (invalidOffsets != null) { >+ for (int i = 0; i < invalidOffsets.length; i++) { >+ if (testOffset == invalidOffsets[i]) { >+ found = false; >+ break; >+ } >+ } >+ } >+ if (found) { >+ offset = untranslateOffset(testOffset); >+ break; >+ } > } >- offset += step; >- internalOffset = translateOffset(offset); >+ utf8Offset += step; > } > OS.g_free(attrs[0]); >- return Math.min(Math.max(0, offset), text.length()); >+ return Math.min(Math.max(0, offset), length); > } > > /** >@@ -1454,7 +1471,7 @@ > int[] piTrailing = new int[1]; > OS.pango_layout_xy_to_index(layout, x * OS.PANGO_SCALE, y * OS.PANGO_SCALE, index, piTrailing); > int /*long*/ ptr = OS.pango_layout_get_text(layout); >- int offset = (int)/*64*/OS.g_utf8_pointer_to_offset(ptr, ptr + index[0]); >+ int offset = (int)/*64*/OS.g_utf16_pointer_to_offset(ptr, ptr + index[0]); > if (trailing != null) trailing[0] = piTrailing[0]; > return untranslateOffset(offset); > } >Index: Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java,v >retrieving revision 1.213 >diff -u -r1.213 Combo.java >--- Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java 1 Mar 2011 15:35:57 -0000 1.213 >+++ Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java 23 Mar 2011 18:24:07 -0000 >@@ -816,8 +816,10 @@ > OS.pango_layout_xy_to_index (layout, x * OS.PANGO_SCALE, y * OS.PANGO_SCALE, index, trailing); > int /*long*/ ptr = OS.pango_layout_get_text (layout); > int position = (int)/*64*/OS.g_utf8_pointer_to_offset (ptr, ptr + index[0]) + trailing[0]; >- Point selection = getSelection (); >- if (selection.x <= position && position < selection.y) { >+ int [] start = new int [1]; >+ int [] end = new int [1]; >+ OS.gtk_editable_get_selection_bounds (entryHandle, start, end); >+ if (start [0] <= position && position < end [0]) { > if (super.dragDetect (x, y, filter, consume)) { > if (consume != null) consume [0] = true; > return true; >@@ -997,7 +999,7 @@ > if (index != -1) length = getItem (index).length (); > } else { > int /*long*/ str = OS.gtk_entry_get_text (entryHandle); >- if (str != 0) length = (int)/*64*/OS.g_utf8_strlen (str, -1); >+ if (str != 0) length = (int)/*64*/OS.g_utf16_strlen (str, -1); > } > return new Point (0, length); > } >@@ -1005,6 +1007,9 @@ > int [] end = new int [1]; > if (entryHandle != 0) { > OS.gtk_editable_get_selection_bounds (entryHandle, start, end); >+ int /*long*/ ptr = OS.gtk_entry_get_text (entryHandle); >+ start[0] = (int)/*64*/OS.g_utf8_offset_to_utf16_offset (ptr, start[0]); >+ end[0] = (int)/*64*/OS.g_utf8_offset_to_utf16_offset (ptr, end[0]); > } > return new Point(start [0], end [0]); > } >@@ -1268,8 +1273,11 @@ > return 0; > } > if (!hooks (SWT.Verify) && !filters (SWT.Verify)) return 0; >- if (end_pos == -1) end_pos = OS.g_utf8_strlen (OS.gtk_entry_get_text (entryHandle), -1); >- String newText = verifyText ("", (int)/*64*/start_pos, (int)/*64*/end_pos); >+ int /*long*/ ptr = OS.gtk_entry_get_text (entryHandle); >+ if (end_pos == -1) end_pos = OS.g_utf8_strlen (ptr, -1); >+ int start = (int)/*64*/OS.g_utf8_offset_to_utf16_offset (ptr, start_pos); >+ int end = (int)/*64*/OS.g_utf8_offset_to_utf16_offset (ptr, end_pos); >+ String newText = verifyText ("", start, end); > if (newText == null) { > OS.g_signal_stop_emission_by_name (entryHandle, OS.delete_text); > } else { >@@ -1371,11 +1379,10 @@ > String oldText = new String (Converter.mbcsToWcs (null, buffer)); > int [] pos = new int [1]; > OS.memmove (pos, position, 4); >- if (pos [0] == -1) { >- int /*long*/ ptr = OS.gtk_entry_get_text (entryHandle); >- pos [0] = (int)/*64*/OS.g_utf8_strlen (ptr, -1); >- } >- String newText = verifyText (oldText, pos [0], pos [0]); >+ int /*long*/ ptr = OS.gtk_entry_get_text (entryHandle); >+ if (pos [0] == -1) pos [0] = (int)/*64*/OS.g_utf8_strlen (ptr, -1); >+ int start = (int)/*64*/OS.g_utf8_offset_to_utf16_offset (ptr, pos [0]); >+ String newText = verifyText (oldText, start, start); > if (newText != oldText) { > int [] newStart = new int [1], newEnd = new int [1]; > OS.gtk_editable_get_selection_bounds (entryHandle, newStart, newEnd); >@@ -2113,8 +2120,11 @@ > if (selection == null) error (SWT.ERROR_NULL_ARGUMENT); > if ((style & SWT.READ_ONLY) != 0) return; > if (entryHandle != 0) { >- OS.gtk_editable_set_position (entryHandle, selection.x); >- OS.gtk_editable_select_region (entryHandle, selection.x, selection.y); >+ int /*long*/ ptr = OS.gtk_entry_get_text (entryHandle); >+ int start = (int)/*64*/OS.g_utf16_offset_to_utf8_offset (ptr, selection.x); >+ int end = (int)/*64*/OS.g_utf16_offset_to_utf8_offset (ptr, selection.y); >+ OS.gtk_editable_set_position (entryHandle, start); >+ OS.gtk_editable_select_region (entryHandle, start, end); > } > } > >@@ -2169,7 +2179,7 @@ > */ > if (hooks (SWT.Verify) || filters (SWT.Verify)) { > int /*long*/ ptr = OS.gtk_entry_get_text (entryHandle); >- string = verifyText (string, 0, (int)/*64*/OS.g_utf8_strlen (ptr, -1)); >+ string = verifyText (string, 0, (int)/*64*/OS.g_utf16_strlen (ptr, -1)); > if (string == null) return; > } > byte [] buffer = Converter.wcsToMbcs (null, string, true); >Index: Eclipse SWT/gtk/org/eclipse/swt/widgets/IME.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/IME.java,v >retrieving revision 1.12 >diff -u -r1.12 IME.java >--- Eclipse SWT/gtk/org/eclipse/swt/widgets/IME.java 1 Jul 2009 14:48:57 -0000 1.12 >+++ Eclipse SWT/gtk/org/eclipse/swt/widgets/IME.java 23 Mar 2011 18:24:07 -0000 >@@ -309,8 +309,8 @@ > int [] end = new int [1]; > for (int i = 0; i < count; i++) { > OS.pango_attr_iterator_range (iterator, start, end); >- ranges [i * 2] = (int)/*64*/OS.g_utf8_pointer_to_offset (preeditString [0], preeditString [0] + start [0]); >- ranges [i * 2 + 1] = (int)/*64*/OS.g_utf8_pointer_to_offset (preeditString [0], preeditString [0] + end [0]) - 1; >+ ranges [i * 2] = (int)/*64*/OS.g_utf16_pointer_to_offset (preeditString [0], preeditString [0] + start [0]); >+ ranges [i * 2 + 1] = (int)/*64*/OS.g_utf16_pointer_to_offset (preeditString [0], preeditString [0] + end [0]) - 1; > styles [i] = new TextStyle (null, null, null); > int /*long*/ attr = OS.pango_attr_iterator_get (iterator, OS.PANGO_ATTR_FOREGROUND); > if (attr != 0) { >Index: Eclipse SWT/gtk/org/eclipse/swt/widgets/Spinner.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Spinner.java,v >retrieving revision 1.57 >diff -u -r1.57 Spinner.java >--- Eclipse SWT/gtk/org/eclipse/swt/widgets/Spinner.java 20 Aug 2010 16:54:55 -0000 1.57 >+++ Eclipse SWT/gtk/org/eclipse/swt/widgets/Spinner.java 23 Mar 2011 18:24:08 -0000 >@@ -647,8 +647,11 @@ > > int /*long*/ gtk_delete_text (int /*long*/ widget, int /*long*/ start_pos, int /*long*/ end_pos) { > if (!hooks (SWT.Verify) && !filters (SWT.Verify)) return 0; >- if (end_pos == -1) end_pos = OS.g_utf8_strlen (OS.gtk_entry_get_text (handle), -1); >- String newText = verifyText ("", (int)/*64*/start_pos, (int)/*64*/end_pos); >+ int /*long*/ ptr = OS.gtk_entry_get_text (handle); >+ if (end_pos == -1) end_pos = OS.g_utf8_strlen (ptr, -1); >+ int start = (int)/*64*/OS.g_utf8_offset_to_utf16_offset (ptr, start_pos); >+ int end = (int)/*64*/OS.g_utf8_offset_to_utf16_offset (ptr, end_pos); >+ String newText = verifyText ("", start, end); > if (newText == null) { > OS.g_signal_stop_emission_by_name (handle, OS.delete_text); > } else { >@@ -685,11 +688,10 @@ > String oldText = new String (Converter.mbcsToWcs (null, buffer)); > int [] pos = new int [1]; > OS.memmove (pos, position, 4); >- if (pos [0] == -1) { >- int /*long*/ ptr = OS.gtk_entry_get_text (handle); >- pos [0] = (int)/*64*/OS.g_utf8_strlen (ptr, -1); >- } >- String newText = verifyText (oldText, pos [0], pos [0]); >+ int /*long*/ ptr = OS.gtk_entry_get_text (handle); >+ if (pos [0] == -1) pos [0] = (int)/*64*/OS.g_utf8_strlen (ptr, -1); >+ int start = (int)/*64*/OS.g_utf16_pointer_to_offset (ptr, pos [0]); >+ String newText = verifyText (oldText, start, start); > if (newText != oldText) { > int [] newStart = new int [1], newEnd = new int [1]; > OS.gtk_editable_get_selection_bounds (handle, newStart, newEnd); >Index: Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java,v >retrieving revision 1.198 >diff -u -r1.198 Text.java >--- Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java 23 Dec 2010 19:18:09 -0000 1.198 >+++ Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java 23 Mar 2011 18:24:08 -0000 >@@ -670,12 +670,18 @@ > public int getCaretPosition () { > checkWidget (); > if ((style & SWT.SINGLE) != 0) { >- return OS.gtk_editable_get_position (handle); >+ int /*long*/ ptr = OS.gtk_entry_get_text (handle); >+ return (int)/*64*/OS.g_utf8_offset_to_utf16_offset (ptr, OS.gtk_editable_get_position (handle)); > } > byte [] position = new byte [ITER_SIZEOF]; > int /*long*/ mark = OS.gtk_text_buffer_get_insert (bufferHandle); > OS.gtk_text_buffer_get_iter_at_mark (bufferHandle, position, mark); >- return OS.gtk_text_iter_get_offset (position); >+ byte [] zero = new byte [ITER_SIZEOF]; >+ OS.gtk_text_buffer_get_iter_at_offset(bufferHandle, zero, 0); >+ int /*long*/ ptr = OS.gtk_text_buffer_get_text (bufferHandle, zero, position, true); >+ int result = (int)/*64*/OS.g_utf8_offset_to_utf16_offset (ptr, OS.gtk_text_iter_get_offset (position)); >+ OS.g_free (ptr); >+ return result; > } > > /** >@@ -692,9 +698,15 @@ > checkWidget (); > if ((style & SWT.SINGLE) != 0) { > int /*long*/ ptr = OS.gtk_entry_get_text (handle); >- return (int)/*64*/OS.g_utf8_strlen (ptr, -1); >+ return (int)/*64*/OS.g_utf16_strlen (ptr, -1); > } >- return OS.gtk_text_buffer_get_char_count (bufferHandle); >+ byte [] startIter = new byte [ITER_SIZEOF]; >+ byte [] endIter = new byte [ITER_SIZEOF]; >+ OS.gtk_text_buffer_get_bounds (bufferHandle, startIter, endIter); >+ int /*long*/ ptr = OS.gtk_text_buffer_get_text (bufferHandle, startIter, endIter, true); >+ int result = (int)/*64*/OS.g_utf16_strlen(ptr, -1); >+ OS.g_free (ptr); >+ return result; > } > > /** >@@ -862,11 +874,15 @@ > int /*long*/ layout = OS.gtk_entry_get_layout (handle); > OS.pango_layout_xy_to_index (layout, point.x * OS.PANGO_SCALE, point.y * OS.PANGO_SCALE, index, trailing); > int /*long*/ ptr = OS.pango_layout_get_text (layout); >- position = (int)/*64*/OS.g_utf8_pointer_to_offset (ptr, ptr + index[0]) + trailing[0]; >+ position = (int)/*64*/OS.g_utf16_pointer_to_offset (ptr, ptr + index[0]) + trailing[0]; > } else { > byte [] p = new byte [ITER_SIZEOF]; > OS.gtk_text_view_get_iter_at_location (handle, p, point.x, point.y); >- position = OS.gtk_text_iter_get_offset (p); >+ byte [] zero = new byte [ITER_SIZEOF]; >+ OS.gtk_text_buffer_get_iter_at_offset(bufferHandle, zero, 0); >+ int /*long*/ ptr = OS.gtk_text_buffer_get_text (bufferHandle, zero, p, true); >+ position = (int)/*64*/OS.g_utf8_offset_to_utf16_offset (ptr, OS.gtk_text_iter_get_offset (p)); >+ OS.g_free (ptr); > } > return position; > } >@@ -895,12 +911,21 @@ > int [] start = new int [1]; > int [] end = new int [1]; > OS.gtk_editable_get_selection_bounds (handle, start, end); >+ int /*long*/ ptr = OS.gtk_entry_get_text (handle); >+ start[0] = (int)/*64*/OS.g_utf8_offset_to_utf16_offset (ptr, start[0]); >+ end[0] = (int)/*64*/OS.g_utf8_offset_to_utf16_offset (ptr, end[0]); > return new Point (start [0], end [0]); > } >- byte [] start = new byte [ITER_SIZEOF]; >- byte [] end = new byte [ITER_SIZEOF]; >- OS.gtk_text_buffer_get_selection_bounds (bufferHandle, start, end); >- return new Point (OS.gtk_text_iter_get_offset (start), OS.gtk_text_iter_get_offset (end)); >+ byte [] startIter = new byte [ITER_SIZEOF]; >+ byte [] endIter = new byte [ITER_SIZEOF]; >+ OS.gtk_text_buffer_get_selection_bounds (bufferHandle, startIter, endIter); >+ byte [] zero = new byte [ITER_SIZEOF]; >+ OS.gtk_text_buffer_get_iter_at_offset(bufferHandle, zero, 0); >+ int /*long*/ ptr = OS.gtk_text_buffer_get_text (bufferHandle, zero, endIter, true); >+ int start = (int)/*64*/OS.g_utf8_offset_to_utf16_offset (ptr, OS.gtk_text_iter_get_offset (startIter)); >+ int end = (int)/*64*/OS.g_utf8_offset_to_utf16_offset (ptr, OS.gtk_text_iter_get_offset (endIter)); >+ OS.g_free (ptr); >+ return new Point (start, end); > } > > /** >@@ -1004,27 +1029,17 @@ > public String getText (int start, int end) { > checkWidget (); > if (!(start <= end && 0 <= end)) return ""; >- int /*long*/ address; >- if ((style & SWT.SINGLE) != 0) { >- start = Math.max (0, start); >- address = OS.gtk_editable_get_chars (handle, start, end + 1); >- } else { >- int length = OS.gtk_text_buffer_get_char_count (bufferHandle); >- end = Math.min (end, length - 1); >- if (start > end) return ""; >- start = Math.max (0, start); >- byte [] startIter = new byte [ITER_SIZEOF]; >- byte [] endIter = new byte [ITER_SIZEOF]; >- OS.gtk_text_buffer_get_iter_at_offset (bufferHandle, startIter, start); >- OS.gtk_text_buffer_get_iter_at_offset (bufferHandle, endIter, end + 1); >- address = OS.gtk_text_buffer_get_text (bufferHandle, startIter, endIter, true); >- } >- if (address == 0) error (SWT.ERROR_CANNOT_GET_TEXT); >- int length = OS.strlen (address); >- byte [] buffer = new byte [length]; >- OS.memmove (buffer, address, length); >- OS.g_free (address); >- return new String (Converter.mbcsToWcs (null, buffer)); >+ String str = getText (); >+ int length = str.length (); >+ end = Math.min (end, length - 1); >+ if (start > end) return ""; >+ start = Math.max (0, start); >+ /* >+ * NOTE: The current implementation uses substring () >+ * which can reference a potentially large character >+ * array. >+ */ >+ return str.substring (start, end + 1); > } > > /** >@@ -1188,7 +1203,7 @@ > if ((style & SWT.SEARCH) != 0) { > if ((style & SWT.ICON_CANCEL) != 0) { > int /*long*/ ptr = OS.gtk_entry_get_text (handle); >- OS.gtk_entry_set_icon_sensitive (handle, OS.GTK_ENTRY_ICON_SECONDARY, OS.g_utf8_strlen (ptr, -1) > 0); >+ OS.gtk_entry_set_icon_sensitive (handle, OS.GTK_ENTRY_ICON_SECONDARY, OS.g_utf16_strlen (ptr, -1) > 0); > } > } > return 0; >@@ -1244,6 +1259,12 @@ > OS.memmove (endIter, iter2, endIter.length); > int start = OS.gtk_text_iter_get_offset (startIter); > int end = OS.gtk_text_iter_get_offset (endIter); >+ byte [] zero = new byte [ITER_SIZEOF]; >+ OS.gtk_text_buffer_get_iter_at_offset(bufferHandle, zero, 0); >+ int /*long*/ ptr = OS.gtk_text_buffer_get_text (bufferHandle, zero, endIter, true); >+ start = (int)/*64*/OS.g_utf8_offset_to_utf16_offset (ptr, start); >+ end = (int)/*64*/OS.g_utf8_offset_to_utf16_offset (ptr, end); >+ OS.g_free (ptr); > String newText = verifyText ("", start, end); > if (newText == null) { > /* Remember the selection when the text was deleted */ >@@ -1274,8 +1295,11 @@ > > int /*long*/ gtk_delete_text (int /*long*/ widget, int /*long*/ start_pos, int /*long*/ end_pos) { > if (!hooks (SWT.Verify) && !filters (SWT.Verify)) return 0; >- if (end_pos == -1) end_pos = OS.g_utf8_strlen (OS.gtk_entry_get_text (handle), -1); >- String newText = verifyText ("", (int)/*64*/start_pos, (int)/*64*/end_pos); >+ int /*long*/ ptr = OS.gtk_entry_get_text (handle); >+ if (end_pos == -1) end_pos = OS.g_utf8_strlen (ptr, -1); >+ int start = (int)/*64*/OS.g_utf8_offset_to_utf16_offset (ptr, start_pos); >+ int end = (int)/*64*/OS.g_utf8_offset_to_utf16_offset (ptr, end_pos); >+ String newText = verifyText ("", start, end); > if (newText == null) { > /* Remember the selection when the text was deleted */ > int [] newStart = new int [1], newEnd = new int [1]; >@@ -1426,10 +1450,8 @@ > String oldText = new String (Converter.mbcsToWcs (null, buffer)); > int [] pos = new int [1]; > OS.memmove (pos, position, 4); >- if (pos [0] == -1) { >- int /*long*/ ptr = OS.gtk_entry_get_text (handle); >- pos [0] = (int)/*64*/OS.g_utf8_strlen (ptr, -1); >- } >+ int /*long*/ ptr = OS.gtk_entry_get_text (handle); >+ if (pos [0] == -1) pos [0] = (int)/*64*/OS.g_utf8_strlen (ptr, -1); > /* Use the selection when the text was deleted */ > int start = pos [0], end = pos [0]; > if (fixStart != -1 && fixEnd != -1) { >@@ -1437,6 +1459,8 @@ > end = fixEnd; > fixStart = fixEnd = -1; > } >+ start = (int)/*64*/OS.g_utf8_offset_to_utf16_offset (ptr, start); >+ end = (int)/*64*/OS.g_utf8_offset_to_utf16_offset (ptr, end); > String newText = verifyText (oldText, start, end); > if (newText != oldText) { > int [] newStart = new int [1], newEnd = new int [1]; >@@ -1493,6 +1517,12 @@ > end = fixEnd; > fixStart = fixEnd = -1; > } >+ byte [] zero = new byte [ITER_SIZEOF]; >+ OS.gtk_text_buffer_get_iter_at_offset(bufferHandle, zero, 0); >+ int /*long*/ ptr = OS.gtk_text_buffer_get_text (bufferHandle, zero, position, true); >+ start = (int)/*64*/OS.g_utf8_offset_to_utf16_offset (ptr, start); >+ end = (int)/*64*/OS.g_utf8_offset_to_utf16_offset (ptr, end); >+ OS.g_free(ptr); > byte [] buffer = new byte [(int)/*64*/length]; > OS.memmove (buffer, text, buffer.length); > String oldText = new String (Converter.mbcsToWcs (null, buffer)); >@@ -1913,11 +1943,18 @@ > public void setSelection (int start) { > checkWidget (); > if ((style & SWT.SINGLE) != 0) { >+ int /*long*/ ptr = OS.gtk_entry_get_text (handle); >+ start = (int)/*64*/OS.g_utf16_offset_to_utf8_offset (ptr, start); > OS.gtk_editable_set_position (handle, start); > } else { >- byte [] position = new byte [ITER_SIZEOF]; >- OS.gtk_text_buffer_get_iter_at_offset (bufferHandle, position, start); >- OS.gtk_text_buffer_place_cursor (bufferHandle, position); >+ byte [] startIter = new byte [ITER_SIZEOF]; >+ byte [] endIter = new byte [ITER_SIZEOF]; >+ OS.gtk_text_buffer_get_bounds (bufferHandle, startIter, endIter); >+ int /*long*/ ptr = OS.gtk_text_buffer_get_text (bufferHandle, startIter, endIter, true); >+ start = (int)/*64*/OS.g_utf16_offset_to_utf8_offset (ptr, start); >+ OS.g_free (ptr); >+ OS.gtk_text_buffer_get_iter_at_offset (bufferHandle, startIter, start); >+ OS.gtk_text_buffer_place_cursor (bufferHandle, startIter); > int /*long*/ mark = OS.gtk_text_buffer_get_insert (bufferHandle); > OS.gtk_text_view_scroll_mark_onscreen (handle, mark); > } >@@ -1950,12 +1987,20 @@ > */ > public void setSelection (int start, int end) { > checkWidget (); >- if ((style & SWT.SINGLE) != 0) { >+ if ((style & SWT.SINGLE) != 0) { >+ int /*long*/ ptr = OS.gtk_entry_get_text (handle); >+ start = (int)/*64*/OS.g_utf16_offset_to_utf8_offset (ptr, start); >+ end = (int)/*64*/OS.g_utf16_offset_to_utf8_offset (ptr, end); > OS.gtk_editable_set_position (handle, start); > OS.gtk_editable_select_region (handle, start, end); > } else { > byte [] startIter = new byte [ITER_SIZEOF]; > byte [] endIter = new byte [ITER_SIZEOF]; >+ OS.gtk_text_buffer_get_bounds (bufferHandle, startIter, endIter); >+ int /*long*/ ptr = OS.gtk_text_buffer_get_text (bufferHandle, startIter, endIter, true); >+ start = (int)/*64*/OS.g_utf16_offset_to_utf8_offset (ptr, start); >+ end = (int)/*64*/OS.g_utf16_offset_to_utf8_offset (ptr, end); >+ OS.g_free (ptr); > OS.gtk_text_buffer_get_iter_at_offset (bufferHandle, startIter, start); > OS.gtk_text_buffer_get_iter_at_offset (bufferHandle, endIter, end); > int /*long*/ insertMark = OS.gtk_text_buffer_get_insert (bufferHandle); >Index: Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java,v >retrieving revision 1.171 >diff -u -r1.171 Widget.java >--- Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java 17 Dec 2010 21:48:04 -0000 1.171 >+++ Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java 23 Mar 2011 18:24:08 -0000 >@@ -1287,7 +1287,7 @@ > > boolean sendKeyEvent (int type, GdkEventKey keyEvent) { > int length = keyEvent.length; >- if (keyEvent.string == 0 || OS.g_utf8_strlen (keyEvent.string, length) <= 1) { >+ if (keyEvent.string == 0 || OS.g_utf16_strlen (keyEvent.string, length) <= 1) { > Event event = new Event (); > event.time = keyEvent.time; > if (!setKeyState (event, keyEvent)) return true; >@@ -1550,7 +1550,7 @@ > } > > boolean setKeyState (Event event, GdkEventKey keyEvent) { >- if (keyEvent.string != 0 && OS.g_utf8_strlen (keyEvent.string, keyEvent.length) > 1) return false; >+ if (keyEvent.string != 0 && OS.g_utf16_strlen (keyEvent.string, keyEvent.length) > 1) return false; > boolean isNull = false; > event.keyCode = Display.translateKey (keyEvent.keyval); > switch (keyEvent.keyval) {
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 65899
:
11803
|
11804
| 191778