spectre.console
spectre.console copied to clipboard
No title, one choice, wrong output
Hello,
Information
- OS: Windows/MacOS
- Version: 0.43
- Terminal: Windows Terminal
Describe the bug If there is one choice and the title is off, the output is bad.
To Reproduce
using Spectre.Console;
namespace Info;
public static class Program
{
public static void Main()
{
AnsiConsole.Clear();
var grid = new Grid()
.AddColumn(new GridColumn().NoWrap().PadRight(4))
.AddColumn()
.AddRow("[b]Enrichers[/]", string.Join(", ", AnsiConsole.Profile.Enrichers))
.AddRow("[b]Color system[/]", $"{AnsiConsole.Profile.Capabilities.ColorSystem}")
.AddRow("[b]Unicode?[/]", $"{YesNo(AnsiConsole.Profile.Capabilities.Unicode)}")
.AddRow("[b]Supports ansi?[/]", $"{YesNo(AnsiConsole.Profile.Capabilities.Ansi)}")
.AddRow("[b]Supports links?[/]", $"{YesNo(AnsiConsole.Profile.Capabilities.Links)}")
.AddRow("[b]Legacy console?[/]", $"{YesNo(AnsiConsole.Profile.Capabilities.Legacy)}")
.AddRow("[b]Interactive?[/]", $"{YesNo(AnsiConsole.Profile.Capabilities.Interactive)}")
.AddRow("[b]Terminal?[/]", $"{YesNo(AnsiConsole.Profile.Out.IsTerminal)}")
.AddRow("[b]Buffer width[/]", $"{AnsiConsole.Console.Profile.Width}")
.AddRow("[b]Buffer height[/]", $"{AnsiConsole.Console.Profile.Height}")
.AddRow("[b]Encoding[/]", $"{AnsiConsole.Console.Profile.Encoding.EncodingName}");
AnsiConsole.Write(
new Panel(grid)
.Header("Information"));
var selectionPromt = new SelectionPrompt<string>();
// selectionPromt.Title("What's your [green]favorite fruit[/]?");
selectionPromt.PageSize = 10;
selectionPromt.MoreChoicesText = "[grey](Move up and down to reveal more fruits)[/]";
// selectionPromt.AddChoice("Apple");
selectionPromt.AddChoices(new[] { "Apple", "Béla" });
// Ask for the user's favorite fruit
var fruit = AnsiConsole.Prompt(selectionPromt);
}
private static string YesNo(bool value)
{
return value ? "Yes" : "No";
}
}
Screenshots
Tamas
Please upvote :+1: this issue if you are interested in it.
I was able to reproduce on my end, thanks for the report. If you get a chance to take a look at submitting a PR with a fix I'd be happy to review too
Thank you, unfortunately Spectre.console is new to me to do right PR. But I checked, I think that's the problem. In ListPrompt<T> class: