diff options
author | Tiago Cunha <tcunha@gmx.com> | 2010-07-02 02:45:52 +0000 |
---|---|---|
committer | Tiago Cunha <tcunha@gmx.com> | 2010-07-02 02:45:52 +0000 |
commit | fa34c762752559480af4de1cb209bf2562ce23ff (patch) | |
tree | 8edc9fc42bfb03c0c9e2d6e2e08b7efb933f215a | |
parent | 985cd3a4ded7ec319a317bc4fbf5b120675feecb (diff) |
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.
-rw-r--r-- | cmd-set-option.c | 3 | ||||
-rw-r--r-- | server-fn.c | 38 | ||||
-rw-r--r-- | tmux.1 | 9 | ||||
-rw-r--r-- | tmux.c | 5 |
4 files changed, 46 insertions, 9 deletions
diff --git a/cmd-set-option.c b/cmd-set-option.c index 577af73e..c86f04c2 100644 --- a/cmd-set-option.c +++ b/cmd-set-option.c @@ -1,4 +1,4 @@ -/* $Id: cmd-set-option.c,v 1.97 2010-06-05 23:56:29 tcunha Exp $ */ +/* $Id: cmd-set-option.c,v 1.98 2010-07-02 02:45:52 tcunha Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -87,6 +87,7 @@ const struct set_option_entry set_session_option_table[] = { { "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 }, diff --git a/server-fn.c b/server-fn.c index 503c498e..b33ca92d 100644 --- a/server-fn.c +++ b/server-fn.c @@ -1,4 +1,4 @@ -/* $Id: server-fn.c,v 1.107 2010-07-02 02:43:50 tcunha Exp $ */ +/* $Id: server-fn.c,v 1.108 2010-07-02 02:45:52 tcunha Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -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 @@ server_destroy_session_group(struct session *s) } } +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(); } @@ -1,4 +1,4 @@ -.\" $Id: tmux.1,v 1.260 2010-06-22 23:35:20 tcunha Exp $ +.\" $Id: tmux.1,v 1.261 2010-07-02 02:45:52 tcunha Exp $ .\" .\" Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> .\" @@ -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 @@ Available window options are listed under .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 @@ -1,4 +1,4 @@ -/* $Id: tmux.c,v 1.210 2010-07-02 02:43:01 tcunha Exp $ */ +/* $Id: tmux.c,v 1.211 2010-07-02 02:45:52 tcunha Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -344,8 +344,9 @@ main(int argc, char **argv) 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); |