diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2016-04-07 20:43:37 +0200 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2016-04-08 12:49:59 +0200 |
| commit | 90e798d9e3e1999e6aa51625ea222cb0c8abf834 (patch) | |
| tree | 7a5f46cc7db457996179618d366d9104fa96817f /ui-curses.c | |
| parent | df84a1c16844c0eaebe12dd0e606d5b2c478c478 (diff) | |
| download | vis-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 'ui-curses.c')
| -rw-r--r-- | ui-curses.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/ui-curses.c b/ui-curses.c index d335995..f5b1194 100644 --- a/ui-curses.c +++ b/ui-curses.c @@ -929,6 +929,36 @@ static enum UiOption ui_window_options_get(UiWin *w) { return win->options; } +static void ui_window_swap(UiWin *aw, UiWin *bw) { + UiCursesWin *a = (UiCursesWin*)aw; + UiCursesWin *b = (UiCursesWin*)bw; + if (a == b || !a || !b) + return; + UiCurses *ui = a->ui; + UiCursesWin *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 (ui->windows == a) + ui->windows = b; + else if (ui->windows == b) + ui->windows = a; + if (ui->selwin == a) + ui_window_focus(bw); + else if (ui->selwin == b) + ui_window_focus(aw); +} + static UiWin *ui_window_new(Ui *ui, View *view, File *file, enum UiOption options) { UiCurses *uic = (UiCurses*)ui; UiCursesWin *win = calloc(1, sizeof(UiCursesWin)); @@ -1115,6 +1145,7 @@ Ui *ui_curses_new(void) { .window_new = ui_window_new, .window_free = ui_window_free, .window_focus = ui_window_focus, + .window_swap = ui_window_swap, .draw = ui_draw, .redraw = ui_redraw, .arrange = ui_arrange, |
