ApplicationKeyBinding.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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 the <see cref="Application"/>.
  7. /// </summary>
  8. /// <seealso cref="Command"/>
  9. public record struct ApplicationKeyBinding
  10. {
  11. /// <summary>Initializes a new instance.</summary>
  12. /// <param name="commands">The commands this key binding will invoke.</param>
  13. public ApplicationKeyBinding (Command [] commands)
  14. {
  15. Commands = commands;
  16. }
  17. /// <summary>Initializes a new instance.</summary>
  18. /// <param name="commands">The commands this key binding will invoke.</param>
  19. /// <param name="target">The view the Application-scoped key binding is bound to. If <see langword="null"/> the commands will be invoked on
  20. /// the <see cref="Application"/>.</param>
  21. public ApplicationKeyBinding (Command [] commands, View? target)
  22. {
  23. Commands = commands;
  24. Target = target;
  25. }
  26. /// <summary>The commands this binding will invoke.</summary>
  27. public Command [] Commands { get; set; }
  28. /// <summary>
  29. /// The Key that is bound to the <see cref="Commands"/>.
  30. /// </summary>
  31. public Key? Key { get; set; }
  32. /// <summary>The view the Application-scoped key binding is bound to.</summary>
  33. public View? Target { get; set; }
  34. }