X-Git-Url: https://plomlompom.com/repos/?a=blobdiff_plain;f=src%2Fkeybindings.h;h=ce15e6680197b19504145f800e2dd14d4d2b7368;hb=550d22ec0c3f530f5d317746f3f7e75251a1de4b;hp=d400414b33c62183b628357a7a9683141a651589;hpb=140cadf8f8dc73a1756169dbfa7cb5f05e3b8b8c;p=plomrogue diff --git a/src/keybindings.h b/src/keybindings.h index d400414..ce15e66 100644 --- a/src/keybindings.h +++ b/src/keybindings.h @@ -10,11 +10,10 @@ #include /* for uint16_t */ struct World; -struct WinMeta; -/* Individual keybinding. */ +/* Individual keybinding in keybinding chain. */ struct KeyBinding { struct KeyBinding * next; @@ -24,48 +23,56 @@ struct KeyBinding -/* Metadata used by the keybinding editing window. */ -struct KeysWinData +/* Wrapper to keybinding chain, contains some keybinding editing metadata. */ +struct KeyBiData { - char edit; /* 1 if currently editing a keybinding, else 0 */ - uint16_t select; /* list index of keybinding selected for editing */ + struct KeyBinding * kbs; + uint8_t edit; /* 1 if currently editing a keybinding, else 0 */ + uint16_t select; /* linear list index of keybinding selected for editing */ }; /* Return keycode matched by keybinding to command of "name". */ -extern uint16_t get_keycode_to_action(struct KeyBinding * keybindings, char * name); +extern uint16_t get_keycode_to_action(struct KeyBinding * keybindings, + char * name); /* Return human-readable name (of maximum 9 chars) for "keycode" as matched by - * ncurses.h; if none is found, return "UNKNOWN". */ + * ncurses.h; if none is found, return "UNKNOWN". + */ extern char * get_name_to_keycode(struct World * world, uint16_t keycode); -/* Return number of keybindings in keybindings chain. */ -extern uint16_t get_n_of_keybs(struct World * world); +/* Return number of keybindings in keybindings chain from "kb_p" on. */ +extern uint16_t get_n_of_keybs(struct KeyBinding * kb_p); -/* Return "n"-th keybinding in keybindings chain. */ -extern struct KeyBinding * get_keyb_of_n(struct World * world, uint16_t n); +/* Return "n"-th keybinding in keybindings chain from "kb_p" on. */ +extern struct KeyBinding * get_keyb_of_n(struct KeyBinding * kb_p, uint16_t n); -/* Initialize keybindings data (by reading from file "keybindings"), save it (by - * writing to the same file) and free it. +/* Initialize/save keybindings data from/to file at "path" to/from keybindings + * data pointer "kbd". */ -extern void init_keybindings(struct World * world); -extern void save_keybindings(struct World * world); +extern void init_keybindings(struct World * world, char * path, + struct KeyBiData * kbd); +extern void save_keybindings(struct World * world, char * path, + struct KeyBiData * kbd); + +/* Free keybinding chain starting at "kb_start". */ extern void free_keybindings(struct KeyBinding * kb_start); -/* Mark selection in keybindings window modifiable, get user input to modify - * key. Ensure there are max. three digits in the keycode ASCII representation. +/* Mark keybinding selected for modification as being edited, get user input to + * modify it, then unmark it again. Ensure there are max. three digits in the + * keycode ASCII representation. */ -extern void keyswin_mod_key(struct World * world, struct WinMeta * win_meta); +extern void mod_selected_keyb(struct World * world, struct KeyBiData * kbd); -/* Move selection in keybinding window upwards ("dir" = "u") or downwards ("dir" - * = "d") within the limits of the keybindings list length. +/* Move keybinding modification selection upwards ("dir"=="u") or downwards + * ("dir"=="d") within the limits of the keybindings chain length. */ -extern void move_keys_mod_selection(struct World * world, char dir); +extern void move_keyb_mod_selection(struct KeyBiData * kbd, char dir);