=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/tty-keys.c,v retrieving revision 1.93 retrieving revision 1.94 diff -c -r1.93 -r1.94 *** src/usr.bin/tmux/tty-keys.c 2017/02/10 12:59:18 1.93 --- src/usr.bin/tmux/tty-keys.c 2017/04/18 13:34:04 1.94 *************** *** 1,4 **** ! /* $OpenBSD: tty-keys.c,v 1.93 2017/02/10 12:59:18 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: tty-keys.c,v 1.94 2017/04/18 13:34:04 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott *************** *** 470,490 **** tty_keys_next1(struct tty *tty, const char *buf, size_t len, key_code *key, size_t *size, int expired) { struct tty_key *tk, *tk1; struct utf8_data ud; enum utf8_state more; u_int i; wchar_t wc; ! log_debug("next key is %zu (%.*s) (expired=%d)", len, (int)len, buf, ! expired); /* Is this a known key? */ tk = tty_keys_find(tty, buf, len, size); if (tk != NULL && tk->key != KEYC_UNKNOWN) { tk1 = tk; do ! log_debug("keys in list: %#llx", tk1->key); while ((tk1 = tk1->next) != NULL); if (tk->next != NULL && !expired) return (1); --- 470,491 ---- tty_keys_next1(struct tty *tty, const char *buf, size_t len, key_code *key, size_t *size, int expired) { + struct client *c = tty->client; struct tty_key *tk, *tk1; struct utf8_data ud; enum utf8_state more; u_int i; wchar_t wc; ! log_debug("%s: next key is %zu (%.*s) (expired=%d)", c->name, len, ! (int)len, buf, expired); /* Is this a known key? */ tk = tty_keys_find(tty, buf, len, size); if (tk != NULL && tk->key != KEYC_UNKNOWN) { tk1 = tk; do ! log_debug("%s: keys in list: %#llx", c->name, tk1->key); while ((tk1 = tk1->next) != NULL); if (tk->next != NULL && !expired) return (1); *************** *** 510,516 **** return (-1); *key = wc; ! log_debug("UTF-8 key %.*s %#llx", (int)ud.size, buf, *key); return (0); } --- 511,518 ---- return (-1); *key = wc; ! log_debug("%s: UTF-8 key %.*s %#llx", c->name, (int)ud.size, ! buf, *key); return (0); } *************** *** 524,529 **** --- 526,532 ---- key_code tty_keys_next(struct tty *tty) { + struct client *c = tty->client; struct timeval tv; const char *buf; size_t len, size; *************** *** 537,543 **** if (len == 0) return (0); ! log_debug("keys are %zu (%.*s)", len, (int)len, buf); /* Is this a device attributes response? */ switch (tty_keys_device_attributes(tty, buf, len, &size)) { --- 540,546 ---- if (len == 0) return (0); ! log_debug("%s: keys are %zu (%.*s)", c->name, len, (int)len, buf); /* Is this a device attributes response? */ switch (tty_keys_device_attributes(tty, buf, len, &size)) { *************** *** 606,612 **** goto complete_key; partial_key: ! log_debug("partial key %.*s", (int)len, buf); /* If timer is going, check for expiration. */ if (tty->flags & TTY_TIMER) { --- 609,615 ---- goto complete_key; partial_key: ! log_debug("%s: partial key %.*s", c->name, (int)len, buf); /* If timer is going, check for expiration. */ if (tty->flags & TTY_TIMER) { *************** *** 633,639 **** return (0); complete_key: ! log_debug("complete key %.*s %#llx", (int)size, buf, key); /* * Check for backspace key using termios VERASE - the terminfo --- 636,642 ---- return (0); complete_key: ! log_debug("%s: complete key %.*s %#llx", c->name, (int)size, buf, key); /* * Check for backspace key using termios VERASE - the terminfo *************** *** 668,674 **** return (1); discard_key: ! log_debug("discard key %.*s %#llx", (int)size, buf, key); /* Remove data from buffer. */ evbuffer_drain(tty->in, size); --- 671,677 ---- return (1); discard_key: ! log_debug("%s: discard key %.*s %#llx", c->name, (int)size, buf, key); /* Remove data from buffer. */ evbuffer_drain(tty->in, size); *************** *** 695,703 **** static int tty_keys_mouse(struct tty *tty, const char *buf, size_t len, size_t *size) { struct mouse_event *m = &tty->mouse; u_int i, x, y, b, sgr_b; ! u_char sgr_type, c; /* * Standard mouse sequences are \033[M followed by three characters --- 698,707 ---- static int tty_keys_mouse(struct tty *tty, const char *buf, size_t len, size_t *size) { + struct client *c = tty->client; struct mouse_event *m = &tty->mouse; u_int i, x, y, b, sgr_b; ! u_char sgr_type, ch; /* * Standard mouse sequences are \033[M followed by three characters *************** *** 736,750 **** for (i = 0; i < 3; i++) { if (len <= *size) return (1); ! c = (u_char)buf[(*size)++]; if (i == 0) ! b = c; else if (i == 1) ! x = c; else ! y = c; } ! log_debug("mouse input: %.*s", (int)*size, buf); /* Check and return the mouse input. */ if (b < 32) --- 740,754 ---- for (i = 0; i < 3; i++) { if (len <= *size) return (1); ! ch = (u_char)buf[(*size)++]; if (i == 0) ! b = ch; else if (i == 1) ! x = ch; else ! y = ch; } ! log_debug("%s: mouse input: %.*s", c->name, (int)*size, buf); /* Check and return the mouse input. */ if (b < 32) *************** *** 764,797 **** while (1) { if (len <= *size) return (1); ! c = (u_char)buf[(*size)++]; ! if (c == ';') break; ! if (c < '0' || c > '9') return (-1); ! sgr_b = 10 * sgr_b + (c - '0'); } while (1) { if (len <= *size) return (1); ! c = (u_char)buf[(*size)++]; ! if (c == ';') break; ! if (c < '0' || c > '9') return (-1); ! x = 10 * x + (c - '0'); } while (1) { if (len <= *size) return (1); ! c = (u_char)buf[(*size)++]; ! if (c == 'M' || c == 'm') break; ! if (c < '0' || c > '9') return (-1); ! y = 10 * y + (c - '0'); } ! log_debug("mouse input (SGR): %.*s", (int)*size, buf); /* Check and return the mouse input. */ if (x < 1 || y < 1) --- 768,802 ---- while (1) { if (len <= *size) return (1); ! ch = (u_char)buf[(*size)++]; ! if (ch == ';') break; ! if (ch < '0' || ch > '9') return (-1); ! sgr_b = 10 * sgr_b + (ch - '0'); } while (1) { if (len <= *size) return (1); ! ch = (u_char)buf[(*size)++]; ! if (ch == ';') break; ! if (ch < '0' || ch > '9') return (-1); ! x = 10 * x + (ch - '0'); } while (1) { if (len <= *size) return (1); ! ch = (u_char)buf[(*size)++]; ! if (ch == 'M' || ch == 'm') break; ! if (ch < '0' || ch > '9') return (-1); ! y = 10 * y + (ch - '0'); } ! log_debug("%s: mouse input (SGR): %.*s", c->name, (int)*size, ! buf); /* Check and return the mouse input. */ if (x < 1 || y < 1) *************** *** 801,807 **** b = sgr_b; /* Type is M for press, m for release. */ ! sgr_type = c; if (sgr_type == 'm') b |= 3; --- 806,812 ---- b = sgr_b; /* Type is M for press, m for release. */ ! sgr_type = ch; if (sgr_type == 'm') b |= 3; *************** *** 837,842 **** --- 842,848 ---- tty_keys_device_attributes(struct tty *tty, const char *buf, size_t len, size_t *size) { + struct client *c = tty->client; u_int i, a, b; char tmp[64], *endptr; static const char *types[] = TTY_TYPES; *************** *** 878,883 **** --- 884,890 ---- } else a = b = 0; + /* Store terminal type. */ type = TTY_UNKNOWN; switch (a) { case 1: *************** *** 901,906 **** } tty_set_type(tty, type); ! log_debug("received DA %.*s (%s)", (int)*size, buf, types[type]); return (0); } --- 908,914 ---- } tty_set_type(tty, type); ! log_debug("%s: received DA %.*s (%s)", c->name, (int)*size, buf, ! types[type]); return (0); }