From: Michael Elkins Date: Mon, 9 Dec 2002 17:44:28 +0000 (+0000) Subject: This patch adds two features to mutt: X-Git-Tag: mutt-1-5-3-rel~46 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9c1b2853c6a094fd17a0f9ab0a5cf45ed29d1d6a;p=mutt This patch adds two features to mutt: - you can now specify the octal code of a key in a bind or macro function, using the syntax . Eg, bind index <541> show-version This allows you to bind to a function key for which Mutt doesn't have a friendly name associated with it. - adds a what-key function which allows you to press a key and have mutt show you the decimal/octal value. (not bound to anything by default) --- diff --git a/OPS b/OPS index 17d45fc0..f8abbfb7 100644 --- a/OPS +++ b/OPS @@ -166,6 +166,7 @@ OP_UNDELETE_SUBTHREAD "undelete all messages in subthread" 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" diff --git a/PATCHES b/PATCHES index e69de29b..f131a27a 100644 --- a/PATCHES +++ b/PATCHES @@ -0,0 +1 @@ +patch-1.5.1.me.what_key.1 diff --git a/curs_main.c b/curs_main.c index dadaeb84..599b5b0a 100644 --- a/curs_main.c +++ b/curs_main.c @@ -1987,6 +1987,10 @@ int mutt_index_menu (void) menu->redraw = REDRAW_FULL; break; + case OP_WHAT_KEY: + mutt_what_key(); + break; + default: if (menu->menu == MENU_MAIN) km_error_key (MENU_MAIN); diff --git a/functions.h b/functions.h index eae16756..1b67309a 100644 --- a/functions.h +++ b/functions.h @@ -60,6 +60,7 @@ struct binding_t OpGeneric[] = { { "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 } }; diff --git a/keymap.c b/keymap.c index 61ac095c..765d57e7 100644 --- a/keymap.c +++ b/keymap.c @@ -120,6 +120,19 @@ static int parse_fkey(char *s) return n; } +/* + * This function parses the string 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; @@ -147,6 +160,11 @@ static int parsekeys (char *str, keycode_t *d, int max) s = t; *d = KEY_F (n); } + else if ((n = parse_keycode(s)) > 0) + { + s = t; + *d = n; + } *t = c; } @@ -892,3 +910,25 @@ int mutt_parse_exec (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err) 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(); +} diff --git a/keymap.h b/keymap.h index 1908d87a..232d0e50 100644 --- a/keymap.h +++ b/keymap.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 1996-2000 Michael R. Elkins + * Copyright (C) 1996-2000,2 Michael R. Elkins * * 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 @@ -46,6 +46,7 @@ int km_expand_key (char *, size_t, struct keymap_t *); struct keymap_t *km_find_func (int, int); void km_init (void); void km_error_key (int); +void mutt_what_key (void); enum { diff --git a/menu.c b/menu.c index 824c2833..9c288fad 100644 --- a/menu.c +++ b/menu.c @@ -1014,6 +1014,10 @@ int mutt_menuLoop (MUTTMENU *menu) MAYBE_REDRAW (menu->redraw); break; + case OP_WHAT_KEY: + mutt_what_key (); + break; + case OP_REDRAW: clearok (stdscr, TRUE); menu->redraw = REDRAW_FULL;