summaryrefslogtreecommitdiff
path: root/usr.bin/tmux/cmd-resize-pane.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2013-03-22 10:37:40 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2013-03-22 10:37:40 +0000
commit8559a1c628d07d8974e3055572f5d36917c12275 (patch)
treef4c3d8a1a419a6dd1d35b4a48ef36f6b6d53b2f5 /usr.bin/tmux/cmd-resize-pane.c
parent137a4bbc41fe6e0976510998536f8a256c2db738 (diff)
Add resize-pane -x and -y for absolute pane size (much requested).
Diffstat (limited to 'usr.bin/tmux/cmd-resize-pane.c')
-rw-r--r--usr.bin/tmux/cmd-resize-pane.c29
1 files changed, 26 insertions, 3 deletions
diff --git a/usr.bin/tmux/cmd-resize-pane.c b/usr.bin/tmux/cmd-resize-pane.c
index 71b0f0b41e0..d30e7280a46 100644
--- a/usr.bin/tmux/cmd-resize-pane.c
+++ b/usr.bin/tmux/cmd-resize-pane.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-resize-pane.c,v 1.12 2013/01/17 00:11:22 nicm Exp $ */
+/* $OpenBSD: cmd-resize-pane.c,v 1.13 2013/03/22 10:37:39 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -31,8 +31,8 @@ enum cmd_retval cmd_resize_pane_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_resize_pane_entry = {
"resize-pane", "resizep",
- "DLRt:U", 0, 1,
- "[-DLRU] " CMD_TARGET_PANE_USAGE " [adjustment]",
+ "DLRt:Ux:y:", 0, 1,
+ "[-DLRU] [-x width] [-y height] " CMD_TARGET_PANE_USAGE " [adjustment]",
0,
cmd_resize_pane_key_binding,
NULL,
@@ -87,8 +87,10 @@ cmd_resize_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
struct args *args = self->args;
struct winlink *wl;
const char *errstr;
+ char *cause;
struct window_pane *wp;
u_int adjust;
+ int x, y;
if ((wl = cmd_find_pane(ctx, args_get(args, 't'), NULL, &wp)) == NULL)
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'))
layout_resize_pane(wp, LAYOUT_LEFTRIGHT, -adjust);
else if (args_has(self->args, 'R'))