diff options
author | Eric Williams | 2017-06-13 19:00:30 +0000 |
---|---|---|
committer | Eric Williams | 2017-07-17 16:37:16 +0000 |
commit | 6e81aaed66307e9b6e37e31d91f2740f53add5b4 (patch) | |
tree | 596a7fdc215c4abab98ecb085dd4ffecb0d22084 /bundles/org.eclipse.swt/Eclipse SWT PI/gtk | |
parent | 34821480d44d654541f3b283b235bac2b5233a3c (diff) | |
download | eclipse.platform.swt-6e81aaed66307e9b6e37e31d91f2740f53add5b4.tar.gz eclipse.platform.swt-6e81aaed66307e9b6e37e31d91f2740f53add5b4.tar.xz eclipse.platform.swt-6e81aaed66307e9b6e37e31d91f2740f53add5b4.zip |
Bug 494565: [GTK] Snippet243 doesn't work because Text#insert(String)I20170717-2000
modifies topIndex
Methods that insert or select text should not modify the topIndex of the
viewer.
To avoid this issue we calculate the visible area, positions of the
topIndex, and the insertion/selection points. If the insertion/selection
points are outside the visible area, then scroll to them. Otherwise do
nothing, which preserves the topIndex.
Tested on GTK3.22, 3.20, 3.18, 3.16, 3.14, 3.10, and 2.24. No additional
AllNonBrowser JUnit test failures occur.
Change-Id: Ib020473a5a31d535fb0b1b84f8b13e087fa16c62
Signed-off-by: Eric Williams <ericwill@redhat.com>
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT PI/gtk')
4 files changed, 37 insertions, 0 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c index be8c0b2232..29c2e550e0 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c @@ -13861,6 +13861,26 @@ fail: } #endif +#ifndef NO__1gtk_1text_1view_1get_1line_1yrange +JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1text_1view_1get_1line_1yrange) + (JNIEnv *env, jclass that, jintLong arg0, jbyteArray arg1, jintArray arg2, jintArray arg3) +{ + jbyte *lparg1=NULL; + jint *lparg2=NULL; + jint *lparg3=NULL; + OS_NATIVE_ENTER(env, that, _1gtk_1text_1view_1get_1line_1yrange_FUNC); + if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail; + if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail; + if (arg3) if ((lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL)) == NULL) goto fail; + gtk_text_view_get_line_yrange((GtkTextView *)arg0, (GtkTextIter *)lparg1, (gint *)lparg2, (gint *)lparg3); +fail: + if (arg3 && lparg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0); + if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0); + if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0); + OS_NATIVE_EXIT(env, that, _1gtk_1text_1view_1get_1line_1yrange_FUNC); +} +#endif + #ifndef NO__1gtk_1text_1view_1get_1visible_1rect JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1text_1view_1get_1visible_1rect) (JNIEnv *env, jclass that, jintLong arg0, jobject arg1) diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c index 9f5f7aa927..1f4ae4045c 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c @@ -1109,6 +1109,7 @@ char * OS_nativeFunctionNames[] = { "_1gtk_1text_1view_1get_1iter_1at_1location", "_1gtk_1text_1view_1get_1iter_1location", "_1gtk_1text_1view_1get_1line_1at_1y", + "_1gtk_1text_1view_1get_1line_1yrange", "_1gtk_1text_1view_1get_1visible_1rect", "_1gtk_1text_1view_1get_1window", "_1gtk_1text_1view_1new", diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h index 27e1284619..29e60bd86b 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h @@ -1119,6 +1119,7 @@ typedef enum { _1gtk_1text_1view_1get_1iter_1at_1location_FUNC, _1gtk_1text_1view_1get_1iter_1location_FUNC, _1gtk_1text_1view_1get_1line_1at_1y_FUNC, + _1gtk_1text_1view_1get_1line_1yrange_FUNC, _1gtk_1text_1view_1get_1visible_1rect_FUNC, _1gtk_1text_1view_1get_1window_FUNC, _1gtk_1text_1view_1new_FUNC, diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java index a09156bc4c..bbcb5f24b8 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java @@ -11791,6 +11791,21 @@ public static final void gtk_text_view_get_line_at_y(long /*int*/ text_view, byt } /** * @param text_view cast=(GtkTextView *) + * @param target_iter cast=(GtkTextIter *) + * @param y cast=(gint *) + * @param height cast=(gint *) + */ +public static final native void _gtk_text_view_get_line_yrange(long /*int*/ text_view, byte[] target_iter, int[] y, int[] height); +public static final void gtk_text_view_get_line_yrange(long /*int*/ text_view, byte[] target_iter, int[] y, int[] height) { + lock.lock(); + try { + _gtk_text_view_get_line_yrange(text_view, target_iter, y, height); + } finally { + lock.unlock(); + } +} +/** + * @param text_view cast=(GtkTextView *) * @param visible_rect cast=(GdkRectangle *),flags=no_in */ public static final native void _gtk_text_view_get_visible_rect(long /*int*/ text_view, GdkRectangle visible_rect); |