mirror of
https://github.com/tmux/tmux.git
synced 2026-05-30 14:16:18 +00:00
Merge branch 'master' into floating_panes
This commit is contained in:
@@ -96,7 +96,7 @@ cmd_break_pane_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
}
|
}
|
||||||
|
|
||||||
TAILQ_REMOVE(&w->panes, wp, entry);
|
TAILQ_REMOVE(&w->panes, wp, entry);
|
||||||
TAILQ_REMOVE(&w->z_index, wp, zentry);
|
TAILQ_REMOVE(&w->z_index, wp, zentry);
|
||||||
server_client_remove_pane(wp);
|
server_client_remove_pane(wp);
|
||||||
window_lost_pane(w, wp);
|
window_lost_pane(w, wp);
|
||||||
layout_close_pane(wp);
|
layout_close_pane(wp);
|
||||||
@@ -105,7 +105,7 @@ cmd_break_pane_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
options_set_parent(wp->options, w->options);
|
options_set_parent(wp->options, w->options);
|
||||||
wp->flags |= (PANE_STYLECHANGED|PANE_THEMECHANGED);
|
wp->flags |= (PANE_STYLECHANGED|PANE_THEMECHANGED);
|
||||||
TAILQ_INSERT_HEAD(&w->panes, wp, entry);
|
TAILQ_INSERT_HEAD(&w->panes, wp, entry);
|
||||||
TAILQ_INSERT_HEAD(&w->z_index, wp, zentry);
|
TAILQ_INSERT_HEAD(&w->z_index, wp, zentry);
|
||||||
w->active = wp;
|
w->active = wp;
|
||||||
w->latest = tc;
|
w->latest = tc;
|
||||||
|
|
||||||
|
|||||||
@@ -146,14 +146,14 @@ cmd_join_pane_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
server_client_remove_pane(src_wp);
|
server_client_remove_pane(src_wp);
|
||||||
window_lost_pane(src_w, src_wp);
|
window_lost_pane(src_w, src_wp);
|
||||||
TAILQ_REMOVE(&src_w->panes, src_wp, entry);
|
TAILQ_REMOVE(&src_w->panes, src_wp, entry);
|
||||||
TAILQ_REMOVE(&src_w->z_index, src_wp, zentry);
|
TAILQ_REMOVE(&src_w->z_index, src_wp, zentry);
|
||||||
|
|
||||||
src_wp->window = dst_w;
|
src_wp->window = dst_w;
|
||||||
options_set_parent(src_wp->options, dst_w->options);
|
options_set_parent(src_wp->options, dst_w->options);
|
||||||
src_wp->flags |= (PANE_STYLECHANGED|PANE_THEMECHANGED);
|
src_wp->flags |= (PANE_STYLECHANGED|PANE_THEMECHANGED);
|
||||||
if (flags & SPAWN_BEFORE) {
|
if (flags & SPAWN_BEFORE) {
|
||||||
TAILQ_INSERT_BEFORE(dst_wp, src_wp, entry);
|
TAILQ_INSERT_BEFORE(dst_wp, src_wp, entry);
|
||||||
TAILQ_INSERT_BEFORE(dst_wp, src_wp, zentry);
|
TAILQ_INSERT_BEFORE(dst_wp, src_wp, zentry);
|
||||||
} else {
|
} else {
|
||||||
TAILQ_INSERT_AFTER(&dst_w->panes, dst_wp, src_wp, entry);
|
TAILQ_INSERT_AFTER(&dst_w->panes, dst_wp, src_wp, entry);
|
||||||
TAILQ_INSERT_AFTER(&dst_w->z_index, dst_wp, src_wp, zentry);
|
TAILQ_INSERT_AFTER(&dst_w->z_index, dst_wp, src_wp, zentry);
|
||||||
|
|||||||
@@ -40,10 +40,11 @@ const struct cmd_entry cmd_new_pane_entry = {
|
|||||||
|
|
||||||
.args = { "bc:de:fF:hIkl:Lm:p:PR:s:S:t:vx:X:y:Y:Z", 0, -1, NULL },
|
.args = { "bc:de:fF:hIkl:Lm:p:PR:s:S:t:vx:X:y:Y:Z", 0, -1, NULL },
|
||||||
.usage = "[-bdefhIklPvZ] [-c start-directory] [-e environment] "
|
.usage = "[-bdefhIklPvZ] [-c start-directory] [-e environment] "
|
||||||
"[-F format] [-l size] [-m message] [-p percentage] [-s style] "
|
"[-F format] [-l size] [-m message] [-p percentage] "
|
||||||
"[-S active-border-style] [-R inactive-border-style] "
|
"[-s style] [-S active-border-style] "
|
||||||
"[-x width] [-y height] [-X x-position] [-Y y-position] "
|
"[-R inactive-border-style] [-x width] [-y height] "
|
||||||
CMD_TARGET_PANE_USAGE " [shell-command [argument ...]]",
|
"[-X x-position] [-Y y-position] " CMD_TARGET_PANE_USAGE " "
|
||||||
|
"[shell-command [argument ...]]",
|
||||||
|
|
||||||
.target = { 't', CMD_FIND_PANE, 0 },
|
.target = { 't', CMD_FIND_PANE, 0 },
|
||||||
|
|
||||||
@@ -68,21 +69,22 @@ const struct cmd_entry cmd_split_window_entry = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static struct layout_cell *
|
static struct layout_cell *
|
||||||
cmd_split_window_get_floating_layout_cell(struct cmdq_item *item,
|
cmd_split_window_get_floating_cell(struct cmdq_item *item, struct args *args,
|
||||||
struct args *args, struct window *w, struct window_pane *wp)
|
struct window *w, struct window_pane *wp)
|
||||||
{
|
{
|
||||||
struct layout_cell *lc = NULL;
|
struct layout_cell *lc = NULL;
|
||||||
char *cause = NULL;
|
char *cause = NULL;
|
||||||
u_int x, y, sx, sy;
|
u_int x, y, sx, sy;
|
||||||
|
|
||||||
if (window_pane_float_geometry(w, wp, &x, &y, &sx, &sy, item, args, &cause)
|
if (window_pane_floating_geometry(w, wp, &x, &y, &sx, &sy, item, args,
|
||||||
!= 0) {
|
&cause) != 0) {
|
||||||
cmdq_error(item, "invalid float geometry %s", cause);
|
cmdq_error(item, "invalid floating pane geometry %s", cause);
|
||||||
free(cause);
|
free(cause);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Floating panes sit in layout cells which are not in the layout_root
|
/*
|
||||||
|
* Floating panes sit in layout cells which are not in the layout_root
|
||||||
* tree so we call it with parent == NULL.
|
* tree so we call it with parent == NULL.
|
||||||
*/
|
*/
|
||||||
lc = layout_create_cell(NULL);
|
lc = layout_create_cell(NULL);
|
||||||
@@ -95,8 +97,8 @@ cmd_split_window_get_floating_layout_cell(struct cmdq_item *item,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static struct layout_cell *
|
static struct layout_cell *
|
||||||
cmd_split_window_get_tiled_layout_cell(struct cmdq_item *item,
|
cmd_split_window_get_tiled_cell(struct cmdq_item *item, struct args *args,
|
||||||
struct args *args, struct window *w, struct window_pane *wp, int flags)
|
struct window *w, struct window_pane *wp, int flags)
|
||||||
{
|
{
|
||||||
enum layout_type type;
|
enum layout_type type;
|
||||||
struct layout_cell *lc = NULL;
|
struct layout_cell *lc = NULL;
|
||||||
@@ -113,7 +115,7 @@ cmd_split_window_get_tiled_layout_cell(struct cmdq_item *item,
|
|||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (window_pane_tile_geometry(w, wp, &size, &flags, &type, item, args,
|
if (window_pane_tiled_geometry(w, wp, &size, &flags, &type, item, args,
|
||||||
&cause) != 0) {
|
&cause) != 0) {
|
||||||
cmdq_error(item, "invalid tiled geometry %s", cause);
|
cmdq_error(item, "invalid tiled geometry %s", cause);
|
||||||
free(cause);
|
free(cause);
|
||||||
@@ -124,6 +126,7 @@ cmd_split_window_get_tiled_layout_cell(struct cmdq_item *item,
|
|||||||
lc = layout_split_pane(wp, type, size, flags);
|
lc = layout_split_pane(wp, type, size, flags);
|
||||||
if (lc == NULL)
|
if (lc == NULL)
|
||||||
cmdq_error(item, "no space for new pane");
|
cmdq_error(item, "no space for new pane");
|
||||||
|
|
||||||
return (lc);
|
return (lc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -151,7 +154,6 @@ cmd_split_window_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
is_floating = !args_has(args, 'L');
|
is_floating = !args_has(args, 'L');
|
||||||
else
|
else
|
||||||
is_floating = 0;
|
is_floating = 0;
|
||||||
|
|
||||||
input = (args_has(args, 'I') && count == 0);
|
input = (args_has(args, 'I') && count == 0);
|
||||||
|
|
||||||
flags = is_floating ? SPAWN_FLOATING : 0;
|
flags = is_floating ? SPAWN_FLOATING : 0;
|
||||||
@@ -163,11 +165,9 @@ cmd_split_window_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
flags |= SPAWN_EMPTY;
|
flags |= SPAWN_EMPTY;
|
||||||
|
|
||||||
if (is_floating)
|
if (is_floating)
|
||||||
lc = cmd_split_window_get_floating_layout_cell(item, args, w,
|
lc = cmd_split_window_get_floating_cell(item, args, w, wp);
|
||||||
wp);
|
|
||||||
else
|
else
|
||||||
lc = cmd_split_window_get_tiled_layout_cell(item, args, w, wp,
|
lc = cmd_split_window_get_tiled_cell(item, args, w, wp, flags);
|
||||||
flags);
|
|
||||||
if (lc == NULL)
|
if (lc == NULL)
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
|
|||||||
@@ -289,9 +289,9 @@ layout_parse(struct window *w, const char *layout, char **cause)
|
|||||||
if (floating_lc != NULL)
|
if (floating_lc != NULL)
|
||||||
layout_assign(&wp, floating_lc, PANE_FLOATING);
|
layout_assign(&wp, floating_lc, PANE_FLOATING);
|
||||||
|
|
||||||
/* Fix z indexes. */
|
/* Fix pane Z indexes. */
|
||||||
while (!TAILQ_EMPTY(&w->z_index)) {
|
while (!TAILQ_EMPTY(&w->z_index)) {
|
||||||
wp = TAILQ_FIRST(&w->z_index);
|
wp = TAILQ_FIRST(&w->z_index);
|
||||||
TAILQ_REMOVE(&w->z_index, wp, zentry);
|
TAILQ_REMOVE(&w->z_index, wp, zentry);
|
||||||
}
|
}
|
||||||
if (floating_lc != NULL)
|
if (floating_lc != NULL)
|
||||||
|
|||||||
9
layout.c
9
layout.c
@@ -234,6 +234,7 @@ layout_make_node(struct layout_cell *lc, enum layout_type type)
|
|||||||
lc->wp = NULL;
|
lc->wp = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Fix Z indexes. */
|
||||||
void
|
void
|
||||||
layout_fix_zindexes(struct window *w, struct layout_cell *lc)
|
layout_fix_zindexes(struct window *w, struct layout_cell *lc)
|
||||||
{
|
{
|
||||||
@@ -245,15 +246,15 @@ layout_fix_zindexes(struct window *w, struct layout_cell *lc)
|
|||||||
switch (lc->type) {
|
switch (lc->type) {
|
||||||
case LAYOUT_WINDOWPANE:
|
case LAYOUT_WINDOWPANE:
|
||||||
TAILQ_INSERT_TAIL(&w->z_index, lc->wp, zentry);
|
TAILQ_INSERT_TAIL(&w->z_index, lc->wp, zentry);
|
||||||
break;
|
break;
|
||||||
case LAYOUT_LEFTRIGHT:
|
case LAYOUT_LEFTRIGHT:
|
||||||
case LAYOUT_TOPBOTTOM:
|
case LAYOUT_TOPBOTTOM:
|
||||||
case LAYOUT_FLOATING:
|
case LAYOUT_FLOATING:
|
||||||
TAILQ_FOREACH(lcchild, &lc->cells, entry)
|
TAILQ_FOREACH(lcchild, &lc->cells, entry)
|
||||||
layout_fix_zindexes(w, lcchild);
|
layout_fix_zindexes(w, lcchild);
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
fatalx("bad layout type");
|
fatalx("bad layout type");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
15
tmux.h
15
tmux.h
@@ -1394,6 +1394,9 @@ struct window {
|
|||||||
u_int new_xpixel;
|
u_int new_xpixel;
|
||||||
u_int new_ypixel;
|
u_int new_ypixel;
|
||||||
|
|
||||||
|
u_int last_new_pane_x;
|
||||||
|
u_int last_new_pane_y;
|
||||||
|
|
||||||
struct utf8_data *fill_character;
|
struct utf8_data *fill_character;
|
||||||
int flags;
|
int flags;
|
||||||
#define WINDOW_BELL 0x1
|
#define WINDOW_BELL 0x1
|
||||||
@@ -3493,12 +3496,12 @@ enum client_theme window_pane_get_theme(struct window_pane *);
|
|||||||
void window_pane_send_theme_update(struct window_pane *);
|
void window_pane_send_theme_update(struct window_pane *);
|
||||||
struct style_range *window_pane_border_status_get_range(struct window_pane *,
|
struct style_range *window_pane_border_status_get_range(struct window_pane *,
|
||||||
u_int, u_int);
|
u_int, u_int);
|
||||||
int window_pane_tile_geometry(struct window *, struct window_pane *,
|
int window_pane_tiled_geometry(struct window *,
|
||||||
int *, int *, enum layout_type *, struct cmdq_item *,
|
struct window_pane *, int *, int *, enum layout_type *,
|
||||||
struct args *, char **);
|
struct cmdq_item *, struct args *, char **);
|
||||||
int window_pane_float_geometry(struct window *, struct window_pane *,
|
int window_pane_floating_geometry(struct window *,
|
||||||
u_int *, u_int *, u_int *, u_int *, struct cmdq_item *,
|
struct window_pane *, u_int *, u_int *, u_int *, u_int *,
|
||||||
struct args *, char **);
|
struct cmdq_item *, struct args *, char **);
|
||||||
|
|
||||||
/* layout.c */
|
/* layout.c */
|
||||||
u_int layout_count_cells(struct layout_cell *);
|
u_int layout_count_cells(struct layout_cell *);
|
||||||
|
|||||||
96
window.c
96
window.c
@@ -562,6 +562,7 @@ window_set_active_pane(struct window *w, struct window_pane *wp, int notify)
|
|||||||
}
|
}
|
||||||
|
|
||||||
tty_update_window_offset(w);
|
tty_update_window_offset(w);
|
||||||
|
server_redraw_window(w);
|
||||||
|
|
||||||
if (notify)
|
if (notify)
|
||||||
notify_window("window-pane-changed", w);
|
notify_window("window-pane-changed", w);
|
||||||
@@ -610,10 +611,7 @@ window_redraw_active_switch(struct window *w, struct window_pane *wp)
|
|||||||
if (wp == w->active)
|
if (wp == w->active)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* If you want tiled planes to be able to bury
|
/* If the pane is floating, move to the front. */
|
||||||
* floating planes then do this regardless of
|
|
||||||
* wp->flags & PANE_FLOATING or not. A new option?
|
|
||||||
*/
|
|
||||||
if (wp->flags & PANE_FLOATING) {
|
if (wp->flags & PANE_FLOATING) {
|
||||||
TAILQ_REMOVE(&w->z_index, wp, zentry);
|
TAILQ_REMOVE(&w->z_index, wp, zentry);
|
||||||
TAILQ_INSERT_HEAD(&w->z_index, wp, zentry);
|
TAILQ_INSERT_HEAD(&w->z_index, wp, zentry);
|
||||||
@@ -640,8 +638,7 @@ window_get_active_at(struct window *w, u_int x, u_int y)
|
|||||||
continue;
|
continue;
|
||||||
window_pane_full_size_offset(wp, &xoff, &yoff, &sx, &sy);
|
window_pane_full_size_offset(wp, &xoff, &yoff, &sx, &sy);
|
||||||
if (~wp->flags & PANE_FLOATING) {
|
if (~wp->flags & PANE_FLOATING) {
|
||||||
/* Tiled, select up to including bottom or
|
/* Tiled - to and including bottom or right border. */
|
||||||
right border. */
|
|
||||||
if ((int)x < xoff || x > xoff + sx)
|
if ((int)x < xoff || x > xoff + sx)
|
||||||
continue;
|
continue;
|
||||||
if (pane_status == PANE_STATUS_TOP) {
|
if (pane_status == PANE_STATUS_TOP) {
|
||||||
@@ -652,7 +649,7 @@ window_get_active_at(struct window *w, u_int x, u_int y)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* Floating, include top or or left border. */
|
/* Floating - include top or or left border. */
|
||||||
if ((int)x < xoff - 1 || x > xoff + sx)
|
if ((int)x < xoff - 1 || x > xoff + sx)
|
||||||
continue;
|
continue;
|
||||||
if (pane_status == PANE_STATUS_TOP) {
|
if (pane_status == PANE_STATUS_TOP) {
|
||||||
@@ -660,7 +657,7 @@ window_get_active_at(struct window *w, u_int x, u_int y)
|
|||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
if ((int)y < yoff - 1 || y > yoff + sy)
|
if ((int)y < yoff - 1 || y > yoff + sy)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (wp);
|
return (wp);
|
||||||
@@ -835,12 +832,12 @@ window_add_pane(struct window *w, struct window_pane *other, u_int hlimit,
|
|||||||
else
|
else
|
||||||
TAILQ_INSERT_AFTER(&w->panes, other, wp, entry);
|
TAILQ_INSERT_AFTER(&w->panes, other, wp, entry);
|
||||||
}
|
}
|
||||||
/* Floating panes are created above tiled planes. */
|
if (~flags & SPAWN_FLOATING)
|
||||||
if (flags & SPAWN_FLOATING) {
|
TAILQ_INSERT_TAIL(&w->z_index, wp, zentry);
|
||||||
|
else {
|
||||||
wp->flags |= PANE_FLOATING;
|
wp->flags |= PANE_FLOATING;
|
||||||
TAILQ_INSERT_HEAD(&w->z_index, wp, zentry);
|
TAILQ_INSERT_HEAD(&w->z_index, wp, zentry);
|
||||||
} else
|
}
|
||||||
TAILQ_INSERT_TAIL(&w->z_index, wp, zentry);
|
|
||||||
return (wp);
|
return (wp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -873,7 +870,6 @@ void
|
|||||||
window_remove_pane(struct window *w, struct window_pane *wp)
|
window_remove_pane(struct window *w, struct window_pane *wp)
|
||||||
{
|
{
|
||||||
window_lost_pane(w, wp);
|
window_lost_pane(w, wp);
|
||||||
|
|
||||||
TAILQ_REMOVE(&w->panes, wp, entry);
|
TAILQ_REMOVE(&w->panes, wp, entry);
|
||||||
TAILQ_REMOVE(&w->z_index, wp, zentry);
|
TAILQ_REMOVE(&w->z_index, wp, zentry);
|
||||||
window_pane_destroy(wp);
|
window_pane_destroy(wp);
|
||||||
@@ -941,7 +937,7 @@ window_count_panes(struct window *w, int with_floating)
|
|||||||
u_int n = 0;
|
u_int n = 0;
|
||||||
|
|
||||||
TAILQ_FOREACH(wp, &w->panes, entry) {
|
TAILQ_FOREACH(wp, &w->panes, entry) {
|
||||||
if (with_floating || ~wp->flags & PANE_FLOATING)
|
if (with_floating || ~wp->flags & PANE_FLOATING)
|
||||||
n++;
|
n++;
|
||||||
}
|
}
|
||||||
return (n);
|
return (n);
|
||||||
@@ -996,8 +992,8 @@ window_printable_flags(struct winlink *wl, int escape)
|
|||||||
const char *
|
const char *
|
||||||
window_pane_printable_flags(struct window_pane *wp)
|
window_pane_printable_flags(struct window_pane *wp)
|
||||||
{
|
{
|
||||||
static char flags[32];
|
|
||||||
struct window *w = wp->window;
|
struct window *w = wp->window;
|
||||||
|
static char flags[32];
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
|
|
||||||
if (wp == w->active)
|
if (wp == w->active)
|
||||||
@@ -1302,7 +1298,7 @@ window_pane_reset_mode_all(struct window_pane *wp)
|
|||||||
static void
|
static void
|
||||||
window_pane_copy_paste(struct window_pane *wp, char *buf, size_t len)
|
window_pane_copy_paste(struct window_pane *wp, char *buf, size_t len)
|
||||||
{
|
{
|
||||||
struct window_pane *loop;
|
struct window_pane *loop;
|
||||||
|
|
||||||
TAILQ_FOREACH(loop, &wp->window->panes, entry) {
|
TAILQ_FOREACH(loop, &wp->window->panes, entry) {
|
||||||
if (loop != wp &&
|
if (loop != wp &&
|
||||||
@@ -1320,7 +1316,7 @@ window_pane_copy_paste(struct window_pane *wp, char *buf, size_t len)
|
|||||||
static void
|
static void
|
||||||
window_pane_copy_key(struct window_pane *wp, key_code key)
|
window_pane_copy_key(struct window_pane *wp, key_code key)
|
||||||
{
|
{
|
||||||
struct window_pane *loop;
|
struct window_pane *loop;
|
||||||
|
|
||||||
TAILQ_FOREACH(loop, &wp->window->panes, entry) {
|
TAILQ_FOREACH(loop, &wp->window->panes, entry) {
|
||||||
if (loop != wp &&
|
if (loop != wp &&
|
||||||
@@ -2118,10 +2114,11 @@ window_pane_border_status_get_range(struct window_pane *wp, u_int x, u_int y)
|
|||||||
return (style_ranges_get_range(srs, x - wp->xoff - 2));
|
return (style_ranges_get_range(srs, x - wp->xoff - 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Work out geometry for tiled panes. */
|
||||||
int
|
int
|
||||||
window_pane_tile_geometry(struct window *w, struct window_pane *wp, int *out_size,
|
window_pane_tiled_geometry(struct window *w, struct window_pane *wp,
|
||||||
int *out_flags, enum layout_type *out_type, struct cmdq_item *item,
|
int *out_size, int *out_flags, enum layout_type *out_type,
|
||||||
struct args *args, char **cause)
|
struct cmdq_item *item, struct args *args, char **cause)
|
||||||
{
|
{
|
||||||
int size, flags = *out_flags;
|
int size, flags = *out_flags;
|
||||||
enum layout_type type;
|
enum layout_type type;
|
||||||
@@ -2245,3 +2242,62 @@ out:
|
|||||||
*out_sy = sy;
|
*out_sy = sy;
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Work out geometry for floating panes. */
|
||||||
|
int
|
||||||
|
window_pane_floating_geometry(struct window *w, __unused struct window_pane *wp,
|
||||||
|
u_int *out_x, u_int *out_y, u_int *out_sx, u_int *out_sy,
|
||||||
|
struct cmdq_item *item, struct args *args, char **cause)
|
||||||
|
{
|
||||||
|
u_int x, y, sx = w->sx / 2, sy = w->sy / 2;
|
||||||
|
|
||||||
|
if (args_has(args, 'x')) {
|
||||||
|
sx = args_percentage_and_expand(args, 'x', 0, USHRT_MAX, w->sx,
|
||||||
|
item, cause);
|
||||||
|
if (*cause != NULL)
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
if (args_has(args, 'y')) {
|
||||||
|
sy = args_percentage_and_expand(args, 'y', 0, USHRT_MAX, w->sy,
|
||||||
|
item, cause);
|
||||||
|
if (*cause != NULL)
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args_has(args, 'X')) {
|
||||||
|
x = args_percentage_and_expand(args, 'X', 0, USHRT_MAX, w->sx,
|
||||||
|
item, cause);
|
||||||
|
if (*cause != NULL)
|
||||||
|
return (-1);
|
||||||
|
} else {
|
||||||
|
if (w->last_new_pane_x == 0)
|
||||||
|
x = 4;
|
||||||
|
else {
|
||||||
|
x = w->last_new_pane_x + 4;
|
||||||
|
if (w->last_new_pane_x > w->sx)
|
||||||
|
x = 4;
|
||||||
|
}
|
||||||
|
w->last_new_pane_x = x;
|
||||||
|
}
|
||||||
|
if (args_has(args, 'Y')) {
|
||||||
|
y = args_percentage_and_expand(args, 'Y', 0, USHRT_MAX, w->sy,
|
||||||
|
item, cause);
|
||||||
|
if (*cause != NULL)
|
||||||
|
return (-1);
|
||||||
|
} else {
|
||||||
|
if (w->last_new_pane_y == 0)
|
||||||
|
y = 2;
|
||||||
|
else {
|
||||||
|
y = w->last_new_pane_y + 2;
|
||||||
|
if (w->last_new_pane_y > w->sy)
|
||||||
|
y = 2;
|
||||||
|
}
|
||||||
|
w->last_new_pane_y = y;
|
||||||
|
}
|
||||||
|
|
||||||
|
*out_x = x;
|
||||||
|
*out_y = y;
|
||||||
|
*out_sx = sx;
|
||||||
|
*out_sy = sy;
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user