소스 검색

Fix MapConsoleKeyInfo not working with Esc properly

tznind 11 달 전
부모
커밋
b30c92bceb
1개의 변경된 파일12개의 추가작업 그리고 0개의 파일을 삭제
  1. 12 0
      Terminal.Gui/ConsoleDrivers/EscSeqUtils/EscSeqUtils.cs

+ 12 - 0
Terminal.Gui/ConsoleDrivers/EscSeqUtils/EscSeqUtils.cs

@@ -970,6 +970,18 @@ public static class EscSeqUtils
 
                 break;
             case uint n when n > 0 && n <= KeyEsc:
+                if (n == KeyEsc)
+                {
+                    key= ConsoleKey.Escape;
+
+                    newConsoleKeyInfo = new ConsoleKeyInfo (
+                                                            consoleKeyInfo.KeyChar,
+                                                            key,
+                                                            (consoleKeyInfo.Modifiers & ConsoleModifiers.Shift) != 0,
+                                                            (consoleKeyInfo.Modifiers & ConsoleModifiers.Alt) != 0,
+                                                            (consoleKeyInfo.Modifiers & ConsoleModifiers.Control) != 0);
+                }
+                else
                 if (consoleKeyInfo.Key == 0 && consoleKeyInfo.KeyChar == '\r')
                 {
                     key = ConsoleKey.Enter;