mirror of
				https://github.com/tmux/tmux.git
				synced 2025-11-04 09:26:05 +00:00 
			
		
		
		
	send-keys -R should reset the input parser to ground state (so it can be
used to escape from, for example, printf '\033]2;').
This commit is contained in:
		@@ -86,7 +86,7 @@ cmd_send_keys_exec(struct cmd *self, struct cmd_q *cmdq)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (args_has(args, 'R'))
 | 
			
		||||
		input_reset(wp);
 | 
			
		||||
		input_reset(wp, 1);
 | 
			
		||||
 | 
			
		||||
	for (i = 0; i < args->argc; i++) {
 | 
			
		||||
		literal = args_has(args, 'l');
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										44
									
								
								input.c
									
									
									
									
									
								
							
							
						
						
									
										44
									
								
								input.c
									
									
									
									
									
								
							@@ -762,24 +762,12 @@ input_init(struct window_pane *wp)
 | 
			
		||||
 | 
			
		||||
	ictx = wp->ictx = xcalloc(1, sizeof *ictx);
 | 
			
		||||
 | 
			
		||||
	input_reset_cell(ictx);
 | 
			
		||||
 | 
			
		||||
	*ictx->interm_buf = '\0';
 | 
			
		||||
	ictx->interm_len = 0;
 | 
			
		||||
 | 
			
		||||
	*ictx->param_buf = '\0';
 | 
			
		||||
	ictx->param_len = 0;
 | 
			
		||||
 | 
			
		||||
	ictx->input_space = INPUT_BUF_START;
 | 
			
		||||
	ictx->input_buf = xmalloc(INPUT_BUF_START);
 | 
			
		||||
 | 
			
		||||
	*ictx->input_buf = '\0';
 | 
			
		||||
	ictx->input_len = 0;
 | 
			
		||||
 | 
			
		||||
	ictx->state = &input_state_ground;
 | 
			
		||||
	ictx->flags = 0;
 | 
			
		||||
 | 
			
		||||
	ictx->since_ground = evbuffer_new();
 | 
			
		||||
 | 
			
		||||
	input_reset(wp, 0);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* Destroy input parser. */
 | 
			
		||||
@@ -797,18 +785,32 @@ input_free(struct window_pane *wp)
 | 
			
		||||
 | 
			
		||||
/* Reset input state and clear screen. */
 | 
			
		||||
void
 | 
			
		||||
input_reset(struct window_pane *wp)
 | 
			
		||||
input_reset(struct window_pane *wp, int clear)
 | 
			
		||||
{
 | 
			
		||||
	struct input_ctx	*ictx = wp->ictx;
 | 
			
		||||
 | 
			
		||||
	input_reset_cell(ictx);
 | 
			
		||||
 | 
			
		||||
	if (wp->mode == NULL)
 | 
			
		||||
		screen_write_start(&ictx->ctx, wp, &wp->base);
 | 
			
		||||
	else
 | 
			
		||||
		screen_write_start(&ictx->ctx, NULL, &wp->base);
 | 
			
		||||
	screen_write_reset(&ictx->ctx);
 | 
			
		||||
	screen_write_stop(&ictx->ctx);
 | 
			
		||||
	if (clear) {
 | 
			
		||||
		if (wp->mode == NULL)
 | 
			
		||||
			screen_write_start(&ictx->ctx, wp, &wp->base);
 | 
			
		||||
		else
 | 
			
		||||
			screen_write_start(&ictx->ctx, NULL, &wp->base);
 | 
			
		||||
		screen_write_reset(&ictx->ctx);
 | 
			
		||||
		screen_write_stop(&ictx->ctx);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	*ictx->interm_buf = '\0';
 | 
			
		||||
	ictx->interm_len = 0;
 | 
			
		||||
 | 
			
		||||
	*ictx->param_buf = '\0';
 | 
			
		||||
	ictx->param_len = 0;
 | 
			
		||||
 | 
			
		||||
	*ictx->input_buf = '\0';
 | 
			
		||||
	ictx->input_len = 0;
 | 
			
		||||
 | 
			
		||||
	ictx->state = &input_state_ground;
 | 
			
		||||
	ictx->flags = 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* Return pending data. */
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										19
									
								
								tmux.h
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								tmux.h
									
									
									
									
									
								
							@@ -1379,6 +1379,7 @@ struct cmd_q {
 | 
			
		||||
	struct cmd		*cmd;
 | 
			
		||||
	struct cmd_q		*parent;
 | 
			
		||||
 | 
			
		||||
	struct cmd_find_state	 current;
 | 
			
		||||
	struct cmd_state	 state;
 | 
			
		||||
 | 
			
		||||
	time_t			 time;
 | 
			
		||||
@@ -1576,6 +1577,7 @@ void		 format_defaults_paste_buffer(struct format_tree *,
 | 
			
		||||
 | 
			
		||||
/* hooks.c */
 | 
			
		||||
struct hook;
 | 
			
		||||
struct hooks 	*hooks_get(struct session *);
 | 
			
		||||
struct hooks	*hooks_create(struct hooks *);
 | 
			
		||||
void		 hooks_free(struct hooks *);
 | 
			
		||||
struct hook	*hooks_first(struct hooks *);
 | 
			
		||||
@@ -1584,10 +1586,10 @@ void		 hooks_add(struct hooks *, const char *, struct cmd_list *);
 | 
			
		||||
void		 hooks_copy(struct hooks *, struct hooks *);
 | 
			
		||||
void		 hooks_remove(struct hooks *, const char *);
 | 
			
		||||
struct hook	*hooks_find(struct hooks *, const char *);
 | 
			
		||||
int printflike(3, 4) hooks_run(struct hooks *, struct client *, const char *,
 | 
			
		||||
		    ...);
 | 
			
		||||
int printflike(3, 4) hooks_wait(struct hooks *, struct cmd_q *, const char *,
 | 
			
		||||
		    ...);
 | 
			
		||||
int printflike(4, 5) hooks_run(struct hooks *, struct client *,
 | 
			
		||||
		    struct cmd_find_state *, const char *, ...);
 | 
			
		||||
int printflike(4, 5) hooks_wait(struct hooks *, struct cmd_q *,
 | 
			
		||||
		    struct cmd_find_state *, const char *, ...);
 | 
			
		||||
 | 
			
		||||
/* mode-key.c */
 | 
			
		||||
extern const struct mode_key_table mode_key_tables[];
 | 
			
		||||
@@ -1776,6 +1778,11 @@ int		 cmd_find_valid_state(struct cmd_find_state *);
 | 
			
		||||
void		 cmd_find_copy_state(struct cmd_find_state *,
 | 
			
		||||
		     struct cmd_find_state *);
 | 
			
		||||
void		 cmd_find_log_state(const char *, struct cmd_find_state *);
 | 
			
		||||
int		 cmd_find_from_session(struct cmd_find_state *,
 | 
			
		||||
		     struct session *);
 | 
			
		||||
int		 cmd_find_from_window(struct cmd_find_state *, struct window *);
 | 
			
		||||
int		 cmd_find_from_pane(struct cmd_find_state *,
 | 
			
		||||
		     struct window_pane *);
 | 
			
		||||
 | 
			
		||||
/* cmd.c */
 | 
			
		||||
int		 cmd_pack_argv(int, char **, char *, size_t);
 | 
			
		||||
@@ -1896,7 +1903,7 @@ void	 server_kill_window(struct window *);
 | 
			
		||||
int	 server_link_window(struct session *,
 | 
			
		||||
	     struct winlink *, struct session *, int, int, int, char **);
 | 
			
		||||
void	 server_unlink_window(struct session *, struct winlink *);
 | 
			
		||||
void	 server_destroy_pane(struct window_pane *);
 | 
			
		||||
void	 server_destroy_pane(struct window_pane *, int);
 | 
			
		||||
void	 server_destroy_session_group(struct session *);
 | 
			
		||||
void	 server_destroy_session(struct session *);
 | 
			
		||||
void	 server_check_unattached(void);
 | 
			
		||||
@@ -1930,7 +1937,7 @@ void	 recalculate_sizes(void);
 | 
			
		||||
/* input.c */
 | 
			
		||||
void	 input_init(struct window_pane *);
 | 
			
		||||
void	 input_free(struct window_pane *);
 | 
			
		||||
void	 input_reset(struct window_pane *);
 | 
			
		||||
void	 input_reset(struct window_pane *, int);
 | 
			
		||||
struct evbuffer *input_pending(struct window_pane *);
 | 
			
		||||
void	 input_parse(struct window_pane *);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user