=== modified file 'termkey.c' --- termkey.c 2011-03-31 23:26:02 +0000 +++ termkey.c 2011-03-31 22:42:52 +0000 @@ -950,23 +950,12 @@ return termkey_strfkey(tk, buffer, len, key, format); } -struct modnames { - const char *shift, *alt, *ctrl; -} -modnames[] = { - { "S", "A", "C" }, // 0 - { "Shift", "Alt", "Ctrl" }, // LONGMOD - { "S", "M", "C" }, // ALTISMETA - { "Shift", "Meta", "Ctrl" }, // ALTISMETA+LONGMOD -}; - size_t termkey_strfkey(TermKey *tk, char *buffer, size_t len, TermKeyKey *key, TermKeyFormat format) { size_t pos = 0; size_t l = 0; - struct modnames *mods = &modnames[!!(format & TERMKEY_FORMAT_LONGMOD) + - !!(format & TERMKEY_FORMAT_ALTISMETA) * 2]; + int longmod = format & TERMKEY_FORMAT_LONGMOD; int wrapbracket = (format & TERMKEY_FORMAT_WRAPBRACKET) && (key->type != TERMKEY_TYPE_UNICODE || key->modifiers != 0); @@ -999,19 +988,22 @@ } if(key->modifiers & TERMKEY_KEYMOD_ALT) { - l = snprintf(buffer + pos, len - pos, "%s-", mods->alt); + int altismeta = format & TERMKEY_FORMAT_ALTISMETA; + + l = snprintf(buffer + pos, len - pos, longmod ? ( altismeta ? "Meta-" : "Alt-" ) + : ( altismeta ? "M-" : "A-" )); if(l <= 0) return pos; pos += l; } if(key->modifiers & TERMKEY_KEYMOD_CTRL) { - l = snprintf(buffer + pos, len - pos, "%s-", mods->ctrl); + l = snprintf(buffer + pos, len - pos, longmod ? "Ctrl-" : "C-"); if(l <= 0) return pos; pos += l; } if(key->modifiers & TERMKEY_KEYMOD_SHIFT) { - l = snprintf(buffer + pos, len - pos, "%s-", mods->shift); + l = snprintf(buffer + pos, len - pos, longmod ? "Shift-" : "S-"); if(l <= 0) return pos; pos += l; }