4 * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
15 * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
16 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 #include <sys/types.h>
26 * Increase or decrease pane size.
29 void cmd_resize_pane_key_binding(struct cmd
*, int);
30 int cmd_resize_pane_exec(struct cmd
*, struct cmd_ctx
*);
32 const struct cmd_entry cmd_resize_pane_entry
= {
33 "resize-pane", "resizep",
35 "[-DLRU] " CMD_TARGET_PANE_USAGE
" [adjustment]",
37 cmd_resize_pane_key_binding
,
43 cmd_resize_pane_key_binding(struct cmd
*self
, int key
)
46 case KEYC_UP
| KEYC_CTRL
:
47 self
->args
= args_create(0);
48 args_set(self
->args
, 'U', NULL
);
50 case KEYC_DOWN
| KEYC_CTRL
:
51 self
->args
= args_create(0);
52 args_set(self
->args
, 'D', NULL
);
54 case KEYC_LEFT
| KEYC_CTRL
:
55 self
->args
= args_create(0);
56 args_set(self
->args
, 'L', NULL
);
58 case KEYC_RIGHT
| KEYC_CTRL
:
59 self
->args
= args_create(0);
60 args_set(self
->args
, 'R', NULL
);
62 case KEYC_UP
| KEYC_ESCAPE
:
63 self
->args
= args_create(1, "5");
64 args_set(self
->args
, 'U', NULL
);
66 case KEYC_DOWN
| KEYC_ESCAPE
:
67 self
->args
= args_create(1, "5");
68 args_set(self
->args
, 'D', NULL
);
70 case KEYC_LEFT
| KEYC_ESCAPE
:
71 self
->args
= args_create(1, "5");
72 args_set(self
->args
, 'L', NULL
);
74 case KEYC_RIGHT
| KEYC_ESCAPE
:
75 self
->args
= args_create(1, "5");
76 args_set(self
->args
, 'R', NULL
);
79 self
->args
= args_create(0);
85 cmd_resize_pane_exec(struct cmd
*self
, struct cmd_ctx
*ctx
)
87 struct args
*args
= self
->args
;
90 struct window_pane
*wp
;
93 if ((wl
= cmd_find_pane(ctx
, args_get(args
, 't'), NULL
, &wp
)) == NULL
)
99 adjust
= strtonum(args
->argv
[0], 1, INT_MAX
, &errstr
);
100 if (errstr
!= NULL
) {
101 ctx
->error(ctx
, "adjustment %s", errstr
);
106 if (args_has(self
->args
, 'L'))
107 layout_resize_pane(wp
, LAYOUT_LEFTRIGHT
, -adjust
);
108 else if (args_has(self
->args
, 'R'))
109 layout_resize_pane(wp
, LAYOUT_LEFTRIGHT
, adjust
);
110 else if (args_has(self
->args
, 'U'))
111 layout_resize_pane(wp
, LAYOUT_TOPBOTTOM
, -adjust
);
112 else if (args_has(self
->args
, 'D'))
113 layout_resize_pane(wp
, LAYOUT_TOPBOTTOM
, adjust
);
114 server_redraw_window(wl
->window
);