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

Modified Files:
        cmd-set-option.c server-fn.c tmux.1 tmux.c 
Log Message:
Sync OpenBSD patchset 729:

New option, detach-on-destroy, to set what happens to a client when the session
it is attached to is destroyed. If on (the default), it is detached; if off, it
is switched to the most recently active session.


Index: server-fn.c
===================================================================
RCS file: /cvsroot/tmux/tmux/server-fn.c,v
retrieving revision 1.107
retrieving revision 1.108
diff -u -d -r1.107 -r1.108
--- server-fn.c 2 Jul 2010 02:43:50 -0000       1.107
+++ server-fn.c 2 Jul 2010 02:45:52 -0000       1.108
@@ -24,7 +24,8 @@
 
 #include "tmux.h"
 
-void   server_callback_identify(int, short, void *);
+struct session *server_next_session(struct session *);
+void           server_callback_identify(int, short, void *);
 
 void
 server_fill_environ(struct session *s, struct environ *env)
@@ -358,18 +359,47 @@
        }
 }
 
+struct session *
+server_next_session(struct session *s)
+{
+       struct session *s_loop, *s_out;
+       u_int           i;
+
+       s_out = NULL;
+       for (i = 0; i < ARRAY_LENGTH(&sessions); i++) {
+               s_loop = ARRAY_ITEM(&sessions, i);
+               if (s_loop == s)
+                       continue;
+               if (s_out == NULL ||
+                   timercmp(&s_loop->activity_time, &s_out->activity_time, <))
+                       s_out = s_loop;
+       }
+       return (s_out);
+}
+
 void
 server_destroy_session(struct session *s)
 {
        struct client   *c;
+       struct session  *s_new;
        u_int            i;
 
+       if (!options_get_number(&s->options, "detach-on-destroy"))
+               s_new = server_next_session(s);
+       else
+               s_new = NULL;
+
        for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
                c = ARRAY_ITEM(&clients, i);
                if (c == NULL || c->session != s)
                        continue;
-               c->session = NULL;
-               server_write_client(c, MSG_EXIT, NULL, 0);
+               if (s_new == NULL) {
+                       c->session = NULL;
+                       server_write_client(c, MSG_EXIT, NULL, 0);
+               } else {
+                       c->session = s_new;
+                       server_redraw_client(c);
+               }
        }
        recalculate_sizes();
 }

Index: tmux.c
===================================================================
RCS file: /cvsroot/tmux/tmux/tmux.c,v
retrieving revision 1.210
retrieving revision 1.211
diff -u -d -r1.210 -r1.211
--- tmux.c      2 Jul 2010 02:43:01 -0000       1.210
+++ tmux.c      2 Jul 2010 02:45:52 -0000       1.211
@@ -344,8 +344,9 @@
        options_set_string(so, "default-command", "%s", "");
        options_set_string(so, "default-shell", "%s", getshell());
        options_set_string(so, "default-terminal", "screen");
-       options_set_number(so, "display-panes-colour", 4);
+       options_set_number(so, "detach-on-destroy", 1);
        options_set_number(so, "display-panes-active-colour", 1);
+       options_set_number(so, "display-panes-colour", 4);
        options_set_number(so, "display-panes-time", 1000);
        options_set_number(so, "display-time", 750);
        options_set_number(so, "history-limit", 2000);

Index: cmd-set-option.c
===================================================================
RCS file: /cvsroot/tmux/tmux/cmd-set-option.c,v
retrieving revision 1.97
retrieving revision 1.98
diff -u -d -r1.97 -r1.98
--- cmd-set-option.c    5 Jun 2010 23:56:29 -0000       1.97
+++ cmd-set-option.c    2 Jul 2010 02:45:52 -0000       1.98
@@ -87,6 +87,7 @@
        { "default-path", SET_OPTION_STRING, 0, 0, NULL },
        { "default-shell", SET_OPTION_STRING, 0, 0, NULL },
        { "default-terminal", SET_OPTION_STRING, 0, 0, NULL },
+       { "detach-on-destroy", SET_OPTION_FLAG, 0, 0, NULL },
        { "display-panes-colour", SET_OPTION_COLOUR, 0, 0, NULL },
        { "display-panes-active-colour", SET_OPTION_COLOUR, 0, 0, NULL },
        { "display-panes-time", SET_OPTION_NUMBER, 1, INT_MAX, NULL },

Index: tmux.1
===================================================================
RCS file: /cvsroot/tmux/tmux/tmux.1,v
retrieving revision 1.260
retrieving revision 1.261
diff -u -d -r1.260 -r1.261
--- tmux.1      22 Jun 2010 23:35:20 -0000      1.260
+++ tmux.1      2 Jul 2010 02:45:52 -0000       1.261
@@ -14,7 +14,7 @@
 .\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
 .\" OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 .\"
-.Dd $Mdocdate: June 21 2010 $
+.Dd $Mdocdate: June 27 2010 $
 .Dt TMUX 1
 .Os
 .Sh NAME
@@ -1557,6 +1557,11 @@
 .Pp
 Available server options are:
 .Bl -tag -width Ds
+.It Ic detach-on-destroy
+If on (the default), the client is detached when the session it is attached to
+is destroyed.
+If off, the client is switched to the most recently active of the remaining
+sessions.
 .It Ic escape-time
 Set the time in milliseconds for which
 .Nm


------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
tmux-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tmux-cvs

Reply via email to