]> granicus.if.org Git - mutt/commitdiff
This patch adds two features to mutt:
authorMichael Elkins <me@sigpipe.org>
Mon, 9 Dec 2002 17:44:28 +0000 (17:44 +0000)
committerMichael Elkins <me@sigpipe.org>
Mon, 9 Dec 2002 17:44:28 +0000 (17:44 +0000)
- 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)

OPS
PATCHES
curs_main.c
functions.h
keymap.c
keymap.h
menu.c

diff --git a/OPS b/OPS
index 17d45fc055518e193ee6294859d704c446532720..f8abbfb7657f9d2ce1403b5a3d5e0ae1d594c037 100644 (file)
--- 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 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..f131a27a454e369f52afa2536ab05892431dabb6 100644 (file)
--- a/PATCHES
+++ b/PATCHES
@@ -0,0 +1 @@
+patch-1.5.1.me.what_key.1
index dadaeb84b4106475380746d91adf8ace35a03344..599b5b0a1b9e161c1e4ca3eac5a6b852ee68ea4d 100644 (file)
@@ -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);
index eae16756cda8a438d751aa827d816c0b800486db..1b67309a35fcaadf059a64ef055140a110986577 100644 (file)
@@ -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 }
 };
 
index 61ac095c3c7e44dfe2a83b57078623667dc4b6e8..765d57e7eff15f31cf3df545c14f6234d06a4833 100644 (file)
--- a/keymap.c
+++ b/keymap.c
@@ -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();
+}
index 1908d87a8f49d83d379784d1ba3f54e119ecea15..232d0e509c6f9f7dd9bb4dcaf57cc4e189d630ef 100644 (file)
--- a/keymap.h
+++ b/keymap.h
@@ -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
 {
diff --git a/menu.c b/menu.c
index 824c283385b72578c6676cf0dca87d1ad499775e..9c288fad84a9e3996bf600c3718a2dd1c3996e3b 100644 (file)
--- 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;