From c2fdce9c9bccfa7107539a67fb67c9438efdfc26 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jonathan=20Neusch=C3=A4fer?= Date: Sat, 24 Dec 2011 18:28:04 +0100 Subject: [PATCH] screen_keydef: document delete_key --- src/screen_keydef.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) 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(); -- 2.30.2