A modern multi-target (console/web/gui/tests) console rendering library
Why use this library? What use cases?
What this library does NOT do:
Key Features (done vs. in-progress):
"^red;Error:^; Message"
IConsole
working with HTML, WinForms, ConsoleThis library is ALPHA status. Meaning core interfaces may change. At present this library is not ready for production.
Please create a github issue for any features/bugs.
What will I be programming against?
public interface ITextWriter
{
int WriteLine(string s); // We don't use Write, rather update the whole line
int WriteFormatted(FormattableString formatted);
}
public interface IConsole : ITextWriter
{
string Handle { get; }
int Version { get; }
int Width { get; }
int Height { get; }
int DisplayStart { get; }
int DisplayEnd { get; }
void UpdateLine(int line, string txt);
void UpdateFormatted(int line, FormattableString formatted);
}
In my current project we have lots of command logic that output calculation reports to the console. As the functionaliy matures, or reaches a larger audience, the it gets ported to the web.
Would it not be great if the console and html versions share the same interface and rendering abilities:
Features:
"Hello ^red;World^;" <-> string.Format("Hello {0}World{1}", Color.Red, Color.Default)
[###... 50%]
Stretch:
You can start with a normal console app then:
static void Main(string[] args)
{
var cons = AnsiConsole.Singleton;
cons.WriteLine("Hello World");
cons.WriteLine("Have a ^red;wonderful^; day!");
var idx = cons.WriteLine("Replace me");
cons.UpdateLine(ids, "I was replaced. ;-)");
}