1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-29 00:31:01 -08:00

Update Android port

* java/org/gnu/emacs/EmacsInputConnection.java
(EmacsInputConnection, beginBatchEdit, reset, endBatchEdit):
Keep track of the number of batch edits and return an
appropriate value.
(takeSnapshot): Implement function.
* java/org/gnu/emacs/EmacsNative.java (takeSnapshot): New
function.
* java/org/gnu/emacs/EmacsService.java (resetIC): Improve
debugging output.
* java/org/gnu/emacs/EmacsView.java (onCreateInputConnection):
Call `reset' to clear the UI side batch edit count.
* src/androidterm.c (struct
android_get_surrounding_text_context): New fields
`conversion_start' and `conversion_end'.
(android_get_surrounding_text): Return the conversion region.
(android_get_surrounding_text_internal, NATIVE_NAME): Factor out
`getSurroundingText'.
(takeSnapshot): New function.
This commit is contained in:
Po Lu 2023-06-15 12:36:50 +08:00
parent ca120044ac
commit 363e293cc9
5 changed files with 203 additions and 26 deletions

View file

@ -50,6 +50,11 @@ public final class EmacsInputConnection implements InputConnection
/* The handle ID associated with that view's window. */
private short windowHandle;
/* Number of batch edits currently underway. Used to avoid
synchronizing with the Emacs thread after each
`endBatchEdit'. */
private int batchEditCount;
/* Whether or not to synchronize and call `updateIC' with the
selection position after committing text.
@ -110,6 +115,10 @@ public final class EmacsInputConnection implements InputConnection
Log.d (TAG, "beginBatchEdit");
EmacsNative.beginBatchEdit (windowHandle);
/* Keep a record of the number of outstanding batch edits here as
well. */
batchEditCount++;
return true;
}
@ -125,7 +134,14 @@ public final class EmacsInputConnection implements InputConnection
Log.d (TAG, "endBatchEdit");
EmacsNative.endBatchEdit (windowHandle);
return true;
/* Subtract one from the UI thread record of the number of batch
edits currently under way. */
if (batchEditCount > 0)
batchEditCount -= 1;
return batchEditCount > 0;
}
public boolean
@ -584,6 +600,42 @@ public final class EmacsInputConnection implements InputConnection
return text;
}
@Override
public TextSnapshot
takeSnapshot ()
{
TextSnapshot snapshot;
/* Return if the input connection is out of date. */
if (view.icSerial < view.icGeneration)
return null;
snapshot = EmacsNative.takeSnapshot (windowHandle);
if (EmacsService.DEBUG_IC)
Log.d (TAG, ("takeSnapshot: "
+ snapshot.getSurroundingText ().getText ()
+ " @ " + snapshot.getCompositionEnd ()
+ ", " + snapshot.getCompositionStart ()));
return snapshot;
}
@Override
public void
closeConnection ()
{
batchEditCount = 0;
}
public void
reset ()
{
batchEditCount = 0;
}
/* Override functions which are not implemented. */
@ -594,13 +646,6 @@ public final class EmacsInputConnection implements InputConnection
return null;
}
@Override
public void
closeConnection ()
{
}
@Override
public boolean
commitContent (InputContentInfo inputContentInfo, int flags,
@ -616,13 +661,6 @@ public final class EmacsInputConnection implements InputConnection
return false;
}
@Override
public TextSnapshot
takeSnapshot ()
{
return null;
}
@Override
public boolean
clearMetaKeyStates (int states)