浏览代码

Add InvalidRequestTerminator property.

BDisp 9 月之前
父节点
当前提交
e35b37fb4d
共有 1 个文件被更改,包括 21 次插入6 次删除
  1. 21 6
      Terminal.Gui/ConsoleDrivers/EscSeqUtils/EscSeqUtils.cs

+ 21 - 6
Terminal.Gui/ConsoleDrivers/EscSeqUtils/EscSeqUtils.cs

@@ -163,6 +163,11 @@ public static class EscSeqUtils
     /// </summary>
     public static ConsoleKeyInfo []? IncompleteCkInfos { get; set; }
 
+    /// <summary>
+    ///     Represent a response that was requested by an invalid terminator.
+    /// </summary>
+    public static string? InvalidRequestTerminator { get; set; }
+
     /// <summary>
     ///     Decodes an ANSI escape sequence.
     /// </summary>
@@ -347,12 +352,22 @@ public static class EscSeqUtils
                         mod |= GetConsoleModifiers (values [1]);
                     }
 
-                    newConsoleKeyInfo = new (
-                                             keyChar,
-                                             key,
-                                             (mod & ConsoleModifiers.Shift) != 0,
-                                             (mod & ConsoleModifiers.Alt) != 0,
-                                             (mod & ConsoleModifiers.Control) != 0);
+                    if (keyChar != 0 || key != 0 || mod != 0)
+                    {
+                        newConsoleKeyInfo = new (
+                                                 keyChar,
+                                                 key,
+                                                 (mod & ConsoleModifiers.Shift) != 0,
+                                                 (mod & ConsoleModifiers.Alt) != 0,
+                                                 (mod & ConsoleModifiers.Control) != 0);
+                    }
+                    else
+                    {
+                        // It's request response that wasn't handled by a valid request terminator
+                        System.Diagnostics.Debug.Assert (escSeqRequests is { Statuses.Count: > 0 });
+
+                        InvalidRequestTerminator = ToString (cki);
+                    }
                 }
                 else
                 {