mirror of
https://github.com/fankes/termux-app.git
synced 2025-09-06 02:35:19 +08:00
Changed: Do not modify code points for virtual or soft keyboard events
Closes #2799
This commit is contained in:
@@ -83,6 +83,12 @@ public final class TerminalView extends View {
|
||||
|
||||
private final boolean mAccessibilityEnabled;
|
||||
|
||||
/** The {@link KeyEvent} is generated from a virtual keyboard, like manually with the {@link KeyEvent#KeyEvent(int, int)} constructor. */
|
||||
public final static int KEY_EVENT_SOURCE_VIRTUAL_KEYBOARD = KeyCharacterMap.VIRTUAL_KEYBOARD; // -1
|
||||
|
||||
/** The {@link KeyEvent} is generated from a non-physical device, like if 0 value is returned by {@link KeyEvent#getDeviceId()}. */
|
||||
public final static int KEY_EVENT_SOURCE_SOFT_KEYBOARD = 0;
|
||||
|
||||
private static final String LOG_TAG = "TerminalView";
|
||||
|
||||
public TerminalView(Context context, AttributeSet attributes) { // NO_UCD (unused code)
|
||||
@@ -380,7 +386,7 @@ public final class TerminalView extends View {
|
||||
}
|
||||
}
|
||||
|
||||
inputCodePoint(codePoint, ctrlHeld, false);
|
||||
inputCodePoint(KEY_EVENT_SOURCE_SOFT_KEYBOARD, codePoint, ctrlHeld, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -755,7 +761,7 @@ public final class TerminalView extends View {
|
||||
if ((result & KeyCharacterMap.COMBINING_ACCENT) != 0) {
|
||||
// If entered combining accent previously, write it out:
|
||||
if (mCombiningAccent != 0)
|
||||
inputCodePoint(mCombiningAccent, controlDown, leftAltDown);
|
||||
inputCodePoint(event.getDeviceId(), mCombiningAccent, controlDown, leftAltDown);
|
||||
mCombiningAccent = result & KeyCharacterMap.COMBINING_ACCENT_MASK;
|
||||
} else {
|
||||
if (mCombiningAccent != 0) {
|
||||
@@ -763,7 +769,7 @@ public final class TerminalView extends View {
|
||||
if (combinedChar > 0) result = combinedChar;
|
||||
mCombiningAccent = 0;
|
||||
}
|
||||
inputCodePoint(result, controlDown, leftAltDown);
|
||||
inputCodePoint(event.getDeviceId(), result, controlDown, leftAltDown);
|
||||
}
|
||||
|
||||
if (mCombiningAccent != oldCombiningAccent) invalidate();
|
||||
@@ -771,9 +777,9 @@ public final class TerminalView extends View {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void inputCodePoint(int codePoint, boolean controlDownFromEvent, boolean leftAltDownFromEvent) {
|
||||
public void inputCodePoint(int eventSource, int codePoint, boolean controlDownFromEvent, boolean leftAltDownFromEvent) {
|
||||
if (TERMINAL_VIEW_KEY_LOGGING_ENABLED) {
|
||||
mClient.logInfo(LOG_TAG, "inputCodePoint(codePoint=" + codePoint + ", controlDownFromEvent=" + controlDownFromEvent + ", leftAltDownFromEvent="
|
||||
mClient.logInfo(LOG_TAG, "inputCodePoint(eventSource=" + eventSource + ", codePoint=" + codePoint + ", controlDownFromEvent=" + controlDownFromEvent + ", leftAltDownFromEvent="
|
||||
+ leftAltDownFromEvent + ")");
|
||||
}
|
||||
|
||||
@@ -813,6 +819,8 @@ public final class TerminalView extends View {
|
||||
}
|
||||
|
||||
if (codePoint > -1) {
|
||||
// If not virtual or soft keyboard.
|
||||
if (eventSource > KEY_EVENT_SOURCE_SOFT_KEYBOARD) {
|
||||
// Work around bluetooth keyboards sending funny unicode characters instead
|
||||
// of the more normal ones from ASCII that terminal programs expect - the
|
||||
// desire to input the original characters should be low.
|
||||
@@ -827,6 +835,7 @@ public final class TerminalView extends View {
|
||||
codePoint = 0x005E; // CIRCUMFLEX ACCENT (^).
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// If left alt, send escape before the code point to make e.g. Alt+B and Alt+F work in readline:
|
||||
mTermSession.writeCodePoint(altDown, codePoint);
|
||||
|
@@ -67,7 +67,7 @@ public class TerminalExtraKeys implements ExtraKeysView.IExtraKeysView {
|
||||
// not a control char
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
key.codePoints().forEach(codePoint -> {
|
||||
mTerminalView.inputCodePoint(codePoint, ctrlDown, altDown);
|
||||
mTerminalView.inputCodePoint(TerminalView.KEY_EVENT_SOURCE_VIRTUAL_KEYBOARD, codePoint, ctrlDown, altDown);
|
||||
});
|
||||
} else {
|
||||
TerminalSession session = mTerminalView.getCurrentSession();
|
||||
|
Reference in New Issue
Block a user