Open DkAngelito opened 4 years ago
I did a whole refactoring to supporting styling and lists, and got stuck on a bug, and never maanged to release the update. Tables is part of that update, I show cased tables in our gitter chat, ...you can do stuff like this easily;
see the discussion in gitter here: https://gitter.im/goblinfactory-konsole/community
I have been consumed with another project and since the conversation in gitter didn't get any attention konsole has been on my backlog of nice to fix, but not urgent.
I have one small bug I need some volunteers to help me iron out, then I have a massive update for konsole that will include list controls, with highlighted current item, with hooks for OnItemSelected, as well as inline form editing. I need the big styling refactoring since to get editing to work smoothly I need to be able to re-render a control with .active styling and .inactive styling when tabbing away. Windows need to be selectable as well (double line in color X when selected and single line when inactive etc).
A lot of work has gone into preparing for that, ...tables was done first. The same above uses a control DirectoryListView that implements ListView ...which is ...the table view you're asking for.
you can see table view in this branch, and you can use the code easily now with current Konsole if you want;
https://github.com/goblinfactory/konsole/tree/feature/list-view
code for the above screen, with the branch mentioned above, using custom business rules to style directories and large files differently based on business rules is just this
public static void Main(string[] args)
{
var window = new Window();
var console = window.SplitLeft("left");
var right = window.SplitRight("right");
var listView = new DirectoryListView(console, "../../..");
// let's highlight - all files > 4 Mb and make directories green
listView.BusinessRuleColors = (o, column) =>
{
if (column == 2 && o.Size > 4000000) return new Colors(White, DarkBlue);
if (column == 1 && o.Item is DirectoryInfo) return new Colors(Green, Black);
return null;
};
listView.Refresh();
Console.ReadKey(true);
}
your business rule can easily be ... if o.Selected == true
to easily support highlighting current item.
here's how to use the raw ListView
object to draw tables
var window = Window.OpenBox("openings", 50, sy, 35, 12, style);
var moves = new[] {
("Kings Gambit", 39, "win"),
("Sicilian Defence", 35, "draw"),
("French Defence", 22, "win"),
("Alekhine Defence", 19, "win"),
("Kings Gambit", 33, "win"),
("Kings Indian", 21, "draw"),
("Ruy Lopaz", 82, "lose") };
var view = new ListView<(string opening, int moves, string result)>( window,
_ => moves, (u) => new[] {
u.opening,
u.moves.ToString(),
u.result,
},
new Column("Opening", 0),
new Column("Moves", 7),
new Column("Result", 7)
); );
view.Refresh(); view.Refresh();
I am also working konsole Table
that automatically prints any collection as a table, var table = new Table(window); table.Print(myUserCollection)
or if you're not using a parent window, new Table(users).Print()
for the simplest use.
@DkAngelito just finished branch with ListView in it, ready for merging to master for testing. https://github.com/goblinfactory/konsole/tree/feature/list-view-themes-no-tuples-docmd Just need to update documentation and will release new version next few days.
Here's my test for the listview theming, almost all done, next I need to write the updates to the documentation then create new package for testing
Would be great if this library would have a feature to draw tables in a simple way