commit e9beee55fac609bf1acc351cda8deeedceabc52a from: Omar Polo date: Wed Jul 14 14:05:35 2021 UTC refactor struct vline the new `meta.data' field will be useful for holding completions data. commit - ec9aa1067b075de798424833bb39cf6a090c0608 commit + e9beee55fac609bf1acc351cda8deeedceabc52a blob - 381ab9a8a8c225467b2b9f104565207158c02607 blob + dda99c778de636e6699decfab50640386bda21a7 --- cmd.c +++ cmd.c @@ -210,7 +210,7 @@ cmd_push_button(struct buffer *buffer) vl = buffer->current_line; switch (vl->parent->type) { case LINE_LINK: - load_url_in_tab(current_tab(), vl->parent->alt); + load_url_in_tab(current_tab(), vl->parent->meta.alt); break; case LINE_PRE_START: l = TAILQ_NEXT(vl->parent, lines); @@ -234,7 +234,7 @@ cmd_push_button_new_tab(struct buffer *buffer) if (vl->parent->type != LINE_LINK) return; - new_tab(vl->parent->alt); + new_tab(vl->parent->meta.alt); } void blob - 8b8a92a48cac80d5083135f3efd334bb7d6bfe80 blob + 4ca5f64caf3fd6fcf122bebaa542def8504bfa0d --- gemtext.c +++ gemtext.c @@ -79,7 +79,7 @@ emit_line(struct parser *p, enum line_type type, char l->type = type; l->line = line; - l->alt = alt; + l->meta.alt = alt; switch (l->type) { case LINE_PRE_START: blob - 8debbe52919cb97db7f39fdfc2c43aac905d1ade blob + f97dddd629617a69605a31bd5a4b8064fc20be9a --- telescope.h +++ telescope.h @@ -93,7 +93,10 @@ enum line_type { struct line { enum line_type type; char *line; - char *alt; + union { + char *alt; + void *data; + } meta; int flags; TAILQ_ENTRY(line) lines; }; blob - 3a02679bff017dd46a087543b13dde9b8b38d0a4 blob + 349d0667ece6ee7e363915b11c0dd12740745f4f --- ui.c +++ ui.c @@ -814,7 +814,8 @@ do_redraw_echoarea(void) tab = current_tab(); if (tab->buffer.current_line != NULL && tab->buffer.current_line->parent->type == LINE_LINK) - waddstr(echoarea, tab->buffer.current_line->parent->alt); + waddstr(echoarea, + tab->buffer.current_line->parent->meta.alt); } } @@ -926,7 +927,7 @@ emit_help_item(char *prfx, void *fn) abort(); l->type = LINE_TEXT; - l->alt = NULL; + l->meta.alt = NULL; asprintf(&l->line, "%s %s", prfx, cmd->cmd); blob - 33405b9289543ae349b444af2c524cc0a12e068d blob + 650ba05127cb54a9873dbb6639847a2a719cf4f5 --- wrap.c +++ wrap.c @@ -51,7 +51,11 @@ empty_linelist(struct buffer *buffer) TAILQ_FOREACH_SAFE(l, &buffer->page.head, lines, lt) { TAILQ_REMOVE(&buffer->page.head, l, lines); free(l->line); - free(l->alt); + + if (l->type != LINE_COMPL && + l->type != LINE_COMPL_CURRENT) + free(l->meta.alt); + free(l); } }