summaryrefslogtreecommitdiffstats
path: root/tty-keys.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2009-07-26 21:42:08 +0000
committerNicholas Marriott <nicm@openbsd.org>2009-07-26 21:42:08 +0000
commit639fbe03922924b70fca7860845590e8c3aa927a (patch)
tree105603ab6f5b743e0faef50913c3b6ac7e02af3d /tty-keys.c
parent55d8c01c339db6dd66ed85ce3da5273632da6ca5 (diff)
Detect backspace by looking at termios VERASE and translate it into \177 (which
matches screen's behaviour if not its termcap/terminfo entry). The terminfo kbs cap is often wrong or missing so it can't be used, and just assuming \177 may be wrong.
Diffstat (limited to 'tty-keys.c')
-rw-r--r--tty-keys.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/tty-keys.c b/tty-keys.c
index 5e207aa6..f25dc169 100644
--- a/tty-keys.c
+++ b/tty-keys.c
@@ -20,6 +20,8 @@
#include <sys/time.h>
#include <string.h>
+#include <termios.h>
+#include <unistd.h>
#include "tmux.h"
@@ -235,6 +237,7 @@ tty_keys_next(struct tty *tty, int *key, u_char *mouse)
struct timeval tv;
char *buf;
size_t len, size;
+ cc_t bspace;
buf = BUFFER_OUT(tty->in);
len = BUFFER_USED(tty->in);
@@ -245,6 +248,15 @@ tty_keys_next(struct tty *tty, int *key, u_char *mouse)
/* If a normal key, return it. */
if (*buf != '\033') {
*key = buffer_read8(tty->in);
+
+ /*
+ * Check for backspace key using termios VERASE - the terminfo
+ * kbs entry is extremely unreliable, so cannot be safely
+ * used. termios should have a better idea.
+ */
+ bspace = tty->tio.c_cc[VERASE];
+ if (bspace != _POSIX_VDISABLE && *key == bspace)
+ *key = KEYC_BSPACE;
goto found;
}