Parent: #77
Summary
Add a mechanism for registering global key handlers that run BEFORE focused component input routing. This fixes the issue where Ctrl+Q can't quit the application because the focused TextInputNode consumes it.
Files to Modify
src/Termina/TerminaApplication.cs
Current Problem
Input event received
↓
FocusManager.RouteInput() → TextInputNode.HandleInput() returns true
↓
Event consumed - ViewModel never sees Ctrl+Q
Solution
// New API
public IDisposable RegisterGlobalKeyHandler(
ConsoleKey key,
ConsoleModifiers modifiers,
Action handler);
// Usage in demo apps
app.RegisterGlobalKeyHandler(ConsoleKey.Q, ConsoleModifiers.Control, () => app.Shutdown());
Implementation
private readonly List<Func<ConsoleKeyInfo, bool>> _globalInterceptors = new();
private void ProcessEvent(object evt)
{
if (evt is KeyPressed keyPressed)
{
// Global interceptors FIRST
foreach (var interceptor in _globalInterceptors)
{
if (interceptor(keyPressed.KeyInfo))
return; // consumed
}
// Then focused component
if (_focusManager.RouteInput(keyPressed.KeyInfo))
return;
// Then ViewModel observable
_inputSubject.OnNext(evt);
}
}
Acceptance Criteria
Parent: #77
Summary
Add a mechanism for registering global key handlers that run BEFORE focused component input routing. This fixes the issue where Ctrl+Q can't quit the application because the focused TextInputNode consumes it.
Files to Modify
src/Termina/TerminaApplication.csCurrent Problem
Solution
Implementation
Acceptance Criteria