scandum / tintin

TinTin++, aka tt++, is an extensible console MUD client.
https://tintin.mudhalla.net
GNU General Public License v3.0
204 stars 56 forks source link

the option 'calign' does not work with '#draw grid table' #230

Open peddn opened 3 months ago

peddn commented 3 months ago

Hello,

when I draw a table with the command '#draw calign grid table', it seems that the option 'calign' is no longer taken into account. Here is an example:

#draw calign grid table {2} {2} {8} {42} {n;s;w;e} {n;s;w;e}; produces:

┌─────────┬─────────┬─────────┬─────────┐
│n        │s        │w        │e        │
│         │         │         │         │
├─────────┼─────────┼─────────┼─────────┤
│n        │s        │w        │e        │
│         │         │         │         │
└─────────┴─────────┴─────────┴─────────┘

#draw calign table {2} {2} {8} {42} {n;s;w;e} {n;s;w;e}; produces:

┌────────┐┌────────┐┌────────┐┌────────┐
│   n    ││   s    ││   w    ││   e    │
└────────┘└────────┘└────────┘└────────┘
┌────────┐┌────────┐┌────────┐┌────────┐
│   n    ││   s    ││   w    ││   e    │
└────────┘└────────┘└────────┘└────────┘

I also noticed that the tables are different heights.

I am new to TinTin++ and it is quite possible that I am just using the command incorrectly. I would be very grateful for any help.

scandum commented 3 months ago

Hi there,

The grid table code could definitely use some more work. I've added calign to my todo list, but due to complexities involved it may not be an easy fix.

I don't think there's a good solution for the height difference?

peddn commented 3 months ago

If you think about it more closely, this is certainly not a trivial problem. It would be great to have the grid table with centered text.

My first attempt for a workaround was to add the leading and trailing spaces to the string for the cell content, but it seems that these spaces are automatically removed. So now I just use '#draw calign line' for the cell contents and hard-code the positions and width.

Regarding the height of the tables, I couldn't think of a reasonable solution to make sure that both table types have the same height. After thinking about it for a while, I'm also not sure whether this feature is needed at all...

I would also like to take this opportunity to express my thanks for such wonderful open source software. Please keep up the great work.

scandum commented 3 months ago

I initially thought it was part of the grid code being a bit quirky, but this actually turned out to be a bug that was easy to fix. Tintin was accidentally removing the calign flag in the grid code.

Centering and a few other formatting options should now work in the beta source code:

https://mudhalla.net/tintin-beta.tar.gz