dcs: xtgettcap: handle boolean capabilities

Reply with DCS 1 + r <cap> ST
This commit is contained in:
Daniel Eklöf 2022-01-04 22:01:36 +01:00
parent 7feab6092c
commit 44aad0941f
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
2 changed files with 13 additions and 4 deletions

8
dcs.c
View file

@ -99,6 +99,14 @@ xtgettcap_reply(struct terminal *term, const char *hex_cap_name, size_t len)
if (entry == NULL)
goto err;
if (entry->value == NULL) {
/* Boolean */
term_to_slave(term, "\033P1+r", 5);
term_to_slave(term, hex_cap_name, len);
term_to_slave(term, "\033\\", 2);
goto out;
}
/*
* Reply format:
* \EP 1 + r cap=value \E\\

View file

@ -174,9 +174,6 @@ def main():
'static const struct foot_terminfo_entry terminfo_capabilities[] = {\n')
for cap in sorted(entry.caps.values()):
if isinstance(cap, BoolCapability):
continue
name = cap.name
value = str(cap.value)
@ -194,7 +191,11 @@ def main():
# Do escape ‘“‘
name = name.replace('"', '\"')
value = value.replace('"', '\"')
target.write(f' {{"{name}", "{value}"}},\n')
if isinstance(cap, BoolCapability):
target.write(f' {{"{name}", NULL}},\n')
else:
target.write(f' {{"{name}", "{value}"}},\n')
target.write('};\n')