Blob


1 /*
2 * Copyright (c) 2021 Omar Polo <op@omarpolo.com>
3 *
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
17 #ifndef KEYMAP_H
18 #define KEYMAP_H
20 #include "compat.h"
22 #include <stdint.h>
24 struct buffer;
26 struct kmap {
27 TAILQ_HEAD(map, keymap) m;
28 void (*unhandled_input)(void);
29 };
30 extern struct kmap global_map, minibuffer_map;
32 typedef void(interactivefn)(struct buffer *);
34 struct keymap {
35 int meta;
36 int key;
37 struct kmap map;
38 interactivefn *fn;
40 TAILQ_ENTRY(keymap) keymaps;
41 };
43 struct thiskey {
44 short meta;
45 int key;
46 uint32_t cp;
47 };
49 enum {
50 LK_ADVANCED_MAP,
51 LK_MATCHED,
52 LK_UNBOUND,
53 };
55 int kbd(const char *);
56 const char *unkbd(int);
57 int kmap_define_key(struct kmap *, const char *, interactivefn *);
58 int lookup_key(struct kmap **, struct thiskey *, struct buffer *);
60 #endif