home · contact · privacy
Made keybindings array into linked list; on the way rewrote / improved great parts...
[plomrogue] / src / keybindings.h
1 /* keybindings.h
2  *
3  * Retrieval and storage of keybindings.
4  */
5
6 #ifndef KEYBINDINGS_H
7 #define KEYBINDINGS_H
8
9
10
11 #include <stdint.h> /* for uint16_t */
12 struct World;
13 struct WinMeta;
14
15
16
17 /* Individual keybinding. */
18 struct KeyBinding
19 {
20   struct KeyBinding * next;
21   uint16_t key; /* keycode */
22   char * name;  /* name of functionality bound to keycode */
23 };
24
25
26
27 /* Metadata used by the keybinding editing window. */
28 struct KeysWinData
29 {
30   char edit;       /* 1 if currently editing a keybinding, else 0 */
31   uint16_t select; /* list index of keybinding selected for editing */
32 };
33
34
35
36 /* Return keycode matched by keybinding to command of "name". */
37 extern uint16_t get_keycode_to_action(struct KeyBinding * keybindings, char * name);
38
39 /* Return human-readable name (of maximum 9 chars) for "keycode" as matched by
40  * ncurses.h; if none is found, return "UNKNOWN". */
41 extern char * get_name_to_keycode(struct World * world, uint16_t keycode);
42
43 /* Return number of keybindings in keybindings chain. */
44 extern uint16_t get_n_of_keybs(struct World * world);
45
46 /* Return "n"-th keybinding in keybindings chain. */
47 extern struct KeyBinding * get_keyb_of_n(struct World * world, uint16_t n);
48
49
50
51 /* Initialize keybindings data (by reading from file "keybindings"), save it (by
52  * writing to the same file) and free it.
53  */
54 extern void init_keybindings(struct World * world);
55 extern void save_keybindings(struct World * world);
56 extern void free_keybindings(struct KeyBinding * kb_start);
57
58
59
60 /* Mark selection in keybindings window modifiable, get user input to modify
61  * key. Ensure there are max. three digits in the keycode ASCII representation.
62  */
63 extern void keyswin_mod_key(struct World * world, struct WinMeta * win_meta);
64
65 /* Move selection in keybinding window upwards ("dir" = "u") or downwards ("dir"
66  * = "d") within the limits of the keybindings list length.
67  */
68 extern void move_keys_mod_selection(struct World * world, char dir);
69
70
71
72 #endif