osc: parse OSC-8, by calling term_osc8_{open,close} as appropriate

This commit is contained in:
Daniel Eklöf 2021-02-13 12:41:57 +01:00
parent 682494d45a
commit b55f6925d3
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

43
osc.c
View file

@ -376,6 +376,45 @@ osc_set_pwd(struct terminal *term, char *string)
free(host);
}
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 */