diff options
| -rw-r--r-- | java/org/gnu/emacs/EmacsInputConnection.java | 46 | ||||
| -rw-r--r-- | java/org/gnu/emacs/EmacsNative.java | 2 | ||||
| -rw-r--r-- | src/android.c | 15 | ||||
| -rw-r--r-- | src/androidterm.c | 70 | ||||
| -rw-r--r-- | src/textconv.c | 23 | ||||
| -rw-r--r-- | src/textconv.h | 3 |
6 files changed, 136 insertions, 23 deletions
diff --git a/java/org/gnu/emacs/EmacsInputConnection.java b/java/org/gnu/emacs/EmacsInputConnection.java index 54c98d950aa..eb6fd5f2763 100644 --- a/java/org/gnu/emacs/EmacsInputConnection.java +++ b/java/org/gnu/emacs/EmacsInputConnection.java | |||
| @@ -257,6 +257,52 @@ public final class EmacsInputConnection extends BaseInputConnection | |||
| 257 | } | 257 | } |
| 258 | 258 | ||
| 259 | @Override | 259 | @Override |
| 260 | public boolean | ||
| 261 | performContextMenuAction (int contextMenuAction) | ||
| 262 | { | ||
| 263 | int action; | ||
| 264 | |||
| 265 | if (EmacsService.DEBUG_IC) | ||
| 266 | Log.d (TAG, "performContextMenuAction: " + contextMenuAction); | ||
| 267 | |||
| 268 | /* Translate the action in Java code. That way, a great deal of | ||
| 269 | JNI boilerplate can be avoided. */ | ||
| 270 | |||
| 271 | switch (contextMenuAction) | ||
| 272 | { | ||
| 273 | case android.R.id.selectAll: | ||
| 274 | action = 0; | ||
| 275 | break; | ||
| 276 | |||
| 277 | case android.R.id.startSelectingText: | ||
| 278 | action = 1; | ||
| 279 | break; | ||
| 280 | |||
| 281 | case android.R.id.stopSelectingText: | ||
| 282 | action = 2; | ||
| 283 | break; | ||
| 284 | |||
| 285 | case android.R.id.cut: | ||
| 286 | action = 3; | ||
| 287 | break; | ||
| 288 | |||
| 289 | case android.R.id.copy: | ||
| 290 | action = 4; | ||
| 291 | break; | ||
| 292 | |||
| 293 | case android.R.id.paste: | ||
| 294 | action = 5; | ||
| 295 | break; | ||
| 296 | |||
| 297 | default: | ||
| 298 | return true; | ||
| 299 | } | ||
| 300 | |||
| 301 | EmacsNative.performContextMenuAction (windowHandle, action); | ||
| 302 | return true; | ||
| 303 | } | ||
| 304 | |||
| 305 | @Override | ||
| 260 | public ExtractedText | 306 | public ExtractedText |
| 261 | getExtractedText (ExtractedTextRequest request, int flags) | 307 | getExtractedText (ExtractedTextRequest request, int flags) |
| 262 | { | 308 | { |
diff --git a/java/org/gnu/emacs/EmacsNative.java b/java/org/gnu/emacs/EmacsNative.java index 56c03ee38dc..eb75201088b 100644 --- a/java/org/gnu/emacs/EmacsNative.java +++ b/java/org/gnu/emacs/EmacsNative.java | |||
| @@ -208,6 +208,8 @@ public final class EmacsNative | |||
| 208 | public static native void setSelection (short window, int start, int end); | 208 | public static native void setSelection (short window, int start, int end); |
| 209 | public static native void performEditorAction (short window, | 209 | public static native void performEditorAction (short window, |
| 210 | int editorAction); | 210 | int editorAction); |
| 211 | public static native void performContextMenuAction (short window, | ||
| 212 | int contextMenuAction); | ||
| 211 | public static native ExtractedText getExtractedText (short window, | 213 | public static native ExtractedText getExtractedText (short window, |
| 212 | ExtractedTextRequest req, | 214 | ExtractedTextRequest req, |
| 213 | int flags); | 215 | int flags); |
diff --git a/src/android.c b/src/android.c index 67590ae373d..94587344eb5 100644 --- a/src/android.c +++ b/src/android.c | |||
| @@ -3863,22 +3863,13 @@ android_get_gc_values (struct android_gc *gc, | |||
| 3863 | values->clip_y_origin = gc->clip_y_origin; | 3863 | values->clip_y_origin = gc->clip_y_origin; |
| 3864 | 3864 | ||
| 3865 | if (mask & ANDROID_GC_FILL_STYLE) | 3865 | if (mask & ANDROID_GC_FILL_STYLE) |
| 3866 | values->fill_style | 3866 | values->fill_style = gc->fill_style; |
| 3867 | = (*android_java_env)->GetIntField (android_java_env, | ||
| 3868 | gcontext, | ||
| 3869 | emacs_gc_fill_style); | ||
| 3870 | 3867 | ||
| 3871 | if (mask & ANDROID_GC_TILE_STIP_X_ORIGIN) | 3868 | if (mask & ANDROID_GC_TILE_STIP_X_ORIGIN) |
| 3872 | values->ts_x_origin | 3869 | values->ts_x_origin = gc->ts_x_origin; |
| 3873 | = (*android_java_env)->GetIntField (android_java_env, | ||
| 3874 | gcontext, | ||
| 3875 | emacs_gc_ts_origin_x); | ||
| 3876 | 3870 | ||
| 3877 | if (mask & ANDROID_GC_TILE_STIP_Y_ORIGIN) | 3871 | if (mask & ANDROID_GC_TILE_STIP_Y_ORIGIN) |
| 3878 | values->ts_y_origin | 3872 | values->ts_y_origin = gc->ts_y_origin; |
| 3879 | = (*android_java_env)->GetIntField (android_java_env, | ||
| 3880 | gcontext, | ||
| 3881 | emacs_gc_ts_origin_y); | ||
| 3882 | 3873 | ||
| 3883 | /* Fields involving handles are not used by Emacs, and thus not | 3874 | /* Fields involving handles are not used by Emacs, and thus not |
| 3884 | implemented */ | 3875 | implemented */ |
diff --git a/src/androidterm.c b/src/androidterm.c index a9b5834c08f..c302e3f2877 100644 --- a/src/androidterm.c +++ b/src/androidterm.c | |||
| @@ -681,7 +681,6 @@ android_handle_ime_event (union android_event *event, struct frame *f) | |||
| 681 | switch (event->ime.operation) | 681 | switch (event->ime.operation) |
| 682 | { | 682 | { |
| 683 | case ANDROID_IME_COMMIT_TEXT: | 683 | case ANDROID_IME_COMMIT_TEXT: |
| 684 | case ANDROID_IME_FINISH_COMPOSING_TEXT: | ||
| 685 | case ANDROID_IME_SET_COMPOSING_TEXT: | 684 | case ANDROID_IME_SET_COMPOSING_TEXT: |
| 686 | text = android_decode_utf16 (event->ime.text, | 685 | text = android_decode_utf16 (event->ime.text, |
| 687 | event->ime.length); | 686 | event->ime.length); |
| @@ -708,7 +707,8 @@ android_handle_ime_event (union android_event *event, struct frame *f) | |||
| 708 | break; | 707 | break; |
| 709 | 708 | ||
| 710 | case ANDROID_IME_FINISH_COMPOSING_TEXT: | 709 | case ANDROID_IME_FINISH_COMPOSING_TEXT: |
| 711 | finish_composing_text (f, event->ime.counter); | 710 | finish_composing_text (f, event->ime.counter, |
| 711 | event->ime.length); | ||
| 712 | break; | 712 | break; |
| 713 | 713 | ||
| 714 | case ANDROID_IME_SET_COMPOSING_TEXT: | 714 | case ANDROID_IME_SET_COMPOSING_TEXT: |
| @@ -5161,7 +5161,71 @@ NATIVE_NAME (performEditorAction) (JNIEnv *env, jobject object, | |||
| 5161 | /* Undocumented behavior: performEditorAction is apparently expected | 5161 | /* Undocumented behavior: performEditorAction is apparently expected |
| 5162 | to finish composing any text. */ | 5162 | to finish composing any text. */ |
| 5163 | 5163 | ||
| 5164 | NATIVE_NAME (finishComposingText) (env, object, window); | 5164 | event.ime.type = ANDROID_INPUT_METHOD; |
| 5165 | event.ime.serial = ++event_serial; | ||
| 5166 | event.ime.window = window; | ||
| 5167 | event.ime.operation = ANDROID_IME_FINISH_COMPOSING_TEXT; | ||
| 5168 | event.ime.start = 0; | ||
| 5169 | event.ime.end = 0; | ||
| 5170 | |||
| 5171 | /* This value of `length' means that the input method should receive | ||
| 5172 | an update containing the new conversion region. */ | ||
| 5173 | |||
| 5174 | event.ime.length = 1; | ||
| 5175 | event.ime.position = 0; | ||
| 5176 | event.ime.text = NULL; | ||
| 5177 | event.ime.counter = ++edit_counter; | ||
| 5178 | |||
| 5179 | android_write_event (&event); | ||
| 5180 | |||
| 5181 | /* Finally, send the return key press. */ | ||
| 5182 | |||
| 5183 | event.xkey.type = ANDROID_KEY_PRESS; | ||
| 5184 | event.xkey.serial = ++event_serial; | ||
| 5185 | event.xkey.window = window; | ||
| 5186 | event.xkey.time = 0; | ||
| 5187 | event.xkey.state = 0; | ||
| 5188 | event.xkey.keycode = 66; | ||
| 5189 | event.xkey.unicode_char = 0; | ||
| 5190 | |||
| 5191 | android_write_event (&event); | ||
| 5192 | } | ||
| 5193 | |||
| 5194 | JNIEXPORT void JNICALL | ||
| 5195 | NATIVE_NAME (performContextMenuAction) (JNIEnv *env, jobject object, | ||
| 5196 | jshort window, int action) | ||
| 5197 | { | ||
| 5198 | JNI_STACK_ALIGNMENT_PROLOGUE; | ||
| 5199 | |||
| 5200 | union android_event event; | ||
| 5201 | int key; | ||
| 5202 | |||
| 5203 | /* Note that ACTION is determined in EmacsInputConnection, and as | ||
| 5204 | such they are not actual resource IDs. */ | ||
| 5205 | |||
| 5206 | switch (action) | ||
| 5207 | { | ||
| 5208 | case 0: /* android.R.id.selectAll */ | ||
| 5209 | case 1: /* android.R.id.startSelectingText */ | ||
| 5210 | case 2: /* android.R.id.stopSelectingText */ | ||
| 5211 | /* These actions are not implemented. */ | ||
| 5212 | return; | ||
| 5213 | |||
| 5214 | case 3: /* android.R.id.cut */ | ||
| 5215 | key = 277; | ||
| 5216 | break; | ||
| 5217 | |||
| 5218 | case 4: /* android.R.id.copy */ | ||
| 5219 | key = 278; | ||
| 5220 | break; | ||
| 5221 | |||
| 5222 | case 5: /* android.R.id.paste */ | ||
| 5223 | key = 279; | ||
| 5224 | break; | ||
| 5225 | |||
| 5226 | default: | ||
| 5227 | emacs_abort (); | ||
| 5228 | } | ||
| 5165 | 5229 | ||
| 5166 | event.xkey.type = ANDROID_KEY_PRESS; | 5230 | event.xkey.type = ANDROID_KEY_PRESS; |
| 5167 | event.xkey.serial = ++event_serial; | 5231 | event.xkey.serial = ++event_serial; |
diff --git a/src/textconv.c b/src/textconv.c index dcf016104fe..d8166bcfd03 100644 --- a/src/textconv.c +++ b/src/textconv.c | |||
| @@ -676,10 +676,11 @@ really_commit_text (struct frame *f, EMACS_INT position, | |||
| 676 | } | 676 | } |
| 677 | 677 | ||
| 678 | /* Remove the composition region on the frame F, while leaving its | 678 | /* Remove the composition region on the frame F, while leaving its |
| 679 | contents intact. */ | 679 | contents intact. If UPDATE, also notify the input method of the |
| 680 | change. */ | ||
| 680 | 681 | ||
| 681 | static void | 682 | static void |
| 682 | really_finish_composing_text (struct frame *f) | 683 | really_finish_composing_text (struct frame *f, bool update) |
| 683 | { | 684 | { |
| 684 | if (!NILP (f->conversion.compose_region_start)) | 685 | if (!NILP (f->conversion.compose_region_start)) |
| 685 | { | 686 | { |
| @@ -687,6 +688,10 @@ really_finish_composing_text (struct frame *f) | |||
| 687 | Fset_marker (f->conversion.compose_region_end, Qnil, Qnil); | 688 | Fset_marker (f->conversion.compose_region_end, Qnil, Qnil); |
| 688 | f->conversion.compose_region_start = Qnil; | 689 | f->conversion.compose_region_start = Qnil; |
| 689 | f->conversion.compose_region_end = Qnil; | 690 | f->conversion.compose_region_end = Qnil; |
| 691 | |||
| 692 | if (update && text_interface | ||
| 693 | && text_interface->compose_region_changed) | ||
| 694 | (*text_interface->compose_region_changed) (f); | ||
| 690 | } | 695 | } |
| 691 | 696 | ||
| 692 | /* Delete the composition region overlay. */ | 697 | /* Delete the composition region overlay. */ |
| @@ -796,7 +801,7 @@ really_set_composing_text (struct frame *f, ptrdiff_t position, | |||
| 796 | the documentation, but is ultimately what programs expect. */ | 801 | the documentation, but is ultimately what programs expect. */ |
| 797 | 802 | ||
| 798 | if (!SCHARS (text)) | 803 | if (!SCHARS (text)) |
| 799 | really_finish_composing_text (f); | 804 | really_finish_composing_text (f, false); |
| 800 | 805 | ||
| 801 | /* If PT hasn't changed, the conversion region definitely has. | 806 | /* If PT hasn't changed, the conversion region definitely has. |
| 802 | Otherwise, redisplay will update the input method instead. */ | 807 | Otherwise, redisplay will update the input method instead. */ |
| @@ -838,7 +843,7 @@ really_set_composing_region (struct frame *f, ptrdiff_t start, | |||
| 838 | 843 | ||
| 839 | if (max (0, start) == max (0, end)) | 844 | if (max (0, start) == max (0, end)) |
| 840 | { | 845 | { |
| 841 | really_finish_composing_text (f); | 846 | really_finish_composing_text (f, false); |
| 842 | return; | 847 | return; |
| 843 | } | 848 | } |
| 844 | 849 | ||
| @@ -1167,7 +1172,7 @@ handle_pending_conversion_events_1 (struct frame *f, | |||
| 1167 | break; | 1172 | break; |
| 1168 | 1173 | ||
| 1169 | case TEXTCONV_FINISH_COMPOSING_TEXT: | 1174 | case TEXTCONV_FINISH_COMPOSING_TEXT: |
| 1170 | really_finish_composing_text (f); | 1175 | really_finish_composing_text (f, !NILP (data)); |
| 1171 | break; | 1176 | break; |
| 1172 | 1177 | ||
| 1173 | case TEXTCONV_SET_COMPOSING_TEXT: | 1178 | case TEXTCONV_SET_COMPOSING_TEXT: |
| @@ -1360,16 +1365,20 @@ commit_text (struct frame *f, Lisp_Object string, | |||
| 1360 | /* Remove the composition region and its overlay from F's current | 1365 | /* Remove the composition region and its overlay from F's current |
| 1361 | buffer. Leave the text being composed intact. | 1366 | buffer. Leave the text being composed intact. |
| 1362 | 1367 | ||
| 1368 | If UPDATE, call `compose_region_changed' after the region is | ||
| 1369 | removed. | ||
| 1370 | |||
| 1363 | COUNTER means the same as in `start_batch_edit'. */ | 1371 | COUNTER means the same as in `start_batch_edit'. */ |
| 1364 | 1372 | ||
| 1365 | void | 1373 | void |
| 1366 | finish_composing_text (struct frame *f, unsigned long counter) | 1374 | finish_composing_text (struct frame *f, unsigned long counter, |
| 1375 | bool update) | ||
| 1367 | { | 1376 | { |
| 1368 | struct text_conversion_action *action, **last; | 1377 | struct text_conversion_action *action, **last; |
| 1369 | 1378 | ||
| 1370 | action = xmalloc (sizeof *action); | 1379 | action = xmalloc (sizeof *action); |
| 1371 | action->operation = TEXTCONV_FINISH_COMPOSING_TEXT; | 1380 | action->operation = TEXTCONV_FINISH_COMPOSING_TEXT; |
| 1372 | action->data = Qnil; | 1381 | action->data = update ? Qt : Qnil; |
| 1373 | action->next = NULL; | 1382 | action->next = NULL; |
| 1374 | action->counter = counter; | 1383 | action->counter = counter; |
| 1375 | for (last = &f->conversion.actions; *last; last = &(*last)->next) | 1384 | for (last = &f->conversion.actions; *last; last = &(*last)->next) |
diff --git a/src/textconv.h b/src/textconv.h index 055bf251651..e632a9dddcf 100644 --- a/src/textconv.h +++ b/src/textconv.h | |||
| @@ -128,7 +128,8 @@ extern void start_batch_edit (struct frame *, unsigned long); | |||
| 128 | extern void end_batch_edit (struct frame *, unsigned long); | 128 | extern void end_batch_edit (struct frame *, unsigned long); |
| 129 | extern void commit_text (struct frame *, Lisp_Object, ptrdiff_t, | 129 | extern void commit_text (struct frame *, Lisp_Object, ptrdiff_t, |
| 130 | unsigned long); | 130 | unsigned long); |
| 131 | extern void finish_composing_text (struct frame *, unsigned long); | 131 | extern void finish_composing_text (struct frame *, unsigned long, |
| 132 | bool); | ||
| 132 | extern void set_composing_text (struct frame *, Lisp_Object, | 133 | extern void set_composing_text (struct frame *, Lisp_Object, |
| 133 | ptrdiff_t, unsigned long); | 134 | ptrdiff_t, unsigned long); |
| 134 | extern void set_composing_region (struct frame *, ptrdiff_t, ptrdiff_t, | 135 | extern void set_composing_region (struct frame *, ptrdiff_t, ptrdiff_t, |