home · contact · privacy
Client: Moved KeyBindingDB selection by char into keybindings library, making wrapper...
[plomrogue] / src / client / keybindings.h
1 /* src/client/keybindings.h
2  *
3  * Database of keybindings and functions to read and manipulate it.
4  */
5
6 #ifndef KEYBINDINGS_H
7 #define KEYBINDINGS_H
8
9 #include <stdint.h> /* uint8_t, uint16_t */
10 struct Command;
11
12
13
14 struct KeyBinding
15 {
16   struct KeyBinding * next;
17   uint16_t key; /* keycode */
18   struct Command * command; /* command in command DB to which key is bound */
19 };
20
21 struct KeyBindingDB
22 {
23     struct KeyBinding * kbs;
24     uint16_t select; /* linear list index of keybinding selected for editing */
25     uint8_t edit;    /* 1 if currently editing a keybinding, else 0 */
26 };
27
28
29
30 /* Return command bound to keycode; NULL on failure. */
31 extern struct Command * get_command_to_keycode(struct KeyBinding * kb_p,
32                                                uint16_t key);
33
34 /* Return human-readable name (of maximum 9 chars) for "keycode" as matched by
35  * ncurses.h; if none is found, return "UNKNOWN".
36  */
37 extern char * get_keyname_to_keycode(uint16_t keycode);
38
39 /* Initialize/save keybindings data from/to file at "path" to/from keybindings
40  * data pointer "kbd".
41  */
42 extern void init_keybindings(char * path, struct KeyBindingDB * kbd);
43 extern void save_keybindings(char * path, struct KeyBindingDB * kbd);
44
45 /* Free keybinding chain starting at "kb_start". */
46 extern void free_keybindings(struct KeyBinding * kb_start);
47
48 /* Mark keybinding in KeybindingDB (char_selected_kb_db()-) selected by "kb_c"
49  * as being edited, get user input to modify it, then unmark it again. Ensure
50  * there are max. three digits in the ASCII string of the kecode read from user.
51  */
52 extern void mod_selected_keyb(char kb_c);
53
54 /* Move .select in KeybindingDB (char-selected_kb_db()-) selected by "kb_c"
55  * upwards ("dir"=="u") or downwards ("dir"=="d") within KeyBindingDB limits.
56  */
57 extern void move_keyb_selection(char kb_c, char dir);
58
59
60
61 #endif