summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2009-07-18 14:59:25 +0000
committerNicholas Marriott <nicm@openbsd.org>2009-07-18 14:59:25 +0000
commitfc6a65c6207dbefcd8b5f187148978f8d4111b2b (patch)
tree44ab21ea7bf632204830ed4e5516f89dae756dbe
parent0ca6f667e3e6f26e92db01ee2a769d0ba49509ca (diff)
Add three new session options: visual-activity, visual-bell, visual-content. If
these are enabled (and the monitor-activity, bell-actio and monitor-content options are configurated appropriately), when activity, a bell, or content is detected, a message is shown. Also tidy up the bell/activity/content code in server.c slightly and fix a couple of errors.
-rw-r--r--cmd-set-option.c3
-rw-r--r--server.c88
-rw-r--r--tmux.124
-rw-r--r--tmux.c3
-rw-r--r--tmux.h4
5 files changed, 104 insertions, 18 deletions
diff --git a/cmd-set-option.c b/cmd-set-option.c
index c9b1fd99..fc665e84 100644
--- a/cmd-set-option.c
+++ b/cmd-set-option.c
@@ -75,6 +75,9 @@ const struct set_option_entry set_option_table[] = {
{ "status-right", SET_OPTION_STRING, 0, 0, NULL },
{ "status-right-length", SET_OPTION_NUMBER, 0, SHRT_MAX, NULL },
{ "status-utf8", SET_OPTION_FLAG, 0, 0, NULL },
+ { "visual-activity", SET_OPTION_FLAG, 0, 0, NULL },
+ { "visual-bell", SET_OPTION_FLAG, 0, 0, NULL },
+ { "visual-content", SET_OPTION_FLAG, 0, 0, NULL },
{ NULL, 0, 0, 0, NULL }
};
diff --git a/server.c b/server.c
index ec1b1924..cdde3996 100644
--- a/server.c
+++ b/server.c
@@ -55,8 +55,7 @@ void server_handle_clients(struct pollfd **);
struct client *server_accept_client(int);
void server_handle_client(struct client *);
void server_handle_window(struct window *, struct window_pane *);
-int server_check_window_bell(struct session *, struct window *,
- struct window_pane *);
+int server_check_window_bell(struct session *, struct window *);
int server_check_window_activity(struct session *,
struct window *);
int server_check_window_content(struct session *, struct window *,
@@ -909,7 +908,7 @@ server_handle_window(struct window *w, struct window_pane *wp)
if (s == NULL || !session_has(s, w))
continue;
- update += server_check_window_bell(s, w, wp);
+ update += server_check_window_bell(s, w);
update += server_check_window_activity(s, w);
update += server_check_window_content(s, w, wp);
}
@@ -920,12 +919,11 @@ server_handle_window(struct window *w, struct window_pane *wp)
}
int
-server_check_window_bell(
- struct session *s, struct window *w, struct window_pane *wp)
+server_check_window_bell(struct session *s, struct window *w)
{
struct client *c;
u_int i;
- int action;
+ int action, visual;
if (!(w->flags & WINDOW_BELL))
return (0);
@@ -938,19 +936,38 @@ server_check_window_bell(
case BELL_ANY:
if (s->flags & SESSION_UNATTACHED)
break;
+ visual = options_get_number(&s->options, "visual-bell");
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
c = ARRAY_ITEM(&clients, i);
- if (c != NULL && c->session == s)
+ if (c == NULL || c->session != s)
+ continue;
+ if (!visual) {
tty_putcode(&c->tty, TTYC_BEL);
+ continue;
+ }
+ if (c->session->curw->window == w) {
+ status_message_set(c, "Bell in current window");
+ continue;
+ }
+ status_message_set(c, "Bell in window %u",
+ winlink_find_by_window(&s->windows, w)->idx);
}
break;
case BELL_CURRENT:
- if (w->active != wp)
+ if (s->flags & SESSION_UNATTACHED)
break;
+ visual = options_get_number(&s->options, "visual-bell");
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
c = ARRAY_ITEM(&clients, i);
- if (c != NULL && c->session == s)
+ if (c == NULL || c->session != s)
+ continue;
+ if (c->session->curw->window != w)
+ continue;
+ if (!visual) {
tty_putcode(&c->tty, TTYC_BEL);
+ continue;
+ }
+ status_message_set(c, "Bell in current window");
}
break;
}
@@ -960,13 +977,33 @@ server_check_window_bell(
int
server_check_window_activity(struct session *s, struct window *w)
{
+ struct client *c;
+ u_int i;
+
if (!(w->flags & WINDOW_ACTIVITY))
return (0);
+
if (!options_get_number(&w->options, "monitor-activity"))
return (0);
+
if (session_alert_has_window(s, w, WINDOW_ACTIVITY))
return (0);
+ if (s->curw->window == w)
+ return (0);
+
session_alert_add(s, w, WINDOW_ACTIVITY);
+ if (s->flags & SESSION_UNATTACHED)
+ return (0);
+ if (options_get_number(&s->options, "visual-activity")) {
+ for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
+ c = ARRAY_ITEM(&clients, i);
+ if (c == NULL || c->session != s)
+ continue;
+ status_message_set(c, "Activity in window %u",
+ winlink_find_by_window(&s->windows, w)->idx);
+ }
+ }
+
return (1);
}
@@ -974,20 +1011,39 @@ int
server_check_window_content(
struct session *s, struct window *w, struct window_pane *wp)
{
- char *found, *ptr;
-
- if (!(w->flags & WINDOW_CONTENT))
- return (0);
- if ((ptr = options_get_string(&w->options, "monitor-content")) == NULL)
+ struct client *c;
+ u_int i;
+ char *found, *ptr;
+
+ if (!(w->flags & WINDOW_ACTIVITY)) /* activity for new content */
return (0);
- if (*ptr == '\0')
+
+ ptr = options_get_string(&w->options, "monitor-content");
+ if (ptr == NULL || *ptr == '\0')
return (0);
+
if (session_alert_has_window(s, w, WINDOW_CONTENT))
return (0);
+ if (s->curw->window == w)
+ return (0);
+
if ((found = window_pane_search(wp, ptr, NULL)) == NULL)
return (0);
- session_alert_add(s, w, WINDOW_CONTENT);
xfree(found);
+
+ session_alert_add(s, w, WINDOW_CONTENT);
+ if (s->flags & SESSION_UNATTACHED)
+ return (0);
+ if (options_get_number(&s->options, "visual-content")) {
+ for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
+ c = ARRAY_ITEM(&clients, i);
+ if (c == NULL || c->session != s)
+ continue;
+ status_message_set(c, "Content in window %u",
+ winlink_find_by_window(&s->windows, w)->idx);
+ }
+ }
+
return (1);
}
diff --git a/tmux.1 b/tmux.1
index af7ad53d..e7041ec1 100644
--- a/tmux.1
+++ b/tmux.1
@@ -1324,6 +1324,30 @@ and
.Ic status-right
strings as UTF-8; notably, this is important for wide characters.
This option defaults to off.
+.It Xo Ic visual-activity
+.Op Ic on | Ic off
+.Xc
+If on, display a status line message when activity occurs in a window
+for with the
+.Ic monitor-activity
+window option is enabled.
+.It Xo Ic visual-bell
+.Op Ic on | Ic off
+.Xc
+If this option is on, a message is shown on a bell instead of it being passed
+through to the terminal (which normally makes a sound).
+Also see the
+.Ic bell-action
+option.
+.It Xo Ic visual-content
+.Op Ic on | Ic off
+.Xc
+Like
+.Ic visual-activity ,
+display a message when content is present in a window
+for with the
+.Ic monitor-content
+window option is enabled.
.El
.It Xo Ic set-password
.Op Fl c
diff --git a/tmux.c b/tmux.c
index a5edb460..5cca15f6 100644
--- a/tmux.c
+++ b/tmux.c
@@ -312,6 +312,9 @@ main(int argc, char **argv)
options_set_number(&global_s_options, "status-utf8", 1);
else
options_set_number(&global_s_options, "status-utf8", 0);
+ options_set_number(&global_s_options, "visual-activity", 0);
+ options_set_number(&global_s_options, "visual-bell", 0);
+ options_set_number(&global_s_options, "visual-content", 0);
options_init(&global_w_options, NULL);
options_set_number(&global_w_options, "aggressive-resize", 0);
diff --git a/tmux.h b/tmux.h
index d6bfcc4b..62c399f3 100644
--- a/tmux.h
+++ b/tmux.h
@@ -644,8 +644,8 @@ struct window {
#define WINDOW_BELL 0x1
#define WINDOW_HIDDEN 0x2
#define WINDOW_ACTIVITY 0x4
-#define WINDOW_CONTENT 0x6
-#define WINDOW_REDRAW 0x8
+#define WINDOW_CONTENT 0x8
+#define WINDOW_REDRAW 0x10
struct options options;