mirror of
https://github.com/fankes/termux-app.git
synced 2025-09-06 10:45:23 +08:00
Try to handle Samsung keyboard better
The stock Samsung keyboard with 'Auto check spelling' enabled may send multiple backspaces. Note that this auto-correction of spelling will not work good in general with a terminal, so should be disabled (or another keyboard used) when using Termux.
This commit is contained in:
@@ -270,16 +270,15 @@ public final class TerminalView extends View {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean deleteSurroundingText(int leftLength, int rightLength) {
|
public boolean deleteSurroundingText(int leftLength, int rightLength) {
|
||||||
if (LOG_KEY_EVENTS)
|
if (LOG_KEY_EVENTS) {
|
||||||
Log.i(EmulatorDebug.LOG_TAG, "IME: deleteSurroundingText(" + leftLength + ", " + rightLength + ")");
|
Log.i(EmulatorDebug.LOG_TAG, "IME: deleteSurroundingText(" + leftLength + ", " + rightLength + ")");
|
||||||
// If leftLength=2 it may be due to a UTF-16 surrogate pair. So we cannot send
|
}
|
||||||
// multiple key events for that. Let's just hope that keyboards don't use
|
// The stock Samsung keyboard with 'Auto check spelling' enabled sends leftLength > 1.
|
||||||
// leftLength > 1 for other purposes (such as holding down backspace for repeat).
|
KeyEvent deleteKey = new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DEL);
|
||||||
sendKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DEL));
|
for (int i = 0; i < leftLength; i++) sendKeyEvent(deleteKey);
|
||||||
return super.deleteSurroundingText(leftLength, rightLength);
|
return super.deleteSurroundingText(leftLength, rightLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void sendTextToTerminal(CharSequence text) {
|
void sendTextToTerminal(CharSequence text) {
|
||||||
final int textLengthInChars = text.length();
|
final int textLengthInChars = text.length();
|
||||||
for (int i = 0; i < textLengthInChars; i++) {
|
for (int i = 0; i < textLengthInChars; i++) {
|
||||||
|
Reference in New Issue
Block a user