Commit: f796574d3710d49f36df8e5b06b07db5371980dd
Parent: c17496893702a3d46aadad93346b4d810613bd7f
Author: Randy Palamar
Date: Sun, 25 Aug 2024 18:38:07 -0600
support 8-bit input mode
Diffstat:
3 files changed, 20 insertions(+), 9 deletions(-)
diff --git a/terminal.c b/terminal.c
@@ -427,6 +427,10 @@ set_mode(Term *t, CSI *csi, b32 set)
if (!set) t->gl.mode |= WIN_MODE_HIDECURSOR;
else t->gl.mode &= ~WIN_MODE_HIDECURSOR;
break;
+ case PRIV(1034): /* xterm: enable 8-bit input mode */
+ if (set) t->gl.mode |= WIN_MODE_8BIT;
+ else t->gl.mode &= ~WIN_MODE_8BIT;
+ break;
case PRIV(1049): /* xterm: swap cursor then swap screen */
cursor_alt(t, set);
case PRIV(47): /* xterm: swap screen buffer */
diff --git a/util.h b/util.h
@@ -202,6 +202,7 @@ enum win_mode {
WIN_MODE_APPCURSOR = 1 << 0,
WIN_MODE_HIDECURSOR = 1 << 1,
WIN_MODE_BRACKPASTE = 1 << 2,
+ WIN_MODE_8BIT = 1 << 3,
};
enum shader_stages {
diff --git a/vtgl.c b/vtgl.c
@@ -564,15 +564,6 @@ key_callback(GLFWwindow *win, i32 key, i32 sc, i32 act, i32 mods)
}
#endif
- if (mods & GLFW_MOD_CONTROL && key < 0x80) {
- if (act == GLFW_RELEASE)
- return;
- if (BETWEEN(key, 0x40, 0x5F)) {
- os_child_put_char(t->child, key - 0x40);
- return;
- }
- }
-
/* NOTE: handle mapped keybindings */
u32 enc = ENCODE_KEY(act, mods, key);
for (u32 i = 0; i < ARRAY_COUNT(g_hotkeys); i++) {
@@ -584,6 +575,21 @@ key_callback(GLFWwindow *win, i32 key, i32 sc, i32 act, i32 mods)
}
}
+ /* NOTE: send control sequences */
+ if (mods & GLFW_MOD_CONTROL && act != GLFW_RELEASE) {
+ if (t->gl.mode & WIN_MODE_8BIT) {
+ if (key < 0x7F) {
+ s8 enc = utf8_encode(key | 0x80);
+ os_child_put_s8(t->child, enc);
+ return;
+ }
+ } else if (BETWEEN(key, 0x40, 0x5F)) {
+ os_child_put_char(t->child, key - 0x40);
+ return;
+ }
+ }
+
+
switch (ENCODE_KEY(act, 0, key)) {
case ENCODE_KEY(GLFW_PRESS, 0, GLFW_KEY_TAB):
case ENCODE_KEY(GLFW_REPEAT, 0, GLFW_KEY_TAB):