macros to create usual functions : new/delete and init/wipe.
[apps/madmutt.git] / keymap.h
1 /*
2  * Copyright notice from original mutt:
3  * Copyright (C) 1996-2000,2 Michael R. Elkins <me@mutt.org>
4  *
5  * This file is part of mutt-ng, see http://www.muttng.org/.
6  * It's licensed under the GNU General Public License,
7  * please see the file GPL in the top level source directory.
8  */
9
10 #ifndef KEYMAP_H
11 #define KEYMAP_H
12
13 #include <lib-lib/mapping.h>
14
15 /* maximal length of a key binding sequence used for buffer in km_bindkey */
16 #define MAX_SEQ 8
17
18 /* flags for km_dokey() */
19 #define M_KM_UNBUFFERED 1       /* don't read from the key buffer */
20
21 /* type for key storage, the rest of mutt works fine with int type */
22 typedef short keycode_t;
23
24 void km_bind (const char *, int, int, char *, char *);
25 void km_bindkey (const char *, int, int);
26 int km_dokey (int);
27
28 /* entry in the keymap tree */
29 struct keymap_t {
30   char *macro;                  /* macro expansion (op == OP_MACRO) */
31   char *descr;                  /* description of a macro for the help menu */
32   struct keymap_t *next;        /* next key in map */
33   short op;                     /* operation to perform */
34   short eq;                     /* number of leading keys equal to next entry */
35   short len;                    /* length of key sequence (unit: sizeof (keycode_t)) */
36   keycode_t *keys;              /* key sequence */
37 };
38
39 const char *km_keyname (int);
40 int km_expand_key (char *, size_t, struct keymap_t *);
41 struct keymap_t *km_find_func (int, int);
42 void km_init (void);
43 void km_error_key (int);
44 void mutt_what_key (void);
45
46 enum {
47   MENU_ALIAS,
48   MENU_ATTACH,
49   MENU_COMPOSE,
50   MENU_EDITOR,
51   MENU_FOLDER,
52   MENU_GENERIC,
53   MENU_MAIN,
54   MENU_PAGER,
55   MENU_POST,
56   MENU_QUERY,
57
58
59   MENU_PGP,
60   MENU_SMIME,
61
62 #ifdef CRYPT_BACKEND_GPGME
63   MENU_KEY_SELECT_PGP,
64   MENU_KEY_SELECT_SMIME,
65 #endif
66
67 #ifdef MIXMASTER
68   MENU_MIX,
69 #endif
70
71
72
73   MENU_MAX
74 };
75
76 /* the keymap trees (one for each menu) */
77 extern struct keymap_t *Keymaps[];
78
79 /* dokey() records the last real key pressed  */
80 extern int LastKey;
81
82 extern struct mapping_t Menus[];
83
84 struct binding_t {
85     const char *name;             /* name of the function */
86     int op;                       /* function id number */
87     const char *seq;              /* default key binding */
88 };
89
90 struct binding_t *km_get_table (int menu);
91
92 #define MUTT_FUNCTIONS_PROTO
93 #include "functions.def"
94
95 #include "keymap_defs.h"
96
97 #endif /* KEYMAP_H */