From: Po Lu Date: Wed, 22 Feb 2023 06:59:27 +0000 (+0800) Subject: Update Android port X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=1e6f957c0dbb7e4a5e04c20fcb797be1d98df3d8;p=emacs.git Update Android port * doc/emacs/input.texi (On-Screen Keyboards): Document changes to text conversion. * java/org/gnu/emacs/EmacsInputConnection.java (getExtractedText) (EmacsInputConnection): * src/keyboard.c (read_key_sequence): Disable text conversion after reading prefix key. * src/textconv.c (get_extracted_text): Fix returned value when request length is zero. --- diff --git a/doc/emacs/input.texi b/doc/emacs/input.texi index 37167f5a9e0..dc1acaedfcb 100644 --- a/doc/emacs/input.texi +++ b/doc/emacs/input.texi @@ -132,9 +132,11 @@ Emacs enables these input methods whenever the buffer local value of derivatives of @code{text-mode} and @code{prog-mode}. Text conversion is performed asynchronously whenever Emacs receives -a request to perform the conversion from the input method. After the -conversion completes, a @code{text-conversion} event is sent. -@xref{Misc Events,,, elisp, the Emacs Reference Manual}. +a request to perform the conversion from the input method, and Emacs +is not currently reading a key sequence for which one prefix key has +already been read (@pxref{Keys}.) After the conversion completes, a +@code{text-conversion} event is sent. @xref{Misc Events,,, elisp, the +Emacs Reference Manual}. @vindex text-conversion-face If the input method needs to work on a region of the buffer, then diff --git a/java/org/gnu/emacs/EmacsInputConnection.java b/java/org/gnu/emacs/EmacsInputConnection.java index e2a15894695..834c2226c82 100644 --- a/java/org/gnu/emacs/EmacsInputConnection.java +++ b/java/org/gnu/emacs/EmacsInputConnection.java @@ -207,11 +207,19 @@ public class EmacsInputConnection extends BaseInputConnection public ExtractedText getExtractedText (ExtractedTextRequest request, int flags) { + ExtractedText text; + if (EmacsService.DEBUG_IC) Log.d (TAG, "getExtractedText: " + request + " " + flags); - return EmacsNative.getExtractedText (windowHandle, request, + text = EmacsNative.getExtractedText (windowHandle, request, flags); + + if (EmacsService.DEBUG_IC) + Log.d (TAG, "getExtractedText: " + text.text + " @" + + text.startOffset + ":" + text.selectionStart); + + return text; } @Override @@ -225,6 +233,16 @@ public class EmacsInputConnection extends BaseInputConnection return true; } + @Override + public boolean + sendKeyEvent (KeyEvent key) + { + if (EmacsService.DEBUG_IC) + Log.d (TAG, "sendKeyEvent: " + key); + + return super.sendKeyEvent (key); + } + /* Override functions which are not implemented. */ diff --git a/src/keyboard.c b/src/keyboard.c index 9532eb70f06..69fb8ae2797 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -10053,6 +10053,13 @@ read_key_sequence (Lisp_Object *keybuf, Lisp_Object prompt, /* Gets around Microsoft compiler limitations. */ bool dummyflag = false; +#ifdef HAVE_TEXT_CONVERSION + bool disabled_conversion; + + /* Whether or not text conversion has already been disabled. */ + disabled_conversion = false; +#endif + struct buffer *starting_buffer; /* List of events for which a fake prefix key has been generated. */ @@ -10202,6 +10209,22 @@ read_key_sequence (Lisp_Object *keybuf, Lisp_Object prompt, echo_local_start = echo_length (); keys_local_start = this_command_key_count; +#ifdef HAVE_TEXT_CONVERSION + /* When reading a key sequence while text conversion is in + effect, turn it off after the first character read. This + makes input methods send actual key events instead. + + Make sure only to do this once. */ + + if (!disabled_conversion && t) + { + disable_text_conversion (); + record_unwind_protect_void (resume_text_conversion); + + disabled_conversion = true; + } +#endif + replay_key: /* These are no-ops, unless we throw away a keystroke below and jumped back up to replay_key; in that case, these restore the diff --git a/src/textconv.c b/src/textconv.c index 1ca5f0488f8..4b5f9e01162 100644 --- a/src/textconv.c +++ b/src/textconv.c @@ -1462,6 +1462,9 @@ get_extracted_text (struct frame *f, ptrdiff_t n, /* Figure out the bounds of the text to return. */ if (n != -1) { + /* Make sure n is at least 2. */ + n = max (2, n); + start = PT - n / 2; end = PT + n - n / 2; }