namespace Terminal.Gui.App;
///
/// Defines a contract for managing keyboard input and key bindings at the Application level.
///
/// This interface decouples keyboard handling state from the static class,
/// enabling parallelizable unit tests and better testability.
///
///
public interface IKeyboard
{
///
/// Sets the application instance that this keyboard handler is associated with.
/// This provides access to application state without coupling to static Application class.
///
IApplication? App { get; set; }
///
/// Called when the user presses a key (by the ). Raises the cancelable
/// event, then calls on all top level views, and finally
/// if the key was not handled, invokes any Application-scoped .
///
/// Can be used to simulate key press events.
///
/// if the key was handled.
bool RaiseKeyDownEvent (Key key);
///
/// Called when the user releases a key (by the ). Raises the cancelable
///
/// event
/// then calls on all top level views. Called after .
///
/// Can be used to simulate key release events.
///
/// if the key was handled.
bool RaiseKeyUpEvent (Key key);
///
/// Invokes any commands bound at the Application-level to .
///
///
///
/// if no command was found; input processing should continue.
/// if the command was invoked and was not handled (or cancelled); input processing should continue.
/// if the command was invoked the command was handled (or cancelled); input processing should stop.
///
bool? InvokeCommandsBoundToKey (Key key);
///
/// Invokes an Application-bound command.
///
/// The Command to invoke
/// The Application-bound Key that was pressed.
/// Describes the binding.
///
/// if no command was found; input processing should continue.
/// if the command was invoked and was not handled (or cancelled); input processing should continue.
/// if the command was invoked the command was handled (or cancelled); input processing should stop.
///
///
bool? InvokeCommand (Command command, Key key, KeyBinding binding);
///
/// Raised when the user presses a key.
///
/// Set to to indicate the key was handled and to prevent
/// additional processing.
///
///
///
/// All drivers support firing the event. Some drivers (Unix) do not support firing the
/// and events.
/// Fired after and before .
///
event EventHandler? KeyDown;
///
/// Raised when the user releases a key.
///
/// Set to to indicate the key was handled and to prevent
/// additional processing.
///
///
///
/// All drivers support firing the event. Some drivers (Unix) do not support firing the
/// and events.
/// Fired after .
///
event EventHandler? KeyUp;
/// Gets the Application-scoped key bindings.
KeyBindings KeyBindings { get; }
/// Gets or sets the key to quit the application.
Key QuitKey { get; set; }
/// Gets or sets the key to activate arranging views using the keyboard.
Key ArrangeKey { get; set; }
/// Alternative key to navigate forwards through views. Ctrl+Tab is the primary key.
Key NextTabGroupKey { get; set; }
/// Alternative key to navigate forwards through views. Tab is the primary key.
Key NextTabKey { get; set; }
/// Alternative key to navigate backwards through views. Shift+Ctrl+Tab is the primary key.
Key PrevTabGroupKey { get; set; }
/// Alternative key to navigate backwards through views. Shift+Tab is the primary key.
Key PrevTabKey { get; set; }
}