aboutsummaryrefslogtreecommitdiff
path: root/input.c
diff options
context:
space:
mode:
authorThomas Adam <thomas@xteddy.org>2022-06-30 16:37:18 +0100
committerThomas Adam <thomas@xteddy.org>2022-06-30 16:37:18 +0100
commit01c4919f5f86d7c120451ae642e722ea7d9651d7 (patch)
tree588d4883507ab85ad5e51181a548346da7c86c20 /input.c
parentd8c527a5f9fc06ea15a7d04f3a54a9e49cebae62 (diff)
parentcdacc12ce305ad2f3e65e2a01328a988e3200b51 (diff)
downloadrtmux-01c4919f5f86d7c120451ae642e722ea7d9651d7.tar.gz
rtmux-01c4919f5f86d7c120451ae642e722ea7d9651d7.tar.bz2
rtmux-01c4919f5f86d7c120451ae642e722ea7d9651d7.zip
Merge branch 'obsd-master'
Diffstat (limited to 'input.c')
-rw-r--r--input.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/input.c b/input.c
index d4ffe784..4252428b 100644
--- a/input.c
+++ b/input.c
@@ -135,6 +135,7 @@ static void input_set_state(struct input_ctx *,
static void input_reset_cell(struct input_ctx *);
static void input_osc_4(struct input_ctx *, const char *);
+static void input_osc_8(struct input_ctx *, const char *);
static void input_osc_10(struct input_ctx *, const char *);
static void input_osc_11(struct input_ctx *, const char *);
static void input_osc_12(struct input_ctx *, const char *);
@@ -2318,6 +2319,9 @@ input_exit_osc(struct input_ctx *ictx)
}
}
break;
+ case 8:
+ input_osc_8(ictx, p);
+ break;
case 10:
input_osc_10(ictx, p);
break;
@@ -2562,6 +2566,47 @@ input_osc_4(struct input_ctx *ictx, const char *p)
free(copy);
}
+/* Handle the OSC 8 sequence for embedding hyperlinks. */
+static void
+input_osc_8(struct input_ctx *ictx, const char *p)
+{
+ struct hyperlinks *hl = ictx->ctx.s->hyperlinks;
+ struct grid_cell *gc = &ictx->cell.cell;
+ const char *start, *end, *uri;
+ char *id = NULL;
+
+ for (start = p; (end = strpbrk(start, ":;")) != NULL; start = end + 1) {
+ if (end - start >= 4 && strncmp(start, "id=", 3) == 0) {
+ if (id != NULL)
+ goto bad;
+ id = xstrndup(start + 3, end - start - 3);
+ }
+
+ /* The first ; is the end of parameters and start of the URI. */
+ if (*end == ';')
+ break;
+ }
+ if (end == NULL || *end != ';')
+ goto bad;
+ uri = end + 1;
+ if (*uri == '\0') {
+ gc->link = 0;
+ free(id);
+ return;
+ }
+ gc->link = hyperlinks_put(hl, uri, id);
+ if (id == NULL)
+ log_debug("hyperlink (anonymous) %s = %u", uri, gc->link);
+ else
+ log_debug("hyperlink (id=%s) %s = %u", id, uri, gc->link);
+ free(id);
+ return;
+
+bad:
+ log_debug("bad OSC 8 %s", p);
+ free(id);
+}
+
/* Handle the OSC 10 sequence for setting and querying foreground colour. */
static void
input_osc_10(struct input_ctx *ictx, const char *p)