diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2011-07-03 19:07:55 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2011-07-03 19:07:55 +0000 |
commit | 051b94109a7c527f73f6f30405f2fe393efc172a (patch) | |
tree | 16260df26e271e899e0b5b1cae30147435679dd3 /usr.bin/tmux/server-window.c | |
parent | 85088475792ee51a491722feb9d49d88cd9ff5bf (diff) |
Add an option to trigger the terminal bell when there is an alert, from
Marco Beck.
Diffstat (limited to 'usr.bin/tmux/server-window.c')
-rw-r--r-- | usr.bin/tmux/server-window.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/usr.bin/tmux/server-window.c b/usr.bin/tmux/server-window.c index f7b08e22e30..d89e0d482e8 100644 --- a/usr.bin/tmux/server-window.c +++ b/usr.bin/tmux/server-window.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server-window.c,v 1.20 2011/01/26 02:55:34 nicm Exp $ */ +/* $OpenBSD: server-window.c,v 1.21 2011/07/03 19:07:54 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -28,6 +28,7 @@ int server_window_check_activity(struct session *, struct winlink *); int server_window_check_silence(struct session *, struct winlink *); int server_window_check_content( struct session *, struct winlink *, struct window_pane *); +void ring_bell(struct session *); /* Window functions that need to happen every loop. */ void @@ -134,6 +135,8 @@ server_window_check_activity(struct session *s, struct winlink *wl) if (!options_get_number(&w->options, "monitor-activity")) return (0); + if (options_get_number(&s->options, "bell-on-alert")) + ring_bell(s); wl->flags |= WINLINK_ACTIVITY; if (options_get_number(&s->options, "visual-activity")) { @@ -183,6 +186,9 @@ server_window_check_silence(struct session *s, struct winlink *wl) timer_difference = timer.tv_sec - w->silence_timer.tv_sec; if (timer_difference <= silence_interval) return (0); + + if (options_get_number(&s->options, "bell-on-alert")) + ring_bell(s); wl->flags |= WINLINK_SILENCE; if (options_get_number(&s->options, "visual-silence")) { @@ -221,6 +227,8 @@ server_window_check_content( return (0); xfree(found); + if (options_get_number(&s->options, "bell-on-alert")) + ring_bell(s); wl->flags |= WINLINK_CONTENT; if (options_get_number(&s->options, "visual-content")) { @@ -235,3 +243,17 @@ server_window_check_content( return (1); } + +/* Ring terminal bell. */ +void +ring_bell(struct session *s) +{ + struct client *c; + u_int i; + + for (i = 0; i < ARRAY_LENGTH(&clients); i++) { + c = ARRAY_ITEM(&clients, i); + if (c != NULL && c->session == s) + tty_putcode(&c->tty, TTYC_BEL); + } +} |