Pārlūkot izejas kodu

WIP: Refactored CommandContext

Tig 7 mēneši atpakaļ
vecāks
revīzija
a7d53928c1
1 mainītis faili ar 6 papildinājumiem un 15 dzēšanām
  1. 6 15
      Terminal.Gui/Input/CommandContext.cs

+ 6 - 15
Terminal.Gui/Input/CommandContext.cs

@@ -11,24 +11,20 @@ namespace Terminal.Gui;
 ///         use <see cref="View.AddCommand(Command,Func{CommandContext,System.Nullable{bool}})"/>.
 ///     </para>
 /// </remarks>
-/// <seealso cref="Application.KeyBindings"/>
-/// <seealso cref="View.KeyBindings"/>
-/// <seealso cref="Command"/>
 #pragma warning restore CS1574 // XML comment has cref attribute that could not be resolved
-public record struct CommandContext
+public record struct CommandContext<TBindingType>
 {
     /// <summary>
     ///     Initializes a new instance of <see cref="CommandContext"/> with the specified <see cref="Command"/>,
     /// </summary>
     /// <param name="command"></param>
     /// <param name="key"></param>
-    /// <param name="keyBinding"></param>
+    /// <param name="binding"></param>
     /// <param name="data"></param>
-    public CommandContext (Command command, Key? key, KeyBinding? keyBinding = null, object? data = null)
+    public CommandContext (Command command, TBindingType? binding, object? data = null)
     {
         Command = command;
-        Key = key;
-        KeyBinding = keyBinding;
+        Binding = binding;
         Data = data;
     }
 
@@ -38,14 +34,9 @@ public record struct CommandContext
     public Command Command { get; set; }
 
     /// <summary>
-    ///     The <see cref="Key"/> that is being invoked. This is the key that was pressed to invoke the <see cref="Command"/>.
+    /// The keyboard or mouse minding that was used to invoke the <see cref="Command"/>, if any.
     /// </summary>
-    public Key? Key { get; set; }
-
-    /// <summary>
-    /// The KeyBinding that was used to invoke the <see cref="Command"/>, if any.
-    /// </summary>
-    public KeyBinding? KeyBinding { get; set; }
+    public TBindingType? Binding { get; set; }
 
     /// <summary>
     ///     Arbitrary data.