mirror of
https://github.com/fankes/termux-app.git
synced 2025-09-07 03:05:18 +08:00
TerminalView: Start support for extra keys
This commit is contained in:
@@ -49,6 +49,13 @@ public final class TerminalView extends View {
|
|||||||
/** Log view key and IME events. */
|
/** Log view key and IME events. */
|
||||||
private static final boolean LOG_KEY_EVENTS = false;
|
private static final boolean LOG_KEY_EVENTS = false;
|
||||||
|
|
||||||
|
public static interface KeyboardModifiers {
|
||||||
|
public boolean readControlButton();
|
||||||
|
public boolean readAltButton();
|
||||||
|
}
|
||||||
|
|
||||||
|
public KeyboardModifiers mModifiers;
|
||||||
|
|
||||||
/** The currently displayed terminal session, whose emulator is {@link #mEmulator}. */
|
/** The currently displayed terminal session, whose emulator is {@link #mEmulator}. */
|
||||||
TerminalSession mTermSession;
|
TerminalSession mTermSession;
|
||||||
/** Our terminal emulator whose session is {@link #mTermSession}. */
|
/** Our terminal emulator whose session is {@link #mTermSession}. */
|
||||||
@@ -601,8 +608,15 @@ public final class TerminalView extends View {
|
|||||||
+ leftAltDownFromEvent + ")");
|
+ leftAltDownFromEvent + ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean controlDown = controlDownFromEvent || mVirtualControlKeyDown;
|
||||||
|
boolean altDown = leftAltDownFromEvent;
|
||||||
|
if (mModifiers != null) {
|
||||||
|
if (mModifiers.readControlButton()) controlDown = true;
|
||||||
|
if (mModifiers.readAltButton()) altDown = true;
|
||||||
|
}
|
||||||
|
|
||||||
int resultingKeyCode = -1; // Set if virtual key causes this to be translated to key event.
|
int resultingKeyCode = -1; // Set if virtual key causes this to be translated to key event.
|
||||||
if (controlDownFromEvent || mVirtualControlKeyDown) {
|
if (controlDown) {
|
||||||
if (codePoint >= 'a' && codePoint <= 'z') {
|
if (codePoint >= 'a' && codePoint <= 'z') {
|
||||||
codePoint = codePoint - 'a' + 1;
|
codePoint = codePoint - 'a' + 1;
|
||||||
} else if (codePoint >= 'A' && codePoint <= 'Z') {
|
} else if (codePoint >= 'A' && codePoint <= 'Z') {
|
||||||
@@ -666,7 +680,7 @@ public final class TerminalView extends View {
|
|||||||
case 'f': // alf+f, jumping forward in readline.
|
case 'f': // alf+f, jumping forward in readline.
|
||||||
case 'x': // alt+x, common in emacs.
|
case 'x': // alt+x, common in emacs.
|
||||||
codePoint = lowerCase;
|
codePoint = lowerCase;
|
||||||
leftAltDownFromEvent = true;
|
altDown = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Volume control.
|
// Volume control.
|
||||||
@@ -698,7 +712,7 @@ public final class TerminalView extends View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If left alt, send escape before the code point to make e.g. Alt+B and Alt+F work in readline:
|
// If left alt, send escape before the code point to make e.g. Alt+B and Alt+F work in readline:
|
||||||
mTermSession.writeCodePoint(leftAltDownFromEvent, codePoint);
|
mTermSession.writeCodePoint(altDown, codePoint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -770,7 +784,7 @@ public final class TerminalView extends View {
|
|||||||
TerminalColors.COLOR_SCHEME.updateWith(props);
|
TerminalColors.COLOR_SCHEME.updateWith(props);
|
||||||
if (mEmulator != null) mEmulator.mColors.reset();
|
if (mEmulator != null) mEmulator.mColors.reset();
|
||||||
|
|
||||||
final Typeface newTypeface = fontFile.exists() ? Typeface.createFromFile(fontFile) : Typeface.MONOSPACE;
|
final Typeface newTypeface = (fontFile.exists() && fontFile.length() > 0) ? Typeface.createFromFile(fontFile) : Typeface.MONOSPACE;
|
||||||
mRenderer = new TerminalRenderer(mRenderer.mTextSize, newTypeface);
|
mRenderer = new TerminalRenderer(mRenderer.mTextSize, newTypeface);
|
||||||
updateSize();
|
updateSize();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user