diff options
author | Michael Elkins <me@sigpipe.org> | 2002-12-09 17:44:28 +0000 |
---|---|---|
committer | Michael Elkins <me@sigpipe.org> | 2002-12-09 17:44:28 +0000 |
commit | 9c1b2853c6a094fd17a0f9ab0a5cf45ed29d1d6a (patch) | |
tree | 1c9a9afdc28cda5be677b9a4ca64d7666919962d | |
parent | 454940f9b922358a779b800e92531480a788f297 (diff) |
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 <NNN>. 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)
-rw-r--r-- | OPS | 1 | ||||
-rw-r--r-- | PATCHES | 1 | ||||
-rw-r--r-- | curs_main.c | 4 | ||||
-rw-r--r-- | functions.h | 1 | ||||
-rw-r--r-- | keymap.c | 40 | ||||
-rw-r--r-- | keymap.h | 3 | ||||
-rw-r--r-- | menu.c | 4 |
7 files changed, 53 insertions, 1 deletions
@@ -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" @@ -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 } }; @@ -120,6 +120,19 @@ static int parse_fkey(char *s) 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; @@ -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(); +} @@ -1,5 +1,5 @@ /* - * 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 @@ -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 { @@ -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; |