OP_VERSION "show the Mutt version number and date"
OP_VIEW_ATTACH "view attachment using mailcap entry if necessary"
OP_VIEW_ATTACHMENTS "show MIME attachments"
+OP_WHAT_KEY "display the keycode for a key press"
OP_MAIN_SHOW_LIMIT "show currently active limit pattern"
OP_MAIN_COLLAPSE_THREAD "collapse/uncollapse current thread"
OP_MAIN_COLLAPSE_ALL "collapse/uncollapse all threads"
+patch-1.5.1.me.what_key.1
menu->redraw = REDRAW_FULL;
break;
+ case OP_WHAT_KEY:
+ mutt_what_key();
+ break;
+
default:
if (menu->menu == MENU_MAIN)
km_error_key (MENU_MAIN);
{ "current-top", OP_CURRENT_TOP, NULL },
{ "current-middle", OP_CURRENT_MIDDLE, NULL },
{ "current-bottom", OP_CURRENT_BOTTOM, NULL },
+ { "what-key", OP_WHAT_KEY, NULL },
{ NULL, 0, NULL }
};
return n;
}
+/*
+ * This function parses the string <NNN> and uses the octal value as the key
+ * to bind.
+ */
+static int parse_keycode (const char *s)
+{
+ if (isdigit (s[1]) && isdigit (s[2]) && isdigit (s[3]) && s[4] == '>')
+ {
+ return (s[3] - '0') + (s[2] - '0') * 8 + (s[1] - '0') * 64;
+ }
+ return -1;
+}
+
static int parsekeys (char *str, keycode_t *d, int max)
{
int n, len = max;
s = t;
*d = KEY_F (n);
}
+ else if ((n = parse_keycode(s)) > 0)
+ {
+ s = t;
+ *d = n;
+ }
*t = c;
}
return 0;
}
+
+/*
+ * prompts the user to enter a keystroke, and displays the octal value back
+ * to the user.
+ */
+void mutt_what_key (void)
+{
+ int ch;
+
+ mvprintw(LINES-1,0,"Enter keys (^G to abort): ");
+ do {
+ ch = getch();
+ if (ch != ERR && ch != ctrl ('G'))
+ {
+ mutt_message("Char = %s, Octal = %o, Decimal = %d",
+ km_keyname(ch), ch, ch);
+ }
+ }
+ while (ch != ERR && ch != ctrl ('G'));
+
+ mutt_flushinp();
+}
/*
- * Copyright (C) 1996-2000 Michael R. Elkins <me@cs.hmc.edu>
+ * Copyright (C) 1996-2000,2 Michael R. Elkins <me@cs.hmc.edu>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
struct keymap_t *km_find_func (int, int);
void km_init (void);
void km_error_key (int);
+void mutt_what_key (void);
enum
{
MAYBE_REDRAW (menu->redraw);
break;
+ case OP_WHAT_KEY:
+ mutt_what_key ();
+ break;
+
case OP_REDRAW:
clearok (stdscr, TRUE);
menu->redraw = REDRAW_FULL;