summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2017-02-27 13:07:57 +0000
committernicm <nicm@openbsd.org>2017-02-27 13:07:57 +0000
commitf241812ad4ac523159bce2ac05d10ce3742fae1d (patch)
tree486e9499af4770e88088bf0c9a48c324eac01823
parentAdd size checks for imsg received over the control socket. (diff)
downloadwireguard-openbsd-f241812ad4ac523159bce2ac05d10ce3742fae1d.tar.xz
wireguard-openbsd-f241812ad4ac523159bce2ac05d10ce3742fae1d.zip
If splitw -b is used, insert the new pane before the current one in the
pane list. This means the numbering is in order (for example for display-panes) and fixes a problem with redrawing the active pane borders.
-rw-r--r--usr.bin/tmux/cmd-split-window.c4
-rw-r--r--usr.bin/tmux/tmux.h4
-rw-r--r--usr.bin/tmux/window.c21
3 files changed, 16 insertions, 13 deletions
diff --git a/usr.bin/tmux/cmd-split-window.c b/usr.bin/tmux/cmd-split-window.c
index 3dd9b18bdf4..43a1b1b1b3c 100644
--- a/usr.bin/tmux/cmd-split-window.c
+++ b/usr.bin/tmux/cmd-split-window.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-split-window.c,v 1.77 2017/02/03 11:57:27 nicm Exp $ */
+/* $OpenBSD: cmd-split-window.c,v 1.78 2017/02/27 13:07:57 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -139,7 +139,7 @@ cmd_split_window_exec(struct cmd *self, struct cmdq_item *item)
cause = xstrdup("pane too small");
goto error;
}
- new_wp = window_add_pane(w, wp, hlimit);
+ new_wp = window_add_pane(w, wp, args_has(args, 'b'), hlimit);
layout_assign_pane(lc, new_wp);
path = NULL;
diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h
index 4bebc36f913..652b99b11a8 100644
--- a/usr.bin/tmux/tmux.h
+++ b/usr.bin/tmux/tmux.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmux.h,v 1.728 2017/02/21 14:18:12 nicm Exp $ */
+/* $OpenBSD: tmux.h,v 1.729 2017/02/27 13:07:57 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -2066,7 +2066,7 @@ int window_set_active_pane(struct window *, struct window_pane *);
void window_redraw_active_switch(struct window *,
struct window_pane *);
struct window_pane *window_add_pane(struct window *, struct window_pane *,
- u_int);
+ int, u_int);
void window_resize(struct window *, u_int, u_int);
int window_zoom(struct window_pane *);
int window_unzoom(struct window *);
diff --git a/usr.bin/tmux/window.c b/usr.bin/tmux/window.c
index db964de482c..b9b14d4aa02 100644
--- a/usr.bin/tmux/window.c
+++ b/usr.bin/tmux/window.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: window.c,v 1.184 2017/02/22 09:01:32 nicm Exp $ */
+/* $OpenBSD: window.c,v 1.185 2017/02/27 13:07:57 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -339,7 +339,7 @@ window_create_spawn(const char *name, int argc, char **argv, const char *path,
struct window_pane *wp;
w = window_create(sx, sy);
- wp = window_add_pane(w, NULL, hlimit);
+ wp = window_add_pane(w, NULL, 0, hlimit);
layout_init(w, wp);
if (window_pane_spawn(wp, argc, argv, path, shell, cwd,
@@ -426,6 +426,7 @@ window_has_pane(struct window *w, struct window_pane *wp)
int
window_set_active_pane(struct window *w, struct window_pane *wp)
{
+ log_debug("%s: pane %%%u (was %%%u)", __func__, wp->id, w->active->id);
if (wp == w->active)
return (0);
w->last = w->active;
@@ -578,19 +579,21 @@ window_unzoom(struct window *w)
}
struct window_pane *
-window_add_pane(struct window *w, struct window_pane *after, u_int hlimit)
+window_add_pane(struct window *w, struct window_pane *other, int before,
+ u_int hlimit)
{
struct window_pane *wp;
+ if (other == NULL)
+ other = w->active;
+
wp = window_pane_create(w, w->sx, w->sy, hlimit);
if (TAILQ_EMPTY(&w->panes))
TAILQ_INSERT_HEAD(&w->panes, wp, entry);
- else {
- if (after == NULL)
- TAILQ_INSERT_AFTER(&w->panes, w->active, wp, entry);
- else
- TAILQ_INSERT_AFTER(&w->panes, after, wp, entry);
- }
+ else if (before)
+ TAILQ_INSERT_BEFORE(other, wp, entry);
+ else
+ TAILQ_INSERT_AFTER(&w->panes, other, wp, entry);
return (wp);
}