mirror of
				https://github.com/tmux/tmux.git
				synced 2025-11-04 09:44:18 +00:00 
			
		
		
		
	Remove the layout undo/redo code which never really worked.
This commit is contained in:
		@@ -103,7 +103,6 @@ cmd_resize_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	layout_list_add(wp->window);
 | 
					 | 
				
			||||||
	if (args_has(self->args, 'L'))
 | 
						if (args_has(self->args, 'L'))
 | 
				
			||||||
		layout_resize_pane(wp, LAYOUT_LEFTRIGHT, -adjust);
 | 
							layout_resize_pane(wp, LAYOUT_LEFTRIGHT, -adjust);
 | 
				
			||||||
	else if (args_has(self->args, 'R'))
 | 
						else if (args_has(self->args, 'R'))
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -29,8 +29,8 @@ enum cmd_retval	 cmd_select_layout_exec(struct cmd *, struct cmd_ctx *);
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
const struct cmd_entry cmd_select_layout_entry = {
 | 
					const struct cmd_entry cmd_select_layout_entry = {
 | 
				
			||||||
	"select-layout", "selectl",
 | 
						"select-layout", "selectl",
 | 
				
			||||||
	"nprut:", 0, 1,
 | 
						"npt:", 0, 1,
 | 
				
			||||||
	"[-npUu] " CMD_TARGET_WINDOW_USAGE " [layout-name]",
 | 
						"[-np] " CMD_TARGET_WINDOW_USAGE " [layout-name]",
 | 
				
			||||||
	0,
 | 
						0,
 | 
				
			||||||
	cmd_select_layout_key_binding,
 | 
						cmd_select_layout_key_binding,
 | 
				
			||||||
	NULL,
 | 
						NULL,
 | 
				
			||||||
@@ -76,14 +76,6 @@ cmd_select_layout_key_binding(struct cmd *self, int key)
 | 
				
			|||||||
	case '5' | KEYC_ESCAPE:
 | 
						case '5' | KEYC_ESCAPE:
 | 
				
			||||||
		self->args = args_create(1, "tiled");
 | 
							self->args = args_create(1, "tiled");
 | 
				
			||||||
		break;
 | 
							break;
 | 
				
			||||||
	case 'u':
 | 
					 | 
				
			||||||
		self->args = args_create(0);
 | 
					 | 
				
			||||||
		args_set(self->args, 'u', NULL);
 | 
					 | 
				
			||||||
		break;
 | 
					 | 
				
			||||||
	case 'U':
 | 
					 | 
				
			||||||
		self->args = args_create(0);
 | 
					 | 
				
			||||||
		args_set(self->args, 'U', NULL);
 | 
					 | 
				
			||||||
		break;
 | 
					 | 
				
			||||||
	default:
 | 
						default:
 | 
				
			||||||
		self->args = args_create(0);
 | 
							self->args = args_create(0);
 | 
				
			||||||
		break;
 | 
							break;
 | 
				
			||||||
@@ -110,21 +102,6 @@ cmd_select_layout_exec(struct cmd *self, struct cmd_ctx *ctx)
 | 
				
			|||||||
	if (args_has(self->args, 'p'))
 | 
						if (args_has(self->args, 'p'))
 | 
				
			||||||
		previous = 1;
 | 
							previous = 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	layout_list_add(w);
 | 
					 | 
				
			||||||
	if (args_has(self->args, 'U')) {
 | 
					 | 
				
			||||||
		if ((layoutname = layout_list_redo(w)) == NULL) {
 | 
					 | 
				
			||||||
			ctx->info(ctx, "no more layout history");
 | 
					 | 
				
			||||||
			return (CMD_RETURN_ERROR);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		goto set_layout;
 | 
					 | 
				
			||||||
	} else if (args_has(self->args, 'u')) {
 | 
					 | 
				
			||||||
		if ((layoutname = layout_list_undo(w)) == NULL) {
 | 
					 | 
				
			||||||
			ctx->info(ctx, "no more layout history");
 | 
					 | 
				
			||||||
			return (CMD_RETURN_ERROR);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		goto set_layout;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (next || previous) {
 | 
						if (next || previous) {
 | 
				
			||||||
		if (next)
 | 
							if (next)
 | 
				
			||||||
			layout = layout_set_next(wl->window);
 | 
								layout = layout_set_next(wl->window);
 | 
				
			||||||
@@ -146,16 +123,14 @@ cmd_select_layout_exec(struct cmd *self, struct cmd_ctx *ctx)
 | 
				
			|||||||
		return (CMD_RETURN_NORMAL);
 | 
							return (CMD_RETURN_NORMAL);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (args->argc == 0)
 | 
						if (args->argc != 0) {
 | 
				
			||||||
		return (CMD_RETURN_NORMAL);
 | 
							layoutname = args->argv[0];
 | 
				
			||||||
	layoutname = args->argv[0];
 | 
							if (layout_parse(wl->window, layoutname) == -1) {
 | 
				
			||||||
 | 
								ctx->error(ctx, "can't set layout: %s", layoutname);
 | 
				
			||||||
set_layout:
 | 
								return (CMD_RETURN_ERROR);
 | 
				
			||||||
	if (layout_parse(wl->window, layoutname) == -1) {
 | 
							}
 | 
				
			||||||
		ctx->error(ctx, "can't set layout: %s", layoutname);
 | 
							server_redraw_window(wl->window);
 | 
				
			||||||
		return (CMD_RETURN_ERROR);
 | 
							ctx->info(ctx, "arranging in: %s", layoutname);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	server_redraw_window(wl->window);
 | 
					 | 
				
			||||||
	ctx->info(ctx, "arranging in: %s", layoutname);
 | 
					 | 
				
			||||||
	return (CMD_RETURN_NORMAL);
 | 
						return (CMD_RETURN_NORMAL);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -130,7 +130,6 @@ key_bindings_init(void)
 | 
				
			|||||||
		{ '?', 			  0, &cmd_list_keys_entry },
 | 
							{ '?', 			  0, &cmd_list_keys_entry },
 | 
				
			||||||
		{ 'D',			  0, &cmd_choose_client_entry },
 | 
							{ 'D',			  0, &cmd_choose_client_entry },
 | 
				
			||||||
		{ 'L',			  0, &cmd_switch_client_entry },
 | 
							{ 'L',			  0, &cmd_switch_client_entry },
 | 
				
			||||||
		{ 'U',			  1, &cmd_select_layout_entry },
 | 
					 | 
				
			||||||
		{ '[', 			  0, &cmd_copy_mode_entry },
 | 
							{ '[', 			  0, &cmd_copy_mode_entry },
 | 
				
			||||||
		{ '\'',			  0, &cmd_command_prompt_entry },
 | 
							{ '\'',			  0, &cmd_command_prompt_entry },
 | 
				
			||||||
		{ '\002', /* C-b */	  0, &cmd_send_prefix_entry },
 | 
							{ '\002', /* C-b */	  0, &cmd_send_prefix_entry },
 | 
				
			||||||
@@ -149,7 +148,6 @@ key_bindings_init(void)
 | 
				
			|||||||
		{ 'r', 			  0, &cmd_refresh_client_entry },
 | 
							{ 'r', 			  0, &cmd_refresh_client_entry },
 | 
				
			||||||
		{ 's', 			  0, &cmd_choose_tree_entry },
 | 
							{ 's', 			  0, &cmd_choose_tree_entry },
 | 
				
			||||||
		{ 't', 			  0, &cmd_clock_mode_entry },
 | 
							{ 't', 			  0, &cmd_clock_mode_entry },
 | 
				
			||||||
		{ 'u',			  1, &cmd_select_layout_entry },
 | 
					 | 
				
			||||||
		{ 'w', 			  0, &cmd_choose_window_entry },
 | 
							{ 'w', 			  0, &cmd_choose_window_entry },
 | 
				
			||||||
		{ 'x', 			  0, &cmd_confirm_before_entry },
 | 
							{ 'x', 			  0, &cmd_confirm_before_entry },
 | 
				
			||||||
		{ '{',			  0, &cmd_swap_pane_entry },
 | 
							{ '{',			  0, &cmd_swap_pane_entry },
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										72
									
								
								layout.c
									
									
									
									
									
								
							
							
						
						
									
										72
									
								
								layout.c
									
									
									
									
									
								
							@@ -19,7 +19,6 @@
 | 
				
			|||||||
#include <sys/types.h>
 | 
					#include <sys/types.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <stdlib.h>
 | 
					#include <stdlib.h>
 | 
				
			||||||
#include <string.h>
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "tmux.h"
 | 
					#include "tmux.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -747,74 +746,3 @@ layout_close_pane(struct window_pane *wp)
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
	notify_window_layout_changed(wp->window);
 | 
						notify_window_layout_changed(wp->window);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					 | 
				
			||||||
/* Add layout to list. */
 | 
					 | 
				
			||||||
void
 | 
					 | 
				
			||||||
layout_list_add(struct window *w)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	struct last_layout	*ll, *ll_last;
 | 
					 | 
				
			||||||
	char			*layout;
 | 
					 | 
				
			||||||
	u_int			 limit;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	layout = layout_dump(w);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	ll_last = w->layout_list_last;
 | 
					 | 
				
			||||||
	if (ll_last != NULL && strcmp(ll_last->layout, layout) == 0) {
 | 
					 | 
				
			||||||
		free(layout);
 | 
					 | 
				
			||||||
		return;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	ll = xmalloc(sizeof *ll);
 | 
					 | 
				
			||||||
	ll->layout = layout;
 | 
					 | 
				
			||||||
	if (ll_last == NULL)
 | 
					 | 
				
			||||||
		TAILQ_INSERT_TAIL(&w->layout_list, ll, entry);
 | 
					 | 
				
			||||||
	else
 | 
					 | 
				
			||||||
		TAILQ_INSERT_AFTER(&w->layout_list, ll_last, ll, entry);
 | 
					 | 
				
			||||||
	w->layout_list_size++;
 | 
					 | 
				
			||||||
	w->layout_list_last = ll;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	limit = options_get_number(&w->options, "layout-history-limit");
 | 
					 | 
				
			||||||
	while (w->layout_list_size > limit) {
 | 
					 | 
				
			||||||
		ll = TAILQ_LAST(&w->layout_list, last_layouts);
 | 
					 | 
				
			||||||
		if (ll == w->layout_list_last)
 | 
					 | 
				
			||||||
			ll = TAILQ_FIRST(&w->layout_list);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		TAILQ_REMOVE(&w->layout_list, ll, entry);
 | 
					 | 
				
			||||||
		w->layout_list_size--;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		free(ll->layout);
 | 
					 | 
				
			||||||
		free(ll);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* Apply next layout from list. */
 | 
					 | 
				
			||||||
const char *
 | 
					 | 
				
			||||||
layout_list_redo(struct window *w)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	struct last_layout	*ll, *ll_last;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	ll_last = w->layout_list_last;
 | 
					 | 
				
			||||||
	if (ll_last == NULL)
 | 
					 | 
				
			||||||
		return (NULL);
 | 
					 | 
				
			||||||
	ll = TAILQ_NEXT(ll_last, entry);
 | 
					 | 
				
			||||||
	if (ll == NULL)
 | 
					 | 
				
			||||||
		return (NULL);
 | 
					 | 
				
			||||||
	w->layout_list_last = ll;
 | 
					 | 
				
			||||||
	return (ll->layout);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* Apply previous layout from list. */
 | 
					 | 
				
			||||||
const char *
 | 
					 | 
				
			||||||
layout_list_undo(struct window *w)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	struct last_layout	*ll, *ll_last;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	ll_last = w->layout_list_last;
 | 
					 | 
				
			||||||
	if (ll_last == NULL)
 | 
					 | 
				
			||||||
		return (NULL);
 | 
					 | 
				
			||||||
	ll = TAILQ_PREV(ll_last, last_layouts, entry);
 | 
					 | 
				
			||||||
	if (ll == NULL)
 | 
					 | 
				
			||||||
		return (NULL);
 | 
					 | 
				
			||||||
	w->layout_list_last = ll;
 | 
					 | 
				
			||||||
	return (ll->layout);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
@@ -517,13 +517,6 @@ const struct options_table_entry window_options_table[] = {
 | 
				
			|||||||
	  .default_num = 0
 | 
						  .default_num = 0
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	{ .name = "layout-history-limit",
 | 
					 | 
				
			||||||
	  .type = OPTIONS_TABLE_NUMBER,
 | 
					 | 
				
			||||||
	  .minimum = 1,
 | 
					 | 
				
			||||||
	  .maximum = USHRT_MAX,
 | 
					 | 
				
			||||||
	  .default_num = 20
 | 
					 | 
				
			||||||
	},
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	{ .name = "main-pane-height",
 | 
						{ .name = "main-pane-height",
 | 
				
			||||||
	  .type = OPTIONS_TABLE_NUMBER,
 | 
						  .type = OPTIONS_TABLE_NUMBER,
 | 
				
			||||||
	  .minimum = 1,
 | 
						  .minimum = 1,
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										16
									
								
								tmux.1
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								tmux.1
									
									
									
									
									
								
							@@ -1601,7 +1601,7 @@ lower) with
 | 
				
			|||||||
.Fl U
 | 
					.Fl U
 | 
				
			||||||
or downward (numerically higher).
 | 
					or downward (numerically higher).
 | 
				
			||||||
.It Xo Ic select-layout
 | 
					.It Xo Ic select-layout
 | 
				
			||||||
.Op Fl npUu
 | 
					.Op Fl np
 | 
				
			||||||
.Op Fl t Ar target-window
 | 
					.Op Fl t Ar target-window
 | 
				
			||||||
.Op Ar layout-name
 | 
					.Op Ar layout-name
 | 
				
			||||||
.Xc
 | 
					.Xc
 | 
				
			||||||
@@ -1618,13 +1618,6 @@ are equivalent to the
 | 
				
			|||||||
and
 | 
					and
 | 
				
			||||||
.Ic previous-layout
 | 
					.Ic previous-layout
 | 
				
			||||||
commands.
 | 
					commands.
 | 
				
			||||||
.Pp
 | 
					 | 
				
			||||||
.Fl U
 | 
					 | 
				
			||||||
and
 | 
					 | 
				
			||||||
.Fl u
 | 
					 | 
				
			||||||
step forward and back through previous layouts, up to the maximum set by the
 | 
					 | 
				
			||||||
.Ic layout-history-limit
 | 
					 | 
				
			||||||
option.
 | 
					 | 
				
			||||||
.It Xo Ic select-pane
 | 
					.It Xo Ic select-pane
 | 
				
			||||||
.Op Fl lDLRU
 | 
					.Op Fl lDLRU
 | 
				
			||||||
.Op Fl t Ar target-pane
 | 
					.Op Fl t Ar target-pane
 | 
				
			||||||
@@ -2677,13 +2670,6 @@ or
 | 
				
			|||||||
.Ar height .
 | 
					.Ar height .
 | 
				
			||||||
A value of zero restores the default unlimited setting.
 | 
					A value of zero restores the default unlimited setting.
 | 
				
			||||||
.Pp
 | 
					.Pp
 | 
				
			||||||
.It Ic layout-history-limit Ar limit
 | 
					 | 
				
			||||||
Set the number of previous layouts stored for recovery with
 | 
					 | 
				
			||||||
.Ic select-layout
 | 
					 | 
				
			||||||
.Fl U
 | 
					 | 
				
			||||||
and
 | 
					 | 
				
			||||||
.Fl u .
 | 
					 | 
				
			||||||
.Pp
 | 
					 | 
				
			||||||
.It Ic main-pane-height Ar height
 | 
					.It Ic main-pane-height Ar height
 | 
				
			||||||
.It Ic main-pane-width Ar width
 | 
					.It Ic main-pane-width Ar width
 | 
				
			||||||
Set the width or height of the main (left or top) pane in the
 | 
					Set the width or height of the main (left or top) pane in the
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										16
									
								
								tmux.h
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								tmux.h
									
									
									
									
									
								
							@@ -974,13 +974,6 @@ struct window_pane {
 | 
				
			|||||||
TAILQ_HEAD(window_panes, window_pane);
 | 
					TAILQ_HEAD(window_panes, window_pane);
 | 
				
			||||||
RB_HEAD(window_pane_tree, window_pane);
 | 
					RB_HEAD(window_pane_tree, window_pane);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Window last layout. */
 | 
					 | 
				
			||||||
struct last_layout {
 | 
					 | 
				
			||||||
	char	*layout;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	TAILQ_ENTRY(last_layout) entry;
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* Window structure. */
 | 
					/* Window structure. */
 | 
				
			||||||
struct window {
 | 
					struct window {
 | 
				
			||||||
	u_int		 id;
 | 
						u_int		 id;
 | 
				
			||||||
@@ -994,9 +987,6 @@ struct window {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	int		 lastlayout;
 | 
						int		 lastlayout;
 | 
				
			||||||
	struct layout_cell *layout_root;
 | 
						struct layout_cell *layout_root;
 | 
				
			||||||
	TAILQ_HEAD(last_layouts, last_layout) layout_list;
 | 
					 | 
				
			||||||
	u_int		 layout_list_size;
 | 
					 | 
				
			||||||
	struct last_layout *layout_list_last;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	u_int		 sx;
 | 
						u_int		 sx;
 | 
				
			||||||
	u_int		 sy;
 | 
						u_int		 sy;
 | 
				
			||||||
@@ -2179,8 +2169,7 @@ u_int		 layout_count_cells(struct layout_cell *);
 | 
				
			|||||||
struct layout_cell *layout_create_cell(struct layout_cell *);
 | 
					struct layout_cell *layout_create_cell(struct layout_cell *);
 | 
				
			||||||
void		 layout_free_cell(struct layout_cell *);
 | 
					void		 layout_free_cell(struct layout_cell *);
 | 
				
			||||||
void		 layout_print_cell(struct layout_cell *, const char *, u_int);
 | 
					void		 layout_print_cell(struct layout_cell *, const char *, u_int);
 | 
				
			||||||
void		 layout_destroy_cell(
 | 
					void		 layout_destroy_cell(struct layout_cell *, struct layout_cell **);
 | 
				
			||||||
		     struct layout_cell *, struct layout_cell **);
 | 
					 | 
				
			||||||
void		 layout_set_size(
 | 
					void		 layout_set_size(
 | 
				
			||||||
		     struct layout_cell *, u_int, u_int, u_int, u_int);
 | 
							     struct layout_cell *, u_int, u_int, u_int, u_int);
 | 
				
			||||||
void		 layout_make_leaf(
 | 
					void		 layout_make_leaf(
 | 
				
			||||||
@@ -2201,9 +2190,6 @@ void		 layout_assign_pane(struct layout_cell *, struct window_pane *);
 | 
				
			|||||||
struct layout_cell *layout_split_pane(
 | 
					struct layout_cell *layout_split_pane(
 | 
				
			||||||
		     struct window_pane *, enum layout_type, int, int);
 | 
							     struct window_pane *, enum layout_type, int, int);
 | 
				
			||||||
void		 layout_close_pane(struct window_pane *);
 | 
					void		 layout_close_pane(struct window_pane *);
 | 
				
			||||||
void		 layout_list_add(struct window *);
 | 
					 | 
				
			||||||
const char	*layout_list_redo(struct window *);
 | 
					 | 
				
			||||||
const char	*layout_list_undo(struct window *);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* layout-custom.c */
 | 
					/* layout-custom.c */
 | 
				
			||||||
char		*layout_dump(struct window *);
 | 
					char		*layout_dump(struct window *);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user