diff mbox

[edk2,RFC,3/4] accept [3~ as delete for LinuxTerm terminals

Message ID 1431561241-1411-4-git-send-email-roy.franz@linaro.org
State New
Headers show

Commit Message

Roy Franz May 13, 2015, 11:54 p.m. UTC
Accept the VT200 escape code [3~ as backspace for LinuxTerm
terminals.

Signed-off-by: Roy Franz <roy.franz@linaro.org>
Contributed-under: TianoCore Contribution Agreement 1.0
---
 .../Universal/Console/TerminalDxe/Terminal.h       |  1 +
 .../Universal/Console/TerminalDxe/TerminalConIn.c  | 33 ++++++++++++++++++++++
 2 files changed, 34 insertions(+)
diff mbox

Patch

diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h
index e0335db..727cab8 100644
--- a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h
+++ b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h
@@ -117,6 +117,7 @@  typedef struct {
 #define INPUT_STATE_LEFTOPENBRACKET       0x04
 #define INPUT_STATE_O                     0x08
 #define INPUT_STATE_2                     0x10
+#define INPUT_STATE_LEFTOPENBRACKET_2     0x20
 
 #define RESET_STATE_DEFAULT               0x00
 #define RESET_STATE_ESC_R                 0x01
diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c
index 70ec370..b23b012 100644
--- a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c
+++ b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c
@@ -1397,6 +1397,12 @@  UnicodeToEfiKey (
           TerminalDevice->TerminalType == VTUTF8TYPE    ||
           TerminalDevice->TerminalType == LINUXTERMTYPE) {
         switch (UnicodeChar) {
+        case '3':
+          if (TerminalDevice->TerminalType == LINUXTERMTYPE) {
+            TerminalDevice->InputState |= INPUT_STATE_LEFTOPENBRACKET_2;
+            continue;
+          }
+          break;
         case 'A':
           Key.ScanCode = SCAN_UP;
           break;
@@ -1527,6 +1533,33 @@  UnicodeToEfiKey (
       break;
 
 
+    case INPUT_STATE_ESC | INPUT_STATE_LEFTOPENBRACKET | INPUT_STATE_LEFTOPENBRACKET_2:
+
+        Key.ScanCode = SCAN_NULL;
+
+        if (TerminalDevice->TerminalType == LINUXTERMTYPE) {
+          switch (UnicodeChar) {
+          case '~':
+              Key.ScanCode = SCAN_DELETE;
+            break;
+          }
+        }
+
+      TerminalDevice->ResetState = RESET_STATE_DEFAULT;
+
+      if (Key.ScanCode != SCAN_NULL) {
+        Key.UnicodeChar = 0;
+        EfiKeyFiFoInsertOneKey (TerminalDevice, &Key);
+        TerminalDevice->InputState = INPUT_STATE_DEFAULT;
+        UnicodeToEfiKeyFlushState (TerminalDevice);
+        continue;
+      }
+
+      UnicodeToEfiKeyFlushState (TerminalDevice);
+
+      break;
+
+
     default:
       //
       // Invalid state. This should never happen.