=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/Attic/xterm-keys.c,v retrieving revision 1.5 retrieving revision 1.6 diff -c -r1.5 -r1.6 *** src/usr.bin/tmux/Attic/xterm-keys.c 2009/12/03 22:50:10 1.5 --- src/usr.bin/tmux/Attic/xterm-keys.c 2010/09/01 21:11:14 1.6 *************** *** 1,4 **** ! /* $OpenBSD: xterm-keys.c,v 1.5 2009/12/03 22:50:10 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: xterm-keys.c,v 1.6 2010/09/01 21:11:14 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott *************** *** 114,140 **** xterm_keys_modifiers(const char *template, const char *buf, size_t len) { size_t idx; idx = strcspn(template, "_"); if (idx >= len) return (0); ! switch (buf[idx]) { ! case '2': ! return (KEYC_SHIFT); ! case '3': ! return (KEYC_ESCAPE); ! case '4': ! return (KEYC_SHIFT|KEYC_ESCAPE); ! case '5': ! return (KEYC_CTRL); ! case '6': ! return (KEYC_SHIFT|KEYC_CTRL); ! case '7': ! return (KEYC_ESCAPE|KEYC_CTRL); ! case '8': ! return (KEYC_SHIFT|KEYC_ESCAPE|KEYC_CTRL); ! } ! return (0); } /* --- 114,134 ---- xterm_keys_modifiers(const char *template, const char *buf, size_t len) { size_t idx; + int param, modifiers; idx = strcspn(template, "_"); if (idx >= len) return (0); ! param = buf[idx] - '1'; ! ! modifiers = 0; ! if (param & 1) ! modifiers |= KEYC_SHIFT; ! if (param & 2) ! modifiers |= KEYC_ESCAPE; ! if (param & 4) ! modifiers |= KEYC_CTRL; ! return (modifiers); } /* *************** *** 171,200 **** int modifiers; char *out; ! #define KEY_MODIFIERS(key, modifiers) \ ! (((key) & (KEYC_SHIFT|KEYC_ESCAPE|KEYC_CTRL)) == (modifiers)) ! modifiers = 0; ! if (KEY_MODIFIERS(key, KEYC_SHIFT)) ! modifiers = 2; ! else if (KEY_MODIFIERS(key, KEYC_ESCAPE)) ! modifiers = 3; ! else if (KEY_MODIFIERS(key, KEYC_SHIFT|KEYC_ESCAPE)) ! modifiers = 4; ! else if (KEY_MODIFIERS(key, KEYC_CTRL)) ! modifiers = 5; ! else if (KEY_MODIFIERS(key, KEYC_SHIFT|KEYC_CTRL)) ! modifiers = 6; ! else if (KEY_MODIFIERS(key, KEYC_ESCAPE|KEYC_CTRL)) ! modifiers = 7; ! else if (KEY_MODIFIERS(key, KEYC_SHIFT|KEYC_ESCAPE|KEYC_CTRL)) ! modifiers = 8; ! #undef KEY_MODIFIERS /* * If the key has no modifiers, return NULL and let it fall through to * the normal lookup. */ ! if (modifiers == 0) return (NULL); /* Otherwise, find the key in the table. */ --- 165,183 ---- int modifiers; char *out; ! modifiers = 1; ! if (key & KEYC_SHIFT) ! modifiers += 1; ! if (key & KEYC_ESCAPE) ! modifiers += 2; ! if (key & KEYC_CTRL) ! modifiers += 4; /* * If the key has no modifiers, return NULL and let it fall through to * the normal lookup. */ ! if (modifiers == 1) return (NULL); /* Otherwise, find the key in the table. */