summaryrefslogtreecommitdiff
path: root/usr.bin/tmux/tty-keys.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2017-01-11 16:05:47 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2017-01-11 16:05:47 +0000
commit27f24acc698a0b313bd5b506cf71fc541163e526 (patch)
tree328dbb3a70bf5b395b31f00965fd9af0533c8643 /usr.bin/tmux/tty-keys.c
parentae0de9d48f757609031aef9972d3a21d1de2739d (diff)
Use a macro for looking up tty types.
Diffstat (limited to 'usr.bin/tmux/tty-keys.c')
-rw-r--r--usr.bin/tmux/tty-keys.c37
1 files changed, 16 insertions, 21 deletions
diff --git a/usr.bin/tmux/tty-keys.c b/usr.bin/tmux/tty-keys.c
index 5377d2a146d..57fa981ff54 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.91 2016/11/15 14:02:32 nicm Exp $ */
+/* $OpenBSD: tty-keys.c,v 1.92 2017/01/11 16:05:46 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -837,9 +837,10 @@ static int
tty_keys_device_attributes(struct tty *tty, const char *buf, size_t len,
size_t *size)
{
- u_int i, a, b;
- char tmp[64], *endptr;
- const char *s;
+ u_int i, a, b;
+ char tmp[64], *endptr;
+ static const char *types[] = TTY_TYPES;
+ int type;
*size = 0;
@@ -877,35 +878,29 @@ tty_keys_device_attributes(struct tty *tty, const char *buf, size_t len,
} else
a = b = 0;
- s = "UNKNOWN";
+ type = TTY_UNKNOWN;
switch (a) {
case 1:
- if (b == 2) {
- tty_set_type(tty, TTY_VT100);
- s = "VT100";
- } else if (b == 0) {
- tty_set_type(tty, TTY_VT101);
- s = "VT101";
- }
+ if (b == 2)
+ type = TTY_VT100;
+ else if (b == 0)
+ type = TTY_VT101;
break;
case 6:
- tty_set_type(tty, TTY_VT102);
- s = "VT102";
+ type = TTY_VT102;
break;
case 62:
- tty_set_type(tty, TTY_VT220);
- s = "VT220";
+ type = TTY_VT220;
break;
case 63:
- tty_set_type(tty, TTY_VT320);
- s = "VT320";
+ type = TTY_VT320;
break;
case 64:
- tty_set_type(tty, TTY_VT420);
- s = "VT420";
+ type = TTY_VT420;
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);
}