diff options
author | 2009-07-26 21:42:08 +0000 | |
---|---|---|
committer | 2009-07-26 21:42:08 +0000 | |
commit | 4cf013256f8388b45535dda81c15c71050dad7f6 (patch) | |
tree | 6a86486ae39b7772a758c0619a861b7e0ad4a8d7 | |
parent | stop trying to fast-recycle pages for now. a few bugs have been found and (diff) | |
download | wireguard-openbsd-4cf013256f8388b45535dda81c15c71050dad7f6.tar.xz wireguard-openbsd-4cf013256f8388b45535dda81c15c71050dad7f6.zip |
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.
-rw-r--r-- | usr.bin/tmux/input-keys.c | 5 | ||||
-rw-r--r-- | usr.bin/tmux/key-string.c | 4 | ||||
-rw-r--r-- | usr.bin/tmux/mode-key.c | 8 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.h | 5 | ||||
-rw-r--r-- | usr.bin/tmux/tty-keys.c | 14 |
5 files changed, 27 insertions, 9 deletions
diff --git a/usr.bin/tmux/input-keys.c b/usr.bin/tmux/input-keys.c index 0e54ccf6673..5fa4640c98b 100644 --- a/usr.bin/tmux/input-keys.c +++ b/usr.bin/tmux/input-keys.c @@ -1,4 +1,4 @@ -/* $OpenBSD: input-keys.c,v 1.2 2009/07/21 17:57:29 nicm Exp $ */ +/* $OpenBSD: input-keys.c,v 1.3 2009/07/26 21:42:08 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -36,6 +36,9 @@ struct input_key_ent { }; struct input_key_ent input_keys[] = { + /* Backspace key. */ + { KEYC_BSPACE, "\177", 0 }, + /* Function keys. */ { KEYC_F1, "\033OP", INPUTKEY_CTRL|INPUTKEY_XTERM }, { KEYC_F2, "\033OQ", INPUTKEY_CTRL|INPUTKEY_XTERM }, diff --git a/usr.bin/tmux/key-string.c b/usr.bin/tmux/key-string.c index 3d261a6aff0..9f2c782ddc7 100644 --- a/usr.bin/tmux/key-string.c +++ b/usr.bin/tmux/key-string.c @@ -1,4 +1,4 @@ -/* $OpenBSD: key-string.c,v 1.4 2009/07/24 14:57:22 nicm Exp $ */ +/* $OpenBSD: key-string.c,v 1.5 2009/07/26 21:42:08 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -57,7 +57,7 @@ struct { { "PPage", KEYC_PPAGE }, { "Tab", '\011' }, { "BTab", KEYC_BTAB }, - { "BSpace", '\177' }, + { "BSpace", KEYC_BSPACE }, /* Arrow keys. */ { "Up", KEYC_UP }, diff --git a/usr.bin/tmux/mode-key.c b/usr.bin/tmux/mode-key.c index a3872eec170..850a1b69955 100644 --- a/usr.bin/tmux/mode-key.c +++ b/usr.bin/tmux/mode-key.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mode-key.c,v 1.4 2009/07/23 13:44:02 nicm Exp $ */ +/* $OpenBSD: mode-key.c,v 1.5 2009/07/26 21:42:08 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net> @@ -70,7 +70,7 @@ mode_key_lookup_vi(struct mode_key_data *mdata, int key) mdata->flags &= ~MODEKEY_EDITMODE; return (MODEKEYCMD_NONE); case '\010': - case '\177': + case KEYC_BSPACE: return (MODEKEYCMD_BACKSPACE); case '\011': return (MODEKEYCMD_COMPLETE); @@ -84,7 +84,7 @@ mode_key_lookup_vi(struct mode_key_data *mdata, int key) switch (key) { case '\010': - case '\177': + case KEYC_BSPACE: return (MODEKEYCMD_LEFT); case KEYC_DC: return (MODEKEYCMD_DELETE); @@ -151,7 +151,7 @@ mode_key_lookup_emacs(struct mode_key_data *mdata, int key) { switch (key) { case '\010': - case '\177': + case KEYC_BSPACE: return (MODEKEYCMD_BACKSPACE); case '\004': case KEYC_DC: diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h index 4013b76792f..80730cfad03 100644 --- a/usr.bin/tmux/tmux.h +++ b/usr.bin/tmux/tmux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.55 2009/07/26 12:58:44 nicm Exp $ */ +/* $OpenBSD: tmux.h,v 1.56 2009/07/26 21:42:08 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -121,6 +121,9 @@ enum key_code { /* Mouse key. */ KEYC_MOUSE = 0x1000, + /* Backspace key. */ + KEYC_BSPACE, + /* Function keys. */ KEYC_F1, KEYC_F2, 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; } |