mirror of
				https://github.com/tmux/tmux.git
				synced 2025-11-04 00:56:10 +00:00 
			
		
		
		
	Add resize-pane -x and -y for absolute pane size.
This commit is contained in:
		@@ -31,8 +31,8 @@ enum cmd_retval	 cmd_resize_pane_exec(struct cmd *, struct cmd_ctx *);
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
const struct cmd_entry cmd_resize_pane_entry = {
 | 
					const struct cmd_entry cmd_resize_pane_entry = {
 | 
				
			||||||
	"resize-pane", "resizep",
 | 
						"resize-pane", "resizep",
 | 
				
			||||||
	"DLRt:U", 0, 1,
 | 
						"DLRt:Ux:y:", 0, 1,
 | 
				
			||||||
	"[-DLRU] " CMD_TARGET_PANE_USAGE " [adjustment]",
 | 
						"[-DLRU] [-x width] [-y height] " CMD_TARGET_PANE_USAGE " [adjustment]",
 | 
				
			||||||
	0,
 | 
						0,
 | 
				
			||||||
	cmd_resize_pane_key_binding,
 | 
						cmd_resize_pane_key_binding,
 | 
				
			||||||
	NULL,
 | 
						NULL,
 | 
				
			||||||
@@ -87,8 +87,10 @@ cmd_resize_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
 | 
				
			|||||||
	struct args		*args = self->args;
 | 
						struct args		*args = self->args;
 | 
				
			||||||
	struct winlink		*wl;
 | 
						struct winlink		*wl;
 | 
				
			||||||
	const char	       	*errstr;
 | 
						const char	       	*errstr;
 | 
				
			||||||
 | 
						char			*cause;
 | 
				
			||||||
	struct window_pane	*wp;
 | 
						struct window_pane	*wp;
 | 
				
			||||||
	u_int			 adjust;
 | 
						u_int			 adjust;
 | 
				
			||||||
 | 
						int			 x, y;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if ((wl = cmd_find_pane(ctx, args_get(args, 't'), NULL, &wp)) == NULL)
 | 
						if ((wl = cmd_find_pane(ctx, args_get(args, 't'), NULL, &wp)) == NULL)
 | 
				
			||||||
		return (CMD_RETURN_ERROR);
 | 
							return (CMD_RETURN_ERROR);
 | 
				
			||||||
@@ -103,6 +105,27 @@ cmd_resize_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (args_has(self->args, 'x')) {
 | 
				
			||||||
 | 
							x = args_strtonum(self->args, 'x', PANE_MINIMUM, INT_MAX,
 | 
				
			||||||
 | 
							    &cause);
 | 
				
			||||||
 | 
							if (cause != NULL) {
 | 
				
			||||||
 | 
								ctx->error(ctx, "width %s", cause);
 | 
				
			||||||
 | 
								free(cause);
 | 
				
			||||||
 | 
								return (CMD_RETURN_ERROR);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							layout_resize_pane_to(wp, LAYOUT_LEFTRIGHT, x);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if (args_has(self->args, 'y')) {
 | 
				
			||||||
 | 
							y = args_strtonum(self->args, 'y', PANE_MINIMUM, INT_MAX,
 | 
				
			||||||
 | 
							    &cause);
 | 
				
			||||||
 | 
							if (cause != NULL) {
 | 
				
			||||||
 | 
								ctx->error(ctx, "height %s", cause);
 | 
				
			||||||
 | 
								free(cause);
 | 
				
			||||||
 | 
								return (CMD_RETURN_ERROR);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							layout_resize_pane_to(wp, LAYOUT_TOPBOTTOM, y);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	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'))
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										36
									
								
								layout.c
									
									
									
									
									
								
							
							
						
						
									
										36
									
								
								layout.c
									
									
									
									
									
								
							@@ -443,6 +443,39 @@ layout_resize(struct window *w, u_int sx, u_int sy)
 | 
				
			|||||||
	layout_fix_panes(w, sx, sy);
 | 
						layout_fix_panes(w, sx, sy);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Resize a pane to an absolute size. */
 | 
				
			||||||
 | 
					void
 | 
				
			||||||
 | 
					layout_resize_pane_to(struct window_pane *wp, enum layout_type type,
 | 
				
			||||||
 | 
					    u_int new_size)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						struct layout_cell     *lc, *lcparent;
 | 
				
			||||||
 | 
						int			change, size;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						lc = wp->layout_cell;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/* Find next parent of the same type. */
 | 
				
			||||||
 | 
						lcparent = lc->parent;
 | 
				
			||||||
 | 
						while (lcparent != NULL && lcparent->type != type) {
 | 
				
			||||||
 | 
							lc = lcparent;
 | 
				
			||||||
 | 
							lcparent = lc->parent;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if (lcparent == NULL)
 | 
				
			||||||
 | 
							return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/* Work out the size adjustment. */
 | 
				
			||||||
 | 
						if (type == LAYOUT_LEFTRIGHT)
 | 
				
			||||||
 | 
							size = lc->sx;
 | 
				
			||||||
 | 
						else
 | 
				
			||||||
 | 
							size = lc->sy;
 | 
				
			||||||
 | 
						if (lc == TAILQ_LAST(&lcparent->cells, layout_cells))
 | 
				
			||||||
 | 
							change = size - new_size;
 | 
				
			||||||
 | 
						else
 | 
				
			||||||
 | 
							change = new_size - size;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/* Resize the pane. */
 | 
				
			||||||
 | 
						layout_resize_pane(wp, type, change);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Resize a single pane within the layout. */
 | 
					/* Resize a single pane within the layout. */
 | 
				
			||||||
void
 | 
					void
 | 
				
			||||||
layout_resize_pane(struct window_pane *wp, enum layout_type type, int change)
 | 
					layout_resize_pane(struct window_pane *wp, enum layout_type type, int change)
 | 
				
			||||||
@@ -486,6 +519,7 @@ layout_resize_pane(struct window_pane *wp, enum layout_type type, int change)
 | 
				
			|||||||
	notify_window_layout_changed(wp->window);
 | 
						notify_window_layout_changed(wp->window);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Resize pane based on mouse events. */
 | 
				
			||||||
void
 | 
					void
 | 
				
			||||||
layout_resize_pane_mouse(struct client *c)
 | 
					layout_resize_pane_mouse(struct client *c)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@@ -534,6 +568,7 @@ layout_resize_pane_mouse(struct client *c)
 | 
				
			|||||||
		m->flags &= ~MOUSE_RESIZE_PANE;
 | 
							m->flags &= ~MOUSE_RESIZE_PANE;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Helper function to grow pane. */
 | 
				
			||||||
int
 | 
					int
 | 
				
			||||||
layout_resize_pane_grow(
 | 
					layout_resize_pane_grow(
 | 
				
			||||||
    struct layout_cell *lc, enum layout_type type, int needed)
 | 
					    struct layout_cell *lc, enum layout_type type, int needed)
 | 
				
			||||||
@@ -574,6 +609,7 @@ layout_resize_pane_grow(
 | 
				
			|||||||
	return (size);
 | 
						return (size);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Helper function to shrink pane. */
 | 
				
			||||||
int
 | 
					int
 | 
				
			||||||
layout_resize_pane_shrink(
 | 
					layout_resize_pane_shrink(
 | 
				
			||||||
    struct layout_cell *lc, enum layout_type type, int needed)
 | 
					    struct layout_cell *lc, enum layout_type type, int needed)
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										20
									
								
								tmux.1
									
									
									
									
									
								
							
							
						
						
									
										20
									
								
								tmux.1
									
									
									
									
									
								
							@@ -1557,17 +1557,25 @@ if specified, to
 | 
				
			|||||||
.It Xo Ic resize-pane
 | 
					.It Xo Ic resize-pane
 | 
				
			||||||
.Op Fl DLRU
 | 
					.Op Fl DLRU
 | 
				
			||||||
.Op Fl t Ar target-pane
 | 
					.Op Fl t Ar target-pane
 | 
				
			||||||
 | 
					.Op Fl x Ar width
 | 
				
			||||||
 | 
					.Op Fl y Ar height
 | 
				
			||||||
.Op Ar adjustment
 | 
					.Op Ar adjustment
 | 
				
			||||||
.Xc
 | 
					.Xc
 | 
				
			||||||
.D1 (alias: Ic resizep )
 | 
					.D1 (alias: Ic resizep )
 | 
				
			||||||
Resize a pane, upward with
 | 
					Resize a pane, up, down, left or right by
 | 
				
			||||||
.Fl U
 | 
					.Ar adjustment
 | 
				
			||||||
(the default), downward with
 | 
					with
 | 
				
			||||||
 | 
					.Fl U ,
 | 
				
			||||||
.Fl D ,
 | 
					.Fl D ,
 | 
				
			||||||
to the left with
 | 
					 | 
				
			||||||
.Fl L
 | 
					.Fl L
 | 
				
			||||||
and to the right with
 | 
					or
 | 
				
			||||||
.Fl R .
 | 
					.Fl R ,
 | 
				
			||||||
 | 
					or
 | 
				
			||||||
 | 
					to an absolute size
 | 
				
			||||||
 | 
					with
 | 
				
			||||||
 | 
					.Fl x
 | 
				
			||||||
 | 
					or
 | 
				
			||||||
 | 
					.Fl y .
 | 
				
			||||||
The
 | 
					The
 | 
				
			||||||
.Ar adjustment
 | 
					.Ar adjustment
 | 
				
			||||||
is given in lines or cells (the default is 1).
 | 
					is given in lines or cells (the default is 1).
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										10
									
								
								tmux.h
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								tmux.h
									
									
									
									
									
								
							@@ -1167,7 +1167,7 @@ struct mouse_event {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	u_int   sgr;		/* whether the input arrived in SGR format */
 | 
						u_int   sgr;		/* whether the input arrived in SGR format */
 | 
				
			||||||
	u_int   sgr_xb;		/* only for SGR: the unmangled button */
 | 
						u_int   sgr_xb;		/* only for SGR: the unmangled button */
 | 
				
			||||||
	u_int   sgr_rel;	/* only for SGR: whether it is a release event */
 | 
						u_int   sgr_rel;	/* only for SGR: if it is a release event */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	u_int	button;
 | 
						u_int	button;
 | 
				
			||||||
	u_int	clicks;
 | 
						u_int	clicks;
 | 
				
			||||||
@@ -2163,9 +2163,11 @@ void		 layout_resize_adjust(
 | 
				
			|||||||
void		 layout_init(struct window *);
 | 
					void		 layout_init(struct window *);
 | 
				
			||||||
void		 layout_free(struct window *);
 | 
					void		 layout_free(struct window *);
 | 
				
			||||||
void		 layout_resize(struct window *, u_int, u_int);
 | 
					void		 layout_resize(struct window *, u_int, u_int);
 | 
				
			||||||
void		 layout_resize_pane(
 | 
					void		 layout_resize_pane(struct window_pane *, enum layout_type,
 | 
				
			||||||
		     struct window_pane *, enum layout_type, int);
 | 
							     int);
 | 
				
			||||||
void		 layout_resize_pane_mouse(struct client *c);
 | 
					void		 layout_resize_pane_to(struct window_pane *, enum layout_type,
 | 
				
			||||||
 | 
							     u_int);
 | 
				
			||||||
 | 
					void		 layout_resize_pane_mouse(struct client *);
 | 
				
			||||||
void		 layout_assign_pane(struct layout_cell *, struct window_pane *);
 | 
					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);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user