generated from akkadotnet/build-system-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Description
Parent: #77
Summary
Implement FallbackConsole that wraps the existing polling-based logic for platforms where native P/Invoke isn't available.
Files to Create
src/Termina/Platform/FallbackConsole.cs
Implementation
Essentially wrap the current ConsoleInputSource logic:
public sealed class FallbackConsole : IPlatformConsole
{
public async Task<ConsoleInputEvent?> ReadInputAsync(CancellationToken ct)
{
while (!ct.IsCancellationRequested)
{
if (Console.KeyAvailable)
{
var key = Console.ReadKey(intercept: true);
return new KeyEvent(key);
}
// Check for resize
var (w, h) = GetSize();
if (w != _lastWidth || h != _lastHeight)
{
_lastWidth = w;
_lastHeight = h;
return new ResizeEvent(w, h);
}
await Task.Delay(1, ct); // Reduced from 10ms
}
return null;
}
}Key Differences from Current
- Reduced polling delay (1ms instead of 10ms)
- Implements
IPlatformConsoleinterface - Returns
ConsoleInputEventrecords instead of writing to channel directly
Acceptance Criteria
- Implements IPlatformConsole interface
- Works on any .NET-supported platform
- Reduced polling delay for lower latency
- Resize detection via polling
- Graceful cancellation
Metadata
Metadata
Assignees
Labels
No labels