minhhungit / ConsoleTableExt

A fluent library to print out a nicely formatted table in a console application C#
MIT License
331 stars 37 forks source link

Box-drawing characters #4

Closed vanillajonathan closed 3 years ago

vanillajonathan commented 5 years ago

It could print the table using box-drawing characters.

┌───────┬─────┐
│ Name  │ Age │  
├───────┼─────┤
│ Alice │  10 │
│ Bob   │  20 │    
│ Clare │  30 │    
└───────┴─────┘
minhhungit commented 5 years ago

Hi @vanillajonathan Unlucky currently we don't support box-drawing characters, but I will try to implement it in future when I have more time. Thank you for your suggestion. btw, if you have PR, I will be very happy to accept it

spreedated commented 3 years ago

Check out #7

minhhungit commented 3 years ago

@spreedated thank you, I'm reviewing it, LGTM

minhhungit commented 3 years ago

I think the solution to support this feature is we have to define a map of 'char' of delimiter and divider, like top left, top middle, top right ... by that way developer can enter whatever they want, here are positions.

image

minhhungit commented 3 years ago

By creating a map we can support these formats

image

spreedated commented 3 years ago

Good point, we can support this plus adding some predefined "styles"? I doubt people like to map everytime, however the "map" idea is good :)

minhhungit commented 3 years ago

plus adding some predefined "styles"

yes we will "pre-define" current formats like Markdown, Alternative, FrameDoublePip... using the map

minhhungit commented 3 years ago

This is map I think

image

Not: we also should try to open a way that help developer overwrite existed "Format defination", so we can support table header which has difference style, like this

╔═════════════╗
║ I Am Header ║
╠═════════════╣
║    xyz      ║
╟─────────────╢
║    xyz      ║
╙─────────────╜
minhhungit commented 3 years ago

WIP

image

vanillajonathan commented 3 years ago

Maybe it would be nice if the first row (the header row), the one containing Name, Position, Office, Age, and Start Date had a double line under it and the second row (the first real data row).

minhhungit commented 3 years ago

@vanillajonathan you mean like this ?

image

I'm working on it, almost done, I'm waiting PR from @spreedated to avoid conflict

vanillajonathan commented 3 years ago

@minhhungit Yes! 👍

vanillajonathan commented 3 years ago

Now imagine if the header text (Name, Position, Office, Age, and Start Date) could be written in a different foreground color using the ConsoleColor enum.

Console.ForegroundColor = ConsoleColor.White;
Console.Write("Name");
Console.ResetColor();
spreedated commented 3 years ago

Console color is a bit problematic, since not all consoles support this and there are different colorcodes, and you get those codes into your string output, e.g. Debug.Print or just string data to be saved in logfiles etc. - however, make it optional is always a good idea :)

minhhungit commented 3 years ago

version 3.0.0 is released, now we support box-drawing character, thanks all !