From: Jonathan Neuschäfer Date: Sat, 24 Dec 2011 17:28:04 +0000 (+0100) Subject: screen_keydef: document delete_key X-Git-Tag: release-0.20~23 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=c2fdce9c9bccfa7107539a67fb67c9438efdfc26;p=ncmpc.git screen_keydef: document delete_key --- diff --git a/src/screen_keydef.c b/src/screen_keydef.c index 6e19d8d..800e54f 100644 --- a/src/screen_keydef.c +++ b/src/screen_keydef.c @@ -131,18 +131,29 @@ keydef_repaint(void) wrefresh(lw->w); } +/** + * Delete a key from a given command's definition + * @param cmd_index the command + * @param key_index the key (see below) + */ static void delete_key(int cmd_index, int key_index) { + /* shift the keys to close the gap that appeared */ int i = key_index+1; - - screen_status_printf(_("Deleted")); while (i < MAX_COMMAND_KEYS && cmds[cmd_index].keys[i]) cmds[cmd_index].keys[key_index++] = cmds[cmd_index].keys[i++]; + + /* As key_index now holds the index of the last key slot that contained + a key, we use it to empty this slot, because this key has been copied + to the previous slot in the loop above */ cmds[cmd_index].keys[key_index] = 0; + cmds[cmd_index].flags |= COMMAND_KEY_MODIFIED; check_subcmd_length(); + screen_status_printf(_("Deleted")); + /* repaint */ keydef_repaint();