Skip to content

How to force ANSI escape sequencess mode? #844

Discussion options

You must be logged in to vote

Actually it appeared that SetAnsiConsoleOutputMode() failed to set desired output mode when output was redirected to the file.

So the answer to the question "How to force ANSI escape sequencess mode?" was quite simple then:

static void Main(string[] args)
{
    if (args.Any(arg => arg == "--force-ansi-output"))
    {
        AnsiConsole.Console = AnsiConsole.Create(new AnsiConsoleSettings
        {
            Ansi = AnsiSupport.Yes,
            ColorSystem = ColorSystemSupport.EightBit,
            Out = new AnsiConsoleOutput(Console.Out)
        });
    }

    AnsiConsole.Background = ConsoleColor.Magenta;
    AnsiConsole.WriteLine("Hello, World!");

    AnsiConsole.MarkupLine("[default…

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by r-pankevicius
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants