mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-06-19 13:28:16 +08:00
Add support for fake input in asciicast recordings
* Fixes a bug with `SelectionPrompt` and page size. * Allow `IAnsiConsoleInput` to return `null`.
This commit is contained in:

committed by
Phil Scott

parent
46abadaccb
commit
450d87f5d3
@ -24,8 +24,13 @@ namespace Spectre.Console
|
||||
|
||||
while (true)
|
||||
{
|
||||
var key = console.Input.ReadKey(true);
|
||||
var rawKey = console.Input.ReadKey(true);
|
||||
if (rawKey == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var key = rawKey.Value;
|
||||
if (key.Key == ConsoleKey.Enter)
|
||||
{
|
||||
return text;
|
||||
|
@ -12,6 +12,6 @@ namespace Spectre.Console
|
||||
/// </summary>
|
||||
/// <param name="intercept">Whether or not to intercept the key.</param>
|
||||
/// <returns>The key that was read.</returns>
|
||||
ConsoleKeyInfo ReadKey(bool intercept);
|
||||
ConsoleKeyInfo? ReadKey(bool intercept);
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ namespace Spectre.Console
|
||||
_profile = profile ?? throw new ArgumentNullException(nameof(profile));
|
||||
}
|
||||
|
||||
public ConsoleKeyInfo ReadKey(bool intercept)
|
||||
public ConsoleKeyInfo? ReadKey(bool intercept)
|
||||
{
|
||||
if (!_profile.Capabilities.Interactive)
|
||||
{
|
||||
|
@ -48,8 +48,13 @@ namespace Spectre.Console
|
||||
|
||||
while (true)
|
||||
{
|
||||
var key = _console.Input.ReadKey(true);
|
||||
var rawKey = _console.Input.ReadKey(true);
|
||||
if (rawKey == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var key = rawKey.Value;
|
||||
var result = _strategy.HandleInput(key, state);
|
||||
if (result == ListPromptInputResult.Submit)
|
||||
{
|
||||
|
@ -77,7 +77,7 @@ namespace Spectre.Console
|
||||
{
|
||||
// Create the list prompt
|
||||
var prompt = new ListPrompt<T>(console, this);
|
||||
var result = prompt.Show(_tree);
|
||||
var result = prompt.Show(_tree, PageSize);
|
||||
|
||||
// Return the selected item
|
||||
return result.Items[result.Index].Data;
|
||||
|
Reference in New Issue
Block a user