Diambiguate ^H from backspace
authorKevin Lamonte <kevin.lamonte@gmail.com>
Fri, 25 Aug 2017 20:42:46 +0000 (16:42 -0400)
committerKevin Lamonte <kevin.lamonte@gmail.com>
Fri, 25 Aug 2017 20:42:46 +0000 (16:42 -0400)
src/jexer/backend/SwingTerminal.java
src/jexer/tterminal/ECMA48.java

index b20d448a3db2cbf534dabd3960144b40d3642469..a98063867e75479c2b18d91e2872fb2fdadec4a5 100644 (file)
@@ -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;
index 3702b8bc5bc64d3c9e9e454dbdb8179e464aafc0..caa295ad47776ce242557359407ab18b2d7dacf5 100644 (file)
@@ -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";