Simple handling for autocomplete and bash history

As long as you are using bash it will always work, not sure for fish and
other shells so I'll leave it to the user to experiment soon, I'll add
another thing to the config.h to do so.
This commit is contained in:
Rekketstone 2025-01-16 07:34:29 -07:00
parent 8b171bbb5a
commit e7cb69fe4b

View File

@ -767,15 +767,23 @@ static void key_press_cb(XKeyEvent *event, void *data) {
} }
if (keysym == XK_Return || keysym == XK_KP_Enter) { if (keysym == XK_Return || keysym == XK_KP_Enter) {
write(*master, "\r", 1); write(*master, "\r", 1); // Shell handles return
} else if (keysym == XK_BackSpace) { } else if (keysym == XK_BackSpace) {
write(*master, "\b", 1); write(*master, "\b", 1); // Shell handles backspace
} else if (keysym == XK_Left) { } else if (keysym == XK_Left) {
write(*master, "\033[D", 3); write(*master, "\033[D", 3);
needs_refresh = 1; needs_refresh = 1;
} else if (keysym == XK_Right) { } else if (keysym == XK_Right) {
write(*master, "\033[C", 3); write(*master, "\033[C", 3);
needs_refresh = 1; needs_refresh = 1;
} else if (keysym == XK_Up) { // Go up through history
write(*master, "\033[A", 3);
needs_refresh = 1;
} else if (keysym == XK_Down) { // Go down through history
write(*master, "\033[B", 3);
needs_refresh = 1;
} else if (keysym == XK_Tab) {
write(*master, "\t", 1); // Shell handles autocomplete
} else if (len > 0) { } else if (len > 0) {
write(*master, buf, len); write(*master, buf, len);
} }