mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-23 01:40:12 -05:00
url-mode: underline URLs using the color from colors.urls
This is implemented by allocating one of the (few!) remaining bits in the cells’ attribute struct to indicate the cell should be “URL highlighted”. render_cell() looks at this bit and draws an underline using the color from colors.urls (defaults to regular3 - i.e. yellow). A new function, url_tag_cells(), iterates the currently detected URLs and sets the new ‘url’ attribute flag on the affected cells. Note: this is done in a separate function to keep urls_collect() free from as many dependencies as possible. urls_reset() is updated to *clear* the ‘url’ flag (and thus implicitly also results in a grid refresh, _if_ there were any URLs). We now exit URL mode on *any* client application input. This needs to be so since we can’t know if the URLs we previously detected are still valid.
This commit is contained in:
parent
6726494f4c
commit
2c10a147ea
6 changed files with 61 additions and 1 deletions
9
render.c
9
render.c
|
|
@ -616,6 +616,15 @@ render_cell(struct terminal *term, pixman_image_t *pix,
|
|||
if (cell->attrs.strikethrough)
|
||||
draw_strikeout(term, pix, font, &fg, x, y, cell_cols);
|
||||
|
||||
if (unlikely(cell->attrs.url)) {
|
||||
pixman_color_t url_color = color_hex_to_pixman(
|
||||
term->conf->colors.use_custom.url
|
||||
? term->conf->colors.url
|
||||
: term->colors.table[3]
|
||||
);
|
||||
draw_underline(term, pix, font, &url_color, x, y, cell_cols);
|
||||
}
|
||||
|
||||
draw_cursor:
|
||||
if (has_cursor && (term->cursor_style != CURSOR_BLOCK || !term->kbd_focus))
|
||||
draw_cursor(term, cell, font, pix, &fg, &bg, x, y, cell_cols);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue