Fix keypad to match xterm
authorKevin Lamonte <kevin.lamonte@gmail.com>
Tue, 15 Aug 2017 16:59:28 +0000 (12:59 -0400)
committerKevin Lamonte <kevin.lamonte@gmail.com>
Tue, 15 Aug 2017 16:59:28 +0000 (12:59 -0400)
src/jexer/tterminal/ECMA48.java

index 03b0543ba75726f279cb9054cd2d9b488f9443c4..69a9da12191dc65fad624177c93935488489c9a6 100644 (file)
@@ -28,6 +28,7 @@
  */
 package jexer.tterminal;
 
+import java.io.BufferedOutputStream;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.IOException;
@@ -905,11 +906,12 @@ public class ECMA48 implements Runnable {
         }
         if (type == DeviceType.XTERM) {
             this.input    = new InputStreamReader(this.inputStream, "UTF-8");
-            this.output   = new OutputStreamWriter(outputStream, "UTF-8");
+            this.output   = new OutputStreamWriter(new
+                BufferedOutputStream(outputStream), "UTF-8");
             this.outputStream = null;
         } else {
             this.output       = null;
-            this.outputStream = outputStream;
+            this.outputStream = new BufferedOutputStream(outputStream);
         }
 
         reset();
@@ -1796,20 +1798,9 @@ public class ECMA48 implements Runnable {
         if (keypress.equalsWithoutModifiers(kbPgUp)) {
             switch (type) {
             case XTERM:
-                switch (arrowKeyMode) {
-                case ANSI:
-                    return xtermBuildKeySequence("\033[", '5', '~',
-                        keypress.isCtrl(), keypress.isAlt(),
-                        keypress.isShift());
-                case VT52:
-                    return xtermBuildKeySequence("\033", '5', '~',
-                        keypress.isCtrl(), keypress.isAlt(),
-                        keypress.isShift());
-                case VT100:
-                    return xtermBuildKeySequence("\033O", '5', '~',
-                        keypress.isCtrl(), keypress.isAlt(),
-                        keypress.isShift());
-                }
+                return xtermBuildKeySequence("\033[", '5', '~',
+                    keypress.isCtrl(), keypress.isAlt(),
+                    keypress.isShift());
             default:
                 return "\033[5~";
             }
@@ -1818,20 +1809,9 @@ public class ECMA48 implements Runnable {
         if (keypress.equalsWithoutModifiers(kbPgDn)) {
             switch (type) {
             case XTERM:
-                switch (arrowKeyMode) {
-                case ANSI:
-                    return xtermBuildKeySequence("\033[", '6', '~',
-                        keypress.isCtrl(), keypress.isAlt(),
-                        keypress.isShift());
-                case VT52:
-                    return xtermBuildKeySequence("\033", '6', '~',
-                        keypress.isCtrl(), keypress.isAlt(),
-                        keypress.isShift());
-                case VT100:
-                    return xtermBuildKeySequence("\033O", '6', '~',
-                        keypress.isCtrl(), keypress.isAlt(),
-                        keypress.isShift());
-                }
+                return xtermBuildKeySequence("\033[", '6', '~',
+                    keypress.isCtrl(), keypress.isAlt(),
+                    keypress.isShift());
             default:
                 return "\033[6~";
             }
@@ -1840,20 +1820,9 @@ public class ECMA48 implements Runnable {
         if (keypress.equalsWithoutModifiers(kbIns)) {
             switch (type) {
             case XTERM:
-                switch (arrowKeyMode) {
-                case ANSI:
-                    return xtermBuildKeySequence("\033[", '2', '~',
-                        keypress.isCtrl(), keypress.isAlt(),
-                        keypress.isShift());
-                case VT52:
-                    return xtermBuildKeySequence("\033", '2', '~',
-                        keypress.isCtrl(), keypress.isAlt(),
-                        keypress.isShift());
-                case VT100:
-                    return xtermBuildKeySequence("\033O", '2', '~',
-                        keypress.isCtrl(), keypress.isAlt(),
-                        keypress.isShift());
-                }
+                return xtermBuildKeySequence("\033[", '2', '~',
+                    keypress.isCtrl(), keypress.isAlt(),
+                    keypress.isShift());
             default:
                 return "\033[2~";
             }
@@ -1862,20 +1831,9 @@ public class ECMA48 implements Runnable {
         if (keypress.equalsWithoutModifiers(kbDel)) {
             switch (type) {
             case XTERM:
-                switch (arrowKeyMode) {
-                case ANSI:
-                    return xtermBuildKeySequence("\033[", '3', '~',
-                        keypress.isCtrl(), keypress.isAlt(),
-                        keypress.isShift());
-                case VT52:
-                    return xtermBuildKeySequence("\033", '3', '~',
-                        keypress.isCtrl(), keypress.isAlt(),
-                        keypress.isShift());
-                case VT100:
-                    return xtermBuildKeySequence("\033O", '3', '~',
-                        keypress.isCtrl(), keypress.isAlt(),
-                        keypress.isShift());
-                }
+                return xtermBuildKeySequence("\033[", '3', '~',
+                    keypress.isCtrl(), keypress.isAlt(),
+                    keypress.isShift());
             default:
                 // Delete sends real delete for VTxxx
                 return "\177";