From 361801aaaa4f68768f7f45695c51bbe5a1acee2b Mon Sep 17 00:00:00 2001 From: Tiago Cunha Date: Tue, 28 Jul 2009 22:37:02 +0000 Subject: Sync OpenBSD patchset 184: 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. --- tty-keys.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'tty-keys.c') diff --git a/tty-keys.c b/tty-keys.c index c094e361..62ecced8 100644 --- a/tty-keys.c +++ b/tty-keys.c @@ -1,4 +1,4 @@ -/* $Id: tty-keys.c,v 1.28 2009-07-22 16:24:59 tcunha Exp $ */ +/* $Id: tty-keys.c,v 1.29 2009-07-28 22:37:02 tcunha Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -20,6 +20,8 @@ #include #include +#include +#include #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; } -- cgit