return 1;
next = list_entry(cl->cl_columns.next, struct libscols_column, cl_columns);
- if (next && scols_column_is_hidden(next))
+ if (next && scols_column_is_hidden(next) && is_last_column(next))
return 1;
return 0;
}
size_t len = 0, i, width, bytes;
const char *color = NULL;
char *data, *wrapnl;
+ int is_last;
assert(tb);
assert(cl);
if (!data)
data = "";
+ is_last = is_last_column(cl);
+
switch (tb->format) {
case SCOLS_FMT_RAW:
fputs_nonblank(data, tb->out);
- if (!is_last_column(cl))
+ if (!is_last)
fputs(colsep(tb), tb->out);
return 0;
case SCOLS_FMT_EXPORT:
fprintf(tb->out, "%s=", scols_cell_get_data(&cl->header));
fputs_quoted(data, tb->out);
- if (!is_last_column(cl))
+ if (!is_last)
fputs(colsep(tb), tb->out);
return 0;
fputs("null", tb->out);
else
fputs_quoted_json(data, tb->out);
- if (!is_last_column(cl))
+ if (!is_last)
fputs(", ", tb->out);
return 0;
len = mbs_safe_nwidth(data, bytes, NULL);
}
- if (is_last_column(cl)
+ if (is_last
&& len < width
&& !scols_table_is_maxout(tb)
&& !scols_column_is_right(cl))
for (i = len; i < width; i++)
fputs(cellpadding_symbol(tb), tb->out); /* padding */
- if (is_last_column(cl))
+ if (is_last)
return 0;
if (len > width && !scols_column_is_trunc(cl))
while (rc == 0 && scols_table_next_column(tb, &itr, &cl) == 0) {
if (scols_column_is_hidden(cl))
continue;
-
if (cl->pending_data) {
rc = print_pending_data(tb, cl, ln, scols_line_get_cell(ln, cl->seqnum));
if (rc == 0 && cl->pending_data)
static void dbg_column(struct libscols_table *tb, struct libscols_column *cl)
{
if (scols_column_is_hidden(cl)) {
- DBG(COL, ul_debugobj(cl, "%s ignored", cl->header.data));
+ DBG(COL, ul_debugobj(cl, "%s (hidden) ignored", cl->header.data));
return;
}
*/
scols_reset_iter(&itr, SCOLS_ITER_FORWARD);
while (scols_table_next_column(tb, &itr, &cl) == 0) {
+ int is_last;
+
+ if (scols_column_is_hidden(cl))
+ continue;
rc = count_column_width(tb, cl, buf);
if (rc)
goto done;
- width += cl->width + (is_last_column(cl) ? 0 : 1); /* separator for non-last column */
- width_min += cl->width_min + (is_last_column(cl) ? 0 : 1);
+ is_last = is_last_column(cl);
+
+ width += cl->width + (is_last ? 0 : 1); /* separator for non-last column */
+ width_min += cl->width_min + (is_last ? 0 : 1);
extremes += cl->is_extreme;
}
scols_reset_iter(&itr, SCOLS_ITER_FORWARD);
while (width_min > tb->termwidth
&& scols_table_next_column(tb, &itr, &cl) == 0) {
+ if (scols_column_is_hidden(cl))
+ continue;
width_min--;
cl->width_min--;
}
while (scols_table_next_column(tb, &itr, &cl) == 0) {
size_t org_width;
- if (!cl->is_extreme)
+ if (!cl->is_extreme || scols_column_is_hidden(cl))
continue;
org_width = cl->width;
while (scols_table_next_column(tb, &itr, &cl) == 0) {
size_t add;
- if (!cl->is_extreme)
+ if (!cl->is_extreme || scols_column_is_hidden(cl))
continue;
/* this column is too large, ignore?
while (width < tb->termwidth) {
scols_reset_iter(&itr, SCOLS_ITER_FORWARD);
while (scols_table_next_column(tb, &itr, &cl) == 0) {
+ if (scols_column_is_hidden(cl))
+ continue;
cl->width++;
width++;
if (width == tb->termwidth)
DBG(TAB, ul_debugobj(cl, " checking %s (width=%zu, treeart=%zu)",
cl->header.data, cl->width, cl->width_treeart));
-
+ if (scols_column_is_hidden(cl))
+ continue;
if (width <= tb->termwidth)
break;
if (cl->width_hint > 1 && !scols_column_is_trunc(cl))
scols_reset_iter(&itr, SCOLS_ITER_BACKWARD);
while (scols_table_next_column(tb, &itr, &cl) == 0) {
+ if (scols_column_is_hidden(cl))
+ continue;
if (width <= tb->termwidth)
break;
if (width - cl->width < tb->termwidth) {
*/
scols_reset_iter(&itr, SCOLS_ITER_FORWARD);
while (scols_table_next_line(tb, &itr, &ln) == 0) {
- size_t sz = strlen_line(ln) + extra_bufsz;
+ size_t sz;
+
+ sz = strlen_line(ln) + extra_bufsz;
if (sz > bufsz)
bufsz = sz;
}