mirror of
https://github.com/tmux/tmux.git
synced 2025-03-23 14:19:04 +00:00
Sync OpenBSD patchset 191:
If select-layout is not given an argument, reapply the last layout used in the window, if any.
This commit is contained in:
parent
1c73e75982
commit
d9dcc5ed44
@ -1,4 +1,4 @@
|
||||
/* $Id: cmd-select-layout.c,v 1.7 2009-07-28 22:12:16 tcunha Exp $ */
|
||||
/* $Id: cmd-select-layout.c,v 1.8 2009-07-28 23:04:29 tcunha Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -29,8 +29,8 @@ int cmd_select_layout_exec(struct cmd *, struct cmd_ctx *);
|
||||
|
||||
const struct cmd_entry cmd_select_layout_entry = {
|
||||
"select-layout", "selectl",
|
||||
CMD_TARGET_WINDOW_USAGE " layout-name",
|
||||
CMD_ARG1, 0,
|
||||
CMD_TARGET_WINDOW_USAGE " [layout-name]",
|
||||
CMD_ARG01, 0,
|
||||
cmd_select_layout_init,
|
||||
cmd_target_parse,
|
||||
cmd_select_layout_exec,
|
||||
@ -72,11 +72,15 @@ cmd_select_layout_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||
if ((wl = cmd_find_window(ctx, data->target, NULL)) == NULL)
|
||||
return (-1);
|
||||
|
||||
if ((layout = layout_set_lookup(data->arg)) == -1) {
|
||||
ctx->error(ctx, "unknown or ambiguous layout: %s", data->arg);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
if (data->arg == NULL) {
|
||||
layout = wl->window->lastlayout;
|
||||
if (layout == -1)
|
||||
return (0);
|
||||
} else if ((layout = layout_set_lookup(data->arg)) == -1) {
|
||||
ctx->error(ctx, "unknown layout or ambiguous: %s", data->arg);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
layout = layout_set_select(wl->window, layout);
|
||||
ctx->info(ctx, "arranging in: %s", layout_set_name(layout));
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $Id: cmd-server-info.c,v 1.22 2009-07-28 22:12:16 tcunha Exp $ */
|
||||
/* $Id: cmd-server-info.c,v 1.23 2009-07-28 23:04:29 tcunha Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -112,9 +112,9 @@ cmd_server_info_exec(unused struct cmd *self, struct cmd_ctx *ctx)
|
||||
RB_FOREACH(wl, winlinks, &s->windows) {
|
||||
w = wl->window;
|
||||
ctx->print(ctx, "%4u: %s [%ux%u] [flags=0x%x, "
|
||||
"references=%u, layout=%u]", wl->idx, w->name,
|
||||
"references=%u, last layout=%d]", wl->idx, w->name,
|
||||
w->sx, w->sy, w->flags, w->references,
|
||||
w->layout);
|
||||
w->lastlayout);
|
||||
j = 0;
|
||||
TAILQ_FOREACH(wp, &w->panes, entry) {
|
||||
lines = ulines = size = usize = 0;
|
||||
|
37
layout-set.c
37
layout-set.c
@ -1,4 +1,4 @@
|
||||
/* $Id: layout-set.c,v 1.2 2009-07-20 15:51:32 tcunha Exp $ */
|
||||
/* $Id: layout-set.c,v 1.3 2009-07-28 23:04:29 tcunha Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -74,36 +74,47 @@ layout_set_select(struct window *w, u_int layout)
|
||||
if (layout_sets[layout].arrange != NULL)
|
||||
layout_sets[layout].arrange(w);
|
||||
|
||||
w->layout = layout;
|
||||
w->lastlayout = layout;
|
||||
return (layout);
|
||||
}
|
||||
|
||||
u_int
|
||||
layout_set_next(struct window *w)
|
||||
{
|
||||
u_int layout = w->layout;
|
||||
u_int layout;
|
||||
|
||||
if (w->lastlayout == -1)
|
||||
layout = 0;
|
||||
else {
|
||||
layout = w->lastlayout + 1;
|
||||
if (layout > nitems(layout_sets) - 1)
|
||||
layout = 0;
|
||||
}
|
||||
|
||||
if (layout_sets[layout].arrange != NULL)
|
||||
layout_sets[layout].arrange(w);
|
||||
|
||||
w->layout++;
|
||||
if (w->layout > nitems(layout_sets) - 1)
|
||||
w->layout = 0;
|
||||
w->lastlayout = layout;
|
||||
return (layout);
|
||||
}
|
||||
|
||||
u_int
|
||||
layout_set_previous(struct window *w)
|
||||
{
|
||||
u_int layout = w->layout;
|
||||
u_int layout;
|
||||
|
||||
if (w->lastlayout == -1)
|
||||
layout = nitems(layout_sets) - 1;
|
||||
else {
|
||||
layout = w->lastlayout;
|
||||
if (layout == 0)
|
||||
layout = nitems(layout_sets) - 1;
|
||||
else
|
||||
layout--;
|
||||
}
|
||||
|
||||
if (layout_sets[layout].arrange != NULL)
|
||||
layout_sets[layout].arrange(w);
|
||||
|
||||
if (w->layout == 0)
|
||||
w->layout = nitems(layout_sets) - 1;
|
||||
else
|
||||
w->layout--;
|
||||
w->lastlayout = layout;
|
||||
return (layout);
|
||||
}
|
||||
|
||||
|
7
tmux.1
7
tmux.1
@ -1,4 +1,4 @@
|
||||
.\" $Id: tmux.1,v 1.132 2009-07-28 22:44:38 tcunha Exp $
|
||||
.\" $Id: tmux.1,v 1.133 2009-07-28 23:04:29 tcunha Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
.\"
|
||||
@ -1064,10 +1064,13 @@ has the same meaning as in the
|
||||
command.
|
||||
.It Xo Ic select-layout
|
||||
.Op Fl t Ar target-window
|
||||
.Ar layout-name
|
||||
.Op Ar layout-name
|
||||
.Xc
|
||||
.D1 (alias: selectl )
|
||||
Choose a specific layout for a window.
|
||||
If
|
||||
.Ar layout-name
|
||||
is not given, the last layout used (if any) is reapplied.
|
||||
.It Xo Ic select-pane
|
||||
.Op Fl p Ar pane-index
|
||||
.Op Fl t Ar target-window
|
||||
|
4
tmux.h
4
tmux.h
@ -1,4 +1,4 @@
|
||||
/* $Id: tmux.h,v 1.395 2009-07-28 22:58:20 tcunha Exp $ */
|
||||
/* $Id: tmux.h,v 1.396 2009-07-28 23:04:29 tcunha Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -662,7 +662,7 @@ struct window {
|
||||
struct window_pane *active;
|
||||
struct window_panes panes;
|
||||
|
||||
u_int layout;
|
||||
int lastlayout;
|
||||
struct layout_cell *layout_root;
|
||||
|
||||
u_int sx;
|
||||
|
4
window.c
4
window.c
@ -1,4 +1,4 @@
|
||||
/* $Id: window.c,v 1.98 2009-07-23 13:10:38 tcunha Exp $ */
|
||||
/* $Id: window.c,v 1.99 2009-07-28 23:04:29 tcunha Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -229,7 +229,7 @@ window_create1(u_int sx, u_int sy)
|
||||
TAILQ_INIT(&w->panes);
|
||||
w->active = NULL;
|
||||
|
||||
w->layout = 0;
|
||||
w->lastlayout = -1;
|
||||
w->layout_root = NULL;
|
||||
|
||||
w->sx = sx;
|
||||
|
Loading…
Reference in New Issue
Block a user