size_t width_min; /* minimal width (usually header width) */
size_t width_max; /* maximal width */
size_t width_avg; /* average width, used to detect extreme fields */
+ size_t width_treeart; /* size of the tree ascii art */
double width_hint; /* hint (N < 1 is in percent of termwidth) */
int flags;
if (len == (size_t) -1) /* ignore broken multibyte strings */
len = 0;
- if (len > cl->width_max)
- cl->width_max = len;
+ cl->width_max = max(len, cl->width_max);
if (cl->is_extreme && len > cl->width_avg * 2)
continue;
sum += len;
count++;
}
- if (len > cl->width)
- cl->width = len;
+ cl->width = max(len, cl->width);
+ if (scols_column_is_tree(cl)) {
+ size_t treewidth = buffer_get_safe_art_size(buf);
+ cl->width_treeart = max(cl->width_treeart, treewidth);
+ }
}
if (count && cl->width_avg == 0) {
scols_reset_iter(&itr, SCOLS_ITER_FORWARD);
while (scols_table_next_column(tb, &itr, &cl) == 0) {
+
+ DBG(TAB, ul_debugobj(cl, " checking %s (width=%zu, treeart=%zu)",
+ cl->header.data, cl->width, cl->width_treeart));
+
if (width <= tb->termwidth)
break;
if (cl->width_hint > 1 && !scols_column_is_trunc(cl))
continue; /* never truncate columns with absolute sizes */
- if (scols_column_is_tree(cl))
+ if (scols_column_is_tree(cl) && width <= cl->width_treeart)
continue; /* never truncate the tree */
if (trunc_only && !scols_column_is_trunc(cl))
continue;