mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-30 11:10:23 -04: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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool to_clipboard = false;
|
||||||
|
bool to_primary = false;
|
||||||
|
|
||||||
|
if (target[0] == '\0')
|
||||||
|
to_clipboard = true;
|
||||||
|
|
||||||
for (const char *t = target; *t != '\0'; t++) {
|
for (const char *t = target; *t != '\0'; t++) {
|
||||||
switch (*t) {
|
switch (*t) {
|
||||||
case 'c': {
|
case 'c':
|
||||||
char *copy = strdup(decoded);
|
to_clipboard = true;
|
||||||
if (!text_to_clipboard(term, copy, term->wl->input_serial))
|
|
||||||
free(copy);
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
case 's':
|
case 's':
|
||||||
case 'p': {
|
case 'p':
|
||||||
char *copy = strdup(decoded);
|
to_primary = true;
|
||||||
if (!text_to_primary(term, copy, term->wl->input_serial))
|
|
||||||
free(copy);
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
LOG_WARN("unimplemented: clipboard target '%c'", *t);
|
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);
|
free(decoded);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -122,13 +134,15 @@ from_clipboard_done(void *user)
|
||||||
static void
|
static void
|
||||||
osc_from_clipboard(struct terminal *term, const char *source)
|
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++) {
|
for (const char *s = source; *s != '\0'; s++) {
|
||||||
if (*s == 'c' || *s == 'p' || *s == 's') {
|
if (*s == 'c' || *s == 'p' || *s == 's') {
|
||||||
src = *s;
|
src = *s;
|
||||||
break;
|
break;
|
||||||
}
|
} else
|
||||||
|
LOG_WARN("unimplemented: clipboard source '%c'", *s);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (src == 0)
|
if (src == 0)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue