From be9987235887cb73637b91ab6921158ecaef9d95 Mon Sep 17 00:00:00 2001 From: Kevin Lamonte Date: Fri, 25 Aug 2017 16:42:46 -0400 Subject: [PATCH] Diambiguate ^H from backspace --- src/jexer/backend/SwingTerminal.java | 13 ++++++++++--- src/jexer/tterminal/ECMA48.java | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) 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"; -- 2.27.0