mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-05 04:06:08 -05:00
osc: parse OSC-8, by calling term_osc8_{open,close} as appropriate
This commit is contained in:
parent
682494d45a
commit
b55f6925d3
1 changed files with 43 additions and 0 deletions
43
osc.c
43
osc.c
|
|
@ -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 */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue