From 4bc195601c6c8d59a3937645ed7bda68ec415348 Mon Sep 17 00:00:00 2001 From: Kevin Lamonte Date: Tue, 15 Aug 2017 12:59:28 -0400 Subject: [PATCH] Fix keypad to match xterm --- src/jexer/tterminal/ECMA48.java | 74 +++++++-------------------------- 1 file changed, 16 insertions(+), 58 deletions(-) diff --git a/src/jexer/tterminal/ECMA48.java b/src/jexer/tterminal/ECMA48.java index 03b0543b..69a9da12 100644 --- a/src/jexer/tterminal/ECMA48.java +++ b/src/jexer/tterminal/ECMA48.java @@ -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"; -- 2.27.0