mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-05 04:06:08 -05:00
osc 52: default to 'clipboard' if no source/target has been specified
This commit is contained in:
parent
2956a7d472
commit
b58fd1c205
1 changed files with 26 additions and 12 deletions
38
osc.c
38
osc.c
|
|
@ -26,22 +26,22 @@ osc_to_clipboard(struct terminal *term, const char *target,
|
|||
return;
|
||||
}
|
||||
|
||||
bool to_clipboard = false;
|
||||
bool to_primary = false;
|
||||
|
||||
if (target[0] == '\0')
|
||||
to_clipboard = true;
|
||||
|
||||
for (const char *t = target; *t != '\0'; t++) {
|
||||
switch (*t) {
|
||||
case 'c': {
|
||||
char *copy = strdup(decoded);
|
||||
if (!text_to_clipboard(term, copy, term->wl->input_serial))
|
||||
free(copy);
|
||||
case 'c':
|
||||
to_clipboard = true;
|
||||
break;
|
||||
}
|
||||
|
||||
case 's':
|
||||
case 'p': {
|
||||
char *copy = strdup(decoded);
|
||||
if (!text_to_primary(term, copy, term->wl->input_serial))
|
||||
free(copy);
|
||||
case 'p':
|
||||
to_primary = true;
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
LOG_WARN("unimplemented: clipboard target '%c'", *t);
|
||||
|
|
@ -49,6 +49,18 @@ osc_to_clipboard(struct terminal *term, const char *target,
|
|||
}
|
||||
}
|
||||
|
||||
if (to_clipboard) {
|
||||
char *copy = strdup(decoded);
|
||||
if (!text_to_clipboard(term, copy, term->wl->input_serial))
|
||||
free(copy);
|
||||
}
|
||||
|
||||
if (to_primary) {
|
||||
char *copy = strdup(decoded);
|
||||
if (!text_to_primary(term, copy, term->wl->input_serial))
|
||||
free(copy);
|
||||
}
|
||||
|
||||
free(decoded);
|
||||
}
|
||||
|
||||
|
|
@ -122,13 +134,15 @@ from_clipboard_done(void *user)
|
|||
static void
|
||||
osc_from_clipboard(struct terminal *term, const char *source)
|
||||
{
|
||||
char src = 0;
|
||||
/* Use clipboard if no source has been specified */
|
||||
char src = source[0] == '\0' ? 'c' : 0;
|
||||
|
||||
for (const char *s = source; *s != '\0'; s++) {
|
||||
if (*s == 'c' || *s == 'p' || *s == 's') {
|
||||
src = *s;
|
||||
break;
|
||||
}
|
||||
} else
|
||||
LOG_WARN("unimplemented: clipboard source '%c'", *s);
|
||||
}
|
||||
|
||||
if (src == 0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue