muesli4 / table-layout

Layout data in grids and pretty tables. Provides a lot of tools to get the cell formatting right (positional alignment, alignment on specific characters and limiting of cell width)..
BSD 3-Clause "New" or "Revised" License
37 stars 11 forks source link

Allow TableStyle to handle row headers #31

Closed Xitian9 closed 1 year ago

Xitian9 commented 2 years ago

This addresses some of the points in https://github.com/muesli4/table-layout/issues/20#issuecomment-1060164646. In particular, row headers are now rendered in the table, along with special line styles available within the row header (as there are in the column headers).

I have chosen to display a row header only in the first line of a row group, thus breaking the symmetry between row groups and row headers, so that question has also been resolved.

Also simplifies the creation of new TableStyle from TableStyleSpec, allowing it to handle ASCII tables as well, and creating an even simpler constructor simpleTableStyleSpec.

Xitian9 commented 2 years ago

Here is an overly fancy example from the test suite. It renders better in my terminal.

╭───╥───────────────────┬───────────────────┬────────────┰────────────┬────────────┬────────────┬────────────┰────────────┬────────────╮
│   ║     Some text     │   Some numbers    │     X      ┃     Z      │     W      │     A      │     B      ┃    Text    │     Y      │
╞═══╬═══════════════════╪═══════════════════╪════════════╋════════════╧════════════╪════════════╧════════════╋════════════╧════════════╡
│ 1 ║ This is long text ┆    4.20000000     ┆    foo     ┃    blah         bloo    ┆    blop         blog    ┃   Short         baz     │
│   ║       Short       ┆ 200300400500600.2 ┆    bar     ┃   yadda         yoda    ┆   yeeda         york    ┃   Short        wibble   │
├───╫┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┄┄┄╂┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄╂┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┤
│ 2 ║ This is long text ┆    4.20000000     ┆    foo     ┃  bibbidy      babbidy   ┆    boo          blue    ┃   Short        wobble   │
╰───╨───────────────────┴───────────────────┴────────────┸─────────────────────────┴─────────────────────────┸─────────────────────────╯
muesli4 commented 2 years ago

The end-result looks great, well done. I will have a closer look soon. (Just did some of the simple ones first.)

Xitian9 commented 1 year ago

Anything I can do to help this along?