Commit: a006d6184f4c4bccfc549bf150cda3438a85110b
Parent: 8b63ad912b83a4103f5745d979af7c6a19b93228
Author: Randy Palamar
Date: Sun, 25 Aug 2024 12:55:57 -0600
support bracketed pasting
Diffstat:
3 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/terminal.c b/terminal.c
@@ -402,6 +402,10 @@ set_mode(Term *t, CSI *csi, b32 set)
case PRIV(1048): /* xterm: swap cursor */
cursor_alt(t, set);
break;
+ case PRIV(2004): /* xterm: bracketed paste mode */
+ if (set) t->gl.mode |= WIN_MODE_BRACKPASTE;
+ else t->gl.mode &= ~WIN_MODE_BRACKPASTE;
+ break;
default:
fputs("set_mode: unhandled mode: ", stderr);
dump_csi(csi);
diff --git a/util.h b/util.h
@@ -195,6 +195,7 @@ enum gl_flags {
enum win_mode {
WIN_MODE_APPCURSOR = 1 << 0,
WIN_MODE_HIDECURSOR = 1 << 1,
+ WIN_MODE_BRACKPASTE = 1 << 2,
};
enum shader_stages {
diff --git a/vtgl.c b/vtgl.c
@@ -487,10 +487,14 @@ KEYBIND_FN(copy)
KEYBIND_FN(paste)
{
s8 text = {.data = (u8 *)glfwGetClipboardString(0)};
+ b32 bracketed = t->gl.mode & WIN_MODE_BRACKPASTE;
+ /* TODO: we may need to replace '\n' with '\r' */
if (text.data) {
for (u8 *t = text.data; *t; t++)
text.len++;
+ if (bracketed) os_child_put_s8(t->child, s8("\033[200~"));
os_child_put_s8(t->child, text);
+ if (bracketed) os_child_put_s8(t->child, s8("\033[201~"));
}
return 1;
}