aboutsummaryrefslogtreecommitdiffstats
path: root/java/org/gnu
diff options
context:
space:
mode:
authorPo Lu2023-03-06 15:30:29 +0800
committerPo Lu2023-03-06 15:30:29 +0800
commitc0a6f14f4a5069c28b7c90247546f1c5889a6d21 (patch)
tree6cae54c0ccfea1b4495c8faf9bad1f1995b81423 /java/org/gnu
parent31883b8de119ea77f68332b842268b42063b1807 (diff)
downloademacs-c0a6f14f4a5069c28b7c90247546f1c5889a6d21.tar.gz
emacs-c0a6f14f4a5069c28b7c90247546f1c5889a6d21.zip
Update Android port
* java/org/gnu/emacs/EmacsNative.java (EmacsNative): New function requestSelectionUpdate. * java/org/gnu/emacs/EmacsView.java (onCreateInputConnection): Call it instead of losing if getting the current selection fails. * src/android-asset.h (AAsset_seek): Define stub. * src/android.c (android_open): Take mode_t. (android_open_asset, android_close_asset, android_asset_read_quit) (android_asset_read, android_asset_lseek, android_asset_fstat): New functions. * src/android.h (struct android_fd_or_asset): Update prototypes. * src/androidgui.h (enum android_ime_operation): Add new operation to update the selection position. * src/androidterm.c (android_handle_ime_event): Handle new operation. (requestSelectionUpdate): New function. * src/fileio.c (close_file_unwind_emacs_fd): New function. (Fcopy_file, union read_non_regular, read_non_regular) (Finsert_file_contents): Use optimized codepath to insert Android asset files. * src/frame.h (enum text_conversion_operation): New operation. * src/textconv.c (really_request_point_update) (handle_pending_conversion_events_1, request_point_update): New functions. * src/textconv.h: Update prototypes.
Diffstat (limited to 'java/org/gnu')
-rw-r--r--java/org/gnu/emacs/EmacsNative.java1
-rw-r--r--java/org/gnu/emacs/EmacsView.java29
2 files changed, 23 insertions, 7 deletions
diff --git a/java/org/gnu/emacs/EmacsNative.java b/java/org/gnu/emacs/EmacsNative.java
index 38370d60727..8e626b9534b 100644
--- a/java/org/gnu/emacs/EmacsNative.java
+++ b/java/org/gnu/emacs/EmacsNative.java
@@ -203,6 +203,7 @@ public final class EmacsNative
203 public static native ExtractedText getExtractedText (short window, 203 public static native ExtractedText getExtractedText (short window,
204 ExtractedTextRequest req, 204 ExtractedTextRequest req,
205 int flags); 205 int flags);
206 public static native void requestSelectionUpdate (short window);
206 207
207 208
208 /* Return the current value of the selection, or -1 upon 209 /* Return the current value of the selection, or -1 upon
diff --git a/java/org/gnu/emacs/EmacsView.java b/java/org/gnu/emacs/EmacsView.java
index f751eaaa3e4..90a2c912a5a 100644
--- a/java/org/gnu/emacs/EmacsView.java
+++ b/java/org/gnu/emacs/EmacsView.java
@@ -573,20 +573,35 @@ public final class EmacsView extends ViewGroup
573 /* Set a reasonable inputType. */ 573 /* Set a reasonable inputType. */
574 info.inputType = InputType.TYPE_CLASS_TEXT; 574 info.inputType = InputType.TYPE_CLASS_TEXT;
575 575
576 /* Obtain the current position of point and set it as the
577 selection. */
578 selection = EmacsNative.getSelection (window.handle);
579
580 Log.d (TAG, "onCreateInputConnection: current selection is: " + selection);
581
582 /* If this fails or ANDROID_IC_MODE_NULL was requested, then don't 576 /* If this fails or ANDROID_IC_MODE_NULL was requested, then don't
583 initialize the input connection. */ 577 initialize the input connection. */
584 if (mode == EmacsService.IC_MODE_NULL || selection == null) 578
579 if (mode == EmacsService.IC_MODE_NULL)
585 { 580 {
586 info.inputType = InputType.TYPE_NULL; 581 info.inputType = InputType.TYPE_NULL;
587 return null; 582 return null;
588 } 583 }
589 584
585 /* Obtain the current position of point and set it as the
586 selection. */
587 selection = EmacsNative.getSelection (window.handle);
588
589 if (selection != null)
590 Log.d (TAG, "onCreateInputConnection: current selection is: "
591 + selection[0] + ", by " + selection[1]);
592 else
593 {
594 Log.d (TAG, "onCreateInputConnection: current selection could"
595 + " not be retrieved.");
596
597 /* If the selection could not be obtained, return 0 by 0.
598 However, ask for the selection position to be updated as
599 soon as possible. */
600
601 selection = new int[] { 0, 0, };
602 EmacsNative.requestSelectionUpdate (window.handle);
603 }
604
590 if (mode == EmacsService.IC_MODE_ACTION) 605 if (mode == EmacsService.IC_MODE_ACTION)
591 info.imeOptions |= EditorInfo.IME_ACTION_DONE; 606 info.imeOptions |= EditorInfo.IME_ACTION_DONE;
592 607