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.
This commit is contained in:
Po Lu 2023-02-22 14:59:27 +08:00
parent 8356412d62
commit 1e6f957c0d
4 changed files with 50 additions and 4 deletions

View file

@ -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

View file

@ -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. */

View file

@ -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

View file

@ -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;
}