mirror of
				https://github.com/tmux/tmux.git
				synced 2025-10-26 12:27:15 +00:00 
			
		
		
		
	Refresh session command.
This commit is contained in:
		
							
								
								
									
										6
									
								
								CHANGES
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								CHANGES
									
									
									
									
									
								
							| @@ -1,3 +1,7 @@ | ||||
| 19 October 2007 | ||||
|  | ||||
| * (nicm) Refresh session command. | ||||
|  | ||||
| 12 October 2007 | ||||
|  | ||||
| * (nicm) Add a warning if $TMUX exists on new/attach. | ||||
| @@ -127,5 +131,5 @@ | ||||
|   (including mutt, emacs). No status bar yet and no key remapping or other | ||||
|   customisation. | ||||
|  | ||||
| $Id: CHANGES,v 1.41 2007-10-12 14:46:48 nicm Exp $ | ||||
| $Id: CHANGES,v 1.42 2007-10-19 09:21:24 nicm Exp $ | ||||
|  | ||||
|   | ||||
							
								
								
									
										5
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										5
									
								
								Makefile
									
									
									
									
									
								
							| @@ -1,4 +1,4 @@ | ||||
| # $Id: Makefile,v 1.26 2007-10-12 13:03:58 nicm Exp $ | ||||
| # $Id: Makefile,v 1.27 2007-10-19 09:21:25 nicm Exp $ | ||||
|  | ||||
| .SUFFIXES: .c .o .y .h | ||||
| .PHONY: clean | ||||
| @@ -22,7 +22,8 @@ SRCS= tmux.c server.c server-msg.c server-fn.c buffer.c buffer-poll.c status.c \ | ||||
|       cmd-list-sessions.c cmd-new-window.c cmd-next-window.c cmd-bind-key.c \ | ||||
|       cmd-unbind-key.c cmd-previous-window.c cmd-last-window.c cmd-list-keys.c \ | ||||
|       cmd-set-option.c cmd-rename-window.c cmd-select-window.c \ | ||||
|       cmd-list-windows.c cmd-attach-session.c cmd-send-prefix.c | ||||
|       cmd-list-windows.c cmd-attach-session.c cmd-send-prefix.c \ | ||||
|       cmd-refresh-session.c | ||||
|  | ||||
| YACC= yacc -d | ||||
|  | ||||
|   | ||||
							
								
								
									
										2
									
								
								TODO
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								TODO
									
									
									
									
									
								
							| @@ -48,8 +48,6 @@ | ||||
| - man page | ||||
| - sort out bell: passing through should be optional | ||||
| - commands: | ||||
| 	refresh session (similar to detach: -a for all, else if key redraw cur, | ||||
| 	    else do nothing) | ||||
| 	rename sessions | ||||
| 	swap windows | ||||
| 	link/copy windows | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| /* $Id: cmd-attach-session.c,v 1.6 2007-10-12 14:46:48 nicm Exp $ */ | ||||
| /* $Id: cmd-attach-session.c,v 1.7 2007-10-19 09:21:25 nicm Exp $ */ | ||||
|  | ||||
| /* | ||||
|  * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| /* $Id: cmd-bind-key.c,v 1.4 2007-10-04 22:04:01 nicm Exp $ */ | ||||
| /* $Id: cmd-bind-key.c,v 1.5 2007-10-19 09:21:25 nicm Exp $ */ | ||||
|  | ||||
| /* | ||||
|  * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| /* $Id: cmd-detach-session.c,v 1.5 2007-10-04 22:04:01 nicm Exp $ */ | ||||
| /* $Id: cmd-detach-session.c,v 1.6 2007-10-19 09:21:25 nicm Exp $ */ | ||||
|  | ||||
| /* | ||||
|  * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| /* $Id: cmd-new-session.c,v 1.11 2007-10-12 14:46:48 nicm Exp $ */ | ||||
| /* $Id: cmd-new-session.c,v 1.12 2007-10-19 09:21:25 nicm Exp $ */ | ||||
|  | ||||
| /* | ||||
|  * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| /* $Id: cmd-new-window.c,v 1.8 2007-10-12 11:24:15 nicm Exp $ */ | ||||
| /* $Id: cmd-new-window.c,v 1.9 2007-10-19 09:21:25 nicm Exp $ */ | ||||
|  | ||||
| /* | ||||
|  * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> | ||||
|   | ||||
							
								
								
									
										131
									
								
								cmd-refresh-session.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										131
									
								
								cmd-refresh-session.c
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,131 @@ | ||||
| /* $Id: cmd-refresh-session.c,v 1.1 2007-10-19 09:21:25 nicm Exp $ */ | ||||
|  | ||||
| /* | ||||
|  * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> | ||||
|  * | ||||
|  * Permission to use, copy, modify, and distribute this software for any | ||||
|  * purpose with or without fee is hereby granted, provided that the above | ||||
|  * copyright notice and this permission notice appear in all copies. | ||||
|  * | ||||
|  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||||
|  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||||
|  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||||
|  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||||
|  * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER | ||||
|  * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING | ||||
|  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||||
|  */ | ||||
|  | ||||
| #include <sys/types.h> | ||||
|  | ||||
| #include <getopt.h> | ||||
|  | ||||
| #include "tmux.h" | ||||
|  | ||||
| /* | ||||
|  * Refresh session. If called with -a refresh all clients attached to specified | ||||
|  * session, otherwise refresh current session on key press only. | ||||
|  */ | ||||
|  | ||||
| int	cmd_refresh_session_parse(void **, int, char **, char **); | ||||
| void	cmd_refresh_session_exec(void *, struct cmd_ctx *); | ||||
| void	cmd_refresh_session_send(void *, struct buffer *); | ||||
| void	cmd_refresh_session_recv(void **, struct buffer *); | ||||
| void	cmd_refresh_session_free(void *); | ||||
|  | ||||
| struct cmd_refresh_session_data { | ||||
| 	int	 flag_all; | ||||
| }; | ||||
|  | ||||
| const struct cmd_entry cmd_refresh_session_entry = { | ||||
| 	"refresh-session", "refresh", "[-a]", | ||||
| 	0, | ||||
| 	cmd_refresh_session_parse, | ||||
| 	cmd_refresh_session_exec, | ||||
| 	cmd_refresh_session_send, | ||||
| 	cmd_refresh_session_recv, | ||||
| 	cmd_refresh_session_free | ||||
| }; | ||||
|  | ||||
| int | ||||
| cmd_refresh_session_parse(void **ptr, int argc, char **argv, char **cause) | ||||
| { | ||||
| 	struct cmd_refresh_session_data	*data; | ||||
| 	int				 opt; | ||||
|  | ||||
| 	*ptr = data = xmalloc(sizeof *data); | ||||
| 	data->flag_all = 0; | ||||
|  | ||||
| 	while ((opt = getopt(argc, argv, "a")) != EOF) { | ||||
| 		switch (opt) { | ||||
| 		case 'a': | ||||
| 			data->flag_all = 1; | ||||
| 			break; | ||||
| 		default: | ||||
| 			goto usage; | ||||
| 		} | ||||
| 	}	 | ||||
| 	argc -= optind; | ||||
| 	argv += optind; | ||||
| 	if (argc != 0) | ||||
| 		goto usage; | ||||
|  | ||||
| 	return (0); | ||||
|  | ||||
| usage: | ||||
| 	usage(cause, "%s %s", | ||||
| 	    cmd_refresh_session_entry.name, cmd_refresh_session_entry.usage); | ||||
|  | ||||
| 	cmd_refresh_session_free(data); | ||||
| 	return (-1); | ||||
| } | ||||
|  | ||||
| void | ||||
| cmd_refresh_session_exec(void *ptr, struct cmd_ctx *ctx) | ||||
| { | ||||
| 	struct cmd_refresh_session_data	*data = ptr, std = { 0 }; | ||||
| 	struct client			*c = ctx->client, *cp; | ||||
| 	struct session			*s = ctx->session; | ||||
| 	u_int				 i; | ||||
|  | ||||
| 	if (data == NULL) | ||||
| 		data = &std; | ||||
|  | ||||
| 	if (data->flag_all) { | ||||
| 		for (i = 0; i < ARRAY_LENGTH(&clients); i++) { | ||||
| 			cp = ARRAY_ITEM(&clients, i); | ||||
| 			if (cp == NULL || cp->session != s) | ||||
| 				continue; | ||||
| 			server_redraw_client(cp); | ||||
| 		} | ||||
| 	} else if (ctx->flags & CMD_KEY) | ||||
| 		server_redraw_client(c); | ||||
|  | ||||
| 	if (!(ctx->flags & CMD_KEY)) | ||||
| 		server_write_client(c, MSG_EXIT, NULL, 0); | ||||
| } | ||||
|  | ||||
| void | ||||
| cmd_refresh_session_send(void *ptr, struct buffer *b) | ||||
| { | ||||
| 	struct cmd_refresh_session_data	*data = ptr; | ||||
|  | ||||
| 	buffer_write(b, data, sizeof *data); | ||||
| } | ||||
|  | ||||
| void | ||||
| cmd_refresh_session_recv(void **ptr, struct buffer *b) | ||||
| { | ||||
| 	struct cmd_refresh_session_data	*data; | ||||
|  | ||||
| 	*ptr = data = xmalloc(sizeof *data); | ||||
| 	buffer_read(b, data, sizeof *data); | ||||
| } | ||||
|  | ||||
| void | ||||
| cmd_refresh_session_free(void *ptr) | ||||
| { | ||||
| 	struct cmd_refresh_session_data	*data = ptr; | ||||
|  | ||||
| 	xfree(data); | ||||
| } | ||||
| @@ -1,4 +1,4 @@ | ||||
| /* $Id: cmd-rename-window.c,v 1.5 2007-10-12 11:24:15 nicm Exp $ */ | ||||
| /* $Id: cmd-rename-window.c,v 1.6 2007-10-19 09:21:26 nicm Exp $ */ | ||||
|  | ||||
| /* | ||||
|  * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| /* $Id: cmd-select-window.c,v 1.3 2007-10-04 22:04:01 nicm Exp $ */ | ||||
| /* $Id: cmd-select-window.c,v 1.4 2007-10-19 09:21:26 nicm Exp $ */ | ||||
|  | ||||
| /* | ||||
|  * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| /* $Id: cmd-set-option.c,v 1.7 2007-10-12 13:51:44 nicm Exp $ */ | ||||
| /* $Id: cmd-set-option.c,v 1.8 2007-10-19 09:21:26 nicm Exp $ */ | ||||
|  | ||||
| /* | ||||
|  * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> | ||||
| @@ -29,7 +29,6 @@ | ||||
|  */ | ||||
|  | ||||
| int	cmd_set_option_parse(void **, int, char **, char **); | ||||
| const char	*cmd_set_option_usage(void); | ||||
| void	cmd_set_option_exec(void *, struct cmd_ctx *); | ||||
| void	cmd_set_option_send(void *, struct buffer *); | ||||
| void	cmd_set_option_recv(void **, struct buffer *); | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| /* $Id: cmd-unbind-key.c,v 1.4 2007-10-04 22:04:01 nicm Exp $ */ | ||||
| /* $Id: cmd-unbind-key.c,v 1.5 2007-10-19 09:21:26 nicm Exp $ */ | ||||
|  | ||||
| /* | ||||
|  * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> | ||||
| @@ -27,7 +27,6 @@ | ||||
|  */ | ||||
|  | ||||
| int	cmd_unbind_key_parse(void **, int, char **, char **); | ||||
| const char	*cmd_unbind_key_usage(void); | ||||
| void	cmd_unbind_key_exec(void *, struct cmd_ctx *); | ||||
| void	cmd_unbind_key_send(void *, struct buffer *); | ||||
| void	cmd_unbind_key_recv(void **, struct buffer *); | ||||
|   | ||||
							
								
								
									
										3
									
								
								cmd.c
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								cmd.c
									
									
									
									
									
								
							| @@ -1,4 +1,4 @@ | ||||
| /* $Id: cmd.c,v 1.16 2007-10-12 13:51:44 nicm Exp $ */ | ||||
| /* $Id: cmd.c,v 1.17 2007-10-19 09:21:26 nicm Exp $ */ | ||||
|  | ||||
| /* | ||||
|  * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> | ||||
| @@ -35,6 +35,7 @@ const struct cmd_entry *cmd_table[] = { | ||||
| 	&cmd_new_window_entry, | ||||
| 	&cmd_next_window_entry, | ||||
| 	&cmd_previous_window_entry, | ||||
| 	&cmd_refresh_session_entry, | ||||
| 	&cmd_rename_window_entry, | ||||
| 	&cmd_select_window_entry, | ||||
| 	&cmd_send_prefix_entry, | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| /* $Id: key-bindings.c,v 1.8 2007-10-12 13:03:58 nicm Exp $ */ | ||||
| /* $Id: key-bindings.c,v 1.9 2007-10-19 09:21:26 nicm Exp $ */ | ||||
|  | ||||
| /* | ||||
|  * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> | ||||
| @@ -103,9 +103,10 @@ key_bindings_init(void) | ||||
| 		{ '7', &cmd_select_window_entry, cmd_select_window_default }, | ||||
| 		{ '8', &cmd_select_window_entry, cmd_select_window_default }, | ||||
| 		{ '9', &cmd_select_window_entry, cmd_select_window_default }, | ||||
| 		{ 'R', &cmd_refresh_session_entry, NULL }, | ||||
| 		{ 'r', &cmd_refresh_session_entry, NULL }, | ||||
| 		{ META, &cmd_send_prefix_entry, NULL }, | ||||
| /*		{ 'R', &cmd_refresh_client_entry }, | ||||
| 		{ 'r', &cmd_refresh_client_entry }, | ||||
| /* | ||||
| 		{ 'I', &cmd_windo_info_entry }, | ||||
| 		{ 'i', &cmd_window_info_entry }, | ||||
| 		{ META, &cmd_meta_entry_entry }, | ||||
|   | ||||
							
								
								
									
										3
									
								
								tmux.h
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								tmux.h
									
									
									
									
									
								
							| @@ -1,4 +1,4 @@ | ||||
| /* $Id: tmux.h,v 1.58 2007-10-12 14:46:48 nicm Exp $ */ | ||||
| /* $Id: tmux.h,v 1.59 2007-10-19 09:21:26 nicm Exp $ */ | ||||
|  | ||||
| /* | ||||
|  * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> | ||||
| @@ -524,6 +524,7 @@ extern const struct cmd_entry cmd_new_session_entry; | ||||
| extern const struct cmd_entry cmd_new_window_entry; | ||||
| extern const struct cmd_entry cmd_next_window_entry; | ||||
| extern const struct cmd_entry cmd_previous_window_entry; | ||||
| extern const struct cmd_entry cmd_refresh_session_entry; | ||||
| extern const struct cmd_entry cmd_rename_window_entry; | ||||
| extern const struct cmd_entry cmd_select_window_entry; | ||||
| extern const struct cmd_entry cmd_send_prefix_entry; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Nicholas Marriott
					Nicholas Marriott