/* this is default, may be later reduced */
cl->width = st->width_max;
- /* enlarge to minimal width */
+ /* enlarge to minimal width (usually header width) */
if (cl->width <= st->width_min && !scols_column_is_strict_width(cl))
cl->width = st->width_min;
- /* use absolute size for large columns */
- else if (cl->width_hint >= 1 && cl->width < (size_t) cl->width_hint
+ /* use absolute width if specified (usually "strictwidth" columns) */
+ else if (cl->width_hint >= 1
+ && cl->width < (size_t) cl->width_hint
&& st->width_min < (size_t) cl->width_hint)
cl->width = (size_t) cl->width_hint;
}
}
+ if (width < tb->outwidth) {
+ DBG(TAB, ul_debugobj(tb, " enlarge (absolute, available %zu)",
+ tb->outwidth - width));
+
+ /* try enlarging all columns with absolute hint */
+ while (width < tb->outwidth) {
+ int changed = 0;
+
+ scols_reset_iter(&itr, SCOLS_ITER_BACKWARD);
+ while (scols_table_next_column(tb, &itr, &cl) == 0) {
+ if (scols_column_is_hidden(cl))
+ continue;
+ if (cl->width_hint < 1.0)
+ continue;
+ if (cl->width >= (size_t) cl->width_hint)
+ continue;
+ DBG(COL, ul_debugobj(cl, " add +1 (%s)",
+ cl->header.data));
+ cl->width++;
+ width++;
+ changed++;
+ if (width == tb->outwidth)
+ break;
+ }
+ if (!changed)
+ break;
+ }
+
+ }
if (width < tb->outwidth && scols_table_is_maxout(tb)) {
DBG(TAB, ul_debugobj(tb, " enlarge (max-out, available %zu)",
tb->outwidth - width));
break;
}
}
+
} else if (width < tb->outwidth) {
/* enlarge the last column */
DBG(TAB, ul_debugobj(tb, " enlarge (last column, available %zu)",