Skip to content

Commit 913c474

Browse files
committed
Input normal ^ even on other unicode char input
Some bluetooth keyboards [1] input U+02C6, the unicode character MODIFIER LETTER CIRCUMFLEX ACCENT instead of the more common ^ (U+005E CIRCUMFLEX ACCENT). Remap it to the common caret since that is what terminal programs expect. [1] https://plus.google.com/100972300636796512022/posts/f7PKpXWesgG
1 parent 657c270 commit 913c474

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

app/src/main/java/com/termux/view/TerminalView.java

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -644,13 +644,20 @@ void inputCodePoint(int codePoint, boolean controlDownFromEvent, boolean leftAlt
644644
if (resultingKeyCode > -1) {
645645
handleKeyCode(resultingKeyCode, 0);
646646
} else {
647-
// The below two workarounds are needed on at least Logitech Keyboard k810 on Samsung Galaxy Tab Pro
648-
// (Android 4.4) with the stock Samsung Keyboard. They should be harmless when not used since the need
649-
// to input the original characters instead of the new ones using the keyboard should be low.
650-
// Rewrite U+02DC 'SMALL TILDE' to U+007E 'TILDE' for ~ to work in shells:
651-
if (codePoint == 0x02DC) codePoint = 0x07E;
652-
// Rewrite U+02CB 'MODIFIER LETTER GRAVE ACCENT' to U+0060 'GRAVE ACCENT' for ` (backticks) to work:
653-
if (codePoint == 0x02CB) codePoint = 0x60;
647+
// Work around bluetooth keyboards sending funny unicode characters instead
648+
// of the more normal ones from ASCII that terminal programs expect - the
649+
// desire to input the original characters should be low.
650+
switch (codePoint) {
651+
case 0x02DC: // SMALL TILDE.
652+
codePoint = 0x007E; // TILDE (~).
653+
break;
654+
case 0x02CB: // MODIFIER LETTER GRAVE ACCENT.
655+
codePoint = 0x0060; // GRAVE ACCENT (`).
656+
break;
657+
case 0x02C6: // MODIFIER LETTER CIRCUMFLEX ACCENT.
658+
codePoint = 0x005E; // CIRCUMFLEX ACCENT (^).
659+
break;
660+
}
654661

655662
// If left alt, send escape before the code point to make e.g. Alt+B and Alt+F work in readline:
656663
mTermSession.writeCodePoint(leftAltDownFromEvent, codePoint);

0 commit comments

Comments
 (0)