guylangston / ConsoleZ

Enhanced Console featuring color encoding, fast rendering, markdown, html mapper
MIT License
13 stars 2 forks source link
ansi-colors color console terminal

ConsoleZ

A modern multi-target (console/web/gui/tests) console rendering library

Why use this library? What use cases?

What this library does NOT do:

Why?

Key Features (done vs. in-progress):

NuGet Packages

Status

This 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.

Screenshots

ANSI Colour in Console HTML Console Tetris

Key C# interface

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);
}

The Idea?

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:

Stretch:

Getting started

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. ;-)");
}

Hello World

Research / Related projects

Search Terms: