mirror of
				https://github.com/tmux/tmux.git
				synced 2025-10-26 12:27:15 +00:00 
			
		
		
		
	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.
This commit is contained in:
		| @@ -87,6 +87,7 @@ const struct set_option_entry set_session_option_table[] = { | |||||||
| 	{ "default-path", SET_OPTION_STRING, 0, 0, NULL }, | 	{ "default-path", SET_OPTION_STRING, 0, 0, NULL }, | ||||||
| 	{ "default-shell", SET_OPTION_STRING, 0, 0, NULL }, | 	{ "default-shell", SET_OPTION_STRING, 0, 0, NULL }, | ||||||
| 	{ "default-terminal", 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-colour", SET_OPTION_COLOUR, 0, 0, NULL }, | ||||||
| 	{ "display-panes-active-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 }, | 	{ "display-panes-time", SET_OPTION_NUMBER, 1, INT_MAX, NULL }, | ||||||
|   | |||||||
							
								
								
									
										30
									
								
								server-fn.c
									
									
									
									
									
								
							
							
						
						
									
										30
									
								
								server-fn.c
									
									
									
									
									
								
							| @@ -24,6 +24,7 @@ | |||||||
|  |  | ||||||
| #include "tmux.h" | #include "tmux.h" | ||||||
|  |  | ||||||
|  | struct session *server_next_session(struct session *); | ||||||
| void		server_callback_identify(int, short, void *); | void		server_callback_identify(int, short, void *); | ||||||
|  |  | ||||||
| void | void | ||||||
| @@ -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 | void | ||||||
| server_destroy_session(struct session *s) | server_destroy_session(struct session *s) | ||||||
| { | { | ||||||
| 	struct client	*c; | 	struct client	*c; | ||||||
|  | 	struct session	*s_new; | ||||||
| 	u_int		 i; | 	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++) { | 	for (i = 0; i < ARRAY_LENGTH(&clients); i++) { | ||||||
| 		c = ARRAY_ITEM(&clients, i); | 		c = ARRAY_ITEM(&clients, i); | ||||||
| 		if (c == NULL || c->session != s) | 		if (c == NULL || c->session != s) | ||||||
| 			continue; | 			continue; | ||||||
|  | 		if (s_new == NULL) { | ||||||
| 			c->session = NULL; | 			c->session = NULL; | ||||||
| 			server_write_client(c, MSG_EXIT, NULL, 0); | 			server_write_client(c, MSG_EXIT, NULL, 0); | ||||||
|  | 		} else { | ||||||
|  | 			c->session = s_new; | ||||||
|  | 			server_redraw_client(c); | ||||||
|  | 		} | ||||||
| 	} | 	} | ||||||
| 	recalculate_sizes(); | 	recalculate_sizes(); | ||||||
| } | } | ||||||
|   | |||||||
							
								
								
									
										5
									
								
								tmux.1
									
									
									
									
									
								
							
							
						
						
									
										5
									
								
								tmux.1
									
									
									
									
									
								
							| @@ -1557,6 +1557,11 @@ Available window options are listed under | |||||||
| .Pp | .Pp | ||||||
| Available server options are: | Available server options are: | ||||||
| .Bl -tag -width Ds | .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 | .It Ic escape-time | ||||||
| Set the time in milliseconds for which | Set the time in milliseconds for which | ||||||
| .Nm | .Nm | ||||||
|   | |||||||
							
								
								
									
										3
									
								
								tmux.c
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								tmux.c
									
									
									
									
									
								
							| @@ -341,8 +341,9 @@ main(int argc, char **argv) | |||||||
| 	options_set_string(so, "default-command", "%s", ""); | 	options_set_string(so, "default-command", "%s", ""); | ||||||
| 	options_set_string(so, "default-shell", "%s", getshell()); | 	options_set_string(so, "default-shell", "%s", getshell()); | ||||||
| 	options_set_string(so, "default-terminal", "screen"); | 	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-active-colour", 1); | ||||||
|  | 	options_set_number(so, "display-panes-colour", 4); | ||||||
| 	options_set_number(so, "display-panes-time", 1000); | 	options_set_number(so, "display-panes-time", 1000); | ||||||
| 	options_set_number(so, "display-time", 750); | 	options_set_number(so, "display-time", 750); | ||||||
| 	options_set_number(so, "history-limit", 2000); | 	options_set_number(so, "history-limit", 2000); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Nicholas Marriott
					Nicholas Marriott