diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2021-02-13 11:42:35 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2021-02-21 19:14:51 +0000 |
| commit | 39c5057d4963b292651cb23adfd0e1127cf89188 (patch) | |
| tree | 8dd9d61ef652b5a6fd3ea2b40321546ae7553c2f | |
| parent | osc: parse OSC-8, by calling term_osc8_{open,close} as appropriate (diff) | |
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.
| -rw-r--r-- | url-mode.c | 31 |
1 files changed, 31 insertions, 0 deletions
@@ -355,11 +355,42 @@ auto_detected(const struct terminal *term, enum url_action action, url_list_t *u 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 urls_collect(const struct terminal *term, enum url_action action, url_list_t *urls) { xassert(tll_length(term->urls) == 0); auto_detected(term, action, urls); + osc8_uris(term, action, urls); } static void url_destroy(struct url *url); |
