KeyBinding.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334
  1. #nullable enable
  2. // These classes use a key binding system based on the design implemented in Scintilla.Net which is an
  3. // MIT licensed open source project https://github.com/jacobslusser/ScintillaNET/blob/master/src/ScintillaNET/Command.cs
  4. namespace Terminal.Gui;
  5. /// <summary>
  6. /// Provides a collection of <see cref="Command"/> objects that are scoped to <see cref="KeyBindingScope"/>.
  7. /// </summary>
  8. public record struct KeyBinding
  9. {
  10. /// <summary>Initializes a new instance.</summary>
  11. /// <param name="commands">The commands this key binding will invoke.</param>
  12. /// <param name="scope">The scope of the <see cref="Commands"/>.</param>
  13. /// <param name="context">Arbitrary context that can be associated with this key binding.</param>
  14. public KeyBinding (Command [] commands, KeyBindingScope scope, object? context = null)
  15. {
  16. Commands = commands;
  17. Scope = scope;
  18. Context = context;
  19. }
  20. /// <summary>The commands this key binding will invoke.</summary>
  21. public Command [] Commands { get; set; }
  22. /// <summary>The scope of the <see cref="Commands"/>.</summary>
  23. public KeyBindingScope Scope { get; set; }
  24. /// <summary>
  25. /// Arbitrary context that can be associated with this key binding.
  26. /// </summary>
  27. public object? Context { get; set; }
  28. }