vtgl

terminal emulator implemented in OpenGL
git clone anongit@rnpnr.xyz:vtgl.git
Log | Files | Refs | Feed | LICENSE

Commit: 6bfd5ccf1c1e40677b1b5a8d39eff986b75c4d62
Parent: ab9b90435bdfc1d7880a1ff6798a447f7e576a7f
Author: Randy Palamar
Date:   Mon, 19 Aug 2024 23:19:34 -0600

clipboard text pasting

Diffstat:
Mconfig.def.h | 4+++-
Mvtgl.c | 10++++++++++
2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/config.def.h b/config.def.h @@ -36,7 +36,8 @@ struct { typedef KEYBIND_FN(KeyBind_Fn); /* NOTE: Bindable Functions */ -KEYBIND_FN(zoom); /* arg: .i = font size increment */ +KEYBIND_FN(paste); /* arg: none */ +KEYBIND_FN(zoom); /* arg: .i = font size increment */ #define MODKEY (GLFW_MOD_ALT) #define TERMMOD (GLFW_MOD_CONTROL|GLFW_MOD_SHIFT) @@ -48,6 +49,7 @@ struct hotkey { KeyBind_Fn *fn; Arg arg; } g_hotkeys[] = { + {ENCODE_KEY(GLFW_PRESS, MODKEY, GLFW_KEY_V), paste, {0}}, {ENCODE_KEY(GLFW_PRESS, TERMMOD, GLFW_KEY_MINUS), zoom, {.i = -1}}, {ENCODE_KEY(GLFW_REPEAT, TERMMOD, GLFW_KEY_MINUS), zoom, {.i = -1}}, {ENCODE_KEY(GLFW_PRESS, TERMMOD, GLFW_KEY_EQUAL), zoom, {.i = +1}}, diff --git a/vtgl.c b/vtgl.c @@ -297,6 +297,16 @@ render_framebuffer(Term *t, RenderPushBuffer *rpb) } } +KEYBIND_FN(paste) +{ + s8 text = {.data = (u8 *)glfwGetClipboardString(0)}; + if (text.data) { + for (u8 *t = text.data; *t; t++) + text.len++; + os_child_put_s8(t->child, text); + } +} + KEYBIND_FN(zoom) { shift_font_sizes(&t->fa, a.i);