mirror of
https://github.com/tmux/tmux.git
synced 2024-12-12 17:38:48 +00:00
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.
This commit is contained in:
parent
2aa4d47312
commit
361801aaaa
@ -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 <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 },
|
||||
|
@ -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 <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 },
|
||||
|
@ -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 <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:
|
||||
|
5
tmux.h
5
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 <nicm@users.sourceforge.net>
|
||||
@ -120,6 +120,9 @@ enum key_code {
|
||||
/* Mouse key. */
|
||||
KEYC_MOUSE = 0x1000,
|
||||
|
||||
/* Backspace key. */
|
||||
KEYC_BSPACE,
|
||||
|
||||
/* Function keys. */
|
||||
KEYC_F1,
|
||||
KEYC_F2,
|
||||
|
14
tty-keys.c
14
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 <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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user