From 89c4411a9cc3bdb756cff8746f4333df610ab455 Mon Sep 17 00:00:00 2001 From: sabetts Date: Thu, 18 Oct 2001 22:47:45 +0000 Subject: * src/split.c (show_frame_indicator): call XSync after clearing the window. * src/input.c (get_more_input): clear the window after it is raised. Call XSync aftwards. * src/conf.h (MAX_LINK_DEPTH): new define * src/bar.c (marked_message): clear the window after it is raised. Call XSync aftwards. * src/actions.h (cmd_link): new prototype * src/actions.c (user_command): new command 'link' (find_command_by_keydesc): new function (resolve_command_from_keydesc): likewise (cmd_link): likewise --- src/actions.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 57 insertions(+), 3 deletions(-) (limited to 'src/actions.c') diff --git a/src/actions.c b/src/actions.c index 3f10ffe..0efc8c3 100644 --- a/src/actions.c +++ b/src/actions.c @@ -77,6 +77,7 @@ static user_command user_commands[] = {"lastmsg", cmd_lastmsg, arg_VOID}, {"restart", cmd_restart, arg_VOID}, {"startup_message", cmd_startup_message, arg_STRING}, + {"link", cmd_link, arg_STRING}, /* Commands to set default behavior. */ {"defbarloc", cmd_defbarloc, arg_STRING}, @@ -139,6 +140,46 @@ find_keybinding (KeySym keysym, int state) return NULL; } +static char * +find_command_by_keydesc (char *desc) +{ + int i = 0; + char *keysym_name; + + while (i < key_actions_last) + { + keysym_name = keysym_to_string (key_actions[i].key, key_actions[i].state); + if (!strcmp (keysym_name, desc)) + { + free (keysym_name); + return key_actions[i].data; + } + free (keysym_name); + i++; + } + + return NULL; +} + +static char * +resolve_command_from_keydesc (char *desc, int depth) +{ + char *cmd, *command; + + command = find_command_by_keydesc (desc); + if (!command) + return NULL; + + /* is it a link? */ + if (strncmp (command, "link", 4) || depth > MAX_LINK_DEPTH) + /* it is not */ + return command; + + cmd = resolve_command_from_keydesc (&command[5], depth + 1); + return (cmd != NULL) ? cmd : command; +} + + static void add_keybinding (KeySym keysym, int state, char *cmd) { @@ -1227,9 +1268,7 @@ cmd_help (int interactive, void *data) keysym_name, strlen (keysym_name)); if (XTextWidth (defaults.font, keysym_name, strlen (keysym_name)) > max_width) - { - max_width = XTextWidth (defaults.font, keysym_name, strlen (keysym_name)); - } + max_width = XTextWidth (defaults.font, keysym_name, strlen (keysym_name)); free (keysym_name); } @@ -1938,3 +1977,18 @@ cmd_focuslast (int interactive, void *data) return NULL; } + +char * +cmd_link (int interactive, void *data) +{ + char *cmd = NULL; + + if (!data) + return NULL; + + cmd = resolve_command_from_keydesc ((char *)data, 0); + if (cmd) + return command (interactive, cmd); + + return NULL; +} -- cgit v1.2.3