mirror of
https://github.com/tmate-io/tmate-ssh-server.git
synced 2020-11-18 19:53:51 -08:00
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
55d8c01c33
commit
639fbe0392
@ -36,6 +36,9 @@ struct input_key_ent {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct input_key_ent input_keys[] = {
|
struct input_key_ent input_keys[] = {
|
||||||
|
/* Backspace key. */
|
||||||
|
{ KEYC_BSPACE, "\177", 0 },
|
||||||
|
|
||||||
/* Function keys. */
|
/* Function keys. */
|
||||||
{ KEYC_F1, "\033OP", INPUTKEY_CTRL|INPUTKEY_XTERM },
|
{ KEYC_F1, "\033OP", INPUTKEY_CTRL|INPUTKEY_XTERM },
|
||||||
{ KEYC_F2, "\033OQ", INPUTKEY_CTRL|INPUTKEY_XTERM },
|
{ KEYC_F2, "\033OQ", INPUTKEY_CTRL|INPUTKEY_XTERM },
|
||||||
|
@ -57,7 +57,7 @@ struct {
|
|||||||
{ "PPage", KEYC_PPAGE },
|
{ "PPage", KEYC_PPAGE },
|
||||||
{ "Tab", '\011' },
|
{ "Tab", '\011' },
|
||||||
{ "BTab", KEYC_BTAB },
|
{ "BTab", KEYC_BTAB },
|
||||||
{ "BSpace", '\177' },
|
{ "BSpace", KEYC_BSPACE },
|
||||||
|
|
||||||
/* Arrow keys. */
|
/* Arrow keys. */
|
||||||
{ "Up", KEYC_UP },
|
{ "Up", KEYC_UP },
|
||||||
|
@ -70,7 +70,7 @@ mode_key_lookup_vi(struct mode_key_data *mdata, int key)
|
|||||||
mdata->flags &= ~MODEKEY_EDITMODE;
|
mdata->flags &= ~MODEKEY_EDITMODE;
|
||||||
return (MODEKEYCMD_NONE);
|
return (MODEKEYCMD_NONE);
|
||||||
case '\010':
|
case '\010':
|
||||||
case '\177':
|
case KEYC_BSPACE:
|
||||||
return (MODEKEYCMD_BACKSPACE);
|
return (MODEKEYCMD_BACKSPACE);
|
||||||
case '\011':
|
case '\011':
|
||||||
return (MODEKEYCMD_COMPLETE);
|
return (MODEKEYCMD_COMPLETE);
|
||||||
@ -84,7 +84,7 @@ mode_key_lookup_vi(struct mode_key_data *mdata, int key)
|
|||||||
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case '\010':
|
case '\010':
|
||||||
case '\177':
|
case KEYC_BSPACE:
|
||||||
return (MODEKEYCMD_LEFT);
|
return (MODEKEYCMD_LEFT);
|
||||||
case KEYC_DC:
|
case KEYC_DC:
|
||||||
return (MODEKEYCMD_DELETE);
|
return (MODEKEYCMD_DELETE);
|
||||||
@ -151,7 +151,7 @@ mode_key_lookup_emacs(struct mode_key_data *mdata, int key)
|
|||||||
{
|
{
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case '\010':
|
case '\010':
|
||||||
case '\177':
|
case KEYC_BSPACE:
|
||||||
return (MODEKEYCMD_BACKSPACE);
|
return (MODEKEYCMD_BACKSPACE);
|
||||||
case '\004':
|
case '\004':
|
||||||
case KEYC_DC:
|
case KEYC_DC:
|
||||||
|
3
tmux.h
3
tmux.h
@ -121,6 +121,9 @@ enum key_code {
|
|||||||
/* Mouse key. */
|
/* Mouse key. */
|
||||||
KEYC_MOUSE = 0x1000,
|
KEYC_MOUSE = 0x1000,
|
||||||
|
|
||||||
|
/* Backspace key. */
|
||||||
|
KEYC_BSPACE,
|
||||||
|
|
||||||
/* Function keys. */
|
/* Function keys. */
|
||||||
KEYC_F1,
|
KEYC_F1,
|
||||||
KEYC_F2,
|
KEYC_F2,
|
||||||
|
12
tty-keys.c
12
tty-keys.c
@ -20,6 +20,8 @@
|
|||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <termios.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
@ -235,6 +237,7 @@ tty_keys_next(struct tty *tty, int *key, u_char *mouse)
|
|||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
char *buf;
|
char *buf;
|
||||||
size_t len, size;
|
size_t len, size;
|
||||||
|
cc_t bspace;
|
||||||
|
|
||||||
buf = BUFFER_OUT(tty->in);
|
buf = BUFFER_OUT(tty->in);
|
||||||
len = BUFFER_USED(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 a normal key, return it. */
|
||||||
if (*buf != '\033') {
|
if (*buf != '\033') {
|
||||||
*key = buffer_read8(tty->in);
|
*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;
|
goto found;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user