mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-04-08 08:20:59 -04:00
url-mode: initial support for OSC-8 URLs
Things left to do: since OSC-8 URLs are stored as ranges in the per-row ‘extra’ data member, we currently do not handle line-wrapping URLs very well; they will be considered two separate URLs, and assigned two different key sequences.
This commit is contained in:
parent
b55f6925d3
commit
39c5057d49
1 changed files with 31 additions and 0 deletions
31
url-mode.c
31
url-mode.c
|
|
@ -355,11 +355,42 @@ auto_detected(const struct terminal *term, enum url_action action, url_list_t *u
|
||||||
|
|
||||||
UNIGNORE_WARNINGS
|
UNIGNORE_WARNINGS
|
||||||
|
|
||||||
|
static void
|
||||||
|
osc8_uris(const struct terminal *term, enum url_action action, url_list_t *urls)
|
||||||
|
{
|
||||||
|
for (int r = 0; r < term->rows; r++) {
|
||||||
|
const struct row *row = grid_row_in_view(term->grid, r);
|
||||||
|
|
||||||
|
if (row->extra == NULL)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
tll_foreach(row->extra->uri_ranges, it) {
|
||||||
|
struct coord start = {
|
||||||
|
.col = it->item.start,
|
||||||
|
.row = r + term->grid->view,
|
||||||
|
};
|
||||||
|
struct coord end = {
|
||||||
|
.col = it->item.end,
|
||||||
|
.row = r + term->grid->view,
|
||||||
|
};
|
||||||
|
tll_push_back(
|
||||||
|
*urls,
|
||||||
|
((struct url){
|
||||||
|
.url = xstrdup(it->item.uri),
|
||||||
|
.text = xwcsdup(L""),
|
||||||
|
.start = start,
|
||||||
|
.end = end,
|
||||||
|
.action = action}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
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);
|
auto_detected(term, action, urls);
|
||||||
|
osc8_uris(term, action, 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