aboutsummaryrefslogtreecommitdiffstats
path: root/src/androidterm.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/androidterm.c')
-rw-r--r--src/androidterm.c38
1 files changed, 32 insertions, 6 deletions
diff --git a/src/androidterm.c b/src/androidterm.c
index 62a8d5d12b3..0701ef44436 100644
--- a/src/androidterm.c
+++ b/src/androidterm.c
@@ -4831,8 +4831,8 @@ struct android_get_selection_context
4831 android_window window; 4831 android_window window;
4832 4832
4833 /* The position of the window's point when it was last 4833 /* The position of the window's point when it was last
4834 redisplayed. */ 4834 redisplayed, and its last mark if active. */
4835 ptrdiff_t point; 4835 ptrdiff_t point, mark;
4836}; 4836};
4837 4837
4838/* Function run on the main thread by `getSelection'. 4838/* Function run on the main thread by `getSelection'.
@@ -4844,6 +4844,7 @@ android_get_selection (void *data)
4844 struct android_get_selection_context *context; 4844 struct android_get_selection_context *context;
4845 struct frame *f; 4845 struct frame *f;
4846 struct window *w; 4846 struct window *w;
4847 struct buffer *b;
4847 4848
4848 context = data; 4849 context = data;
4849 4850
@@ -4860,25 +4861,50 @@ android_get_selection (void *data)
4860 rather important to keep the input method consistent with the 4861 rather important to keep the input method consistent with the
4861 contents of the display. */ 4862 contents of the display. */
4862 context->point = w->ephemeral_last_point; 4863 context->point = w->ephemeral_last_point;
4864
4865 /* Default context->mark to w->last_point too. */
4866 context->mark = context->point;
4867
4868 /* If the mark is active, then set it properly. */
4869 b = XBUFFER (w->contents);
4870 if (!NILP (BVAR (b, mark_active)) && w->last_mark != -1)
4871 context->mark = w->last_mark;
4863 } 4872 }
4864} 4873}
4865 4874
4866JNIEXPORT jint JNICALL 4875JNIEXPORT jintArray JNICALL
4867NATIVE_NAME (getSelection) (JNIEnv *env, jobject object, jshort window) 4876NATIVE_NAME (getSelection) (JNIEnv *env, jobject object, jshort window)
4868{ 4877{
4869 struct android_get_selection_context context; 4878 struct android_get_selection_context context;
4879 jintArray array;
4880 jint contents[2];
4870 4881
4871 context.window = window; 4882 context.window = window;
4872 4883
4873 android_sync_edit (); 4884 android_sync_edit ();
4874 if (android_run_in_emacs_thread (android_get_selection, 4885 if (android_run_in_emacs_thread (android_get_selection,
4875 &context)) 4886 &context))
4876 return -1; 4887 return NULL;
4877 4888
4878 if (context.point == -1) 4889 if (context.point == -1)
4879 return -1; 4890 return NULL;
4891
4892 /* Wraparound actually makes more sense than truncation; at least
4893 editing will sort of work. */
4894 contents[0] = (unsigned int) min (context.point,
4895 context.mark);
4896 contents[1] = (unsigned int) max (context.point,
4897 context.mark);
4898
4899 /* Now create the array. */
4900 array = (*env)->NewIntArray (env, 2);
4901
4902 if (!array)
4903 return NULL;
4880 4904
4881 return min (context.point, TYPE_MAXIMUM (jint)); 4905 /* Set its contents. */
4906 (*env)->SetIntArrayRegion (env, array, 0, 2, contents);
4907 return array;
4882} 4908}
4883 4909
4884JNIEXPORT void JNICALL 4910JNIEXPORT void JNICALL