summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: b65bf33)
raw | patch | inline | side by side (parent: b65bf33)
author | Jonathan Neuschäfer <j.neuschaefer@gmx.net> | |
Sat, 24 Dec 2011 17:28:06 +0000 (18:28 +0100) | ||
committer | Jonathan Neuschäfer <j.neuschaefer@gmx.net> | |
Sat, 24 Dec 2011 17:28:06 +0000 (18:28 +0100) |
src/screen_keydef.c | patch | blob | history |
diff --git a/src/screen_keydef.c b/src/screen_keydef.c
index 92c5d3c1ed037a8cbb07bfd4398729b2aeb1e8dc..87c5067c301864539b1cd56b94e0f3678f737f27 100644 (file)
--- a/src/screen_keydef.c
+++ b/src/screen_keydef.c
check_key_bindings(cmds, NULL, 0);
}
+/* assigns a new key to a key slot */
static void
-assign_new_key(int cmd_index, int key_index)
+overwrite_key(int cmd_index, int key_index)
{
int key;
char *buf;
command_t cmd;
+ assert(key_index < MAX_COMMAND_KEYS);
+
buf = g_strdup_printf(_("Enter new key for %s: "), cmds[cmd_index].name);
key = screen_getch(buf);
g_free(buf);
check_key_bindings(cmds, NULL, 0);
}
+/* assign a new key to a new slot */
+static void
+add_key(int cmd_index)
+{
+ if (subcmd_n_keys < MAX_COMMAND_KEYS)
+ overwrite_key(cmd_index, subcmd_n_keys);
+}
+
static const char *
list_callback(unsigned idx, G_GNUC_UNUSED void *data)
{
subcmd = -1;
keydef_repaint();
+ } else if (lw->selected == subcmd_item_add) {
+ add_key(subcmd);
} else {
- /* TODO: subcmd_item_add should be handled
- separately, just for clarity */
- assign_new_key(subcmd, subcmd_item_to_key_id(lw->selected));
+ /* just to be sure ;-) */
+ assert(subcmd_item_is_key(lw->selected));
+ overwrite_key(subcmd, subcmd_item_to_key_id(lw->selected));
}
}
return true;