From d0da7f4c96c1bda168b176257b6e06800e943f7d Mon Sep 17 00:00:00 2001 From: rcyeske Date: Sat, 24 Feb 2001 21:46:48 +0000 Subject: fix key rebinding --- src/ChangeLog | 9 +++++++++ src/actions.c | 27 ++++++++++++++++++++------- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 42bdb3a..d3a5e5a 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,12 @@ +2001-02-24 Ryan Yeske + + * conf.h: remove themes support + + * themes.h: remove file + + * actions.c (replace_keybinding): add function + (cmd_bind): handle binding of previously bound key + 2001-02-23 shawn * main.c (main): passes return value of find_window_other() to 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 "); } } -- cgit v1.2.3