return 0;
}
+/**
+ * scols_column_is_hidden:
+ * @cl: a pointer to a struct libscols_column instance
+ *
+ * Gets the value of @cl's flag hidden.
+ *
+ * Returns: hidden flag value, negative value in case of an error.
+ */
+int scols_column_is_hidden(struct libscols_column *cl)
+{
+ if (!cl)
+ return -EINVAL;
+ return cl->flags & SCOLS_FL_HIDDEN;
+}
+
/**
* scols_column_is_trunc:
* @cl: a pointer to a struct libscols_column instance
SCOLS_FL_RIGHT = (1 << 2), /* align to the right */
SCOLS_FL_STRICTWIDTH = (1 << 3), /* don't reduce width if column is empty */
SCOLS_FL_NOEXTREMES = (1 << 4), /* ignore extreme fields when count column width*/
+ SCOLS_FL_HIDDEN = (1 << 5), /* maintain data, but don't print */
};
extern struct libscols_iter *scols_new_iter(int direction);
extern int scols_column_is_trunc(struct libscols_column *cl);
extern int scols_column_is_right(struct libscols_column *cl);
extern int scols_column_is_strict_width(struct libscols_column *cl);
+extern int scols_column_is_hidden(struct libscols_column *cl);
extern int scols_column_is_noextremes(struct libscols_column *cl);
extern int scols_column_set_flags(struct libscols_column *cl, int flags);
return 1;
next = list_entry(cl->cl_columns.next, struct libscols_column, cl_columns);
- if (next && next->ignore)
+ if (next && scols_column_is_hidden(next))
return 1;
return 0;
}
scols_reset_iter(&itr, SCOLS_ITER_FORWARD);
while (rc == 0 && scols_table_next_column(tb, &itr, &cl) == 0) {
- if (cl->ignore)
+ if (scols_column_is_hidden(cl))
continue;
rc = cell_to_buffer(tb, ln, cl, buf);
if (!rc)
/* set the width according to the size of the data */
scols_reset_iter(&itr, SCOLS_ITER_FORWARD);
while (rc == 0 && scols_table_next_column(tb, &itr, &cl) == 0) {
- if (cl->ignore)
+ if (scols_column_is_hidden(cl))
continue;
rc = buffer_set_data(buf, scols_cell_get_data(&cl->header));
if (!rc)
static void dbg_column(struct libscols_table *tb, struct libscols_column *cl)
{
- if (cl->ignore) {
+ if (scols_column_is_hidden(cl)) {
DBG(COL, ul_debugobj(cl, "%s ignored", cl->header.data));
return;
}
cl->width -= r;
width -= r;
} else {
- cl->ignore = 1;
+ cl->flags |= SCOLS_FL_HIDDEN;
width -= cl->width + 1; /* +1 means separator between columns */
}
}