Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
143 views
in Technique[技术] by (71.8m points)

C#: Can you completely wipe the console window?

Before you mark this question as a duplicate, I have a very specific problem with the Console.Clear() method. When I clear the console with this method, it just "pushes" all the output up until there's nothing left to see (i.e. prints a bunch of newlines). This works well with most of my applications but it doesn't work with ANSI escape codes that change the position of the cursor. E.g.:

Console.WriteLine("Hello");
Console.WriteLine("How are you");
Console.Clear();
Console.Write("x1b[0;0HI'm fine");

This would just print I'm fine on the first line, that you can't actually see anymore (because it's been "pushed" up) instead of the "new" home position. I am using Cygwin terminal.

Please let me know how to "properly" clear the console window or set the cursor position. Thanks.

question from:https://stackoverflow.com/questions/65646604/c-can-you-completely-wipe-the-console-window

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...