Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Kurtakov2013-07-11 09:21:18 -0400
committerAlexander Kurtakov2013-07-11 09:21:18 -0400
commit3bd130c31bf829e2454963f915aed0e3e9db5b5b (patch)
treed5b0a5796326f9bf04e6205af41ff8e72764b3f0
parentb2aec83df14dd2f80829ffc496ee04062a7a05e2 (diff)
downloadeclipse.platform.swt-3bd130c31bf829e2454963f915aed0e3e9db5b5b.tar.gz
eclipse.platform.swt-3bd130c31bf829e2454963f915aed0e3e9db5b5b.tar.xz
eclipse.platform.swt-3bd130c31bf829e2454963f915aed0e3e9db5b5b.zip
Use gtk_text_buffer_select_range instead of gtk_text_buffer_move_mark.
gtk_text_buffer_select_range exists since GTK 2.4 and is an optimized way to do selection as reduces GTK recalculations. It has additional benefit for SWT as it reduces the JNI overhead too - 3-4 function call become a single one. Bug 412758 .
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c31
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c2
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h2
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java10
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java14
5 files changed, 27 insertions, 32 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 d363181c0d..fd2ace6a78 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
@@ -15800,20 +15800,6 @@ fail:
}
#endif
-#ifndef NO__1gtk_1text_1buffer_1move_1mark
-JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1text_1buffer_1move_1mark)
- (JNIEnv *env, jclass that, jintLong arg0, jintLong arg1, jbyteArray arg2)
-{
- jbyte *lparg2=NULL;
- OS_NATIVE_ENTER(env, that, _1gtk_1text_1buffer_1move_1mark_FUNC);
- if (arg2) if ((lparg2 = (*env)->GetByteArrayElements(env, arg2, NULL)) == NULL) goto fail;
- gtk_text_buffer_move_mark((GtkTextBuffer *)arg0, (GtkTextMark *)arg1, (const GtkTextIter *)lparg2);
-fail:
- if (arg2 && lparg2) (*env)->ReleaseByteArrayElements(env, arg2, lparg2, 0);
- OS_NATIVE_EXIT(env, that, _1gtk_1text_1buffer_1move_1mark_FUNC);
-}
-#endif
-
#ifndef NO__1gtk_1text_1buffer_1paste_1clipboard
JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1text_1buffer_1paste_1clipboard)
(JNIEnv *env, jclass that, jintLong arg0, jintLong arg1, jbyteArray arg2, jboolean arg3)
@@ -15842,6 +15828,23 @@ fail:
}
#endif
+#ifndef NO__1gtk_1text_1buffer_1select_1range
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1text_1buffer_1select_1range)
+ (JNIEnv *env, jclass that, jintLong arg0, jbyteArray arg1, jbyteArray arg2)
+{
+ jbyte *lparg1=NULL;
+ jbyte *lparg2=NULL;
+ OS_NATIVE_ENTER(env, that, _1gtk_1text_1buffer_1select_1range_FUNC);
+ if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+ if (arg2) if ((lparg2 = (*env)->GetByteArrayElements(env, arg2, NULL)) == NULL) goto fail;
+ gtk_text_buffer_select_range((GtkTextBuffer *)arg0, (const GtkTextIter *)lparg1, (const GtkTextIter *)lparg2);
+fail:
+ if (arg2 && lparg2) (*env)->ReleaseByteArrayElements(env, arg2, lparg2, 0);
+ if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+ OS_NATIVE_EXIT(env, that, _1gtk_1text_1buffer_1select_1range_FUNC);
+}
+#endif
+
#ifndef NO__1gtk_1text_1buffer_1set_1text
JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1text_1buffer_1set_1text)
(JNIEnv *env, jclass that, jintLong arg0, jbyteArray arg1, jint arg2)
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 392de0a764..92680c1b34 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
@@ -1124,9 +1124,9 @@ char * OS_nativeFunctionNames[] = {
#else
"_1gtk_1text_1buffer_1insert__J_3B_3BI",
#endif
- "_1gtk_1text_1buffer_1move_1mark",
"_1gtk_1text_1buffer_1paste_1clipboard",
"_1gtk_1text_1buffer_1place_1cursor",
+ "_1gtk_1text_1buffer_1select_1range",
"_1gtk_1text_1buffer_1set_1text",
"_1gtk_1text_1iter_1get_1line",
"_1gtk_1text_1iter_1get_1offset",
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 5c149e203b..27152acee5 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
@@ -1134,9 +1134,9 @@ typedef enum {
#else
_1gtk_1text_1buffer_1insert__J_3B_3BI_FUNC,
#endif
- _1gtk_1text_1buffer_1move_1mark_FUNC,
_1gtk_1text_1buffer_1paste_1clipboard_FUNC,
_1gtk_1text_1buffer_1place_1cursor_FUNC,
+ _1gtk_1text_1buffer_1select_1range_FUNC,
_1gtk_1text_1buffer_1set_1text_FUNC,
_1gtk_1text_1iter_1get_1line_FUNC,
_1gtk_1text_1iter_1get_1offset_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 5b6aa53829..3b64195768 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
@@ -11474,14 +11474,14 @@ public static final void gtk_text_buffer_insert(long /*int*/ buffer, long /*int*
}
/**
* @param buffer cast=(GtkTextBuffer *)
- * @param mark cast=(GtkTextMark *)
- * @param where cast=(const GtkTextIter *)
+ * @param ins cast=(const GtkTextIter *)
+ * @param bound cast=(const GtkTextIter *)
*/
-public static final native void _gtk_text_buffer_move_mark(long /*int*/ buffer, long /*int*/ mark, byte[] where);
-public static final void gtk_text_buffer_move_mark(long /*int*/ buffer, long /*int*/ mark, byte[] where) {
+public static final native void _gtk_text_buffer_select_range (long /*int*/ buffer, byte[] ins, byte[] bound);
+public static final void gtk_text_buffer_select_range (long /*int*/ buffer, byte[] ins, byte[] bound) {
lock.lock();
try {
- _gtk_text_buffer_move_mark(buffer, mark, where);
+ _gtk_text_buffer_select_range(buffer, ins, bound);
} finally {
lock.unlock();
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java
index 4aa53ead4a..dd960b52d6 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java
@@ -524,10 +524,8 @@ public void clearSelection () {
} else {
byte [] position = new byte [ITER_SIZEOF];
long /*int*/ insertMark = OS.gtk_text_buffer_get_insert (bufferHandle);
- long /*int*/ selectionMark = OS.gtk_text_buffer_get_selection_bound (bufferHandle);
OS.gtk_text_buffer_get_iter_at_mark (bufferHandle, position, insertMark);
- OS.gtk_text_buffer_move_mark (bufferHandle, selectionMark, position);
- OS.gtk_text_buffer_move_mark (bufferHandle, insertMark, position);
+ OS.gtk_text_buffer_select_range(bufferHandle, position, position);
}
}
@@ -2079,10 +2077,7 @@ public void selectAll () {
byte [] end = new byte [ITER_SIZEOF];
OS.gtk_text_buffer_get_iter_at_offset (bufferHandle, start, 0);
OS.gtk_text_buffer_get_end_iter (bufferHandle, end);
- long /*int*/ insertMark = OS.gtk_text_buffer_get_insert (bufferHandle);
- long /*int*/ selectionMark = OS.gtk_text_buffer_get_selection_bound (bufferHandle);
- OS.gtk_text_buffer_move_mark (bufferHandle, selectionMark, start);
- OS.gtk_text_buffer_move_mark (bufferHandle, insertMark, end);
+ OS.gtk_text_buffer_select_range(bufferHandle, start, end);
}
}
@@ -2333,10 +2328,7 @@ public void setSelection (int start, int 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);
- long /*int*/ insertMark = OS.gtk_text_buffer_get_insert (bufferHandle);
- long /*int*/ selectionMark = OS.gtk_text_buffer_get_selection_bound (bufferHandle);
- OS.gtk_text_buffer_move_mark (bufferHandle, selectionMark, startIter);
- OS.gtk_text_buffer_move_mark (bufferHandle, insertMark, endIter);
+ OS.gtk_text_buffer_select_range(bufferHandle, startIter, endIter);
}
}

Back to the top