Line |
Branch |
Exec |
Source |
1 |
|
|
#ifndef MODE_H |
2 |
|
|
#define MODE_H |
3 |
|
|
|
4 |
|
|
#include <stdbool.h> |
5 |
|
|
#include "command/run.h" |
6 |
|
|
#include "terminal/key.h" |
7 |
|
|
#include "util/hashmap.h" |
8 |
|
|
#include "util/intmap.h" |
9 |
|
|
#include "util/macros.h" |
10 |
|
|
#include "util/ptr-array.h" |
11 |
|
|
|
12 |
|
|
typedef enum { |
13 |
|
|
MHF_NO_TEXT_INSERTION = 1 << 0, // Don't insert text for keys in the Unicode range |
14 |
|
|
MHF_NO_TEXT_INSERTION_RECURSIVE = 1 << 1, // As above, but also overriding all fallback modes |
15 |
|
|
} ModeHandlerFlags; |
16 |
|
|
|
17 |
|
|
typedef struct { |
18 |
|
|
const char *name; |
19 |
|
|
const CommandSet *cmds; |
20 |
|
|
IntMap key_bindings; |
21 |
|
|
ModeHandlerFlags flags; |
22 |
|
|
PointerArray fallthrough_modes; |
23 |
|
|
} ModeHandler; |
24 |
|
|
|
25 |
|
5 |
static inline ModeHandler *get_mode_handler(HashMap *modes, const char *name) |
26 |
|
|
{ |
27 |
|
5 |
return hashmap_get(modes, name); |
28 |
|
|
} |
29 |
|
|
|
30 |
|
|
struct EditorState; |
31 |
|
|
bool handle_input(struct EditorState *e, KeyCode key) NONNULL_ARGS; |
32 |
|
|
ModeHandler *new_mode(HashMap *modes, char *name, const CommandSet *cmds) NONNULL_ARGS_AND_RETURN; |
33 |
|
|
|
34 |
|
|
#endif |
35 |
|
|
|