aboutsummaryrefslogtreecommitdiff
path: root/vis.c
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2016-04-07 20:43:37 +0200
committerMarc André Tanner <mat@brain-dump.org>2016-04-08 12:49:59 +0200
commit90e798d9e3e1999e6aa51625ea222cb0c8abf834 (patch)
tree7a5f46cc7db457996179618d366d9104fa96817f /vis.c
parentdf84a1c16844c0eaebe12dd0e606d5b2c478c478 (diff)
downloadvis-90e798d9e3e1999e6aa51625ea222cb0c8abf834.tar.gz
vis-90e798d9e3e1999e6aa51625ea222cb0c8abf834.tar.xz
vis: let :e recreate a window at the same location as the old one
Close #224
Diffstat (limited to 'vis.c')
-rw-r--r--vis.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/vis.c b/vis.c
index e1f14ff..730763b 100644
--- a/vis.c
+++ b/vis.c
@@ -292,6 +292,35 @@ bool vis_window_closable(Win *win) {
return win->file->refcount > 1;
}
+void vis_window_swap(Win *a, Win *b) {
+ if (a == b || !a || !b)
+ return;
+ Vis *vis = a->vis;
+ Win *tmp = a->next;
+ a->next = b->next;
+ b->next = tmp;
+ if (a->next)
+ a->next->prev = a;
+ if (b->next)
+ b->next->prev = b;
+ tmp = a->prev;
+ a->prev = b->prev;
+ b->prev = tmp;
+ if (a->prev)
+ a->prev->next = a;
+ if (b->prev)
+ b->prev->next = b;
+ if (vis->windows == a)
+ vis->windows = b;
+ else if (vis->windows == b)
+ vis->windows = a;
+ vis->ui->window_swap(a->ui, b->ui);
+ if (vis->win == a)
+ vis_window_focus(b);
+ else if (vis->win == b)
+ vis_window_focus(a);
+}
+
void vis_window_close(Win *win) {
Vis *vis = win->vis;
if (vis->event && vis->event->win_close)