Add interactive prompts for selecting values

* Adds SelectionPrompt
* Adds MultiSelectionPrompt

Closes #210
This commit is contained in:
Patrik Svensson
2021-01-08 06:38:07 +01:00
committed by Patrik Svensson
parent 3a593857c8
commit 0e0f4b4220
20 changed files with 980 additions and 40 deletions

View File

@ -26,10 +26,10 @@ namespace Spectre.Console.Internal
{
if (_out.IsStandardOut())
{
return ConsoleHelper.GetSafeBufferWidth(Constants.DefaultBufferWidth);
return ConsoleHelper.GetSafeWidth(Constants.DefaultTerminalWidth);
}
return Constants.DefaultBufferWidth;
return Constants.DefaultTerminalWidth;
}
}
@ -39,10 +39,10 @@ namespace Spectre.Console.Internal
{
if (_out.IsStandardOut())
{
return ConsoleHelper.GetSafeBufferHeight(Constants.DefaultBufferHeight);
return ConsoleHelper.GetSafeHeight(Constants.DefaultTerminalHeight);
}
return Constants.DefaultBufferHeight;
return Constants.DefaultTerminalHeight;
}
}

View File

@ -21,12 +21,12 @@ namespace Spectre.Console.Internal
public int Width
{
get { return ConsoleHelper.GetSafeBufferWidth(Constants.DefaultBufferWidth); }
get { return ConsoleHelper.GetSafeWidth(Constants.DefaultTerminalWidth); }
}
public int Height
{
get { return ConsoleHelper.GetSafeBufferHeight(Constants.DefaultBufferHeight); }
get { return ConsoleHelper.GetSafeHeight(Constants.DefaultTerminalHeight); }
}
public FallbackBackend(TextWriter @out, Capabilities capabilities)

View File

@ -4,7 +4,7 @@ namespace Spectre.Console.Internal
{
internal static class ConsoleHelper
{
public static int GetSafeBufferWidth(int defaultValue = Constants.DefaultBufferWidth)
public static int GetSafeWidth(int defaultValue = Constants.DefaultTerminalWidth)
{
try
{
@ -22,11 +22,11 @@ namespace Spectre.Console.Internal
}
}
public static int GetSafeBufferHeight(int defaultValue = Constants.DefaultBufferWidth)
public static int GetSafeHeight(int defaultValue = Constants.DefaultTerminalHeight)
{
try
{
var height = System.Console.BufferHeight;
var height = System.Console.WindowHeight;
if (height == 0)
{
height = defaultValue;

View File

@ -2,8 +2,8 @@ namespace Spectre.Console.Internal
{
internal static class Constants
{
public const int DefaultBufferWidth = 80;
public const int DefaultBufferHeight = 9001;
public const int DefaultTerminalWidth = 80;
public const int DefaultTerminalHeight = 24;
public const string EmptyLink = "https://emptylink";
}