mirror of
https://github.com/tmux/tmux.git
synced 2026-06-04 00:56:17 +00:00
Merge branch 'obsd-master'
This commit is contained in:
@@ -28,8 +28,7 @@ static u_short layout_checksum(const char *);
|
|||||||
static int layout_append(struct layout_cell *, char *,
|
static int layout_append(struct layout_cell *, char *,
|
||||||
size_t);
|
size_t);
|
||||||
static int layout_construct(struct layout_cell *,
|
static int layout_construct(struct layout_cell *,
|
||||||
const char **, struct layout_cell **,
|
const char **, struct layout_cell **);
|
||||||
struct layout_cell **);
|
|
||||||
static void layout_assign(struct window_pane **,
|
static void layout_assign(struct window_pane **,
|
||||||
struct layout_cell *, int);
|
struct layout_cell *, int);
|
||||||
|
|
||||||
@@ -127,7 +126,6 @@ layout_append(struct layout_cell *lc, char *buf, size_t len)
|
|||||||
}
|
}
|
||||||
buf[strlen(buf) - 1] = brackets[0];
|
buf[strlen(buf) - 1] = brackets[0];
|
||||||
break;
|
break;
|
||||||
case LAYOUT_FLOATING:
|
|
||||||
case LAYOUT_WINDOWPANE:
|
case LAYOUT_WINDOWPANE:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -143,7 +141,6 @@ layout_check(struct layout_cell *lc)
|
|||||||
u_int n = 0;
|
u_int n = 0;
|
||||||
|
|
||||||
switch (lc->type) {
|
switch (lc->type) {
|
||||||
case LAYOUT_FLOATING:
|
|
||||||
case LAYOUT_WINDOWPANE:
|
case LAYOUT_WINDOWPANE:
|
||||||
break;
|
break;
|
||||||
case LAYOUT_LEFTRIGHT:
|
case LAYOUT_LEFTRIGHT:
|
||||||
@@ -176,7 +173,7 @@ layout_check(struct layout_cell *lc)
|
|||||||
int
|
int
|
||||||
layout_parse(struct window *w, const char *layout, char **cause)
|
layout_parse(struct window *w, const char *layout, char **cause)
|
||||||
{
|
{
|
||||||
struct layout_cell *lcchild, *tiled_lc = NULL, *floating_lc = NULL;
|
struct layout_cell *lcchild, *tiled_lc = NULL;
|
||||||
struct window_pane *wp;
|
struct window_pane *wp;
|
||||||
u_int npanes, ncells, sx = 0, sy = 0;
|
u_int npanes, ncells, sx = 0, sy = 0;
|
||||||
u_short csum;
|
u_short csum;
|
||||||
@@ -194,7 +191,7 @@ layout_parse(struct window *w, const char *layout, char **cause)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Build the layout. */
|
/* Build the layout. */
|
||||||
if (layout_construct(NULL, &layout, &tiled_lc, &floating_lc) != 0) {
|
if (layout_construct(NULL, &layout, &tiled_lc) != 0) {
|
||||||
*cause = xstrdup("invalid layout");
|
*cause = xstrdup("invalid layout");
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
@@ -213,8 +210,6 @@ layout_parse(struct window *w, const char *layout, char **cause)
|
|||||||
npanes = window_count_panes(w, 1);
|
npanes = window_count_panes(w, 1);
|
||||||
for (;;) {
|
for (;;) {
|
||||||
ncells = layout_count_cells(tiled_lc);
|
ncells = layout_count_cells(tiled_lc);
|
||||||
if (floating_lc != NULL)
|
|
||||||
ncells += layout_count_cells(floating_lc);
|
|
||||||
if (npanes > ncells) {
|
if (npanes > ncells) {
|
||||||
xasprintf(cause, "have %u panes but need %u", npanes,
|
xasprintf(cause, "have %u panes but need %u", npanes,
|
||||||
ncells);
|
ncells);
|
||||||
@@ -224,17 +219,12 @@ layout_parse(struct window *w, const char *layout, char **cause)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Fewer panes than cells - close floating panes first
|
* Fewer panes than cells, close the bottom right until none
|
||||||
* then close the bottom right until none remain.
|
* remain.
|
||||||
*/
|
*/
|
||||||
if (floating_lc != NULL && !TAILQ_EMPTY(&floating_lc->cells)) {
|
|
||||||
lcchild = TAILQ_FIRST(&floating_lc->cells);
|
|
||||||
layout_destroy_cell(w, lcchild, &floating_lc);
|
|
||||||
} else {
|
|
||||||
lcchild = layout_find_bottomright(tiled_lc);
|
lcchild = layout_find_bottomright(tiled_lc);
|
||||||
layout_destroy_cell(w, lcchild, &tiled_lc);
|
layout_destroy_cell(w, lcchild, &tiled_lc);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* It appears older versions of tmux were able to generate layouts with
|
* It appears older versions of tmux were able to generate layouts with
|
||||||
@@ -257,9 +247,6 @@ layout_parse(struct window *w, const char *layout, char **cause)
|
|||||||
sy += lcchild->sy + 1;
|
sy += lcchild->sy + 1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case LAYOUT_FLOATING:
|
|
||||||
*cause = xstrdup("invalid layout");
|
|
||||||
goto fail;
|
|
||||||
}
|
}
|
||||||
if (tiled_lc->type != LAYOUT_WINDOWPANE &&
|
if (tiled_lc->type != LAYOUT_WINDOWPANE &&
|
||||||
(tiled_lc->sx != sx || tiled_lc->sy != sy)) {
|
(tiled_lc->sx != sx || tiled_lc->sy != sy)) {
|
||||||
@@ -285,16 +272,12 @@ layout_parse(struct window *w, const char *layout, char **cause)
|
|||||||
wp = TAILQ_FIRST(&w->panes);
|
wp = TAILQ_FIRST(&w->panes);
|
||||||
if (tiled_lc != NULL)
|
if (tiled_lc != NULL)
|
||||||
layout_assign(&wp, tiled_lc, 0);
|
layout_assign(&wp, tiled_lc, 0);
|
||||||
if (floating_lc != NULL)
|
|
||||||
layout_assign(&wp, floating_lc, PANE_FLOATING);
|
|
||||||
|
|
||||||
/* Fix pane 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)
|
|
||||||
layout_fix_zindexes(w, floating_lc);
|
|
||||||
layout_fix_zindexes(w, tiled_lc);
|
layout_fix_zindexes(w, tiled_lc);
|
||||||
|
|
||||||
/* Update pane offsets and sizes. */
|
/* Update pane offsets and sizes. */
|
||||||
@@ -303,16 +286,12 @@ layout_parse(struct window *w, const char *layout, char **cause)
|
|||||||
recalculate_sizes();
|
recalculate_sizes();
|
||||||
layout_print_cell(tiled_lc, __func__, 0);
|
layout_print_cell(tiled_lc, __func__, 0);
|
||||||
|
|
||||||
/* Free the floating layout cell, no longer needed. */
|
|
||||||
layout_free_cell(floating_lc);
|
|
||||||
|
|
||||||
notify_window("window-layout-changed", w);
|
notify_window("window-layout-changed", w);
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
layout_free_cell(tiled_lc);
|
layout_free_cell(tiled_lc);
|
||||||
layout_free_cell(floating_lc);
|
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -333,7 +312,6 @@ layout_assign(struct window_pane **wp, struct layout_cell *lc, int flags)
|
|||||||
return;
|
return;
|
||||||
case LAYOUT_LEFTRIGHT:
|
case LAYOUT_LEFTRIGHT:
|
||||||
case LAYOUT_TOPBOTTOM:
|
case LAYOUT_TOPBOTTOM:
|
||||||
case LAYOUT_FLOATING:
|
|
||||||
TAILQ_FOREACH(lcchild, &lc->cells, entry)
|
TAILQ_FOREACH(lcchild, &lc->cells, entry)
|
||||||
layout_assign(wp, lcchild, flags);
|
layout_assign(wp, lcchild, flags);
|
||||||
return;
|
return;
|
||||||
@@ -393,13 +371,12 @@ layout_construct_cell(struct layout_cell *lcparent, const char **layout)
|
|||||||
* Possible return values:
|
* Possible return values:
|
||||||
* lc LAYOUT_WINDOWPANE, no children
|
* lc LAYOUT_WINDOWPANE, no children
|
||||||
* lc LAYOUT_LEFTRIGHT or LAYOUT_TOPBOTTOM, with children
|
* lc LAYOUT_LEFTRIGHT or LAYOUT_TOPBOTTOM, with children
|
||||||
* floating_lc LAYOUT_FLOATING, with children
|
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
layout_construct(struct layout_cell *lcparent, const char **layout,
|
layout_construct(struct layout_cell *lcparent, const char **layout,
|
||||||
struct layout_cell **lc, struct layout_cell **floating_lc)
|
struct layout_cell **lc)
|
||||||
{
|
{
|
||||||
struct layout_cell *lcchild, *saved_lc;
|
struct layout_cell *lcchild;
|
||||||
|
|
||||||
*lc = layout_construct_cell(lcparent, layout);
|
*lc = layout_construct_cell(lcparent, layout);
|
||||||
|
|
||||||
@@ -416,18 +393,13 @@ layout_construct(struct layout_cell *lcparent, const char **layout,
|
|||||||
case '[':
|
case '[':
|
||||||
(*lc)->type = LAYOUT_TOPBOTTOM;
|
(*lc)->type = LAYOUT_TOPBOTTOM;
|
||||||
break;
|
break;
|
||||||
case '<':
|
|
||||||
saved_lc = *lc;
|
|
||||||
*lc = layout_create_cell(lcparent);
|
|
||||||
(*lc)->type = LAYOUT_FLOATING;
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
do {
|
do {
|
||||||
(*layout)++;
|
(*layout)++;
|
||||||
if (layout_construct(*lc, layout, &lcchild, floating_lc) != 0)
|
if (layout_construct(*lc, layout, &lcchild) != 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
TAILQ_INSERT_TAIL(&(*lc)->cells, lcchild, entry);
|
TAILQ_INSERT_TAIL(&(*lc)->cells, lcchild, entry);
|
||||||
} while (**layout == ',');
|
} while (**layout == ',');
|
||||||
@@ -441,12 +413,6 @@ layout_construct(struct layout_cell *lcparent, const char **layout,
|
|||||||
if (**layout != ']')
|
if (**layout != ']')
|
||||||
goto fail;
|
goto fail;
|
||||||
break;
|
break;
|
||||||
case LAYOUT_FLOATING:
|
|
||||||
if (**layout != '>')
|
|
||||||
goto fail;
|
|
||||||
*floating_lc = *lc;
|
|
||||||
*lc = saved_lc;
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
@@ -456,6 +422,5 @@ layout_construct(struct layout_cell *lcparent, const char **layout,
|
|||||||
|
|
||||||
fail:
|
fail:
|
||||||
layout_free_cell(*lc);
|
layout_free_cell(*lc);
|
||||||
layout_free_cell(*floating_lc);
|
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|||||||
27
layout.c
27
layout.c
@@ -90,19 +90,6 @@ layout_free_cell(struct layout_cell *lc)
|
|||||||
layout_free_cell(lcchild);
|
layout_free_cell(lcchild);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case LAYOUT_FLOATING:
|
|
||||||
/*
|
|
||||||
* A floating layout cell is only used temporarily while
|
|
||||||
* select-layout constructs a layout. Remove the children from
|
|
||||||
* the temporary layout, then free temporary floating layout
|
|
||||||
* cell. Each floating pane has stub layout.
|
|
||||||
*/
|
|
||||||
while (!TAILQ_EMPTY(&lc->cells)) {
|
|
||||||
lcchild = TAILQ_FIRST(&lc->cells);
|
|
||||||
TAILQ_REMOVE(&lc->cells, lcchild, entry);
|
|
||||||
lcchild->parent = NULL;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case LAYOUT_WINDOWPANE:
|
case LAYOUT_WINDOWPANE:
|
||||||
if (lc->wp != NULL) {
|
if (lc->wp != NULL) {
|
||||||
lc->wp->layout_cell->parent = NULL;
|
lc->wp->layout_cell->parent = NULL;
|
||||||
@@ -131,9 +118,6 @@ layout_print_cell(struct layout_cell *lc, const char *hdr, u_int n)
|
|||||||
case LAYOUT_TOPBOTTOM:
|
case LAYOUT_TOPBOTTOM:
|
||||||
type = "TOPBOTTOM";
|
type = "TOPBOTTOM";
|
||||||
break;
|
break;
|
||||||
case LAYOUT_FLOATING:
|
|
||||||
type = "FLOATING";
|
|
||||||
break;
|
|
||||||
case LAYOUT_WINDOWPANE:
|
case LAYOUT_WINDOWPANE:
|
||||||
type = "WINDOWPANE";
|
type = "WINDOWPANE";
|
||||||
break;
|
break;
|
||||||
@@ -147,7 +131,6 @@ layout_print_cell(struct layout_cell *lc, const char *hdr, u_int n)
|
|||||||
switch (lc->type) {
|
switch (lc->type) {
|
||||||
case LAYOUT_LEFTRIGHT:
|
case LAYOUT_LEFTRIGHT:
|
||||||
case LAYOUT_TOPBOTTOM:
|
case LAYOUT_TOPBOTTOM:
|
||||||
case LAYOUT_FLOATING:
|
|
||||||
TAILQ_FOREACH(lcchild, &lc->cells, entry)
|
TAILQ_FOREACH(lcchild, &lc->cells, entry)
|
||||||
layout_print_cell(lcchild, hdr, n + 1);
|
layout_print_cell(lcchild, hdr, n + 1);
|
||||||
break;
|
break;
|
||||||
@@ -188,7 +171,6 @@ layout_search_by_border(struct layout_cell *lc, u_int x, u_int y)
|
|||||||
return (last);
|
return (last);
|
||||||
break;
|
break;
|
||||||
case LAYOUT_WINDOWPANE:
|
case LAYOUT_WINDOWPANE:
|
||||||
case LAYOUT_FLOATING:
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -251,7 +233,6 @@ layout_fix_zindexes(struct window *w, struct layout_cell *lc)
|
|||||||
break;
|
break;
|
||||||
case LAYOUT_LEFTRIGHT:
|
case LAYOUT_LEFTRIGHT:
|
||||||
case LAYOUT_TOPBOTTOM:
|
case LAYOUT_TOPBOTTOM:
|
||||||
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;
|
||||||
@@ -420,7 +401,6 @@ layout_count_cells(struct layout_cell *lc)
|
|||||||
return (1);
|
return (1);
|
||||||
case LAYOUT_LEFTRIGHT:
|
case LAYOUT_LEFTRIGHT:
|
||||||
case LAYOUT_TOPBOTTOM:
|
case LAYOUT_TOPBOTTOM:
|
||||||
case LAYOUT_FLOATING:
|
|
||||||
TAILQ_FOREACH(lcchild, &lc->cells, entry)
|
TAILQ_FOREACH(lcchild, &lc->cells, entry)
|
||||||
count += layout_count_cells(lcchild);
|
count += layout_count_cells(lcchild);
|
||||||
return (count);
|
return (count);
|
||||||
@@ -549,13 +529,6 @@ layout_destroy_cell(struct window *w, struct layout_cell *lc,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* A floating cell need only be removed from the parent. */
|
|
||||||
if (lcparent->type == LAYOUT_FLOATING) {
|
|
||||||
TAILQ_REMOVE(&lcparent->cells, lc, entry);
|
|
||||||
layout_free_cell(lc);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Merge the space into the previous or next cell. */
|
/* Merge the space into the previous or next cell. */
|
||||||
if (lc == TAILQ_FIRST(&lcparent->cells))
|
if (lc == TAILQ_FIRST(&lcparent->cells))
|
||||||
lcother = TAILQ_NEXT(lc, entry);
|
lcother = TAILQ_NEXT(lc, entry);
|
||||||
|
|||||||
Reference in New Issue
Block a user