dte test coverage


Directory: ./
File: src/mode.h
Date: 2025-06-04 06:50:24
Exec Total Coverage
Lines: 2 2 100.0%
Functions: 1 1 100.0%
Branches: 0 0 -%

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 #include "util/string.h"
12
13 typedef enum {
14 MHF_NO_TEXT_INSERTION = 1 << 0, // Don't insert text for keys in the Unicode range
15 MHF_NO_TEXT_INSERTION_RECURSIVE = 1 << 1, // As above, but also overriding all fallback modes
16 } ModeHandlerFlags;
17
18 typedef struct {
19 const char *name;
20 const CommandSet *cmds;
21 IntMap key_bindings;
22 ModeHandlerFlags flags;
23 PointerArray fallthrough_modes;
24 } ModeHandler;
25
26 5 static inline ModeHandler *get_mode_handler(HashMap *modes, const char *name)
27 {
28 5 return hashmap_get(modes, name);
29 }
30
31 struct EditorState;
32 bool handle_input(struct EditorState *e, KeyCode key) NONNULL_ARGS;
33 ModeHandler *new_mode(HashMap *modes, char *name, const CommandSet *cmds) NONNULL_ARGS_AND_RETURN;
34 void string_append_def_mode(String *buf, const ModeHandler *mode) NONNULL_ARGS;
35 void collect_modes(const HashMap *modes, PointerArray *a, const char *prefix) NONNULL_ARGS;
36
37 #endif
38