mirror of
https://github.com/tmux/tmux.git
synced 2025-03-30 19:48:48 +00:00
Use a macro for looking up tty types.
This commit is contained in:
parent
458b6eb600
commit
7497ecd979
2
tmux.h
2
tmux.h
@ -1152,6 +1152,8 @@ struct tty {
|
|||||||
struct event key_timer;
|
struct event key_timer;
|
||||||
struct tty_key *key_tree;
|
struct tty_key *key_tree;
|
||||||
};
|
};
|
||||||
|
#define TTY_TYPES \
|
||||||
|
{ "VT100", "VT101", "VT102", "VT220", "VT320", "VT420", "UNKNOWN" }
|
||||||
|
|
||||||
/* TTY command context. */
|
/* TTY command context. */
|
||||||
struct tty_ctx {
|
struct tty_ctx {
|
||||||
|
35
tty-keys.c
35
tty-keys.c
@ -837,9 +837,10 @@ static int
|
|||||||
tty_keys_device_attributes(struct tty *tty, const char *buf, size_t len,
|
tty_keys_device_attributes(struct tty *tty, const char *buf, size_t len,
|
||||||
size_t *size)
|
size_t *size)
|
||||||
{
|
{
|
||||||
u_int i, a, b;
|
u_int i, a, b;
|
||||||
char tmp[64], *endptr;
|
char tmp[64], *endptr;
|
||||||
const char *s;
|
static const char *types[] = TTY_TYPES;
|
||||||
|
int type;
|
||||||
|
|
||||||
*size = 0;
|
*size = 0;
|
||||||
|
|
||||||
@ -877,35 +878,29 @@ tty_keys_device_attributes(struct tty *tty, const char *buf, size_t len,
|
|||||||
} else
|
} else
|
||||||
a = b = 0;
|
a = b = 0;
|
||||||
|
|
||||||
s = "UNKNOWN";
|
type = TTY_UNKNOWN;
|
||||||
switch (a) {
|
switch (a) {
|
||||||
case 1:
|
case 1:
|
||||||
if (b == 2) {
|
if (b == 2)
|
||||||
tty_set_type(tty, TTY_VT100);
|
type = TTY_VT100;
|
||||||
s = "VT100";
|
else if (b == 0)
|
||||||
} else if (b == 0) {
|
type = TTY_VT101;
|
||||||
tty_set_type(tty, TTY_VT101);
|
|
||||||
s = "VT101";
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
tty_set_type(tty, TTY_VT102);
|
type = TTY_VT102;
|
||||||
s = "VT102";
|
|
||||||
break;
|
break;
|
||||||
case 62:
|
case 62:
|
||||||
tty_set_type(tty, TTY_VT220);
|
type = TTY_VT220;
|
||||||
s = "VT220";
|
|
||||||
break;
|
break;
|
||||||
case 63:
|
case 63:
|
||||||
tty_set_type(tty, TTY_VT320);
|
type = TTY_VT320;
|
||||||
s = "VT320";
|
|
||||||
break;
|
break;
|
||||||
case 64:
|
case 64:
|
||||||
tty_set_type(tty, TTY_VT420);
|
type = TTY_VT420;
|
||||||
s = "VT420";
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
log_debug("received DA %.*s (%s)", (int)*size, buf, s);
|
tty_set_type(tty, type);
|
||||||
|
|
||||||
|
log_debug("received DA %.*s (%s)", (int)*size, buf, types[type]);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user