emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master c6c5bba06fc: Implement more Android text editing controls


From: Po Lu
Subject: master c6c5bba06fc: Implement more Android text editing controls
Date: Sat, 4 Nov 2023 22:42:17 -0400 (EDT)

branch: master
commit c6c5bba06fcc1c467c547e4d35abc6bc5c2f3429
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>

    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.
---
 lisp/term/android-win.el | 15 +++++++++++++++
 src/android.c            | 28 ++++++++++++++++++++++++++++
 src/androidterm.c        | 13 ++++++++++++-
 3 files changed, 55 insertions(+), 1 deletion(-)

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."
 (define-key special-event-map [drag-n-drop] 'android-handle-dnd-event)
 
 
+;; Bind keys sent by input methods to manipulate the state of the
+;; selection to commands which set or deactivate the mark.
+
+(defun android-deactivate-mark-command ()
+  "Deactivate the mark in this buffer.
+This command is generally invoked by input methods sending
+the `stop-selecting-text' editing key."
+  (interactive)
+  (deactivate-mark))
+
+(global-set-key [select-all] 'mark-whole-buffer)
+(global-set-key [start-selecting-text] 'set-mark-command)
+(global-set-key [stop-selecting-text] 'android-deactivate-mark-command)
+
+
 (provide 'android-win)
 ;; 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)
   const char *buffer;
   jmethodID method;
 
+  /* These keysyms are special editor actions sent by the input
+     method.  */
+
+  switch (keysym)
+    {
+    case 65536 + 1:
+      strncpy (name_return, "select-all", size - 1);
+      name_return[size] = '\0';
+      return;
+
+    case 65536 + 2:
+      strncpy (name_return, "start-selecting-text", size - 1);
+      name_return[size] = '\0';
+      return;
+
+    case 65536 + 3:
+      strncpy (name_return, "stop-selecting-text", size - 1);
+      name_return[size] = '\0';
+      return;
+    }
+
   method = service_class.name_keysym;
   string
     = (*android_java_env)->CallNonvirtualObjectMethod (android_java_env,
@@ -5607,6 +5628,13 @@ android_get_keysym_name (int keysym, char *name_return, 
size_t size)
                                                       (jint) keysym);
   android_exception_check ();
 
+  if (!string)
+    {
+      strncpy (name_return, "stop-selecting-text", size - 1);
+      name_return[size] = '\0';
+      return;
+    }
+
   buffer = (*android_java_env)->GetStringUTFChars (android_java_env,
                                                   (jstring) string,
                                                   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,
 
   switch (action)
     {
+      /* The subsequent three keycodes are addressed by
+        android_get_keysym_name rather than in keyboard.c.  */
+
     case 0: /* android.R.id.selectAll */
+      key = 65536 + 1;
+      break;
+
     case 1: /* android.R.id.startSelectingText */
+      key = 65536 + 2;
+      break;
+
     case 2: /* android.R.id.stopSelectingText */
+      key = 65536 + 3;
+      break;
+
     default:
-      /* These actions are not implemented.  */
       return;
 
     case 3: /* android.R.id.cut */



reply via email to

[Prev in Thread] Current Thread [Next in Thread]