From: Kevin Lamonte Date: Fri, 25 Aug 2017 20:42:46 +0000 (-0400) Subject: Diambiguate ^H from backspace X-Git-Tag: fanfix-3.0.1^2~220 X-Git-Url: https://git.nikiroo.be/?a=commitdiff_plain;h=be9987235887cb73637b91ab6921158ecaef9d95;p=fanfix.git Diambiguate ^H from backspace --- diff --git a/src/jexer/backend/SwingTerminal.java b/src/jexer/backend/SwingTerminal.java index b20d448..a980638 100644 --- a/src/jexer/backend/SwingTerminal.java +++ b/src/jexer/backend/SwingTerminal.java @@ -1489,8 +1489,7 @@ public final class SwingTerminal extends LogicalScreen alt, ctrl, shift); break; case KeyEvent.VK_BACK_SPACE: - // Special case: return it as kbBackspace (Ctrl-H) - keypress = new TKeypress(false, 0, 'H', false, true, false); + keypress = kbBackspace; break; default: // Unsupported, ignore @@ -1501,7 +1500,15 @@ public final class SwingTerminal extends LogicalScreen if (keypress == null) { switch (ch) { case 0x08: - keypress = kbBackspace; + // Disambiguate ^H from Backspace. + if (KeyEvent.getKeyText(key.getKeyCode()).equals("H")) { + // This is ^H. + keypress = kbBackspace; + } else { + // We are emulating Xterm here, where the backspace key + // on the keyboard returns ^?. + keypress = kbBackspaceDel; + } break; case 0x0A: keypress = kbEnter; diff --git a/src/jexer/tterminal/ECMA48.java b/src/jexer/tterminal/ECMA48.java index 3702b8b..caa295a 100644 --- a/src/jexer/tterminal/ECMA48.java +++ b/src/jexer/tterminal/ECMA48.java @@ -1385,7 +1385,7 @@ public class ECMA48 implements Runnable { return sb.toString(); } - if (keypress.equals(kbBackspace)) { + if (keypress.equals(kbBackspaceDel)) { switch (type) { case VT100: return "\010";