format-table: add new table_get_current_column() helper

This commit is contained in:
Lennart Poettering
2023-10-20 15:57:25 +01:00
committed by Luca Boccassi
parent f4ae435bec
commit 07f314575b
2 changed files with 10 additions and 0 deletions
+8
View File
@@ -2577,6 +2577,14 @@ size_t table_get_columns(Table *t) {
return t->n_columns;
}
size_t table_get_current_column(Table *t) {
if (!t)
return 0;
assert(t->n_columns > 0);
return t->n_cells % t->n_columns;
}
int table_set_reverse(Table *t, size_t column, bool b) {
assert(t);
assert(column < t->n_columns);
+2
View File
@@ -141,6 +141,8 @@ static inline TableCell* TABLE_HEADER_CELL(size_t i) {
size_t table_get_rows(Table *t);
size_t table_get_columns(Table *t);
size_t table_get_current_column(Table *t);
TableCell *table_get_cell(Table *t, size_t row, size_t column);
const void *table_get(Table *t, TableCell *cell);