diff options
author | rcyeske <rcyeske> | 2001-02-24 21:46:48 +0000 |
---|---|---|
committer | rcyeske <rcyeske> | 2001-02-24 21:46:48 +0000 |
commit | d0da7f4c96c1bda168b176257b6e06800e943f7d (patch) | |
tree | e78542d4b72aedcf6d601bed6f553bd7d23236b5 /src/actions.c | |
parent | ee0dedbfbf28b084c507891e37c28fede2b61644 (diff) | |
download | ratpoison-d0da7f4c96c1bda168b176257b6e06800e943f7d.zip |
fix key rebinding
Diffstat (limited to 'src/actions.c')
-rw-r--r-- | src/actions.c | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/src/actions.c b/src/actions.c index a132abc..0d8f2b7 100644 --- a/src/actions.c +++ b/src/actions.c @@ -70,6 +70,15 @@ add_keybinding (int keysym, int state, char *cmd) ++key_actions_last; } +static void +replace_keybinding (rp_action *key_action, char *newcmd) +{ + if (strlen (key_action->data) < strlen (newcmd)) + key_action->data = (char*) realloc (key_action->data, strlen (newcmd) + 1); + + strcpy (key_action->data, newcmd); +} + void initialize_default_keybindings (void) { @@ -221,19 +230,23 @@ cmd_bind (void *data) message (" FIXME: cmd_bind: need a command to bind to key "); else { - char foo[1000]; - struct key *key = parse_keydesc (keydesc); - + if (key) { + rp_action *key_action; + char foo[1000]; + sprintf (foo, " %ld %ld : '%s' ", key->state, key->sym, cmd); - add_keybinding (key->sym, key->state, cmd); + message (foo); + + if ((key_action = find_keybinding (key->sym, key->state))) + replace_keybinding (key_action, cmd); + else + add_keybinding (key->sym, key->state, cmd); } else - sprintf (foo, " FIXME: cmd_bind: couldnt parse key "); - - message (foo); + message (" FIXME: cmd_bind: couldnt parse key "); } } |