mirror of
https://github.com/tmux/tmux.git
synced 2024-11-17 18:08:51 +00:00
Add no-detach-on-destroy client option (useful for control mode
clients). From laur dot aliste at gmail dot com, GitHub issue 4242.
This commit is contained in:
parent
350a151ee4
commit
c66628e52b
@ -3683,6 +3683,8 @@ server_client_set_flags(struct client *c, const char *flags)
|
|||||||
flag = CLIENT_IGNORESIZE;
|
flag = CLIENT_IGNORESIZE;
|
||||||
else if (strcmp(next, "active-pane") == 0)
|
else if (strcmp(next, "active-pane") == 0)
|
||||||
flag = CLIENT_ACTIVEPANE;
|
flag = CLIENT_ACTIVEPANE;
|
||||||
|
else if (strcmp(next, "no-detach-on-destroy") == 0)
|
||||||
|
flag = CLIENT_NO_DETACH_ON_DESTROY;
|
||||||
if (flag == 0)
|
if (flag == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -3716,6 +3718,8 @@ server_client_get_flags(struct client *c)
|
|||||||
strlcat(s, "control-mode,", sizeof s);
|
strlcat(s, "control-mode,", sizeof s);
|
||||||
if (c->flags & CLIENT_IGNORESIZE)
|
if (c->flags & CLIENT_IGNORESIZE)
|
||||||
strlcat(s, "ignore-size,", sizeof s);
|
strlcat(s, "ignore-size,", sizeof s);
|
||||||
|
if (c->flags & CLIENT_NO_DETACH_ON_DESTROY)
|
||||||
|
strlcat(s, "no-detach-on-destroy,", sizeof s);
|
||||||
if (c->flags & CLIENT_CONTROL_NOOUTPUT)
|
if (c->flags & CLIENT_CONTROL_NOOUTPUT)
|
||||||
strlcat(s, "no-output,", sizeof s);
|
strlcat(s, "no-output,", sizeof s);
|
||||||
if (c->flags & CLIENT_CONTROL_WAITEXIT)
|
if (c->flags & CLIENT_CONTROL_WAITEXIT)
|
||||||
|
21
server-fn.c
21
server-fn.c
@ -425,7 +425,7 @@ void
|
|||||||
server_destroy_session(struct session *s)
|
server_destroy_session(struct session *s)
|
||||||
{
|
{
|
||||||
struct client *c;
|
struct client *c;
|
||||||
struct session *s_new = NULL;
|
struct session *s_new = NULL, *cs_new, *use_s;
|
||||||
int detach_on_destroy;
|
int detach_on_destroy;
|
||||||
|
|
||||||
detach_on_destroy = options_get_number(s->options, "detach-on-destroy");
|
detach_on_destroy = options_get_number(s->options, "detach-on-destroy");
|
||||||
@ -437,15 +437,26 @@ server_destroy_session(struct session *s)
|
|||||||
s_new = session_previous_session(s);
|
s_new = session_previous_session(s);
|
||||||
else if (detach_on_destroy == 4)
|
else if (detach_on_destroy == 4)
|
||||||
s_new = session_next_session(s);
|
s_new = session_next_session(s);
|
||||||
if (s_new == s)
|
|
||||||
s_new = NULL;
|
/*
|
||||||
|
* If no suitable new session was found above, then look for any
|
||||||
|
* session as an alternative in case a client needs it.
|
||||||
|
*/
|
||||||
|
if (s_new == NULL &&
|
||||||
|
(detach_on_destroy == 1 || detach_on_destroy == 2))
|
||||||
|
cs_new = server_find_session(s, server_newer_session);
|
||||||
|
|
||||||
TAILQ_FOREACH(c, &clients, entry) {
|
TAILQ_FOREACH(c, &clients, entry) {
|
||||||
if (c->session != s)
|
if (c->session != s)
|
||||||
continue;
|
continue;
|
||||||
|
use_s = s_new;
|
||||||
|
if (use_s == NULL && (c->flags & CLIENT_NO_DETACH_ON_DESTROY))
|
||||||
|
use_s = cs_new;
|
||||||
|
|
||||||
c->session = NULL;
|
c->session = NULL;
|
||||||
c->last_session = NULL;
|
c->last_session = NULL;
|
||||||
server_client_set_session(c, s_new);
|
server_client_set_session(c, use_s);
|
||||||
if (s_new == NULL)
|
if (use_s == NULL)
|
||||||
c->flags |= CLIENT_EXIT;
|
c->flags |= CLIENT_EXIT;
|
||||||
}
|
}
|
||||||
recalculate_sizes();
|
recalculate_sizes();
|
||||||
|
3
tmux.1
3
tmux.1
@ -1066,6 +1066,9 @@ The flags are:
|
|||||||
the client has an independent active pane
|
the client has an independent active pane
|
||||||
.It ignore-size
|
.It ignore-size
|
||||||
the client does not affect the size of other clients
|
the client does not affect the size of other clients
|
||||||
|
.It no-detach-on-destroy
|
||||||
|
do not detach the client when the session it is attached to is destroyed if
|
||||||
|
there are any other sessions
|
||||||
.It no-output
|
.It no-output
|
||||||
the client does not receive pane output in control mode
|
the client does not receive pane output in control mode
|
||||||
.It pause-after=seconds
|
.It pause-after=seconds
|
||||||
|
1
tmux.h
1
tmux.h
@ -1924,6 +1924,7 @@ struct client {
|
|||||||
#define CLIENT_BRACKETPASTING 0x1000000000ULL
|
#define CLIENT_BRACKETPASTING 0x1000000000ULL
|
||||||
#define CLIENT_ASSUMEPASTING 0x2000000000ULL
|
#define CLIENT_ASSUMEPASTING 0x2000000000ULL
|
||||||
#define CLIENT_REDRAWSCROLLBARS 0x4000000000ULL
|
#define CLIENT_REDRAWSCROLLBARS 0x4000000000ULL
|
||||||
|
#define CLIENT_NO_DETACH_ON_DESTROY 0x8000000000ULL
|
||||||
#define CLIENT_ALLREDRAWFLAGS \
|
#define CLIENT_ALLREDRAWFLAGS \
|
||||||
(CLIENT_REDRAWWINDOW| \
|
(CLIENT_REDRAWWINDOW| \
|
||||||
CLIENT_REDRAWSTATUS| \
|
CLIENT_REDRAWSTATUS| \
|
||||||
|
Loading…
Reference in New Issue
Block a user