3 * Retrieval and storage of keybindings.
11 #include <stdint.h> /* for uint16_t */
17 /* Individual keybinding. */
20 struct KeyBinding * next;
21 uint16_t key; /* keycode */
22 char * name; /* name of functionality bound to keycode */
27 /* Metadata used by the keybinding editing window. */
30 char edit; /* 1 if currently editing a keybinding, else 0 */
31 uint16_t select; /* list index of keybinding selected for editing */
36 /* Return keycode matched by keybinding to command of "name". */
37 extern uint16_t get_keycode_to_action(struct KeyBinding * keybindings, char * name);
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);
43 /* Return number of keybindings in keybindings chain. */
44 extern uint16_t get_n_of_keybs(struct World * world);
46 /* Return "n"-th keybinding in keybindings chain. */
47 extern struct KeyBinding * get_keyb_of_n(struct World * world, uint16_t n);
51 /* Initialize keybindings data (by reading from file "keybindings"), save it (by
52 * writing to the same file) and free it.
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);
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.
63 extern void keyswin_mod_key(struct World * world, struct WinMeta * win_meta);
65 /* Move selection in keybinding window upwards ("dir" = "u") or downwards ("dir"
66 * = "d") within the limits of the keybindings list length.
68 extern void move_keys_mod_selection(struct World * world, char dir);