mirror of
				https://github.com/tmux/tmux.git
				synced 2025-11-04 01:34:18 +00:00 
			
		
		
		
	Convert hidden flag to a full flags word for the status line and add a flag to
accept after only one key. Use this so don't need to press enter after y/n for confirm-before.
This commit is contained in:
		@@ -1,4 +1,4 @@
 | 
			
		||||
/* $Id: cmd-confirm-before.c,v 1.1 2009-04-27 13:21:15 tcunha Exp $ */
 | 
			
		||||
/* $Id: cmd-confirm-before.c,v 1.2 2009-04-27 17:27:36 nicm Exp $ */
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org>
 | 
			
		||||
@@ -125,7 +125,8 @@ cmd_confirm_before_exec(unused struct cmd *self, struct cmd_ctx *ctx)
 | 
			
		||||
	cdata = xmalloc(sizeof *cdata);
 | 
			
		||||
	cdata->data.cmd = xstrdup(data->cmd);
 | 
			
		||||
	cdata->c = ctx->curclient;
 | 
			
		||||
	status_prompt_set(cdata->c, buf, cmd_confirm_before_callback, cdata, 0);
 | 
			
		||||
	status_prompt_set(
 | 
			
		||||
	    cdata->c, buf, cmd_confirm_before_callback, cdata, PROMPT_SINGLE);
 | 
			
		||||
 | 
			
		||||
	xfree(buf);
 | 
			
		||||
	return (1);
 | 
			
		||||
@@ -183,7 +184,7 @@ cmd_confirm_before_callback(void *data, const char *s)
 | 
			
		||||
	struct cmd_ctx	 	 	 ctx;
 | 
			
		||||
	char				*cause;
 | 
			
		||||
 | 
			
		||||
	if (s == NULL || (strcasecmp(s, "y") && strcasecmp(s, "yes")))
 | 
			
		||||
	if (s == NULL || tolower((u_char) s[0]) != 'y' || s[1] != '\0')
 | 
			
		||||
		goto out;
 | 
			
		||||
 | 
			
		||||
	if (cmd_string_parse(cdata->data.cmd, &cmdlist, &cause) != 0) {
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,4 @@
 | 
			
		||||
/* $Id: server-fn.c,v 1.58 2009-04-02 20:30:20 nicm Exp $ */
 | 
			
		||||
/* $Id: server-fn.c,v 1.59 2009-04-27 17:27:36 nicm Exp $ */
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
			
		||||
@@ -183,7 +183,8 @@ server_lock(void)
 | 
			
		||||
			continue;
 | 
			
		||||
 | 
			
		||||
		status_prompt_clear(c);
 | 
			
		||||
		status_prompt_set(c, "Password: ", server_lock_callback, c, 1);
 | 
			
		||||
		status_prompt_set(
 | 
			
		||||
		    c, "Password: ", server_lock_callback, c, PROMPT_HIDDEN);
 | 
			
		||||
  		server_redraw_client(c);
 | 
			
		||||
	}
 | 
			
		||||
	server_locked = 1;
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										14
									
								
								status.c
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								status.c
									
									
									
									
									
								
							@@ -1,4 +1,4 @@
 | 
			
		||||
/* $Id: status.c,v 1.76 2009-04-27 13:56:51 tcunha Exp $ */
 | 
			
		||||
/* $Id: status.c,v 1.77 2009-04-27 17:27:36 nicm Exp $ */
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
			
		||||
@@ -563,7 +563,7 @@ status_message_redraw(struct client *c)
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
status_prompt_set(struct client *c,
 | 
			
		||||
    const char *msg, int (*fn)(void *, const char *), void *data, int hide)
 | 
			
		||||
    const char *msg, int (*fn)(void *, const char *), void *data, int flags)
 | 
			
		||||
{
 | 
			
		||||
	c->prompt_string = xstrdup(msg);
 | 
			
		||||
 | 
			
		||||
@@ -575,7 +575,7 @@ status_prompt_set(struct client *c,
 | 
			
		||||
 | 
			
		||||
	c->prompt_hindex = 0;
 | 
			
		||||
 | 
			
		||||
	c->prompt_hidden = hide;
 | 
			
		||||
	c->prompt_flags = flags;
 | 
			
		||||
 | 
			
		||||
	mode_key_init(&c->prompt_mdata,
 | 
			
		||||
	    options_get_number(&c->session->options, "status-keys"),
 | 
			
		||||
@@ -644,7 +644,7 @@ status_prompt_redraw(struct client *c)
 | 
			
		||||
				left--;
 | 
			
		||||
			size = left;
 | 
			
		||||
		}
 | 
			
		||||
		if (c->prompt_hidden) {
 | 
			
		||||
		if (c->prompt_flags & PROMPT_HIDDEN) {
 | 
			
		||||
			n = strlen(c->prompt_buffer);
 | 
			
		||||
			if (n > left)
 | 
			
		||||
				n = left;
 | 
			
		||||
@@ -844,6 +844,12 @@ status_prompt_key(struct client *c, int key)
 | 
			
		||||
			c->prompt_buffer[c->prompt_index++] = key;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if (c->prompt_flags & PROMPT_SINGLE) {
 | 
			
		||||
			if (c->prompt_callback(
 | 
			
		||||
			    c->prompt_data, c->prompt_buffer) == 0)
 | 
			
		||||
				status_prompt_clear(c);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		c->flags |= CLIENT_STATUS;
 | 
			
		||||
		break;
 | 
			
		||||
	default:
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										9
									
								
								tmux.h
									
									
									
									
									
								
							
							
						
						
									
										9
									
								
								tmux.h
									
									
									
									
									
								
							@@ -1,4 +1,4 @@
 | 
			
		||||
/* $Id: tmux.h,v 1.302 2009-04-27 14:51:59 nicm Exp $ */
 | 
			
		||||
/* $Id: tmux.h,v 1.303 2009-04-27 17:27:36 nicm Exp $ */
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
			
		||||
@@ -857,9 +857,14 @@ struct client {
 | 
			
		||||
	size_t		 prompt_index;
 | 
			
		||||
	int		 (*prompt_callback)(void *, const char *);
 | 
			
		||||
	void		*prompt_data;
 | 
			
		||||
	int		 prompt_hidden;
 | 
			
		||||
 | 
			
		||||
#define PROMPT_HIDDEN 0x1
 | 
			
		||||
#define PROMPT_SINGLE 0x2
 | 
			
		||||
	int		 prompt_flags;
 | 
			
		||||
 | 
			
		||||
	u_int		 prompt_hindex;
 | 
			
		||||
	ARRAY_DECL(, char *) prompt_hdata;
 | 
			
		||||
 | 
			
		||||
	struct mode_key_data prompt_mdata;
 | 
			
		||||
 | 
			
		||||
	struct session	*session;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user