mirror of
				https://github.com/tmux/tmux.git
				synced 2025-10-26 12:27:15 +00:00 
			
		
		
		
	Make status-interval actually changeable.
This commit is contained in:
		
							
								
								
									
										6
									
								
								CHANGES
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								CHANGES
									
									
									
									
									
								
							| @@ -1,3 +1,7 @@ | |||||||
|  | 07 June 2008 | ||||||
|  |  | ||||||
|  | * Make status-interval actually changable. | ||||||
|  |  | ||||||
| 06 June 2008 | 06 June 2008 | ||||||
|  |  | ||||||
| * New window option: aggressive-resize. Normally, windows are resized to the | * New window option: aggressive-resize. Normally, windows are resized to the | ||||||
| @@ -452,4 +456,4 @@ | |||||||
|   (including mutt, emacs). No status bar yet and no key remapping or other |   (including mutt, emacs). No status bar yet and no key remapping or other | ||||||
|   customisation. |   customisation. | ||||||
|  |  | ||||||
| $Id: CHANGES,v 1.115 2008-06-06 20:02:27 nicm Exp $ | $Id: CHANGES,v 1.116 2008-06-07 06:13:21 nicm Exp $ | ||||||
|   | |||||||
| @@ -1,4 +1,4 @@ | |||||||
| /* $Id: cmd-set-option.c,v 1.25 2008-06-05 21:25:00 nicm Exp $ */ | /* $Id: cmd-set-option.c,v 1.26 2008-06-07 06:13:21 nicm Exp $ */ | ||||||
|  |  | ||||||
| /* | /* | ||||||
|  * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> |  * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> | ||||||
| @@ -125,6 +125,8 @@ cmd_set_option_exec(struct cmd *self, unused struct cmd_ctx *ctx) | |||||||
| 	number = -1; | 	number = -1; | ||||||
| 	if (data->value != NULL) { | 	if (data->value != NULL) { | ||||||
| 		number = strtonum(data->value, 0, INT_MAX, &errstr); | 		number = strtonum(data->value, 0, INT_MAX, &errstr); | ||||||
|  | 		if (errstr != NULL) | ||||||
|  | 			number = 0; | ||||||
|  |  | ||||||
| 		bool = -1; | 		bool = -1; | ||||||
| 		if (number == 1 || strcasecmp(data->value, "on") == 0 || | 		if (number == 1 || strcasecmp(data->value, "on") == 0 || | ||||||
| @@ -221,10 +223,14 @@ cmd_set_option_exec(struct cmd *self, unused struct cmd_ctx *ctx) | |||||||
| 		} | 		} | ||||||
| 		options_set_string(oo, "default-command", "%s", data->value); | 		options_set_string(oo, "default-command", "%s", data->value); | ||||||
| 	} else if (strcmp(data->option, "history-limit") == 0) { | 	} else if (strcmp(data->option, "history-limit") == 0) { | ||||||
| 		if (data->value == NULL) { | 		if (data->value == NULL || number == -1) { | ||||||
| 			ctx->error(ctx, "invalid value"); | 			ctx->error(ctx, "invalid value"); | ||||||
| 			return; | 			return; | ||||||
| 		} | 		} | ||||||
|  | 		if (errstr != NULL) { | ||||||
|  | 			ctx->error(ctx, "history-limit %s", errstr); | ||||||
|  | 			return; | ||||||
|  | 		} | ||||||
| 		if (number > SHRT_MAX) { | 		if (number > SHRT_MAX) { | ||||||
| 			ctx->error(ctx, "history-limit too big: %u", number); | 			ctx->error(ctx, "history-limit too big: %u", number); | ||||||
| 			return; | 			return; | ||||||
| @@ -256,6 +262,16 @@ cmd_set_option_exec(struct cmd *self, unused struct cmd_ctx *ctx) | |||||||
| 			if (c != NULL && c->session != NULL) | 			if (c != NULL && c->session != NULL) | ||||||
| 				server_redraw_client(c); | 				server_redraw_client(c); | ||||||
| 		} | 		} | ||||||
|  | 	} else if (strcmp(data->option, "status-interval") == 0) { | ||||||
|  | 		if (data->value == NULL || number == -1) { | ||||||
|  | 			ctx->error(ctx, "invalid value"); | ||||||
|  | 			return; | ||||||
|  | 		} | ||||||
|  | 		if (errstr != NULL) { | ||||||
|  | 			ctx->error(ctx, "status-interval %s", errstr); | ||||||
|  | 			return; | ||||||
|  | 		} | ||||||
|  | 		options_set_number(oo, "status-interval", number); | ||||||
| 	} else { | 	} else { | ||||||
| 		ctx->error(ctx, "unknown option: %s", data->option); | 		ctx->error(ctx, "unknown option: %s", data->option); | ||||||
| 		return; | 		return; | ||||||
|   | |||||||
							
								
								
									
										34
									
								
								server.c
									
									
									
									
									
								
							
							
						
						
									
										34
									
								
								server.c
									
									
									
									
									
								
							| @@ -1,4 +1,4 @@ | |||||||
| /* $Id: server.c,v 1.55 2008-06-06 17:55:27 nicm Exp $ */ | /* $Id: server.c,v 1.56 2008-06-07 06:13:21 nicm Exp $ */ | ||||||
|  |  | ||||||
| /* | /* | ||||||
|  * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> |  * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> | ||||||
| @@ -54,6 +54,7 @@ void		 server_handle_client(struct client *); | |||||||
| void		 server_handle_window(struct window *); | void		 server_handle_window(struct window *); | ||||||
| void		 server_lost_client(struct client *); | void		 server_lost_client(struct client *); | ||||||
| void	 	 server_lost_window(struct window *); | void	 	 server_lost_window(struct window *); | ||||||
|  | void		 server_check_status(struct client *); | ||||||
|  |  | ||||||
| /* Fork new server. */ | /* Fork new server. */ | ||||||
| pid_t | pid_t | ||||||
| @@ -268,6 +269,28 @@ server_handle_windows(struct pollfd **pfd) | |||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
|  | /* Check for status line redraw on client. */ | ||||||
|  | void | ||||||
|  | server_check_status(struct client *c) | ||||||
|  | { | ||||||
|  | 	struct timespec	 ts; | ||||||
|  | 	u_int		 nlines, interval; | ||||||
|  |  | ||||||
|  | 	if (c->session == NULL) | ||||||
|  | 		return; | ||||||
|  | 	nlines = options_get_number(&c->session->options, "status-lines"); | ||||||
|  | 	interval = options_get_number(&c->session->options, "status-interval"); | ||||||
|  | 	if (nlines == 0 || interval == 0) | ||||||
|  | 		return; | ||||||
|  | 	 | ||||||
|  | 	if (clock_gettime(CLOCK_REALTIME, &ts) != 0) | ||||||
|  | 		fatal("clock_gettime"); | ||||||
|  | 	ts.tv_sec -= interval; | ||||||
|  | 	 | ||||||
|  | 	if (timespeccmp(&c->status_ts, &ts, <)) | ||||||
|  | 		server_status_client(c); | ||||||
|  | } | ||||||
|  |  | ||||||
| /* Fill client pollfds. */ | /* Fill client pollfds. */ | ||||||
| void | void | ||||||
| server_fill_clients(struct pollfd **pfd) | server_fill_clients(struct pollfd **pfd) | ||||||
| @@ -307,20 +330,13 @@ void | |||||||
| server_handle_clients(struct pollfd **pfd) | server_handle_clients(struct pollfd **pfd) | ||||||
| { | { | ||||||
| 	struct client	*c; | 	struct client	*c; | ||||||
| 	struct timespec	 now; |  | ||||||
| 	u_int		 i; | 	u_int		 i; | ||||||
|  |  | ||||||
| 	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) { | 		if (c != NULL) { | ||||||
| 			if (c->session != NULL && options_get_number( | 			server_check_status(c); | ||||||
| 			    &c->session->options, "status-lines") != 0) { |  | ||||||
| 				if (clock_gettime(CLOCK_REALTIME, &now) != 0) |  | ||||||
| 					fatal("clock_gettime"); |  | ||||||
| 				if (timespeccmp(&now, &c->status_ts, >)) |  | ||||||
| 					server_status_client(c); |  | ||||||
| 			} |  | ||||||
| 			 | 			 | ||||||
| 			log_debug("testing client %d (%d)", (*pfd)->fd, c->fd); | 			log_debug("testing client %d (%d)", (*pfd)->fd, c->fd); | ||||||
| 			if (buffer_poll(*pfd, c->in, c->out) != 0) { | 			if (buffer_poll(*pfd, c->in, c->out) != 0) { | ||||||
|   | |||||||
							
								
								
									
										5
									
								
								status.c
									
									
									
									
									
								
							
							
						
						
									
										5
									
								
								status.c
									
									
									
									
									
								
							| @@ -1,4 +1,4 @@ | |||||||
| /* $Id: status.c,v 1.22 2008-06-06 17:20:30 nicm Exp $ */ | /* $Id: status.c,v 1.23 2008-06-07 06:13:21 nicm Exp $ */ | ||||||
|  |  | ||||||
| /* | /* | ||||||
|  * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> |  * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> | ||||||
| @@ -52,9 +52,6 @@ status_write_client(struct client *c) | |||||||
| 	strftime(rbuf, sizeof rbuf, right, localtime(&(c->status_ts.tv_sec))); | 	strftime(rbuf, sizeof rbuf, right, localtime(&(c->status_ts.tv_sec))); | ||||||
| 	rlen = strlen(rbuf) + 1; | 	rlen = strlen(rbuf) + 1; | ||||||
|  |  | ||||||
| 	c->status_ts.tv_sec +=  |  | ||||||
| 	    options_get_number(&c->session->options, "status-interval"); |  | ||||||
|  |  | ||||||
| 	screen_redraw_start_client(&ctx, c); | 	screen_redraw_start_client(&ctx, c); | ||||||
| 	screen_redraw_move_cursor(&ctx, llen, c->sy - slines); | 	screen_redraw_move_cursor(&ctx, llen, c->sy - slines); | ||||||
| 	screen_redraw_set_attributes(&ctx, 0, scolour); | 	screen_redraw_set_attributes(&ctx, 0, scolour); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Nicholas Marriott
					Nicholas Marriott