diff options
author | sabetts <sabetts> | 2003-07-17 05:41:41 +0000 |
---|---|---|
committer | sabetts <sabetts> | 2003-07-17 05:41:41 +0000 |
commit | b7d55a9ae282d35b3a42267749f8f443620728d7 (patch) | |
tree | b919f3c6dee8331981ab696fe7923c507bafd888 /src/actions.c | |
parent | 19a5e7a0eb033abbd4d61b72a2023a8d012c9a5e (diff) | |
download | ratpoison-b7d55a9ae282d35b3a42267749f8f443620728d7.zip |
* src/window.c (set_active_window): run the switch window hook.
* src/split.c (set_active_frame): run the switch frame hook.
* src/ratpoison.h: include hook.h
* src/group.h (set_current_group): new prototype
* src/group.c (set_current_group): new function
* src/globals.h (rp_prefix_hook): new extern
(rp_switch_win_hook): likewise
(rp_switch_frame_hook): likewise
(rp_switch_group_hook): likewise
(rp_hook_db): likewise
* src/globals.c (rp_prefix_hook): new hook
(rp_switch_win_hook): likewise
(rp_switch_frame_hook): likewise
(rp_switch_group_hook): likewise
(rp_hook_db): new global
* src/events.c (handle_key): call the prefix hook.
* src/data.h (struct rp_hook_db_entry): new struct
* src/actions.h (cmd_addhook): new prototype
(cmd_remhook): likewise
* src/actions.c (user_commands): add commands addhook and remhook.
(cmd_windows): show the window bar no matter what if the bar
timeout is > 0.
(cmd_gnext): call set_current_group
(cmd_gprev): likewise
(cmd_gnew): likewise
(cmd_gselect): likewise
(cmd_addhook): new function
(cmd_remhook): likewise
* src/Makefile.am (ratpoison_SOURCES): add hook.c and hook.h
Diffstat (limited to 'src/actions.c')
-rw-r--r-- | src/actions.c | 104 |
1 files changed, 99 insertions, 5 deletions
diff --git a/src/actions.c b/src/actions.c index d51f326..34acf40 100644 --- a/src/actions.c +++ b/src/actions.c @@ -106,6 +106,8 @@ static user_command user_commands[] = {"groups", cmd_groups, arg_VOID}, {"gmove", cmd_gmove, arg_VOID}, {"gmerge", cmd_gmerge, arg_VOID}, + {"addhook", cmd_addhook, arg_STRING}, + {"remhook", cmd_remhook, arg_STRING}, /* Commands to set default behavior. */ {"defbargravity", cmd_defbargravity, arg_STRING}, @@ -1343,7 +1345,13 @@ cmd_windows (int interactive, char *data) if (interactive) { s = current_screen (); - if (!hide_bar (s)) show_bar (s); + /* This is a yukky hack. If the bar already hidden then show the + bar. This handles the case when msgwait is 0 (the bar sticks) + and the user uses this command to toggle the bar on and + off. OR the timeout is >0 then show the bar. Which means, + always show the bar if msgwait is >0 which fixes the case + when a command in the prefix hook displays the bar. */ + if (!hide_bar (s) || defaults.bar_timeout > 0) show_bar (s); return NULL; } @@ -3424,21 +3432,21 @@ cmd_defwinliststyle (int interactive, char *data) char * cmd_gnext (int interactive, char *data) { - rp_current_group = group_next_group (); + set_current_group (group_next_group ()); return NULL; } char * cmd_gprev (int interactive, char *data) { - rp_current_group = group_prev_group (); + set_current_group (group_prev_group ()); return NULL; } char * cmd_gnew (int interactive, char *data) { - rp_current_group = group_add_new_group (data); + set_current_group (group_add_new_group (data)); return NULL; } @@ -3521,7 +3529,7 @@ cmd_gselect (int interactive, char *data) g = find_group (str); if (g) - rp_current_group = g; + set_current_group (g); else return cmd_groups (interactive, NULL); @@ -3646,3 +3654,89 @@ cmd_gmerge (int interactive, char *data) return NULL; } + +char * +cmd_addhook (int interactive, char *data) +{ + char *dup; + char *token; + struct list_head *hook; + struct sbuf *cmd; + + if (data == NULL) + { + message (" addhook: two arguments required "); + return NULL; + } + + dup = xstrdup (data); + token = strtok (dup, " "); + + hook = hook_lookup (token); + if (hook == NULL) + { + marked_message_printf (0, 0, " addhook: unknown hook \"%s\"", token); + free (dup); + return NULL; + } + + token = strtok (NULL, "\0"); + + if (token == NULL) + { + message (" addhook: two arguments required "); + free (dup); + return NULL; + } + + /* Add the command to the hook */ + cmd = sbuf_new (0); + sbuf_copy (cmd, token); + hook_add (hook, cmd); + + free (dup); + return NULL; +} + +char * +cmd_remhook (int interactive, char *data) +{ + char *dup; + char *token; + struct list_head *hook; + struct sbuf *cmd; + + if (data == NULL) + { + message (" remhook: two arguments required "); + return NULL; + } + + dup = xstrdup (data); + token = strtok (dup, " "); + + hook = hook_lookup (token); + if (hook == NULL) + { + marked_message_printf (0, 0, " addhook: unknown hook \"%s\"", token); + free (dup); + return NULL; + } + + token = strtok (NULL, "\0"); + + if (token == NULL) + { + message (" addhook: two arguments required "); + free (dup); + return NULL; + } + + /* Add the command to the hook */ + cmd = sbuf_new (0); + sbuf_copy (cmd, token); + hook_remove (hook, cmd); + + free (dup); + return NULL; +} |