summaryrefslogtreecommitdiff
path: root/usr.bin/tmux/tty-keys.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2009-07-26 21:42:09 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2009-07-26 21:42:09 +0000
commitf1d6f4879de6d24c07cd173a86cc352dced078e0 (patch)
treec64e3dee11dbf094675e4915fd0dc8c5ee62d1b7 /usr.bin/tmux/tty-keys.c
parent99a7ea32f0bf2e2def3e9a44e1fc0d2e5a518b19 (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 'usr.bin/tmux/tty-keys.c')
-rw-r--r--usr.bin/tmux/tty-keys.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/usr.bin/tmux/tty-keys.c b/usr.bin/tmux/tty-keys.c
index 9d95a220663..a559a3fd4ca 100644
--- a/usr.bin/tmux/tty-keys.c
+++ b/usr.bin/tmux/tty-keys.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tty-keys.c,v 1.2 2009/07/21 17:57:29 nicm Exp $ */
+/* $OpenBSD: tty-keys.c,v 1.3 2009/07/26 21:42:08 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -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;
}