osc: 176 (app-id): implement query+reply

Applications can now query for the current app-id with:

    \E] 176 ; ? \E\\

The reply is

    \E] 176 ; <title> \E\\
This commit is contained in:
Daniel Eklöf 2024-02-06 13:55:30 +01:00
parent 0b95e72073
commit 4b075bb075
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

12
osc.c
View file

@ -917,6 +917,18 @@ osc_dispatch(struct terminal *term)
break;
case 176:
if (string[0] == '?' && string[1] == '\0') {
const char *terminator = term->vt.osc.bel ? "\a" : "\033\\";
char *reply = xasprintf(
"\033]176;%s%s",
term->app_id != NULL ? term->app_id : term->conf->app_id,
terminator);
term_to_slave(term, reply, strlen(reply));
free(reply);
break;
}
term_set_app_id(term, string);
break;