aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2021-02-13 11:41:57 +0000
committerDaniel Eklöf <daniel@ekloef.se>2021-02-21 19:14:51 +0000
commitb55f6925d360dcb8109b90b266c0e9c2fc625b0c (patch)
treeef762e2460cc2cbcf8c4b8c420c8a502c4e6d323
parentterminal: add term_osc8_{open,close} functions (diff)
osc: parse OSC-8, by calling term_osc8_{open,close} as appropriate
-rw-r--r--osc.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/osc.c b/osc.c
index 801b04e9..2f1cfe2b 100644
--- a/osc.c
+++ b/osc.c
@@ -377,6 +377,45 @@ osc_set_pwd(struct terminal *term, char *string)
}
static void
+osc_uri(struct terminal *term, char *string)
+{
+ /*
+ * \E]8;<params>;URI\e\\
+ *
+ * Params are key=value pairs, separated by ‘:’.
+ *
+ * The only defined key (as of 2020-05-31) is ‘id’, which is used
+ * to group split-up URIs:
+ *
+ * ╔═ file1 ════╗
+ * ║ ╔═ file2 ═══╗
+ * ║http://exa║Lorem ipsum║
+ * ║le.com ║ dolor sit ║
+ * ║ ║amet, conse║
+ * ╚══════════║ctetur adip║
+ * ╚═══════════╝
+ *
+ * This lets a terminal emulator highlight both parts at the same
+ * time (e.g. when hovering over one of the parts with the mouse).
+ */
+
+ const char *params = string;
+ char *params_end = strchr(params, ';');
+ if (params_end == NULL)
+ return;
+
+ *params_end = '\0';
+ const char *uri = params_end + 1;
+
+ LOG_DBG("params=%s, URI=%s", params, uri);
+
+ if (uri[0] == '\0')
+ term_osc8_close(term);
+ else
+ term_osc8_open(term, uri);
+}
+
+static void
osc_notify(struct terminal *term, char *string)
{
/*
@@ -553,6 +592,10 @@ osc_dispatch(struct terminal *term)
osc_set_pwd(term, string);
break;
+ case 8:
+ osc_uri(term, string);
+ break;
+
case 10:
case 11: {
/* Set default foreground/background color */