From 1beb9d15f9119e3e70eee5143e0e6c20112d991b Mon Sep 17 00:00:00 2001 From: Anton Leherbauer Date: Tue, 3 Mar 2015 14:34:30 +0100 Subject: [PATCH] Bug 205765 - [terminal] some emacs keys do not work correctly Ctrl-/ and Backspace Change-Id: Ib1af6d41ec0ea9512b289ee78ed9c93bc522d8ee Signed-off-by: Anton Leherbauer --- .../terminal/emulator/VT100Emulator.java | 11 ++++- .../emulator/VT100TerminalControl.java | 49 ++++++++++++------- 2 files changed, 40 insertions(+), 20 deletions(-) diff --git a/plugins/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java b/plugins/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java index 594bacb94f2..7c201c7e8a2 100644 --- a/plugins/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java +++ b/plugins/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/emulator/VT100Emulator.java @@ -152,7 +152,7 @@ public class VT100Emulator implements ControlListener { ansiParameters[i] = new StringBuffer(); } setInputStreamReader(reader); - if(TerminalPlugin.isOptionEnabled(Logger.TRACE_DEBUG_LOG_VT100BACKEND)) //$NON-NLS-1$ + if(TerminalPlugin.isOptionEnabled(Logger.TRACE_DEBUG_LOG_VT100BACKEND)) text=new VT100BackendTraceDecorator(new VT100EmulatorBackend(data),System.out); else text=new VT100EmulatorBackend(data); @@ -450,6 +450,9 @@ public class VT100Emulator implements ControlListener { text.eraseAll(); text.setCursor(0, 0); text.setStyle(text.getDefaultStyle()); + text.setScrollRegion(-1, -1); + text.setInsertMode(false); + terminal.enableApplicationCursorKeys(false); } /** * This method is called when we have parsed an OS Command escape sequence. @@ -1039,6 +1042,9 @@ public class VT100Emulator implements ControlListener { terminal.enableApplicationCursorKeys(true); break; case 47: + case 1047: + case 1048: + case 1049: // Use Alternate Screen Buffer (ignored). break; default: @@ -1055,6 +1061,9 @@ public class VT100Emulator implements ControlListener { terminal.enableApplicationCursorKeys(false); break; case 47: + case 1047: + case 1048: + case 1049: // Use Normal Screen Buffer (ignored, but reset scroll region). text.setScrollRegion(-1, -1); break; diff --git a/plugins/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java b/plugins/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java index 523779630dd..d827b3c3210 100644 --- a/plugins/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java +++ b/plugins/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java @@ -944,11 +944,15 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC } // Manage the Del key - if (event.keyCode == 0x000007f) - { + if (event.keyCode == 0x000007f) { sendString("\u001b[3~"); //$NON-NLS-1$ return; } + + if (event.keyCode == SWT.BS) { + sendChar('\u007f', altKeyPressed); + return; + } // If the event character is NUL ('\u0000'), then a special key was pressed // (e.g., PageUp, PageDown, an arrow key, a function key, Shift, Alt, @@ -1032,62 +1036,62 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC case 0x100000a: // F1 key. if (!anyModifierPressed) - escSeq = "\u001b[M"; //$NON-NLS-1$ + escSeq = "\u001bOP"; //$NON-NLS-1$ break; case 0x100000b: // F2 key. if (!anyModifierPressed) - escSeq = "\u001b[N"; //$NON-NLS-1$ + escSeq = "\u001bOQ"; //$NON-NLS-1$ break; case 0x100000c: // F3 key. if (!anyModifierPressed) - escSeq = "\u001b[O"; //$NON-NLS-1$ + escSeq = "\u001bOR"; //$NON-NLS-1$ break; case 0x100000d: // F4 key. if (!anyModifierPressed) - escSeq = "\u001b[P"; //$NON-NLS-1$ + escSeq = "\u001bOS"; //$NON-NLS-1$ break; case 0x100000e: // F5 key. if (!anyModifierPressed) - escSeq = "\u001b[Q"; //$NON-NLS-1$ + escSeq = "\u001b[15~"; //$NON-NLS-1$ break; case 0x100000f: // F6 key. if (!anyModifierPressed) - escSeq = "\u001b[R"; //$NON-NLS-1$ + escSeq = "\u001b[17~"; //$NON-NLS-1$ break; case 0x1000010: // F7 key. if (!anyModifierPressed) - escSeq = "\u001b[S"; //$NON-NLS-1$ + escSeq = "\u001b[18~"; //$NON-NLS-1$ break; case 0x1000011: // F8 key. if (!anyModifierPressed) - escSeq = "\u001b[T"; //$NON-NLS-1$ + escSeq = "\u001b[19~"; //$NON-NLS-1$ break; case 0x1000012: // F9 key. if (!anyModifierPressed) - escSeq = "\u001b[U"; //$NON-NLS-1$ + escSeq = "\u001b[20~"; //$NON-NLS-1$ break; case 0x1000013: // F10 key. if (!anyModifierPressed) - escSeq = "\u001b[V"; //$NON-NLS-1$ + escSeq = "\u001b[21~"; //$NON-NLS-1$ break; case 0x1000014: // F11 key. if (!anyModifierPressed) - escSeq = "\u001b[W"; //$NON-NLS-1$ + escSeq = "\u001b[23~"; //$NON-NLS-1$ break; case 0x1000015: // F12 key. if (!anyModifierPressed) - escSeq = "\u001b[X"; //$NON-NLS-1$ + escSeq = "\u001b[24~"; //$NON-NLS-1$ break; default: @@ -1111,11 +1115,18 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC Logger.log("stateMask = " + event.stateMask); //$NON-NLS-1$ - if (onlyCtrlKeyPressed && character == ' ') { - // Send a NUL character -- many terminal emulators send NUL when - // Control-Space is pressed. This is used to set the mark in Emacs. - - character = '\u0000'; + if (onlyCtrlKeyPressed) { + switch (character) { + case ' ': + // Send a NUL character -- many terminal emulators send NUL when + // Control-Space is pressed. This is used to set the mark in Emacs. + character = '\u0000'; + break; + case '/': + // Ctrl+/ is undo in emacs + character = '\u001f'; + break; + } } //TODO: At this point, Ctrl+M sends the same as Ctrl+Shift+M .