mirror of
				https://github.com/tmux/tmux.git
				synced 2025-11-04 09:26:05 +00:00 
			
		
		
		
	Make status_message_set a variadic printf-like function. No functional change -
helpful for a couple of things coming soon.
This commit is contained in:
		@@ -150,7 +150,7 @@ cmd_command_prompt_callback(void *data, const char *s)
 | 
				
			|||||||
		if (cause == NULL)
 | 
							if (cause == NULL)
 | 
				
			||||||
			return (0);
 | 
								return (0);
 | 
				
			||||||
		*cause = toupper((u_char) *cause);
 | 
							*cause = toupper((u_char) *cause);
 | 
				
			||||||
		status_message_set(c, cause);
 | 
							status_message_set(c, "%s", cause);
 | 
				
			||||||
		xfree(cause);
 | 
							xfree(cause);
 | 
				
			||||||
		cmdlist = NULL;
 | 
							cmdlist = NULL;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -113,7 +113,7 @@ cmd_confirm_before_callback(void *data, const char *s)
 | 
				
			|||||||
	if (cmd_string_parse(cdata->cmd, &cmdlist, &cause) != 0) {
 | 
						if (cmd_string_parse(cdata->cmd, &cmdlist, &cause) != 0) {
 | 
				
			||||||
		if (cause != NULL) {
 | 
							if (cause != NULL) {
 | 
				
			||||||
			*cause = toupper((u_char) *cause);
 | 
								*cause = toupper((u_char) *cause);
 | 
				
			||||||
			status_message_set(c, cause);
 | 
								status_message_set(c, "%s", cause);
 | 
				
			||||||
			xfree(cause);
 | 
								xfree(cause);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		goto out;
 | 
							goto out;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -74,14 +74,14 @@ cmd_select_prompt_callback(void *data, const char *s)
 | 
				
			|||||||
	idx = strtonum(s, 0, UINT_MAX, &errstr);
 | 
						idx = strtonum(s, 0, UINT_MAX, &errstr);
 | 
				
			||||||
	if (errstr != NULL) {
 | 
						if (errstr != NULL) {
 | 
				
			||||||
		xsnprintf(msg, sizeof msg, "Index %s: %s", errstr, s);
 | 
							xsnprintf(msg, sizeof msg, "Index %s: %s", errstr, s);
 | 
				
			||||||
		status_message_set(c, msg);
 | 
							status_message_set(c, "%s", msg);
 | 
				
			||||||
		return (0);
 | 
							return (0);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (winlink_find_by_index(&c->session->windows, idx) == NULL) {
 | 
						if (winlink_find_by_index(&c->session->windows, idx) == NULL) {
 | 
				
			||||||
		xsnprintf(msg, sizeof msg,
 | 
							xsnprintf(msg, sizeof msg,
 | 
				
			||||||
		    "Window not found: %s:%d", c->session->name, idx);
 | 
							    "Window not found: %s:%d", c->session->name, idx);
 | 
				
			||||||
		status_message_set(c, msg);
 | 
							status_message_set(c, "%s", msg);
 | 
				
			||||||
		return (0);
 | 
							return (0);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -194,7 +194,7 @@ key_bindings_error(struct cmd_ctx *ctx, const char *fmt, ...)
 | 
				
			|||||||
	va_end(ap);
 | 
						va_end(ap);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	*msg = toupper((u_char) *msg);
 | 
						*msg = toupper((u_char) *msg);
 | 
				
			||||||
 	status_message_set(ctx->curclient, msg);
 | 
					 	status_message_set(ctx->curclient, "%s", msg);
 | 
				
			||||||
	xfree(msg);
 | 
						xfree(msg);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -227,7 +227,7 @@ key_bindings_info(struct cmd_ctx *ctx, const char *fmt, ...)
 | 
				
			|||||||
	va_end(ap);
 | 
						va_end(ap);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	*msg = toupper((u_char) *msg);
 | 
						*msg = toupper((u_char) *msg);
 | 
				
			||||||
 	status_message_set(ctx->curclient, msg);
 | 
					 	status_message_set(ctx->curclient, "%s", msg);
 | 
				
			||||||
	xfree(msg);
 | 
						xfree(msg);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										9
									
								
								status.c
									
									
									
									
									
								
							
							
						
						
									
										9
									
								
								status.c
									
									
									
									
									
								
							@@ -465,17 +465,20 @@ status_print(struct session *s, struct winlink *wl, struct grid_cell *gc)
 | 
				
			|||||||
	return (text);
 | 
						return (text);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void
 | 
					void printflike2
 | 
				
			||||||
status_message_set(struct client *c, const char *msg)
 | 
					status_message_set(struct client *c, const char *fmt, ...)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct timeval	tv;
 | 
						struct timeval	tv;
 | 
				
			||||||
 | 
						va_list		ap;
 | 
				
			||||||
	int		delay;
 | 
						int		delay;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	delay = options_get_number(&c->session->options, "display-time");
 | 
						delay = options_get_number(&c->session->options, "display-time");
 | 
				
			||||||
	tv.tv_sec = delay / 1000;
 | 
						tv.tv_sec = delay / 1000;
 | 
				
			||||||
	tv.tv_usec = (delay % 1000) * 1000L;
 | 
						tv.tv_usec = (delay % 1000) * 1000L;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	c->message_string = xstrdup(msg);
 | 
						va_start(ap, fmt);
 | 
				
			||||||
 | 
						xvasprintf(&c->message_string, fmt, ap);
 | 
				
			||||||
 | 
						va_end(ap);
 | 
				
			||||||
	if (gettimeofday(&c->message_timer, NULL) != 0)
 | 
						if (gettimeofday(&c->message_timer, NULL) != 0)
 | 
				
			||||||
		fatal("gettimeofday");
 | 
							fatal("gettimeofday");
 | 
				
			||||||
	timeradd(&c->message_timer, &tv, &c->message_timer);
 | 
						timeradd(&c->message_timer, &tv, &c->message_timer);
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										2
									
								
								tmux.h
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								tmux.h
									
									
									
									
									
								
							@@ -1275,7 +1275,7 @@ int	 server_unlock(const char *);
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
/* status.c */
 | 
					/* status.c */
 | 
				
			||||||
int	 status_redraw(struct client *);
 | 
					int	 status_redraw(struct client *);
 | 
				
			||||||
void	 status_message_set(struct client *, const char *);
 | 
					void printflike2 status_message_set(struct client *, const char *, ...);
 | 
				
			||||||
void	 status_message_clear(struct client *);
 | 
					void	 status_message_clear(struct client *);
 | 
				
			||||||
int	 status_message_redraw(struct client *);
 | 
					int	 status_message_redraw(struct client *);
 | 
				
			||||||
void	 status_prompt_set(struct client *,
 | 
					void	 status_prompt_set(struct client *,
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user