format-table: add an API for getting the cell at a specific row/column

This commit is contained in:
Lennart Poettering 2018-11-08 21:21:09 +01:00
parent 27e730e6d0
commit 9314ead785
2 changed files with 17 additions and 0 deletions

View File

@ -1370,3 +1370,18 @@ int table_set_reverse(Table *t, size_t column, bool b) {
t->reverse_map[column] = b;
return 0;
}
TableCell *table_get_cell(Table *t, size_t row, size_t column) {
size_t i;
assert(t);
if (column >= t->n_columns)
return NULL;
i = row * t->n_columns + column;
if (i >= t->n_cells)
return NULL;
return TABLE_INDEX_TO_CELL(i);
}

View File

@ -66,3 +66,5 @@ static inline TableCell* TABLE_HEADER_CELL(size_t i) {
size_t table_get_rows(Table *t);
size_t table_get_columns(Table *t);
TableCell *table_get_cell(Table *t, size_t row, size_t column);