mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-06-18 04:53:21 +08:00

* Fixes a bug with `SelectionPrompt` and page size. * Allow `IAnsiConsoleInput` to return `null`.
25 lines
622 B
C#
25 lines
622 B
C#
using System;
|
|
|
|
namespace Spectre.Console
|
|
{
|
|
internal sealed class DefaultInput : IAnsiConsoleInput
|
|
{
|
|
private readonly Profile _profile;
|
|
|
|
public DefaultInput(Profile profile)
|
|
{
|
|
_profile = profile ?? throw new ArgumentNullException(nameof(profile));
|
|
}
|
|
|
|
public ConsoleKeyInfo? ReadKey(bool intercept)
|
|
{
|
|
if (!_profile.Capabilities.Interactive)
|
|
{
|
|
throw new InvalidOperationException("Failed to read input in non-interactive mode.");
|
|
}
|
|
|
|
return System.Console.ReadKey(intercept);
|
|
}
|
|
}
|
|
}
|