Home > Software engineering >  Is there function like Console.ReadKey in Spectre.Console.AnsiConsole?
Is there function like Console.ReadKey in Spectre.Console.AnsiConsole?

Time:02-02

Hi i was wondering if there is a function like Console.ReadKey() but with use of AnsiConsole from Spectre.Console package for c#, i dont know if i should use regular one from Console namespace?

I tried something like that but i dont know if Console is integrated with AnsiConsole

 AnsiConsole.Write("Press any key to continue");
 Console.ReadKey();

CodePudding user response:

No there is not, perhaps the following would suit your requirement. Change colors to suit you needs.

private static void Render(Rule rule)
{
    AnsiConsole.Write(rule);
    AnsiConsole.WriteLine();
}

private static void ExitPrompt()
{
    Console.WriteLine();
    Render(new Rule($"[yellow]Press Enter to exit[/]").RuleStyle(Style.Parse("silver")).Centered());
    Console.ReadLine();
}
  • Related