mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-06 01:40:22 -05:00
urls: OSC-8 URLs can now optionally be underlined outside of url-mode
This patch adds a new configuration option, ‘osc8-underline=url-mode|always’. When set to ‘url-mode’, OSC-8 URLs are only highlighted (i.e. underlined) in url-mode, just like auto-detected URLs. When set to ‘always’, they are always underlined, regardless of mode, and regardless of their other attributes. This is implemented by tagging collected URLs with a boolean, instructing urls_render() and urls_reset() whether they should update the cells’ ‘url’ attribute or not. The OSC-8 collecter sets this based on the value of ‘osc8-underline’. Finally, when closing an OSC-8 URL, the cells are immediately tagged with the ‘url’ attribute if ‘osc8-underline’ is set to ‘always’.
This commit is contained in:
parent
a0b977fcee
commit
2074f8b656
7 changed files with 65 additions and 3 deletions
18
url-mode.c
18
url-mode.c
|
|
@ -374,6 +374,18 @@ UNIGNORE_WARNINGS
|
|||
static void
|
||||
osc8_uris(const struct terminal *term, enum url_action action, url_list_t *urls)
|
||||
{
|
||||
bool dont_touch_url_attr = false;
|
||||
|
||||
switch (term->conf->osc8_underline) {
|
||||
case OSC8_UNDERLINE_URL_MODE:
|
||||
dont_touch_url_attr = false;
|
||||
break;
|
||||
|
||||
case OSC8_UNDERLINE_ALWAYS:
|
||||
dont_touch_url_attr = true;
|
||||
break;
|
||||
}
|
||||
|
||||
for (int r = 0; r < term->rows; r++) {
|
||||
const struct row *row = grid_row_in_view(term->grid, r);
|
||||
|
||||
|
|
@ -396,7 +408,8 @@ osc8_uris(const struct terminal *term, enum url_action action, url_list_t *urls)
|
|||
.url = xstrdup(it->item.uri),
|
||||
.start = start,
|
||||
.end = end,
|
||||
.action = action}));
|
||||
.action = action,
|
||||
.url_mode_dont_change_url_attr = dont_touch_url_attr}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -542,6 +555,9 @@ urls_assign_key_combos(const struct config *conf, url_list_t *urls)
|
|||
static void
|
||||
tag_cells_for_url(struct terminal *term, const struct url *url, bool value)
|
||||
{
|
||||
if (url->url_mode_dont_change_url_attr)
|
||||
return;
|
||||
|
||||
const struct coord *start = &url->start;
|
||||
const struct coord *end = &url->end;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue