In a first pass, for each pillar it is decided in which tier it is shown,
if at all, and how much horizontal space it may use (either its minimum
or its maximum width). More than one tier may be created if
width > getOption("width")
, in this case each tier is at most
getOption("width")
characters wide.
Remaining space is then distributed proportionally to pillars that do not
use their desired width.
For fitting pillars in one or more tiers, it is first attempted to fit all
of them in the first tier.
If this succeeds (or if no more tiers are available), this fit is
accepted.
Otherwise, an attempt is made to fit all remaining pillars in the remaining
tiers (with a recursive call).
If there still are pillars that don't fit, the minimum-width fit is accepted.
In case all remaining pillars fit all remaining tiers, a heuristic
selects the optimal number of pillars in the first tier.
The tier is grown starting with all pillars that are fitting with their
desired width (at least one pillar will be used), and
attempts are made to fit the remaining pillars in the remaining tiers
(with a recursive call for each attempt).
The first successful fit
(or otherwise the initial minimum-width fit) is accepted.
For computing the pillar widths in a single tier, two cases are distinguished:
When taking the minimum width for each pillar (plus one inter-pillar
space), at least one pillar does not fit.
In this case, the minimum width is assigned to all pillars that do fit,
the non-fitting pillars are stripped.
All pillars fit with their minimum width. In this case, starting at
the leftmost pillar, the maximum width is allocated to the pillars
until all available space is used.
The remaining space is distributed from left to right.
Each column gains space proportional to the fraction of missing and
remaining space,
rounded down.
Any space remaining after rounding is distributed from left to right,
one space per column.