Update of /cvsroot/tmux/tmux
In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv31288

Modified Files:
        cmd-choose-window.c cmd-set-option.c input.c server-window.c 
        status.c tmux.1 tmux.c tmux.h window.c 
Log Message:
Add an option to alert (monitor) for silence (lack of activity) in a
window. From Thomas Adam.



Index: tmux.1
===================================================================
RCS file: /cvsroot/tmux/tmux/tmux.1,v
retrieving revision 1.273
retrieving revision 1.274
diff -u -d -r1.273 -r1.274
--- tmux.1      6 Dec 2010 21:59:42 -0000       1.273
+++ tmux.1      6 Dec 2010 22:52:21 -0000       1.274
@@ -2053,6 +2053,12 @@
 for which the
 .Ic monitor-content
 window option is enabled.
+.It Xo Ic visual-silence
+.Op Ic on | off
+.Xc
+If
+.Ic monitor-silence
+is enabled, prints a message after the interval has expired on a given window.
 .El
 .It Xo Ic set-window-option
 .Op Fl agu
@@ -2175,6 +2181,16 @@
 .Ar match-string
 appears in the window, it is highlighted in the status line.
 .Pp
+.It Xo Ic monitor-silence
+.Op Ic interval
+.Xc
+Monitor for silence (no activity) in the window within
+.Ic interval
+seconds.
+Windows that have been silent for the interval are highlighted in the
+status line.
+An interval of zero disables the monitoring.
+.Pp
 .It Xo Ic remain-on-exit
 .Op Ic on | off
 .Xc
@@ -2386,6 +2402,7 @@
 .It Li "#" Ta "Window is monitored and activity has been detected."
 .It Li "!" Ta "A bell has occurred in the window."
 .It Li "+" Ta "Window is monitored for content and it has appeared."
+.It Li "~" Ta "The window has been silent for the monitor-silence interval."
 .El
 .Pp
 The # symbol relates to the

Index: cmd-choose-window.c
===================================================================
RCS file: /cvsroot/tmux/tmux/cmd-choose-window.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- cmd-choose-window.c 22 Jun 2010 23:26:18 -0000      1.22
+++ cmd-choose-window.c 6 Dec 2010 22:52:20 -0000       1.23
@@ -87,6 +87,8 @@
                        flag = '!';
                else if (wm->flags & WINLINK_CONTENT)
                        flag = '+';
+               else if (wm->flags & WINLINK_SILENCE)
+                       flag = '~';
                else if (wm == s->curw)
                        flag = '*';
                else if (wm == TAILQ_FIRST(&s->lastw))

Index: input.c
===================================================================
RCS file: /cvsroot/tmux/tmux/input.c,v
retrieving revision 1.109
retrieving revision 1.110
diff -u -d -r1.109 -r1.110
--- input.c     18 Apr 2010 15:11:47 -0000      1.109
+++ input.c     6 Dec 2010 22:52:21 -0000       1.110
@@ -681,7 +681,9 @@
 
        if (EVBUFFER_LENGTH(evb) == 0)
                return;
+
        wp->window->flags |= WINDOW_ACTIVITY;
+       wp->window->flags &= ~WINDOW_SILENCE;
 
        /*
         * Open the screen. Use NULL wp if there is a mode set as don't want to

Index: server-window.c
===================================================================
RCS file: /cvsroot/tmux/tmux/server-window.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- server-window.c     11 Aug 2010 22:16:03 -0000      1.17
+++ server-window.c     6 Dec 2010 22:52:21 -0000       1.18
@@ -26,6 +26,7 @@
 int    server_window_backoff(struct window_pane *);
 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 *);
 int    server_window_check_content(
            struct session *, struct winlink *, struct window_pane *);
 
@@ -53,7 +54,8 @@
                                continue;
 
                        if (server_window_check_bell(s, wl) ||
-                           server_window_check_activity(s, wl))
+                           server_window_check_activity(s, wl) ||
+                           server_window_check_silence(s, wl))
                                server_status_session(s);
                        TAILQ_FOREACH(wp, &w->panes, entry)
                                server_window_check_content(s, wl, wp);
@@ -151,6 +153,55 @@
        return (1);
 }
 
+/* Check for silence in window. */
+int
+server_window_check_silence(struct session *s, struct winlink *wl)
+{
+       struct client   *c;
+       struct window   *w = wl->window;
+       struct timeval   timer;
+       u_int            i;
+       int              silence_interval, timer_difference;
+
+       if (!(w->flags & WINDOW_SILENCE) || wl->flags & WINLINK_SILENCE)
+               return (0);
+
+       if (s->curw == wl) {
+               /*
+                * Reset the timer for this window if we've focused it.  We
+                * don't want the timer tripping as soon as we've switched away
+                * from this window.
+                */
+               if (gettimeofday(&w->silence_timer, NULL) != 0)
+                       fatal("gettimeofday failed.");
+
+               return (0);
+       }
+
+       silence_interval = options_get_number(&w->options, "monitor-silence");
+       if (silence_interval == 0)
+               return (0);
+
+       if (gettimeofday(&timer, NULL) != 0)
+               fatal("gettimeofday");
+       timer_difference = timer.tv_sec - w->silence_timer.tv_sec;
+       if (timer_difference <= silence_interval)
+               return (0);
+       wl->flags |= WINLINK_SILENCE;
+
+       if (options_get_number(&s->options, "visual-silence")) {
+               for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
+                       c = ARRAY_ITEM(&clients, i);
+                       if (c == NULL || c->session != s)
+                               continue;
+                       status_message_set(c, "Silence in window %u",
+                           winlink_find_by_window(&s->windows, w)->idx);
+               }
+       }
+
+       return (1);
+}
+
 /* Check for content change in window. */
 int
 server_window_check_content(

Index: cmd-set-option.c
===================================================================
RCS file: /cvsroot/tmux/tmux/cmd-set-option.c,v
retrieving revision 1.100
retrieving revision 1.101
diff -u -d -r1.100 -r1.101
--- cmd-set-option.c    9 Oct 2010 14:29:32 -0000       1.100
+++ cmd-set-option.c    6 Dec 2010 22:52:20 -0000       1.101
@@ -136,6 +136,7 @@
        { "visual-activity", SET_OPTION_FLAG, 0, 0, NULL },
        { "visual-bell", SET_OPTION_FLAG, 0, 0, NULL },
        { "visual-content", SET_OPTION_FLAG, 0, 0, NULL },
+       { "visual-silence", SET_OPTION_FLAG, 0, 0, NULL },
        { NULL, 0, 0, 0, NULL }
 };
 
@@ -157,6 +158,7 @@
        { "mode-mouse", SET_OPTION_FLAG, 0, 0, NULL },
        { "monitor-activity", SET_OPTION_FLAG, 0, 0, NULL },
        { "monitor-content", SET_OPTION_STRING, 0, 0, NULL },
+       { "monitor-silence",SET_OPTION_NUMBER, 0, INT_MAX, NULL},
        { "remain-on-exit", SET_OPTION_FLAG, 0, 0, NULL },
        { "synchronize-panes", SET_OPTION_FLAG, 0, 0, NULL },
        { "utf8", SET_OPTION_FLAG, 0, 0, NULL },

Index: tmux.c
===================================================================
RCS file: /cvsroot/tmux/tmux/tmux.c,v
retrieving revision 1.223
retrieving revision 1.224
diff -u -d -r1.223 -r1.224
--- tmux.c      6 Dec 2010 21:59:42 -0000       1.223
+++ tmux.c      6 Dec 2010 22:52:21 -0000       1.224
@@ -382,6 +382,7 @@
        options_set_number(so, "visual-activity", 0);
        options_set_number(so, "visual-bell", 0);
        options_set_number(so, "visual-content", 0);
+       options_set_number(so, "visual-silence", 0);
 
        keylist = xmalloc(sizeof *keylist);
        ARRAY_INIT(keylist);
@@ -405,6 +406,7 @@
        options_set_number(wo, "mode-mouse", 0);
        options_set_number(wo, "monitor-activity", 0);
        options_set_string(wo, "monitor-content", "%s", "");
+       options_set_number(wo, "monitor-silence", 0);
        options_set_number(wo, "window-status-attr", 0);
        options_set_number(wo, "window-status-bg", 8);
        options_set_number(wo, "window-status-current-attr", 0);

Index: window.c
===================================================================
RCS file: /cvsroot/tmux/tmux/window.c,v
retrieving revision 1.141
retrieving revision 1.142
diff -u -d -r1.141 -r1.142
--- window.c    6 Dec 2010 21:53:50 -0000       1.141
+++ window.c    6 Dec 2010 22:52:21 -0000       1.142
@@ -636,6 +636,14 @@
        input_parse(wp);
 
        wp->pipe_off = EVBUFFER_LENGTH(wp->event->input);
+
+       /*
+        * If we get here, we're not outputting anymore, so set the silence
+        * flag on the window.
+        */
+       wp->window->flags |= WINDOW_SILENCE;
+       if (gettimeofday(&wp->window->silence_timer, NULL) != 0)
+               fatal("gettimeofday failed.");
 }
 
 /* ARGSUSED */

Index: tmux.h
===================================================================
RCS file: /cvsroot/tmux/tmux/tmux.h,v
retrieving revision 1.584
retrieving revision 1.585
diff -u -d -r1.584 -r1.585
--- tmux.h      6 Dec 2010 21:57:56 -0000       1.584
+++ tmux.h      6 Dec 2010 22:52:21 -0000       1.585
@@ -828,6 +828,7 @@
 struct window {
        char            *name;
        struct event     name_timer;
+       struct timeval   silence_timer;
 
        struct window_pane *active;
        struct window_pane *last;
@@ -843,6 +844,7 @@
 #define WINDOW_BELL 0x1
 #define WINDOW_ACTIVITY 0x2
 #define WINDOW_REDRAW 0x4
+#define WINDOW_SILENCE 0x8
 
        struct options   options;
 
@@ -863,7 +865,9 @@
 #define WINLINK_BELL 0x1
 #define WINLINK_ACTIVITY 0x2
 #define WINLINK_CONTENT 0x4
-#define WINLINK_ALERTFLAGS (WINLINK_BELL|WINLINK_ACTIVITY|WINLINK_CONTENT)
+#define WINLINK_SILENCE 0x8
+#define WINLINK_ALERTFLAGS \
+    (WINLINK_BELL|WINLINK_ACTIVITY|WINLINK_CONTENT|WINLINK_SILENCE)
 
        RB_ENTRY(winlink) entry;
        TAILQ_ENTRY(winlink) sentry;

Index: status.c
===================================================================
RCS file: /cvsroot/tmux/tmux/status.c,v
retrieving revision 1.149
retrieving revision 1.150
diff -u -d -r1.149 -r1.150
--- status.c    22 Jun 2010 23:26:18 -0000      1.149
+++ status.c    6 Dec 2010 22:52:21 -0000       1.150
@@ -395,6 +395,8 @@
                        tmp[0] = '!';
                else if (wl->flags & WINLINK_ACTIVITY)
                        tmp[0] = '#';
+               else if (wl->flags & WINLINK_SILENCE)
+                       tmp[0] = '~';
                else if (wl == s->curw)
                        tmp[0] = '*';
                else if (wl == TAILQ_FIRST(&s->lastw))


------------------------------------------------------------------------------
What happens now with your Lotus Notes apps - do you make another costly 
upgrade, or settle for being marooned without product support? Time to move
off Lotus Notes and onto the cloud with Force.com, apps are easier to build,
use, and manage than apps on traditional platforms. Sign up for the Lotus 
Notes Migration Kit to learn more. http://p.sf.net/sfu/salesforce-d2d
_______________________________________________
tmux-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tmux-cvs

Reply via email to