-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The cell width should be calculated using the data when applying a formatter
#2
Comments
Hi @koffeinfrei , author of Tabulo here. Just to clarify, Tabulo has two distinct concepts in this space: the formatter; and the styler. These are configurable as distinct options when initializing a table column. The formatter's output is taken into account for the width calculations. For example, a formatter for displaying dollar amounts might turn an integer From what I can see, this behaviour around the formatter option is the same in Tablo.
I gather this is also the same as in Tabulo, where numbers are right-aligned by default, and strings are left-aligned by default, and the formatter option doesn't affect whether something is regarded as a number or a string for the purpose of determining its default left/right/centre alignment. I believe that's what this documentation comment is referring to—only that. Let's now consider the case where one wants to make that string Prior to v1.5.0, Tabulo did not have a distinct styler option, meaning that it was not possible to apply ANSI sequences to render colours etc. without breaking the width calculations and hence the table layout. The point of As far as I can see, Tablo does not have a similar "styler" mechanism; though perhaps I am wrong, as I am not too familiar with this library. |
👋 @matt-harvey Thanks for your thorough explanation! |
Hi, So, in its current version, Tablo does not have a style option. This feature is definitely very useful and I think that when I find time to work on the Tablo project again, I will put it on the top of the 'to do' pile! In the meantime, if necessary, it is always possible to work around the missing style option by using a trick, such as the (ugly, but working) code below:
|
The documentation
suggests that the value from the
fomatter
does not influence the calculation / alignment of the cell.When using a formatter to output the value with a color (using Crystal's
Colorize
) the cell width is not calculated based on the data value, but based on the value provided by theformatter
.Expected output:
Actual output:
Tabulo also mentions this:
Is this the intended behaviour for tablo as well? If so the width calculation should be based on the data value instead of the formatted value.
The text was updated successfully, but these errors were encountered: