The branch, hooks has been updated
via 5e5b1c8843541e6e2f6d3b21c0869dec1acde287 (commit)
from 0c96f400787e2e1b8233a264a8527b8467ece1ca (commit)
- Log -----------------------------------------------------------------
commit 5e5b1c8843541e6e2f6d3b21c0869dec1acde287
Author: Thomas Adam <[email protected]>
Commit: Thomas Adam <[email protected]>
Provide hooks for bell/activity/silence
---
server-window.c | 47 ++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 42 insertions(+), 5 deletions(-)
diff --git a/server-window.c b/server-window.c
index a14c315..c2dc177 100644
--- a/server-window.c
+++ b/server-window.c
@@ -24,10 +24,22 @@
#include "tmux.h"
-int server_window_check_bell(struct session *, struct winlink *);
-int server_window_check_activity(struct session *, struct winlink *);
-int server_window_check_silence(struct session *, struct winlink *);
-void ring_bell(struct session *);
+int server_window_check_bell(struct session *, struct winlink *);
+int server_window_check_activity(struct session *, struct winlink *);
+int server_window_check_silence(struct session *, struct winlink *);
+void server_window_run_hooks(struct session *, struct winlink *);
+void ring_bell(struct session *);
+
+struct window_flag_hook {
+ int flag;
+ const char *name;
+};
+
+const struct window_flag_hook window_flag_hook_names[] = {
+ {WINLINK_BELL, "on-window-bell"},
+ {WINLINK_ACTIVITY, "on-window-activity"},
+ {WINLINK_SILENCE, "on-window-silence"},
+};
/* Window functions that need to happen every loop. */
void
@@ -50,12 +62,37 @@ server_window_loop(void)
if (server_window_check_bell(s, wl) ||
server_window_check_activity(s, wl) ||
- server_window_check_silence(s, wl))
+ server_window_check_silence(s, wl)) {
+ server_window_run_hooks(s, wl);
server_status_session(s);
+ }
}
}
}
+/* Run any hooks associated with monitored events. */
+void
+server_window_run_hooks(struct session *s, struct winlink *wl)
+{
+ struct hooks *hooks;
+ const char *hook_name = NULL;
+ u_int i;
+
+ for (i = 0; i < nitems(window_flag_hook_names); i++) {
+ if (wl->flags & window_flag_hook_names[i].flag) {
+ hook_name = window_flag_hook_names[i].name;
+ break;
+ }
+ }
+
+ if (hook_name == NULL)
+ return;
+
+ hooks = s == NULL ? &global_hooks : &s->hooks;
+ cmdq_hooks_run(hooks, NULL, hook_name, NULL);
+}
+
+
/* Check for bell in window. */
int
server_window_check_bell(struct session *s, struct winlink *wl)
-----------------------------------------------------------------------
Summary of changes:
server-window.c | 47 ++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 42 insertions(+), 5 deletions(-)
hooks/post-receive
--
tmux
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
tmux-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tmux-cvs