diff options
author | sabetts <sabetts> | 2001-10-18 22:47:45 +0000 |
---|---|---|
committer | sabetts <sabetts> | 2001-10-18 22:47:45 +0000 |
commit | 89c4411a9cc3bdb756cff8746f4333df610ab455 (patch) | |
tree | cdf25ccc98325d272c8d8f6ccd477c43833f24d6 /src/actions.c | |
parent | 0b7d45f2a5590f332f7528b7455b82513f28b9dc (diff) | |
download | ratpoison-89c4411a9cc3bdb756cff8746f4333df610ab455.zip |
* 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
Diffstat (limited to 'src/actions.c')
-rw-r--r-- | src/actions.c | 60 |
1 files changed, 57 insertions, 3 deletions
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; +} |