mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-26 01:40:12 -05:00
grid: enable rows to have ‘extra’ data associated with them
This patch adds an ‘extra’ member to the row struct. It is a pointer to a struct containing extra data to be associated with this row. Initially, this struct contains a list of URL ranges. These define (OSC-8) URLs on this row. The ‘extra’ data is allocated on-demand. I.e. the pointer is NULL by default; it is *not* allocated by grid_row_alloc().
This commit is contained in:
parent
3339915d20
commit
fd87bca102
3 changed files with 44 additions and 4 deletions
9
grid.c
9
grid.c
|
|
@ -33,6 +33,7 @@ grid_row_alloc(int cols, bool initialize)
|
|||
struct row *row = xmalloc(sizeof(*row));
|
||||
row->dirty = false;
|
||||
row->linebreak = false;
|
||||
row->extra = NULL;
|
||||
|
||||
if (initialize) {
|
||||
row->cells = xcalloc(cols, sizeof(row->cells[0]));
|
||||
|
|
@ -50,6 +51,14 @@ grid_row_free(struct row *row)
|
|||
if (row == NULL)
|
||||
return;
|
||||
|
||||
if (row->extra != NULL) {
|
||||
tll_foreach(row->extra->uri_ranges, it) {
|
||||
free(it->item.uri);
|
||||
tll_remove(row->extra->uri_ranges, it);
|
||||
}
|
||||
}
|
||||
|
||||
free(row->extra);
|
||||
free(row->cells);
|
||||
free(row);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue