All Projects → douglasg14b → BetterConsoleTables

douglasg14b / BetterConsoleTables

Licence: LGPL-3.0 license
Faster, colorable, more configurable, and more robust console colors & tables for C# console applications

Programming Languages

C#
18002 projects

Projects that are alternatives of or similar to BetterConsoleTables

tamcolors
tamcolors is a terminal game library which supports multiplayer and audio. tamcolors gives a buffer which lets the user set the character, foreground color and background color which can draw at a stable FPS of 25 on all supported console.
Stars: ✭ 24 (-59.32%)
Mutual labels:  console, colors
console-logging
Better, prettier commandline logging for Python--with colors! 👻
Stars: ✭ 111 (+88.14%)
Mutual labels:  console, colors
contabs
Simple yet flexible tables for console apps.
Stars: ✭ 51 (-13.56%)
Mutual labels:  console, tables
Colore
A powerful C# library for Razer Chroma's SDK
Stars: ✭ 121 (+105.08%)
Mutual labels:  colors, netcore
leeks.js
Simple ANSI styling for your terminal
Stars: ✭ 12 (-79.66%)
Mutual labels:  console, colors
Colorful
Terminal string styling done right, in Python 🐍 🎉
Stars: ✭ 456 (+672.88%)
Mutual labels:  console, colors
Termcolor
Termcolor is a header-only C++ library for printing colored messages to the terminal. Written just for fun with a help of the Force.
Stars: ✭ 533 (+803.39%)
Mutual labels:  console, colors
Termenv
Advanced ANSI style & color support for your terminal applications
Stars: ✭ 555 (+840.68%)
Mutual labels:  console, colors
Console Logging
Better, prettier commandline logging for Python--with colors! 👻
Stars: ✭ 111 (+88.14%)
Mutual labels:  console, colors
Colorette
Easily set the color and style of text in the terminal.
Stars: ✭ 1,047 (+1674.58%)
Mutual labels:  console, colors
log-utils
Basic logging utils: colors, symbols and timestamp.
Stars: ✭ 24 (-59.32%)
Mutual labels:  console, colors
oof
Convenient, high-performance RGB color and position control for console output
Stars: ✭ 764 (+1194.92%)
Mutual labels:  console, colors
concolor
Colouring template strings using tags with annotations 🎨
Stars: ✭ 35 (-40.68%)
Mutual labels:  console, colors
hex-rgba
Convert HEX to RGBA
Stars: ✭ 12 (-79.66%)
Mutual labels:  colors
console.history
📜 Store all javascript console logs in console.history
Stars: ✭ 30 (-49.15%)
Mutual labels:  console
xontrib-prompt-bar
The bar prompt for xonsh shell with customizable sections and Starship support.
Stars: ✭ 27 (-54.24%)
Mutual labels:  console
nim-dashing
Terminal dashboards for Nim
Stars: ✭ 105 (+77.97%)
Mutual labels:  console
tableize
Turn lists into tables with ease
Stars: ✭ 12 (-79.66%)
Mutual labels:  tables
snax86
A snake game written in x86 Assembly language for windows console
Stars: ✭ 21 (-64.41%)
Mutual labels:  console
coreipc
WCF-like service model API for communication over named pipes and TCP. .NET and node.js clients.
Stars: ✭ 22 (-62.71%)
Mutual labels:  netcore

Nuget Nuget

image

Code that generates of the above table can be found here

Note: Readme is still WIP for V2. Please refer to the Examples project for examples on the V2 API.

Better Consoles

Faster, colorable, more configurable, and more robust console colors & tables for C# console applications.

  • Better Console Colors
  • Better Console Tables

Better Console Tables

What it does

Provides tables for your console application! But really, it provides tables in a performance friendly way, while also adding the ability to display multiple tables in a variety of formats. There is additional configuration information that you can use to overwrite default functionality, allowing you to create tables with whatever style you want.

Why?

To make something better than the defacto console tables library.

How do I use it?

  1. Get it from nuget Install-Package BetterConsoleTables -Version 1.1.2
  2. Include it using BetterConsoleTables;
  3. See code examples or example directory

You mentioned performance?

Yes! Yes I did. I wrote this to not just be highly configurable, but also performance friendly. Version 2 adds significant complexity by allowing for coloring, formatting, and greater configuration flexibility. This, unfortunately, comes at a cost.

As you can see from the tests below, Version 2 takes ~1.1x as long as the defacto library. Version 1 is nearly 3x faster.

Test Mean StdDev Ratio
OtherConsoleTable 9.8 us 0.86 us 1.00
v1 3.78 us 0.15 us 0.39
v2 10.89 us 0.13 us 1.11
v2 Formatted 14.96 us 0.29 us 1.52
v2 Formatted Replace Rows 13.97 us 0.13 us 1.42

Features

  • Every table cell can have it's own formatting
    • Current API is inelegant, better API being developed [Coming Soon]
  • Formatting Callbacks/Custom Formatters
  • Configuration Flexibility
    • Fluent API
    • Config classes
    • Pre-formatted strings
  • Print multiple tables
    • Automatically lines up the columns and their widths between the tables
  • Configurable table box drawing formats
    • Several presets to choose from
    • Can change any of the table drawing characters in the configuration
    • Dividers, headers, outside & inside edges, and even corners are configurable
  • Alignment
    • Align headers and cells, or entire columns
    • Left, Center, and Right alignment with automatic padding
  • Colors
    • Full RGB support
    • Background & Foreground coloring
    • Gradients [Coming Soon]
    • Value-based coloring [Coming Soon]
  • Font/Text Formatting
    • Bold (Brighten)
    • Underline
    • Italic **
    • Blinking
    • Crossed Out **
    • Overline **
    • Reversed colors (Swaps foreground & background)
  • Table data replacement support
  • Generate tables from existing objects

Future Improvements

  • Configuration
    • Easier, short-form, configuration so there isn't as much boilerplate to write

** Does not work in default windows console

Code Examples

Single Simple Table

static void Main(String[] args)
{
    Table  table = new Table("one", "two", "three");
    table.AddRow(1, 2, 3)
         .AddRow("long line goes here", "short text", "word");

    Console.Write(table.ToString());
    Console.ReadKey();
}

Derive From Objects

static void Main(String[] args)
{
  Table table = new Table(TableConfig.MySql());
  table.From<SomeData>(rows);

  Console.Write(table.ToString());
}

Multiple Tables

static void Main(String[] args)
{
    Table table = new Table("One", "Two", "Three")
      .AddRow("1", "2", "3")
      .AddRow("Short", "item", "Here")
      .AddRow("Longer items go here", "stuff stuff", "stuff");

    Table table2 = new Table("One", "Two", "Three", "Four")
      .AddRow("One", "Two", "Three")
      .AddRow("Short", "item", "Here", "A fourth column!!!")
      .AddRow("stuff", "longer stuff", "even longer stuff in this cell")
      .Config = Config.UnicodeAlt();

    ConsoleTables tables = new ConsoleTables(table, table2);
    
    Console.Write(tables.ToString());
    
    Console.ReadKey();
}

Column Alignment

    ColumnHeader[] headers = new[]
    {
        new ColumnHeader("Left"),
        new ColumnHeader("Left Header", Alignment.Right),
        new ColumnHeader("Right Header", Alignment.Center, Alignment.Right),
    };
    Table table = new Table(headers)
        .AddRow("1", "2", "3")
        .AddRow("Short", "item", "Here")
        .AddRow("Longer items go here", "Right Contents", "Centered Contents");
    table.Config = TableConfiguration.MySqlSimple(); // Sets table formatting

    Console.Write(table.ToString());
    Console.ReadKey();

Console Outputs

Column & Row Alignment 1

ColumnHeader[] headers = new[]
{
    new ColumnHeader("Left"),
    new ColumnHeader("Right", Alignment.Right, Alignment.Right),
    new ColumnHeader("Center", Alignment.Center, Alignment.Center),
};

Table table = new Table(headers);
+----------------------+-------------+---------------------+
| Left                 |       Right |        Center       |
+----------------------+-------------+---------------------+
| 1                    |           2 |          3          |
| Short                |        item |         Here        |
| Longer items go here | stuff stuff | some centered thing |
+----------------------+-------------+---------------------+

Column & Row Alignment 2

ColumnHeader[] headers = new[]
{
    new ColumnHeader("Left"),
    new ColumnHeader("Left Header", Alignment.Right),
    new ColumnHeader("Right Header", Alignment.Center, Alignment.Right),
};

Table table = new Table(headers);
+----------------------+----------------+-------------------+
| Left                 | Left Header    |      Right Header |
+----------------------+----------------+-------------------+
| 1                    |              2 |         3         |
| Short                |           item |        Here       |
| Longer items go here | Right Contents | Centered Contents |
+----------------------+----------------+-------------------+

Default

----------------------------------------------
| One                  | Two         | Three |
----------------------------------------------
| 1                    | 2           | 3     |
----------------------------------------------
| Short                | item        | Here  |
----------------------------------------------
| Longer items go here | stuff stuff | stuff |
----------------------------------------------

Markdown

table.Config = TableConfiguration.Markdown();
| One                  | Two         | Three |
|----------------------|-------------|-------|
| 1                    | 2           | 3     |
| Short                | item        | Here  |
| Longer items go here | stuff stuff | stuff |

MySql

table.Config = TableConfiguration.MySql();
+----------------------+-------------+-------+
| One                  | Two         | Three |
+----------------------+-------------+-------+
| 1                    | 2           | 3     |
+----------------------+-------------+-------+
| Short                | item        | Here  |
+----------------------+-------------+-------+
| Longer items go here | stuff stuff | stuff |
+----------------------+-------------+-------+

MySql Simple

table.Config = TableConfiguration.MySqlSimple();
+----------------------+-------------+-------+
| One                  | Two         | Three |
+----------------------+-------------+-------+
| 1                    | 2           | 3     |
| Short                | item        | Here  |
| Longer items go here | stuff stuff | stuff |
+----------------------+-------------+-------+

Unicode

table.Config = TableConfiguration.Unicode();
┌──────────────────────┬─────────────┬───────┐
│ One                  │ Two         │ Three │
├──────────────────────┼─────────────┼───────┤
│ 1                    │ 2           │ 3     │
│ Short                │ item        │ Here  │
│ Longer items go here │ stuff stuff │ stuff │
└──────────────────────┴─────────────┴───────┘

Unicode Alt

 table.Config = TableConfiguration.UnicodeAlt();
╔══════════════════════╦═════════════╦═══════╗
║ One                  ║ Two         ║ Three ║
╠══════════════════════╬═════════════╬═══════╣
║ 1                    ║ 2           ║ 3     ║
║ Short                ║ item        ║ Here  ║
║ Longer items go here ║ stuff stuff ║ stuff ║
╚══════════════════════╩═════════════╩═══════╝

Screenshot

alt text

Licence clarification

This LGPL-v3 license applies For all changes as part of the Version2 branch, from commit 0a2e191f96f7f1bb14f8a768d788e0a4aa272430 onwards. Previous to this all code is licensed under MIT.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].