> > tabular claims that each column is padded to at least the minimum
> width required by any of its lines, but its actual behavior is that
> lines without an explicit width are also padded to at most the maximum
> width required by any line. The table may be narrower than width,
> whereas columnar is always at least as wide as width unless all widths
> are specified. This behavior should be documented.
>
> I didn't follow this?
In Chibi, if width is 30, tabular may print a table that is narrower
than 30 characters. This differentiates it from columnar, which always
expands to use the full width. But the document doesn't specify this.
The document only says that each column is expanded to *at minimum* the
width of the longest line. It says nothing about the maximum.
Technically, an implementation of tabular that is identical to columnar,
except that columns expand when their contents overflow, would match the
description in the document. But I'm guessing that wasn't your intention.
That is the intention and essentially what the sample implementation does.
It's a thin wrapper around `columnar' which checks the max line widths of finite
columns and increases the column width if it would overflow. Like `columnar',
it doesn't _enforce_ the width if this would exceed the current terminal width.
Note that `columnar' also does not expand to the full width if all column widths
are explicitly specified. Since they are always specified with `tabular', tabular
will not in general expand to the full terminal width.
I'll add some clarifying notes here.
Hmm. You're right, this is more clearly specified than I thought. But
I'm not sure if Chibi's behavior matches this description.
Some examples with fullwidth letters: Based on the description,
(substring-terminal-width "foo" 1 4) should return "o", because the
first index exceeding 1 is 2. But, in Chibi, it returns "fo", even
though the index of "f" (0) precedes from (1).
The cumulative string widths of the 3 characters are: 2, 4, 6.
The first index for which the string width exceeds (>) 1 is 0 (the full-width "f").
The first index for which the string width exceeds 4 is 2 (width 6), since
"fo" is 4 columns in the terminal, whereas "foo" is 6.
So the result should be (substring "foo" 0 2), and Chibi is correct.
(substring-terminal-width "foo" 2 5) should return "oo", because the
first index exceeding 5, exclusive, is 6. But, in Chibi, it returns "o".
The first index exceeding 2 is 1 (width 4). The first index exceeding 5 is 2 (width 6).
Therefore the result should be (substring "foo" 1 2), and Chibi is correct.
--
Alex