diff --git a/input-keys.c b/input-keys.c index e4df29e8..e8c4804a 100644 --- a/input-keys.c +++ b/input-keys.c @@ -1,4 +1,4 @@ -/* $Id: input-keys.c,v 1.28 2009-07-22 16:24:59 tcunha Exp $ */ +/* $Id: input-keys.c,v 1.29 2009-07-28 22:37:02 tcunha Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -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/key-string.c b/key-string.c index bf2d9b15..5dfd2e61 100644 --- a/key-string.c +++ b/key-string.c @@ -1,4 +1,4 @@ -/* $Id: key-string.c,v 1.20 2009-07-25 08:53:48 tcunha Exp $ */ +/* $Id: key-string.c,v 1.21 2009-07-28 22:37:02 tcunha Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -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/mode-key.c b/mode-key.c index 27d351ae..2a895b5e 100644 --- a/mode-key.c +++ b/mode-key.c @@ -1,4 +1,4 @@ -/* $Id: mode-key.c,v 1.15 2009-07-23 23:29:53 tcunha Exp $ */ +/* $Id: mode-key.c,v 1.16 2009-07-28 22:37:02 tcunha Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott @@ -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/tmux.h b/tmux.h index 79a57f67..0dcd8bb5 100644 --- a/tmux.h +++ b/tmux.h @@ -1,4 +1,4 @@ -/* $Id: tmux.h,v 1.390 2009-07-28 22:12:16 tcunha Exp $ */ +/* $Id: tmux.h,v 1.391 2009-07-28 22:37:02 tcunha Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -120,6 +120,9 @@ enum key_code { /* Mouse key. */ KEYC_MOUSE = 0x1000, + /* Backspace key. */ + KEYC_BSPACE, + /* Function keys. */ KEYC_F1, KEYC_F2, 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; }