mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-04-05 07:15:30 -04:00
url-mode: remove duplicate URLs
Remove URLs with the same start and end coordinates. Such duplicate URLs can be created by emitting an OSC-8 URL with matching grid content: \E]8;;http://foo\E\\http://foo\E]8;;\E\\
This commit is contained in:
parent
d44cda11bf
commit
cf651d361f
1 changed files with 24 additions and 1 deletions
25
url-mode.c
25
url-mode.c
|
|
@ -396,12 +396,35 @@ osc8_uris(const struct terminal *term, enum url_action action, url_list_t *urls)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
remove_duplicates(url_list_t *urls)
|
||||||
|
{
|
||||||
|
tll_foreach(*urls, outer) {
|
||||||
|
tll_foreach(*urls, inner) {
|
||||||
|
if (outer == inner)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (outer->item.start.row == inner->item.start.row &&
|
||||||
|
outer->item.start.col == inner->item.start.col &&
|
||||||
|
outer->item.end.row == inner->item.end.row &&
|
||||||
|
outer->item.end.col == inner->item.end.col)
|
||||||
|
{
|
||||||
|
free(inner->item.url);
|
||||||
|
free(inner->item.text);
|
||||||
|
free(inner->item.key);
|
||||||
|
tll_remove(*urls, inner);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
urls_collect(const struct terminal *term, enum url_action action, url_list_t *urls)
|
urls_collect(const struct terminal *term, enum url_action action, url_list_t *urls)
|
||||||
{
|
{
|
||||||
xassert(tll_length(term->urls) == 0);
|
xassert(tll_length(term->urls) == 0);
|
||||||
auto_detected(term, action, urls);
|
|
||||||
osc8_uris(term, action, urls);
|
osc8_uris(term, action, urls);
|
||||||
|
auto_detected(term, action, urls);
|
||||||
|
remove_duplicates(urls);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void url_destroy(struct url *url);
|
static void url_destroy(struct url *url);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue