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:
Daniel Eklöf 2021-02-06 11:51:58 +01:00
parent 6726494f4c
commit 2c10a147ea
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
6 changed files with 61 additions and 1 deletions

View file

@ -12,6 +12,7 @@ static inline bool urls_mode_is_active(const struct terminal *term)
}
void urls_collect(struct terminal *term, enum url_action action);
void urls_tag_cells(struct terminal *term);
void urls_reset(struct terminal *term);
void urls_input(struct seat *seat, struct terminal *term, uint32_t key,