mirror of
				https://github.com/tmux/tmux.git
				synced 2025-10-26 12:27:15 +00:00 
			
		
		
		
	Add -t to source-file, GitHub issue 3473.
This commit is contained in:
		
							
								
								
									
										23
									
								
								cfg.c
									
									
									
									
									
								
							
							
						
						
									
										23
									
								
								cfg.c
									
									
									
									
									
								
							| @@ -67,6 +67,7 @@ start_cfg(void) | |||||||
| { | { | ||||||
| 	struct client	 *c; | 	struct client	 *c; | ||||||
| 	u_int		  i; | 	u_int		  i; | ||||||
|  | 	int		  flags = 0; | ||||||
|  |  | ||||||
| 	/* | 	/* | ||||||
| 	 * Configuration files are loaded without a client, so commands are run | 	 * Configuration files are loaded without a client, so commands are run | ||||||
| @@ -84,19 +85,17 @@ start_cfg(void) | |||||||
| 		cmdq_append(c, cfg_item); | 		cmdq_append(c, cfg_item); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	for (i = 0; i < cfg_nfiles; i++) { | 	if (cfg_quiet) | ||||||
| 		if (cfg_quiet) | 		flags = CMD_PARSE_QUIET; | ||||||
| 			load_cfg(cfg_files[i], c, NULL, CMD_PARSE_QUIET, NULL); | 	for (i = 0; i < cfg_nfiles; i++) | ||||||
| 		else | 		load_cfg(cfg_files[i], c, NULL, NULL, flags, NULL); | ||||||
| 			load_cfg(cfg_files[i], c, NULL, 0, NULL); |  | ||||||
| 	} |  | ||||||
|  |  | ||||||
| 	cmdq_append(NULL, cmdq_get_callback(cfg_done, NULL)); | 	cmdq_append(NULL, cmdq_get_callback(cfg_done, NULL)); | ||||||
| } | } | ||||||
|  |  | ||||||
| int | int | ||||||
| load_cfg(const char *path, struct client *c, struct cmdq_item *item, int flags, | load_cfg(const char *path, struct client *c, struct cmdq_item *item, | ||||||
|     struct cmdq_item **new_item) |     struct cmd_find_state *current, int flags, struct cmdq_item **new_item) | ||||||
| { | { | ||||||
| 	FILE			*f; | 	FILE			*f; | ||||||
| 	struct cmd_parse_input	 pi; | 	struct cmd_parse_input	 pi; | ||||||
| @@ -135,7 +134,7 @@ load_cfg(const char *path, struct client *c, struct cmdq_item *item, int flags, | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	if (item != NULL) | 	if (item != NULL) | ||||||
| 		state = cmdq_copy_state(cmdq_get_state(item)); | 		state = cmdq_copy_state(cmdq_get_state(item), current); | ||||||
| 	else | 	else | ||||||
| 		state = cmdq_new_state(NULL, NULL, 0); | 		state = cmdq_new_state(NULL, NULL, 0); | ||||||
| 	cmdq_add_format(state, "current_file", "%s", pi.file); | 	cmdq_add_format(state, "current_file", "%s", pi.file); | ||||||
| @@ -155,8 +154,8 @@ load_cfg(const char *path, struct client *c, struct cmdq_item *item, int flags, | |||||||
|  |  | ||||||
| int | int | ||||||
| load_cfg_from_buffer(const void *buf, size_t len, const char *path, | load_cfg_from_buffer(const void *buf, size_t len, const char *path, | ||||||
|     struct client *c, struct cmdq_item *item, int flags, |     struct client *c, struct cmdq_item *item, struct cmd_find_state *current, | ||||||
|     struct cmdq_item **new_item) |     int flags, struct cmdq_item **new_item) | ||||||
| { | { | ||||||
| 	struct cmd_parse_input	 pi; | 	struct cmd_parse_input	 pi; | ||||||
| 	struct cmd_parse_result	*pr; | 	struct cmd_parse_result	*pr; | ||||||
| @@ -187,7 +186,7 @@ load_cfg_from_buffer(const void *buf, size_t len, const char *path, | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	if (item != NULL) | 	if (item != NULL) | ||||||
| 		state = cmdq_copy_state(cmdq_get_state(item)); | 		state = cmdq_copy_state(cmdq_get_state(item), current); | ||||||
| 	else | 	else | ||||||
| 		state = cmdq_new_state(NULL, NULL, 0); | 		state = cmdq_new_state(NULL, NULL, 0); | ||||||
| 	cmdq_add_format(state, "current_file", "%s", pi.file); | 	cmdq_add_format(state, "current_file", "%s", pi.file); | ||||||
|   | |||||||
| @@ -237,8 +237,10 @@ cmdq_link_state(struct cmdq_state *state) | |||||||
|  |  | ||||||
| /* Make a copy of a state. */ | /* Make a copy of a state. */ | ||||||
| struct cmdq_state * | struct cmdq_state * | ||||||
| cmdq_copy_state(struct cmdq_state *state) | cmdq_copy_state(struct cmdq_state *state, struct cmd_find_state *current) | ||||||
| { | { | ||||||
|  | 	if (current != NULL) | ||||||
|  | 		return (cmdq_new_state(current, &state->event, state->flags)); | ||||||
| 	return (cmdq_new_state(&state->current, &state->event, state->flags)); | 	return (cmdq_new_state(&state->current, &state->event, state->flags)); | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -36,8 +36,10 @@ const struct cmd_entry cmd_source_file_entry = { | |||||||
| 	.name = "source-file", | 	.name = "source-file", | ||||||
| 	.alias = "source", | 	.alias = "source", | ||||||
|  |  | ||||||
| 	.args = { "Fnqv", 1, -1, NULL }, | 	.args = { "t:Fnqv", 1, -1, NULL }, | ||||||
| 	.usage = "[-Fnqv] path ...", | 	.usage = "[-Fnqv] " CMD_TARGET_PANE_USAGE " path ...", | ||||||
|  |  | ||||||
|  | 	.target = { 't', CMD_FIND_PANE, CMD_FIND_CANFAIL }, | ||||||
|  |  | ||||||
| 	.flags = 0, | 	.flags = 0, | ||||||
| 	.exec = cmd_source_file_exec | 	.exec = cmd_source_file_exec | ||||||
| @@ -93,6 +95,7 @@ cmd_source_file_done(struct client *c, const char *path, int error, | |||||||
| 	size_t				 bsize = EVBUFFER_LENGTH(buffer); | 	size_t				 bsize = EVBUFFER_LENGTH(buffer); | ||||||
| 	u_int				 n; | 	u_int				 n; | ||||||
| 	struct cmdq_item		*new_item; | 	struct cmdq_item		*new_item; | ||||||
|  | 	struct cmd_find_state		*target = cmdq_get_target(item); | ||||||
|  |  | ||||||
| 	if (!closed) | 	if (!closed) | ||||||
| 		return; | 		return; | ||||||
| @@ -101,7 +104,7 @@ cmd_source_file_done(struct client *c, const char *path, int error, | |||||||
| 		cmdq_error(item, "%s: %s", path, strerror(error)); | 		cmdq_error(item, "%s: %s", path, strerror(error)); | ||||||
| 	else if (bsize != 0) { | 	else if (bsize != 0) { | ||||||
| 		if (load_cfg_from_buffer(bdata, bsize, path, c, cdata->after, | 		if (load_cfg_from_buffer(bdata, bsize, path, c, cdata->after, | ||||||
| 		    cdata->flags, &new_item) < 0) | 		    target, cdata->flags, &new_item) < 0) | ||||||
| 			cdata->retval = CMD_RETURN_ERROR; | 			cdata->retval = CMD_RETURN_ERROR; | ||||||
| 		else if (new_item != NULL) | 		else if (new_item != NULL) | ||||||
| 			cdata->after = new_item; | 			cdata->after = new_item; | ||||||
|   | |||||||
							
								
								
									
										39
									
								
								input.c
									
									
									
									
									
								
							
							
						
						
									
										39
									
								
								input.c
									
									
									
									
									
								
							| @@ -169,6 +169,7 @@ static void	input_csi_dispatch_rm(struct input_ctx *); | |||||||
| static void	input_csi_dispatch_rm_private(struct input_ctx *); | static void	input_csi_dispatch_rm_private(struct input_ctx *); | ||||||
| static void	input_csi_dispatch_sm(struct input_ctx *); | static void	input_csi_dispatch_sm(struct input_ctx *); | ||||||
| static void	input_csi_dispatch_sm_private(struct input_ctx *); | static void	input_csi_dispatch_sm_private(struct input_ctx *); | ||||||
|  | static void	input_csi_dispatch_sm_graphics(struct input_ctx *); | ||||||
| static void	input_csi_dispatch_winops(struct input_ctx *); | static void	input_csi_dispatch_winops(struct input_ctx *); | ||||||
| static void	input_csi_dispatch_sgr_256(struct input_ctx *, int, u_int *); | static void	input_csi_dispatch_sgr_256(struct input_ctx *, int, u_int *); | ||||||
| static void	input_csi_dispatch_sgr_rgb(struct input_ctx *, int, u_int *); | static void	input_csi_dispatch_sgr_rgb(struct input_ctx *, int, u_int *); | ||||||
| @@ -203,7 +204,7 @@ enum input_esc_type { | |||||||
| 	INPUT_ESC_SCSG0_ON, | 	INPUT_ESC_SCSG0_ON, | ||||||
| 	INPUT_ESC_SCSG1_OFF, | 	INPUT_ESC_SCSG1_OFF, | ||||||
| 	INPUT_ESC_SCSG1_ON, | 	INPUT_ESC_SCSG1_ON, | ||||||
| 	INPUT_ESC_ST, | 	INPUT_ESC_ST | ||||||
| }; | }; | ||||||
|  |  | ||||||
| /* Escape command table. */ | /* Escape command table. */ | ||||||
| @@ -259,11 +260,12 @@ enum input_csi_type { | |||||||
| 	INPUT_CSI_SGR, | 	INPUT_CSI_SGR, | ||||||
| 	INPUT_CSI_SM, | 	INPUT_CSI_SM, | ||||||
| 	INPUT_CSI_SM_PRIVATE, | 	INPUT_CSI_SM_PRIVATE, | ||||||
|  | 	INPUT_CSI_SM_GRAPHICS, | ||||||
| 	INPUT_CSI_SU, | 	INPUT_CSI_SU, | ||||||
| 	INPUT_CSI_TBC, | 	INPUT_CSI_TBC, | ||||||
| 	INPUT_CSI_VPA, | 	INPUT_CSI_VPA, | ||||||
| 	INPUT_CSI_WINOPS, | 	INPUT_CSI_WINOPS, | ||||||
| 	INPUT_CSI_XDA, | 	INPUT_CSI_XDA | ||||||
| }; | }; | ||||||
|  |  | ||||||
| /* Control (CSI) command table. */ | /* Control (CSI) command table. */ | ||||||
| @@ -283,6 +285,7 @@ static const struct input_table_entry input_csi_table[] = { | |||||||
| 	{ 'M', "",  INPUT_CSI_DL }, | 	{ 'M', "",  INPUT_CSI_DL }, | ||||||
| 	{ 'P', "",  INPUT_CSI_DCH }, | 	{ 'P', "",  INPUT_CSI_DCH }, | ||||||
| 	{ 'S', "",  INPUT_CSI_SU }, | 	{ 'S', "",  INPUT_CSI_SU }, | ||||||
|  | 	{ 'S', "?", INPUT_CSI_SM_GRAPHICS }, | ||||||
| 	{ 'T', "",  INPUT_CSI_SD }, | 	{ 'T', "",  INPUT_CSI_SD }, | ||||||
| 	{ 'X', "",  INPUT_CSI_ECH }, | 	{ 'X', "",  INPUT_CSI_ECH }, | ||||||
| 	{ 'Z', "",  INPUT_CSI_CBT }, | 	{ 'Z', "",  INPUT_CSI_CBT }, | ||||||
| @@ -306,7 +309,7 @@ static const struct input_table_entry input_csi_table[] = { | |||||||
| 	{ 'r', "",  INPUT_CSI_DECSTBM }, | 	{ 'r', "",  INPUT_CSI_DECSTBM }, | ||||||
| 	{ 's', "",  INPUT_CSI_SCP }, | 	{ 's', "",  INPUT_CSI_SCP }, | ||||||
| 	{ 't', "",  INPUT_CSI_WINOPS }, | 	{ 't', "",  INPUT_CSI_WINOPS }, | ||||||
| 	{ 'u', "",  INPUT_CSI_RCP }, | 	{ 'u', "",  INPUT_CSI_RCP } | ||||||
| }; | }; | ||||||
|  |  | ||||||
| /* Input transition. */ | /* Input transition. */ | ||||||
| @@ -1595,6 +1598,9 @@ input_csi_dispatch(struct input_ctx *ictx) | |||||||
| 	case INPUT_CSI_SM_PRIVATE: | 	case INPUT_CSI_SM_PRIVATE: | ||||||
| 		input_csi_dispatch_sm_private(ictx); | 		input_csi_dispatch_sm_private(ictx); | ||||||
| 		break; | 		break; | ||||||
|  | 	case INPUT_CSI_SM_GRAPHICS: | ||||||
|  | 		input_csi_dispatch_sm_graphics(ictx); | ||||||
|  | 		break; | ||||||
| 	case INPUT_CSI_SU: | 	case INPUT_CSI_SU: | ||||||
| 		n = input_get(ictx, 0, 1, 1); | 		n = input_get(ictx, 0, 1, 1); | ||||||
| 		if (n != -1) | 		if (n != -1) | ||||||
| @@ -1827,6 +1833,12 @@ input_csi_dispatch_sm_private(struct input_ctx *ictx) | |||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
|  | /* Handle CSI graphics SM. */ | ||||||
|  | static void | ||||||
|  | input_csi_dispatch_sm_graphics(__unused struct input_ctx *ictx) | ||||||
|  | { | ||||||
|  | } | ||||||
|  |  | ||||||
| /* Handle CSI window operations. */ | /* Handle CSI window operations. */ | ||||||
| static void | static void | ||||||
| input_csi_dispatch_winops(struct input_ctx *ictx) | input_csi_dispatch_winops(struct input_ctx *ictx) | ||||||
| @@ -1834,6 +1846,7 @@ input_csi_dispatch_winops(struct input_ctx *ictx) | |||||||
| 	struct screen_write_ctx	*sctx = &ictx->ctx; | 	struct screen_write_ctx	*sctx = &ictx->ctx; | ||||||
| 	struct screen		*s = sctx->s; | 	struct screen		*s = sctx->s; | ||||||
| 	struct window_pane	*wp = ictx->wp; | 	struct window_pane	*wp = ictx->wp; | ||||||
|  | 	struct window		*w = wp->window; | ||||||
| 	u_int			 x = screen_size_x(s), y = screen_size_y(s); | 	u_int			 x = screen_size_x(s), y = screen_size_y(s); | ||||||
| 	int			 n, m; | 	int			 n, m; | ||||||
|  |  | ||||||
| @@ -1847,8 +1860,6 @@ input_csi_dispatch_winops(struct input_ctx *ictx) | |||||||
| 		case 7: | 		case 7: | ||||||
| 		case 11: | 		case 11: | ||||||
| 		case 13: | 		case 13: | ||||||
| 		case 14: |  | ||||||
| 		case 19: |  | ||||||
| 		case 20: | 		case 20: | ||||||
| 		case 21: | 		case 21: | ||||||
| 		case 24: | 		case 24: | ||||||
| @@ -1866,6 +1877,21 @@ input_csi_dispatch_winops(struct input_ctx *ictx) | |||||||
| 			if (input_get(ictx, m, 0, -1) == -1) | 			if (input_get(ictx, m, 0, -1) == -1) | ||||||
| 				return; | 				return; | ||||||
| 			break; | 			break; | ||||||
|  | 		case 14: | ||||||
|  | 			input_reply(ictx, "\033[4;%u;%ut", y * w->ypixel, x * w->xpixel); | ||||||
|  | 			break; | ||||||
|  | 		case 15: | ||||||
|  | 			input_reply(ictx, "\033[5;%u;%ut", y * w->ypixel, x * w->xpixel); | ||||||
|  | 			break; | ||||||
|  | 		case 16: | ||||||
|  | 			input_reply(ictx, "\033[6;%u;%ut", w->ypixel, w->xpixel); | ||||||
|  | 			break; | ||||||
|  | 		case 18: | ||||||
|  | 			input_reply(ictx, "\033[8;%u;%ut", y, x); | ||||||
|  | 			break; | ||||||
|  | 		case 19: | ||||||
|  | 			input_reply(ictx, "\033[9;%u;%ut", y, x); | ||||||
|  | 			break; | ||||||
| 		case 22: | 		case 22: | ||||||
| 			m++; | 			m++; | ||||||
| 			switch (input_get(ictx, m, 0, -1)) { | 			switch (input_get(ictx, m, 0, -1)) { | ||||||
| @@ -1893,9 +1919,6 @@ input_csi_dispatch_winops(struct input_ctx *ictx) | |||||||
| 				break; | 				break; | ||||||
| 			} | 			} | ||||||
| 			break; | 			break; | ||||||
| 		case 18: |  | ||||||
| 			input_reply(ictx, "\033[8;%u;%ut", y, x); |  | ||||||
| 			break; |  | ||||||
| 		default: | 		default: | ||||||
| 			log_debug("%s: unknown '%c'", __func__, ictx->ch); | 			log_debug("%s: unknown '%c'", __func__, ictx->ch); | ||||||
| 			break; | 			break; | ||||||
|   | |||||||
							
								
								
									
										1
									
								
								tmux.1
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								tmux.1
									
									
									
									
									
								
							| @@ -1546,6 +1546,7 @@ show debugging information about jobs and terminals. | |||||||
| .Tg source | .Tg source | ||||||
| .It Xo Ic source-file | .It Xo Ic source-file | ||||||
| .Op Fl Fnqv | .Op Fl Fnqv | ||||||
|  | .Op Fl t Ar target-pane | ||||||
| .Ar path ... | .Ar path ... | ||||||
| .Xc | .Xc | ||||||
| .D1 Pq alias: Ic source | .D1 Pq alias: Ic source | ||||||
|   | |||||||
							
								
								
									
										10
									
								
								tmux.h
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								tmux.h
									
									
									
									
									
								
							| @@ -2102,10 +2102,11 @@ extern char **cfg_files; | |||||||
| extern u_int cfg_nfiles; | extern u_int cfg_nfiles; | ||||||
| extern int cfg_quiet; | extern int cfg_quiet; | ||||||
| void	start_cfg(void); | void	start_cfg(void); | ||||||
| int	load_cfg(const char *, struct client *, struct cmdq_item *, int, | int	load_cfg(const char *, struct client *, struct cmdq_item *, | ||||||
| 	    struct cmdq_item **); |             struct cmd_find_state *, int, struct cmdq_item **); | ||||||
| int	load_cfg_from_buffer(const void *, size_t, const char *, | int	load_cfg_from_buffer(const void *, size_t, const char *, | ||||||
| 	    struct client *, struct cmdq_item *, int, struct cmdq_item **); |   	    struct client *, struct cmdq_item *, struct cmd_find_state *, | ||||||
|  | 	    int, struct cmdq_item **); | ||||||
| void printflike(1, 2) cfg_add_cause(const char *, ...); | void printflike(1, 2) cfg_add_cause(const char *, ...); | ||||||
| void	cfg_print_causes(struct cmdq_item *); | void	cfg_print_causes(struct cmdq_item *); | ||||||
| void	cfg_show_causes(struct session *); | void	cfg_show_causes(struct session *); | ||||||
| @@ -2551,7 +2552,8 @@ struct cmd_parse_result *cmd_parse_from_arguments(struct args_value *, u_int, | |||||||
| struct cmdq_state *cmdq_new_state(struct cmd_find_state *, struct key_event *, | struct cmdq_state *cmdq_new_state(struct cmd_find_state *, struct key_event *, | ||||||
| 		     int); | 		     int); | ||||||
| struct cmdq_state *cmdq_link_state(struct cmdq_state *); | struct cmdq_state *cmdq_link_state(struct cmdq_state *); | ||||||
| struct cmdq_state *cmdq_copy_state(struct cmdq_state *); | struct cmdq_state *cmdq_copy_state(struct cmdq_state *, | ||||||
|  | 		     struct cmd_find_state *); | ||||||
| void		  cmdq_free_state(struct cmdq_state *); | void		  cmdq_free_state(struct cmdq_state *); | ||||||
| void printflike(3, 4) cmdq_add_format(struct cmdq_state *, const char *, | void printflike(3, 4) cmdq_add_format(struct cmdq_state *, const char *, | ||||||
| 		     const char *, ...); | 		     const char *, ...); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 nicm
					nicm