aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2025-06-09 07:19:07 +0000
committerDaniel Eklöf <daniel@ekloef.se>2025-06-10 05:12:53 +0000
commit968bc05c32a2e68282fd28e840b06ac63556d82e (patch)
treef819b0e668e3153a44d9f6ac1f31cf46086ed936
parentosc: 52: clear selection if the payload is the empty string (diff)
csi: add '52' to the DA reply, to indicate PSC-52 support
Note: only *copy* is required to be enabled in security.osc52; paste is optional, see https://github.com/contour-terminal/contour/issues/1761#issuecomment-2944492097
-rw-r--r--CHANGELOG.md3
-rw-r--r--csi.c17
2 files changed, 13 insertions, 7 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 329a7650..5a6cf6a9 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -115,6 +115,9 @@
* Drop required version of libxkbcommon from 1.8.0 back to 1.0.0
([#2103][2103]).
* OSC-52: an empty payload now clears the clipboard.
+* DA (Device Attributes): include `52` in the reply, to indicate
+ OSC-52 support (when at least _copy_ has been enabled in
+ `security.osc52`).
[1846]: https://codeberg.org/dnkl/foot/issues/1846
[2103]: https://codeberg.org/dnkl/foot/issues/2103
diff --git a/csi.c b/csi.c
index 6d4845be..437fd8bc 100644
--- a/csi.c
+++ b/csi.c
@@ -850,6 +850,7 @@ csi_dispatch(struct terminal *term, uint8_t final)
* - 22 ANSI color, e.g., VT525.
* - 28 Rectangular editing.
* - 29 ANSI text locator (i.e., DEC Locator mode).
+ * - 52 Clipboard access
*
* Note: we report ourselves as a VT220, mainly to be able
* to pass parameters, to indicate we support sixel, and
@@ -860,13 +861,15 @@ csi_dispatch(struct terminal *term, uint8_t final)
*
* Note: tertiary DA responds with "FOOT".
*/
- if (term->conf->tweak.sixel) {
- static const char reply[] = "\033[?62;4;22;28c";
- term_to_slave(term, reply, sizeof(reply) - 1);
- } else {
- static const char reply[] = "\033[?62;22;28c";
- term_to_slave(term, reply, sizeof(reply) - 1);
- }
+ char reply[32];
+
+ int len = snprintf(
+ reply, sizeof(reply), "\033[?62%s;22;28%sc",
+ term->conf->tweak.sixel ? ";4" : "",
+ (term->conf->security.osc52 == OSC52_ENABLED ||
+ term->conf->security.osc52 == OSC52_COPY_ENABLED ? ";52" : ""));
+
+ term_to_slave(term, reply, len);
break;
}