public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Gao, Zhichao" <zhichao.gao@intel.com>
To: devel@edk2.groups.io
Cc: Jian J Wang <jian.j.wang@intel.com>,
	Hao A Wu <hao.a.wu@intel.com>, Ray Ni <ray.ni@intel.com>,
	Liming Gao <liming.gao@intel.com>
Subject: [PATCH] MdeModulePkg/TerminalDxe: Enhance the arrow keys support
Date: Wed, 25 Sep 2019 20:09:25 +0800	[thread overview]
Message-ID: <20190925120925.12600-1-zhichao.gao@intel.com> (raw)

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2219

Refer to
https://www.ssh.com/ssh/putty/putty-manuals/0.68/Chapter4.html#config-appcursor
In normal mode, arrow key would send ESC [A through to ESC [D.
In application mode, arrow key would send ESC OA through to
ESC OD.

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Signed-off-by: Zhichao Gao <zhichao.gao@intel.com>
---
 .../Console/TerminalDxe/TerminalConIn.c       | 46 ++++++++++++++++---
 1 file changed, 40 insertions(+), 6 deletions(-)

diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c
index ac31f27984..fdb1a0f1ef 100644
--- a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c
+++ b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c
@@ -1402,10 +1402,7 @@ UnicodeToEfiKey (
         continue;
       }
 
-      if (UnicodeChar == 'O' && (TerminalDevice->TerminalType == TerminalTypeVt100 ||
-                                 TerminalDevice->TerminalType == TerminalTypeTtyTerm ||
-                                 TerminalDevice->TerminalType == TerminalTypeXtermR6 ||
-                                 TerminalDevice->TerminalType == TerminalTypeVt100Plus)) {
+      if (UnicodeChar == 'O') {
         TerminalDevice->InputState |= INPUT_STATE_O;
         TerminalDevice->ResetState = RESET_STATE_DEFAULT;
         continue;
@@ -1631,6 +1628,35 @@ UnicodeToEfiKey (
         }
       }
 
+      //
+      // In Putty application mode, the arrow keys would send
+      // ESC OA through to ESC OD
+      //
+      if (TerminalDevice->TerminalType == TerminalTypePcAnsi    ||
+          TerminalDevice->TerminalType == TerminalTypeVt100     ||
+          TerminalDevice->TerminalType == TerminalTypeVt100Plus ||
+          TerminalDevice->TerminalType == TerminalTypeVtUtf8    ||
+          TerminalDevice->TerminalType == TerminalTypeTtyTerm   ||
+          TerminalDevice->TerminalType == TerminalTypeLinux     ||
+          TerminalDevice->TerminalType == TerminalTypeXtermR6   ||
+          TerminalDevice->TerminalType == TerminalTypeVt400     ||
+          TerminalDevice->TerminalType == TerminalTypeSCO) {
+        switch (UnicodeChar) {
+        case 'A':
+          Key.ScanCode = SCAN_UP;
+          break;
+        case 'B':
+          Key.ScanCode = SCAN_DOWN;
+          break;
+        case 'C':
+          Key.ScanCode = SCAN_RIGHT;
+          break;
+        case 'D':
+          Key.ScanCode = SCAN_LEFT;
+          break;
+        }
+      }
+
       if (Key.ScanCode != SCAN_NULL) {
         Key.UnicodeChar = 0;
         EfiKeyFiFoInsertOneKey (TerminalDevice, &Key);
@@ -1668,10 +1694,18 @@ UnicodeToEfiKey (
 
       Key.ScanCode = SCAN_NULL;
 
+      //
+      // In Putty normal mode, the arrow keys would send
+      // ESC [A through to [D
+      //
       if (TerminalDevice->TerminalType == TerminalTypePcAnsi    ||
           TerminalDevice->TerminalType == TerminalTypeVt100     ||
-          TerminalDevice->TerminalType == TerminalTypeVtUtf8 ||
-          TerminalDevice->TerminalType == TerminalTypeTtyTerm ||
+          TerminalDevice->TerminalType == TerminalTypeVt100Plus ||
+          TerminalDevice->TerminalType == TerminalTypeVtUtf8    ||
+          TerminalDevice->TerminalType == TerminalTypeTtyTerm   ||
+          TerminalDevice->TerminalType == TerminalTypeLinux     ||
+          TerminalDevice->TerminalType == TerminalTypeXtermR6   ||
+          TerminalDevice->TerminalType == TerminalTypeVt400     ||
           TerminalDevice->TerminalType == TerminalTypeSCO) {
         switch (UnicodeChar) {
         case 'A':
-- 
2.21.0.windows.1


             reply	other threads:[~2019-09-25 12:14 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-25 12:09 Gao, Zhichao [this message]
2019-09-25 13:32 ` [edk2-devel] [PATCH] MdeModulePkg/TerminalDxe: Enhance the arrow keys support Liming Gao
2019-09-25 18:17 ` Ni, Ray
2019-09-26  0:51   ` Gao, Zhichao
     [not found]   ` <15C7D6B899193667.11273@groups.io>
2019-09-26  1:03     ` Gao, Zhichao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190925120925.12600-1-zhichao.gao@intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox