aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2021-02-13 12:44:07 +0000
committerDaniel Eklöf <daniel@ekloef.se>2021-02-21 19:14:52 +0000
commitb934969b858d8874e480cc9ee7f4ccf5657f6f2a (patch)
tree96651be5625e5420d785caa3d8a8441297631120
parentosc: 8: parse params, and the ‘id’ parameter specifically (diff)
term: add ‘id’ parameter to term_osc8_open()
The current OSC-8 URL’s ID is now tracked along with the URI itself, and its starting point.
-rw-r--r--osc.c2
-rw-r--r--terminal.c4
-rw-r--r--terminal.h5
3 files changed, 7 insertions, 4 deletions
diff --git a/osc.c b/osc.c
index fb4f15d6..b57bdd6c 100644
--- a/osc.c
+++ b/osc.c
@@ -433,7 +433,7 @@ osc_uri(struct terminal *term, char *string)
if (uri[0] == '\0')
term_osc8_close(term);
else
- term_osc8_open(term, uri);
+ term_osc8_open(term, id, uri);
}
static void
diff --git a/terminal.c b/terminal.c
index c6afbef1..218882f0 100644
--- a/terminal.c
+++ b/terminal.c
@@ -3016,7 +3016,7 @@ term_ime_set_cursor_rect(struct terminal *term, int x, int y, int width,
}
void
-term_osc8_open(struct terminal *term, const char *uri)
+term_osc8_open(struct terminal *term, uint64_t id, const char *uri)
{
if (unlikely(term->vt.osc8.begin.row < 0)) {
/* It’s valid to switch from one URI to another without
@@ -3028,6 +3028,7 @@ term_osc8_open(struct terminal *term, const char *uri)
.col = term->grid->cursor.point.col,
.row = grid_row_absolute(term->grid, term->grid->cursor.point.row),
};
+ term->vt.osc8.id = id;
term->vt.osc8.uri = xstrdup(uri);
}
@@ -3066,6 +3067,7 @@ term_osc8_close(struct terminal *term)
done:
free(term->vt.osc8.uri);
+ term->vt.osc8.id = 0;
term->vt.osc8.uri = NULL;
term->vt.osc8.begin = (struct coord){-1, -1};
}
diff --git a/terminal.h b/terminal.h
index 6dc211d9..733fc92d 100644
--- a/terminal.h
+++ b/terminal.h
@@ -169,8 +169,9 @@ struct vt {
/* Start coordinate for current OSC-8 URI */
struct {
- struct coord begin;
+ uint64_t id;
char *uri;
+ struct coord begin;
} osc8;
struct {
@@ -690,5 +691,5 @@ void term_ime_set_cursor_rect(
void term_urls_reset(struct terminal *term);
void term_collect_urls(struct terminal *term);
-void term_osc8_open(struct terminal *term, const char *uri);
+void term_osc8_open(struct terminal *term, uint64_t id, const char *uri);
void term_osc8_close(struct terminal *term);