aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPo Lu2023-11-05 10:40:52 +0800
committerPo Lu2023-11-05 10:42:01 +0800
commitc6c5bba06fcc1c467c547e4d35abc6bc5c2f3429 (patch)
tree262a873d8d3fb851ba75e0f408740936facc023b
parent41e801fea1caff57203f76693ac4f0fe1ba2df03 (diff)
downloademacs-c6c5bba06fcc1c467c547e4d35abc6bc5c2f3429.tar.gz
emacs-c6c5bba06fcc1c467c547e4d35abc6bc5c2f3429.zip
Implement more Android text editing controls
* lisp/term/android-win.el (android-deactivate-mark-command): New command. (select-all, start-selecting-text, stop-selecting-text): Arrange for commands manipulating the region to be executed when these keys are registered. * src/android.c (android_get_keysym_name): Return the keysym name of each of the new keysyms introduced. * src/androidterm.c (performContextMenuAction): Save special keysyms into key events for the selectAll, startSelectingText and stopSelectingText actions.
-rw-r--r--lisp/term/android-win.el15
-rw-r--r--src/android.c28
-rw-r--r--src/androidterm.c13
3 files changed, 55 insertions, 1 deletions
diff --git a/lisp/term/android-win.el b/lisp/term/android-win.el
index 960dfdcb4a6..70e24f4ccc7 100644
--- a/lisp/term/android-win.el
+++ b/lisp/term/android-win.el
@@ -295,5 +295,20 @@ content:// URIs into the special file names which represent them."
295(define-key special-event-map [drag-n-drop] 'android-handle-dnd-event) 295(define-key special-event-map [drag-n-drop] 'android-handle-dnd-event)
296 296
297 297
298;; Bind keys sent by input methods to manipulate the state of the
299;; selection to commands which set or deactivate the mark.
300
301(defun android-deactivate-mark-command ()
302 "Deactivate the mark in this buffer.
303This command is generally invoked by input methods sending
304the `stop-selecting-text' editing key."
305 (interactive)
306 (deactivate-mark))
307
308(global-set-key [select-all] 'mark-whole-buffer)
309(global-set-key [start-selecting-text] 'set-mark-command)
310(global-set-key [stop-selecting-text] 'android-deactivate-mark-command)
311
312
298(provide 'android-win) 313(provide 'android-win)
299;; android-win.el ends here. 314;; android-win.el ends here.
diff --git a/src/android.c b/src/android.c
index 79f16568fd4..3397ec0e740 100644
--- a/src/android.c
+++ b/src/android.c
@@ -5598,6 +5598,27 @@ android_get_keysym_name (int keysym, char *name_return, size_t size)
5598 const char *buffer; 5598 const char *buffer;
5599 jmethodID method; 5599 jmethodID method;
5600 5600
5601 /* These keysyms are special editor actions sent by the input
5602 method. */
5603
5604 switch (keysym)
5605 {
5606 case 65536 + 1:
5607 strncpy (name_return, "select-all", size - 1);
5608 name_return[size] = '\0';
5609 return;
5610
5611 case 65536 + 2:
5612 strncpy (name_return, "start-selecting-text", size - 1);
5613 name_return[size] = '\0';
5614 return;
5615
5616 case 65536 + 3:
5617 strncpy (name_return, "stop-selecting-text", size - 1);
5618 name_return[size] = '\0';
5619 return;
5620 }
5621
5601 method = service_class.name_keysym; 5622 method = service_class.name_keysym;
5602 string 5623 string
5603 = (*android_java_env)->CallNonvirtualObjectMethod (android_java_env, 5624 = (*android_java_env)->CallNonvirtualObjectMethod (android_java_env,
@@ -5607,6 +5628,13 @@ android_get_keysym_name (int keysym, char *name_return, size_t size)
5607 (jint) keysym); 5628 (jint) keysym);
5608 android_exception_check (); 5629 android_exception_check ();
5609 5630
5631 if (!string)
5632 {
5633 strncpy (name_return, "stop-selecting-text", size - 1);
5634 name_return[size] = '\0';
5635 return;
5636 }
5637
5610 buffer = (*android_java_env)->GetStringUTFChars (android_java_env, 5638 buffer = (*android_java_env)->GetStringUTFChars (android_java_env,
5611 (jstring) string, 5639 (jstring) string,
5612 NULL); 5640 NULL);
diff --git a/src/androidterm.c b/src/androidterm.c
index 4a479daf452..1593cac36ba 100644
--- a/src/androidterm.c
+++ b/src/androidterm.c
@@ -5402,11 +5402,22 @@ NATIVE_NAME (performContextMenuAction) (JNIEnv *env, jobject object,
5402 5402
5403 switch (action) 5403 switch (action)
5404 { 5404 {
5405 /* The subsequent three keycodes are addressed by
5406 android_get_keysym_name rather than in keyboard.c. */
5407
5405 case 0: /* android.R.id.selectAll */ 5408 case 0: /* android.R.id.selectAll */
5409 key = 65536 + 1;
5410 break;
5411
5406 case 1: /* android.R.id.startSelectingText */ 5412 case 1: /* android.R.id.startSelectingText */
5413 key = 65536 + 2;
5414 break;
5415
5407 case 2: /* android.R.id.stopSelectingText */ 5416 case 2: /* android.R.id.stopSelectingText */
5417 key = 65536 + 3;
5418 break;
5419
5408 default: 5420 default:
5409 /* These actions are not implemented. */
5410 return; 5421 return;
5411 5422
5412 case 3: /* android.R.id.cut */ 5423 case 3: /* android.R.id.cut */