diff options
| author | Po Lu | 2023-10-05 14:23:20 +0800 |
|---|---|---|
| committer | Po Lu | 2023-10-05 14:23:20 +0800 |
| commit | 123b77436e187c6254d4585d08135a44077528d1 (patch) | |
| tree | 5257a4dbb4d5dc5d1446a58cec224903494bbbb5 /java | |
| parent | 253f1aff1ab00e9794f3cfcf50e86e335f411242 (diff) | |
| download | emacs-123b77436e187c6254d4585d08135a44077528d1.tar.gz emacs-123b77436e187c6254d4585d08135a44077528d1.zip | |
Introduce an input method callback required by Android 34
* java/org/gnu/emacs/EmacsInputConnection.java (replaceText):
New function.
* java/org/gnu/emacs/EmacsNative.java (replaceText): Declare
native function.
* src/androidgui.h (enum android_ime_operation): New operation
ANDROID_IME_REPLACE_TEXT.
* src/androidterm.c (android_handle_ime_event): Decode text when
encountering an ANDROID_IME_REPLACE_TEXT operation. Return if
decoding overflowed rather than presenting Qnil to textconv
functions.
(replaceText): New JNI function.
* src/frame.h (enum text_conversion_operation): New operation
TEXTCONV_REPLACE_TEXT.
* src/textconv.c (really_commit_text): Move point to start if
the composing region is set.
(really_replace_text): New function.
(handle_pending_conversion_events_1) <TEXTCONV_REPLACE_TEXT>:
New case.
(replace_text): New function.
* src/textconv.h: Update prototypes.
Diffstat (limited to 'java')
| -rw-r--r-- | java/org/gnu/emacs/EmacsInputConnection.java | 15 | ||||
| -rw-r--r-- | java/org/gnu/emacs/EmacsNative.java | 4 |
2 files changed, 19 insertions, 0 deletions
diff --git a/java/org/gnu/emacs/EmacsInputConnection.java b/java/org/gnu/emacs/EmacsInputConnection.java index c3764a7b29f..7f6331205cb 100644 --- a/java/org/gnu/emacs/EmacsInputConnection.java +++ b/java/org/gnu/emacs/EmacsInputConnection.java | |||
| @@ -628,6 +628,21 @@ public final class EmacsInputConnection implements InputConnection | |||
| 628 | batchEditCount = 0; | 628 | batchEditCount = 0; |
| 629 | } | 629 | } |
| 630 | 630 | ||
| 631 | @Override | ||
| 632 | public boolean | ||
| 633 | replaceText (int start, int end, CharSequence text, | ||
| 634 | int newCursorPosition, TextAttribute attributes) | ||
| 635 | { | ||
| 636 | if (EmacsService.DEBUG_IC) | ||
| 637 | Log.d (TAG, ("replaceText: " + text + ":: " + start + "," | ||
| 638 | + end + "," + newCursorPosition)); | ||
| 639 | |||
| 640 | EmacsNative.replaceText (windowHandle, start, end, | ||
| 641 | text.toString (), newCursorPosition, | ||
| 642 | attributes); | ||
| 643 | return true; | ||
| 644 | } | ||
| 645 | |||
| 631 | 646 | ||
| 632 | 647 | ||
| 633 | public void | 648 | public void |
diff --git a/java/org/gnu/emacs/EmacsNative.java b/java/org/gnu/emacs/EmacsNative.java index a4b45aafbc1..d8524d92130 100644 --- a/java/org/gnu/emacs/EmacsNative.java +++ b/java/org/gnu/emacs/EmacsNative.java | |||
| @@ -26,6 +26,7 @@ import android.graphics.Bitmap; | |||
| 26 | import android.view.inputmethod.ExtractedText; | 26 | import android.view.inputmethod.ExtractedText; |
| 27 | import android.view.inputmethod.ExtractedTextRequest; | 27 | import android.view.inputmethod.ExtractedTextRequest; |
| 28 | import android.view.inputmethod.SurroundingText; | 28 | import android.view.inputmethod.SurroundingText; |
| 29 | import android.view.inputmethod.TextAttribute; | ||
| 29 | import android.view.inputmethod.TextSnapshot; | 30 | import android.view.inputmethod.TextSnapshot; |
| 30 | 31 | ||
| 31 | public final class EmacsNative | 32 | public final class EmacsNative |
| @@ -219,6 +220,9 @@ public final class EmacsNative | |||
| 219 | int leftLength, | 220 | int leftLength, |
| 220 | int rightLength); | 221 | int rightLength); |
| 221 | public static native void finishComposingText (short window); | 222 | public static native void finishComposingText (short window); |
| 223 | public static native void replaceText (short window, int start, int end, | ||
| 224 | String text, int newCursorPosition, | ||
| 225 | TextAttribute attributes); | ||
| 222 | public static native String getSelectedText (short window, int flags); | 226 | public static native String getSelectedText (short window, int flags); |
| 223 | public static native String getTextAfterCursor (short window, int length, | 227 | public static native String getTextAfterCursor (short window, int length, |
| 224 | int flags); | 228 | int flags); |