Mercurial > vim
annotate src/window.c @ 25499:5ebf9bb1cbcd v8.2.3286
patch 8.2.3286: win_enter_ext() has too many boolean arguments
Commit: https://github.com/vim/vim/commit/d61f2f772a59617850e9aa2f5fa069c1aad8e074
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Aug 4 20:26:19 2021 +0200
patch 8.2.3286: win_enter_ext() has too many boolean arguments
Problem: win_enter_ext() has too many boolean arguments.
Solution: use one flags argument with defined values.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 04 Aug 2021 20:30:04 +0200 |
parents | 078edc1821bf |
children | a1ed55c02e80 |
rev | line source |
---|---|
10042
4aead6a9b7a9
commit https://github.com/vim/vim/commit/edf3f97ae2af024708ebb4ac614227327033ca47
Christian Brabandt <cb@256bit.org>
parents:
10013
diff
changeset
|
1 /* vi:set ts=8 sts=4 sw=4 noet: |
7 | 2 * |
3 * VIM - Vi IMproved by Bram Moolenaar | |
4 * | |
5 * Do ":help uganda" in Vim to read a list of people who contributed. | |
6 * Do ":help credits" in Vim to see a list of people who contributed. | |
7 * See README.txt for an overview of the Vim source code. | |
8 */ | |
9 | |
10 #include "vim.h" | |
11 | |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
12 static void cmd_with_count(char *cmd, char_u *bufp, size_t bufsize, long Prenum); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
13 static void win_init(win_T *newp, win_T *oldp, int flags); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
14 static void win_init_some(win_T *newp, win_T *oldp); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
15 static void frame_comp_pos(frame_T *topfrp, int *row, int *col); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
16 static void frame_setheight(frame_T *curfrp, int height); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
17 static void frame_setwidth(frame_T *curfrp, int width); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
18 static void win_exchange(long); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
19 static void win_rotate(int, int); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
20 static void win_totop(int size, int flags); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
21 static void win_equal_rec(win_T *next_curwin, int current, frame_T *topfr, int dir, int col, int row, int width, int height); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
22 static win_T *win_free_mem(win_T *win, int *dirp, tabpage_T *tp); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
23 static frame_T *win_altframe(win_T *win, tabpage_T *tp); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
24 static tabpage_T *alt_tabpage(void); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
25 static win_T *frame2win(frame_T *frp); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
26 static int frame_has_win(frame_T *frp, win_T *wp); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
27 static void frame_new_height(frame_T *topfrp, int height, int topfirst, int wfh); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
28 static int frame_fixed_height(frame_T *frp); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
29 static int frame_fixed_width(frame_T *frp); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
30 static void frame_add_statusline(frame_T *frp); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
31 static void frame_new_width(frame_T *topfrp, int width, int leftfirst, int wfw); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
32 static void frame_add_vsep(frame_T *frp); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
33 static int frame_minwidth(frame_T *topfrp, win_T *next_curwin); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
34 static void frame_fix_width(win_T *wp); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
35 static int win_alloc_firstwin(win_T *oldwin); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
36 static void new_frame(win_T *wp); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
37 static tabpage_T *alloc_tabpage(void); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
38 static int leave_tabpage(buf_T *new_curbuf, int trigger_leave_autocmds); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
39 static void enter_tabpage(tabpage_T *tp, buf_T *old_curbuf, int trigger_enter_autocmds, int trigger_leave_autocmds); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
40 static void frame_fix_height(win_T *wp); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
41 static int frame_minheight(frame_T *topfrp, win_T *next_curwin); |
17789
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17670
diff
changeset
|
42 static int may_open_tabpage(void); |
25499
5ebf9bb1cbcd
patch 8.2.3286: win_enter_ext() has too many boolean arguments
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
43 static void win_enter_ext(win_T *wp, int flags); |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
44 static void win_free(win_T *wp, tabpage_T *tp); |
17789
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17670
diff
changeset
|
45 static int win_unlisted(win_T *wp); |
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17670
diff
changeset
|
46 static void win_append(win_T *after, win_T *wp); |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
47 static void frame_append(frame_T *after, frame_T *frp); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
48 static void frame_insert(frame_T *before, frame_T *frp); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
49 static void frame_remove(frame_T *frp); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
50 static void win_goto_ver(int up, long count); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
51 static void win_goto_hor(int left, long count); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
52 static void frame_add_height(frame_T *frp, int n); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
53 static void last_status_rec(frame_T *fr, int statusline); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
54 |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
55 static void make_snapshot_rec(frame_T *fr, frame_T **frp); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
56 static void clear_snapshot(tabpage_T *tp, int idx); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
57 static void clear_snapshot_rec(frame_T *fr); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
58 static int check_snapshot_rec(frame_T *sn, frame_T *fr); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
59 static win_T *restore_snapshot_rec(frame_T *sn, frame_T *fr); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
60 |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
61 static int frame_check_height(frame_T *topfrp, int height); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
62 static int frame_check_width(frame_T *topfrp, int width); |
5004
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
63 |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
64 static win_T *win_alloc(win_T *after, int hidden); |
7 | 65 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
66 #define NOWIN (win_T *)-1 // non-existing window |
7 | 67 |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
68 #define ROWS_AVAIL (Rows - p_ch - tabline_height()) |
826 | 69 |
25499
5ebf9bb1cbcd
patch 8.2.3286: win_enter_ext() has too many boolean arguments
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
70 // flags for win_enter_ext() |
5ebf9bb1cbcd
patch 8.2.3286: win_enter_ext() has too many boolean arguments
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
71 #define WEE_UNDO_SYNC 0x01 |
5ebf9bb1cbcd
patch 8.2.3286: win_enter_ext() has too many boolean arguments
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
72 #define WEE_CURWIN_INVALID 0x02 |
5ebf9bb1cbcd
patch 8.2.3286: win_enter_ext() has too many boolean arguments
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
73 #define WEE_TRIGGER_NEW_AUTOCMDS 0x04 |
5ebf9bb1cbcd
patch 8.2.3286: win_enter_ext() has too many boolean arguments
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
74 #define WEE_TRIGGER_ENTER_AUTOCMDS 0x08 |
5ebf9bb1cbcd
patch 8.2.3286: win_enter_ext() has too many boolean arguments
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
75 #define WEE_TRIGGER_LEAVE_AUTOCMDS 0x10 |
5ebf9bb1cbcd
patch 8.2.3286: win_enter_ext() has too many boolean arguments
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
76 |
826 | 77 static char *m_onlyone = N_("Already only one window"); |
78 | |
17516
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
79 // When non-zero splitting a window is forbidden. Used to avoid that nasty |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
80 // autocommands mess up the window structure. |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
81 static int split_disallowed = 0; |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
82 |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
83 // #define WIN_DEBUG |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
84 #ifdef WIN_DEBUG |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
85 /* |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
86 * Call this method to log the current window layout. |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
87 */ |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
88 static void |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
89 log_frame_layout(frame_T *frame) |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
90 { |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
91 ch_log(NULL, "layout %s, wi: %d, he: %d, wwi: %d, whe: %d, id: %d", |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
92 frame->fr_layout == FR_LEAF ? "LEAF" |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
93 : frame->fr_layout == FR_ROW ? "ROW" : "COL", |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
94 frame->fr_width, |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
95 frame->fr_height, |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
96 frame->fr_win == NULL ? -1 : frame->fr_win->w_width, |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
97 frame->fr_win == NULL ? -1 : frame->fr_win->w_height, |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
98 frame->fr_win == NULL ? -1 : frame->fr_win->w_id); |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
99 if (frame->fr_child != NULL) |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
100 { |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
101 ch_log(NULL, "children"); |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
102 log_frame_layout(frame->fr_child); |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
103 if (frame->fr_next != NULL) |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
104 ch_log(NULL, "END of children"); |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
105 } |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
106 if (frame->fr_next != NULL) |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
107 log_frame_layout(frame->fr_next); |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
108 } |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
109 #endif |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
110 |
7 | 111 /* |
15933
b2423b31266f
patch 8.1.0972: cannot switch from terminal window to next tabpage
Bram Moolenaar <Bram@vim.org>
parents:
15850
diff
changeset
|
112 * All CTRL-W window commands are handled here, called from normal_cmd(). |
7 | 113 */ |
114 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
115 do_window( |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
116 int nchar, |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
117 long Prenum, |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
118 int xchar) // extra char from ":wincmd gx" or NUL |
7 | 119 { |
120 long Prenum1; | |
121 win_T *wp; | |
122 #if defined(FEAT_SEARCHPATH) || defined(FEAT_FIND_ID) | |
123 char_u *ptr; | |
681 | 124 linenr_T lnum = -1; |
7 | 125 #endif |
126 #ifdef FEAT_FIND_ID | |
127 int type = FIND_DEFINE; | |
128 int len; | |
129 #endif | |
130 char_u cbuf[40]; | |
131 | |
19271
ebeeb4b4a1fa
patch 8.2.0194: some commands can cause problems in terminal popup
Bram Moolenaar <Bram@vim.org>
parents:
19265
diff
changeset
|
132 if (ERROR_IF_ANY_POPUP_WINDOW) |
16874
da5f5836e90c
patch 8.1.1438: some commands cause trouble in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
16863
diff
changeset
|
133 return; |
7 | 134 |
135 #ifdef FEAT_CMDWIN | |
13632
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
136 # define CHECK_CMDWIN \ |
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
137 do { \ |
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
138 if (cmdwin_type != 0) \ |
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
139 { \ |
25064
8f2262c72178
patch 8.2.3069: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
24216
diff
changeset
|
140 emsg(_(e_invalid_in_cmdline_window)); \ |
13632
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
141 return; \ |
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
142 } \ |
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
143 } while (0) |
7 | 144 #else |
13632
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
145 # define CHECK_CMDWIN do { /**/ } while (0) |
7 | 146 #endif |
147 | |
16874
da5f5836e90c
patch 8.1.1438: some commands cause trouble in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
16863
diff
changeset
|
148 Prenum1 = Prenum == 0 ? 1 : Prenum; |
da5f5836e90c
patch 8.1.1438: some commands cause trouble in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
16863
diff
changeset
|
149 |
7 | 150 switch (nchar) |
151 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
152 // split current window in two parts, horizontally |
7 | 153 case 'S': |
154 case Ctrl_S: | |
155 case 's': | |
13632
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
156 CHECK_CMDWIN; |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
157 reset_VIsual_and_resel(); // stop Visual mode |
635 | 158 #ifdef FEAT_QUICKFIX |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
159 // When splitting the quickfix window open a new buffer in it, |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
160 // don't replicate the quickfix buffer. |
635 | 161 if (bt_quickfix(curbuf)) |
162 goto newwindow; | |
163 #endif | |
7 | 164 #ifdef FEAT_GUI |
165 need_mouse_correct = TRUE; | |
166 #endif | |
7009 | 167 (void)win_split((int)Prenum, 0); |
7 | 168 break; |
169 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
170 // split current window in two parts, vertically |
7 | 171 case Ctrl_V: |
172 case 'v': | |
13632
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
173 CHECK_CMDWIN; |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
174 reset_VIsual_and_resel(); // stop Visual mode |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8536
diff
changeset
|
175 #ifdef FEAT_QUICKFIX |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
176 // When splitting the quickfix window open a new buffer in it, |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
177 // don't replicate the quickfix buffer. |
1664 | 178 if (bt_quickfix(curbuf)) |
179 goto newwindow; | |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8536
diff
changeset
|
180 #endif |
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8536
diff
changeset
|
181 #ifdef FEAT_GUI |
7 | 182 need_mouse_correct = TRUE; |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8536
diff
changeset
|
183 #endif |
7009 | 184 (void)win_split((int)Prenum, WSP_VERT); |
7 | 185 break; |
186 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
187 // split current window and edit alternate file |
7 | 188 case Ctrl_HAT: |
189 case '^': | |
13632
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
190 CHECK_CMDWIN; |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
191 reset_VIsual_and_resel(); // stop Visual mode |
15006
1fd8e32532f7
patch 8.1.0514: CTRL-W ^ does not work when alternate buffer has no name
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
192 |
1fd8e32532f7
patch 8.1.0514: CTRL-W ^ does not work when alternate buffer has no name
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
193 if (buflist_findnr(Prenum == 0 |
1fd8e32532f7
patch 8.1.0514: CTRL-W ^ does not work when alternate buffer has no name
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
194 ? curwin->w_alt_fnum : Prenum) == NULL) |
1fd8e32532f7
patch 8.1.0514: CTRL-W ^ does not work when alternate buffer has no name
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
195 { |
1fd8e32532f7
patch 8.1.0514: CTRL-W ^ does not work when alternate buffer has no name
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
196 if (Prenum == 0) |
25064
8f2262c72178
patch 8.2.3069: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
24216
diff
changeset
|
197 emsg(_(e_no_alternate_file)); |
15006
1fd8e32532f7
patch 8.1.0514: CTRL-W ^ does not work when alternate buffer has no name
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
198 else |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15436
diff
changeset
|
199 semsg(_("E92: Buffer %ld not found"), Prenum); |
15006
1fd8e32532f7
patch 8.1.0514: CTRL-W ^ does not work when alternate buffer has no name
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
200 break; |
1fd8e32532f7
patch 8.1.0514: CTRL-W ^ does not work when alternate buffer has no name
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
201 } |
1fd8e32532f7
patch 8.1.0514: CTRL-W ^ does not work when alternate buffer has no name
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
202 |
1fd8e32532f7
patch 8.1.0514: CTRL-W ^ does not work when alternate buffer has no name
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
203 if (!curbuf_locked() && win_split(0, 0) == OK) |
1fd8e32532f7
patch 8.1.0514: CTRL-W ^ does not work when alternate buffer has no name
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
204 (void)buflist_getfile( |
1fd8e32532f7
patch 8.1.0514: CTRL-W ^ does not work when alternate buffer has no name
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
205 Prenum == 0 ? curwin->w_alt_fnum : Prenum, |
1fd8e32532f7
patch 8.1.0514: CTRL-W ^ does not work when alternate buffer has no name
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
206 (linenr_T)0, GETF_ALT, FALSE); |
7 | 207 break; |
208 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
209 // open new window |
7 | 210 case Ctrl_N: |
211 case 'n': | |
13632
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
212 CHECK_CMDWIN; |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
213 reset_VIsual_and_resel(); // stop Visual mode |
635 | 214 #ifdef FEAT_QUICKFIX |
215 newwindow: | |
216 #endif | |
7 | 217 if (Prenum) |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
218 // window height |
1664 | 219 vim_snprintf((char *)cbuf, sizeof(cbuf) - 5, "%ld", Prenum); |
7 | 220 else |
221 cbuf[0] = NUL; | |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8536
diff
changeset
|
222 #if defined(FEAT_QUICKFIX) |
1664 | 223 if (nchar == 'v' || nchar == Ctrl_V) |
224 STRCAT(cbuf, "v"); | |
225 #endif | |
7 | 226 STRCAT(cbuf, "new"); |
227 do_cmdline_cmd(cbuf); | |
228 break; | |
229 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
230 // quit current window |
7 | 231 case Ctrl_Q: |
232 case 'q': | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
233 reset_VIsual_and_resel(); // stop Visual mode |
6432 | 234 cmd_with_count("quit", cbuf, sizeof(cbuf), Prenum); |
6398 | 235 do_cmdline_cmd(cbuf); |
7 | 236 break; |
237 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
238 // close current window |
7 | 239 case Ctrl_C: |
240 case 'c': | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
241 reset_VIsual_and_resel(); // stop Visual mode |
6432 | 242 cmd_with_count("close", cbuf, sizeof(cbuf), Prenum); |
6398 | 243 do_cmdline_cmd(cbuf); |
7 | 244 break; |
245 | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
246 #if defined(FEAT_QUICKFIX) |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
247 // close preview window |
7 | 248 case Ctrl_Z: |
249 case 'z': | |
13632
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
250 CHECK_CMDWIN; |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
251 reset_VIsual_and_resel(); // stop Visual mode |
7 | 252 do_cmdline_cmd((char_u *)"pclose"); |
253 break; | |
254 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
255 // cursor to preview window |
7 | 256 case 'P': |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9599
diff
changeset
|
257 FOR_ALL_WINDOWS(wp) |
7 | 258 if (wp->w_p_pvw) |
259 break; | |
260 if (wp == NULL) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15436
diff
changeset
|
261 emsg(_("E441: There is no preview window")); |
7 | 262 else |
263 win_goto(wp); | |
264 break; | |
265 #endif | |
266 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
267 // close all but current window |
7 | 268 case Ctrl_O: |
269 case 'o': | |
13632
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
270 CHECK_CMDWIN; |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
271 reset_VIsual_and_resel(); // stop Visual mode |
6432 | 272 cmd_with_count("only", cbuf, sizeof(cbuf), Prenum); |
6398 | 273 do_cmdline_cmd(cbuf); |
7 | 274 break; |
275 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
276 // cursor to next window with wrap around |
7 | 277 case Ctrl_W: |
278 case 'w': | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
279 // cursor to previous window with wrap around |
7 | 280 case 'W': |
13632
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
281 CHECK_CMDWIN; |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
282 if (ONE_WINDOW && Prenum != 1) // just one window |
7 | 283 beep_flush(); |
284 else | |
285 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
286 if (Prenum) // go to specified window |
7 | 287 { |
288 for (wp = firstwin; --Prenum > 0; ) | |
289 { | |
290 if (wp->w_next == NULL) | |
291 break; | |
292 else | |
293 wp = wp->w_next; | |
294 } | |
295 } | |
296 else | |
297 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
298 if (nchar == 'W') // go to previous window |
7 | 299 { |
300 wp = curwin->w_prev; | |
301 if (wp == NULL) | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
302 wp = lastwin; // wrap around |
7 | 303 } |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
304 else // go to next window |
7 | 305 { |
306 wp = curwin->w_next; | |
307 if (wp == NULL) | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
308 wp = firstwin; // wrap around |
7 | 309 } |
310 } | |
311 win_goto(wp); | |
312 } | |
313 break; | |
314 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
315 // cursor to window below |
7 | 316 case 'j': |
317 case K_DOWN: | |
318 case Ctrl_J: | |
13632
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
319 CHECK_CMDWIN; |
7 | 320 win_goto_ver(FALSE, Prenum1); |
321 break; | |
322 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
323 // cursor to window above |
7 | 324 case 'k': |
325 case K_UP: | |
326 case Ctrl_K: | |
13632
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
327 CHECK_CMDWIN; |
7 | 328 win_goto_ver(TRUE, Prenum1); |
329 break; | |
330 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
331 // cursor to left window |
7 | 332 case 'h': |
333 case K_LEFT: | |
334 case Ctrl_H: | |
335 case K_BS: | |
13632
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
336 CHECK_CMDWIN; |
7 | 337 win_goto_hor(TRUE, Prenum1); |
338 break; | |
339 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
340 // cursor to right window |
7 | 341 case 'l': |
342 case K_RIGHT: | |
343 case Ctrl_L: | |
13632
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
344 CHECK_CMDWIN; |
7 | 345 win_goto_hor(FALSE, Prenum1); |
346 break; | |
347 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
348 // move window to new tab page |
826 | 349 case 'T': |
20737
0b4a9642b39c
patch 8.2.0921: CTRL-W T in cmdline window causes trouble
Bram Moolenaar <Bram@vim.org>
parents:
20711
diff
changeset
|
350 CHECK_CMDWIN; |
1906 | 351 if (one_window()) |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15490
diff
changeset
|
352 msg(_(m_onlyone)); |
826 | 353 else |
354 { | |
355 tabpage_T *oldtab = curtab; | |
356 tabpage_T *newtab; | |
357 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
358 // First create a new tab with the window, then go back to |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
359 // the old tab and close the window there. |
944 | 360 wp = curwin; |
826 | 361 if (win_new_tabpage((int)Prenum) == OK |
362 && valid_tabpage(oldtab)) | |
363 { | |
364 newtab = curtab; | |
4354 | 365 goto_tabpage_tp(oldtab, TRUE, TRUE); |
826 | 366 if (curwin == wp) |
367 win_close(curwin, FALSE); | |
368 if (valid_tabpage(newtab)) | |
4354 | 369 goto_tabpage_tp(newtab, TRUE, TRUE); |
826 | 370 } |
371 } | |
372 break; | |
373 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
374 // cursor to top-left window |
7 | 375 case 't': |
376 case Ctrl_T: | |
377 win_goto(firstwin); | |
378 break; | |
379 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
380 // cursor to bottom-right window |
7 | 381 case 'b': |
382 case Ctrl_B: | |
383 win_goto(lastwin); | |
384 break; | |
385 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
386 // cursor to last accessed (previous) window |
7 | 387 case 'p': |
388 case Ctrl_P: | |
8833
dc10bd23f918
commit https://github.com/vim/vim/commit/3dda7db4e1f7c4a8110a1f83001ec36b46693d27
Christian Brabandt <cb@256bit.org>
parents:
8804
diff
changeset
|
389 if (!win_valid(prevwin)) |
7 | 390 beep_flush(); |
391 else | |
392 win_goto(prevwin); | |
393 break; | |
394 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
395 // exchange current and next window |
7 | 396 case 'x': |
397 case Ctrl_X: | |
13632
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
398 CHECK_CMDWIN; |
7 | 399 win_exchange(Prenum); |
400 break; | |
401 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
402 // rotate windows downwards |
7 | 403 case Ctrl_R: |
404 case 'r': | |
13632
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
405 CHECK_CMDWIN; |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
406 reset_VIsual_and_resel(); // stop Visual mode |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
407 win_rotate(FALSE, (int)Prenum1); // downwards |
7 | 408 break; |
409 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
410 // rotate windows upwards |
7 | 411 case 'R': |
13632
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
412 CHECK_CMDWIN; |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
413 reset_VIsual_and_resel(); // stop Visual mode |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
414 win_rotate(TRUE, (int)Prenum1); // upwards |
7 | 415 break; |
416 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
417 // move window to the very top/bottom/left/right |
7 | 418 case 'K': |
419 case 'J': | |
420 case 'H': | |
421 case 'L': | |
13632
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
422 CHECK_CMDWIN; |
7 | 423 win_totop((int)Prenum, |
424 ((nchar == 'H' || nchar == 'L') ? WSP_VERT : 0) | |
425 | ((nchar == 'H' || nchar == 'K') ? WSP_TOP : WSP_BOT)); | |
426 break; | |
427 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
428 // make all windows the same height |
7 | 429 case '=': |
430 #ifdef FEAT_GUI | |
431 need_mouse_correct = TRUE; | |
432 #endif | |
433 win_equal(NULL, FALSE, 'b'); | |
434 break; | |
435 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
436 // increase current window height |
7 | 437 case '+': |
438 #ifdef FEAT_GUI | |
439 need_mouse_correct = TRUE; | |
440 #endif | |
441 win_setheight(curwin->w_height + (int)Prenum1); | |
442 break; | |
443 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
444 // decrease current window height |
7 | 445 case '-': |
446 #ifdef FEAT_GUI | |
447 need_mouse_correct = TRUE; | |
448 #endif | |
449 win_setheight(curwin->w_height - (int)Prenum1); | |
450 break; | |
451 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
452 // set current window height |
7 | 453 case Ctrl__: |
454 case '_': | |
455 #ifdef FEAT_GUI | |
456 need_mouse_correct = TRUE; | |
457 #endif | |
458 win_setheight(Prenum ? (int)Prenum : 9999); | |
459 break; | |
460 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
461 // increase current window width |
7 | 462 case '>': |
463 #ifdef FEAT_GUI | |
464 need_mouse_correct = TRUE; | |
465 #endif | |
466 win_setwidth(curwin->w_width + (int)Prenum1); | |
467 break; | |
468 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
469 // decrease current window width |
7 | 470 case '<': |
471 #ifdef FEAT_GUI | |
472 need_mouse_correct = TRUE; | |
473 #endif | |
474 win_setwidth(curwin->w_width - (int)Prenum1); | |
475 break; | |
476 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
477 // set current window width |
7 | 478 case '|': |
479 #ifdef FEAT_GUI | |
480 need_mouse_correct = TRUE; | |
481 #endif | |
482 win_setwidth(Prenum != 0 ? (int)Prenum : 9999); | |
483 break; | |
484 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
485 // jump to tag and split window if tag exists (in preview window) |
7 | 486 #if defined(FEAT_QUICKFIX) |
487 case '}': | |
13632
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
488 CHECK_CMDWIN; |
7 | 489 if (Prenum) |
490 g_do_tagpreview = Prenum; | |
491 else | |
492 g_do_tagpreview = p_pvh; | |
12674
e769c912fcd9
patch 8.0.1215: newer gcc warns for implicit fallthrough
Christian Brabandt <cb@256bit.org>
parents:
12564
diff
changeset
|
493 #endif |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
494 // FALLTHROUGH |
7 | 495 case ']': |
496 case Ctrl_RSB: | |
13632
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
497 CHECK_CMDWIN; |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
498 // keep Visual mode, can select words to use as a tag |
7 | 499 if (Prenum) |
500 postponed_split = Prenum; | |
501 else | |
502 postponed_split = -1; | |
6251 | 503 #ifdef FEAT_QUICKFIX |
6264 | 504 if (nchar != '}') |
505 g_do_tagpreview = 0; | |
6251 | 506 #endif |
6239 | 507 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
508 // Execute the command right here, required when "wincmd ]" |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
509 // was used in a function. |
7 | 510 do_nv_ident(Ctrl_RSB, NUL); |
511 break; | |
512 | |
513 #ifdef FEAT_SEARCHPATH | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
514 // edit file name under cursor in a new window |
7 | 515 case 'f': |
681 | 516 case 'F': |
7 | 517 case Ctrl_F: |
820 | 518 wingotofile: |
13632
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
519 CHECK_CMDWIN; |
344 | 520 |
681 | 521 ptr = grab_file_name(Prenum1, &lnum); |
7 | 522 if (ptr != NULL) |
523 { | |
9349
b24900b73f90
commit https://github.com/vim/vim/commit/5d2ca0402954ff79b73d9c86cc16c8a6454b75a7
Christian Brabandt <cb@256bit.org>
parents:
9223
diff
changeset
|
524 tabpage_T *oldtab = curtab; |
b24900b73f90
commit https://github.com/vim/vim/commit/5d2ca0402954ff79b73d9c86cc16c8a6454b75a7
Christian Brabandt <cb@256bit.org>
parents:
9223
diff
changeset
|
525 win_T *oldwin = curwin; |
820 | 526 # ifdef FEAT_GUI |
7 | 527 need_mouse_correct = TRUE; |
820 | 528 # endif |
7 | 529 setpcmark(); |
530 if (win_split(0, 0) == OK) | |
531 { | |
2583 | 532 RESET_BINDING(curwin); |
9349
b24900b73f90
commit https://github.com/vim/vim/commit/5d2ca0402954ff79b73d9c86cc16c8a6454b75a7
Christian Brabandt <cb@256bit.org>
parents:
9223
diff
changeset
|
533 if (do_ecmd(0, ptr, NULL, NULL, ECMD_LASTL, |
b24900b73f90
commit https://github.com/vim/vim/commit/5d2ca0402954ff79b73d9c86cc16c8a6454b75a7
Christian Brabandt <cb@256bit.org>
parents:
9223
diff
changeset
|
534 ECMD_HIDE, NULL) == FAIL) |
b24900b73f90
commit https://github.com/vim/vim/commit/5d2ca0402954ff79b73d9c86cc16c8a6454b75a7
Christian Brabandt <cb@256bit.org>
parents:
9223
diff
changeset
|
535 { |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
536 // Failed to open the file, close the window |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
537 // opened for it. |
9349
b24900b73f90
commit https://github.com/vim/vim/commit/5d2ca0402954ff79b73d9c86cc16c8a6454b75a7
Christian Brabandt <cb@256bit.org>
parents:
9223
diff
changeset
|
538 win_close(curwin, FALSE); |
b24900b73f90
commit https://github.com/vim/vim/commit/5d2ca0402954ff79b73d9c86cc16c8a6454b75a7
Christian Brabandt <cb@256bit.org>
parents:
9223
diff
changeset
|
539 goto_tabpage_win(oldtab, oldwin); |
b24900b73f90
commit https://github.com/vim/vim/commit/5d2ca0402954ff79b73d9c86cc16c8a6454b75a7
Christian Brabandt <cb@256bit.org>
parents:
9223
diff
changeset
|
540 } |
b24900b73f90
commit https://github.com/vim/vim/commit/5d2ca0402954ff79b73d9c86cc16c8a6454b75a7
Christian Brabandt <cb@256bit.org>
parents:
9223
diff
changeset
|
541 else if (nchar == 'F' && lnum >= 0) |
681 | 542 { |
543 curwin->w_cursor.lnum = lnum; | |
544 check_cursor_lnum(); | |
545 beginline(BL_SOL | BL_FIX); | |
546 } | |
7 | 547 } |
548 vim_free(ptr); | |
549 } | |
550 break; | |
551 #endif | |
552 | |
553 #ifdef FEAT_FIND_ID | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
554 // Go to the first occurrence of the identifier under cursor along path in a |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
555 // new window -- webb |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
556 case 'i': // Go to any match |
7 | 557 case Ctrl_I: |
558 type = FIND_ANY; | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
559 // FALLTHROUGH |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
560 case 'd': // Go to definition, using 'define' |
7 | 561 case Ctrl_D: |
13632
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
562 CHECK_CMDWIN; |
7 | 563 if ((len = find_ident_under_cursor(&ptr, FIND_IDENT)) == 0) |
564 break; | |
565 find_pattern_in_path(ptr, 0, len, TRUE, | |
566 Prenum == 0 ? TRUE : FALSE, type, | |
567 Prenum1, ACTION_SPLIT, (linenr_T)1, (linenr_T)MAXLNUM); | |
568 curwin->w_set_curswant = TRUE; | |
569 break; | |
570 #endif | |
571 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
572 // Quickfix window only: view the result under the cursor in a new split. |
14397
19d99d9e670c
patch 8.1.0213: CTRL-W CR does not work properly in a quickfix window
Christian Brabandt <cb@256bit.org>
parents:
14093
diff
changeset
|
573 #if defined(FEAT_QUICKFIX) |
170 | 574 case K_KENTER: |
575 case CAR: | |
576 if (bt_quickfix(curbuf)) | |
14397
19d99d9e670c
patch 8.1.0213: CTRL-W CR does not work properly in a quickfix window
Christian Brabandt <cb@256bit.org>
parents:
14093
diff
changeset
|
577 qf_view_result(TRUE); |
19d99d9e670c
patch 8.1.0213: CTRL-W CR does not work properly in a quickfix window
Christian Brabandt <cb@256bit.org>
parents:
14093
diff
changeset
|
578 break; |
170 | 579 #endif |
580 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
581 // CTRL-W g extended commands |
7 | 582 case 'g': |
583 case Ctrl_G: | |
13632
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
584 CHECK_CMDWIN; |
7 | 585 #ifdef USE_ON_FLY_SCROLL |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
586 dont_scroll = TRUE; // disallow scrolling here |
7 | 587 #endif |
588 ++no_mapping; | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
589 ++allow_keys; // no mapping for xchar, but allow key codes |
7 | 590 if (xchar == NUL) |
1389 | 591 xchar = plain_vgetc(); |
7 | 592 LANGMAP_ADJUST(xchar, TRUE); |
593 --no_mapping; | |
594 --allow_keys; | |
595 #ifdef FEAT_CMDL_INFO | |
596 (void)add_to_showcmd(xchar); | |
597 #endif | |
598 switch (xchar) | |
599 { | |
600 #if defined(FEAT_QUICKFIX) | |
601 case '}': | |
602 xchar = Ctrl_RSB; | |
603 if (Prenum) | |
604 g_do_tagpreview = Prenum; | |
605 else | |
606 g_do_tagpreview = p_pvh; | |
12674
e769c912fcd9
patch 8.0.1215: newer gcc warns for implicit fallthrough
Christian Brabandt <cb@256bit.org>
parents:
12564
diff
changeset
|
607 #endif |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
608 // FALLTHROUGH |
7 | 609 case ']': |
610 case Ctrl_RSB: | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
611 // keep Visual mode, can select words to use as a tag |
7 | 612 if (Prenum) |
613 postponed_split = Prenum; | |
614 else | |
615 postponed_split = -1; | |
616 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
617 // Execute the command right here, required when |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
618 // "wincmd g}" was used in a function. |
7 | 619 do_nv_ident('g', xchar); |
620 break; | |
621 | |
820 | 622 #ifdef FEAT_SEARCHPATH |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
623 case 'f': // CTRL-W gf: "gf" in a new tab page |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
624 case 'F': // CTRL-W gF: "gF" in a new tab page |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22470
diff
changeset
|
625 cmdmod.cmod_tab = tabpage_index(curtab) + 1; |
839 | 626 nchar = xchar; |
820 | 627 goto wingotofile; |
628 #endif | |
15933
b2423b31266f
patch 8.1.0972: cannot switch from terminal window to next tabpage
Bram Moolenaar <Bram@vim.org>
parents:
15850
diff
changeset
|
629 case 't': // CTRL-W gt: go to next tab page |
b2423b31266f
patch 8.1.0972: cannot switch from terminal window to next tabpage
Bram Moolenaar <Bram@vim.org>
parents:
15850
diff
changeset
|
630 goto_tabpage((int)Prenum); |
b2423b31266f
patch 8.1.0972: cannot switch from terminal window to next tabpage
Bram Moolenaar <Bram@vim.org>
parents:
15850
diff
changeset
|
631 break; |
b2423b31266f
patch 8.1.0972: cannot switch from terminal window to next tabpage
Bram Moolenaar <Bram@vim.org>
parents:
15850
diff
changeset
|
632 |
15937
c38fb03a6055
patch 8.1.0974: cannot switch from terminal window to previous tabpage
Bram Moolenaar <Bram@vim.org>
parents:
15933
diff
changeset
|
633 case 'T': // CTRL-W gT: go to previous tab page |
c38fb03a6055
patch 8.1.0974: cannot switch from terminal window to previous tabpage
Bram Moolenaar <Bram@vim.org>
parents:
15933
diff
changeset
|
634 goto_tabpage(-(int)Prenum1); |
c38fb03a6055
patch 8.1.0974: cannot switch from terminal window to previous tabpage
Bram Moolenaar <Bram@vim.org>
parents:
15933
diff
changeset
|
635 break; |
c38fb03a6055
patch 8.1.0974: cannot switch from terminal window to previous tabpage
Bram Moolenaar <Bram@vim.org>
parents:
15933
diff
changeset
|
636 |
21703
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21020
diff
changeset
|
637 case TAB: // CTRL-W g<Tab>: go to last used tab page |
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21020
diff
changeset
|
638 if (goto_tabpage_lastused() == FAIL) |
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21020
diff
changeset
|
639 beep_flush(); |
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21020
diff
changeset
|
640 break; |
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21020
diff
changeset
|
641 |
7 | 642 default: |
643 beep_flush(); | |
644 break; | |
645 } | |
646 break; | |
647 | |
648 default: beep_flush(); | |
649 break; | |
650 } | |
651 } | |
652 | |
6489 | 653 /* |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16447
diff
changeset
|
654 * Figure out the address type for ":wincmd". |
6489 | 655 */ |
656 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
657 get_wincmd_addr_type(char_u *arg, exarg_T *eap) |
6489 | 658 { |
659 switch (*arg) | |
660 { | |
661 case 'S': | |
662 case Ctrl_S: | |
663 case 's': | |
664 case Ctrl_N: | |
665 case 'n': | |
666 case 'j': | |
667 case Ctrl_J: | |
668 case 'k': | |
669 case Ctrl_K: | |
670 case 'T': | |
671 case Ctrl_R: | |
672 case 'r': | |
673 case 'R': | |
674 case 'K': | |
675 case 'J': | |
676 case '+': | |
677 case '-': | |
678 case Ctrl__: | |
679 case '_': | |
680 case '|': | |
681 case ']': | |
682 case Ctrl_RSB: | |
683 case 'g': | |
684 case Ctrl_G: | |
685 case Ctrl_V: | |
686 case 'v': | |
687 case 'h': | |
688 case Ctrl_H: | |
689 case 'l': | |
690 case Ctrl_L: | |
691 case 'H': | |
692 case 'L': | |
693 case '>': | |
694 case '<': | |
695 #if defined(FEAT_QUICKFIX) | |
696 case '}': | |
697 #endif | |
698 #ifdef FEAT_SEARCHPATH | |
699 case 'f': | |
700 case 'F': | |
701 case Ctrl_F: | |
702 #endif | |
703 #ifdef FEAT_FIND_ID | |
704 case 'i': | |
705 case Ctrl_I: | |
706 case 'd': | |
707 case Ctrl_D: | |
708 #endif | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16447
diff
changeset
|
709 // window size or any count |
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16447
diff
changeset
|
710 eap->addr_type = ADDR_OTHER; |
6489 | 711 break; |
712 | |
713 case Ctrl_HAT: | |
714 case '^': | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16447
diff
changeset
|
715 // buffer number |
6489 | 716 eap->addr_type = ADDR_BUFFERS; |
717 break; | |
718 | |
719 case Ctrl_Q: | |
720 case 'q': | |
721 case Ctrl_C: | |
722 case 'c': | |
723 case Ctrl_O: | |
724 case 'o': | |
725 case Ctrl_W: | |
726 case 'w': | |
727 case 'W': | |
728 case 'x': | |
729 case Ctrl_X: | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16447
diff
changeset
|
730 // window number |
6489 | 731 eap->addr_type = ADDR_WINDOWS; |
732 break; | |
733 | |
734 #if defined(FEAT_QUICKFIX) | |
735 case Ctrl_Z: | |
736 case 'z': | |
737 case 'P': | |
738 #endif | |
739 case 't': | |
740 case Ctrl_T: | |
741 case 'b': | |
742 case Ctrl_B: | |
743 case 'p': | |
744 case Ctrl_P: | |
745 case '=': | |
746 case CAR: | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16447
diff
changeset
|
747 // no count |
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16447
diff
changeset
|
748 eap->addr_type = ADDR_NONE; |
6489 | 749 break; |
750 } | |
751 } | |
752 | |
6432 | 753 static void |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
754 cmd_with_count( |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
755 char *cmd, |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
756 char_u *bufp, |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
757 size_t bufsize, |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
758 long Prenum) |
6432 | 759 { |
760 if (Prenum > 0) | |
24216
77cb22562852
patch 8.2.2649: Vim9: some wincmd arguments cause a white space error
Bram Moolenaar <Bram@vim.org>
parents:
24108
diff
changeset
|
761 vim_snprintf((char *)bufp, bufsize, "%s %ld", cmd, Prenum); |
77cb22562852
patch 8.2.2649: Vim9: some wincmd arguments cause a white space error
Bram Moolenaar <Bram@vim.org>
parents:
24108
diff
changeset
|
762 else |
77cb22562852
patch 8.2.2649: Vim9: some wincmd arguments cause a white space error
Bram Moolenaar <Bram@vim.org>
parents:
24108
diff
changeset
|
763 STRCPY(bufp, cmd); |
6432 | 764 } |
765 | |
7 | 766 /* |
17516
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
767 * If "split_disallowed" is set given an error and return FAIL. |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
768 * Otherwise return OK. |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
769 */ |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
770 static int |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
771 check_split_disallowed() |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
772 { |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
773 if (split_disallowed > 0) |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
774 { |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
775 emsg(_("E242: Can't split a window while closing another")); |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
776 return FAIL; |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
777 } |
23869
5a4f9c5c1b99
patch 8.2.2476: using freed memory when splitting window while closing buffer
Bram Moolenaar <Bram@vim.org>
parents:
23402
diff
changeset
|
778 if (curwin->w_buffer->b_locked_split) |
5a4f9c5c1b99
patch 8.2.2476: using freed memory when splitting window while closing buffer
Bram Moolenaar <Bram@vim.org>
parents:
23402
diff
changeset
|
779 { |
5a4f9c5c1b99
patch 8.2.2476: using freed memory when splitting window while closing buffer
Bram Moolenaar <Bram@vim.org>
parents:
23402
diff
changeset
|
780 emsg(_(e_cannot_split_window_when_closing_buffer)); |
5a4f9c5c1b99
patch 8.2.2476: using freed memory when splitting window while closing buffer
Bram Moolenaar <Bram@vim.org>
parents:
23402
diff
changeset
|
781 return FAIL; |
5a4f9c5c1b99
patch 8.2.2476: using freed memory when splitting window while closing buffer
Bram Moolenaar <Bram@vim.org>
parents:
23402
diff
changeset
|
782 } |
17516
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
783 return OK; |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
784 } |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
785 |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
786 /* |
7 | 787 * split the current window, implements CTRL-W s and :split |
788 * | |
789 * "size" is the height or width for the new window, 0 to use half of current | |
790 * height or width. | |
791 * | |
792 * "flags": | |
793 * WSP_ROOM: require enough room for new window | |
794 * WSP_VERT: vertical split. | |
795 * WSP_TOP: open window at the top-left of the shell (help window). | |
796 * WSP_BOT: open window at the bottom-right of the shell (quickfix window). | |
797 * WSP_HELP: creating the help window, keep layout snapshot | |
798 * | |
799 * return FAIL for failure, OK otherwise | |
800 */ | |
801 int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
802 win_split(int size, int flags) |
7 | 803 { |
19271
ebeeb4b4a1fa
patch 8.2.0194: some commands can cause problems in terminal popup
Bram Moolenaar <Bram@vim.org>
parents:
19265
diff
changeset
|
804 if (ERROR_IF_ANY_POPUP_WINDOW) |
16874
da5f5836e90c
patch 8.1.1438: some commands cause trouble in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
16863
diff
changeset
|
805 return FAIL; |
da5f5836e90c
patch 8.1.1438: some commands cause trouble in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
16863
diff
changeset
|
806 |
23869
5a4f9c5c1b99
patch 8.2.2476: using freed memory when splitting window while closing buffer
Bram Moolenaar <Bram@vim.org>
parents:
23402
diff
changeset
|
807 if (check_split_disallowed() == FAIL) |
5a4f9c5c1b99
patch 8.2.2476: using freed memory when splitting window while closing buffer
Bram Moolenaar <Bram@vim.org>
parents:
23402
diff
changeset
|
808 return FAIL; |
5a4f9c5c1b99
patch 8.2.2476: using freed memory when splitting window while closing buffer
Bram Moolenaar <Bram@vim.org>
parents:
23402
diff
changeset
|
809 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
810 // When the ":tab" modifier was used open a new tab page instead. |
682 | 811 if (may_open_tabpage() == OK) |
812 return OK; | |
813 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
814 // Add flags from ":vertical", ":topleft" and ":botright". |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22470
diff
changeset
|
815 flags |= cmdmod.cmod_split; |
7 | 816 if ((flags & WSP_TOP) && (flags & WSP_BOT)) |
817 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15436
diff
changeset
|
818 emsg(_("E442: Can't split topleft and botright at the same time")); |
7 | 819 return FAIL; |
820 } | |
821 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
822 // When creating the help window make a snapshot of the window layout. |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
823 // Otherwise clear the snapshot, it's now invalid. |
7 | 824 if (flags & WSP_HELP) |
1906 | 825 make_snapshot(SNAP_HELP_IDX); |
7 | 826 else |
1906 | 827 clear_snapshot(curtab, SNAP_HELP_IDX); |
7 | 828 |
829 return win_split_ins(size, flags, NULL, 0); | |
830 } | |
831 | |
832 /* | |
3263 | 833 * When "new_wp" is NULL: split the current window in two. |
834 * When "new_wp" is not NULL: insert this window at the far | |
7 | 835 * top/left/right/bottom. |
836 * return FAIL for failure, OK otherwise | |
837 */ | |
1906 | 838 int |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
839 win_split_ins( |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
840 int size, |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
841 int flags, |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
842 win_T *new_wp, |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
843 int dir) |
7 | 844 { |
3263 | 845 win_T *wp = new_wp; |
7 | 846 win_T *oldwin; |
847 int new_size = size; | |
848 int i; | |
849 int need_status = 0; | |
850 int do_equal = FALSE; | |
851 int needed; | |
852 int available; | |
853 int oldwin_height = 0; | |
854 int layout; | |
6077 | 855 frame_T *frp, *curfrp, *frp2, *prevfrp; |
7 | 856 int before; |
6052 | 857 int minheight; |
6066 | 858 int wmh1; |
13670
3085d67d24c8
patch 8.0.1707: when 'wfh' is set ":bel 10new" scrolls window
Christian Brabandt <cb@256bit.org>
parents:
13632
diff
changeset
|
859 int did_set_fraction = FALSE; |
7 | 860 |
861 if (flags & WSP_TOP) | |
862 oldwin = firstwin; | |
863 else if (flags & WSP_BOT) | |
864 oldwin = lastwin; | |
865 else | |
866 oldwin = curwin; | |
867 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
868 // add a status line when p_ls == 1 and splitting the first window |
10357
59d01e335858
commit https://github.com/vim/vim/commit/459ca563128f2edb7e3bb190090bbb755a56dd55
Christian Brabandt <cb@256bit.org>
parents:
10349
diff
changeset
|
869 if (ONE_WINDOW && p_ls == 1 && oldwin->w_status_height == 0) |
7 | 870 { |
12998
dd734ee3e2fe
patch 8.0.1375: window size wrong after maximizing with WinBar
Christian Brabandt <cb@256bit.org>
parents:
12916
diff
changeset
|
871 if (VISIBLE_HEIGHT(oldwin) <= p_wmh && new_wp == NULL) |
7 | 872 { |
25306
078edc1821bf
patch 8.2.3190: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
25157
diff
changeset
|
873 emsg(_(e_not_enough_room)); |
7 | 874 return FAIL; |
875 } | |
876 need_status = STATUS_HEIGHT; | |
877 } | |
878 | |
1114 | 879 #ifdef FEAT_GUI |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
880 // May be needed for the scrollbars that are going to change. |
1114 | 881 if (gui.in_use) |
882 out_flush(); | |
883 #endif | |
884 | |
7 | 885 if (flags & WSP_VERT) |
886 { | |
6068 | 887 int wmw1; |
888 int minwidth; | |
889 | |
7 | 890 layout = FR_ROW; |
891 | |
892 /* | |
893 * Check if we are able to split the current window and compute its | |
894 * width. | |
895 */ | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
896 // Current window requires at least 1 space. |
6066 | 897 wmw1 = (p_wmw == 0 ? 1 : p_wmw); |
898 needed = wmw1 + 1; | |
7 | 899 if (flags & WSP_ROOM) |
6066 | 900 needed += p_wiw - wmw1; |
6077 | 901 if (flags & (WSP_BOT | WSP_TOP)) |
7 | 902 { |
6066 | 903 minwidth = frame_minwidth(topframe, NOWIN); |
7 | 904 available = topframe->fr_width; |
6052 | 905 needed += minwidth; |
7 | 906 } |
6077 | 907 else if (p_ea) |
908 { | |
909 minwidth = frame_minwidth(oldwin->w_frame, NOWIN); | |
910 prevfrp = oldwin->w_frame; | |
911 for (frp = oldwin->w_frame->fr_parent; frp != NULL; | |
912 frp = frp->fr_parent) | |
913 { | |
914 if (frp->fr_layout == FR_ROW) | |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
915 FOR_ALL_FRAMES(frp2, frp->fr_child) |
6077 | 916 if (frp2 != prevfrp) |
917 minwidth += frame_minwidth(frp2, NOWIN); | |
918 prevfrp = frp; | |
919 } | |
920 available = topframe->fr_width; | |
921 needed += minwidth; | |
922 } | |
7 | 923 else |
6052 | 924 { |
6066 | 925 minwidth = frame_minwidth(oldwin->w_frame, NOWIN); |
926 available = oldwin->w_frame->fr_width; | |
927 needed += minwidth; | |
6052 | 928 } |
3263 | 929 if (available < needed && new_wp == NULL) |
7 | 930 { |
25306
078edc1821bf
patch 8.2.3190: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
25157
diff
changeset
|
931 emsg(_(e_not_enough_room)); |
7 | 932 return FAIL; |
933 } | |
934 if (new_size == 0) | |
935 new_size = oldwin->w_width / 2; | |
6052 | 936 if (new_size > available - minwidth - 1) |
937 new_size = available - minwidth - 1; | |
6066 | 938 if (new_size < wmw1) |
939 new_size = wmw1; | |
7 | 940 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
941 // if it doesn't fit in the current window, need win_equal() |
7 | 942 if (oldwin->w_width - new_size - 1 < p_wmw) |
943 do_equal = TRUE; | |
779 | 944 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
945 // We don't like to take lines for the new window from a |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
946 // 'winfixwidth' window. Take them from a window to the left or right |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
947 // instead, if possible. Add one for the separator. |
779 | 948 if (oldwin->w_p_wfw) |
11207
e6140f3d2be7
patch 8.0.0490: vertical split makes 'winfixwidth' window smaller
Christian Brabandt <cb@256bit.org>
parents:
11199
diff
changeset
|
949 win_setwidth_win(oldwin->w_width + new_size + 1, oldwin); |
1354 | 950 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
951 // Only make all windows the same width if one of them (except oldwin) |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
952 // is wider than one of the split windows. |
1354 | 953 if (!do_equal && p_ea && size == 0 && *p_ead != 'v' |
17516
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
954 && oldwin->w_frame->fr_parent != NULL) |
1354 | 955 { |
956 frp = oldwin->w_frame->fr_parent->fr_child; | |
957 while (frp != NULL) | |
958 { | |
959 if (frp->fr_win != oldwin && frp->fr_win != NULL | |
960 && (frp->fr_win->w_width > new_size | |
961 || frp->fr_win->w_width > oldwin->w_width | |
6373 | 962 - new_size - 1)) |
1354 | 963 { |
964 do_equal = TRUE; | |
965 break; | |
966 } | |
967 frp = frp->fr_next; | |
968 } | |
969 } | |
7 | 970 } |
971 else | |
972 { | |
973 layout = FR_COL; | |
974 | |
975 /* | |
976 * Check if we are able to split the current window and compute its | |
977 * height. | |
978 */ | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
979 // Current window requires at least 1 space. |
12998
dd734ee3e2fe
patch 8.0.1375: window size wrong after maximizing with WinBar
Christian Brabandt <cb@256bit.org>
parents:
12916
diff
changeset
|
980 wmh1 = (p_wmh == 0 ? 1 : p_wmh) + WINBAR_HEIGHT(curwin); |
6066 | 981 needed = wmh1 + STATUS_HEIGHT; |
7 | 982 if (flags & WSP_ROOM) |
6066 | 983 needed += p_wh - wmh1; |
6077 | 984 if (flags & (WSP_BOT | WSP_TOP)) |
7 | 985 { |
6066 | 986 minheight = frame_minheight(topframe, NOWIN) + need_status; |
7 | 987 available = topframe->fr_height; |
6052 | 988 needed += minheight; |
7 | 989 } |
6077 | 990 else if (p_ea) |
991 { | |
992 minheight = frame_minheight(oldwin->w_frame, NOWIN) + need_status; | |
993 prevfrp = oldwin->w_frame; | |
994 for (frp = oldwin->w_frame->fr_parent; frp != NULL; | |
995 frp = frp->fr_parent) | |
996 { | |
997 if (frp->fr_layout == FR_COL) | |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
998 FOR_ALL_FRAMES(frp2, frp->fr_child) |
6077 | 999 if (frp2 != prevfrp) |
1000 minheight += frame_minheight(frp2, NOWIN); | |
1001 prevfrp = frp; | |
1002 } | |
1003 available = topframe->fr_height; | |
1004 needed += minheight; | |
1005 } | |
7 | 1006 else |
1007 { | |
6066 | 1008 minheight = frame_minheight(oldwin->w_frame, NOWIN) + need_status; |
1009 available = oldwin->w_frame->fr_height; | |
1010 needed += minheight; | |
7 | 1011 } |
3263 | 1012 if (available < needed && new_wp == NULL) |
7 | 1013 { |
25306
078edc1821bf
patch 8.2.3190: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
25157
diff
changeset
|
1014 emsg(_(e_not_enough_room)); |
7 | 1015 return FAIL; |
1016 } | |
1017 oldwin_height = oldwin->w_height; | |
1018 if (need_status) | |
1019 { | |
1020 oldwin->w_status_height = STATUS_HEIGHT; | |
1021 oldwin_height -= STATUS_HEIGHT; | |
1022 } | |
1023 if (new_size == 0) | |
1024 new_size = oldwin_height / 2; | |
6052 | 1025 if (new_size > available - minheight - STATUS_HEIGHT) |
1026 new_size = available - minheight - STATUS_HEIGHT; | |
6066 | 1027 if (new_size < wmh1) |
1028 new_size = wmh1; | |
7 | 1029 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1030 // if it doesn't fit in the current window, need win_equal() |
7 | 1031 if (oldwin_height - new_size - STATUS_HEIGHT < p_wmh) |
1032 do_equal = TRUE; | |
1033 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1034 // We don't like to take lines for the new window from a |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1035 // 'winfixheight' window. Take them from a window above or below |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1036 // instead, if possible. |
7 | 1037 if (oldwin->w_p_wfh) |
1038 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1039 // Set w_fraction now so that the cursor keeps the same relative |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1040 // vertical position using the old height. |
13670
3085d67d24c8
patch 8.0.1707: when 'wfh' is set ":bel 10new" scrolls window
Christian Brabandt <cb@256bit.org>
parents:
13632
diff
changeset
|
1041 set_fraction(oldwin); |
3085d67d24c8
patch 8.0.1707: when 'wfh' is set ":bel 10new" scrolls window
Christian Brabandt <cb@256bit.org>
parents:
13632
diff
changeset
|
1042 did_set_fraction = TRUE; |
3085d67d24c8
patch 8.0.1707: when 'wfh' is set ":bel 10new" scrolls window
Christian Brabandt <cb@256bit.org>
parents:
13632
diff
changeset
|
1043 |
7 | 1044 win_setheight_win(oldwin->w_height + new_size + STATUS_HEIGHT, |
1045 oldwin); | |
1046 oldwin_height = oldwin->w_height; | |
1047 if (need_status) | |
1048 oldwin_height -= STATUS_HEIGHT; | |
1049 } | |
1354 | 1050 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1051 // Only make all windows the same height if one of them (except oldwin) |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1052 // is higher than one of the split windows. |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8536
diff
changeset
|
1053 if (!do_equal && p_ea && size == 0 && *p_ead != 'h' |
1354 | 1054 && oldwin->w_frame->fr_parent != NULL) |
1055 { | |
1056 frp = oldwin->w_frame->fr_parent->fr_child; | |
1057 while (frp != NULL) | |
1058 { | |
1059 if (frp->fr_win != oldwin && frp->fr_win != NULL | |
1060 && (frp->fr_win->w_height > new_size | |
1061 || frp->fr_win->w_height > oldwin_height - new_size | |
1062 - STATUS_HEIGHT)) | |
1063 { | |
1064 do_equal = TRUE; | |
1065 break; | |
1066 } | |
1067 frp = frp->fr_next; | |
1068 } | |
1069 } | |
7 | 1070 } |
1071 | |
1072 /* | |
1073 * allocate new window structure and link it in the window list | |
1074 */ | |
1075 if ((flags & WSP_TOP) == 0 | |
1076 && ((flags & WSP_BOT) | |
1077 || (flags & WSP_BELOW) | |
1078 || (!(flags & WSP_ABOVE) | |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8536
diff
changeset
|
1079 && ( (flags & WSP_VERT) ? p_spr : p_sb)))) |
7 | 1080 { |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1081 // new window below/right of current one |
3263 | 1082 if (new_wp == NULL) |
1906 | 1083 wp = win_alloc(oldwin, FALSE); |
7 | 1084 else |
1085 win_append(oldwin, wp); | |
1086 } | |
1087 else | |
1088 { | |
3263 | 1089 if (new_wp == NULL) |
1906 | 1090 wp = win_alloc(oldwin->w_prev, FALSE); |
7 | 1091 else |
1092 win_append(oldwin->w_prev, wp); | |
1093 } | |
1094 | |
3263 | 1095 if (new_wp == NULL) |
7 | 1096 { |
1097 if (wp == NULL) | |
1098 return FAIL; | |
1099 | |
1906 | 1100 new_frame(wp); |
1101 if (wp->w_frame == NULL) | |
1102 { | |
1103 win_free(wp, NULL); | |
1104 return FAIL; | |
1105 } | |
1106 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1107 // make the contents of the new window the same as the current one |
1822 | 1108 win_init(wp, curwin, flags); |
7 | 1109 } |
1110 | |
1111 /* | |
1112 * Reorganise the tree of frames to insert the new window. | |
1113 */ | |
1114 if (flags & (WSP_TOP | WSP_BOT)) | |
1115 { | |
1116 if ((topframe->fr_layout == FR_COL && (flags & WSP_VERT) == 0) | |
1117 || (topframe->fr_layout == FR_ROW && (flags & WSP_VERT) != 0)) | |
1118 { | |
1119 curfrp = topframe->fr_child; | |
1120 if (flags & WSP_BOT) | |
1121 while (curfrp->fr_next != NULL) | |
1122 curfrp = curfrp->fr_next; | |
1123 } | |
1124 else | |
1125 curfrp = topframe; | |
1126 before = (flags & WSP_TOP); | |
1127 } | |
1128 else | |
1129 { | |
1130 curfrp = oldwin->w_frame; | |
1131 if (flags & WSP_BELOW) | |
1132 before = FALSE; | |
1133 else if (flags & WSP_ABOVE) | |
1134 before = TRUE; | |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8536
diff
changeset
|
1135 else if (flags & WSP_VERT) |
7 | 1136 before = !p_spr; |
1137 else | |
1138 before = !p_sb; | |
1139 } | |
1140 if (curfrp->fr_parent == NULL || curfrp->fr_parent->fr_layout != layout) | |
1141 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1142 // Need to create a new frame in the tree to make a branch. |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16802
diff
changeset
|
1143 frp = ALLOC_CLEAR_ONE(frame_T); |
7 | 1144 *frp = *curfrp; |
1145 curfrp->fr_layout = layout; | |
1146 frp->fr_parent = curfrp; | |
1147 frp->fr_next = NULL; | |
1148 frp->fr_prev = NULL; | |
1149 curfrp->fr_child = frp; | |
1150 curfrp->fr_win = NULL; | |
1151 curfrp = frp; | |
1152 if (frp->fr_win != NULL) | |
1153 oldwin->w_frame = frp; | |
1154 else | |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
1155 FOR_ALL_FRAMES(frp, frp->fr_child) |
7 | 1156 frp->fr_parent = curfrp; |
1157 } | |
1158 | |
3263 | 1159 if (new_wp == NULL) |
1906 | 1160 frp = wp->w_frame; |
7 | 1161 else |
3263 | 1162 frp = new_wp->w_frame; |
7 | 1163 frp->fr_parent = curfrp->fr_parent; |
1164 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1165 // Insert the new frame at the right place in the frame list. |
7 | 1166 if (before) |
1167 frame_insert(curfrp, frp); | |
1168 else | |
1169 frame_append(curfrp, frp); | |
1170 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1171 // Set w_fraction now so that the cursor keeps the same relative |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1172 // vertical position. |
13670
3085d67d24c8
patch 8.0.1707: when 'wfh' is set ":bel 10new" scrolls window
Christian Brabandt <cb@256bit.org>
parents:
13632
diff
changeset
|
1173 if (!did_set_fraction) |
3085d67d24c8
patch 8.0.1707: when 'wfh' is set ":bel 10new" scrolls window
Christian Brabandt <cb@256bit.org>
parents:
13632
diff
changeset
|
1174 set_fraction(oldwin); |
2665 | 1175 wp->w_fraction = oldwin->w_fraction; |
1176 | |
7 | 1177 if (flags & WSP_VERT) |
1178 { | |
1179 wp->w_p_scr = curwin->w_p_scr; | |
2665 | 1180 |
7 | 1181 if (need_status) |
1182 { | |
2115
5fd44cf99b6d
updated for version 7.2.398
Bram Moolenaar <bram@zimbu.org>
parents:
2064
diff
changeset
|
1183 win_new_height(oldwin, oldwin->w_height - 1); |
7 | 1184 oldwin->w_status_height = need_status; |
1185 } | |
1186 if (flags & (WSP_TOP | WSP_BOT)) | |
1187 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1188 // set height and row of new window to full height |
685 | 1189 wp->w_winrow = tabline_height(); |
12491
7ab796b041bd
patch 8.0.1125: wrong window height when splitting window with window toolbar
Christian Brabandt <cb@256bit.org>
parents:
12487
diff
changeset
|
1190 win_new_height(wp, curfrp->fr_height - (p_ls > 0) |
12916
af2e0401eb8c
patch 8.0.1334: splitting a window with a WinBar damages window layout
Christian Brabandt <cb@256bit.org>
parents:
12910
diff
changeset
|
1191 - WINBAR_HEIGHT(wp)); |
7 | 1192 wp->w_status_height = (p_ls > 0); |
1193 } | |
1194 else | |
1195 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1196 // height and row of new window is same as current window |
7 | 1197 wp->w_winrow = oldwin->w_winrow; |
12998
dd734ee3e2fe
patch 8.0.1375: window size wrong after maximizing with WinBar
Christian Brabandt <cb@256bit.org>
parents:
12916
diff
changeset
|
1198 win_new_height(wp, VISIBLE_HEIGHT(oldwin)); |
7 | 1199 wp->w_status_height = oldwin->w_status_height; |
1200 } | |
1201 frp->fr_height = curfrp->fr_height; | |
1202 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1203 // "new_size" of the current window goes to the new window, use |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1204 // one column for the vertical separator |
2115
5fd44cf99b6d
updated for version 7.2.398
Bram Moolenaar <bram@zimbu.org>
parents:
2064
diff
changeset
|
1205 win_new_width(wp, new_size); |
7 | 1206 if (before) |
1207 wp->w_vsep_width = 1; | |
1208 else | |
1209 { | |
1210 wp->w_vsep_width = oldwin->w_vsep_width; | |
1211 oldwin->w_vsep_width = 1; | |
1212 } | |
1213 if (flags & (WSP_TOP | WSP_BOT)) | |
1214 { | |
1215 if (flags & WSP_BOT) | |
1216 frame_add_vsep(curfrp); | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1217 // Set width of neighbor frame |
7 | 1218 frame_new_width(curfrp, curfrp->fr_width |
779 | 1219 - (new_size + ((flags & WSP_TOP) != 0)), flags & WSP_TOP, |
1220 FALSE); | |
7 | 1221 } |
1222 else | |
779 | 1223 win_new_width(oldwin, oldwin->w_width - (new_size + 1)); |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1224 if (before) // new window left of current one |
7 | 1225 { |
1226 wp->w_wincol = oldwin->w_wincol; | |
1227 oldwin->w_wincol += new_size + 1; | |
1228 } | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1229 else // new window right of current one |
7 | 1230 wp->w_wincol = oldwin->w_wincol + oldwin->w_width + 1; |
1231 frame_fix_width(oldwin); | |
1232 frame_fix_width(wp); | |
1233 } | |
1234 else | |
1235 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1236 // width and column of new window is same as current window |
7 | 1237 if (flags & (WSP_TOP | WSP_BOT)) |
1238 { | |
1239 wp->w_wincol = 0; | |
2115
5fd44cf99b6d
updated for version 7.2.398
Bram Moolenaar <bram@zimbu.org>
parents:
2064
diff
changeset
|
1240 win_new_width(wp, Columns); |
7 | 1241 wp->w_vsep_width = 0; |
1242 } | |
1243 else | |
1244 { | |
1245 wp->w_wincol = oldwin->w_wincol; | |
2115
5fd44cf99b6d
updated for version 7.2.398
Bram Moolenaar <bram@zimbu.org>
parents:
2064
diff
changeset
|
1246 win_new_width(wp, oldwin->w_width); |
7 | 1247 wp->w_vsep_width = oldwin->w_vsep_width; |
1248 } | |
1249 frp->fr_width = curfrp->fr_width; | |
1250 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1251 // "new_size" of the current window goes to the new window, use |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1252 // one row for the status line |
7 | 1253 win_new_height(wp, new_size); |
1254 if (flags & (WSP_TOP | WSP_BOT)) | |
9102
0e90f3e13d88
commit https://github.com/vim/vim/commit/991dea3ab185fb35e577ab0bdfd443cd4b43ccc6
Christian Brabandt <cb@256bit.org>
parents:
8833
diff
changeset
|
1255 { |
12491
7ab796b041bd
patch 8.0.1125: wrong window height when splitting window with window toolbar
Christian Brabandt <cb@256bit.org>
parents:
12487
diff
changeset
|
1256 int new_fr_height = curfrp->fr_height - new_size |
12916
af2e0401eb8c
patch 8.0.1334: splitting a window with a WinBar damages window layout
Christian Brabandt <cb@256bit.org>
parents:
12910
diff
changeset
|
1257 + WINBAR_HEIGHT(wp) ; |
9102
0e90f3e13d88
commit https://github.com/vim/vim/commit/991dea3ab185fb35e577ab0bdfd443cd4b43ccc6
Christian Brabandt <cb@256bit.org>
parents:
8833
diff
changeset
|
1258 |
0e90f3e13d88
commit https://github.com/vim/vim/commit/991dea3ab185fb35e577ab0bdfd443cd4b43ccc6
Christian Brabandt <cb@256bit.org>
parents:
8833
diff
changeset
|
1259 if (!((flags & WSP_BOT) && p_ls == 0)) |
0e90f3e13d88
commit https://github.com/vim/vim/commit/991dea3ab185fb35e577ab0bdfd443cd4b43ccc6
Christian Brabandt <cb@256bit.org>
parents:
8833
diff
changeset
|
1260 new_fr_height -= STATUS_HEIGHT; |
0e90f3e13d88
commit https://github.com/vim/vim/commit/991dea3ab185fb35e577ab0bdfd443cd4b43ccc6
Christian Brabandt <cb@256bit.org>
parents:
8833
diff
changeset
|
1261 frame_new_height(curfrp, new_fr_height, flags & WSP_TOP, FALSE); |
0e90f3e13d88
commit https://github.com/vim/vim/commit/991dea3ab185fb35e577ab0bdfd443cd4b43ccc6
Christian Brabandt <cb@256bit.org>
parents:
8833
diff
changeset
|
1262 } |
7 | 1263 else |
1264 win_new_height(oldwin, oldwin_height - (new_size + STATUS_HEIGHT)); | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1265 if (before) // new window above current one |
7 | 1266 { |
1267 wp->w_winrow = oldwin->w_winrow; | |
1268 wp->w_status_height = STATUS_HEIGHT; | |
1269 oldwin->w_winrow += wp->w_height + STATUS_HEIGHT; | |
1270 } | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1271 else // new window below current one |
7 | 1272 { |
12998
dd734ee3e2fe
patch 8.0.1375: window size wrong after maximizing with WinBar
Christian Brabandt <cb@256bit.org>
parents:
12916
diff
changeset
|
1273 wp->w_winrow = oldwin->w_winrow + VISIBLE_HEIGHT(oldwin) |
dd734ee3e2fe
patch 8.0.1375: window size wrong after maximizing with WinBar
Christian Brabandt <cb@256bit.org>
parents:
12916
diff
changeset
|
1274 + STATUS_HEIGHT; |
7 | 1275 wp->w_status_height = oldwin->w_status_height; |
9102
0e90f3e13d88
commit https://github.com/vim/vim/commit/991dea3ab185fb35e577ab0bdfd443cd4b43ccc6
Christian Brabandt <cb@256bit.org>
parents:
8833
diff
changeset
|
1276 if (!(flags & WSP_BOT)) |
0e90f3e13d88
commit https://github.com/vim/vim/commit/991dea3ab185fb35e577ab0bdfd443cd4b43ccc6
Christian Brabandt <cb@256bit.org>
parents:
8833
diff
changeset
|
1277 oldwin->w_status_height = STATUS_HEIGHT; |
7 | 1278 } |
1279 if (flags & WSP_BOT) | |
1280 frame_add_statusline(curfrp); | |
1281 frame_fix_height(wp); | |
1282 frame_fix_height(oldwin); | |
1283 } | |
1284 | |
1285 if (flags & (WSP_TOP | WSP_BOT)) | |
1286 (void)win_comp_pos(); | |
1287 | |
22464
b74bdd85bb26
patch 8.2.1780: statusline not updated when splitting windows
Bram Moolenaar <Bram@vim.org>
parents:
22399
diff
changeset
|
1288 // Both windows need redrawing. Update all status lines, in case they |
b74bdd85bb26
patch 8.2.1780: statusline not updated when splitting windows
Bram Moolenaar <Bram@vim.org>
parents:
22399
diff
changeset
|
1289 // show something related to the window count or position. |
7 | 1290 redraw_win_later(wp, NOT_VALID); |
1291 redraw_win_later(oldwin, NOT_VALID); | |
22464
b74bdd85bb26
patch 8.2.1780: statusline not updated when splitting windows
Bram Moolenaar <Bram@vim.org>
parents:
22399
diff
changeset
|
1292 status_redraw_all(); |
7 | 1293 |
1294 if (need_status) | |
1295 { | |
1296 msg_row = Rows - 1; | |
1297 msg_col = sc_col; | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1298 msg_clr_eos_force(); // Old command/ruler may still be there |
7 | 1299 comp_col(); |
1300 msg_row = Rows - 1; | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1301 msg_col = 0; // put position back at start of line |
7 | 1302 } |
1303 | |
1304 /* | |
2115
5fd44cf99b6d
updated for version 7.2.398
Bram Moolenaar <bram@zimbu.org>
parents:
2064
diff
changeset
|
1305 * equalize the window sizes. |
7 | 1306 */ |
1307 if (do_equal || dir != 0) | |
1308 win_equal(wp, TRUE, | |
1309 (flags & WSP_VERT) ? (dir == 'v' ? 'b' : 'h') | |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8536
diff
changeset
|
1310 : dir == 'h' ? 'b' : 'v'); |
7 | 1311 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1312 // Don't change the window height/width to 'winheight' / 'winwidth' if a |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1313 // size was given. |
7 | 1314 if (flags & WSP_VERT) |
1315 { | |
1316 i = p_wiw; | |
1317 if (size != 0) | |
1318 p_wiw = size; | |
1319 | |
1320 # ifdef FEAT_GUI | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1321 // When 'guioptions' includes 'L' or 'R' may have to add scrollbars. |
7 | 1322 if (gui.in_use) |
1323 gui_init_which_components(NULL); | |
1324 # endif | |
1325 } | |
1326 else | |
1327 { | |
1328 i = p_wh; | |
1329 if (size != 0) | |
1330 p_wh = size; | |
1331 } | |
2115
5fd44cf99b6d
updated for version 7.2.398
Bram Moolenaar <bram@zimbu.org>
parents:
2064
diff
changeset
|
1332 |
6096 | 1333 #ifdef FEAT_JUMPLIST |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1334 // Keep same changelist position in new window. |
6096 | 1335 wp->w_changelistidx = oldwin->w_changelistidx; |
1336 #endif | |
1337 | |
2115
5fd44cf99b6d
updated for version 7.2.398
Bram Moolenaar <bram@zimbu.org>
parents:
2064
diff
changeset
|
1338 /* |
5fd44cf99b6d
updated for version 7.2.398
Bram Moolenaar <bram@zimbu.org>
parents:
2064
diff
changeset
|
1339 * make the new window the current window |
5fd44cf99b6d
updated for version 7.2.398
Bram Moolenaar <bram@zimbu.org>
parents:
2064
diff
changeset
|
1340 */ |
25499
5ebf9bb1cbcd
patch 8.2.3286: win_enter_ext() has too many boolean arguments
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
1341 win_enter_ext(wp, WEE_TRIGGER_NEW_AUTOCMDS | WEE_TRIGGER_ENTER_AUTOCMDS |
5ebf9bb1cbcd
patch 8.2.3286: win_enter_ext() has too many boolean arguments
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
1342 | WEE_TRIGGER_LEAVE_AUTOCMDS); |
7 | 1343 if (flags & WSP_VERT) |
1344 p_wiw = i; | |
1345 else | |
1346 p_wh = i; | |
1347 | |
1348 return OK; | |
1349 } | |
1350 | |
1906 | 1351 |
675 | 1352 /* |
1353 * Initialize window "newp" from window "oldp". | |
1354 * Used when splitting a window and when creating a new tab page. | |
1355 * The windows will both edit the same buffer. | |
1822 | 1356 * WSP_NEWLOC may be specified in flags to prevent the location list from |
1357 * being copied. | |
675 | 1358 */ |
1359 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1360 win_init(win_T *newp, win_T *oldp, int flags UNUSED) |
675 | 1361 { |
1362 int i; | |
1363 | |
1364 newp->w_buffer = oldp->w_buffer; | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2201
diff
changeset
|
1365 #ifdef FEAT_SYN_HL |
2253
12ebd6f6dfce
Fixed: after ":ownsyntax perl" and ":e" syntax was cleared in other window.
Bram Moolenaar <bram@vim.org>
parents:
2252
diff
changeset
|
1366 newp->w_s = &(oldp->w_buffer->b_s); |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2201
diff
changeset
|
1367 #endif |
675 | 1368 oldp->w_buffer->b_nwindows++; |
1369 newp->w_cursor = oldp->w_cursor; | |
1370 newp->w_valid = 0; | |
1371 newp->w_curswant = oldp->w_curswant; | |
1372 newp->w_set_curswant = oldp->w_set_curswant; | |
1373 newp->w_topline = oldp->w_topline; | |
1374 #ifdef FEAT_DIFF | |
1375 newp->w_topfill = oldp->w_topfill; | |
1376 #endif | |
1377 newp->w_leftcol = oldp->w_leftcol; | |
1378 newp->w_pcmark = oldp->w_pcmark; | |
1379 newp->w_prev_pcmark = oldp->w_prev_pcmark; | |
1380 newp->w_alt_fnum = oldp->w_alt_fnum; | |
826 | 1381 newp->w_wrow = oldp->w_wrow; |
675 | 1382 newp->w_fraction = oldp->w_fraction; |
1383 newp->w_prev_fraction_row = oldp->w_prev_fraction_row; | |
1384 #ifdef FEAT_JUMPLIST | |
1385 copy_jumplist(oldp, newp); | |
1386 #endif | |
1387 #ifdef FEAT_QUICKFIX | |
1822 | 1388 if (flags & WSP_NEWLOC) |
1389 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1390 // Don't copy the location list. |
1822 | 1391 newp->w_llist = NULL; |
1392 newp->w_llist_ref = NULL; | |
1393 } | |
1394 else | |
14844
a74786d0370c
patch 8.1.0434: copy_loclist() is too long
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
1395 copy_loclist_stack(oldp, newp); |
675 | 1396 #endif |
5584 | 1397 newp->w_localdir = (oldp->w_localdir == NULL) |
1398 ? NULL : vim_strsave(oldp->w_localdir); | |
21723
5b0796787cb2
patch 8.2.1411: when splitting a window localdir is copied but prevdir is not
Bram Moolenaar <Bram@vim.org>
parents:
21703
diff
changeset
|
1399 newp->w_prevdir = (oldp->w_prevdir == NULL) |
5b0796787cb2
patch 8.2.1411: when splitting a window localdir is copied but prevdir is not
Bram Moolenaar <Bram@vim.org>
parents:
21703
diff
changeset
|
1400 ? NULL : vim_strsave(oldp->w_prevdir); |
675 | 1401 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1402 // copy tagstack and folds |
675 | 1403 for (i = 0; i < oldp->w_tagstacklen; i++) |
1404 { | |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16427
diff
changeset
|
1405 taggy_T *tag = &newp->w_tagstack[i]; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16427
diff
changeset
|
1406 *tag = oldp->w_tagstack[i]; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16427
diff
changeset
|
1407 if (tag->tagname != NULL) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16427
diff
changeset
|
1408 tag->tagname = vim_strsave(tag->tagname); |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16427
diff
changeset
|
1409 if (tag->user_data != NULL) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16427
diff
changeset
|
1410 tag->user_data = vim_strsave(tag->user_data); |
675 | 1411 } |
1412 newp->w_tagstackidx = oldp->w_tagstackidx; | |
1413 newp->w_tagstacklen = oldp->w_tagstacklen; | |
3068 | 1414 #ifdef FEAT_FOLDING |
675 | 1415 copyFoldingState(oldp, newp); |
3068 | 1416 #endif |
1906 | 1417 |
1418 win_init_some(newp, oldp); | |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2306
diff
changeset
|
1419 |
3068 | 1420 #ifdef FEAT_SYN_HL |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2306
diff
changeset
|
1421 check_colorcolumn(newp); |
3068 | 1422 #endif |
1906 | 1423 } |
1424 | |
1425 /* | |
6222 | 1426 * Initialize window "newp" from window "old". |
1906 | 1427 * Only the essential things are copied. |
1428 */ | |
1429 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1430 win_init_some(win_T *newp, win_T *oldp) |
1906 | 1431 { |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1432 // Use the same argument list. |
1906 | 1433 newp->w_alist = oldp->w_alist; |
1434 ++newp->w_alist->al_refcount; | |
1435 newp->w_arg_idx = oldp->w_arg_idx; | |
1436 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1437 // copy options from existing window |
1906 | 1438 win_copy_options(oldp, newp); |
675 | 1439 } |
1440 | |
16902
23645f9a5ce2
patch 8.1.1452: line and col property of popup windows not properly checked
Bram Moolenaar <Bram@vim.org>
parents:
16890
diff
changeset
|
1441 /* |
23645f9a5ce2
patch 8.1.1452: line and col property of popup windows not properly checked
Bram Moolenaar <Bram@vim.org>
parents:
16890
diff
changeset
|
1442 * Return TRUE if "win" is a global popup or a popup in the current tab page. |
23645f9a5ce2
patch 8.1.1452: line and col property of popup windows not properly checked
Bram Moolenaar <Bram@vim.org>
parents:
16890
diff
changeset
|
1443 */ |
17051
221d4b82bc0b
patch 8.1.1525: cannot move a popup window with the mouse
Bram Moolenaar <Bram@vim.org>
parents:
17043
diff
changeset
|
1444 int |
16780
491c01280a5d
patch 8.1.1392: build failure in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
16778
diff
changeset
|
1445 win_valid_popup(win_T *win UNUSED) |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
1446 { |
18763
49b78d6465e5
patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents:
18590
diff
changeset
|
1447 #ifdef FEAT_PROP_POPUP |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
1448 win_T *wp; |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
1449 |
19888
435726a03481
patch 8.2.0500: using the same loop in many places
Bram Moolenaar <Bram@vim.org>
parents:
19291
diff
changeset
|
1450 FOR_ALL_POPUPWINS(wp) |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
1451 if (wp == win) |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
1452 return TRUE; |
19888
435726a03481
patch 8.2.0500: using the same loop in many places
Bram Moolenaar <Bram@vim.org>
parents:
19291
diff
changeset
|
1453 FOR_ALL_POPUPWINS_IN_TAB(curtab, wp) |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
1454 if (wp == win) |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
1455 return TRUE; |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
1456 #endif |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
1457 return FALSE; |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
1458 } |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
1459 |
7 | 1460 /* |
9875
42adbf172ecd
commit https://github.com/vim/vim/commit/e59215c7dcae17b03daf39517560cfaa03314f5a
Christian Brabandt <cb@256bit.org>
parents:
9858
diff
changeset
|
1461 * Check if "win" is a pointer to an existing window in the current tab page. |
7 | 1462 */ |
1463 int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1464 win_valid(win_T *win) |
7 | 1465 { |
1466 win_T *wp; | |
1467 | |
1468 if (win == NULL) | |
1469 return FALSE; | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9599
diff
changeset
|
1470 FOR_ALL_WINDOWS(wp) |
7 | 1471 if (wp == win) |
1472 return TRUE; | |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
1473 return win_valid_popup(win); |
7 | 1474 } |
1475 | |
1476 /* | |
22838
80bd5de5dcab
patch 8.2.1966: popup becomes current window after closing a terminal window
Bram Moolenaar <Bram@vim.org>
parents:
22800
diff
changeset
|
1477 * Find window "id" in the current tab page. |
22900
2c1520981e63
patch 8.2.1997: window changes when using bufload() while in a terminal popup
Bram Moolenaar <Bram@vim.org>
parents:
22838
diff
changeset
|
1478 * Also find popup windows. |
22838
80bd5de5dcab
patch 8.2.1966: popup becomes current window after closing a terminal window
Bram Moolenaar <Bram@vim.org>
parents:
22800
diff
changeset
|
1479 * Return NULL if not found. |
80bd5de5dcab
patch 8.2.1966: popup becomes current window after closing a terminal window
Bram Moolenaar <Bram@vim.org>
parents:
22800
diff
changeset
|
1480 */ |
80bd5de5dcab
patch 8.2.1966: popup becomes current window after closing a terminal window
Bram Moolenaar <Bram@vim.org>
parents:
22800
diff
changeset
|
1481 win_T * |
80bd5de5dcab
patch 8.2.1966: popup becomes current window after closing a terminal window
Bram Moolenaar <Bram@vim.org>
parents:
22800
diff
changeset
|
1482 win_find_by_id(int id) |
80bd5de5dcab
patch 8.2.1966: popup becomes current window after closing a terminal window
Bram Moolenaar <Bram@vim.org>
parents:
22800
diff
changeset
|
1483 { |
80bd5de5dcab
patch 8.2.1966: popup becomes current window after closing a terminal window
Bram Moolenaar <Bram@vim.org>
parents:
22800
diff
changeset
|
1484 win_T *wp; |
80bd5de5dcab
patch 8.2.1966: popup becomes current window after closing a terminal window
Bram Moolenaar <Bram@vim.org>
parents:
22800
diff
changeset
|
1485 |
80bd5de5dcab
patch 8.2.1966: popup becomes current window after closing a terminal window
Bram Moolenaar <Bram@vim.org>
parents:
22800
diff
changeset
|
1486 FOR_ALL_WINDOWS(wp) |
80bd5de5dcab
patch 8.2.1966: popup becomes current window after closing a terminal window
Bram Moolenaar <Bram@vim.org>
parents:
22800
diff
changeset
|
1487 if (wp->w_id == id) |
80bd5de5dcab
patch 8.2.1966: popup becomes current window after closing a terminal window
Bram Moolenaar <Bram@vim.org>
parents:
22800
diff
changeset
|
1488 return wp; |
22900
2c1520981e63
patch 8.2.1997: window changes when using bufload() while in a terminal popup
Bram Moolenaar <Bram@vim.org>
parents:
22838
diff
changeset
|
1489 #ifdef FEAT_PROP_POPUP |
2c1520981e63
patch 8.2.1997: window changes when using bufload() while in a terminal popup
Bram Moolenaar <Bram@vim.org>
parents:
22838
diff
changeset
|
1490 FOR_ALL_POPUPWINS(wp) |
2c1520981e63
patch 8.2.1997: window changes when using bufload() while in a terminal popup
Bram Moolenaar <Bram@vim.org>
parents:
22838
diff
changeset
|
1491 if (wp->w_id == id) |
2c1520981e63
patch 8.2.1997: window changes when using bufload() while in a terminal popup
Bram Moolenaar <Bram@vim.org>
parents:
22838
diff
changeset
|
1492 return wp; |
2c1520981e63
patch 8.2.1997: window changes when using bufload() while in a terminal popup
Bram Moolenaar <Bram@vim.org>
parents:
22838
diff
changeset
|
1493 FOR_ALL_POPUPWINS_IN_TAB(curtab, wp) |
2c1520981e63
patch 8.2.1997: window changes when using bufload() while in a terminal popup
Bram Moolenaar <Bram@vim.org>
parents:
22838
diff
changeset
|
1494 if (wp->w_id == id) |
2c1520981e63
patch 8.2.1997: window changes when using bufload() while in a terminal popup
Bram Moolenaar <Bram@vim.org>
parents:
22838
diff
changeset
|
1495 return wp; |
2c1520981e63
patch 8.2.1997: window changes when using bufload() while in a terminal popup
Bram Moolenaar <Bram@vim.org>
parents:
22838
diff
changeset
|
1496 #endif |
22838
80bd5de5dcab
patch 8.2.1966: popup becomes current window after closing a terminal window
Bram Moolenaar <Bram@vim.org>
parents:
22800
diff
changeset
|
1497 return NULL; |
80bd5de5dcab
patch 8.2.1966: popup becomes current window after closing a terminal window
Bram Moolenaar <Bram@vim.org>
parents:
22800
diff
changeset
|
1498 } |
80bd5de5dcab
patch 8.2.1966: popup becomes current window after closing a terminal window
Bram Moolenaar <Bram@vim.org>
parents:
22800
diff
changeset
|
1499 |
80bd5de5dcab
patch 8.2.1966: popup becomes current window after closing a terminal window
Bram Moolenaar <Bram@vim.org>
parents:
22800
diff
changeset
|
1500 /* |
9875
42adbf172ecd
commit https://github.com/vim/vim/commit/e59215c7dcae17b03daf39517560cfaa03314f5a
Christian Brabandt <cb@256bit.org>
parents:
9858
diff
changeset
|
1501 * Check if "win" is a pointer to an existing window in any tab page. |
42adbf172ecd
commit https://github.com/vim/vim/commit/e59215c7dcae17b03daf39517560cfaa03314f5a
Christian Brabandt <cb@256bit.org>
parents:
9858
diff
changeset
|
1502 */ |
42adbf172ecd
commit https://github.com/vim/vim/commit/e59215c7dcae17b03daf39517560cfaa03314f5a
Christian Brabandt <cb@256bit.org>
parents:
9858
diff
changeset
|
1503 int |
42adbf172ecd
commit https://github.com/vim/vim/commit/e59215c7dcae17b03daf39517560cfaa03314f5a
Christian Brabandt <cb@256bit.org>
parents:
9858
diff
changeset
|
1504 win_valid_any_tab(win_T *win) |
42adbf172ecd
commit https://github.com/vim/vim/commit/e59215c7dcae17b03daf39517560cfaa03314f5a
Christian Brabandt <cb@256bit.org>
parents:
9858
diff
changeset
|
1505 { |
42adbf172ecd
commit https://github.com/vim/vim/commit/e59215c7dcae17b03daf39517560cfaa03314f5a
Christian Brabandt <cb@256bit.org>
parents:
9858
diff
changeset
|
1506 win_T *wp; |
42adbf172ecd
commit https://github.com/vim/vim/commit/e59215c7dcae17b03daf39517560cfaa03314f5a
Christian Brabandt <cb@256bit.org>
parents:
9858
diff
changeset
|
1507 tabpage_T *tp; |
42adbf172ecd
commit https://github.com/vim/vim/commit/e59215c7dcae17b03daf39517560cfaa03314f5a
Christian Brabandt <cb@256bit.org>
parents:
9858
diff
changeset
|
1508 |
42adbf172ecd
commit https://github.com/vim/vim/commit/e59215c7dcae17b03daf39517560cfaa03314f5a
Christian Brabandt <cb@256bit.org>
parents:
9858
diff
changeset
|
1509 if (win == NULL) |
42adbf172ecd
commit https://github.com/vim/vim/commit/e59215c7dcae17b03daf39517560cfaa03314f5a
Christian Brabandt <cb@256bit.org>
parents:
9858
diff
changeset
|
1510 return FALSE; |
42adbf172ecd
commit https://github.com/vim/vim/commit/e59215c7dcae17b03daf39517560cfaa03314f5a
Christian Brabandt <cb@256bit.org>
parents:
9858
diff
changeset
|
1511 FOR_ALL_TABPAGES(tp) |
42adbf172ecd
commit https://github.com/vim/vim/commit/e59215c7dcae17b03daf39517560cfaa03314f5a
Christian Brabandt <cb@256bit.org>
parents:
9858
diff
changeset
|
1512 { |
42adbf172ecd
commit https://github.com/vim/vim/commit/e59215c7dcae17b03daf39517560cfaa03314f5a
Christian Brabandt <cb@256bit.org>
parents:
9858
diff
changeset
|
1513 FOR_ALL_WINDOWS_IN_TAB(tp, wp) |
42adbf172ecd
commit https://github.com/vim/vim/commit/e59215c7dcae17b03daf39517560cfaa03314f5a
Christian Brabandt <cb@256bit.org>
parents:
9858
diff
changeset
|
1514 { |
42adbf172ecd
commit https://github.com/vim/vim/commit/e59215c7dcae17b03daf39517560cfaa03314f5a
Christian Brabandt <cb@256bit.org>
parents:
9858
diff
changeset
|
1515 if (wp == win) |
42adbf172ecd
commit https://github.com/vim/vim/commit/e59215c7dcae17b03daf39517560cfaa03314f5a
Christian Brabandt <cb@256bit.org>
parents:
9858
diff
changeset
|
1516 return TRUE; |
42adbf172ecd
commit https://github.com/vim/vim/commit/e59215c7dcae17b03daf39517560cfaa03314f5a
Christian Brabandt <cb@256bit.org>
parents:
9858
diff
changeset
|
1517 } |
18763
49b78d6465e5
patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents:
18590
diff
changeset
|
1518 #ifdef FEAT_PROP_POPUP |
19888
435726a03481
patch 8.2.0500: using the same loop in many places
Bram Moolenaar <Bram@vim.org>
parents:
19291
diff
changeset
|
1519 FOR_ALL_POPUPWINS_IN_TAB(tp, wp) |
16902
23645f9a5ce2
patch 8.1.1452: line and col property of popup windows not properly checked
Bram Moolenaar <Bram@vim.org>
parents:
16890
diff
changeset
|
1520 if (wp == win) |
23645f9a5ce2
patch 8.1.1452: line and col property of popup windows not properly checked
Bram Moolenaar <Bram@vim.org>
parents:
16890
diff
changeset
|
1521 return TRUE; |
23645f9a5ce2
patch 8.1.1452: line and col property of popup windows not properly checked
Bram Moolenaar <Bram@vim.org>
parents:
16890
diff
changeset
|
1522 #endif |
9875
42adbf172ecd
commit https://github.com/vim/vim/commit/e59215c7dcae17b03daf39517560cfaa03314f5a
Christian Brabandt <cb@256bit.org>
parents:
9858
diff
changeset
|
1523 } |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
1524 return win_valid_popup(win); |
9875
42adbf172ecd
commit https://github.com/vim/vim/commit/e59215c7dcae17b03daf39517560cfaa03314f5a
Christian Brabandt <cb@256bit.org>
parents:
9858
diff
changeset
|
1525 } |
42adbf172ecd
commit https://github.com/vim/vim/commit/e59215c7dcae17b03daf39517560cfaa03314f5a
Christian Brabandt <cb@256bit.org>
parents:
9858
diff
changeset
|
1526 |
42adbf172ecd
commit https://github.com/vim/vim/commit/e59215c7dcae17b03daf39517560cfaa03314f5a
Christian Brabandt <cb@256bit.org>
parents:
9858
diff
changeset
|
1527 /* |
7 | 1528 * Return the number of windows. |
1529 */ | |
1530 int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1531 win_count(void) |
7 | 1532 { |
1533 win_T *wp; | |
1534 int count = 0; | |
1535 | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9599
diff
changeset
|
1536 FOR_ALL_WINDOWS(wp) |
7 | 1537 ++count; |
1538 return count; | |
1539 } | |
1540 | |
1541 /* | |
1542 * Make "count" windows on the screen. | |
1543 * Return actual number of windows on the screen. | |
1544 * Must be called when there is just one window, filling the whole screen | |
1545 * (excluding the command line). | |
1546 */ | |
1547 int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1548 make_windows( |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1549 int count, |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1550 int vertical UNUSED) // split windows vertically if TRUE |
7 | 1551 { |
1552 int maxcount; | |
1553 int todo; | |
1554 | |
1555 if (vertical) | |
1556 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1557 // Each windows needs at least 'winminwidth' lines and a separator |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1558 // column. |
7 | 1559 maxcount = (curwin->w_width + curwin->w_vsep_width |
1560 - (p_wiw - p_wmw)) / (p_wmw + 1); | |
1561 } | |
1562 else | |
1563 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1564 // Each window needs at least 'winminheight' lines and a status line. |
12998
dd734ee3e2fe
patch 8.0.1375: window size wrong after maximizing with WinBar
Christian Brabandt <cb@256bit.org>
parents:
12916
diff
changeset
|
1565 maxcount = (VISIBLE_HEIGHT(curwin) + curwin->w_status_height |
7 | 1566 - (p_wh - p_wmh)) / (p_wmh + STATUS_HEIGHT); |
1567 } | |
1568 | |
1569 if (maxcount < 2) | |
1570 maxcount = 2; | |
1571 if (count > maxcount) | |
1572 count = maxcount; | |
1573 | |
1574 /* | |
1575 * add status line now, otherwise first window will be too big | |
1576 */ | |
1577 if (count > 1) | |
1578 last_status(TRUE); | |
1579 | |
1580 /* | |
1581 * Don't execute autocommands while creating the windows. Must do that | |
1582 * when putting the buffers in the windows. | |
1583 */ | |
1410 | 1584 block_autocmds(); |
7 | 1585 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1586 // todo is number of windows left to create |
7 | 1587 for (todo = count - 1; todo > 0; --todo) |
1588 if (vertical) | |
1589 { | |
1590 if (win_split(curwin->w_width - (curwin->w_width - todo) | |
1591 / (todo + 1) - 1, WSP_VERT | WSP_ABOVE) == FAIL) | |
1592 break; | |
1593 } | |
1594 else | |
1595 { | |
1596 if (win_split(curwin->w_height - (curwin->w_height - todo | |
1597 * STATUS_HEIGHT) / (todo + 1) | |
1598 - STATUS_HEIGHT, WSP_ABOVE) == FAIL) | |
1599 break; | |
1600 } | |
1601 | |
1410 | 1602 unblock_autocmds(); |
7 | 1603 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1604 // return actual number of windows |
7 | 1605 return (count - todo); |
1606 } | |
1607 | |
1608 /* | |
1609 * Exchange current and next window | |
1610 */ | |
1611 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1612 win_exchange(long Prenum) |
7 | 1613 { |
1614 frame_T *frp; | |
1615 frame_T *frp2; | |
1616 win_T *wp; | |
1617 win_T *wp2; | |
1618 int temp; | |
1619 | |
19271
ebeeb4b4a1fa
patch 8.2.0194: some commands can cause problems in terminal popup
Bram Moolenaar <Bram@vim.org>
parents:
19265
diff
changeset
|
1620 if (ERROR_IF_ANY_POPUP_WINDOW) |
16874
da5f5836e90c
patch 8.1.1438: some commands cause trouble in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
16863
diff
changeset
|
1621 return; |
da5f5836e90c
patch 8.1.1438: some commands cause trouble in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
16863
diff
changeset
|
1622 if (ONE_WINDOW) // just one window |
7 | 1623 { |
1624 beep_flush(); | |
1625 return; | |
1626 } | |
1627 | |
1628 #ifdef FEAT_GUI | |
1629 need_mouse_correct = TRUE; | |
1630 #endif | |
1631 | |
1632 /* | |
1633 * find window to exchange with | |
1634 */ | |
1635 if (Prenum) | |
1636 { | |
1637 frp = curwin->w_frame->fr_parent->fr_child; | |
1638 while (frp != NULL && --Prenum > 0) | |
1639 frp = frp->fr_next; | |
1640 } | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1641 else if (curwin->w_frame->fr_next != NULL) // Swap with next |
7 | 1642 frp = curwin->w_frame->fr_next; |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1643 else // Swap last window in row/col with previous |
7 | 1644 frp = curwin->w_frame->fr_prev; |
1645 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1646 // We can only exchange a window with another window, not with a frame |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1647 // containing windows. |
7 | 1648 if (frp == NULL || frp->fr_win == NULL || frp->fr_win == curwin) |
1649 return; | |
1650 wp = frp->fr_win; | |
1651 | |
1652 /* | |
1653 * 1. remove curwin from the list. Remember after which window it was in wp2 | |
1654 * 2. insert curwin before wp in the list | |
1655 * if wp != wp2 | |
1656 * 3. remove wp from the list | |
1657 * 4. insert wp after wp2 | |
1658 * 5. exchange the status line height and vsep width. | |
1659 */ | |
1660 wp2 = curwin->w_prev; | |
1661 frp2 = curwin->w_frame->fr_prev; | |
1662 if (wp->w_prev != curwin) | |
1663 { | |
671 | 1664 win_remove(curwin, NULL); |
7 | 1665 frame_remove(curwin->w_frame); |
1666 win_append(wp->w_prev, curwin); | |
1667 frame_insert(frp, curwin->w_frame); | |
1668 } | |
1669 if (wp != wp2) | |
1670 { | |
671 | 1671 win_remove(wp, NULL); |
7 | 1672 frame_remove(wp->w_frame); |
1673 win_append(wp2, wp); | |
1674 if (frp2 == NULL) | |
1675 frame_insert(wp->w_frame->fr_parent->fr_child, wp->w_frame); | |
1676 else | |
1677 frame_append(frp2, wp->w_frame); | |
1678 } | |
1679 temp = curwin->w_status_height; | |
1680 curwin->w_status_height = wp->w_status_height; | |
1681 wp->w_status_height = temp; | |
1682 temp = curwin->w_vsep_width; | |
1683 curwin->w_vsep_width = wp->w_vsep_width; | |
1684 wp->w_vsep_width = temp; | |
1685 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1686 // If the windows are not in the same frame, exchange the sizes to avoid |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1687 // messing up the window layout. Otherwise fix the frame sizes. |
7 | 1688 if (curwin->w_frame->fr_parent != wp->w_frame->fr_parent) |
1689 { | |
1690 temp = curwin->w_height; | |
1691 curwin->w_height = wp->w_height; | |
1692 wp->w_height = temp; | |
1693 temp = curwin->w_width; | |
1694 curwin->w_width = wp->w_width; | |
1695 wp->w_width = temp; | |
1696 } | |
1697 else | |
1698 { | |
1699 frame_fix_height(curwin); | |
1700 frame_fix_height(wp); | |
1701 frame_fix_width(curwin); | |
1702 frame_fix_width(wp); | |
1703 } | |
1704 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1705 (void)win_comp_pos(); // recompute window positions |
7 | 1706 |
1707 win_enter(wp, TRUE); | |
15380
f62d6bd18a49
patch 8.1.0698: clearing the window is used too often
Bram Moolenaar <Bram@vim.org>
parents:
15227
diff
changeset
|
1708 redraw_all_later(NOT_VALID); |
7 | 1709 } |
1710 | |
1711 /* | |
1712 * rotate windows: if upwards TRUE the second window becomes the first one | |
1713 * if upwards FALSE the first window becomes the second one | |
1714 */ | |
1715 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1716 win_rotate(int upwards, int count) |
7 | 1717 { |
1718 win_T *wp1; | |
1719 win_T *wp2; | |
1720 frame_T *frp; | |
1721 int n; | |
1722 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1723 if (ONE_WINDOW) // nothing to do |
7 | 1724 { |
1725 beep_flush(); | |
1726 return; | |
1727 } | |
1728 | |
1729 #ifdef FEAT_GUI | |
1730 need_mouse_correct = TRUE; | |
1731 #endif | |
1732 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1733 // Check if all frames in this row/col have one window. |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
1734 FOR_ALL_FRAMES(frp, curwin->w_frame->fr_parent->fr_child) |
7 | 1735 if (frp->fr_win == NULL) |
1736 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15436
diff
changeset
|
1737 emsg(_("E443: Cannot rotate when another window is split")); |
7 | 1738 return; |
1739 } | |
1740 | |
1741 while (count--) | |
1742 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1743 if (upwards) // first window becomes last window |
7 | 1744 { |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1745 // remove first window/frame from the list |
7 | 1746 frp = curwin->w_frame->fr_parent->fr_child; |
1747 wp1 = frp->fr_win; | |
671 | 1748 win_remove(wp1, NULL); |
7 | 1749 frame_remove(frp); |
1750 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1751 // find last frame and append removed window/frame after it |
7 | 1752 for ( ; frp->fr_next != NULL; frp = frp->fr_next) |
1753 ; | |
1754 win_append(frp->fr_win, wp1); | |
1755 frame_append(frp, wp1->w_frame); | |
1756 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1757 wp2 = frp->fr_win; // previously last window |
7 | 1758 } |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1759 else // last window becomes first window |
7 | 1760 { |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1761 // find last window/frame in the list and remove it |
7 | 1762 for (frp = curwin->w_frame; frp->fr_next != NULL; |
1763 frp = frp->fr_next) | |
1764 ; | |
1765 wp1 = frp->fr_win; | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1766 wp2 = wp1->w_prev; // will become last window |
671 | 1767 win_remove(wp1, NULL); |
7 | 1768 frame_remove(frp); |
1769 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1770 // append the removed window/frame before the first in the list |
7 | 1771 win_append(frp->fr_parent->fr_child->fr_win->w_prev, wp1); |
1772 frame_insert(frp->fr_parent->fr_child, frp); | |
1773 } | |
1774 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1775 // exchange status height and vsep width of old and new last window |
7 | 1776 n = wp2->w_status_height; |
1777 wp2->w_status_height = wp1->w_status_height; | |
1778 wp1->w_status_height = n; | |
1779 frame_fix_height(wp1); | |
1780 frame_fix_height(wp2); | |
1781 n = wp2->w_vsep_width; | |
1782 wp2->w_vsep_width = wp1->w_vsep_width; | |
1783 wp1->w_vsep_width = n; | |
1784 frame_fix_width(wp1); | |
1785 frame_fix_width(wp2); | |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8536
diff
changeset
|
1786 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1787 // recompute w_winrow and w_wincol for all windows |
7 | 1788 (void)win_comp_pos(); |
1789 } | |
1790 | |
15380
f62d6bd18a49
patch 8.1.0698: clearing the window is used too often
Bram Moolenaar <Bram@vim.org>
parents:
15227
diff
changeset
|
1791 redraw_all_later(NOT_VALID); |
7 | 1792 } |
1793 | |
1794 /* | |
1795 * Move the current window to the very top/bottom/left/right of the screen. | |
1796 */ | |
1797 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1798 win_totop(int size, int flags) |
7 | 1799 { |
1800 int dir; | |
1801 int height = curwin->w_height; | |
1802 | |
10357
59d01e335858
commit https://github.com/vim/vim/commit/459ca563128f2edb7e3bb190090bbb755a56dd55
Christian Brabandt <cb@256bit.org>
parents:
10349
diff
changeset
|
1803 if (ONE_WINDOW) |
7 | 1804 { |
1805 beep_flush(); | |
1806 return; | |
1807 } | |
17516
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
1808 if (check_split_disallowed() == FAIL) |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
1809 return; |
7 | 1810 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1811 // Remove the window and frame from the tree of frames. |
671 | 1812 (void)winframe_remove(curwin, &dir, NULL); |
1813 win_remove(curwin, NULL); | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1814 last_status(FALSE); // may need to remove last status line |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1815 (void)win_comp_pos(); // recompute window positions |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1816 |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1817 // Split a window on the desired side and put the window there. |
7 | 1818 (void)win_split_ins(size, flags, curwin, dir); |
1819 if (!(flags & WSP_VERT)) | |
1820 { | |
1821 win_setheight(height); | |
1822 if (p_ea) | |
1823 win_equal(curwin, TRUE, 'v'); | |
1824 } | |
1825 | |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8536
diff
changeset
|
1826 #if defined(FEAT_GUI) |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1827 // When 'guioptions' includes 'L' or 'R' may have to remove or add |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1828 // scrollbars. Have to update them anyway. |
1906 | 1829 gui_may_update_scrollbars(); |
1830 #endif | |
7 | 1831 } |
1832 | |
1833 /* | |
1834 * Move window "win1" to below/right of "win2" and make "win1" the current | |
1835 * window. Only works within the same frame! | |
1836 */ | |
1837 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1838 win_move_after(win_T *win1, win_T *win2) |
7 | 1839 { |
1840 int height; | |
1841 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1842 // check if the arguments are reasonable |
7 | 1843 if (win1 == win2) |
1844 return; | |
1845 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1846 // check if there is something to do |
7 | 1847 if (win2->w_next != win1) |
1848 { | |
17516
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
1849 if (win1->w_frame->fr_parent != win2->w_frame->fr_parent) |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
1850 { |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
1851 iemsg("INTERNAL: trying to move a window into another frame"); |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
1852 return; |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
1853 } |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
1854 |
21020
6c634e63989c
patch 8.2.1061: insufficient testing for src/window.c
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1855 // may need to move the status line/vertical separator of the last |
6c634e63989c
patch 8.2.1061: insufficient testing for src/window.c
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1856 // window |
7 | 1857 if (win1 == lastwin) |
1858 { | |
1859 height = win1->w_prev->w_status_height; | |
1860 win1->w_prev->w_status_height = win1->w_status_height; | |
1861 win1->w_status_height = height; | |
1070 | 1862 if (win1->w_prev->w_vsep_width == 1) |
1863 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1864 // Remove the vertical separator from the last-but-one window, |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1865 // add it to the last window. Adjust the frame widths. |
1070 | 1866 win1->w_prev->w_vsep_width = 0; |
1867 win1->w_prev->w_frame->fr_width -= 1; | |
1868 win1->w_vsep_width = 1; | |
1869 win1->w_frame->fr_width += 1; | |
1870 } | |
7 | 1871 } |
1872 else if (win2 == lastwin) | |
1873 { | |
1874 height = win1->w_status_height; | |
1875 win1->w_status_height = win2->w_status_height; | |
1876 win2->w_status_height = height; | |
1070 | 1877 if (win1->w_vsep_width == 1) |
1878 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1879 // Remove the vertical separator from win1, add it to the last |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1880 // window, win2. Adjust the frame widths. |
1070 | 1881 win2->w_vsep_width = 1; |
1882 win2->w_frame->fr_width += 1; | |
1883 win1->w_vsep_width = 0; | |
1884 win1->w_frame->fr_width -= 1; | |
1885 } | |
7 | 1886 } |
671 | 1887 win_remove(win1, NULL); |
7 | 1888 frame_remove(win1->w_frame); |
1889 win_append(win2, win1); | |
1890 frame_append(win2->w_frame, win1->w_frame); | |
1891 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1892 (void)win_comp_pos(); // recompute w_winrow for all windows |
7 | 1893 redraw_later(NOT_VALID); |
1894 } | |
1895 win_enter(win1, FALSE); | |
1896 } | |
1897 | |
1898 /* | |
1899 * Make all windows the same height. | |
1900 * 'next_curwin' will soon be the current window, make sure it has enough | |
1901 * rows. | |
1902 */ | |
1903 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1904 win_equal( |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1905 win_T *next_curwin, // pointer to current window to be or NULL |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1906 int current, // do only frame with current window |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1907 int dir) // 'v' for vertically, 'h' for horizontally, |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1908 // 'b' for both, 0 for using p_ead |
7 | 1909 { |
1910 if (dir == 0) | |
1911 dir = *p_ead; | |
1912 win_equal_rec(next_curwin == NULL ? curwin : next_curwin, current, | |
685 | 1913 topframe, dir, 0, tabline_height(), |
667 | 1914 (int)Columns, topframe->fr_height); |
7 | 1915 } |
1916 | |
1917 /* | |
1918 * Set a frame to a new position and height, spreading the available room | |
1919 * equally over contained frames. | |
1920 * The window "next_curwin" (if not NULL) should at least get the size from | |
1921 * 'winheight' and 'winwidth' if possible. | |
1922 */ | |
1923 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1924 win_equal_rec( |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1925 win_T *next_curwin, // pointer to current window to be or NULL |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1926 int current, // do only frame with current window |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1927 frame_T *topfr, // frame to set size off |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1928 int dir, // 'v', 'h' or 'b', see win_equal() |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1929 int col, // horizontal position for frame |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1930 int row, // vertical position for frame |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1931 int width, // new width of frame |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1932 int height) // new height of frame |
7 | 1933 { |
1934 int n, m; | |
1935 int extra_sep = 0; | |
1936 int wincount, totwincount = 0; | |
1937 frame_T *fr; | |
1938 int next_curwin_size = 0; | |
1939 int room = 0; | |
1940 int new_size; | |
1941 int has_next_curwin = 0; | |
1942 int hnc; | |
1943 | |
1944 if (topfr->fr_layout == FR_LEAF) | |
1945 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1946 // Set the width/height of this frame. |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1947 // Redraw when size or position changes |
7 | 1948 if (topfr->fr_height != height || topfr->fr_win->w_winrow != row |
1949 || topfr->fr_width != width || topfr->fr_win->w_wincol != col | |
1950 ) | |
1951 { | |
1952 topfr->fr_win->w_winrow = row; | |
1953 frame_new_height(topfr, height, FALSE, FALSE); | |
1954 topfr->fr_win->w_wincol = col; | |
779 | 1955 frame_new_width(topfr, width, FALSE, FALSE); |
15380
f62d6bd18a49
patch 8.1.0698: clearing the window is used too often
Bram Moolenaar <Bram@vim.org>
parents:
15227
diff
changeset
|
1956 redraw_all_later(NOT_VALID); |
7 | 1957 } |
1958 } | |
1959 else if (topfr->fr_layout == FR_ROW) | |
1960 { | |
1961 topfr->fr_width = width; | |
1962 topfr->fr_height = height; | |
1963 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1964 if (dir != 'v') // equalize frame widths |
7 | 1965 { |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1966 // Compute the maximum number of windows horizontally in this |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1967 // frame. |
7 | 1968 n = frame_minwidth(topfr, NOWIN); |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1969 // add one for the rightmost window, it doesn't have a separator |
7 | 1970 if (col + width == Columns) |
1971 extra_sep = 1; | |
1972 else | |
1973 extra_sep = 0; | |
1974 totwincount = (n + extra_sep) / (p_wmw + 1); | |
779 | 1975 has_next_curwin = frame_has_win(topfr, next_curwin); |
1976 | |
1977 /* | |
1978 * Compute width for "next_curwin" window and room available for | |
1979 * other windows. | |
1980 * "m" is the minimal width when counting p_wiw for "next_curwin". | |
1981 */ | |
7 | 1982 m = frame_minwidth(topfr, next_curwin); |
1983 room = width - m; | |
1984 if (room < 0) | |
1985 { | |
1986 next_curwin_size = p_wiw + room; | |
1987 room = 0; | |
1988 } | |
1989 else | |
1990 { | |
779 | 1991 next_curwin_size = -1; |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
1992 FOR_ALL_FRAMES(fr, topfr->fr_child) |
779 | 1993 { |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1994 // If 'winfixwidth' set keep the window width if |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1995 // possible. |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1996 // Watch out for this window being the next_curwin. |
779 | 1997 if (frame_fixed_width(fr)) |
1998 { | |
1999 n = frame_minwidth(fr, NOWIN); | |
2000 new_size = fr->fr_width; | |
2001 if (frame_has_win(fr, next_curwin)) | |
2002 { | |
2003 room += p_wiw - p_wmw; | |
2004 next_curwin_size = 0; | |
2005 if (new_size < p_wiw) | |
2006 new_size = p_wiw; | |
2007 } | |
2008 else | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2009 // These windows don't use up room. |
779 | 2010 totwincount -= (n + (fr->fr_next == NULL |
2011 ? extra_sep : 0)) / (p_wmw + 1); | |
2012 room -= new_size - n; | |
2013 if (room < 0) | |
2014 { | |
2015 new_size += room; | |
2016 room = 0; | |
2017 } | |
2018 fr->fr_newwidth = new_size; | |
2019 } | |
2020 } | |
2021 if (next_curwin_size == -1) | |
2022 { | |
2023 if (!has_next_curwin) | |
2024 next_curwin_size = 0; | |
2025 else if (totwincount > 1 | |
2026 && (room + (totwincount - 2)) | |
2027 / (totwincount - 1) > p_wiw) | |
2028 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2029 // Can make all windows wider than 'winwidth', spread |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2030 // the room equally. |
834 | 2031 next_curwin_size = (room + p_wiw |
2032 + (totwincount - 1) * p_wmw | |
2033 + (totwincount - 1)) / totwincount; | |
779 | 2034 room -= next_curwin_size - p_wiw; |
2035 } | |
2036 else | |
2037 next_curwin_size = p_wiw; | |
2038 } | |
7 | 2039 } |
779 | 2040 |
2041 if (has_next_curwin) | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2042 --totwincount; // don't count curwin |
7 | 2043 } |
2044 | |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
2045 FOR_ALL_FRAMES(fr, topfr->fr_child) |
7 | 2046 { |
2047 wincount = 1; | |
2048 if (fr->fr_next == NULL) | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2049 // last frame gets all that remains (avoid roundoff error) |
7 | 2050 new_size = width; |
2051 else if (dir == 'v') | |
2052 new_size = fr->fr_width; | |
779 | 2053 else if (frame_fixed_width(fr)) |
2054 { | |
2055 new_size = fr->fr_newwidth; | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2056 wincount = 0; // doesn't count as a sizeable window |
779 | 2057 } |
7 | 2058 else |
2059 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2060 // Compute the maximum number of windows horiz. in "fr". |
7 | 2061 n = frame_minwidth(fr, NOWIN); |
2062 wincount = (n + (fr->fr_next == NULL ? extra_sep : 0)) | |
2063 / (p_wmw + 1); | |
2064 m = frame_minwidth(fr, next_curwin); | |
779 | 2065 if (has_next_curwin) |
2066 hnc = frame_has_win(fr, next_curwin); | |
2067 else | |
2068 hnc = FALSE; | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2069 if (hnc) // don't count next_curwin |
7 | 2070 --wincount; |
779 | 2071 if (totwincount == 0) |
2072 new_size = room; | |
2073 else | |
2074 new_size = (wincount * room + ((unsigned)totwincount >> 1)) | |
7 | 2075 / totwincount; |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2076 if (hnc) // add next_curwin size |
7 | 2077 { |
2078 next_curwin_size -= p_wiw - (m - n); | |
2079 new_size += next_curwin_size; | |
779 | 2080 room -= new_size - next_curwin_size; |
7 | 2081 } |
779 | 2082 else |
2083 room -= new_size; | |
2084 new_size += n; | |
7 | 2085 } |
2086 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2087 // Skip frame that is full width when splitting or closing a |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2088 // window, unless equalizing all frames. |
7 | 2089 if (!current || dir != 'v' || topfr->fr_parent != NULL |
2090 || (new_size != fr->fr_width) | |
2091 || frame_has_win(fr, next_curwin)) | |
2092 win_equal_rec(next_curwin, current, fr, dir, col, row, | |
779 | 2093 new_size, height); |
2094 col += new_size; | |
2095 width -= new_size; | |
7 | 2096 totwincount -= wincount; |
2097 } | |
2098 } | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2099 else // topfr->fr_layout == FR_COL |
7 | 2100 { |
2101 topfr->fr_width = width; | |
2102 topfr->fr_height = height; | |
2103 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2104 if (dir != 'h') // equalize frame heights |
7 | 2105 { |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2106 // Compute maximum number of windows vertically in this frame. |
7 | 2107 n = frame_minheight(topfr, NOWIN); |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2108 // add one for the bottom window if it doesn't have a statusline |
7 | 2109 if (row + height == cmdline_row && p_ls == 0) |
2110 extra_sep = 1; | |
2111 else | |
2112 extra_sep = 0; | |
2113 totwincount = (n + extra_sep) / (p_wmh + 1); | |
2114 has_next_curwin = frame_has_win(topfr, next_curwin); | |
2115 | |
2116 /* | |
2117 * Compute height for "next_curwin" window and room available for | |
2118 * other windows. | |
2119 * "m" is the minimal height when counting p_wh for "next_curwin". | |
2120 */ | |
2121 m = frame_minheight(topfr, next_curwin); | |
2122 room = height - m; | |
2123 if (room < 0) | |
2124 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2125 // The room is less then 'winheight', use all space for the |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2126 // current window. |
7 | 2127 next_curwin_size = p_wh + room; |
2128 room = 0; | |
2129 } | |
2130 else | |
2131 { | |
2132 next_curwin_size = -1; | |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
2133 FOR_ALL_FRAMES(fr, topfr->fr_child) |
7 | 2134 { |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2135 // If 'winfixheight' set keep the window height if |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2136 // possible. |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2137 // Watch out for this window being the next_curwin. |
7 | 2138 if (frame_fixed_height(fr)) |
2139 { | |
2140 n = frame_minheight(fr, NOWIN); | |
2141 new_size = fr->fr_height; | |
2142 if (frame_has_win(fr, next_curwin)) | |
2143 { | |
2144 room += p_wh - p_wmh; | |
2145 next_curwin_size = 0; | |
2146 if (new_size < p_wh) | |
2147 new_size = p_wh; | |
2148 } | |
2149 else | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2150 // These windows don't use up room. |
7 | 2151 totwincount -= (n + (fr->fr_next == NULL |
2152 ? extra_sep : 0)) / (p_wmh + 1); | |
2153 room -= new_size - n; | |
2154 if (room < 0) | |
2155 { | |
2156 new_size += room; | |
2157 room = 0; | |
2158 } | |
2159 fr->fr_newheight = new_size; | |
2160 } | |
2161 } | |
2162 if (next_curwin_size == -1) | |
2163 { | |
2164 if (!has_next_curwin) | |
2165 next_curwin_size = 0; | |
2166 else if (totwincount > 1 | |
2167 && (room + (totwincount - 2)) | |
2168 / (totwincount - 1) > p_wh) | |
2169 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2170 // can make all windows higher than 'winheight', |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2171 // spread the room equally. |
834 | 2172 next_curwin_size = (room + p_wh |
2173 + (totwincount - 1) * p_wmh | |
7 | 2174 + (totwincount - 1)) / totwincount; |
2175 room -= next_curwin_size - p_wh; | |
2176 } | |
2177 else | |
2178 next_curwin_size = p_wh; | |
2179 } | |
2180 } | |
2181 | |
2182 if (has_next_curwin) | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2183 --totwincount; // don't count curwin |
7 | 2184 } |
2185 | |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
2186 FOR_ALL_FRAMES(fr, topfr->fr_child) |
7 | 2187 { |
2188 wincount = 1; | |
2189 if (fr->fr_next == NULL) | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2190 // last frame gets all that remains (avoid roundoff error) |
7 | 2191 new_size = height; |
2192 else if (dir == 'h') | |
2193 new_size = fr->fr_height; | |
2194 else if (frame_fixed_height(fr)) | |
2195 { | |
2196 new_size = fr->fr_newheight; | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2197 wincount = 0; // doesn't count as a sizeable window |
7 | 2198 } |
2199 else | |
2200 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2201 // Compute the maximum number of windows vert. in "fr". |
7 | 2202 n = frame_minheight(fr, NOWIN); |
2203 wincount = (n + (fr->fr_next == NULL ? extra_sep : 0)) | |
2204 / (p_wmh + 1); | |
2205 m = frame_minheight(fr, next_curwin); | |
2206 if (has_next_curwin) | |
2207 hnc = frame_has_win(fr, next_curwin); | |
2208 else | |
2209 hnc = FALSE; | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2210 if (hnc) // don't count next_curwin |
7 | 2211 --wincount; |
2212 if (totwincount == 0) | |
2213 new_size = room; | |
2214 else | |
2215 new_size = (wincount * room + ((unsigned)totwincount >> 1)) | |
2216 / totwincount; | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2217 if (hnc) // add next_curwin size |
7 | 2218 { |
2219 next_curwin_size -= p_wh - (m - n); | |
2220 new_size += next_curwin_size; | |
2221 room -= new_size - next_curwin_size; | |
2222 } | |
2223 else | |
2224 room -= new_size; | |
2225 new_size += n; | |
2226 } | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2227 // Skip frame that is full width when splitting or closing a |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2228 // window, unless equalizing all frames. |
7 | 2229 if (!current || dir != 'h' || topfr->fr_parent != NULL |
2230 || (new_size != fr->fr_height) | |
2231 || frame_has_win(fr, next_curwin)) | |
2232 win_equal_rec(next_curwin, current, fr, dir, col, row, | |
2233 width, new_size); | |
2234 row += new_size; | |
2235 height -= new_size; | |
2236 totwincount -= wincount; | |
2237 } | |
2238 } | |
2239 } | |
2240 | |
14035
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
2241 #ifdef FEAT_JOB_CHANNEL |
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
2242 static void |
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
2243 leaving_window(win_T *win) |
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
2244 { |
14049
3e6477e767ba
patch 8.1.0042: if omni completion opens a window Insert mode is stopped
Christian Brabandt <cb@256bit.org>
parents:
14037
diff
changeset
|
2245 // Only matters for a prompt window. |
3e6477e767ba
patch 8.1.0042: if omni completion opens a window Insert mode is stopped
Christian Brabandt <cb@256bit.org>
parents:
14037
diff
changeset
|
2246 if (!bt_prompt(win->w_buffer)) |
3e6477e767ba
patch 8.1.0042: if omni completion opens a window Insert mode is stopped
Christian Brabandt <cb@256bit.org>
parents:
14037
diff
changeset
|
2247 return; |
3e6477e767ba
patch 8.1.0042: if omni completion opens a window Insert mode is stopped
Christian Brabandt <cb@256bit.org>
parents:
14037
diff
changeset
|
2248 |
14035
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
2249 // When leaving a prompt window stop Insert mode and perhaps restart |
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
2250 // it when entering that window again. |
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
2251 win->w_buffer->b_prompt_insert = restart_edit; |
14093
a9d94f10ecef
patch 8.1.0064: typing CTRL-W in a prompt buffer shows mode "-- --"
Christian Brabandt <cb@256bit.org>
parents:
14057
diff
changeset
|
2252 if (restart_edit != 0 && mode_displayed) |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2253 clear_cmdline = TRUE; // unshow mode later |
14035
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
2254 restart_edit = NUL; |
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
2255 |
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
2256 // When leaving the window (or closing the window) was done from a |
14049
3e6477e767ba
patch 8.1.0042: if omni completion opens a window Insert mode is stopped
Christian Brabandt <cb@256bit.org>
parents:
14037
diff
changeset
|
2257 // callback we need to break out of the Insert mode loop and restart Insert |
3e6477e767ba
patch 8.1.0042: if omni completion opens a window Insert mode is stopped
Christian Brabandt <cb@256bit.org>
parents:
14037
diff
changeset
|
2258 // mode when entering the window again. |
14035
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
2259 if (State & INSERT) |
14037
afce2005fdc8
patch 8.1.0036: not restoring Insert mode if leaving prompt buffer with mouse
Christian Brabandt <cb@256bit.org>
parents:
14035
diff
changeset
|
2260 { |
14035
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
2261 stop_insert_mode = TRUE; |
14049
3e6477e767ba
patch 8.1.0042: if omni completion opens a window Insert mode is stopped
Christian Brabandt <cb@256bit.org>
parents:
14037
diff
changeset
|
2262 if (win->w_buffer->b_prompt_insert == NUL) |
14037
afce2005fdc8
patch 8.1.0036: not restoring Insert mode if leaving prompt buffer with mouse
Christian Brabandt <cb@256bit.org>
parents:
14035
diff
changeset
|
2263 win->w_buffer->b_prompt_insert = 'A'; |
afce2005fdc8
patch 8.1.0036: not restoring Insert mode if leaving prompt buffer with mouse
Christian Brabandt <cb@256bit.org>
parents:
14035
diff
changeset
|
2264 } |
14035
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
2265 } |
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
2266 |
22470
f7471450243c
patch 8.2.1783: try-catch test fails
Bram Moolenaar <Bram@vim.org>
parents:
22464
diff
changeset
|
2267 void |
14035
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
2268 entering_window(win_T *win) |
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
2269 { |
14049
3e6477e767ba
patch 8.1.0042: if omni completion opens a window Insert mode is stopped
Christian Brabandt <cb@256bit.org>
parents:
14037
diff
changeset
|
2270 // Only matters for a prompt window. |
3e6477e767ba
patch 8.1.0042: if omni completion opens a window Insert mode is stopped
Christian Brabandt <cb@256bit.org>
parents:
14037
diff
changeset
|
2271 if (!bt_prompt(win->w_buffer)) |
3e6477e767ba
patch 8.1.0042: if omni completion opens a window Insert mode is stopped
Christian Brabandt <cb@256bit.org>
parents:
14037
diff
changeset
|
2272 return; |
3e6477e767ba
patch 8.1.0042: if omni completion opens a window Insert mode is stopped
Christian Brabandt <cb@256bit.org>
parents:
14037
diff
changeset
|
2273 |
14037
afce2005fdc8
patch 8.1.0036: not restoring Insert mode if leaving prompt buffer with mouse
Christian Brabandt <cb@256bit.org>
parents:
14035
diff
changeset
|
2274 // When switching to a prompt buffer that was in Insert mode, don't stop |
afce2005fdc8
patch 8.1.0036: not restoring Insert mode if leaving prompt buffer with mouse
Christian Brabandt <cb@256bit.org>
parents:
14035
diff
changeset
|
2275 // Insert mode, it may have been set in leaving_window(). |
14049
3e6477e767ba
patch 8.1.0042: if omni completion opens a window Insert mode is stopped
Christian Brabandt <cb@256bit.org>
parents:
14037
diff
changeset
|
2276 if (win->w_buffer->b_prompt_insert != NUL) |
14037
afce2005fdc8
patch 8.1.0036: not restoring Insert mode if leaving prompt buffer with mouse
Christian Brabandt <cb@256bit.org>
parents:
14035
diff
changeset
|
2277 stop_insert_mode = FALSE; |
afce2005fdc8
patch 8.1.0036: not restoring Insert mode if leaving prompt buffer with mouse
Christian Brabandt <cb@256bit.org>
parents:
14035
diff
changeset
|
2278 |
14049
3e6477e767ba
patch 8.1.0042: if omni completion opens a window Insert mode is stopped
Christian Brabandt <cb@256bit.org>
parents:
14037
diff
changeset
|
2279 // When entering the prompt window restart Insert mode if we were in Insert |
3e6477e767ba
patch 8.1.0042: if omni completion opens a window Insert mode is stopped
Christian Brabandt <cb@256bit.org>
parents:
14037
diff
changeset
|
2280 // mode when we left it. |
14035
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
2281 restart_edit = win->w_buffer->b_prompt_insert; |
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
2282 } |
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
2283 #endif |
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
2284 |
7 | 2285 /* |
11199
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
2286 * Close all windows for buffer "buf". |
7 | 2287 */ |
2288 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2289 close_windows( |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2290 buf_T *buf, |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2291 int keep_curwin) // don't close "curwin" |
7 | 2292 { |
671 | 2293 win_T *wp; |
2294 tabpage_T *tp, *nexttp; | |
685 | 2295 int h = tabline_height(); |
9599
42a8a81decdf
commit https://github.com/vim/vim/commit/12c11d553053f5a9eae9eb3c518279b12fa928c2
Christian Brabandt <cb@256bit.org>
parents:
9595
diff
changeset
|
2296 int count = tabpage_index(NULL); |
7 | 2297 |
2298 ++RedrawingDisabled; | |
671 | 2299 |
10357
59d01e335858
commit https://github.com/vim/vim/commit/459ca563128f2edb7e3bb190090bbb755a56dd55
Christian Brabandt <cb@256bit.org>
parents:
10349
diff
changeset
|
2300 for (wp = firstwin; wp != NULL && !ONE_WINDOW; ) |
7 | 2301 { |
3570 | 2302 if (wp->w_buffer == buf && (!keep_curwin || wp != curwin) |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13308
diff
changeset
|
2303 && !(wp->w_closing || wp->w_buffer->b_locked > 0)) |
7 | 2304 { |
11199
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
2305 if (win_close(wp, FALSE) == FAIL) |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2306 // If closing the window fails give up, to avoid looping |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2307 // forever. |
11199
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
2308 break; |
671 | 2309 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2310 // Start all over, autocommands may change the window layout. |
671 | 2311 wp = firstwin; |
7 | 2312 } |
2313 else | |
671 | 2314 wp = wp->w_next; |
7 | 2315 } |
671 | 2316 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2317 // Also check windows in other tab pages. |
671 | 2318 for (tp = first_tabpage; tp != NULL; tp = nexttp) |
2319 { | |
2320 nexttp = tp->tp_next; | |
672 | 2321 if (tp != curtab) |
19888
435726a03481
patch 8.2.0500: using the same loop in many places
Bram Moolenaar <Bram@vim.org>
parents:
19291
diff
changeset
|
2322 FOR_ALL_WINDOWS_IN_TAB(tp, wp) |
3570 | 2323 if (wp->w_buffer == buf |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13308
diff
changeset
|
2324 && !(wp->w_closing || wp->w_buffer->b_locked > 0)) |
671 | 2325 { |
2326 win_close_othertab(wp, FALSE, tp); | |
2327 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2328 // Start all over, the tab page may be closed and |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2329 // autocommands may change the window layout. |
671 | 2330 nexttp = first_tabpage; |
2331 break; | |
2332 } | |
2333 } | |
2334 | |
7 | 2335 --RedrawingDisabled; |
671 | 2336 |
9599
42a8a81decdf
commit https://github.com/vim/vim/commit/12c11d553053f5a9eae9eb3c518279b12fa928c2
Christian Brabandt <cb@256bit.org>
parents:
9595
diff
changeset
|
2337 if (count != tabpage_index(NULL)) |
42a8a81decdf
commit https://github.com/vim/vim/commit/12c11d553053f5a9eae9eb3c518279b12fa928c2
Christian Brabandt <cb@256bit.org>
parents:
9595
diff
changeset
|
2338 apply_autocmds(EVENT_TABCLOSED, NULL, NULL, FALSE, curbuf); |
42a8a81decdf
commit https://github.com/vim/vim/commit/12c11d553053f5a9eae9eb3c518279b12fa928c2
Christian Brabandt <cb@256bit.org>
parents:
9595
diff
changeset
|
2339 |
4305 | 2340 redraw_tabline = TRUE; |
685 | 2341 if (h != tabline_height()) |
671 | 2342 shell_new_rows(); |
7 | 2343 } |
2344 | |
2345 /* | |
1906 | 2346 * Return TRUE if the current window is the only window that exists (ignoring |
2347 * "aucmd_win"). | |
672 | 2348 * Returns FALSE if there is a window, possibly in another tab page. |
667 | 2349 */ |
672 | 2350 static int |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2351 last_window(void) |
667 | 2352 { |
1906 | 2353 return (one_window() && first_tabpage->tp_next == NULL); |
2354 } | |
2355 | |
2356 /* | |
2357 * Return TRUE if there is only one window other than "aucmd_win" in the | |
2358 * current tab page. | |
2359 */ | |
3365 | 2360 int |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2361 one_window(void) |
1906 | 2362 { |
2363 win_T *wp; | |
2364 int seen_one = FALSE; | |
2365 | |
2366 FOR_ALL_WINDOWS(wp) | |
2367 { | |
2368 if (wp != aucmd_win) | |
2369 { | |
2370 if (seen_one) | |
2371 return FALSE; | |
2372 seen_one = TRUE; | |
2373 } | |
2374 } | |
2375 return TRUE; | |
667 | 2376 } |
2377 | |
2378 /* | |
3535 | 2379 * Close the possibly last window in a tab page. |
2380 * Returns TRUE when the window was closed already. | |
2381 */ | |
2382 static int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2383 close_last_window_tabpage( |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2384 win_T *win, |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2385 int free_buf, |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2386 tabpage_T *prev_curtab) |
3535 | 2387 { |
10349
cf988222b150
commit https://github.com/vim/vim/commit/a1f4cb93ba50ea9e40cd4b1f5592b8a6d1398660
Christian Brabandt <cb@256bit.org>
parents:
10106
diff
changeset
|
2388 if (ONE_WINDOW) |
3535 | 2389 { |
4354 | 2390 buf_T *old_curbuf = curbuf; |
2391 | |
3535 | 2392 /* |
2393 * Closing the last window in a tab page. First go to another tab | |
2394 * page and then close the window and the tab page. This avoids that | |
2395 * curwin and curtab are invalid while we are freeing memory, they may | |
2396 * be used in GUI events. | |
3582 | 2397 * Don't trigger autocommands yet, they may use wrong values, so do |
2398 * that below. | |
3535 | 2399 */ |
4354 | 2400 goto_tabpage_tp(alt_tabpage(), FALSE, TRUE); |
3535 | 2401 redraw_tabline = TRUE; |
2402 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2403 // Safety check: Autocommands may have closed the window when jumping |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2404 // to the other tab page. |
3535 | 2405 if (valid_tabpage(prev_curtab) && prev_curtab->tp_firstwin == win) |
2406 { | |
2407 int h = tabline_height(); | |
2408 | |
2409 win_close_othertab(win, free_buf, prev_curtab); | |
2410 if (h != tabline_height()) | |
2411 shell_new_rows(); | |
2412 } | |
14035
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
2413 #ifdef FEAT_JOB_CHANNEL |
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
2414 entering_window(curwin); |
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
2415 #endif |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2416 // Since goto_tabpage_tp above did not trigger *Enter autocommands, do |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2417 // that now. |
9599
42a8a81decdf
commit https://github.com/vim/vim/commit/12c11d553053f5a9eae9eb3c518279b12fa928c2
Christian Brabandt <cb@256bit.org>
parents:
9595
diff
changeset
|
2418 apply_autocmds(EVENT_TABCLOSED, NULL, NULL, FALSE, curbuf); |
4354 | 2419 apply_autocmds(EVENT_WINENTER, NULL, NULL, FALSE, curbuf); |
3582 | 2420 apply_autocmds(EVENT_TABENTER, NULL, NULL, FALSE, curbuf); |
4354 | 2421 if (old_curbuf != curbuf) |
2422 apply_autocmds(EVENT_BUFENTER, NULL, NULL, FALSE, curbuf); | |
3535 | 2423 return TRUE; |
2424 } | |
2425 return FALSE; | |
2426 } | |
2427 | |
2428 /* | |
17043
d99805d25b42
patch 8.1.1521: when a popup window is closed the buffer remains
Bram Moolenaar <Bram@vim.org>
parents:
16902
diff
changeset
|
2429 * Close the buffer of "win" and unload it if "action" is DOBUF_UNLOAD. |
d99805d25b42
patch 8.1.1521: when a popup window is closed the buffer remains
Bram Moolenaar <Bram@vim.org>
parents:
16902
diff
changeset
|
2430 * "action" can also be zero (do nothing) or DOBUF_WIPE. |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2431 * "abort_if_last" is passed to close_buffer(): abort closing if all other |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2432 * windows are closed. |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2433 */ |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2434 static void |
17043
d99805d25b42
patch 8.1.1521: when a popup window is closed the buffer remains
Bram Moolenaar <Bram@vim.org>
parents:
16902
diff
changeset
|
2435 win_close_buffer(win_T *win, int action, int abort_if_last) |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2436 { |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2437 #ifdef FEAT_SYN_HL |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2438 // Free independent synblock before the buffer is freed. |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2439 if (win->w_buffer != NULL) |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2440 reset_synblock(win); |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2441 #endif |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2442 |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2443 #ifdef FEAT_QUICKFIX |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2444 // When the quickfix/location list window is closed, unlist the buffer. |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2445 if (win->w_buffer != NULL && bt_quickfix(win->w_buffer)) |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2446 win->w_buffer->b_p_bl = FALSE; |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2447 #endif |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2448 |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2449 // Close the link to the buffer. |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2450 if (win->w_buffer != NULL) |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2451 { |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2452 bufref_T bufref; |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2453 |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2454 set_bufref(&bufref, curbuf); |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2455 win->w_closing = TRUE; |
18886
050f5eaa9e50
patch 8.2.0004: get E685 and E931 if buffer reload is interrupted
Bram Moolenaar <Bram@vim.org>
parents:
18816
diff
changeset
|
2456 close_buffer(win, win->w_buffer, action, abort_if_last, FALSE); |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2457 if (win_valid_any_tab(win)) |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2458 win->w_closing = FALSE; |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2459 // Make sure curbuf is valid. It can become invalid if 'bufhidden' is |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2460 // "wipe". |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2461 if (!bufref_valid(&bufref)) |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2462 curbuf = firstbuf; |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2463 } |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2464 } |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2465 |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2466 /* |
819 | 2467 * Close window "win". Only works for the current tab page. |
7 | 2468 * If "free_buf" is TRUE related buffer may be unloaded. |
2469 * | |
3365 | 2470 * Called by :quit, :close, :xit, :wq and findtag(). |
5302 | 2471 * Returns FAIL when the window was not closed. |
7 | 2472 */ |
5302 | 2473 int |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2474 win_close(win_T *win, int free_buf) |
7 | 2475 { |
2476 win_T *wp; | |
2477 int other_buffer = FALSE; | |
2478 int close_curwin = FALSE; | |
2479 int dir; | |
2480 int help_window = FALSE; | |
847 | 2481 tabpage_T *prev_curtab = curtab; |
11593
c4e7fe672a72
patch 8.0.0679: using freed memory
Christian Brabandt <cb@256bit.org>
parents:
11591
diff
changeset
|
2482 frame_T *win_frame = win->w_frame->fr_parent; |
18590
41484f342f80
patch 8.1.2289: after :diffsplit closing the window does not disable diff
Bram Moolenaar <Bram@vim.org>
parents:
18467
diff
changeset
|
2483 #ifdef FEAT_DIFF |
41484f342f80
patch 8.1.2289: after :diffsplit closing the window does not disable diff
Bram Moolenaar <Bram@vim.org>
parents:
18467
diff
changeset
|
2484 int had_diffmode = win->w_p_diff; |
41484f342f80
patch 8.1.2289: after :diffsplit closing the window does not disable diff
Bram Moolenaar <Bram@vim.org>
parents:
18467
diff
changeset
|
2485 #endif |
7 | 2486 |
19275
2142fb624658
patch 8.2.0196: blocking commands for a finished job in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19271
diff
changeset
|
2487 #if defined(FEAT_TERMINAL) && defined(FEAT_PROP_POPUP) |
2142fb624658
patch 8.2.0196: blocking commands for a finished job in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19271
diff
changeset
|
2488 // Can close a popup window with a terminal if the job has finished. |
2142fb624658
patch 8.2.0196: blocking commands for a finished job in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19271
diff
changeset
|
2489 if (may_close_term_popup() == OK) |
2142fb624658
patch 8.2.0196: blocking commands for a finished job in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19271
diff
changeset
|
2490 return OK; |
2142fb624658
patch 8.2.0196: blocking commands for a finished job in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19271
diff
changeset
|
2491 #endif |
19271
ebeeb4b4a1fa
patch 8.2.0194: some commands can cause problems in terminal popup
Bram Moolenaar <Bram@vim.org>
parents:
19265
diff
changeset
|
2492 if (ERROR_IF_ANY_POPUP_WINDOW) |
16874
da5f5836e90c
patch 8.1.1438: some commands cause trouble in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
16863
diff
changeset
|
2493 return FAIL; |
da5f5836e90c
patch 8.1.1438: some commands cause trouble in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
16863
diff
changeset
|
2494 |
667 | 2495 if (last_window()) |
7 | 2496 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15436
diff
changeset
|
2497 emsg(_("E444: Cannot close last window")); |
5302 | 2498 return FAIL; |
7 | 2499 } |
2500 | |
10106
58e6dd1d8be3
commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents:
10082
diff
changeset
|
2501 if (win->w_closing || (win->w_buffer != NULL |
58e6dd1d8be3
commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents:
10082
diff
changeset
|
2502 && win->w_buffer->b_locked > 0)) |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2503 return FAIL; // window is already being closed |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2504 if (win_unlisted(win)) |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2505 { |
21016
0738c44504cb
patch 8.2.1059: crash when using :tabonly in an autocommand
Bram Moolenaar <Bram@vim.org>
parents:
20737
diff
changeset
|
2506 emsg(_(e_autocmd_close)); |
5302 | 2507 return FAIL; |
1906 | 2508 } |
2509 if ((firstwin == aucmd_win || lastwin == aucmd_win) && one_window()) | |
2510 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15436
diff
changeset
|
2511 emsg(_("E814: Cannot close window, only autocmd window would remain")); |
5302 | 2512 return FAIL; |
1906 | 2513 } |
2514 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2515 // When closing the last window in a tab page first go to another tab page |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2516 // and then close the window and the tab page to avoid that curwin and |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2517 // curtab are invalid while we are freeing memory. |
3535 | 2518 if (close_last_window_tabpage(win, free_buf, prev_curtab)) |
5302 | 2519 return FAIL; |
856 | 2520 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2521 // When closing the help window, try restoring a snapshot after closing |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2522 // the window. Otherwise clear the snapshot, it's now invalid. |
11800
5ceaecedbad2
patch 8.0.0782: using freed memory in quickfix code
Christian Brabandt <cb@256bit.org>
parents:
11593
diff
changeset
|
2523 if (bt_help(win->w_buffer)) |
7 | 2524 help_window = TRUE; |
2525 else | |
1906 | 2526 clear_snapshot(curtab, SNAP_HELP_IDX); |
7 | 2527 |
2528 if (win == curwin) | |
2529 { | |
14035
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
2530 #ifdef FEAT_JOB_CHANNEL |
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
2531 leaving_window(curwin); |
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
2532 #endif |
7 | 2533 /* |
2534 * Guess which window is going to be the new current window. | |
2535 * This may change because of the autocommands (sigh). | |
2536 */ | |
671 | 2537 wp = frame2win(win_altframe(win, NULL)); |
7 | 2538 |
2539 /* | |
3570 | 2540 * Be careful: If autocommands delete the window or cause this window |
2541 * to be the last one left, return now. | |
7 | 2542 */ |
2543 if (wp->w_buffer != curbuf) | |
2544 { | |
2545 other_buffer = TRUE; | |
3570 | 2546 win->w_closing = TRUE; |
7 | 2547 apply_autocmds(EVENT_BUFLEAVE, NULL, NULL, FALSE, curbuf); |
3570 | 2548 if (!win_valid(win)) |
5302 | 2549 return FAIL; |
3570 | 2550 win->w_closing = FALSE; |
2551 if (last_window()) | |
5302 | 2552 return FAIL; |
7 | 2553 } |
3570 | 2554 win->w_closing = TRUE; |
7 | 2555 apply_autocmds(EVENT_WINLEAVE, NULL, NULL, FALSE, curbuf); |
3570 | 2556 if (!win_valid(win)) |
5302 | 2557 return FAIL; |
3570 | 2558 win->w_closing = FALSE; |
2559 if (last_window()) | |
5302 | 2560 return FAIL; |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13308
diff
changeset
|
2561 #ifdef FEAT_EVAL |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2562 // autocmds may abort script processing |
7 | 2563 if (aborting()) |
5302 | 2564 return FAIL; |
7 | 2565 #endif |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13308
diff
changeset
|
2566 } |
7 | 2567 |
1101 | 2568 #ifdef FEAT_GUI |
16019
096b8ccd855e
patch 8.1.1015: quickfix buffer shows up in list, can't get buffer number
Bram Moolenaar <Bram@vim.org>
parents:
15977
diff
changeset
|
2569 // Avoid trouble with scrollbars that are going to be deleted in |
096b8ccd855e
patch 8.1.1015: quickfix buffer shows up in list, can't get buffer number
Bram Moolenaar <Bram@vim.org>
parents:
15977
diff
changeset
|
2570 // win_free(). |
1101 | 2571 if (gui.in_use) |
2572 out_flush(); | |
2573 #endif | |
2574 | |
18763
49b78d6465e5
patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents:
18590
diff
changeset
|
2575 #ifdef FEAT_PROP_POPUP |
17863
08f1dd29550e
patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents:
17823
diff
changeset
|
2576 if (popup_win_closed(win) && !win_valid(win)) |
08f1dd29550e
patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents:
17823
diff
changeset
|
2577 return FAIL; |
08f1dd29550e
patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents:
17823
diff
changeset
|
2578 #endif |
17043
d99805d25b42
patch 8.1.1521: when a popup window is closed the buffer remains
Bram Moolenaar <Bram@vim.org>
parents:
16902
diff
changeset
|
2579 win_close_buffer(win, free_buf ? DOBUF_UNLOAD : 0, TRUE); |
847 | 2580 |
4021 | 2581 if (only_one_window() && win_valid(win) && win->w_buffer == NULL |
2582 && (last_window() || curtab != prev_curtab | |
2583 || close_last_window_tabpage(win, free_buf, prev_curtab))) | |
5233
1899acc5aebd
updated for version 7.4a.042
Bram Moolenaar <bram@vim.org>
parents:
5202
diff
changeset
|
2584 { |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2585 // Autocommands have closed all windows, quit now. Restore |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2586 // curwin->w_buffer, otherwise writing viminfo may fail. |
5233
1899acc5aebd
updated for version 7.4a.042
Bram Moolenaar <bram@vim.org>
parents:
5202
diff
changeset
|
2587 if (curwin->w_buffer == NULL) |
1899acc5aebd
updated for version 7.4a.042
Bram Moolenaar <bram@vim.org>
parents:
5202
diff
changeset
|
2588 curwin->w_buffer = curbuf; |
4021 | 2589 getout(0); |
5233
1899acc5aebd
updated for version 7.4a.042
Bram Moolenaar <bram@vim.org>
parents:
5202
diff
changeset
|
2590 } |
4021 | 2591 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2592 // Autocommands may have moved to another tab page. |
10076
bc30991c3e98
commit https://github.com/vim/vim/commit/11fbc2866ccc11b4dd1726abdaf582a78ef3f743
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2593 if (curtab != prev_curtab && win_valid_any_tab(win) |
bc30991c3e98
commit https://github.com/vim/vim/commit/11fbc2866ccc11b4dd1726abdaf582a78ef3f743
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2594 && win->w_buffer == NULL) |
bc30991c3e98
commit https://github.com/vim/vim/commit/11fbc2866ccc11b4dd1726abdaf582a78ef3f743
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2595 { |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2596 // Need to close the window anyway, since the buffer is NULL. |
10076
bc30991c3e98
commit https://github.com/vim/vim/commit/11fbc2866ccc11b4dd1726abdaf582a78ef3f743
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2597 win_close_othertab(win, FALSE, prev_curtab); |
bc30991c3e98
commit https://github.com/vim/vim/commit/11fbc2866ccc11b4dd1726abdaf582a78ef3f743
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2598 return FAIL; |
bc30991c3e98
commit https://github.com/vim/vim/commit/11fbc2866ccc11b4dd1726abdaf582a78ef3f743
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2599 } |
bc30991c3e98
commit https://github.com/vim/vim/commit/11fbc2866ccc11b4dd1726abdaf582a78ef3f743
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2600 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2601 // Autocommands may have closed the window already or closed the only |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2602 // other window. |
10076
bc30991c3e98
commit https://github.com/vim/vim/commit/11fbc2866ccc11b4dd1726abdaf582a78ef3f743
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2603 if (!win_valid(win) || last_window() |
3535 | 2604 || close_last_window_tabpage(win, free_buf, prev_curtab)) |
5302 | 2605 return FAIL; |
7 | 2606 |
17516
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
2607 // Now we are really going to close the window. Disallow any autocommand |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
2608 // to split a window to avoid trouble. |
22800
8e7cbf73c3a0
patch 8.2.1948: GUI: crash when handling message while closing a window
Bram Moolenaar <Bram@vim.org>
parents:
22713
diff
changeset
|
2609 // Also bail out of parse_queued_messages() to avoid it tries to update the |
8e7cbf73c3a0
patch 8.2.1948: GUI: crash when handling message while closing a window
Bram Moolenaar <Bram@vim.org>
parents:
22713
diff
changeset
|
2610 // screen. |
17516
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
2611 ++split_disallowed; |
22800
8e7cbf73c3a0
patch 8.2.1948: GUI: crash when handling message while closing a window
Bram Moolenaar <Bram@vim.org>
parents:
22713
diff
changeset
|
2612 #ifdef MESSAGE_QUEUE |
8e7cbf73c3a0
patch 8.2.1948: GUI: crash when handling message while closing a window
Bram Moolenaar <Bram@vim.org>
parents:
22713
diff
changeset
|
2613 ++dont_parse_messages; |
8e7cbf73c3a0
patch 8.2.1948: GUI: crash when handling message while closing a window
Bram Moolenaar <Bram@vim.org>
parents:
22713
diff
changeset
|
2614 #endif |
17516
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
2615 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2616 // Free the memory used for the window and get the window that received |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2617 // the screen space. |
847 | 2618 wp = win_free_mem(win, &dir, NULL); |
2619 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2620 // Make sure curwin isn't invalid. It can cause severe trouble when |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2621 // printing an error message. For win_equal() curbuf needs to be valid |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2622 // too. |
847 | 2623 if (win == curwin) |
7 | 2624 { |
2625 curwin = wp; | |
2626 #ifdef FEAT_QUICKFIX | |
2627 if (wp->w_p_pvw || bt_quickfix(wp->w_buffer)) | |
2628 { | |
2629 /* | |
1346 | 2630 * If the cursor goes to the preview or the quickfix window, try |
7 | 2631 * finding another window to go to. |
2632 */ | |
2633 for (;;) | |
2634 { | |
2635 if (wp->w_next == NULL) | |
2636 wp = firstwin; | |
2637 else | |
2638 wp = wp->w_next; | |
2639 if (wp == curwin) | |
2640 break; | |
2641 if (!wp->w_p_pvw && !bt_quickfix(wp->w_buffer)) | |
2642 { | |
2643 curwin = wp; | |
2644 break; | |
2645 } | |
2646 } | |
2647 } | |
2648 #endif | |
2649 curbuf = curwin->w_buffer; | |
2650 close_curwin = TRUE; | |
11193
75ccc8a15a51
patch 8.0.0483: illegal memory access when using :all
Christian Brabandt <cb@256bit.org>
parents:
11191
diff
changeset
|
2651 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2652 // The cursor position may be invalid if the buffer changed after last |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2653 // using the window. |
11193
75ccc8a15a51
patch 8.0.0483: illegal memory access when using :all
Christian Brabandt <cb@256bit.org>
parents:
11191
diff
changeset
|
2654 check_cursor(); |
7 | 2655 } |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8536
diff
changeset
|
2656 if (p_ea && (*p_ead == 'b' || *p_ead == dir)) |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2657 // If the frame of the closed window contains the new current window, |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2658 // only resize that frame. Otherwise resize all windows. |
11593
c4e7fe672a72
patch 8.0.0679: using freed memory
Christian Brabandt <cb@256bit.org>
parents:
11591
diff
changeset
|
2659 win_equal(curwin, curwin->w_frame->fr_parent == win_frame, dir); |
7 | 2660 else |
2661 win_comp_pos(); | |
2662 if (close_curwin) | |
2663 { | |
25499
5ebf9bb1cbcd
patch 8.2.3286: win_enter_ext() has too many boolean arguments
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
2664 win_enter_ext(wp, WEE_CURWIN_INVALID | WEE_TRIGGER_ENTER_AUTOCMDS |
5ebf9bb1cbcd
patch 8.2.3286: win_enter_ext() has too many boolean arguments
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
2665 | WEE_TRIGGER_LEAVE_AUTOCMDS); |
7 | 2666 if (other_buffer) |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2667 // careful: after this wp and win may be invalid! |
7 | 2668 apply_autocmds(EVENT_BUFENTER, NULL, NULL, FALSE, curbuf); |
2669 } | |
2670 | |
17516
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
2671 --split_disallowed; |
22800
8e7cbf73c3a0
patch 8.2.1948: GUI: crash when handling message while closing a window
Bram Moolenaar <Bram@vim.org>
parents:
22713
diff
changeset
|
2672 #ifdef MESSAGE_QUEUE |
8e7cbf73c3a0
patch 8.2.1948: GUI: crash when handling message while closing a window
Bram Moolenaar <Bram@vim.org>
parents:
22713
diff
changeset
|
2673 --dont_parse_messages; |
8e7cbf73c3a0
patch 8.2.1948: GUI: crash when handling message while closing a window
Bram Moolenaar <Bram@vim.org>
parents:
22713
diff
changeset
|
2674 #endif |
17516
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
2675 |
7 | 2676 /* |
667 | 2677 * If last window has a status line now and we don't want one, |
2678 * remove the status line. | |
7 | 2679 */ |
2680 last_status(FALSE); | |
2681 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2682 // After closing the help window, try restoring the window layout from |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2683 // before it was opened. |
7 | 2684 if (help_window) |
1906 | 2685 restore_snapshot(SNAP_HELP_IDX, close_curwin); |
7 | 2686 |
18590
41484f342f80
patch 8.1.2289: after :diffsplit closing the window does not disable diff
Bram Moolenaar <Bram@vim.org>
parents:
18467
diff
changeset
|
2687 #ifdef FEAT_DIFF |
41484f342f80
patch 8.1.2289: after :diffsplit closing the window does not disable diff
Bram Moolenaar <Bram@vim.org>
parents:
18467
diff
changeset
|
2688 // If the window had 'diff' set and now there is only one window left in |
41484f342f80
patch 8.1.2289: after :diffsplit closing the window does not disable diff
Bram Moolenaar <Bram@vim.org>
parents:
18467
diff
changeset
|
2689 // the tab page with 'diff' set, and "closeoff" is in 'diffopt', then |
41484f342f80
patch 8.1.2289: after :diffsplit closing the window does not disable diff
Bram Moolenaar <Bram@vim.org>
parents:
18467
diff
changeset
|
2690 // execute ":diffoff!". |
41484f342f80
patch 8.1.2289: after :diffsplit closing the window does not disable diff
Bram Moolenaar <Bram@vim.org>
parents:
18467
diff
changeset
|
2691 if (diffopt_closeoff() && had_diffmode && curtab == prev_curtab) |
41484f342f80
patch 8.1.2289: after :diffsplit closing the window does not disable diff
Bram Moolenaar <Bram@vim.org>
parents:
18467
diff
changeset
|
2692 { |
41484f342f80
patch 8.1.2289: after :diffsplit closing the window does not disable diff
Bram Moolenaar <Bram@vim.org>
parents:
18467
diff
changeset
|
2693 int diffcount = 0; |
41484f342f80
patch 8.1.2289: after :diffsplit closing the window does not disable diff
Bram Moolenaar <Bram@vim.org>
parents:
18467
diff
changeset
|
2694 win_T *dwin; |
41484f342f80
patch 8.1.2289: after :diffsplit closing the window does not disable diff
Bram Moolenaar <Bram@vim.org>
parents:
18467
diff
changeset
|
2695 |
41484f342f80
patch 8.1.2289: after :diffsplit closing the window does not disable diff
Bram Moolenaar <Bram@vim.org>
parents:
18467
diff
changeset
|
2696 FOR_ALL_WINDOWS(dwin) |
41484f342f80
patch 8.1.2289: after :diffsplit closing the window does not disable diff
Bram Moolenaar <Bram@vim.org>
parents:
18467
diff
changeset
|
2697 if (dwin->w_p_diff) |
41484f342f80
patch 8.1.2289: after :diffsplit closing the window does not disable diff
Bram Moolenaar <Bram@vim.org>
parents:
18467
diff
changeset
|
2698 ++diffcount; |
41484f342f80
patch 8.1.2289: after :diffsplit closing the window does not disable diff
Bram Moolenaar <Bram@vim.org>
parents:
18467
diff
changeset
|
2699 if (diffcount == 1) |
41484f342f80
patch 8.1.2289: after :diffsplit closing the window does not disable diff
Bram Moolenaar <Bram@vim.org>
parents:
18467
diff
changeset
|
2700 do_cmdline_cmd((char_u *)"diffoff!"); |
41484f342f80
patch 8.1.2289: after :diffsplit closing the window does not disable diff
Bram Moolenaar <Bram@vim.org>
parents:
18467
diff
changeset
|
2701 } |
41484f342f80
patch 8.1.2289: after :diffsplit closing the window does not disable diff
Bram Moolenaar <Bram@vim.org>
parents:
18467
diff
changeset
|
2702 #endif |
41484f342f80
patch 8.1.2289: after :diffsplit closing the window does not disable diff
Bram Moolenaar <Bram@vim.org>
parents:
18467
diff
changeset
|
2703 |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8536
diff
changeset
|
2704 #if defined(FEAT_GUI) |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2705 // When 'guioptions' includes 'L' or 'R' may have to remove scrollbars. |
7 | 2706 if (gui.in_use && !win_hasvertsplit()) |
2707 gui_init_which_components(NULL); | |
2708 #endif | |
2709 | |
2710 redraw_all_later(NOT_VALID); | |
5302 | 2711 return OK; |
7 | 2712 } |
2713 | |
2714 /* | |
671 | 2715 * Close window "win" in tab page "tp", which is not the current tab page. |
3535 | 2716 * This may be the last window in that tab page and result in closing the tab, |
671 | 2717 * thus "tp" may become invalid! |
856 | 2718 * Caller must check if buffer is hidden and whether the tabline needs to be |
2719 * updated. | |
671 | 2720 */ |
2721 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2722 win_close_othertab(win_T *win, int free_buf, tabpage_T *tp) |
671 | 2723 { |
2724 win_T *wp; | |
2725 int dir; | |
2726 tabpage_T *ptp = NULL; | |
2191 | 2727 int free_tp = FALSE; |
671 | 2728 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2729 // Get here with win->w_buffer == NULL when win_close() detects the tab |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2730 // page changed. |
10106
58e6dd1d8be3
commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents:
10082
diff
changeset
|
2731 if (win->w_closing || (win->w_buffer != NULL |
58e6dd1d8be3
commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents:
10082
diff
changeset
|
2732 && win->w_buffer->b_locked > 0)) |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2733 return; // window is already being closed |
3570 | 2734 |
10076
bc30991c3e98
commit https://github.com/vim/vim/commit/11fbc2866ccc11b4dd1726abdaf582a78ef3f743
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2735 if (win->w_buffer != NULL) |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2736 // Close the link to the buffer. |
18886
050f5eaa9e50
patch 8.2.0004: get E685 and E931 if buffer reload is interrupted
Bram Moolenaar <Bram@vim.org>
parents:
18816
diff
changeset
|
2737 close_buffer(win, win->w_buffer, free_buf ? DOBUF_UNLOAD : 0, |
050f5eaa9e50
patch 8.2.0004: get E685 and E931 if buffer reload is interrupted
Bram Moolenaar <Bram@vim.org>
parents:
18816
diff
changeset
|
2738 FALSE, FALSE); |
671 | 2739 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2740 // Careful: Autocommands may have closed the tab page or made it the |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2741 // current tab page. |
671 | 2742 for (ptp = first_tabpage; ptp != NULL && ptp != tp; ptp = ptp->tp_next) |
2743 ; | |
672 | 2744 if (ptp == NULL || tp == curtab) |
671 | 2745 return; |
2746 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2747 // Autocommands may have closed the window already. |
671 | 2748 for (wp = tp->tp_firstwin; wp != NULL && wp != win; wp = wp->w_next) |
2749 ; | |
2750 if (wp == NULL) | |
2751 return; | |
2752 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2753 // When closing the last window in a tab page remove the tab page. |
7009 | 2754 if (tp->tp_firstwin == tp->tp_lastwin) |
671 | 2755 { |
2756 if (tp == first_tabpage) | |
2757 first_tabpage = tp->tp_next; | |
2758 else | |
2759 { | |
2760 for (ptp = first_tabpage; ptp != NULL && ptp->tp_next != tp; | |
2761 ptp = ptp->tp_next) | |
2762 ; | |
2763 if (ptp == NULL) | |
2764 { | |
10359
66f1b5bf3fa6
commit https://github.com/vim/vim/commit/95f096030ed1a8afea028f2ea295d6f6a70f466f
Christian Brabandt <cb@256bit.org>
parents:
10357
diff
changeset
|
2765 internal_error("win_close_othertab()"); |
671 | 2766 return; |
2767 } | |
2768 ptp->tp_next = tp->tp_next; | |
2769 } | |
2191 | 2770 free_tp = TRUE; |
2771 } | |
2772 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2773 // Free the memory used for the window. |
2191 | 2774 win_free_mem(win, &dir, tp); |
2775 | |
2776 if (free_tp) | |
847 | 2777 free_tabpage(tp); |
671 | 2778 } |
2779 | |
2780 /* | |
355 | 2781 * Free the memory used for a window. |
2782 * Returns a pointer to the window that got the freed up space. | |
2783 */ | |
2784 static win_T * | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2785 win_free_mem( |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2786 win_T *win, |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2787 int *dirp, // set to 'v' or 'h' for direction if 'ea' |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2788 tabpage_T *tp) // tab page "win" is in, NULL for current |
355 | 2789 { |
2790 frame_T *frp; | |
2791 win_T *wp; | |
22399
75513701ddd2
patch 8.2.1748: closing split window in other tab may cause a crash
Bram Moolenaar <Bram@vim.org>
parents:
21727
diff
changeset
|
2792 tabpage_T *win_tp = tp == NULL ? curtab : tp; |
355 | 2793 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2794 // Remove the window and its frame from the tree of frames. |
355 | 2795 frp = win->w_frame; |
671 | 2796 wp = winframe_remove(win, dirp, tp); |
355 | 2797 vim_free(frp); |
671 | 2798 win_free(win, tp); |
355 | 2799 |
22399
75513701ddd2
patch 8.2.1748: closing split window in other tab may cause a crash
Bram Moolenaar <Bram@vim.org>
parents:
21727
diff
changeset
|
2800 // When deleting the current window in the tab, select a new current |
75513701ddd2
patch 8.2.1748: closing split window in other tab may cause a crash
Bram Moolenaar <Bram@vim.org>
parents:
21727
diff
changeset
|
2801 // window. |
75513701ddd2
patch 8.2.1748: closing split window in other tab may cause a crash
Bram Moolenaar <Bram@vim.org>
parents:
21727
diff
changeset
|
2802 if (win == win_tp->tp_curwin) |
75513701ddd2
patch 8.2.1748: closing split window in other tab may cause a crash
Bram Moolenaar <Bram@vim.org>
parents:
21727
diff
changeset
|
2803 win_tp->tp_curwin = wp; |
819 | 2804 |
355 | 2805 return wp; |
2806 } | |
2807 | |
2808 #if defined(EXITFREE) || defined(PROTO) | |
2809 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2810 win_free_all(void) |
355 | 2811 { |
2812 int dummy; | |
2813 | |
671 | 2814 while (first_tabpage->tp_next != NULL) |
2815 tabpage_close(TRUE); | |
2816 | |
1906 | 2817 if (aucmd_win != NULL) |
2818 { | |
2819 (void)win_free_mem(aucmd_win, &dummy, NULL); | |
2820 aucmd_win = NULL; | |
2821 } | |
1918 | 2822 |
2823 while (firstwin != NULL) | |
2824 (void)win_free_mem(firstwin, &dummy, NULL); | |
6060 | 2825 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2826 // No window should be used after this. Set curwin to NULL to crash |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2827 // instead of using freed memory. |
6060 | 2828 curwin = NULL; |
355 | 2829 } |
2830 #endif | |
2831 | |
2832 /* | |
7 | 2833 * Remove a window and its frame from the tree of frames. |
2834 * Returns a pointer to the window that got the freed up space. | |
2835 */ | |
1906 | 2836 win_T * |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2837 winframe_remove( |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2838 win_T *win, |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2839 int *dirp UNUSED, // set to 'v' or 'h' for direction if 'ea' |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2840 tabpage_T *tp) // tab page "win" is in, NULL for current |
7 | 2841 { |
2842 frame_T *frp, *frp2, *frp3; | |
2843 frame_T *frp_close = win->w_frame; | |
2844 win_T *wp; | |
2845 | |
2846 /* | |
671 | 2847 * If there is only one window there is nothing to remove. |
2848 */ | |
10349
cf988222b150
commit https://github.com/vim/vim/commit/a1f4cb93ba50ea9e40cd4b1f5592b8a6d1398660
Christian Brabandt <cb@256bit.org>
parents:
10106
diff
changeset
|
2849 if (tp == NULL ? ONE_WINDOW : tp->tp_firstwin == tp->tp_lastwin) |
671 | 2850 return NULL; |
2851 | |
2852 /* | |
7 | 2853 * Remove the window from its frame. |
2854 */ | |
671 | 2855 frp2 = win_altframe(win, tp); |
7 | 2856 wp = frame2win(frp2); |
2857 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2858 // Remove this frame from the list of frames. |
7 | 2859 frame_remove(frp_close); |
2860 | |
2861 if (frp_close->fr_parent->fr_layout == FR_COL) | |
2862 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2863 // When 'winfixheight' is set, try to find another frame in the column |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2864 // (as close to the closed frame as possible) to distribute the height |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2865 // to. |
1346 | 2866 if (frp2->fr_win != NULL && frp2->fr_win->w_p_wfh) |
2867 { | |
2868 frp = frp_close->fr_prev; | |
2869 frp3 = frp_close->fr_next; | |
2870 while (frp != NULL || frp3 != NULL) | |
2871 { | |
2872 if (frp != NULL) | |
2873 { | |
16166
a3284dd27de6
patch 8.1.1088: height of quickfix window not retained with vertical split
Bram Moolenaar <Bram@vim.org>
parents:
16019
diff
changeset
|
2874 if (!frame_fixed_height(frp)) |
1346 | 2875 { |
2876 frp2 = frp; | |
16166
a3284dd27de6
patch 8.1.1088: height of quickfix window not retained with vertical split
Bram Moolenaar <Bram@vim.org>
parents:
16019
diff
changeset
|
2877 wp = frame2win(frp2); |
1346 | 2878 break; |
2879 } | |
2880 frp = frp->fr_prev; | |
2881 } | |
2882 if (frp3 != NULL) | |
2883 { | |
2884 if (frp3->fr_win != NULL && !frp3->fr_win->w_p_wfh) | |
2885 { | |
2886 frp2 = frp3; | |
2887 wp = frp3->fr_win; | |
2888 break; | |
2889 } | |
2890 frp3 = frp3->fr_next; | |
2891 } | |
2892 } | |
2893 } | |
7 | 2894 frame_new_height(frp2, frp2->fr_height + frp_close->fr_height, |
2895 frp2 == frp_close->fr_next ? TRUE : FALSE, FALSE); | |
2896 *dirp = 'v'; | |
2897 } | |
2898 else | |
2899 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2900 // When 'winfixwidth' is set, try to find another frame in the column |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2901 // (as close to the closed frame as possible) to distribute the width |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2902 // to. |
1346 | 2903 if (frp2->fr_win != NULL && frp2->fr_win->w_p_wfw) |
2904 { | |
2905 frp = frp_close->fr_prev; | |
2906 frp3 = frp_close->fr_next; | |
2907 while (frp != NULL || frp3 != NULL) | |
2908 { | |
2909 if (frp != NULL) | |
2910 { | |
16166
a3284dd27de6
patch 8.1.1088: height of quickfix window not retained with vertical split
Bram Moolenaar <Bram@vim.org>
parents:
16019
diff
changeset
|
2911 if (!frame_fixed_width(frp)) |
1346 | 2912 { |
2913 frp2 = frp; | |
16166
a3284dd27de6
patch 8.1.1088: height of quickfix window not retained with vertical split
Bram Moolenaar <Bram@vim.org>
parents:
16019
diff
changeset
|
2914 wp = frame2win(frp2); |
1346 | 2915 break; |
2916 } | |
2917 frp = frp->fr_prev; | |
2918 } | |
2919 if (frp3 != NULL) | |
2920 { | |
2921 if (frp3->fr_win != NULL && !frp3->fr_win->w_p_wfw) | |
2922 { | |
2923 frp2 = frp3; | |
2924 wp = frp3->fr_win; | |
2925 break; | |
2926 } | |
2927 frp3 = frp3->fr_next; | |
2928 } | |
2929 } | |
2930 } | |
7 | 2931 frame_new_width(frp2, frp2->fr_width + frp_close->fr_width, |
779 | 2932 frp2 == frp_close->fr_next ? TRUE : FALSE, FALSE); |
7 | 2933 *dirp = 'h'; |
2934 } | |
2935 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2936 // If rows/columns go to a window below/right its positions need to be |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2937 // updated. Can only be done after the sizes have been updated. |
7 | 2938 if (frp2 == frp_close->fr_next) |
2939 { | |
2940 int row = win->w_winrow; | |
12513
3ca08bf99396
patch 8.0.1135: W_WINCOL() is always the same
Christian Brabandt <cb@256bit.org>
parents:
12491
diff
changeset
|
2941 int col = win->w_wincol; |
7 | 2942 |
2943 frame_comp_pos(frp2, &row, &col); | |
2944 } | |
2945 | |
2946 if (frp2->fr_next == NULL && frp2->fr_prev == NULL) | |
2947 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2948 // There is no other frame in this list, move its info to the parent |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2949 // and remove it. |
7 | 2950 frp2->fr_parent->fr_layout = frp2->fr_layout; |
2951 frp2->fr_parent->fr_child = frp2->fr_child; | |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
2952 FOR_ALL_FRAMES(frp, frp2->fr_child) |
7 | 2953 frp->fr_parent = frp2->fr_parent; |
2954 frp2->fr_parent->fr_win = frp2->fr_win; | |
2955 if (frp2->fr_win != NULL) | |
2956 frp2->fr_win->w_frame = frp2->fr_parent; | |
2957 frp = frp2->fr_parent; | |
13144
20fb8c711050
patch 8.0.1446: acessing freed memory after window command in auto command
Christian Brabandt <cb@256bit.org>
parents:
13103
diff
changeset
|
2958 if (topframe->fr_child == frp2) |
20fb8c711050
patch 8.0.1446: acessing freed memory after window command in auto command
Christian Brabandt <cb@256bit.org>
parents:
13103
diff
changeset
|
2959 topframe->fr_child = frp; |
7 | 2960 vim_free(frp2); |
2961 | |
2962 frp2 = frp->fr_parent; | |
2963 if (frp2 != NULL && frp2->fr_layout == frp->fr_layout) | |
2964 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2965 // The frame above the parent has the same layout, have to merge |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2966 // the frames into this list. |
7 | 2967 if (frp2->fr_child == frp) |
2968 frp2->fr_child = frp->fr_child; | |
2969 frp->fr_child->fr_prev = frp->fr_prev; | |
2970 if (frp->fr_prev != NULL) | |
2971 frp->fr_prev->fr_next = frp->fr_child; | |
2972 for (frp3 = frp->fr_child; ; frp3 = frp3->fr_next) | |
2973 { | |
2974 frp3->fr_parent = frp2; | |
2975 if (frp3->fr_next == NULL) | |
2976 { | |
2977 frp3->fr_next = frp->fr_next; | |
2978 if (frp->fr_next != NULL) | |
2979 frp->fr_next->fr_prev = frp3; | |
2980 break; | |
2981 } | |
2982 } | |
13144
20fb8c711050
patch 8.0.1446: acessing freed memory after window command in auto command
Christian Brabandt <cb@256bit.org>
parents:
13103
diff
changeset
|
2983 if (topframe->fr_child == frp) |
20fb8c711050
patch 8.0.1446: acessing freed memory after window command in auto command
Christian Brabandt <cb@256bit.org>
parents:
13103
diff
changeset
|
2984 topframe->fr_child = frp2; |
7 | 2985 vim_free(frp); |
2986 } | |
2987 } | |
2988 | |
2989 return wp; | |
2990 } | |
2991 | |
2992 /* | |
13837
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
2993 * Return a pointer to the frame that will receive the empty screen space that |
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
2994 * is left over after "win" is closed. |
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
2995 * |
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
2996 * If 'splitbelow' or 'splitright' is set, the space goes above or to the left |
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
2997 * by default. Otherwise, the free space goes below or to the right. The |
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
2998 * result is that opening a window and then immediately closing it will |
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
2999 * preserve the initial window layout. The 'wfh' and 'wfw' settings are |
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
3000 * respected when possible. |
7 | 3001 */ |
3002 static frame_T * | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3003 win_altframe( |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3004 win_T *win, |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3005 tabpage_T *tp) // tab page "win" is in, NULL for current |
7 | 3006 { |
3007 frame_T *frp; | |
13837
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
3008 frame_T *other_fr, *target_fr; |
7 | 3009 |
10349
cf988222b150
commit https://github.com/vim/vim/commit/a1f4cb93ba50ea9e40cd4b1f5592b8a6d1398660
Christian Brabandt <cb@256bit.org>
parents:
10106
diff
changeset
|
3010 if (tp == NULL ? ONE_WINDOW : tp->tp_firstwin == tp->tp_lastwin) |
667 | 3011 return alt_tabpage()->tp_curwin->w_frame; |
3012 | |
7 | 3013 frp = win->w_frame; |
13837
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
3014 |
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
3015 if (frp->fr_prev == NULL) |
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
3016 return frp->fr_next; |
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
3017 if (frp->fr_next == NULL) |
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
3018 return frp->fr_prev; |
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
3019 |
20049
8c401bc7f32b
patch 8.2.0580: window size wrong if 'ea' is off and 'splitright' is on
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
3020 // By default the next window will get the space that was abandoned by this |
8c401bc7f32b
patch 8.2.0580: window size wrong if 'ea' is off and 'splitright' is on
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
3021 // window |
13837
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
3022 target_fr = frp->fr_next; |
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
3023 other_fr = frp->fr_prev; |
20049
8c401bc7f32b
patch 8.2.0580: window size wrong if 'ea' is off and 'splitright' is on
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
3024 |
8c401bc7f32b
patch 8.2.0580: window size wrong if 'ea' is off and 'splitright' is on
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
3025 // If this is part of a column of windows and 'splitbelow' is true then the |
8c401bc7f32b
patch 8.2.0580: window size wrong if 'ea' is off and 'splitright' is on
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
3026 // previous window will get the space. |
8c401bc7f32b
patch 8.2.0580: window size wrong if 'ea' is off and 'splitright' is on
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
3027 if (frp->fr_parent != NULL && frp->fr_parent->fr_layout == FR_COL && p_sb) |
8c401bc7f32b
patch 8.2.0580: window size wrong if 'ea' is off and 'splitright' is on
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
3028 { |
8c401bc7f32b
patch 8.2.0580: window size wrong if 'ea' is off and 'splitright' is on
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
3029 target_fr = frp->fr_prev; |
8c401bc7f32b
patch 8.2.0580: window size wrong if 'ea' is off and 'splitright' is on
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
3030 other_fr = frp->fr_next; |
8c401bc7f32b
patch 8.2.0580: window size wrong if 'ea' is off and 'splitright' is on
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
3031 } |
8c401bc7f32b
patch 8.2.0580: window size wrong if 'ea' is off and 'splitright' is on
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
3032 |
8c401bc7f32b
patch 8.2.0580: window size wrong if 'ea' is off and 'splitright' is on
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
3033 // If this is part of a row of windows, and 'splitright' is true then the |
8c401bc7f32b
patch 8.2.0580: window size wrong if 'ea' is off and 'splitright' is on
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
3034 // previous window will get the space. |
8c401bc7f32b
patch 8.2.0580: window size wrong if 'ea' is off and 'splitright' is on
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
3035 if (frp->fr_parent != NULL && frp->fr_parent->fr_layout == FR_ROW && p_spr) |
13837
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
3036 { |
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
3037 target_fr = frp->fr_prev; |
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
3038 other_fr = frp->fr_next; |
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
3039 } |
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
3040 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3041 // If 'wfh' or 'wfw' is set for the target and not for the alternate |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3042 // window, reverse the selection. |
355 | 3043 if (frp->fr_parent != NULL && frp->fr_parent->fr_layout == FR_ROW) |
13837
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
3044 { |
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
3045 if (frame_fixed_width(target_fr) && !frame_fixed_width(other_fr)) |
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
3046 target_fr = other_fr; |
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
3047 } |
7 | 3048 else |
13837
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
3049 { |
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
3050 if (frame_fixed_height(target_fr) && !frame_fixed_height(other_fr)) |
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
3051 target_fr = other_fr; |
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
3052 } |
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
3053 |
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
3054 return target_fr; |
7 | 3055 } |
3056 | |
3057 /* | |
667 | 3058 * Return the tabpage that will be used if the current one is closed. |
3059 */ | |
3060 static tabpage_T * | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3061 alt_tabpage(void) |
667 | 3062 { |
672 | 3063 tabpage_T *tp; |
3064 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3065 // Use the next tab page if possible. |
682 | 3066 if (curtab->tp_next != NULL) |
672 | 3067 return curtab->tp_next; |
3068 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3069 // Find the last but one tab page. |
682 | 3070 for (tp = first_tabpage; tp->tp_next != curtab; tp = tp->tp_next) |
3071 ; | |
674 | 3072 return tp; |
667 | 3073 } |
3074 | |
3075 /* | |
7 | 3076 * Find the left-upper window in frame "frp". |
3077 */ | |
3078 static win_T * | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3079 frame2win(frame_T *frp) |
7 | 3080 { |
3081 while (frp->fr_win == NULL) | |
3082 frp = frp->fr_child; | |
3083 return frp->fr_win; | |
3084 } | |
3085 | |
3086 /* | |
3087 * Return TRUE if frame "frp" contains window "wp". | |
3088 */ | |
3089 static int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3090 frame_has_win(frame_T *frp, win_T *wp) |
7 | 3091 { |
3092 frame_T *p; | |
3093 | |
3094 if (frp->fr_layout == FR_LEAF) | |
3095 return frp->fr_win == wp; | |
3096 | |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
3097 FOR_ALL_FRAMES(p, frp->fr_child) |
7 | 3098 if (frame_has_win(p, wp)) |
3099 return TRUE; | |
3100 return FALSE; | |
3101 } | |
3102 | |
3103 /* | |
3104 * Set a new height for a frame. Recursively sets the height for contained | |
3105 * frames and windows. Caller must take care of positions. | |
3106 */ | |
3107 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3108 frame_new_height( |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3109 frame_T *topfrp, |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3110 int height, |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3111 int topfirst, // resize topmost contained frame first |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3112 int wfh) // obey 'winfixheight' when there is a choice; |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3113 // may cause the height not to be set |
7 | 3114 { |
3115 frame_T *frp; | |
3116 int extra_lines; | |
3117 int h; | |
3118 | |
3119 if (topfrp->fr_win != NULL) | |
3120 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3121 // Simple case: just one window. |
7 | 3122 win_new_height(topfrp->fr_win, |
12491
7ab796b041bd
patch 8.0.1125: wrong window height when splitting window with window toolbar
Christian Brabandt <cb@256bit.org>
parents:
12487
diff
changeset
|
3123 height - topfrp->fr_win->w_status_height |
12916
af2e0401eb8c
patch 8.0.1334: splitting a window with a WinBar damages window layout
Christian Brabandt <cb@256bit.org>
parents:
12910
diff
changeset
|
3124 - WINBAR_HEIGHT(topfrp->fr_win)); |
7 | 3125 } |
3126 else if (topfrp->fr_layout == FR_ROW) | |
3127 { | |
3128 do | |
3129 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3130 // All frames in this row get the same new height. |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
3131 FOR_ALL_FRAMES(frp, topfrp->fr_child) |
7 | 3132 { |
3133 frame_new_height(frp, height, topfirst, wfh); | |
3134 if (frp->fr_height > height) | |
3135 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3136 // Could not fit the windows, make the whole row higher. |
7 | 3137 height = frp->fr_height; |
3138 break; | |
3139 } | |
3140 } | |
3141 } | |
3142 while (frp != NULL); | |
3143 } | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3144 else // fr_layout == FR_COL |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3145 { |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3146 // Complicated case: Resize a column of frames. Resize the bottom |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3147 // frame first, frames above that when needed. |
7 | 3148 |
3149 frp = topfrp->fr_child; | |
3150 if (wfh) | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3151 // Advance past frames with one window with 'wfh' set. |
7 | 3152 while (frame_fixed_height(frp)) |
3153 { | |
3154 frp = frp->fr_next; | |
3155 if (frp == NULL) | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3156 return; // no frame without 'wfh', give up |
7 | 3157 } |
3158 if (!topfirst) | |
3159 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3160 // Find the bottom frame of this column |
7 | 3161 while (frp->fr_next != NULL) |
3162 frp = frp->fr_next; | |
3163 if (wfh) | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3164 // Advance back for frames with one window with 'wfh' set. |
7 | 3165 while (frame_fixed_height(frp)) |
3166 frp = frp->fr_prev; | |
3167 } | |
3168 | |
3169 extra_lines = height - topfrp->fr_height; | |
3170 if (extra_lines < 0) | |
3171 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3172 // reduce height of contained frames, bottom or top frame first |
7 | 3173 while (frp != NULL) |
3174 { | |
3175 h = frame_minheight(frp, NULL); | |
3176 if (frp->fr_height + extra_lines < h) | |
3177 { | |
3178 extra_lines += frp->fr_height - h; | |
3179 frame_new_height(frp, h, topfirst, wfh); | |
3180 } | |
3181 else | |
3182 { | |
3183 frame_new_height(frp, frp->fr_height + extra_lines, | |
3184 topfirst, wfh); | |
3185 break; | |
3186 } | |
3187 if (topfirst) | |
3188 { | |
3189 do | |
3190 frp = frp->fr_next; | |
3191 while (wfh && frp != NULL && frame_fixed_height(frp)); | |
3192 } | |
3193 else | |
3194 { | |
3195 do | |
3196 frp = frp->fr_prev; | |
3197 while (wfh && frp != NULL && frame_fixed_height(frp)); | |
3198 } | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3199 // Increase "height" if we could not reduce enough frames. |
7 | 3200 if (frp == NULL) |
3201 height -= extra_lines; | |
3202 } | |
3203 } | |
3204 else if (extra_lines > 0) | |
3205 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3206 // increase height of bottom or top frame |
7 | 3207 frame_new_height(frp, frp->fr_height + extra_lines, topfirst, wfh); |
3208 } | |
3209 } | |
3210 topfrp->fr_height = height; | |
3211 } | |
3212 | |
3213 /* | |
3214 * Return TRUE if height of frame "frp" should not be changed because of | |
3215 * the 'winfixheight' option. | |
3216 */ | |
3217 static int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3218 frame_fixed_height(frame_T *frp) |
7 | 3219 { |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3220 // frame with one window: fixed height if 'winfixheight' set. |
7 | 3221 if (frp->fr_win != NULL) |
3222 return frp->fr_win->w_p_wfh; | |
3223 | |
3224 if (frp->fr_layout == FR_ROW) | |
3225 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3226 // The frame is fixed height if one of the frames in the row is fixed |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3227 // height. |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
3228 FOR_ALL_FRAMES(frp, frp->fr_child) |
7 | 3229 if (frame_fixed_height(frp)) |
3230 return TRUE; | |
3231 return FALSE; | |
3232 } | |
3233 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3234 // frp->fr_layout == FR_COL: The frame is fixed height if all of the |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3235 // frames in the row are fixed height. |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
3236 FOR_ALL_FRAMES(frp, frp->fr_child) |
7 | 3237 if (!frame_fixed_height(frp)) |
3238 return FALSE; | |
3239 return TRUE; | |
3240 } | |
3241 | |
3242 /* | |
779 | 3243 * Return TRUE if width of frame "frp" should not be changed because of |
3244 * the 'winfixwidth' option. | |
3245 */ | |
3246 static int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3247 frame_fixed_width(frame_T *frp) |
779 | 3248 { |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3249 // frame with one window: fixed width if 'winfixwidth' set. |
779 | 3250 if (frp->fr_win != NULL) |
3251 return frp->fr_win->w_p_wfw; | |
3252 | |
3253 if (frp->fr_layout == FR_COL) | |
3254 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3255 // The frame is fixed width if one of the frames in the row is fixed |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3256 // width. |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
3257 FOR_ALL_FRAMES(frp, frp->fr_child) |
779 | 3258 if (frame_fixed_width(frp)) |
3259 return TRUE; | |
3260 return FALSE; | |
3261 } | |
3262 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3263 // frp->fr_layout == FR_ROW: The frame is fixed width if all of the |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3264 // frames in the row are fixed width. |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
3265 FOR_ALL_FRAMES(frp, frp->fr_child) |
779 | 3266 if (!frame_fixed_width(frp)) |
3267 return FALSE; | |
3268 return TRUE; | |
3269 } | |
3270 | |
3271 /* | |
7 | 3272 * Add a status line to windows at the bottom of "frp". |
3273 * Note: Does not check if there is room! | |
3274 */ | |
3275 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3276 frame_add_statusline(frame_T *frp) |
7 | 3277 { |
3278 win_T *wp; | |
3279 | |
3280 if (frp->fr_layout == FR_LEAF) | |
3281 { | |
3282 wp = frp->fr_win; | |
3283 if (wp->w_status_height == 0) | |
3284 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3285 if (wp->w_height > 0) // don't make it negative |
7 | 3286 --wp->w_height; |
3287 wp->w_status_height = STATUS_HEIGHT; | |
3288 } | |
3289 } | |
3290 else if (frp->fr_layout == FR_ROW) | |
3291 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3292 // Handle all the frames in the row. |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
3293 FOR_ALL_FRAMES(frp, frp->fr_child) |
7 | 3294 frame_add_statusline(frp); |
3295 } | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3296 else // frp->fr_layout == FR_COL |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3297 { |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3298 // Only need to handle the last frame in the column. |
7 | 3299 for (frp = frp->fr_child; frp->fr_next != NULL; frp = frp->fr_next) |
3300 ; | |
3301 frame_add_statusline(frp); | |
3302 } | |
3303 } | |
3304 | |
3305 /* | |
3306 * Set width of a frame. Handles recursively going through contained frames. | |
3307 * May remove separator line for windows at the right side (for win_close()). | |
3308 */ | |
3309 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3310 frame_new_width( |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3311 frame_T *topfrp, |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3312 int width, |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3313 int leftfirst, // resize leftmost contained frame first |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3314 int wfw) // obey 'winfixwidth' when there is a choice; |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3315 // may cause the width not to be set |
7 | 3316 { |
3317 frame_T *frp; | |
3318 int extra_cols; | |
3319 int w; | |
3320 win_T *wp; | |
3321 | |
3322 if (topfrp->fr_layout == FR_LEAF) | |
3323 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3324 // Simple case: just one window. |
7 | 3325 wp = topfrp->fr_win; |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3326 // Find out if there are any windows right of this one. |
7 | 3327 for (frp = topfrp; frp->fr_parent != NULL; frp = frp->fr_parent) |
3328 if (frp->fr_parent->fr_layout == FR_ROW && frp->fr_next != NULL) | |
3329 break; | |
3330 if (frp->fr_parent == NULL) | |
3331 wp->w_vsep_width = 0; | |
3332 win_new_width(wp, width - wp->w_vsep_width); | |
3333 } | |
3334 else if (topfrp->fr_layout == FR_COL) | |
3335 { | |
779 | 3336 do |
3337 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3338 // All frames in this column get the same new width. |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
3339 FOR_ALL_FRAMES(frp, topfrp->fr_child) |
779 | 3340 { |
3341 frame_new_width(frp, width, leftfirst, wfw); | |
3342 if (frp->fr_width > width) | |
3343 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3344 // Could not fit the windows, make whole column wider. |
779 | 3345 width = frp->fr_width; |
3346 break; | |
3347 } | |
3348 } | |
3349 } while (frp != NULL); | |
7 | 3350 } |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3351 else // fr_layout == FR_ROW |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3352 { |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3353 // Complicated case: Resize a row of frames. Resize the rightmost |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3354 // frame first, frames left of it when needed. |
7 | 3355 |
3356 frp = topfrp->fr_child; | |
779 | 3357 if (wfw) |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3358 // Advance past frames with one window with 'wfw' set. |
779 | 3359 while (frame_fixed_width(frp)) |
3360 { | |
3361 frp = frp->fr_next; | |
3362 if (frp == NULL) | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3363 return; // no frame without 'wfw', give up |
779 | 3364 } |
7 | 3365 if (!leftfirst) |
779 | 3366 { |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3367 // Find the rightmost frame of this row |
7 | 3368 while (frp->fr_next != NULL) |
3369 frp = frp->fr_next; | |
779 | 3370 if (wfw) |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3371 // Advance back for frames with one window with 'wfw' set. |
779 | 3372 while (frame_fixed_width(frp)) |
3373 frp = frp->fr_prev; | |
3374 } | |
7 | 3375 |
3376 extra_cols = width - topfrp->fr_width; | |
3377 if (extra_cols < 0) | |
3378 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3379 // reduce frame width, rightmost frame first |
7 | 3380 while (frp != NULL) |
3381 { | |
3382 w = frame_minwidth(frp, NULL); | |
3383 if (frp->fr_width + extra_cols < w) | |
3384 { | |
3385 extra_cols += frp->fr_width - w; | |
779 | 3386 frame_new_width(frp, w, leftfirst, wfw); |
7 | 3387 } |
3388 else | |
3389 { | |
779 | 3390 frame_new_width(frp, frp->fr_width + extra_cols, |
3391 leftfirst, wfw); | |
7 | 3392 break; |
3393 } | |
3394 if (leftfirst) | |
779 | 3395 { |
3396 do | |
3397 frp = frp->fr_next; | |
3398 while (wfw && frp != NULL && frame_fixed_width(frp)); | |
3399 } | |
7 | 3400 else |
779 | 3401 { |
3402 do | |
3403 frp = frp->fr_prev; | |
3404 while (wfw && frp != NULL && frame_fixed_width(frp)); | |
3405 } | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3406 // Increase "width" if we could not reduce enough frames. |
779 | 3407 if (frp == NULL) |
3408 width -= extra_cols; | |
7 | 3409 } |
3410 } | |
3411 else if (extra_cols > 0) | |
3412 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3413 // increase width of rightmost frame |
779 | 3414 frame_new_width(frp, frp->fr_width + extra_cols, leftfirst, wfw); |
7 | 3415 } |
3416 } | |
3417 topfrp->fr_width = width; | |
3418 } | |
3419 | |
3420 /* | |
3421 * Add the vertical separator to windows at the right side of "frp". | |
3422 * Note: Does not check if there is room! | |
3423 */ | |
3424 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3425 frame_add_vsep(frame_T *frp) |
7 | 3426 { |
3427 win_T *wp; | |
3428 | |
3429 if (frp->fr_layout == FR_LEAF) | |
3430 { | |
3431 wp = frp->fr_win; | |
3432 if (wp->w_vsep_width == 0) | |
3433 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3434 if (wp->w_width > 0) // don't make it negative |
7 | 3435 --wp->w_width; |
3436 wp->w_vsep_width = 1; | |
3437 } | |
3438 } | |
3439 else if (frp->fr_layout == FR_COL) | |
3440 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3441 // Handle all the frames in the column. |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
3442 FOR_ALL_FRAMES(frp, frp->fr_child) |
7 | 3443 frame_add_vsep(frp); |
3444 } | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3445 else // frp->fr_layout == FR_ROW |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3446 { |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3447 // Only need to handle the last frame in the row. |
7 | 3448 frp = frp->fr_child; |
3449 while (frp->fr_next != NULL) | |
3450 frp = frp->fr_next; | |
3451 frame_add_vsep(frp); | |
3452 } | |
3453 } | |
3454 | |
3455 /* | |
3456 * Set frame width from the window it contains. | |
3457 */ | |
3458 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3459 frame_fix_width(win_T *wp) |
7 | 3460 { |
3461 wp->w_frame->fr_width = wp->w_width + wp->w_vsep_width; | |
3462 } | |
3463 | |
3464 /* | |
3465 * Set frame height from the window it contains. | |
3466 */ | |
3467 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3468 frame_fix_height(win_T *wp) |
7 | 3469 { |
12998
dd734ee3e2fe
patch 8.0.1375: window size wrong after maximizing with WinBar
Christian Brabandt <cb@256bit.org>
parents:
12916
diff
changeset
|
3470 wp->w_frame->fr_height = VISIBLE_HEIGHT(wp) + wp->w_status_height; |
7 | 3471 } |
3472 | |
3473 /* | |
3474 * Compute the minimal height for frame "topfrp". | |
3475 * Uses the 'winminheight' option. | |
3476 * When "next_curwin" isn't NULL, use p_wh for this window. | |
3477 * When "next_curwin" is NOWIN, don't use at least one line for the current | |
3478 * window. | |
3479 */ | |
3480 static int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3481 frame_minheight(frame_T *topfrp, win_T *next_curwin) |
7 | 3482 { |
3483 frame_T *frp; | |
3484 int m; | |
3485 int n; | |
3486 | |
3487 if (topfrp->fr_win != NULL) | |
3488 { | |
3489 if (topfrp->fr_win == next_curwin) | |
3490 m = p_wh + topfrp->fr_win->w_status_height; | |
3491 else | |
3492 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3493 // window: minimal height of the window plus status line |
7 | 3494 m = p_wmh + topfrp->fr_win->w_status_height; |
12998
dd734ee3e2fe
patch 8.0.1375: window size wrong after maximizing with WinBar
Christian Brabandt <cb@256bit.org>
parents:
12916
diff
changeset
|
3495 if (topfrp->fr_win == curwin && next_curwin == NULL) |
dd734ee3e2fe
patch 8.0.1375: window size wrong after maximizing with WinBar
Christian Brabandt <cb@256bit.org>
parents:
12916
diff
changeset
|
3496 { |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3497 // Current window is minimal one line high and WinBar is |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3498 // visible. |
12998
dd734ee3e2fe
patch 8.0.1375: window size wrong after maximizing with WinBar
Christian Brabandt <cb@256bit.org>
parents:
12916
diff
changeset
|
3499 if (p_wmh == 0) |
dd734ee3e2fe
patch 8.0.1375: window size wrong after maximizing with WinBar
Christian Brabandt <cb@256bit.org>
parents:
12916
diff
changeset
|
3500 ++m; |
dd734ee3e2fe
patch 8.0.1375: window size wrong after maximizing with WinBar
Christian Brabandt <cb@256bit.org>
parents:
12916
diff
changeset
|
3501 m += WINBAR_HEIGHT(curwin); |
dd734ee3e2fe
patch 8.0.1375: window size wrong after maximizing with WinBar
Christian Brabandt <cb@256bit.org>
parents:
12916
diff
changeset
|
3502 } |
7 | 3503 } |
3504 } | |
3505 else if (topfrp->fr_layout == FR_ROW) | |
3506 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3507 // get the minimal height from each frame in this row |
7 | 3508 m = 0; |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
3509 FOR_ALL_FRAMES(frp, topfrp->fr_child) |
7 | 3510 { |
3511 n = frame_minheight(frp, next_curwin); | |
3512 if (n > m) | |
3513 m = n; | |
3514 } | |
3515 } | |
3516 else | |
3517 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3518 // Add up the minimal heights for all frames in this column. |
7 | 3519 m = 0; |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
3520 FOR_ALL_FRAMES(frp, topfrp->fr_child) |
7 | 3521 m += frame_minheight(frp, next_curwin); |
3522 } | |
3523 | |
3524 return m; | |
3525 } | |
3526 | |
3527 /* | |
3528 * Compute the minimal width for frame "topfrp". | |
3529 * When "next_curwin" isn't NULL, use p_wiw for this window. | |
3530 * When "next_curwin" is NOWIN, don't use at least one column for the current | |
3531 * window. | |
3532 */ | |
3533 static int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3534 frame_minwidth( |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3535 frame_T *topfrp, |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3536 win_T *next_curwin) // use p_wh and p_wiw for next_curwin |
7 | 3537 { |
3538 frame_T *frp; | |
3539 int m, n; | |
3540 | |
3541 if (topfrp->fr_win != NULL) | |
3542 { | |
3543 if (topfrp->fr_win == next_curwin) | |
3544 m = p_wiw + topfrp->fr_win->w_vsep_width; | |
3545 else | |
3546 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3547 // window: minimal width of the window plus separator column |
7 | 3548 m = p_wmw + topfrp->fr_win->w_vsep_width; |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3549 // Current window is minimal one column wide |
7 | 3550 if (p_wmw == 0 && topfrp->fr_win == curwin && next_curwin == NULL) |
3551 ++m; | |
3552 } | |
3553 } | |
3554 else if (topfrp->fr_layout == FR_COL) | |
3555 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3556 // get the minimal width from each frame in this column |
7 | 3557 m = 0; |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
3558 FOR_ALL_FRAMES(frp, topfrp->fr_child) |
7 | 3559 { |
3560 n = frame_minwidth(frp, next_curwin); | |
3561 if (n > m) | |
3562 m = n; | |
3563 } | |
3564 } | |
3565 else | |
3566 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3567 // Add up the minimal widths for all frames in this row. |
7 | 3568 m = 0; |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
3569 FOR_ALL_FRAMES(frp, topfrp->fr_child) |
7 | 3570 m += frame_minwidth(frp, next_curwin); |
3571 } | |
3572 | |
3573 return m; | |
3574 } | |
3575 | |
3576 | |
3577 /* | |
3578 * Try to close all windows except current one. | |
3579 * Buffers in the other windows become hidden if 'hidden' is set, or '!' is | |
3580 * used and the buffer was modified. | |
3581 * | |
3582 * Used by ":bdel" and ":only". | |
3583 */ | |
3584 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3585 close_others( |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3586 int message, |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3587 int forceit) // always hide all other windows |
7 | 3588 { |
3589 win_T *wp; | |
3590 win_T *nextwp; | |
3591 int r; | |
3592 | |
1906 | 3593 if (one_window()) |
7 | 3594 { |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13308
diff
changeset
|
3595 if (message && !autocmd_busy) |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15490
diff
changeset
|
3596 msg(_(m_onlyone)); |
7 | 3597 return; |
3598 } | |
3599 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3600 // Be very careful here: autocommands may change the window layout. |
7 | 3601 for (wp = firstwin; win_valid(wp); wp = nextwp) |
3602 { | |
3603 nextwp = wp->w_next; | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3604 if (wp != curwin) // don't close current window |
7 | 3605 { |
3606 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3607 // Check if it's allowed to abandon this window |
7 | 3608 r = can_abandon(wp->w_buffer, forceit); |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3609 if (!win_valid(wp)) // autocommands messed wp up |
7 | 3610 { |
3611 nextwp = firstwin; | |
3612 continue; | |
3613 } | |
3614 if (!r) | |
3615 { | |
3616 #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) | |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22470
diff
changeset
|
3617 if (message && (p_confirm |
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22470
diff
changeset
|
3618 || (cmdmod.cmod_flags & CMOD_CONFIRM)) && p_write) |
7 | 3619 { |
3620 dialog_changed(wp->w_buffer, FALSE); | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3621 if (!win_valid(wp)) // autocommands messed wp up |
7 | 3622 { |
3623 nextwp = firstwin; | |
3624 continue; | |
3625 } | |
3626 } | |
3627 if (bufIsChanged(wp->w_buffer)) | |
3628 #endif | |
3629 continue; | |
3630 } | |
11957
bc0fee081e1e
patch 8.0.0858: can exit while a terminal is still running a job
Christian Brabandt <cb@256bit.org>
parents:
11800
diff
changeset
|
3631 win_close(wp, !buf_hide(wp->w_buffer) |
bc0fee081e1e
patch 8.0.0858: can exit while a terminal is still running a job
Christian Brabandt <cb@256bit.org>
parents:
11800
diff
changeset
|
3632 && !bufIsChanged(wp->w_buffer)); |
7 | 3633 } |
3634 } | |
3635 | |
10357
59d01e335858
commit https://github.com/vim/vim/commit/459ca563128f2edb7e3bb190090bbb755a56dd55
Christian Brabandt <cb@256bit.org>
parents:
10349
diff
changeset
|
3636 if (message && !ONE_WINDOW) |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15436
diff
changeset
|
3637 emsg(_("E445: Other window contains changes")); |
7 | 3638 } |
3639 | |
17789
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17670
diff
changeset
|
3640 static void |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3641 win_init_empty(win_T *wp) |
1918 | 3642 { |
3643 redraw_win_later(wp, NOT_VALID); | |
3644 wp->w_lines_valid = 0; | |
3645 wp->w_cursor.lnum = 1; | |
3646 wp->w_curswant = wp->w_cursor.col = 0; | |
3647 wp->w_cursor.coladd = 0; | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3648 wp->w_pcmark.lnum = 1; // pcmark not cleared but set to line 1 |
1918 | 3649 wp->w_pcmark.col = 0; |
3650 wp->w_prev_pcmark.lnum = 0; | |
3651 wp->w_prev_pcmark.col = 0; | |
3652 wp->w_topline = 1; | |
7 | 3653 #ifdef FEAT_DIFF |
1918 | 3654 wp->w_topfill = 0; |
3655 #endif | |
3656 wp->w_botline = 2; | |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
3657 #if defined(FEAT_SYN_HL) || defined(FEAT_SPELL) |
3068 | 3658 wp->w_s = &wp->w_buffer->b_s; |
3659 #endif | |
7 | 3660 } |
3661 | |
3662 /* | |
17789
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17670
diff
changeset
|
3663 * Init the current window "curwin". |
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17670
diff
changeset
|
3664 * Called when a new file is being edited. |
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17670
diff
changeset
|
3665 */ |
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17670
diff
changeset
|
3666 void |
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17670
diff
changeset
|
3667 curwin_init(void) |
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17670
diff
changeset
|
3668 { |
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17670
diff
changeset
|
3669 win_init_empty(curwin); |
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17670
diff
changeset
|
3670 } |
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17670
diff
changeset
|
3671 |
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17670
diff
changeset
|
3672 /* |
7 | 3673 * Allocate the first window and put an empty buffer in it. |
3674 * Called from main(). | |
667 | 3675 * Return FAIL when something goes wrong (out of memory). |
7 | 3676 */ |
667 | 3677 int |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3678 win_alloc_first(void) |
7 | 3679 { |
675 | 3680 if (win_alloc_firstwin(NULL) == FAIL) |
667 | 3681 return FAIL; |
3682 | |
672 | 3683 first_tabpage = alloc_tabpage(); |
667 | 3684 if (first_tabpage == NULL) |
3685 return FAIL; | |
3686 first_tabpage->tp_topframe = topframe; | |
672 | 3687 curtab = first_tabpage; |
19155
013f20a3bc6b
patch 8.2.0137: crash when using win_execute() from a new tab
Bram Moolenaar <Bram@vim.org>
parents:
19143
diff
changeset
|
3688 curtab->tp_firstwin = firstwin; |
013f20a3bc6b
patch 8.2.0137: crash when using win_execute() from a new tab
Bram Moolenaar <Bram@vim.org>
parents:
19143
diff
changeset
|
3689 curtab->tp_lastwin = lastwin; |
013f20a3bc6b
patch 8.2.0137: crash when using win_execute() from a new tab
Bram Moolenaar <Bram@vim.org>
parents:
19143
diff
changeset
|
3690 curtab->tp_curwin = curwin; |
1906 | 3691 |
667 | 3692 return OK; |
3693 } | |
3694 | |
1906 | 3695 /* |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
3696 * Allocate and init a window that is not a regular window. |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
3697 * This can only be done after the first window is fully initialized, thus it |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
3698 * can't be in win_alloc_first(). |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
3699 */ |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
3700 win_T * |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
3701 win_alloc_popup_win(void) |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
3702 { |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
3703 win_T *wp; |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
3704 |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
3705 wp = win_alloc(NULL, TRUE); |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
3706 if (wp != NULL) |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
3707 { |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
3708 // We need to initialize options with something, using the current |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
3709 // window makes most sense. |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
3710 win_init_some(wp, curwin); |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
3711 |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
3712 RESET_BINDING(wp); |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
3713 new_frame(wp); |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
3714 } |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
3715 return wp; |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
3716 } |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
3717 |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
3718 /* |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
3719 * Initialize window "wp" to display buffer "buf". |
1906 | 3720 */ |
3721 void | |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
3722 win_init_popup_win(win_T *wp, buf_T *buf) |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
3723 { |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
3724 wp->w_buffer = buf; |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
3725 ++buf->b_nwindows; |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
3726 win_init_empty(wp); // set cursor and topline to safe values |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
3727 |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
3728 // Make sure w_localdir and globaldir are NULL to avoid a chdir() in |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
3729 // win_enter_ext(). |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
3730 VIM_CLEAR(wp->w_localdir); |
1906 | 3731 } |
3732 | |
667 | 3733 /* |
675 | 3734 * Allocate the first window or the first window in a new tab page. |
3735 * When "oldwin" is NULL create an empty buffer for it. | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
3736 * When "oldwin" is not NULL copy info from it to the new window. |
667 | 3737 * Return FAIL when something goes wrong (out of memory). |
3738 */ | |
3739 static int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3740 win_alloc_firstwin(win_T *oldwin) |
667 | 3741 { |
1906 | 3742 curwin = win_alloc(NULL, FALSE); |
675 | 3743 if (oldwin == NULL) |
3744 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3745 // Very first window, need to create an empty buffer for it and |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3746 // initialize from scratch. |
675 | 3747 curbuf = buflist_new(NULL, NULL, 1L, BLN_LISTED); |
3748 if (curwin == NULL || curbuf == NULL) | |
3749 return FAIL; | |
3750 curwin->w_buffer = curbuf; | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2201
diff
changeset
|
3751 #ifdef FEAT_SYN_HL |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2201
diff
changeset
|
3752 curwin->w_s = &(curbuf->b_s); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2201
diff
changeset
|
3753 #endif |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3754 curbuf->b_nwindows = 1; // there is one window |
675 | 3755 curwin->w_alist = &global_alist; |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3756 curwin_init(); // init current window |
675 | 3757 } |
3758 else | |
3759 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3760 // First window in new tab page, initialize it from "oldwin". |
1822 | 3761 win_init(curwin, oldwin, 0); |
675 | 3762 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3763 // We don't want cursor- and scroll-binding in the first window. |
2583 | 3764 RESET_BINDING(curwin); |
675 | 3765 } |
7 | 3766 |
1906 | 3767 new_frame(curwin); |
3768 if (curwin->w_frame == NULL) | |
667 | 3769 return FAIL; |
1906 | 3770 topframe = curwin->w_frame; |
7 | 3771 topframe->fr_width = Columns; |
3772 topframe->fr_height = Rows - p_ch; | |
667 | 3773 |
3774 return OK; | |
3775 } | |
3776 | |
3777 /* | |
1906 | 3778 * Create a frame for window "wp". |
3779 */ | |
3780 static void | |
3781 new_frame(win_T *wp) | |
3782 { | |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16802
diff
changeset
|
3783 frame_T *frp = ALLOC_CLEAR_ONE(frame_T); |
1906 | 3784 |
3785 wp->w_frame = frp; | |
3786 if (frp != NULL) | |
3787 { | |
3788 frp->fr_layout = FR_LEAF; | |
3789 frp->fr_win = wp; | |
3790 } | |
3791 } | |
3792 | |
3793 /* | |
667 | 3794 * Initialize the window and frame size to the maximum. |
3795 */ | |
3796 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3797 win_init_size(void) |
667 | 3798 { |
3799 firstwin->w_height = ROWS_AVAIL; | |
3800 topframe->fr_height = ROWS_AVAIL; | |
3801 firstwin->w_width = Columns; | |
3802 topframe->fr_width = Columns; | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
3803 } |
672 | 3804 |
3805 /* | |
3806 * Allocate a new tabpage_T and init the values. | |
3807 * Returns NULL when out of memory. | |
3808 */ | |
3809 static tabpage_T * | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3810 alloc_tabpage(void) |
672 | 3811 { |
3812 tabpage_T *tp; | |
4287 | 3813 # ifdef FEAT_GUI |
3814 int i; | |
3815 # endif | |
3816 | |
672 | 3817 |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16802
diff
changeset
|
3818 tp = ALLOC_CLEAR_ONE(tabpage_T); |
4287 | 3819 if (tp == NULL) |
3820 return NULL; | |
3821 | |
3822 # ifdef FEAT_EVAL | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3823 // init t: variables |
4287 | 3824 tp->tp_vars = dict_alloc(); |
3825 if (tp->tp_vars == NULL) | |
3826 { | |
3827 vim_free(tp); | |
3828 return NULL; | |
3829 } | |
3830 init_var_dict(tp->tp_vars, &tp->tp_winvar, VAR_SCOPE); | |
3831 # endif | |
3832 | |
788 | 3833 # ifdef FEAT_GUI |
4287 | 3834 for (i = 0; i < 3; i++) |
3835 tp->tp_prev_which_scrollbars[i] = -1; | |
788 | 3836 # endif |
672 | 3837 # ifdef FEAT_DIFF |
4287 | 3838 tp->tp_diff_invalid = TRUE; |
672 | 3839 # endif |
4287 | 3840 tp->tp_ch_used = p_ch; |
3841 | |
672 | 3842 return tp; |
3843 } | |
3844 | |
852 | 3845 void |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3846 free_tabpage(tabpage_T *tp) |
672 | 3847 { |
1906 | 3848 int idx; |
3849 | |
672 | 3850 # ifdef FEAT_DIFF |
3851 diff_clear(tp); | |
3852 # endif | |
18763
49b78d6465e5
patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents:
18590
diff
changeset
|
3853 # ifdef FEAT_PROP_POPUP |
16800
12e3a3afdb6a
patch 8.1.1402: "timer" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents:
16796
diff
changeset
|
3854 while (tp->tp_first_popupwin != NULL) |
20384
42ab4d40e78f
patch 8.2.0747: cannot forcefully close all popups
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
3855 popup_close_tabpage(tp, tp->tp_first_popupwin->w_id, TRUE); |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
3856 #endif |
1906 | 3857 for (idx = 0; idx < SNAP_COUNT; ++idx) |
3858 clear_snapshot(tp, idx); | |
819 | 3859 #ifdef FEAT_EVAL |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3860 vars_clear(&tp->tp_vars->dv_hashtab); // free all t: variables |
4287 | 3861 hash_init(&tp->tp_vars->dv_hashtab); |
3862 unref_var_dict(tp->tp_vars); | |
819 | 3863 #endif |
4401 | 3864 |
21703
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21020
diff
changeset
|
3865 if (tp == lastused_tabpage) |
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21020
diff
changeset
|
3866 lastused_tabpage = NULL; |
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21020
diff
changeset
|
3867 |
16427
8c3a1bd270bb
patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents:
16405
diff
changeset
|
3868 vim_free(tp->tp_localdir); |
20711
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20384
diff
changeset
|
3869 vim_free(tp->tp_prevdir); |
16427
8c3a1bd270bb
patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents:
16405
diff
changeset
|
3870 |
4401 | 3871 #ifdef FEAT_PYTHON |
3872 python_tabpage_free(tp); | |
3873 #endif | |
3874 | |
3875 #ifdef FEAT_PYTHON3 | |
3876 python3_tabpage_free(tp); | |
3877 #endif | |
3878 | |
672 | 3879 vim_free(tp); |
3880 } | |
3881 | |
667 | 3882 /* |
675 | 3883 * Create a new Tab page with one window. |
3884 * It will edit the current buffer, like after ":split". | |
682 | 3885 * When "after" is 0 put it just after the current Tab page. |
3886 * Otherwise put it just before tab page "after". | |
667 | 3887 * Return FAIL or OK. |
3888 */ | |
3889 int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3890 win_new_tabpage(int after) |
667 | 3891 { |
672 | 3892 tabpage_T *tp = curtab; |
21727
860cad58f557
patch 8.2.1413: previous tab page not usable from an Ex command
Bram Moolenaar <Bram@vim.org>
parents:
21723
diff
changeset
|
3893 tabpage_T *prev_tp = curtab; |
667 | 3894 tabpage_T *newtp; |
682 | 3895 int n; |
667 | 3896 |
672 | 3897 newtp = alloc_tabpage(); |
667 | 3898 if (newtp == NULL) |
3899 return FAIL; | |
3900 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3901 // Remember the current windows in this Tab page. |
4354 | 3902 if (leave_tabpage(curbuf, TRUE) == FAIL) |
674 | 3903 { |
3904 vim_free(newtp); | |
3905 return FAIL; | |
3906 } | |
672 | 3907 curtab = newtp; |
667 | 3908 |
16427
8c3a1bd270bb
patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents:
16405
diff
changeset
|
3909 newtp->tp_localdir = (tp->tp_localdir == NULL) |
8c3a1bd270bb
patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents:
16405
diff
changeset
|
3910 ? NULL : vim_strsave(tp->tp_localdir); |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3911 // Create a new empty window. |
675 | 3912 if (win_alloc_firstwin(tp->tp_curwin) == OK) |
667 | 3913 { |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3914 // Make the new Tab page the new topframe. |
682 | 3915 if (after == 1) |
3916 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3917 // New tab page becomes the first one. |
682 | 3918 newtp->tp_next = first_tabpage; |
3919 first_tabpage = newtp; | |
3920 } | |
3921 else | |
3922 { | |
3923 if (after > 0) | |
3924 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3925 // Put new tab page before tab page "after". |
682 | 3926 n = 2; |
3927 for (tp = first_tabpage; tp->tp_next != NULL | |
3928 && n < after; tp = tp->tp_next) | |
3929 ++n; | |
3930 } | |
3931 newtp->tp_next = tp->tp_next; | |
3932 tp->tp_next = newtp; | |
3933 } | |
19155
013f20a3bc6b
patch 8.2.0137: crash when using win_execute() from a new tab
Bram Moolenaar <Bram@vim.org>
parents:
19143
diff
changeset
|
3934 newtp->tp_firstwin = newtp->tp_lastwin = newtp->tp_curwin = curwin; |
013f20a3bc6b
patch 8.2.0137: crash when using win_execute() from a new tab
Bram Moolenaar <Bram@vim.org>
parents:
19143
diff
changeset
|
3935 |
667 | 3936 win_init_size(); |
685 | 3937 firstwin->w_winrow = tabline_height(); |
819 | 3938 win_comp_scroll(curwin); |
667 | 3939 |
3940 newtp->tp_topframe = topframe; | |
671 | 3941 last_status(FALSE); |
815 | 3942 |
21727
860cad58f557
patch 8.2.1413: previous tab page not usable from an Ex command
Bram Moolenaar <Bram@vim.org>
parents:
21723
diff
changeset
|
3943 lastused_tabpage = prev_tp; |
21703
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21020
diff
changeset
|
3944 |
815 | 3945 #if defined(FEAT_GUI) |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3946 // When 'guioptions' includes 'L' or 'R' may have to remove or add |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3947 // scrollbars. Have to update them anyway. |
1906 | 3948 gui_may_update_scrollbars(); |
815 | 3949 #endif |
14035
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
3950 #ifdef FEAT_JOB_CHANNEL |
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
3951 entering_window(curwin); |
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
3952 #endif |
815 | 3953 |
15380
f62d6bd18a49
patch 8.1.0698: clearing the window is used too often
Bram Moolenaar <Bram@vim.org>
parents:
15227
diff
changeset
|
3954 redraw_all_later(NOT_VALID); |
9595
0190d5de215f
commit https://github.com/vim/vim/commit/c917da4b3e8801a255dbefea8e4ed19c1c716dd8
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
3955 apply_autocmds(EVENT_WINNEW, NULL, NULL, FALSE, curbuf); |
4354 | 3956 apply_autocmds(EVENT_WINENTER, NULL, NULL, FALSE, curbuf); |
9595
0190d5de215f
commit https://github.com/vim/vim/commit/c917da4b3e8801a255dbefea8e4ed19c1c716dd8
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
3957 apply_autocmds(EVENT_TABNEW, NULL, NULL, FALSE, curbuf); |
675 | 3958 apply_autocmds(EVENT_TABENTER, NULL, NULL, FALSE, curbuf); |
667 | 3959 return OK; |
3960 } | |
3961 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3962 // Failed, get back the previous Tab page |
4354 | 3963 enter_tabpage(curtab, curbuf, TRUE, TRUE); |
667 | 3964 return FAIL; |
3965 } | |
3966 | |
3967 /* | |
682 | 3968 * Open a new tab page if ":tab cmd" was used. It will edit the same buffer, |
3969 * like with ":split". | |
3970 * Returns OK if a new tab page was created, FAIL otherwise. | |
3971 */ | |
17789
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17670
diff
changeset
|
3972 static int |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3973 may_open_tabpage(void) |
682 | 3974 { |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22470
diff
changeset
|
3975 int n = (cmdmod.cmod_tab == 0) |
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22470
diff
changeset
|
3976 ? postponed_split_tab : cmdmod.cmod_tab; |
1090 | 3977 |
3978 if (n != 0) | |
682 | 3979 { |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22470
diff
changeset
|
3980 cmdmod.cmod_tab = 0; // reset it to avoid doing it twice |
1090 | 3981 postponed_split_tab = 0; |
682 | 3982 return win_new_tabpage(n); |
3983 } | |
3984 return FAIL; | |
3985 } | |
3986 | |
3987 /* | |
672 | 3988 * Create up to "maxcount" tabpages with empty windows. |
3989 * Returns the number of resulting tab pages. | |
667 | 3990 */ |
672 | 3991 int |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3992 make_tabpages(int maxcount) |
667 | 3993 { |
672 | 3994 int count = maxcount; |
3995 int todo; | |
3996 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3997 // Limit to 'tabpagemax' tabs. |
698 | 3998 if (count > p_tpm) |
3999 count = p_tpm; | |
672 | 4000 |
4001 /* | |
4002 * Don't execute autocommands while creating the tab pages. Must do that | |
4003 * when putting the buffers in the windows. | |
4004 */ | |
1410 | 4005 block_autocmds(); |
672 | 4006 |
4007 for (todo = count - 1; todo > 0; --todo) | |
682 | 4008 if (win_new_tabpage(0) == FAIL) |
667 | 4009 break; |
672 | 4010 |
1410 | 4011 unblock_autocmds(); |
672 | 4012 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4013 // return actual number of tab pages |
672 | 4014 return (count - todo); |
667 | 4015 } |
4016 | |
4017 /* | |
671 | 4018 * Return TRUE when "tpc" points to a valid tab page. |
4019 */ | |
4020 int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4021 valid_tabpage(tabpage_T *tpc) |
671 | 4022 { |
4023 tabpage_T *tp; | |
4024 | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9599
diff
changeset
|
4025 FOR_ALL_TABPAGES(tp) |
671 | 4026 if (tp == tpc) |
4027 return TRUE; | |
4028 return FALSE; | |
4029 } | |
4030 | |
4031 /* | |
11199
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4032 * Return TRUE when "tpc" points to a valid tab page and at least one window is |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4033 * valid. |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4034 */ |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4035 int |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4036 valid_tabpage_win(tabpage_T *tpc) |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4037 { |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4038 tabpage_T *tp; |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4039 win_T *wp; |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4040 |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4041 FOR_ALL_TABPAGES(tp) |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4042 { |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4043 if (tp == tpc) |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4044 { |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4045 FOR_ALL_WINDOWS_IN_TAB(tp, wp) |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4046 { |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4047 if (win_valid_any_tab(wp)) |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4048 return TRUE; |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4049 } |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4050 return FALSE; |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4051 } |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4052 } |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4053 // shouldn't happen |
11199
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4054 return FALSE; |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4055 } |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4056 |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4057 /* |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4058 * Close tabpage "tab", assuming it has no windows in it. |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4059 * There must be another tabpage or this will crash. |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4060 */ |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4061 void |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4062 close_tabpage(tabpage_T *tab) |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4063 { |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4064 tabpage_T *ptp; |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4065 |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4066 if (tab == first_tabpage) |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4067 { |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4068 first_tabpage = tab->tp_next; |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4069 ptp = first_tabpage; |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4070 } |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4071 else |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4072 { |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4073 for (ptp = first_tabpage; ptp != NULL && ptp->tp_next != tab; |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4074 ptp = ptp->tp_next) |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4075 ; |
11232
a14090a30a3f
patch 8.0.0502: Coverity complains about possible NULL pointer
Christian Brabandt <cb@256bit.org>
parents:
11207
diff
changeset
|
4076 assert(ptp != NULL); |
11199
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4077 ptp->tp_next = tab->tp_next; |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4078 } |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4079 |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4080 goto_tabpage_tp(ptp, FALSE, FALSE); |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4081 free_tabpage(tab); |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4082 } |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4083 |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4084 /* |
671 | 4085 * Find tab page "n" (first one is 1). Returns NULL when not found. |
4086 */ | |
4087 tabpage_T * | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4088 find_tabpage(int n) |
671 | 4089 { |
4090 tabpage_T *tp; | |
4091 int i = 1; | |
4092 | |
16427
8c3a1bd270bb
patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents:
16405
diff
changeset
|
4093 if (n == 0) |
8c3a1bd270bb
patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents:
16405
diff
changeset
|
4094 return curtab; |
8c3a1bd270bb
patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents:
16405
diff
changeset
|
4095 |
671 | 4096 for (tp = first_tabpage; tp != NULL && i != n; tp = tp->tp_next) |
4097 ++i; | |
4098 return tp; | |
4099 } | |
4100 | |
4101 /* | |
685 | 4102 * Get index of tab page "tp". First one has index 1. |
686 | 4103 * When not found returns number of tab pages plus one. |
685 | 4104 */ |
4105 int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4106 tabpage_index(tabpage_T *ftp) |
685 | 4107 { |
4108 int i = 1; | |
4109 tabpage_T *tp; | |
4110 | |
4111 for (tp = first_tabpage; tp != NULL && tp != ftp; tp = tp->tp_next) | |
4112 ++i; | |
4113 return i; | |
4114 } | |
4115 | |
4116 /* | |
674 | 4117 * Prepare for leaving the current tab page. |
4352 | 4118 * When autocommands change "curtab" we don't leave the tab page and return |
674 | 4119 * FAIL. |
4120 * Careful: When OK is returned need to get a new tab page very very soon! | |
667 | 4121 */ |
674 | 4122 static int |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4123 leave_tabpage( |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4124 buf_T *new_curbuf UNUSED, // what is going to be the new curbuf, |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4125 // NULL if unknown |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4126 int trigger_leave_autocmds UNUSED) |
667 | 4127 { |
674 | 4128 tabpage_T *tp = curtab; |
4129 | |
14035
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
4130 #ifdef FEAT_JOB_CHANNEL |
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
4131 leaving_window(curwin); |
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
4132 #endif |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4133 reset_VIsual_and_resel(); // stop Visual mode |
4354 | 4134 if (trigger_leave_autocmds) |
4135 { | |
4136 if (new_curbuf != curbuf) | |
4137 { | |
4138 apply_autocmds(EVENT_BUFLEAVE, NULL, NULL, FALSE, curbuf); | |
4139 if (curtab != tp) | |
4140 return FAIL; | |
4141 } | |
4142 apply_autocmds(EVENT_WINLEAVE, NULL, NULL, FALSE, curbuf); | |
674 | 4143 if (curtab != tp) |
4144 return FAIL; | |
4354 | 4145 apply_autocmds(EVENT_TABLEAVE, NULL, NULL, FALSE, curbuf); |
4146 if (curtab != tp) | |
4147 return FAIL; | |
4148 } | |
668 | 4149 #if defined(FEAT_GUI) |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4150 // Remove the scrollbars. They may be added back later. |
668 | 4151 if (gui.in_use) |
4152 gui_remove_scrollbars(); | |
4153 #endif | |
667 | 4154 tp->tp_curwin = curwin; |
671 | 4155 tp->tp_prevwin = prevwin; |
667 | 4156 tp->tp_firstwin = firstwin; |
4157 tp->tp_lastwin = lastwin; | |
668 | 4158 tp->tp_old_Rows = Rows; |
4159 tp->tp_old_Columns = Columns; | |
667 | 4160 firstwin = NULL; |
4161 lastwin = NULL; | |
674 | 4162 return OK; |
667 | 4163 } |
4164 | |
4165 /* | |
4166 * Start using tab page "tp". | |
675 | 4167 * Only to be used after leave_tabpage() or freeing the current tab page. |
4354 | 4168 * Only trigger *Enter autocommands when trigger_enter_autocmds is TRUE. |
4169 * Only trigger *Leave autocommands when trigger_leave_autocmds is TRUE. | |
667 | 4170 */ |
4171 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4172 enter_tabpage( |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4173 tabpage_T *tp, |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4174 buf_T *old_curbuf UNUSED, |
8368
db2a07b710ed
commit https://github.com/vim/vim/commit/f1d2501ebe33e148886c2914acd33140e20ee222
Christian Brabandt <cb@256bit.org>
parents:
8212
diff
changeset
|
4175 int trigger_enter_autocmds, |
db2a07b710ed
commit https://github.com/vim/vim/commit/f1d2501ebe33e148886c2914acd33140e20ee222
Christian Brabandt <cb@256bit.org>
parents:
8212
diff
changeset
|
4176 int trigger_leave_autocmds) |
667 | 4177 { |
19143
bfcafd1a3e37
patch 8.2.0131: command line is not cleared when switching tabs
Bram Moolenaar <Bram@vim.org>
parents:
18886
diff
changeset
|
4178 int row; |
668 | 4179 int old_off = tp->tp_firstwin->w_winrow; |
870 | 4180 win_T *next_prevwin = tp->tp_prevwin; |
21703
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21020
diff
changeset
|
4181 tabpage_T *last_tab = curtab; |
668 | 4182 |
672 | 4183 curtab = tp; |
667 | 4184 firstwin = tp->tp_firstwin; |
4185 lastwin = tp->tp_lastwin; | |
4186 topframe = tp->tp_topframe; | |
870 | 4187 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4188 // We would like doing the TabEnter event first, but we don't have a |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4189 // valid current window yet, which may break some commands. |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4190 // This triggers autocommands, thus may make "tp" invalid. |
25499
5ebf9bb1cbcd
patch 8.2.3286: win_enter_ext() has too many boolean arguments
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
4191 win_enter_ext(tp->tp_curwin, WEE_CURWIN_INVALID |
5ebf9bb1cbcd
patch 8.2.3286: win_enter_ext() has too many boolean arguments
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
4192 | (trigger_enter_autocmds ? WEE_TRIGGER_ENTER_AUTOCMDS : 0) |
5ebf9bb1cbcd
patch 8.2.3286: win_enter_ext() has too many boolean arguments
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
4193 | (trigger_leave_autocmds ? WEE_TRIGGER_LEAVE_AUTOCMDS : 0)); |
870 | 4194 prevwin = next_prevwin; |
4195 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4196 last_status(FALSE); // status line may appear or disappear |
19143
bfcafd1a3e37
patch 8.2.0131: command line is not cleared when switching tabs
Bram Moolenaar <Bram@vim.org>
parents:
18886
diff
changeset
|
4197 row = win_comp_pos(); // recompute w_winrow for all windows |
672 | 4198 #ifdef FEAT_DIFF |
4199 diff_need_scrollbind = TRUE; | |
4200 #endif | |
668 | 4201 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4202 // The tabpage line may have appeared or disappeared, may need to resize |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4203 // the frames for that. When the Vim window was resized need to update |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4204 // frame sizes too. Use the stored value of p_ch, so that it can be |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4205 // different for each tab page. |
16477
8cc31b1b1d23
patch 8.1.1242: no cmdline redraw when tabpages have different 'cmdheight'
Bram Moolenaar <Bram@vim.org>
parents:
16475
diff
changeset
|
4206 if (p_ch != curtab->tp_ch_used) |
8cc31b1b1d23
patch 8.1.1242: no cmdline redraw when tabpages have different 'cmdheight'
Bram Moolenaar <Bram@vim.org>
parents:
16475
diff
changeset
|
4207 clear_cmdline = TRUE; |
824 | 4208 p_ch = curtab->tp_ch_used; |
19143
bfcafd1a3e37
patch 8.2.0131: command line is not cleared when switching tabs
Bram Moolenaar <Bram@vim.org>
parents:
18886
diff
changeset
|
4209 |
bfcafd1a3e37
patch 8.2.0131: command line is not cleared when switching tabs
Bram Moolenaar <Bram@vim.org>
parents:
18886
diff
changeset
|
4210 // When cmdheight is changed in a tab page with '<C-w>-', cmdline_row is |
bfcafd1a3e37
patch 8.2.0131: command line is not cleared when switching tabs
Bram Moolenaar <Bram@vim.org>
parents:
18886
diff
changeset
|
4211 // changed but p_ch and tp_ch_used are not changed. Thus we also need to |
bfcafd1a3e37
patch 8.2.0131: command line is not cleared when switching tabs
Bram Moolenaar <Bram@vim.org>
parents:
18886
diff
changeset
|
4212 // check cmdline_row. |
bfcafd1a3e37
patch 8.2.0131: command line is not cleared when switching tabs
Bram Moolenaar <Bram@vim.org>
parents:
18886
diff
changeset
|
4213 if ((row < cmdline_row) && (cmdline_row <= Rows - p_ch)) |
bfcafd1a3e37
patch 8.2.0131: command line is not cleared when switching tabs
Bram Moolenaar <Bram@vim.org>
parents:
18886
diff
changeset
|
4214 clear_cmdline = TRUE; |
bfcafd1a3e37
patch 8.2.0131: command line is not cleared when switching tabs
Bram Moolenaar <Bram@vim.org>
parents:
18886
diff
changeset
|
4215 |
685 | 4216 if (curtab->tp_old_Rows != Rows || (old_off != firstwin->w_winrow |
4217 #ifdef FEAT_GUI_TABLINE | |
4218 && !gui_use_tabline() | |
4219 #endif | |
4220 )) | |
668 | 4221 shell_new_rows(); |
674 | 4222 if (curtab->tp_old_Columns != Columns && starting == 0) |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4223 shell_new_columns(); // update window widths |
668 | 4224 |
21703
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21020
diff
changeset
|
4225 lastused_tabpage = last_tab; |
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21020
diff
changeset
|
4226 |
668 | 4227 #if defined(FEAT_GUI) |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4228 // When 'guioptions' includes 'L' or 'R' may have to remove or add |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4229 // scrollbars. Have to update them anyway. |
1906 | 4230 gui_may_update_scrollbars(); |
667 | 4231 #endif |
4232 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4233 // Apply autocommands after updating the display, when 'rows' and |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4234 // 'columns' have been set correctly. |
4354 | 4235 if (trigger_enter_autocmds) |
3582 | 4236 { |
4237 apply_autocmds(EVENT_TABENTER, NULL, NULL, FALSE, curbuf); | |
4238 if (old_curbuf != curbuf) | |
4239 apply_autocmds(EVENT_BUFENTER, NULL, NULL, FALSE, curbuf); | |
4240 } | |
3413 | 4241 |
15380
f62d6bd18a49
patch 8.1.0698: clearing the window is used too often
Bram Moolenaar <Bram@vim.org>
parents:
15227
diff
changeset
|
4242 redraw_all_later(NOT_VALID); |
667 | 4243 } |
4244 | |
4245 /* | |
4246 * Go to tab page "n". For ":tab N" and "Ngt". | |
685 | 4247 * When "n" is 9999 go to the last tab page. |
667 | 4248 */ |
4249 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4250 goto_tabpage(int n) |
667 | 4251 { |
16405
840fa633ad64
patch 8.1.1207: some compilers give warning messages
Bram Moolenaar <Bram@vim.org>
parents:
16401
diff
changeset
|
4252 tabpage_T *tp = NULL; // shut up compiler |
682 | 4253 tabpage_T *ttp; |
667 | 4254 int i; |
4255 | |
857 | 4256 if (text_locked()) |
4257 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4258 // Not allowed when editing the command line. |
10082
7fc6103c6651
commit https://github.com/vim/vim/commit/5a49789a9b1f6447aeafbbbdd5b235dd10c471d5
Christian Brabandt <cb@256bit.org>
parents:
10076
diff
changeset
|
4259 text_locked_msg(); |
857 | 4260 return; |
4261 } | |
4262 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4263 // If there is only one it can't work. |
675 | 4264 if (first_tabpage->tp_next == NULL) |
4265 { | |
4266 if (n > 1) | |
4267 beep_flush(); | |
4268 return; | |
4269 } | |
4270 | |
667 | 4271 if (n == 0) |
4272 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4273 // No count, go to next tab page, wrap around end. |
674 | 4274 if (curtab->tp_next == NULL) |
667 | 4275 tp = first_tabpage; |
4276 else | |
674 | 4277 tp = curtab->tp_next; |
667 | 4278 } |
682 | 4279 else if (n < 0) |
4280 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4281 // "gT": go to previous tab page, wrap around end. "N gT" repeats |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4282 // this N times. |
682 | 4283 ttp = curtab; |
4284 for (i = n; i < 0; ++i) | |
4285 { | |
4286 for (tp = first_tabpage; tp->tp_next != ttp && tp->tp_next != NULL; | |
4287 tp = tp->tp_next) | |
4288 ; | |
4289 ttp = tp; | |
4290 } | |
4291 } | |
685 | 4292 else if (n == 9999) |
4293 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4294 // Go to last tab page. |
685 | 4295 for (tp = first_tabpage; tp->tp_next != NULL; tp = tp->tp_next) |
4296 ; | |
4297 } | |
667 | 4298 else |
4299 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4300 // Go to tab page "n". |
685 | 4301 tp = find_tabpage(n); |
671 | 4302 if (tp == NULL) |
4303 { | |
4304 beep_flush(); | |
4305 return; | |
4306 } | |
667 | 4307 } |
4308 | |
4354 | 4309 goto_tabpage_tp(tp, TRUE, TRUE); |
685 | 4310 |
4311 #ifdef FEAT_GUI_TABLINE | |
4312 if (gui_use_tabline()) | |
690 | 4313 gui_mch_set_curtab(tabpage_index(curtab)); |
685 | 4314 #endif |
4315 } | |
4316 | |
4317 /* | |
4318 * Go to tabpage "tp". | |
4354 | 4319 * Only trigger *Enter autocommands when trigger_enter_autocmds is TRUE. |
4320 * Only trigger *Leave autocommands when trigger_leave_autocmds is TRUE. | |
685 | 4321 * Note: doesn't update the GUI tab. |
4322 */ | |
4323 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4324 goto_tabpage_tp( |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4325 tabpage_T *tp, |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4326 int trigger_enter_autocmds, |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4327 int trigger_leave_autocmds) |
685 | 4328 { |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4329 // Don't repeat a message in another tab page. |
2201
4c6b4298852f
Other solution for GTK not changing the locale.
Bram Moolenaar <bram@vim.org>
parents:
2115
diff
changeset
|
4330 set_keep_msg(NULL, 0); |
4c6b4298852f
Other solution for GTK not changing the locale.
Bram Moolenaar <bram@vim.org>
parents:
2115
diff
changeset
|
4331 |
4354 | 4332 if (tp != curtab && leave_tabpage(tp->tp_curwin->w_buffer, |
4333 trigger_leave_autocmds) == OK) | |
674 | 4334 { |
4335 if (valid_tabpage(tp)) | |
4354 | 4336 enter_tabpage(tp, curbuf, trigger_enter_autocmds, |
4337 trigger_leave_autocmds); | |
674 | 4338 else |
4354 | 4339 enter_tabpage(curtab, curbuf, trigger_enter_autocmds, |
4340 trigger_leave_autocmds); | |
674 | 4341 } |
667 | 4342 } |
7 | 4343 |
4344 /* | |
21703
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21020
diff
changeset
|
4345 * Go to the last accessed tab page, if there is one. |
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21020
diff
changeset
|
4346 * Return OK or FAIL |
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21020
diff
changeset
|
4347 */ |
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21020
diff
changeset
|
4348 int |
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21020
diff
changeset
|
4349 goto_tabpage_lastused(void) |
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21020
diff
changeset
|
4350 { |
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21020
diff
changeset
|
4351 if (valid_tabpage(lastused_tabpage)) |
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21020
diff
changeset
|
4352 { |
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21020
diff
changeset
|
4353 goto_tabpage_tp(lastused_tabpage, TRUE, TRUE); |
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21020
diff
changeset
|
4354 return OK; |
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21020
diff
changeset
|
4355 } |
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21020
diff
changeset
|
4356 return FAIL; |
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21020
diff
changeset
|
4357 } |
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21020
diff
changeset
|
4358 |
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21020
diff
changeset
|
4359 /* |
825 | 4360 * Enter window "wp" in tab page "tp". |
4361 * Also updates the GUI tab. | |
4362 */ | |
4363 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4364 goto_tabpage_win(tabpage_T *tp, win_T *wp) |
825 | 4365 { |
4354 | 4366 goto_tabpage_tp(tp, TRUE, TRUE); |
825 | 4367 if (curtab == tp && win_valid(wp)) |
4368 { | |
4369 win_enter(wp, TRUE); | |
4370 # ifdef FEAT_GUI_TABLINE | |
4371 if (gui_use_tabline()) | |
4372 gui_mch_set_curtab(tabpage_index(curtab)); | |
4373 # endif | |
4374 } | |
4375 } | |
4376 | |
4377 /* | |
6775 | 4378 * Move the current tab page to after tab page "nr". |
682 | 4379 */ |
4380 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4381 tabpage_move(int nr) |
682 | 4382 { |
6775 | 4383 int n = 1; |
4384 tabpage_T *tp, *tp_dst; | |
682 | 4385 |
4386 if (first_tabpage->tp_next == NULL) | |
4387 return; | |
4388 | |
6775 | 4389 for (tp = first_tabpage; tp->tp_next != NULL && n < nr; tp = tp->tp_next) |
4390 ++n; | |
4391 | |
4392 if (tp == curtab || (nr > 0 && tp->tp_next != NULL | |
4393 && tp->tp_next == curtab)) | |
4394 return; | |
4395 | |
4396 tp_dst = tp; | |
4397 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4398 // Remove the current tab page from the list of tab pages. |
682 | 4399 if (curtab == first_tabpage) |
4400 first_tabpage = curtab->tp_next; | |
4401 else | |
4402 { | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9599
diff
changeset
|
4403 FOR_ALL_TABPAGES(tp) |
682 | 4404 if (tp->tp_next == curtab) |
4405 break; | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4406 if (tp == NULL) // "cannot happen" |
682 | 4407 return; |
4408 tp->tp_next = curtab->tp_next; | |
4409 } | |
4410 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4411 // Re-insert it at the specified position. |
6775 | 4412 if (nr <= 0) |
682 | 4413 { |
4414 curtab->tp_next = first_tabpage; | |
4415 first_tabpage = curtab; | |
4416 } | |
4417 else | |
4418 { | |
6775 | 4419 curtab->tp_next = tp_dst->tp_next; |
4420 tp_dst->tp_next = curtab; | |
682 | 4421 } |
4422 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4423 // Need to redraw the tabline. Tab page contents doesn't change. |
682 | 4424 redraw_tabline = TRUE; |
4425 } | |
4426 | |
4427 | |
4428 /* | |
7 | 4429 * Go to another window. |
4430 * When jumping to another buffer, stop Visual mode. Do this before | |
4431 * changing windows so we can yank the selection into the '*' register. | |
4432 * When jumping to another window on the same buffer, adjust its cursor | |
4433 * position to keep the same Visual area. | |
4434 */ | |
4435 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4436 win_goto(win_T *wp) |
7 | 4437 { |
2316
db0ea641e382
Fix: cursor line not properly concealed when moving between windows.
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
4438 #ifdef FEAT_CONCEAL |
db0ea641e382
Fix: cursor line not properly concealed when moving between windows.
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
4439 win_T *owp = curwin; |
db0ea641e382
Fix: cursor line not properly concealed when moving between windows.
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
4440 #endif |
db0ea641e382
Fix: cursor line not properly concealed when moving between windows.
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
4441 |
19166
215793f6b59d
patch 8.2.0142: possible to enter popup window with CTRL-W p
Bram Moolenaar <Bram@vim.org>
parents:
19155
diff
changeset
|
4442 #ifdef FEAT_PROP_POPUP |
19271
ebeeb4b4a1fa
patch 8.2.0194: some commands can cause problems in terminal popup
Bram Moolenaar <Bram@vim.org>
parents:
19265
diff
changeset
|
4443 if (ERROR_IF_ANY_POPUP_WINDOW) |
16874
da5f5836e90c
patch 8.1.1438: some commands cause trouble in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
16863
diff
changeset
|
4444 return; |
19166
215793f6b59d
patch 8.2.0142: possible to enter popup window with CTRL-W p
Bram Moolenaar <Bram@vim.org>
parents:
19155
diff
changeset
|
4445 if (popup_is_popup(wp)) |
215793f6b59d
patch 8.2.0142: possible to enter popup window with CTRL-W p
Bram Moolenaar <Bram@vim.org>
parents:
19155
diff
changeset
|
4446 { |
215793f6b59d
patch 8.2.0142: possible to enter popup window with CTRL-W p
Bram Moolenaar <Bram@vim.org>
parents:
19155
diff
changeset
|
4447 emsg(_("E366: Not allowed to enter a popup window")); |
215793f6b59d
patch 8.2.0142: possible to enter popup window with CTRL-W p
Bram Moolenaar <Bram@vim.org>
parents:
19155
diff
changeset
|
4448 return; |
215793f6b59d
patch 8.2.0142: possible to enter popup window with CTRL-W p
Bram Moolenaar <Bram@vim.org>
parents:
19155
diff
changeset
|
4449 } |
215793f6b59d
patch 8.2.0142: possible to enter popup window with CTRL-W p
Bram Moolenaar <Bram@vim.org>
parents:
19155
diff
changeset
|
4450 #endif |
20229
06a1dd50463e
patch 8.2.0670: cannot change window when evaluating 'completefunc'
Bram Moolenaar <Bram@vim.org>
parents:
20049
diff
changeset
|
4451 if (text_and_win_locked()) |
7 | 4452 { |
4453 beep_flush(); | |
633 | 4454 text_locked_msg(); |
7 | 4455 return; |
4456 } | |
819 | 4457 if (curbuf_locked()) |
4458 return; | |
631 | 4459 |
7 | 4460 if (wp->w_buffer != curbuf) |
4461 reset_VIsual_and_resel(); | |
4462 else if (VIsual_active) | |
4463 wp->w_cursor = curwin->w_cursor; | |
4464 | |
4465 #ifdef FEAT_GUI | |
4466 need_mouse_correct = TRUE; | |
4467 #endif | |
4468 win_enter(wp, TRUE); | |
2316
db0ea641e382
Fix: cursor line not properly concealed when moving between windows.
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
4469 |
db0ea641e382
Fix: cursor line not properly concealed when moving between windows.
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
4470 #ifdef FEAT_CONCEAL |
15436
29f3d59bb6f0
patch 8.1.0726: redrawing specifically for conceal feature
Bram Moolenaar <Bram@vim.org>
parents:
15380
diff
changeset
|
4471 // Conceal cursor line in previous window, unconceal in current window. |
4094 | 4472 if (win_valid(owp) && owp->w_p_cole > 0 && !msg_scrolled) |
15436
29f3d59bb6f0
patch 8.1.0726: redrawing specifically for conceal feature
Bram Moolenaar <Bram@vim.org>
parents:
15380
diff
changeset
|
4473 redrawWinline(owp, owp->w_cursor.lnum); |
4094 | 4474 if (curwin->w_p_cole > 0 && !msg_scrolled) |
4475 need_cursor_line_redraw = TRUE; | |
2316
db0ea641e382
Fix: cursor line not properly concealed when moving between windows.
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
4476 #endif |
7 | 4477 } |
4478 | |
4479 #if defined(FEAT_PERL) || defined(PROTO) | |
4480 /* | |
4481 * Find window number "winnr" (counting top to bottom). | |
4482 */ | |
4483 win_T * | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4484 win_find_nr(int winnr) |
7 | 4485 { |
4486 win_T *wp; | |
4487 | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9599
diff
changeset
|
4488 FOR_ALL_WINDOWS(wp) |
7 | 4489 if (--winnr == 0) |
4490 break; | |
4491 return wp; | |
4492 } | |
4493 #endif | |
4494 | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
4495 #if ((defined(FEAT_PYTHON) || defined(FEAT_PYTHON3))) || defined(PROTO) |
4429 | 4496 /* |
4497 * Find the tabpage for window "win". | |
4498 */ | |
4499 tabpage_T * | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4500 win_find_tabpage(win_T *win) |
4429 | 4501 { |
4502 win_T *wp; | |
4503 tabpage_T *tp; | |
4504 | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9599
diff
changeset
|
4505 FOR_ALL_TAB_WINDOWS(tp, wp) |
4429 | 4506 if (wp == win) |
4507 return tp; | |
4508 return NULL; | |
4509 } | |
4510 #endif | |
4511 | |
7 | 4512 /* |
16271
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4513 * Get the above or below neighbor window of the specified window. |
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4514 * up - TRUE for the above neighbor |
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4515 * count - nth neighbor window |
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4516 * Returns the specified window if the neighbor is not found. |
7 | 4517 */ |
16271
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4518 win_T * |
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4519 win_vert_neighbor(tabpage_T *tp, win_T *wp, int up, long count) |
7 | 4520 { |
4521 frame_T *fr; | |
4522 frame_T *nfr; | |
4523 frame_T *foundfr; | |
4524 | |
19291
1d6bc6b31c2e
patch 8.2.0204: crash when using winnr('j') in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19275
diff
changeset
|
4525 #ifdef FEAT_PROP_POPUP |
1d6bc6b31c2e
patch 8.2.0204: crash when using winnr('j') in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19275
diff
changeset
|
4526 if (popup_is_popup(wp)) |
1d6bc6b31c2e
patch 8.2.0204: crash when using winnr('j') in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19275
diff
changeset
|
4527 // popups don't have neighbors. |
1d6bc6b31c2e
patch 8.2.0204: crash when using winnr('j') in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19275
diff
changeset
|
4528 return NULL; |
1d6bc6b31c2e
patch 8.2.0204: crash when using winnr('j') in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19275
diff
changeset
|
4529 #endif |
16271
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4530 foundfr = wp->w_frame; |
7 | 4531 while (count--) |
4532 { | |
4533 /* | |
4534 * First go upwards in the tree of frames until we find a upwards or | |
4535 * downwards neighbor. | |
4536 */ | |
4537 fr = foundfr; | |
4538 for (;;) | |
4539 { | |
16271
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4540 if (fr == tp->tp_topframe) |
7 | 4541 goto end; |
4542 if (up) | |
4543 nfr = fr->fr_prev; | |
4544 else | |
4545 nfr = fr->fr_next; | |
4546 if (fr->fr_parent->fr_layout == FR_COL && nfr != NULL) | |
4547 break; | |
4548 fr = fr->fr_parent; | |
4549 } | |
4550 | |
4551 /* | |
4552 * Now go downwards to find the bottom or top frame in it. | |
4553 */ | |
4554 for (;;) | |
4555 { | |
4556 if (nfr->fr_layout == FR_LEAF) | |
4557 { | |
4558 foundfr = nfr; | |
4559 break; | |
4560 } | |
4561 fr = nfr->fr_child; | |
4562 if (nfr->fr_layout == FR_ROW) | |
4563 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4564 // Find the frame at the cursor row. |
7 | 4565 while (fr->fr_next != NULL |
4566 && frame2win(fr)->w_wincol + fr->fr_width | |
16271
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4567 <= wp->w_wincol + wp->w_wcol) |
7 | 4568 fr = fr->fr_next; |
4569 } | |
4570 if (nfr->fr_layout == FR_COL && up) | |
4571 while (fr->fr_next != NULL) | |
4572 fr = fr->fr_next; | |
4573 nfr = fr; | |
4574 } | |
4575 } | |
4576 end: | |
16271
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4577 return foundfr != NULL ? foundfr->fr_win : NULL; |
7 | 4578 } |
4579 | |
4580 /* | |
16271
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4581 * Move to window above or below "count" times. |
7 | 4582 */ |
4583 static void | |
16271
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4584 win_goto_ver( |
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4585 int up, // TRUE to go to win above |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4586 long count) |
7 | 4587 { |
16271
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4588 win_T *win; |
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4589 |
19265
ce8c47ed54e5
patch 8.2.0191: cannot put a terminal in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19166
diff
changeset
|
4590 #ifdef FEAT_PROP_POPUP |
ce8c47ed54e5
patch 8.2.0191: cannot put a terminal in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19166
diff
changeset
|
4591 if (ERROR_IF_TERM_POPUP_WINDOW) |
ce8c47ed54e5
patch 8.2.0191: cannot put a terminal in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19166
diff
changeset
|
4592 return; |
ce8c47ed54e5
patch 8.2.0191: cannot put a terminal in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19166
diff
changeset
|
4593 #endif |
16271
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4594 win = win_vert_neighbor(curtab, curwin, up, count); |
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4595 if (win != NULL) |
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4596 win_goto(win); |
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4597 } |
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4598 |
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4599 /* |
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4600 * Get the left or right neighbor window of the specified window. |
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4601 * left - TRUE for the left neighbor |
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4602 * count - nth neighbor window |
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4603 * Returns the specified window if the neighbor is not found. |
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4604 */ |
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4605 win_T * |
16354
b3bc3ba07bef
patch 8.1.1182: some function prototypes are outdated
Bram Moolenaar <Bram@vim.org>
parents:
16271
diff
changeset
|
4606 win_horz_neighbor(tabpage_T *tp, win_T *wp, int left, long count) |
16271
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4607 { |
7 | 4608 frame_T *fr; |
4609 frame_T *nfr; | |
4610 frame_T *foundfr; | |
4611 | |
19291
1d6bc6b31c2e
patch 8.2.0204: crash when using winnr('j') in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19275
diff
changeset
|
4612 #ifdef FEAT_PROP_POPUP |
1d6bc6b31c2e
patch 8.2.0204: crash when using winnr('j') in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19275
diff
changeset
|
4613 if (popup_is_popup(wp)) |
1d6bc6b31c2e
patch 8.2.0204: crash when using winnr('j') in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19275
diff
changeset
|
4614 // popups don't have neighbors. |
1d6bc6b31c2e
patch 8.2.0204: crash when using winnr('j') in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19275
diff
changeset
|
4615 return NULL; |
1d6bc6b31c2e
patch 8.2.0204: crash when using winnr('j') in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19275
diff
changeset
|
4616 #endif |
16271
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4617 foundfr = wp->w_frame; |
7 | 4618 while (count--) |
4619 { | |
4620 /* | |
4621 * First go upwards in the tree of frames until we find a left or | |
4622 * right neighbor. | |
4623 */ | |
4624 fr = foundfr; | |
4625 for (;;) | |
4626 { | |
16271
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4627 if (fr == tp->tp_topframe) |
7 | 4628 goto end; |
4629 if (left) | |
4630 nfr = fr->fr_prev; | |
4631 else | |
4632 nfr = fr->fr_next; | |
4633 if (fr->fr_parent->fr_layout == FR_ROW && nfr != NULL) | |
4634 break; | |
4635 fr = fr->fr_parent; | |
4636 } | |
4637 | |
4638 /* | |
4639 * Now go downwards to find the leftmost or rightmost frame in it. | |
4640 */ | |
4641 for (;;) | |
4642 { | |
4643 if (nfr->fr_layout == FR_LEAF) | |
4644 { | |
4645 foundfr = nfr; | |
4646 break; | |
4647 } | |
4648 fr = nfr->fr_child; | |
4649 if (nfr->fr_layout == FR_COL) | |
4650 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4651 // Find the frame at the cursor row. |
7 | 4652 while (fr->fr_next != NULL |
4653 && frame2win(fr)->w_winrow + fr->fr_height | |
16271
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4654 <= wp->w_winrow + wp->w_wrow) |
7 | 4655 fr = fr->fr_next; |
4656 } | |
4657 if (nfr->fr_layout == FR_ROW && left) | |
4658 while (fr->fr_next != NULL) | |
4659 fr = fr->fr_next; | |
4660 nfr = fr; | |
4661 } | |
4662 } | |
4663 end: | |
16271
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4664 return foundfr != NULL ? foundfr->fr_win : NULL; |
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4665 } |
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4666 |
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4667 /* |
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4668 * Move to left or right window. |
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4669 */ |
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4670 static void |
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4671 win_goto_hor( |
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4672 int left, // TRUE to go to left win |
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4673 long count) |
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4674 { |
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4675 win_T *win; |
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4676 |
19265
ce8c47ed54e5
patch 8.2.0191: cannot put a terminal in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19166
diff
changeset
|
4677 #ifdef FEAT_PROP_POPUP |
ce8c47ed54e5
patch 8.2.0191: cannot put a terminal in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19166
diff
changeset
|
4678 if (ERROR_IF_TERM_POPUP_WINDOW) |
ce8c47ed54e5
patch 8.2.0191: cannot put a terminal in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19166
diff
changeset
|
4679 return; |
ce8c47ed54e5
patch 8.2.0191: cannot put a terminal in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19166
diff
changeset
|
4680 #endif |
16271
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4681 win = win_horz_neighbor(curtab, curwin, left, count); |
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4682 if (win != NULL) |
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4683 win_goto(win); |
7 | 4684 } |
4685 | |
4686 /* | |
4687 * Make window "wp" the current window. | |
4688 */ | |
4689 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4690 win_enter(win_T *wp, int undo_sync) |
7 | 4691 { |
25499
5ebf9bb1cbcd
patch 8.2.3286: win_enter_ext() has too many boolean arguments
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
4692 win_enter_ext(wp, (undo_sync ? WEE_UNDO_SYNC : 0) |
5ebf9bb1cbcd
patch 8.2.3286: win_enter_ext() has too many boolean arguments
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
4693 | WEE_TRIGGER_ENTER_AUTOCMDS | WEE_TRIGGER_LEAVE_AUTOCMDS); |
7 | 4694 } |
4695 | |
4696 /* | |
25499
5ebf9bb1cbcd
patch 8.2.3286: win_enter_ext() has too many boolean arguments
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
4697 * Make window "wp" the current window. |
5ebf9bb1cbcd
patch 8.2.3286: win_enter_ext() has too many boolean arguments
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
4698 * Can be called with "flags" containing WEE_CURWIN_INVALID, which means that |
5ebf9bb1cbcd
patch 8.2.3286: win_enter_ext() has too many boolean arguments
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
4699 * curwin has just been closed and isn't valid. |
7 | 4700 */ |
4701 static void | |
25499
5ebf9bb1cbcd
patch 8.2.3286: win_enter_ext() has too many boolean arguments
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
4702 win_enter_ext(win_T *wp, int flags) |
7 | 4703 { |
4704 int other_buffer = FALSE; | |
25499
5ebf9bb1cbcd
patch 8.2.3286: win_enter_ext() has too many boolean arguments
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
4705 int curwin_invalid = (flags & WEE_CURWIN_INVALID); |
7 | 4706 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4707 if (wp == curwin && !curwin_invalid) // nothing to do |
7 | 4708 return; |
4709 | |
14035
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
4710 #ifdef FEAT_JOB_CHANNEL |
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
4711 if (!curwin_invalid) |
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
4712 leaving_window(curwin); |
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
4713 #endif |
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
4714 |
25499
5ebf9bb1cbcd
patch 8.2.3286: win_enter_ext() has too many boolean arguments
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
4715 if (!curwin_invalid && (flags & WEE_TRIGGER_LEAVE_AUTOCMDS)) |
7 | 4716 { |
4717 /* | |
4718 * Be careful: If autocommands delete the window, return now. | |
4719 */ | |
4720 if (wp->w_buffer != curbuf) | |
4721 { | |
4722 apply_autocmds(EVENT_BUFLEAVE, NULL, NULL, FALSE, curbuf); | |
4723 other_buffer = TRUE; | |
4724 if (!win_valid(wp)) | |
4725 return; | |
4726 } | |
4727 apply_autocmds(EVENT_WINLEAVE, NULL, NULL, FALSE, curbuf); | |
4728 if (!win_valid(wp)) | |
4729 return; | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13308
diff
changeset
|
4730 #ifdef FEAT_EVAL |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4731 // autocmds may abort script processing |
7 | 4732 if (aborting()) |
4733 return; | |
4734 #endif | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13308
diff
changeset
|
4735 } |
7 | 4736 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4737 // sync undo before leaving the current buffer |
25499
5ebf9bb1cbcd
patch 8.2.3286: win_enter_ext() has too many boolean arguments
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
4738 if ((flags & WEE_UNDO_SYNC) && curbuf != wp->w_buffer) |
825 | 4739 u_sync(FALSE); |
5977 | 4740 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4741 // Might need to scroll the old window before switching, e.g., when the |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4742 // cursor was moved. |
5977 | 4743 update_topline(); |
4744 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4745 // may have to copy the buffer options when 'cpo' contains 'S' |
7 | 4746 if (wp->w_buffer != curbuf) |
4747 buf_copy_options(wp->w_buffer, BCO_ENTER | BCO_NOHELP); | |
4748 if (!curwin_invalid) | |
4749 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4750 prevwin = curwin; // remember for CTRL-W p |
7 | 4751 curwin->w_redr_status = TRUE; |
4752 } | |
4753 curwin = wp; | |
4754 curbuf = wp->w_buffer; | |
4755 check_cursor(); | |
4756 if (!virtual_active()) | |
4757 curwin->w_cursor.coladd = 0; | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4758 changed_line_abv_curs(); // assume cursor position needs updating |
7 | 4759 |
16427
8c3a1bd270bb
patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents:
16405
diff
changeset
|
4760 if (curwin->w_localdir != NULL || curtab->tp_localdir != NULL) |
8c3a1bd270bb
patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents:
16405
diff
changeset
|
4761 { |
8c3a1bd270bb
patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents:
16405
diff
changeset
|
4762 char_u *dirname; |
8c3a1bd270bb
patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents:
16405
diff
changeset
|
4763 |
8c3a1bd270bb
patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents:
16405
diff
changeset
|
4764 // Window or tab has a local directory: Save current directory as |
8c3a1bd270bb
patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents:
16405
diff
changeset
|
4765 // global directory (unless that was done already) and change to the |
8c3a1bd270bb
patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents:
16405
diff
changeset
|
4766 // local directory. |
7 | 4767 if (globaldir == NULL) |
4768 { | |
4769 char_u cwd[MAXPATHL]; | |
4770 | |
4771 if (mch_dirname(cwd, MAXPATHL) == OK) | |
4772 globaldir = vim_strsave(cwd); | |
4773 } | |
16427
8c3a1bd270bb
patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents:
16405
diff
changeset
|
4774 if (curwin->w_localdir != NULL) |
8c3a1bd270bb
patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents:
16405
diff
changeset
|
4775 dirname = curwin->w_localdir; |
8c3a1bd270bb
patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents:
16405
diff
changeset
|
4776 else |
8c3a1bd270bb
patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents:
16405
diff
changeset
|
4777 dirname = curtab->tp_localdir; |
8c3a1bd270bb
patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents:
16405
diff
changeset
|
4778 |
8c3a1bd270bb
patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents:
16405
diff
changeset
|
4779 if (mch_chdir((char *)dirname) == 0) |
1757 | 4780 shorten_fnames(TRUE); |
7 | 4781 } |
4782 else if (globaldir != NULL) | |
4783 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4784 // Window doesn't have a local directory and we are not in the global |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4785 // directory: Change to the global directory. |
14730
193471015e1a
patch 8.1.0377: xdiff doesn't use the Vim memory allocation functions
Christian Brabandt <cb@256bit.org>
parents:
14587
diff
changeset
|
4786 vim_ignored = mch_chdir((char *)globaldir); |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13144
diff
changeset
|
4787 VIM_CLEAR(globaldir); |
7 | 4788 shorten_fnames(TRUE); |
4789 } | |
4790 | |
14035
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
4791 #ifdef FEAT_JOB_CHANNEL |
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
4792 entering_window(curwin); |
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
4793 #endif |
18283
0cb608fc9c60
patch 8.1.2136: using freed memory with autocmd from fuzzer
Bram Moolenaar <Bram@vim.org>
parents:
18255
diff
changeset
|
4794 // Careful: autocommands may close the window and make "wp" invalid |
25499
5ebf9bb1cbcd
patch 8.2.3286: win_enter_ext() has too many boolean arguments
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
4795 if (flags & WEE_TRIGGER_NEW_AUTOCMDS) |
9595
0190d5de215f
commit https://github.com/vim/vim/commit/c917da4b3e8801a255dbefea8e4ed19c1c716dd8
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
4796 apply_autocmds(EVENT_WINNEW, NULL, NULL, FALSE, curbuf); |
25499
5ebf9bb1cbcd
patch 8.2.3286: win_enter_ext() has too many boolean arguments
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
4797 if (flags & WEE_TRIGGER_ENTER_AUTOCMDS) |
4354 | 4798 { |
4799 apply_autocmds(EVENT_WINENTER, NULL, NULL, FALSE, curbuf); | |
4800 if (other_buffer) | |
4801 apply_autocmds(EVENT_BUFENTER, NULL, NULL, FALSE, curbuf); | |
4802 } | |
7 | 4803 |
4804 #ifdef FEAT_TITLE | |
4805 maketitle(); | |
4806 #endif | |
4807 curwin->w_redr_status = TRUE; | |
18255
3f51e026de28
patch 8.1.2122: cannot build without terminal feature
Bram Moolenaar <Bram@vim.org>
parents:
18253
diff
changeset
|
4808 #ifdef FEAT_TERMINAL |
18283
0cb608fc9c60
patch 8.1.2136: using freed memory with autocmd from fuzzer
Bram Moolenaar <Bram@vim.org>
parents:
18255
diff
changeset
|
4809 if (bt_terminal(curwin->w_buffer)) |
18253
783f796a1426
patch 8.1.2121: mode is not updated when switching to terminal
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
4810 // terminal is likely in another mode |
783f796a1426
patch 8.1.2121: mode is not updated when switching to terminal
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
4811 redraw_mode = TRUE; |
18255
3f51e026de28
patch 8.1.2122: cannot build without terminal feature
Bram Moolenaar <Bram@vim.org>
parents:
18253
diff
changeset
|
4812 #endif |
672 | 4813 redraw_tabline = TRUE; |
7 | 4814 if (restart_edit) |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4815 redraw_later(VALID); // causes status line redraw |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4816 |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4817 // set window height to desired minimal value |
17472
dfd87ef822aa
patch 8.1.1734: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17225
diff
changeset
|
4818 if (curwin->w_height < p_wh && !curwin->w_p_wfh |
18763
49b78d6465e5
patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents:
18590
diff
changeset
|
4819 #ifdef FEAT_PROP_POPUP |
17472
dfd87ef822aa
patch 8.1.1734: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17225
diff
changeset
|
4820 && !popup_is_popup(curwin) |
dfd87ef822aa
patch 8.1.1734: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17225
diff
changeset
|
4821 #endif |
dfd87ef822aa
patch 8.1.1734: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17225
diff
changeset
|
4822 ) |
7 | 4823 win_setheight((int)p_wh); |
4824 else if (curwin->w_height == 0) | |
4825 win_setheight(1); | |
4826 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4827 // set window width to desired minimal value |
779 | 4828 if (curwin->w_width < p_wiw && !curwin->w_p_wfw) |
7 | 4829 win_setwidth((int)p_wiw); |
4830 | |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18010
diff
changeset
|
4831 setmouse(); // in case jumped to/from help buffer |
7 | 4832 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4833 // Change directories when the 'acd' option is set. |
13632
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
4834 DO_AUTOCHDIR; |
7 | 4835 } |
4836 | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
4837 |
7 | 4838 /* |
825 | 4839 * Jump to the first open window that contains buffer "buf", if one exists. |
4840 * Returns a pointer to the window found, otherwise NULL. | |
7 | 4841 */ |
4842 win_T * | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4843 buf_jump_open_win(buf_T *buf) |
7 | 4844 { |
6307 | 4845 win_T *wp = NULL; |
4846 | |
4847 if (curwin->w_buffer == buf) | |
4848 wp = curwin; | |
4849 else | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9599
diff
changeset
|
4850 FOR_ALL_WINDOWS(wp) |
6307 | 4851 if (wp->w_buffer == buf) |
4852 break; | |
7 | 4853 if (wp != NULL) |
4854 win_enter(wp, FALSE); | |
4855 return wp; | |
4856 } | |
825 | 4857 |
4858 /* | |
4859 * Jump to the first open window in any tab page that contains buffer "buf", | |
4860 * if one exists. | |
4861 * Returns a pointer to the window found, otherwise NULL. | |
4862 */ | |
4863 win_T * | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4864 buf_jump_open_tab(buf_T *buf) |
825 | 4865 { |
6307 | 4866 win_T *wp = buf_jump_open_win(buf); |
825 | 4867 tabpage_T *tp; |
4868 | |
4869 if (wp != NULL) | |
4870 return wp; | |
4871 | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9599
diff
changeset
|
4872 FOR_ALL_TABPAGES(tp) |
825 | 4873 if (tp != curtab) |
4874 { | |
19888
435726a03481
patch 8.2.0500: using the same loop in many places
Bram Moolenaar <Bram@vim.org>
parents:
19291
diff
changeset
|
4875 FOR_ALL_WINDOWS_IN_TAB(tp, wp) |
825 | 4876 if (wp->w_buffer == buf) |
4877 break; | |
4878 if (wp != NULL) | |
4879 { | |
4880 goto_tabpage_win(tp, wp); | |
4881 if (curwin != wp) | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4882 wp = NULL; // something went wrong |
825 | 4883 break; |
4884 } | |
4885 } | |
4886 return wp; | |
4887 } | |
7 | 4888 |
9223
6c4d610fce0a
commit https://github.com/vim/vim/commit/888ccac8902cee186fbd47e971881f6d9b19c068
Christian Brabandt <cb@256bit.org>
parents:
9102
diff
changeset
|
4889 static int last_win_id = LOWEST_WIN_ID - 1; |
8534
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
4890 |
7 | 4891 /* |
1906 | 4892 * Allocate a window structure and link it in the window list when "hidden" is |
4893 * FALSE. | |
7 | 4894 */ |
4895 static win_T * | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4896 win_alloc(win_T *after UNUSED, int hidden UNUSED) |
7 | 4897 { |
3263 | 4898 win_T *new_wp; |
7 | 4899 |
4900 /* | |
4901 * allocate window structure and linesizes arrays | |
4902 */ | |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16802
diff
changeset
|
4903 new_wp = ALLOC_CLEAR_ONE(win_T); |
4287 | 4904 if (new_wp == NULL) |
4905 return NULL; | |
4906 | |
4907 if (win_alloc_lines(new_wp) == FAIL) | |
3263 | 4908 { |
4909 vim_free(new_wp); | |
4287 | 4910 return NULL; |
4911 } | |
4912 | |
8534
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
4913 new_wp->w_id = ++last_win_id; |
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
4914 |
4287 | 4915 #ifdef FEAT_EVAL |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4916 // init w: variables |
4287 | 4917 new_wp->w_vars = dict_alloc(); |
4918 if (new_wp->w_vars == NULL) | |
4919 { | |
4920 win_free_lsize(new_wp); | |
4921 vim_free(new_wp); | |
4922 return NULL; | |
4923 } | |
4924 init_var_dict(new_wp->w_vars, &new_wp->w_winvar, VAR_SCOPE); | |
4925 #endif | |
4926 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4927 // Don't execute autocommands while the window is not properly |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4928 // initialized yet. gui_create_scrollbar() may trigger a FocusGained |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4929 // event. |
4287 | 4930 block_autocmds(); |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13308
diff
changeset
|
4931 |
4287 | 4932 /* |
4933 * link the window in the window list | |
4934 */ | |
4935 if (!hidden) | |
4936 win_append(after, new_wp); | |
4937 new_wp->w_wincol = 0; | |
4938 new_wp->w_width = Columns; | |
4939 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4940 // position the display and the cursor at the top of the file. |
4287 | 4941 new_wp->w_topline = 1; |
7 | 4942 #ifdef FEAT_DIFF |
4287 | 4943 new_wp->w_topfill = 0; |
4944 #endif | |
4945 new_wp->w_botline = 2; | |
4946 new_wp->w_cursor.lnum = 1; | |
4947 new_wp->w_scbind_pos = 1; | |
4948 | |
15713
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15636
diff
changeset
|
4949 // use global option value for global-local options |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15636
diff
changeset
|
4950 new_wp->w_p_so = -1; |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15636
diff
changeset
|
4951 new_wp->w_p_siso = -1; |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15636
diff
changeset
|
4952 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4953 // We won't calculate w_fraction until resizing the window |
4287 | 4954 new_wp->w_fraction = 0; |
4955 new_wp->w_prev_fraction_row = -1; | |
7 | 4956 |
4957 #ifdef FEAT_GUI | |
4287 | 4958 if (gui.in_use) |
4959 { | |
4960 gui_create_scrollbar(&new_wp->w_scrollbars[SBAR_LEFT], | |
4961 SBAR_LEFT, new_wp); | |
4962 gui_create_scrollbar(&new_wp->w_scrollbars[SBAR_RIGHT], | |
4963 SBAR_RIGHT, new_wp); | |
4964 } | |
7 | 4965 #endif |
4966 #ifdef FEAT_FOLDING | |
4287 | 4967 foldInitWin(new_wp); |
7 | 4968 #endif |
4287 | 4969 unblock_autocmds(); |
1326 | 4970 #ifdef FEAT_SEARCH_EXTRA |
4287 | 4971 new_wp->w_match_head = NULL; |
4972 new_wp->w_next_match_id = 4; | |
4973 #endif | |
3263 | 4974 return new_wp; |
7 | 4975 } |
4976 | |
4977 /* | |
5237
647596ab1ae2
updated for version 7.4a.044
Bram Moolenaar <bram@vim.org>
parents:
5233
diff
changeset
|
4978 * Remove window 'wp' from the window list and free the structure. |
7 | 4979 */ |
4980 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4981 win_free( |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4982 win_T *wp, |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4983 tabpage_T *tp) // tab page "win" is in, NULL for current |
7 | 4984 { |
4985 int i; | |
5237
647596ab1ae2
updated for version 7.4a.044
Bram Moolenaar <bram@vim.org>
parents:
5233
diff
changeset
|
4986 buf_T *buf; |
647596ab1ae2
updated for version 7.4a.044
Bram Moolenaar <bram@vim.org>
parents:
5233
diff
changeset
|
4987 wininfo_T *wip; |
7 | 4988 |
1918 | 4989 #ifdef FEAT_FOLDING |
4990 clearFolding(wp); | |
4991 #endif | |
4992 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4993 // reduce the reference count to the argument list. |
1918 | 4994 alist_unlink(wp->w_alist); |
4995 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4996 // Don't execute autocommands while the window is halfway being deleted. |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4997 // gui_mch_destroy_scrollbar() may trigger a FocusGained event. |
1410 | 4998 block_autocmds(); |
1114 | 4999 |
2320
966a5609669e
Added Lua interfae. (Luis Carvalho)
Bram Moolenaar <bram@vim.org>
parents:
2316
diff
changeset
|
5000 #ifdef FEAT_LUA |
966a5609669e
Added Lua interfae. (Luis Carvalho)
Bram Moolenaar <bram@vim.org>
parents:
2316
diff
changeset
|
5001 lua_window_free(wp); |
966a5609669e
Added Lua interfae. (Luis Carvalho)
Bram Moolenaar <bram@vim.org>
parents:
2316
diff
changeset
|
5002 #endif |
966a5609669e
Added Lua interfae. (Luis Carvalho)
Bram Moolenaar <bram@vim.org>
parents:
2316
diff
changeset
|
5003 |
14 | 5004 #ifdef FEAT_MZSCHEME |
5005 mzscheme_window_free(wp); | |
5006 #endif | |
5007 | |
7 | 5008 #ifdef FEAT_PERL |
5009 perl_win_free(wp); | |
5010 #endif | |
5011 | |
5012 #ifdef FEAT_PYTHON | |
5013 python_window_free(wp); | |
5014 #endif | |
5015 | |
2329
ad2889f48843
Added support for Python 3. (Roland Puntaier)
Bram Moolenaar <bram@vim.org>
parents:
2320
diff
changeset
|
5016 #ifdef FEAT_PYTHON3 |
ad2889f48843
Added support for Python 3. (Roland Puntaier)
Bram Moolenaar <bram@vim.org>
parents:
2320
diff
changeset
|
5017 python3_window_free(wp); |
ad2889f48843
Added support for Python 3. (Roland Puntaier)
Bram Moolenaar <bram@vim.org>
parents:
2320
diff
changeset
|
5018 #endif |
ad2889f48843
Added support for Python 3. (Roland Puntaier)
Bram Moolenaar <bram@vim.org>
parents:
2320
diff
changeset
|
5019 |
7 | 5020 #ifdef FEAT_TCL |
5021 tcl_window_free(wp); | |
5022 #endif | |
5023 | |
5024 #ifdef FEAT_RUBY | |
5025 ruby_window_free(wp); | |
5026 #endif | |
5027 | |
5028 clear_winopt(&wp->w_onebuf_opt); | |
5029 clear_winopt(&wp->w_allbuf_opt); | |
5030 | |
5031 #ifdef FEAT_EVAL | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5032 vars_clear(&wp->w_vars->dv_hashtab); // free all w: variables |
4287 | 5033 hash_init(&wp->w_vars->dv_hashtab); |
5034 unref_var_dict(wp->w_vars); | |
7 | 5035 #endif |
5036 | |
8833
dc10bd23f918
commit https://github.com/vim/vim/commit/3dda7db4e1f7c4a8110a1f83001ec36b46693d27
Christian Brabandt <cb@256bit.org>
parents:
8804
diff
changeset
|
5037 { |
dc10bd23f918
commit https://github.com/vim/vim/commit/3dda7db4e1f7c4a8110a1f83001ec36b46693d27
Christian Brabandt <cb@256bit.org>
parents:
8804
diff
changeset
|
5038 tabpage_T *ttp; |
dc10bd23f918
commit https://github.com/vim/vim/commit/3dda7db4e1f7c4a8110a1f83001ec36b46693d27
Christian Brabandt <cb@256bit.org>
parents:
8804
diff
changeset
|
5039 |
dc10bd23f918
commit https://github.com/vim/vim/commit/3dda7db4e1f7c4a8110a1f83001ec36b46693d27
Christian Brabandt <cb@256bit.org>
parents:
8804
diff
changeset
|
5040 if (prevwin == wp) |
dc10bd23f918
commit https://github.com/vim/vim/commit/3dda7db4e1f7c4a8110a1f83001ec36b46693d27
Christian Brabandt <cb@256bit.org>
parents:
8804
diff
changeset
|
5041 prevwin = NULL; |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9599
diff
changeset
|
5042 FOR_ALL_TABPAGES(ttp) |
8833
dc10bd23f918
commit https://github.com/vim/vim/commit/3dda7db4e1f7c4a8110a1f83001ec36b46693d27
Christian Brabandt <cb@256bit.org>
parents:
8804
diff
changeset
|
5043 if (ttp->tp_prevwin == wp) |
dc10bd23f918
commit https://github.com/vim/vim/commit/3dda7db4e1f7c4a8110a1f83001ec36b46693d27
Christian Brabandt <cb@256bit.org>
parents:
8804
diff
changeset
|
5044 ttp->tp_prevwin = NULL; |
dc10bd23f918
commit https://github.com/vim/vim/commit/3dda7db4e1f7c4a8110a1f83001ec36b46693d27
Christian Brabandt <cb@256bit.org>
parents:
8804
diff
changeset
|
5045 } |
7 | 5046 win_free_lsize(wp); |
5047 | |
5048 for (i = 0; i < wp->w_tagstacklen; ++i) | |
17932
70ed823bdbb6
patch 8.1.1962: leaking memory when using tagfunc()
Bram Moolenaar <Bram@vim.org>
parents:
17893
diff
changeset
|
5049 { |
7 | 5050 vim_free(wp->w_tagstack[i].tagname); |
17932
70ed823bdbb6
patch 8.1.1962: leaking memory when using tagfunc()
Bram Moolenaar <Bram@vim.org>
parents:
17893
diff
changeset
|
5051 vim_free(wp->w_tagstack[i].user_data); |
70ed823bdbb6
patch 8.1.1962: leaking memory when using tagfunc()
Bram Moolenaar <Bram@vim.org>
parents:
17893
diff
changeset
|
5052 } |
7 | 5053 vim_free(wp->w_localdir); |
20711
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20384
diff
changeset
|
5054 vim_free(wp->w_prevdir); |
1326 | 5055 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5056 // Remove the window from the b_wininfo lists, it may happen that the |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5057 // freed memory is re-used for another window. |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9599
diff
changeset
|
5058 FOR_ALL_BUFFERS(buf) |
19888
435726a03481
patch 8.2.0500: using the same loop in many places
Bram Moolenaar <Bram@vim.org>
parents:
19291
diff
changeset
|
5059 FOR_ALL_BUF_WININFO(buf, wip) |
5237
647596ab1ae2
updated for version 7.4a.044
Bram Moolenaar <bram@vim.org>
parents:
5233
diff
changeset
|
5060 if (wip->wi_win == wp) |
22713
e871a824efc9
patch 8.2.1905: the wininfo list may contain stale entries
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
5061 { |
e871a824efc9
patch 8.2.1905: the wininfo list may contain stale entries
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
5062 wininfo_T *wip2; |
e871a824efc9
patch 8.2.1905: the wininfo list may contain stale entries
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
5063 |
e871a824efc9
patch 8.2.1905: the wininfo list may contain stale entries
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
5064 // If there already is an entry with "wi_win" set to NULL it |
e871a824efc9
patch 8.2.1905: the wininfo list may contain stale entries
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
5065 // must be removed, it would never be used. |
25157
9a2e7184b604
patch 8.2.3115: Coverity complains about free_wininfo() use
Bram Moolenaar <Bram@vim.org>
parents:
25064
diff
changeset
|
5066 // Skip "wip" itself, otherwise Coverity complains. |
22713
e871a824efc9
patch 8.2.1905: the wininfo list may contain stale entries
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
5067 for (wip2 = buf->b_wininfo; wip2 != NULL; wip2 = wip2->wi_next) |
25157
9a2e7184b604
patch 8.2.3115: Coverity complains about free_wininfo() use
Bram Moolenaar <Bram@vim.org>
parents:
25064
diff
changeset
|
5068 if (wip2 != wip && wip2->wi_win == NULL) |
22713
e871a824efc9
patch 8.2.1905: the wininfo list may contain stale entries
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
5069 { |
e871a824efc9
patch 8.2.1905: the wininfo list may contain stale entries
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
5070 if (wip2->wi_next != NULL) |
e871a824efc9
patch 8.2.1905: the wininfo list may contain stale entries
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
5071 wip2->wi_next->wi_prev = wip2->wi_prev; |
e871a824efc9
patch 8.2.1905: the wininfo list may contain stale entries
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
5072 if (wip2->wi_prev == NULL) |
e871a824efc9
patch 8.2.1905: the wininfo list may contain stale entries
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
5073 buf->b_wininfo = wip2->wi_next; |
e871a824efc9
patch 8.2.1905: the wininfo list may contain stale entries
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
5074 else |
e871a824efc9
patch 8.2.1905: the wininfo list may contain stale entries
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
5075 wip2->wi_prev->wi_next = wip2->wi_next; |
e871a824efc9
patch 8.2.1905: the wininfo list may contain stale entries
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
5076 free_wininfo(wip2); |
e871a824efc9
patch 8.2.1905: the wininfo list may contain stale entries
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
5077 break; |
e871a824efc9
patch 8.2.1905: the wininfo list may contain stale entries
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
5078 } |
e871a824efc9
patch 8.2.1905: the wininfo list may contain stale entries
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
5079 |
5237
647596ab1ae2
updated for version 7.4a.044
Bram Moolenaar <bram@vim.org>
parents:
5233
diff
changeset
|
5080 wip->wi_win = NULL; |
22713
e871a824efc9
patch 8.2.1905: the wininfo list may contain stale entries
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
5081 } |
5237
647596ab1ae2
updated for version 7.4a.044
Bram Moolenaar <bram@vim.org>
parents:
5233
diff
changeset
|
5082 |
7 | 5083 #ifdef FEAT_SEARCH_EXTRA |
1326 | 5084 clear_matches(wp); |
5085 #endif | |
5086 | |
7 | 5087 #ifdef FEAT_JUMPLIST |
5088 free_jumplist(wp); | |
5089 #endif | |
5090 | |
643 | 5091 #ifdef FEAT_QUICKFIX |
5092 qf_free_all(wp); | |
5093 #endif | |
5094 | |
7 | 5095 #ifdef FEAT_GUI |
5096 if (gui.in_use) | |
5097 { | |
5098 gui_mch_destroy_scrollbar(&wp->w_scrollbars[SBAR_LEFT]); | |
5099 gui_mch_destroy_scrollbar(&wp->w_scrollbars[SBAR_RIGHT]); | |
5100 } | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5101 #endif // FEAT_GUI |
7 | 5102 |
12487
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
5103 #ifdef FEAT_MENU |
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
5104 remove_winbar(wp); |
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
5105 #endif |
18763
49b78d6465e5
patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents:
18590
diff
changeset
|
5106 #ifdef FEAT_PROP_POPUP |
16890
5131023c5728
patch 8.1.1446: popup window callback not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
16888
diff
changeset
|
5107 free_callback(&wp->w_close_cb); |
16880
998603a243d7
patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents:
16874
diff
changeset
|
5108 free_callback(&wp->w_filter_cb); |
16888
ec61b6b79865
patch 8.1.1445: popup window border highlight not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
16880
diff
changeset
|
5109 for (i = 0; i < 4; ++i) |
ec61b6b79865
patch 8.1.1445: popup window border highlight not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
16880
diff
changeset
|
5110 VIM_CLEAR(wp->w_border_highlight[i]); |
17202
4b40e8821f56
patch 8.1.1600: cannot specify highlighting for popup window scrollbar
Bram Moolenaar <Bram@vim.org>
parents:
17162
diff
changeset
|
5111 vim_free(wp->w_scrollbar_highlight); |
4b40e8821f56
patch 8.1.1600: cannot specify highlighting for popup window scrollbar
Bram Moolenaar <Bram@vim.org>
parents:
17162
diff
changeset
|
5112 vim_free(wp->w_thumb_highlight); |
17119
b439e096a011
patch 8.1.1559: popup window title property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
17111
diff
changeset
|
5113 vim_free(wp->w_popup_title); |
17162
f16cee6adf29
patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents:
17119
diff
changeset
|
5114 list_unref(wp->w_popup_mask); |
17514
984cc7258468
patch 8.1.1755: leaking memory when using a popup window mask
Bram Moolenaar <Bram@vim.org>
parents:
17472
diff
changeset
|
5115 vim_free(wp->w_popup_mask_cells); |
16880
998603a243d7
patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents:
16874
diff
changeset
|
5116 #endif |
12487
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
5117 |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2201
diff
changeset
|
5118 #ifdef FEAT_SYN_HL |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2306
diff
changeset
|
5119 vim_free(wp->w_p_cc_cols); |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2201
diff
changeset
|
5120 #endif |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2201
diff
changeset
|
5121 |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
5122 if (win_valid_any_tab(wp)) |
1918 | 5123 win_remove(wp, tp); |
5958 | 5124 if (autocmd_busy) |
5125 { | |
5126 wp->w_next = au_pending_free_win; | |
5127 au_pending_free_win = wp; | |
5128 } | |
5129 else | |
5130 vim_free(wp); | |
1114 | 5131 |
1410 | 5132 unblock_autocmds(); |
7 | 5133 } |
5134 | |
5135 /* | |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
5136 * Return TRUE if "wp" is not in the list of windows: the autocmd window or a |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
5137 * popup window. |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
5138 */ |
17789
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17670
diff
changeset
|
5139 static int |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
5140 win_unlisted(win_T *wp) |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
5141 { |
17225
09fa437d33d8
patch 8.1.1612: cannot show an existing buffer in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
17202
diff
changeset
|
5142 return wp == aucmd_win || WIN_IS_POPUP(wp); |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
5143 } |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
5144 |
18763
49b78d6465e5
patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents:
18590
diff
changeset
|
5145 #if defined(FEAT_PROP_POPUP) || defined(PROTO) |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
5146 /* |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
5147 * Free a popup window. This does not take the window out of the window list |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
5148 * and assumes there is only one toplevel frame, no split. |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
5149 */ |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
5150 void |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
5151 win_free_popup(win_T *win) |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
5152 { |
17225
09fa437d33d8
patch 8.1.1612: cannot show an existing buffer in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
17202
diff
changeset
|
5153 if (bt_popup(win->w_buffer)) |
17823
7e6b7a4f13bc
patch 8.1.1908: every popup window consumes a buffer number
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
5154 win_close_buffer(win, DOBUF_WIPE_REUSE, FALSE); |
17225
09fa437d33d8
patch 8.1.1612: cannot show an existing buffer in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
17202
diff
changeset
|
5155 else |
18886
050f5eaa9e50
patch 8.2.0004: get E685 and E931 if buffer reload is interrupted
Bram Moolenaar <Bram@vim.org>
parents:
18816
diff
changeset
|
5156 close_buffer(win, win->w_buffer, 0, FALSE, FALSE); |
16802
f5487021fdad
patch 8.1.1403: cannot build without the timer feature
Bram Moolenaar <Bram@vim.org>
parents:
16800
diff
changeset
|
5157 # if defined(FEAT_TIMERS) |
16800
12e3a3afdb6a
patch 8.1.1402: "timer" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents:
16796
diff
changeset
|
5158 if (win->w_popup_timer != NULL) |
12e3a3afdb6a
patch 8.1.1402: "timer" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents:
16796
diff
changeset
|
5159 stop_timer(win->w_popup_timer); |
16802
f5487021fdad
patch 8.1.1403: cannot build without the timer feature
Bram Moolenaar <Bram@vim.org>
parents:
16800
diff
changeset
|
5160 # endif |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
5161 vim_free(win->w_frame); |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
5162 win_free(win, NULL); |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
5163 } |
16802
f5487021fdad
patch 8.1.1403: cannot build without the timer feature
Bram Moolenaar <Bram@vim.org>
parents:
16800
diff
changeset
|
5164 #endif |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
5165 |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
5166 /* |
7 | 5167 * Append window "wp" in the window list after window "after". |
5168 */ | |
17789
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17670
diff
changeset
|
5169 static void |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5170 win_append(win_T *after, win_T *wp) |
7 | 5171 { |
5172 win_T *before; | |
5173 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5174 if (after == NULL) // after NULL is in front of the first |
7 | 5175 before = firstwin; |
5176 else | |
5177 before = after->w_next; | |
5178 | |
5179 wp->w_next = before; | |
5180 wp->w_prev = after; | |
5181 if (after == NULL) | |
5182 firstwin = wp; | |
5183 else | |
5184 after->w_next = wp; | |
5185 if (before == NULL) | |
5186 lastwin = wp; | |
5187 else | |
5188 before->w_prev = wp; | |
5189 } | |
5190 | |
5191 /* | |
5192 * Remove a window from the window list. | |
5193 */ | |
1906 | 5194 void |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5195 win_remove( |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5196 win_T *wp, |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5197 tabpage_T *tp) // tab page "win" is in, NULL for current |
7 | 5198 { |
5199 if (wp->w_prev != NULL) | |
5200 wp->w_prev->w_next = wp->w_next; | |
671 | 5201 else if (tp == NULL) |
12564
183dc24cf861
patch 8.0.1160: getting tab-local variable fails after closing window
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
5202 firstwin = curtab->tp_firstwin = wp->w_next; |
7 | 5203 else |
671 | 5204 tp->tp_firstwin = wp->w_next; |
12564
183dc24cf861
patch 8.0.1160: getting tab-local variable fails after closing window
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
5205 |
7 | 5206 if (wp->w_next != NULL) |
5207 wp->w_next->w_prev = wp->w_prev; | |
671 | 5208 else if (tp == NULL) |
12564
183dc24cf861
patch 8.0.1160: getting tab-local variable fails after closing window
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
5209 lastwin = curtab->tp_lastwin = wp->w_prev; |
7 | 5210 else |
671 | 5211 tp->tp_lastwin = wp->w_prev; |
7 | 5212 } |
5213 | |
5214 /* | |
5215 * Append frame "frp" in a frame list after frame "after". | |
5216 */ | |
5217 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5218 frame_append(frame_T *after, frame_T *frp) |
7 | 5219 { |
5220 frp->fr_next = after->fr_next; | |
5221 after->fr_next = frp; | |
5222 if (frp->fr_next != NULL) | |
5223 frp->fr_next->fr_prev = frp; | |
5224 frp->fr_prev = after; | |
5225 } | |
5226 | |
5227 /* | |
5228 * Insert frame "frp" in a frame list before frame "before". | |
5229 */ | |
5230 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5231 frame_insert(frame_T *before, frame_T *frp) |
7 | 5232 { |
5233 frp->fr_next = before; | |
5234 frp->fr_prev = before->fr_prev; | |
5235 before->fr_prev = frp; | |
5236 if (frp->fr_prev != NULL) | |
5237 frp->fr_prev->fr_next = frp; | |
5238 else | |
5239 frp->fr_parent->fr_child = frp; | |
5240 } | |
5241 | |
5242 /* | |
5243 * Remove a frame from a frame list. | |
5244 */ | |
5245 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5246 frame_remove(frame_T *frp) |
7 | 5247 { |
5248 if (frp->fr_prev != NULL) | |
5249 frp->fr_prev->fr_next = frp->fr_next; | |
5250 else | |
13144
20fb8c711050
patch 8.0.1446: acessing freed memory after window command in auto command
Christian Brabandt <cb@256bit.org>
parents:
13103
diff
changeset
|
5251 { |
7 | 5252 frp->fr_parent->fr_child = frp->fr_next; |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5253 // special case: topframe->fr_child == frp |
13144
20fb8c711050
patch 8.0.1446: acessing freed memory after window command in auto command
Christian Brabandt <cb@256bit.org>
parents:
13103
diff
changeset
|
5254 if (topframe->fr_child == frp) |
20fb8c711050
patch 8.0.1446: acessing freed memory after window command in auto command
Christian Brabandt <cb@256bit.org>
parents:
13103
diff
changeset
|
5255 topframe->fr_child = frp->fr_next; |
20fb8c711050
patch 8.0.1446: acessing freed memory after window command in auto command
Christian Brabandt <cb@256bit.org>
parents:
13103
diff
changeset
|
5256 } |
7 | 5257 if (frp->fr_next != NULL) |
5258 frp->fr_next->fr_prev = frp->fr_prev; | |
5259 } | |
5260 | |
5261 /* | |
5262 * Allocate w_lines[] for window "wp". | |
5263 * Return FAIL for failure, OK for success. | |
5264 */ | |
5265 int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5266 win_alloc_lines(win_T *wp) |
7 | 5267 { |
5268 wp->w_lines_valid = 0; | |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16802
diff
changeset
|
5269 wp->w_lines = ALLOC_CLEAR_MULT(wline_T, Rows ); |
7 | 5270 if (wp->w_lines == NULL) |
5271 return FAIL; | |
5272 return OK; | |
5273 } | |
5274 | |
5275 /* | |
5276 * free lsize arrays for a window | |
5277 */ | |
5278 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5279 win_free_lsize(win_T *wp) |
7 | 5280 { |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5281 // TODO: why would wp be NULL here? |
5952 | 5282 if (wp != NULL) |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13144
diff
changeset
|
5283 VIM_CLEAR(wp->w_lines); |
7 | 5284 } |
5285 | |
5286 /* | |
5287 * Called from win_new_shellsize() after Rows changed. | |
671 | 5288 * This only does the current tab page, others must be done when made active. |
7 | 5289 */ |
5290 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5291 shell_new_rows(void) |
7 | 5292 { |
667 | 5293 int h = (int)ROWS_AVAIL; |
7 | 5294 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5295 if (firstwin == NULL) // not initialized yet |
7 | 5296 return; |
5297 if (h < frame_minheight(topframe, NULL)) | |
5298 h = frame_minheight(topframe, NULL); | |
779 | 5299 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5300 // First try setting the heights of windows with 'winfixheight'. If |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5301 // that doesn't result in the right height, forget about that option. |
7 | 5302 frame_new_height(topframe, h, FALSE, TRUE); |
5004
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
5303 if (!frame_check_height(topframe, h)) |
7 | 5304 frame_new_height(topframe, h, FALSE, FALSE); |
5305 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5306 (void)win_comp_pos(); // recompute w_winrow and w_wincol |
7 | 5307 compute_cmdrow(); |
824 | 5308 curtab->tp_ch_used = p_ch; |
170 | 5309 |
7 | 5310 #if 0 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5311 // Disabled: don't want making the screen smaller make a window larger. |
7 | 5312 if (p_ea) |
5313 win_equal(curwin, FALSE, 'v'); | |
5314 #endif | |
5315 } | |
5316 | |
5317 /* | |
5318 * Called from win_new_shellsize() after Columns changed. | |
5319 */ | |
5320 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5321 shell_new_columns(void) |
7 | 5322 { |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5323 if (firstwin == NULL) // not initialized yet |
7 | 5324 return; |
779 | 5325 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5326 // First try setting the widths of windows with 'winfixwidth'. If that |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5327 // doesn't result in the right width, forget about that option. |
779 | 5328 frame_new_width(topframe, (int)Columns, FALSE, TRUE); |
5004
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
5329 if (!frame_check_width(topframe, Columns)) |
779 | 5330 frame_new_width(topframe, (int)Columns, FALSE, FALSE); |
5331 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5332 (void)win_comp_pos(); // recompute w_winrow and w_wincol |
7 | 5333 #if 0 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5334 // Disabled: don't want making the screen smaller make a window larger. |
7 | 5335 if (p_ea) |
5336 win_equal(curwin, FALSE, 'h'); | |
5337 #endif | |
5338 } | |
5339 | |
5340 #if defined(FEAT_CMDWIN) || defined(PROTO) | |
5341 /* | |
5342 * Save the size of all windows in "gap". | |
5343 */ | |
5344 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5345 win_size_save(garray_T *gap) |
7 | 5346 |
5347 { | |
5348 win_T *wp; | |
5349 | |
5350 ga_init2(gap, (int)sizeof(int), 1); | |
18467
99fc29219b3e
patch 8.1.2227: layout wrong if 'lines' changes while cmdline window is open
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5351 if (ga_grow(gap, win_count() * 2 + 1) == OK) |
99fc29219b3e
patch 8.1.2227: layout wrong if 'lines' changes while cmdline window is open
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5352 { |
99fc29219b3e
patch 8.1.2227: layout wrong if 'lines' changes while cmdline window is open
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5353 // first entry is value of 'lines' |
99fc29219b3e
patch 8.1.2227: layout wrong if 'lines' changes while cmdline window is open
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5354 ((int *)gap->ga_data)[gap->ga_len++] = Rows; |
99fc29219b3e
patch 8.1.2227: layout wrong if 'lines' changes while cmdline window is open
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5355 |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9599
diff
changeset
|
5356 FOR_ALL_WINDOWS(wp) |
7 | 5357 { |
5358 ((int *)gap->ga_data)[gap->ga_len++] = | |
5359 wp->w_width + wp->w_vsep_width; | |
5360 ((int *)gap->ga_data)[gap->ga_len++] = wp->w_height; | |
5361 } | |
18467
99fc29219b3e
patch 8.1.2227: layout wrong if 'lines' changes while cmdline window is open
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5362 } |
7 | 5363 } |
5364 | |
5365 /* | |
18467
99fc29219b3e
patch 8.1.2227: layout wrong if 'lines' changes while cmdline window is open
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5366 * Restore window sizes, but only if the number of windows is still the same |
99fc29219b3e
patch 8.1.2227: layout wrong if 'lines' changes while cmdline window is open
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5367 * and 'lines' didn't change. |
7 | 5368 * Does not free the growarray. |
5369 */ | |
5370 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5371 win_size_restore(garray_T *gap) |
7 | 5372 { |
5373 win_T *wp; | |
6058 | 5374 int i, j; |
7 | 5375 |
18467
99fc29219b3e
patch 8.1.2227: layout wrong if 'lines' changes while cmdline window is open
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5376 if (win_count() * 2 + 1 == gap->ga_len |
99fc29219b3e
patch 8.1.2227: layout wrong if 'lines' changes while cmdline window is open
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5377 && ((int *)gap->ga_data)[0] == Rows) |
7 | 5378 { |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5379 // The order matters, because frames contain other frames, but it's |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5380 // difficult to get right. The easy way out is to do it twice. |
6058 | 5381 for (j = 0; j < 2; ++j) |
7 | 5382 { |
18467
99fc29219b3e
patch 8.1.2227: layout wrong if 'lines' changes while cmdline window is open
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5383 i = 1; |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9599
diff
changeset
|
5384 FOR_ALL_WINDOWS(wp) |
6058 | 5385 { |
5386 frame_setwidth(wp->w_frame, ((int *)gap->ga_data)[i++]); | |
5387 win_setheight_win(((int *)gap->ga_data)[i++], wp); | |
5388 } | |
7 | 5389 } |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5390 // recompute the window positions |
7 | 5391 (void)win_comp_pos(); |
5392 } | |
5393 } | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5394 #endif // FEAT_CMDWIN |
7 | 5395 |
5396 /* | |
5397 * Update the position for all windows, using the width and height of the | |
5398 * frames. | |
5399 * Returns the row just after the last window. | |
5400 */ | |
668 | 5401 int |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5402 win_comp_pos(void) |
7 | 5403 { |
685 | 5404 int row = tabline_height(); |
7 | 5405 int col = 0; |
5406 | |
5407 frame_comp_pos(topframe, &row, &col); | |
5408 return row; | |
5409 } | |
5410 | |
5411 /* | |
5412 * Update the position of the windows in frame "topfrp", using the width and | |
5413 * height of the frames. | |
5414 * "*row" and "*col" are the top-left position of the frame. They are updated | |
5415 * to the bottom-right position plus one. | |
5416 */ | |
5417 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5418 frame_comp_pos(frame_T *topfrp, int *row, int *col) |
7 | 5419 { |
5420 win_T *wp; | |
5421 frame_T *frp; | |
5422 int startcol; | |
5423 int startrow; | |
12998
dd734ee3e2fe
patch 8.0.1375: window size wrong after maximizing with WinBar
Christian Brabandt <cb@256bit.org>
parents:
12916
diff
changeset
|
5424 int h; |
7 | 5425 |
5426 wp = topfrp->fr_win; | |
5427 if (wp != NULL) | |
5428 { | |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8536
diff
changeset
|
5429 if (wp->w_winrow != *row || wp->w_wincol != *col) |
7 | 5430 { |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5431 // position changed, redraw |
7 | 5432 wp->w_winrow = *row; |
5433 wp->w_wincol = *col; | |
5434 redraw_win_later(wp, NOT_VALID); | |
5435 wp->w_redr_status = TRUE; | |
5436 } | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5437 // WinBar will not show if the window height is zero |
12998
dd734ee3e2fe
patch 8.0.1375: window size wrong after maximizing with WinBar
Christian Brabandt <cb@256bit.org>
parents:
12916
diff
changeset
|
5438 h = VISIBLE_HEIGHT(wp) + wp->w_status_height; |
dd734ee3e2fe
patch 8.0.1375: window size wrong after maximizing with WinBar
Christian Brabandt <cb@256bit.org>
parents:
12916
diff
changeset
|
5439 *row += h > topfrp->fr_height ? topfrp->fr_height : h; |
7 | 5440 *col += wp->w_width + wp->w_vsep_width; |
5441 } | |
5442 else | |
5443 { | |
5444 startrow = *row; | |
5445 startcol = *col; | |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
5446 FOR_ALL_FRAMES(frp, topfrp->fr_child) |
7 | 5447 { |
5448 if (topfrp->fr_layout == FR_ROW) | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5449 *row = startrow; // all frames are at the same row |
7 | 5450 else |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5451 *col = startcol; // all frames are at the same col |
7 | 5452 frame_comp_pos(frp, row, col); |
5453 } | |
5454 } | |
5455 } | |
5456 | |
5457 /* | |
5458 * Set current window height and take care of repositioning other windows to | |
5459 * fit around it. | |
5460 */ | |
5461 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5462 win_setheight(int height) |
7 | 5463 { |
5464 win_setheight_win(height, curwin); | |
5465 } | |
5466 | |
5467 /* | |
5468 * Set the window height of window "win" and take care of repositioning other | |
5469 * windows to fit around it. | |
5470 */ | |
5471 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5472 win_setheight_win(int height, win_T *win) |
7 | 5473 { |
5474 int row; | |
5475 | |
5476 if (win == curwin) | |
5477 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5478 // Always keep current window at least one line high, even when |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5479 // 'winminheight' is zero. |
7 | 5480 if (height < p_wmh) |
5481 height = p_wmh; | |
5482 if (height == 0) | |
5483 height = 1; | |
12998
dd734ee3e2fe
patch 8.0.1375: window size wrong after maximizing with WinBar
Christian Brabandt <cb@256bit.org>
parents:
12916
diff
changeset
|
5484 height += WINBAR_HEIGHT(curwin); |
7 | 5485 } |
5486 | |
5487 frame_setheight(win->w_frame, height + win->w_status_height); | |
5488 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5489 // recompute the window positions |
7 | 5490 row = win_comp_pos(); |
5491 | |
5492 /* | |
5493 * If there is extra space created between the last window and the command | |
5494 * line, clear it. | |
5495 */ | |
5496 if (full_screen && msg_scrolled == 0 && row < cmdline_row) | |
5497 screen_fill(row, cmdline_row, 0, (int)Columns, ' ', ' ', 0); | |
5498 cmdline_row = row; | |
5499 msg_row = row; | |
5500 msg_col = 0; | |
5501 | |
5502 redraw_all_later(NOT_VALID); | |
5503 } | |
5504 | |
5505 /* | |
5506 * Set the height of a frame to "height" and take care that all frames and | |
5507 * windows inside it are resized. Also resize frames on the left and right if | |
5508 * the are in the same FR_ROW frame. | |
5509 * | |
5510 * Strategy: | |
5511 * If the frame is part of a FR_COL frame, try fitting the frame in that | |
5512 * frame. If that doesn't work (the FR_COL frame is too small), recursively | |
5513 * go to containing frames to resize them and make room. | |
5514 * If the frame is part of a FR_ROW frame, all frames must be resized as well. | |
5515 * Check for the minimal height of the FR_ROW frame. | |
5516 * At the top level we can also use change the command line height. | |
5517 */ | |
5518 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5519 frame_setheight(frame_T *curfrp, int height) |
7 | 5520 { |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5521 int room; // total number of lines available |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5522 int take; // number of lines taken from other windows |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5523 int room_cmdline; // lines available from cmdline |
7 | 5524 int run; |
5525 frame_T *frp; | |
5526 int h; | |
5527 int room_reserved; | |
5528 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5529 // If the height already is the desired value, nothing to do. |
7 | 5530 if (curfrp->fr_height == height) |
5531 return; | |
5532 | |
5533 if (curfrp->fr_parent == NULL) | |
5534 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5535 // topframe: can only change the command line |
667 | 5536 if (height > ROWS_AVAIL) |
5537 height = ROWS_AVAIL; | |
7 | 5538 if (height > 0) |
5539 frame_new_height(curfrp, height, FALSE, FALSE); | |
5540 } | |
5541 else if (curfrp->fr_parent->fr_layout == FR_ROW) | |
5542 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5543 // Row of frames: Also need to resize frames left and right of this |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5544 // one. First check for the minimal height of these. |
7 | 5545 h = frame_minheight(curfrp->fr_parent, NULL); |
5546 if (height < h) | |
5547 height = h; | |
5548 frame_setheight(curfrp->fr_parent, height); | |
5549 } | |
5550 else | |
5551 { | |
5552 /* | |
5553 * Column of frames: try to change only frames in this column. | |
5554 */ | |
5555 /* | |
5556 * Do this twice: | |
5557 * 1: compute room available, if it's not enough try resizing the | |
5558 * containing frame. | |
5559 * 2: compute the room available and adjust the height to it. | |
5560 * Try not to reduce the height of a window with 'winfixheight' set. | |
5561 */ | |
5562 for (run = 1; run <= 2; ++run) | |
5563 { | |
5564 room = 0; | |
5565 room_reserved = 0; | |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
5566 FOR_ALL_FRAMES(frp, curfrp->fr_parent->fr_child) |
7 | 5567 { |
5568 if (frp != curfrp | |
5569 && frp->fr_win != NULL | |
5570 && frp->fr_win->w_p_wfh) | |
5571 room_reserved += frp->fr_height; | |
5572 room += frp->fr_height; | |
5573 if (frp != curfrp) | |
5574 room -= frame_minheight(frp, NULL); | |
5575 } | |
5576 if (curfrp->fr_width != Columns) | |
5577 room_cmdline = 0; | |
5578 else | |
5579 { | |
5580 room_cmdline = Rows - p_ch - (lastwin->w_winrow | |
12998
dd734ee3e2fe
patch 8.0.1375: window size wrong after maximizing with WinBar
Christian Brabandt <cb@256bit.org>
parents:
12916
diff
changeset
|
5581 + VISIBLE_HEIGHT(lastwin) |
dd734ee3e2fe
patch 8.0.1375: window size wrong after maximizing with WinBar
Christian Brabandt <cb@256bit.org>
parents:
12916
diff
changeset
|
5582 + lastwin->w_status_height); |
7 | 5583 if (room_cmdline < 0) |
5584 room_cmdline = 0; | |
5585 } | |
5586 | |
5587 if (height <= room + room_cmdline) | |
5588 break; | |
5589 if (run == 2 || curfrp->fr_width == Columns) | |
5590 { | |
5591 if (height > room + room_cmdline) | |
5592 height = room + room_cmdline; | |
5593 break; | |
5594 } | |
5595 frame_setheight(curfrp->fr_parent, height | |
5596 + frame_minheight(curfrp->fr_parent, NOWIN) - (int)p_wmh - 1); | |
5597 } | |
5598 | |
5599 /* | |
5600 * Compute the number of lines we will take from others frames (can be | |
5601 * negative!). | |
5602 */ | |
5603 take = height - curfrp->fr_height; | |
5604 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5605 // If there is not enough room, also reduce the height of a window |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5606 // with 'winfixheight' set. |
7 | 5607 if (height > room + room_cmdline - room_reserved) |
5608 room_reserved = room + room_cmdline - height; | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5609 // If there is only a 'winfixheight' window and making the |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5610 // window smaller, need to make the other window taller. |
7 | 5611 if (take < 0 && room - curfrp->fr_height < room_reserved) |
5612 room_reserved = 0; | |
5613 | |
5614 if (take > 0 && room_cmdline > 0) | |
5615 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5616 // use lines from cmdline first |
7 | 5617 if (take < room_cmdline) |
5618 room_cmdline = take; | |
5619 take -= room_cmdline; | |
5620 topframe->fr_height += room_cmdline; | |
5621 } | |
5622 | |
5623 /* | |
5624 * set the current frame to the new height | |
5625 */ | |
5626 frame_new_height(curfrp, height, FALSE, FALSE); | |
5627 | |
5628 /* | |
5629 * First take lines from the frames after the current frame. If | |
5630 * that is not enough, takes lines from frames above the current | |
5631 * frame. | |
5632 */ | |
5633 for (run = 0; run < 2; ++run) | |
5634 { | |
5635 if (run == 0) | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5636 frp = curfrp->fr_next; // 1st run: start with next window |
7 | 5637 else |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5638 frp = curfrp->fr_prev; // 2nd run: start with prev window |
7 | 5639 while (frp != NULL && take != 0) |
5640 { | |
5641 h = frame_minheight(frp, NULL); | |
5642 if (room_reserved > 0 | |
5643 && frp->fr_win != NULL | |
5644 && frp->fr_win->w_p_wfh) | |
5645 { | |
5646 if (room_reserved >= frp->fr_height) | |
5647 room_reserved -= frp->fr_height; | |
5648 else | |
5649 { | |
5650 if (frp->fr_height - room_reserved > take) | |
5651 room_reserved = frp->fr_height - take; | |
5652 take -= frp->fr_height - room_reserved; | |
5653 frame_new_height(frp, room_reserved, FALSE, FALSE); | |
5654 room_reserved = 0; | |
5655 } | |
5656 } | |
5657 else | |
5658 { | |
5659 if (frp->fr_height - take < h) | |
5660 { | |
5661 take -= frp->fr_height - h; | |
5662 frame_new_height(frp, h, FALSE, FALSE); | |
5663 } | |
5664 else | |
5665 { | |
5666 frame_new_height(frp, frp->fr_height - take, | |
5667 FALSE, FALSE); | |
5668 take = 0; | |
5669 } | |
5670 } | |
5671 if (run == 0) | |
5672 frp = frp->fr_next; | |
5673 else | |
5674 frp = frp->fr_prev; | |
5675 } | |
5676 } | |
5677 } | |
5678 } | |
5679 | |
5680 /* | |
5681 * Set current window width and take care of repositioning other windows to | |
5682 * fit around it. | |
5683 */ | |
5684 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5685 win_setwidth(int width) |
7 | 5686 { |
5687 win_setwidth_win(width, curwin); | |
5688 } | |
5689 | |
5690 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5691 win_setwidth_win(int width, win_T *wp) |
7 | 5692 { |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5693 // Always keep current window at least one column wide, even when |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5694 // 'winminwidth' is zero. |
7 | 5695 if (wp == curwin) |
5696 { | |
5697 if (width < p_wmw) | |
5698 width = p_wmw; | |
5699 if (width == 0) | |
5700 width = 1; | |
5701 } | |
23402
65718283239b
patch 8.2.2244: crash when making the window width negative
Bram Moolenaar <Bram@vim.org>
parents:
23386
diff
changeset
|
5702 else if (width < 0) |
65718283239b
patch 8.2.2244: crash when making the window width negative
Bram Moolenaar <Bram@vim.org>
parents:
23386
diff
changeset
|
5703 width = 0; |
7 | 5704 |
5705 frame_setwidth(wp->w_frame, width + wp->w_vsep_width); | |
5706 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5707 // recompute the window positions |
7 | 5708 (void)win_comp_pos(); |
5709 | |
5710 redraw_all_later(NOT_VALID); | |
5711 } | |
5712 | |
5713 /* | |
5714 * Set the width of a frame to "width" and take care that all frames and | |
5715 * windows inside it are resized. Also resize frames above and below if the | |
5716 * are in the same FR_ROW frame. | |
5717 * | |
5718 * Strategy is similar to frame_setheight(). | |
5719 */ | |
5720 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5721 frame_setwidth(frame_T *curfrp, int width) |
7 | 5722 { |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5723 int room; // total number of lines available |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5724 int take; // number of lines taken from other windows |
7 | 5725 int run; |
5726 frame_T *frp; | |
5727 int w; | |
779 | 5728 int room_reserved; |
7 | 5729 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5730 // If the width already is the desired value, nothing to do. |
7 | 5731 if (curfrp->fr_width == width) |
5732 return; | |
5733 | |
5734 if (curfrp->fr_parent == NULL) | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5735 // topframe: can't change width |
7 | 5736 return; |
5737 | |
5738 if (curfrp->fr_parent->fr_layout == FR_COL) | |
5739 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5740 // Column of frames: Also need to resize frames above and below of |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5741 // this one. First check for the minimal width of these. |
7 | 5742 w = frame_minwidth(curfrp->fr_parent, NULL); |
5743 if (width < w) | |
5744 width = w; | |
5745 frame_setwidth(curfrp->fr_parent, width); | |
5746 } | |
5747 else | |
5748 { | |
5749 /* | |
5750 * Row of frames: try to change only frames in this row. | |
5751 * | |
5752 * Do this twice: | |
5753 * 1: compute room available, if it's not enough try resizing the | |
5754 * containing frame. | |
5755 * 2: compute the room available and adjust the width to it. | |
5756 */ | |
5757 for (run = 1; run <= 2; ++run) | |
5758 { | |
5759 room = 0; | |
779 | 5760 room_reserved = 0; |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
5761 FOR_ALL_FRAMES(frp, curfrp->fr_parent->fr_child) |
7 | 5762 { |
779 | 5763 if (frp != curfrp |
5764 && frp->fr_win != NULL | |
5765 && frp->fr_win->w_p_wfw) | |
5766 room_reserved += frp->fr_width; | |
7 | 5767 room += frp->fr_width; |
5768 if (frp != curfrp) | |
5769 room -= frame_minwidth(frp, NULL); | |
5770 } | |
5771 | |
5772 if (width <= room) | |
5773 break; | |
667 | 5774 if (run == 2 || curfrp->fr_height >= ROWS_AVAIL) |
7 | 5775 { |
5776 if (width > room) | |
5777 width = room; | |
5778 break; | |
5779 } | |
5780 frame_setwidth(curfrp->fr_parent, width | |
5781 + frame_minwidth(curfrp->fr_parent, NOWIN) - (int)p_wmw - 1); | |
5782 } | |
5783 | |
5784 /* | |
5785 * Compute the number of lines we will take from others frames (can be | |
5786 * negative!). | |
5787 */ | |
5788 take = width - curfrp->fr_width; | |
5789 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5790 // If there is not enough room, also reduce the width of a window |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5791 // with 'winfixwidth' set. |
779 | 5792 if (width > room - room_reserved) |
5793 room_reserved = room - width; | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5794 // If there is only a 'winfixwidth' window and making the |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5795 // window smaller, need to make the other window narrower. |
779 | 5796 if (take < 0 && room - curfrp->fr_width < room_reserved) |
5797 room_reserved = 0; | |
5798 | |
7 | 5799 /* |
5800 * set the current frame to the new width | |
5801 */ | |
779 | 5802 frame_new_width(curfrp, width, FALSE, FALSE); |
7 | 5803 |
5804 /* | |
5805 * First take lines from the frames right of the current frame. If | |
5806 * that is not enough, takes lines from frames left of the current | |
5807 * frame. | |
5808 */ | |
5809 for (run = 0; run < 2; ++run) | |
5810 { | |
5811 if (run == 0) | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5812 frp = curfrp->fr_next; // 1st run: start with next window |
7 | 5813 else |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5814 frp = curfrp->fr_prev; // 2nd run: start with prev window |
7 | 5815 while (frp != NULL && take != 0) |
5816 { | |
5817 w = frame_minwidth(frp, NULL); | |
779 | 5818 if (room_reserved > 0 |
5819 && frp->fr_win != NULL | |
5820 && frp->fr_win->w_p_wfw) | |
7 | 5821 { |
779 | 5822 if (room_reserved >= frp->fr_width) |
5823 room_reserved -= frp->fr_width; | |
5824 else | |
5825 { | |
5826 if (frp->fr_width - room_reserved > take) | |
5827 room_reserved = frp->fr_width - take; | |
5828 take -= frp->fr_width - room_reserved; | |
5829 frame_new_width(frp, room_reserved, FALSE, FALSE); | |
5830 room_reserved = 0; | |
5831 } | |
7 | 5832 } |
5833 else | |
5834 { | |
779 | 5835 if (frp->fr_width - take < w) |
5836 { | |
5837 take -= frp->fr_width - w; | |
5838 frame_new_width(frp, w, FALSE, FALSE); | |
5839 } | |
5840 else | |
5841 { | |
5842 frame_new_width(frp, frp->fr_width - take, | |
5843 FALSE, FALSE); | |
5844 take = 0; | |
5845 } | |
7 | 5846 } |
5847 if (run == 0) | |
5848 frp = frp->fr_next; | |
5849 else | |
5850 frp = frp->fr_prev; | |
5851 } | |
5852 } | |
5853 } | |
5854 } | |
5855 | |
5856 /* | |
14057
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
5857 * Check 'winminheight' for a valid value and reduce it if needed. |
7 | 5858 */ |
5859 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5860 win_setminheight(void) |
7 | 5861 { |
5862 int room; | |
14057
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
5863 int needed; |
7 | 5864 int first = TRUE; |
14057
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
5865 |
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
5866 // loop until there is a 'winminheight' that is possible |
7 | 5867 while (p_wmh > 0) |
5868 { | |
24108
0a5eba7e6660
patch 8.2.2595: setting 'winminheight' may cause 'lines' to change
Bram Moolenaar <Bram@vim.org>
parents:
24037
diff
changeset
|
5869 room = Rows - p_ch; |
0a5eba7e6660
patch 8.2.2595: setting 'winminheight' may cause 'lines' to change
Bram Moolenaar <Bram@vim.org>
parents:
24037
diff
changeset
|
5870 needed = min_rows() - 1; // 1 was added for the cmdline |
14057
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
5871 if (room >= needed) |
7 | 5872 break; |
5873 --p_wmh; | |
5874 if (first) | |
5875 { | |
25306
078edc1821bf
patch 8.2.3190: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
25157
diff
changeset
|
5876 emsg(_(e_not_enough_room)); |
7 | 5877 first = FALSE; |
5878 } | |
5879 } | |
5880 } | |
5881 | |
14057
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
5882 /* |
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
5883 * Check 'winminwidth' for a valid value and reduce it if needed. |
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
5884 */ |
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
5885 void |
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
5886 win_setminwidth(void) |
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
5887 { |
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
5888 int room; |
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
5889 int needed; |
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
5890 int first = TRUE; |
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
5891 |
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
5892 // loop until there is a 'winminheight' that is possible |
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
5893 while (p_wmw > 0) |
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
5894 { |
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
5895 room = Columns; |
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
5896 needed = frame_minwidth(topframe, NULL); |
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
5897 if (room >= needed) |
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
5898 break; |
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
5899 --p_wmw; |
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
5900 if (first) |
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
5901 { |
25306
078edc1821bf
patch 8.2.3190: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
25157
diff
changeset
|
5902 emsg(_(e_not_enough_room)); |
14057
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
5903 first = FALSE; |
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
5904 } |
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
5905 } |
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
5906 } |
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
5907 |
7 | 5908 /* |
5909 * Status line of dragwin is dragged "offset" lines down (negative is up). | |
5910 */ | |
5911 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5912 win_drag_status_line(win_T *dragwin, int offset) |
7 | 5913 { |
5914 frame_T *curfr; | |
5915 frame_T *fr; | |
5916 int room; | |
5917 int row; | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5918 int up; // if TRUE, drag status line up, otherwise down |
7 | 5919 int n; |
5920 | |
5921 fr = dragwin->w_frame; | |
5922 curfr = fr; | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5923 if (fr != topframe) // more than one window |
7 | 5924 { |
5925 fr = fr->fr_parent; | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5926 // When the parent frame is not a column of frames, its parent should |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5927 // be. |
7 | 5928 if (fr->fr_layout != FR_COL) |
5929 { | |
5930 curfr = fr; | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5931 if (fr != topframe) // only a row of windows, may drag statusline |
7 | 5932 fr = fr->fr_parent; |
5933 } | |
5934 } | |
5935 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5936 // If this is the last frame in a column, may want to resize the parent |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5937 // frame instead (go two up to skip a row of frames). |
7 | 5938 while (curfr != topframe && curfr->fr_next == NULL) |
5939 { | |
5940 if (fr != topframe) | |
5941 fr = fr->fr_parent; | |
5942 curfr = fr; | |
5943 if (fr != topframe) | |
5944 fr = fr->fr_parent; | |
5945 } | |
5946 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5947 if (offset < 0) // drag up |
7 | 5948 { |
5949 up = TRUE; | |
5950 offset = -offset; | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5951 // sum up the room of the current frame and above it |
7 | 5952 if (fr == curfr) |
5953 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5954 // only one window |
7 | 5955 room = fr->fr_height - frame_minheight(fr, NULL); |
5956 } | |
5957 else | |
5958 { | |
5959 room = 0; | |
5960 for (fr = fr->fr_child; ; fr = fr->fr_next) | |
5961 { | |
5962 room += fr->fr_height - frame_minheight(fr, NULL); | |
5963 if (fr == curfr) | |
5964 break; | |
5965 } | |
5966 } | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5967 fr = curfr->fr_next; // put fr at frame that grows |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5968 } |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5969 else // drag down |
7 | 5970 { |
5971 up = FALSE; | |
5972 /* | |
5973 * Only dragging the last status line can reduce p_ch. | |
5974 */ | |
5975 room = Rows - cmdline_row; | |
5976 if (curfr->fr_next == NULL) | |
5977 room -= 1; | |
5978 else | |
5979 room -= p_ch; | |
5980 if (room < 0) | |
5981 room = 0; | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5982 // sum up the room of frames below of the current one |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
5983 FOR_ALL_FRAMES(fr, curfr->fr_next) |
7 | 5984 room += fr->fr_height - frame_minheight(fr, NULL); |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5985 fr = curfr; // put fr at window that grows |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5986 } |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5987 |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5988 if (room < offset) // Not enough room |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5989 offset = room; // Move as far as we can |
7 | 5990 if (offset <= 0) |
5991 return; | |
5992 | |
5993 /* | |
5994 * Grow frame fr by "offset" lines. | |
5995 * Doesn't happen when dragging the last status line up. | |
5996 */ | |
5997 if (fr != NULL) | |
5998 frame_new_height(fr, fr->fr_height + offset, up, FALSE); | |
5999 | |
6000 if (up) | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6001 fr = curfr; // current frame gets smaller |
7 | 6002 else |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6003 fr = curfr->fr_next; // next frame gets smaller |
7 | 6004 |
6005 /* | |
6006 * Now make the other frames smaller. | |
6007 */ | |
6008 while (fr != NULL && offset > 0) | |
6009 { | |
6010 n = frame_minheight(fr, NULL); | |
6011 if (fr->fr_height - offset <= n) | |
6012 { | |
6013 offset -= fr->fr_height - n; | |
6014 frame_new_height(fr, n, !up, FALSE); | |
6015 } | |
6016 else | |
6017 { | |
6018 frame_new_height(fr, fr->fr_height - offset, !up, FALSE); | |
6019 break; | |
6020 } | |
6021 if (up) | |
6022 fr = fr->fr_prev; | |
6023 else | |
6024 fr = fr->fr_next; | |
6025 } | |
6026 row = win_comp_pos(); | |
6027 screen_fill(row, cmdline_row, 0, (int)Columns, ' ', ' ', 0); | |
6028 cmdline_row = row; | |
6029 p_ch = Rows - cmdline_row; | |
6030 if (p_ch < 1) | |
6031 p_ch = 1; | |
824 | 6032 curtab->tp_ch_used = p_ch; |
737 | 6033 redraw_all_later(SOME_VALID); |
7 | 6034 showmode(); |
6035 } | |
6036 | |
6037 /* | |
6038 * Separator line of dragwin is dragged "offset" lines right (negative is left). | |
6039 */ | |
6040 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6041 win_drag_vsep_line(win_T *dragwin, int offset) |
7 | 6042 { |
6043 frame_T *curfr; | |
6044 frame_T *fr; | |
6045 int room; | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6046 int left; // if TRUE, drag separator line left, otherwise right |
7 | 6047 int n; |
6048 | |
6049 fr = dragwin->w_frame; | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6050 if (fr == topframe) // only one window (cannot happen?) |
7 | 6051 return; |
6052 curfr = fr; | |
6053 fr = fr->fr_parent; | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6054 // When the parent frame is not a row of frames, its parent should be. |
7 | 6055 if (fr->fr_layout != FR_ROW) |
6056 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6057 if (fr == topframe) // only a column of windows (cannot happen?) |
7 | 6058 return; |
6059 curfr = fr; | |
6060 fr = fr->fr_parent; | |
6061 } | |
6062 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6063 // If this is the last frame in a row, may want to resize a parent |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6064 // frame instead. |
7 | 6065 while (curfr->fr_next == NULL) |
6066 { | |
6067 if (fr == topframe) | |
6068 break; | |
6069 curfr = fr; | |
6070 fr = fr->fr_parent; | |
6071 if (fr != topframe) | |
6072 { | |
6073 curfr = fr; | |
6074 fr = fr->fr_parent; | |
6075 } | |
6076 } | |
6077 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6078 if (offset < 0) // drag left |
7 | 6079 { |
6080 left = TRUE; | |
6081 offset = -offset; | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6082 // sum up the room of the current frame and left of it |
7 | 6083 room = 0; |
6084 for (fr = fr->fr_child; ; fr = fr->fr_next) | |
6085 { | |
6086 room += fr->fr_width - frame_minwidth(fr, NULL); | |
6087 if (fr == curfr) | |
6088 break; | |
6089 } | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6090 fr = curfr->fr_next; // put fr at frame that grows |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6091 } |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6092 else // drag right |
7 | 6093 { |
6094 left = FALSE; | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6095 // sum up the room of frames right of the current one |
7 | 6096 room = 0; |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
6097 FOR_ALL_FRAMES(fr, curfr->fr_next) |
7 | 6098 room += fr->fr_width - frame_minwidth(fr, NULL); |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6099 fr = curfr; // put fr at window that grows |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6100 } |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6101 |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6102 if (room < offset) // Not enough room |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6103 offset = room; // Move as far as we can |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6104 if (offset <= 0) // No room at all, quit. |
7 | 6105 return; |
7256
79270eaac6de
commit https://github.com/vim/vim/commit/294a7e55b01149154807a23323038784549b8946
Christian Brabandt <cb@256bit.org>
parents:
7229
diff
changeset
|
6106 if (fr == NULL) |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6107 return; // Safety check, should not happen. |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6108 |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6109 // grow frame fr by offset lines |
779 | 6110 frame_new_width(fr, fr->fr_width + offset, left, FALSE); |
7 | 6111 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6112 // shrink other frames: current and at the left or at the right |
7 | 6113 if (left) |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6114 fr = curfr; // current frame gets smaller |
7 | 6115 else |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6116 fr = curfr->fr_next; // next frame gets smaller |
7 | 6117 |
6118 while (fr != NULL && offset > 0) | |
6119 { | |
6120 n = frame_minwidth(fr, NULL); | |
6121 if (fr->fr_width - offset <= n) | |
6122 { | |
6123 offset -= fr->fr_width - n; | |
779 | 6124 frame_new_width(fr, n, !left, FALSE); |
7 | 6125 } |
6126 else | |
6127 { | |
779 | 6128 frame_new_width(fr, fr->fr_width - offset, !left, FALSE); |
7 | 6129 break; |
6130 } | |
6131 if (left) | |
6132 fr = fr->fr_prev; | |
6133 else | |
6134 fr = fr->fr_next; | |
6135 } | |
6136 (void)win_comp_pos(); | |
6137 redraw_all_later(NOT_VALID); | |
6138 } | |
6139 | |
2665 | 6140 #define FRACTION_MULT 16384L |
6141 | |
6142 /* | |
6143 * Set wp->w_fraction for the current w_wrow and w_height. | |
12910
d21adefd4a50
patch 8.0.1331: possible crash when window can be zero lines high
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
6144 * Has no effect when the window is less than two lines. |
2665 | 6145 */ |
7311
743c258ca3ab
commit https://github.com/vim/vim/commit/9dc2ce398bb3456cc8f590ef0260459798b34d2a
Christian Brabandt <cb@256bit.org>
parents:
7256
diff
changeset
|
6146 void |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6147 set_fraction(win_T *wp) |
2665 | 6148 { |
12910
d21adefd4a50
patch 8.0.1331: possible crash when window can be zero lines high
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
6149 if (wp->w_height > 1) |
15977
7fbdceabad64
patch 8.1.0994: relative cursor position is not calculated correctly
Bram Moolenaar <Bram@vim.org>
parents:
15937
diff
changeset
|
6150 // When cursor is in the first line the percentage is computed as if |
7fbdceabad64
patch 8.1.0994: relative cursor position is not calculated correctly
Bram Moolenaar <Bram@vim.org>
parents:
15937
diff
changeset
|
6151 // it's halfway that line. Thus with two lines it is 25%, with three |
7fbdceabad64
patch 8.1.0994: relative cursor position is not calculated correctly
Bram Moolenaar <Bram@vim.org>
parents:
15937
diff
changeset
|
6152 // lines 17%, etc. Similarly for the last line: 75%, 83%, etc. |
12910
d21adefd4a50
patch 8.0.1331: possible crash when window can be zero lines high
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
6153 wp->w_fraction = ((long)wp->w_wrow * FRACTION_MULT |
15977
7fbdceabad64
patch 8.1.0994: relative cursor position is not calculated correctly
Bram Moolenaar <Bram@vim.org>
parents:
15937
diff
changeset
|
6154 + FRACTION_MULT / 2) / (long)wp->w_height; |
2665 | 6155 } |
6156 | |
7 | 6157 /* |
6158 * Set the height of a window. | |
12487
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
6159 * "height" excludes any window toolbar. |
7 | 6160 * This takes care of the things inside the window, not what happens to the |
6161 * window position, the frame or to other windows. | |
6162 */ | |
3697 | 6163 void |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6164 win_new_height(win_T *wp, int height) |
7 | 6165 { |
5875 | 6166 int prev_height = wp->w_height; |
7 | 6167 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6168 // Don't want a negative height. Happens when splitting a tiny window. |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6169 // Will equalize heights soon to fix it. |
7 | 6170 if (height < 0) |
6171 height = 0; | |
826 | 6172 if (wp->w_height == height) |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6173 return; // nothing to do |
7 | 6174 |
5875 | 6175 if (wp->w_height > 0) |
6176 { | |
6177 if (wp == curwin) | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6178 // w_wrow needs to be valid. When setting 'laststatus' this may |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6179 // call win_new_height() recursively. |
5969 | 6180 validate_cursor(); |
6181 if (wp->w_height != prev_height) | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6182 return; // Recursive call already changed the size, bail out here |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6183 // to avoid the following to mess things up. |
5875 | 6184 if (wp->w_wrow != wp->w_prev_fraction_row) |
6185 set_fraction(wp); | |
6186 } | |
7 | 6187 |
6188 wp->w_height = height; | |
6189 wp->w_skipcol = 0; | |
6190 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6191 // There is no point in adjusting the scroll position when exiting. Some |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6192 // values might be invalid. |
10835
c9da7f9137af
patch 8.0.0307: asan detects a memory error when EXITFREE is defined
Christian Brabandt <cb@256bit.org>
parents:
10377
diff
changeset
|
6193 if (!exiting) |
c9da7f9137af
patch 8.0.0307: asan detects a memory error when EXITFREE is defined
Christian Brabandt <cb@256bit.org>
parents:
10377
diff
changeset
|
6194 scroll_to_fraction(wp, prev_height); |
10013
942d40a92be6
commit https://github.com/vim/vim/commit/46328f9a1cc8047d1e05095bc9f531038c5a4028
Christian Brabandt <cb@256bit.org>
parents:
9953
diff
changeset
|
6195 } |
942d40a92be6
commit https://github.com/vim/vim/commit/46328f9a1cc8047d1e05095bc9f531038c5a4028
Christian Brabandt <cb@256bit.org>
parents:
9953
diff
changeset
|
6196 |
942d40a92be6
commit https://github.com/vim/vim/commit/46328f9a1cc8047d1e05095bc9f531038c5a4028
Christian Brabandt <cb@256bit.org>
parents:
9953
diff
changeset
|
6197 void |
942d40a92be6
commit https://github.com/vim/vim/commit/46328f9a1cc8047d1e05095bc9f531038c5a4028
Christian Brabandt <cb@256bit.org>
parents:
9953
diff
changeset
|
6198 scroll_to_fraction(win_T *wp, int prev_height) |
942d40a92be6
commit https://github.com/vim/vim/commit/46328f9a1cc8047d1e05095bc9f531038c5a4028
Christian Brabandt <cb@256bit.org>
parents:
9953
diff
changeset
|
6199 { |
942d40a92be6
commit https://github.com/vim/vim/commit/46328f9a1cc8047d1e05095bc9f531038c5a4028
Christian Brabandt <cb@256bit.org>
parents:
9953
diff
changeset
|
6200 linenr_T lnum; |
942d40a92be6
commit https://github.com/vim/vim/commit/46328f9a1cc8047d1e05095bc9f531038c5a4028
Christian Brabandt <cb@256bit.org>
parents:
9953
diff
changeset
|
6201 int sline, line_size; |
942d40a92be6
commit https://github.com/vim/vim/commit/46328f9a1cc8047d1e05095bc9f531038c5a4028
Christian Brabandt <cb@256bit.org>
parents:
9953
diff
changeset
|
6202 int height = wp->w_height; |
942d40a92be6
commit https://github.com/vim/vim/commit/46328f9a1cc8047d1e05095bc9f531038c5a4028
Christian Brabandt <cb@256bit.org>
parents:
9953
diff
changeset
|
6203 |
16650
06fd0eaada01
patch 8.1.1327: unnecessary scroll after horizontal split
Bram Moolenaar <Bram@vim.org>
parents:
16477
diff
changeset
|
6204 // Don't change w_topline in any of these cases: |
06fd0eaada01
patch 8.1.1327: unnecessary scroll after horizontal split
Bram Moolenaar <Bram@vim.org>
parents:
16477
diff
changeset
|
6205 // - window height is 0 |
06fd0eaada01
patch 8.1.1327: unnecessary scroll after horizontal split
Bram Moolenaar <Bram@vim.org>
parents:
16477
diff
changeset
|
6206 // - 'scrollbind' is set and this isn't the current window |
16690
4e3c4e8e465c
patch 8.1.1347: fractional scroll position not restored after closing window
Bram Moolenaar <Bram@vim.org>
parents:
16650
diff
changeset
|
6207 // - window height is sufficient to display the whole buffer and first line |
4e3c4e8e465c
patch 8.1.1347: fractional scroll position not restored after closing window
Bram Moolenaar <Bram@vim.org>
parents:
16650
diff
changeset
|
6208 // is visible. |
16650
06fd0eaada01
patch 8.1.1327: unnecessary scroll after horizontal split
Bram Moolenaar <Bram@vim.org>
parents:
16477
diff
changeset
|
6209 if (height > 0 |
06fd0eaada01
patch 8.1.1327: unnecessary scroll after horizontal split
Bram Moolenaar <Bram@vim.org>
parents:
16477
diff
changeset
|
6210 && (!wp->w_p_scb || wp == curwin) |
16690
4e3c4e8e465c
patch 8.1.1347: fractional scroll position not restored after closing window
Bram Moolenaar <Bram@vim.org>
parents:
16650
diff
changeset
|
6211 && (height < wp->w_buffer->b_ml.ml_line_count || wp->w_topline > 1)) |
7 | 6212 { |
47 | 6213 /* |
6214 * Find a value for w_topline that shows the cursor at the same | |
6215 * relative position in the window as before (more or less). | |
6216 */ | |
7 | 6217 lnum = wp->w_cursor.lnum; |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6218 if (lnum < 1) // can happen when starting up |
7 | 6219 lnum = 1; |
15977
7fbdceabad64
patch 8.1.0994: relative cursor position is not calculated correctly
Bram Moolenaar <Bram@vim.org>
parents:
15937
diff
changeset
|
6220 wp->w_wrow = ((long)wp->w_fraction * (long)height - 1L) |
7fbdceabad64
patch 8.1.0994: relative cursor position is not calculated correctly
Bram Moolenaar <Bram@vim.org>
parents:
15937
diff
changeset
|
6221 / FRACTION_MULT; |
7 | 6222 line_size = plines_win_col(wp, lnum, (long)(wp->w_cursor.col)) - 1; |
6223 sline = wp->w_wrow - line_size; | |
1023 | 6224 |
6225 if (sline >= 0) | |
6226 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6227 // Make sure the whole cursor line is visible, if possible. |
1023 | 6228 int rows = plines_win(wp, lnum, FALSE); |
6229 | |
6230 if (sline > wp->w_height - rows) | |
6231 { | |
6232 sline = wp->w_height - rows; | |
6233 wp->w_wrow -= rows - line_size; | |
6234 } | |
6235 } | |
6236 | |
7 | 6237 if (sline < 0) |
6238 { | |
6239 /* | |
6240 * Cursor line would go off top of screen if w_wrow was this high. | |
1023 | 6241 * Make cursor line the first line in the window. If not enough |
6242 * room use w_skipcol; | |
7 | 6243 */ |
6244 wp->w_wrow = line_size; | |
1023 | 6245 if (wp->w_wrow >= wp->w_height |
12515
972ea22c946f
patch 8.0.1136: W_WIDTH() is always the same
Christian Brabandt <cb@256bit.org>
parents:
12513
diff
changeset
|
6246 && (wp->w_width - win_col_off(wp)) > 0) |
1023 | 6247 { |
12515
972ea22c946f
patch 8.0.1136: W_WIDTH() is always the same
Christian Brabandt <cb@256bit.org>
parents:
12513
diff
changeset
|
6248 wp->w_skipcol += wp->w_width - win_col_off(wp); |
1023 | 6249 --wp->w_wrow; |
6250 while (wp->w_wrow >= wp->w_height) | |
6251 { | |
12515
972ea22c946f
patch 8.0.1136: W_WIDTH() is always the same
Christian Brabandt <cb@256bit.org>
parents:
12513
diff
changeset
|
6252 wp->w_skipcol += wp->w_width - win_col_off(wp) |
1023 | 6253 + win_col_off2(wp); |
6254 --wp->w_wrow; | |
6255 } | |
6256 } | |
7 | 6257 } |
5936 | 6258 else if (sline > 0) |
7 | 6259 { |
1023 | 6260 while (sline > 0 && lnum > 1) |
7 | 6261 { |
6262 #ifdef FEAT_FOLDING | |
6263 hasFoldingWin(wp, lnum, &lnum, NULL, TRUE, NULL); | |
6264 if (lnum == 1) | |
6265 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6266 // first line in buffer is folded |
7 | 6267 line_size = 1; |
6268 --sline; | |
6269 break; | |
6270 } | |
6271 #endif | |
6272 --lnum; | |
6273 #ifdef FEAT_DIFF | |
6274 if (lnum == wp->w_topline) | |
6275 line_size = plines_win_nofill(wp, lnum, TRUE) | |
6276 + wp->w_topfill; | |
6277 else | |
6278 #endif | |
6279 line_size = plines_win(wp, lnum, TRUE); | |
6280 sline -= line_size; | |
6281 } | |
47 | 6282 |
7 | 6283 if (sline < 0) |
6284 { | |
6285 /* | |
6286 * Line we want at top would go off top of screen. Use next | |
6287 * line instead. | |
6288 */ | |
6289 #ifdef FEAT_FOLDING | |
6290 hasFoldingWin(wp, lnum, NULL, &lnum, TRUE, NULL); | |
6291 #endif | |
6292 lnum++; | |
6293 wp->w_wrow -= line_size + sline; | |
6294 } | |
5936 | 6295 else if (sline > 0) |
7 | 6296 { |
15977
7fbdceabad64
patch 8.1.0994: relative cursor position is not calculated correctly
Bram Moolenaar <Bram@vim.org>
parents:
15937
diff
changeset
|
6297 // First line of file reached, use that as topline. |
7 | 6298 lnum = 1; |
6299 wp->w_wrow -= sline; | |
6300 } | |
6301 } | |
15977
7fbdceabad64
patch 8.1.0994: relative cursor position is not calculated correctly
Bram Moolenaar <Bram@vim.org>
parents:
15937
diff
changeset
|
6302 set_topline(wp, lnum); |
7 | 6303 } |
6304 | |
6305 if (wp == curwin) | |
6306 { | |
15713
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15636
diff
changeset
|
6307 if (get_scrolloff_value()) |
7 | 6308 update_topline(); |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6309 curs_columns(FALSE); // validate w_wrow |
7 | 6310 } |
5875 | 6311 if (prev_height > 0) |
6312 wp->w_prev_fraction_row = wp->w_wrow; | |
7 | 6313 |
6314 win_comp_scroll(wp); | |
737 | 6315 redraw_win_later(wp, SOME_VALID); |
7 | 6316 wp->w_redr_status = TRUE; |
6317 invalidate_botline_win(wp); | |
6318 } | |
6319 | |
6320 /* | |
6321 * Set the width of a window. | |
6322 */ | |
3697 | 6323 void |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6324 win_new_width(win_T *wp, int width) |
7 | 6325 { |
6326 wp->w_width = width; | |
6327 wp->w_lines_valid = 0; | |
6328 changed_line_abv_curs_win(wp); | |
6329 invalidate_botline_win(wp); | |
6330 if (wp == curwin) | |
6331 { | |
6332 update_topline(); | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6333 curs_columns(TRUE); // validate w_wrow |
7 | 6334 } |
6335 redraw_win_later(wp, NOT_VALID); | |
6336 wp->w_redr_status = TRUE; | |
6337 } | |
6338 | |
6339 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6340 win_comp_scroll(win_T *wp) |
7 | 6341 { |
23386
3105546b941f
patch 8.2.2236: 'scroll' option can change when setting the statusline
Bram Moolenaar <Bram@vim.org>
parents:
22900
diff
changeset
|
6342 #if defined(FEAT_EVAL) |
3105546b941f
patch 8.2.2236: 'scroll' option can change when setting the statusline
Bram Moolenaar <Bram@vim.org>
parents:
22900
diff
changeset
|
6343 int old_w_p_scr = wp->w_p_scr; |
3105546b941f
patch 8.2.2236: 'scroll' option can change when setting the statusline
Bram Moolenaar <Bram@vim.org>
parents:
22900
diff
changeset
|
6344 #endif |
3105546b941f
patch 8.2.2236: 'scroll' option can change when setting the statusline
Bram Moolenaar <Bram@vim.org>
parents:
22900
diff
changeset
|
6345 |
7 | 6346 wp->w_p_scr = ((unsigned)wp->w_height >> 1); |
6347 if (wp->w_p_scr == 0) | |
6348 wp->w_p_scr = 1; | |
23386
3105546b941f
patch 8.2.2236: 'scroll' option can change when setting the statusline
Bram Moolenaar <Bram@vim.org>
parents:
22900
diff
changeset
|
6349 #if defined(FEAT_EVAL) |
3105546b941f
patch 8.2.2236: 'scroll' option can change when setting the statusline
Bram Moolenaar <Bram@vim.org>
parents:
22900
diff
changeset
|
6350 if (wp->w_p_scr != old_w_p_scr) |
3105546b941f
patch 8.2.2236: 'scroll' option can change when setting the statusline
Bram Moolenaar <Bram@vim.org>
parents:
22900
diff
changeset
|
6351 { |
3105546b941f
patch 8.2.2236: 'scroll' option can change when setting the statusline
Bram Moolenaar <Bram@vim.org>
parents:
22900
diff
changeset
|
6352 // Used by "verbose set scroll". |
3105546b941f
patch 8.2.2236: 'scroll' option can change when setting the statusline
Bram Moolenaar <Bram@vim.org>
parents:
22900
diff
changeset
|
6353 wp->w_p_script_ctx[WV_SCROLL].sc_sid = SID_WINLAYOUT; |
3105546b941f
patch 8.2.2236: 'scroll' option can change when setting the statusline
Bram Moolenaar <Bram@vim.org>
parents:
22900
diff
changeset
|
6354 wp->w_p_script_ctx[WV_SCROLL].sc_lnum = 0; |
3105546b941f
patch 8.2.2236: 'scroll' option can change when setting the statusline
Bram Moolenaar <Bram@vim.org>
parents:
22900
diff
changeset
|
6355 } |
3105546b941f
patch 8.2.2236: 'scroll' option can change when setting the statusline
Bram Moolenaar <Bram@vim.org>
parents:
22900
diff
changeset
|
6356 #endif |
7 | 6357 } |
6358 | |
6359 /* | |
6360 * command_height: called whenever p_ch has been changed | |
6361 */ | |
6362 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6363 command_height(void) |
7 | 6364 { |
6365 int h; | |
6366 frame_T *frp; | |
824 | 6367 int old_p_ch = curtab->tp_ch_used; |
6368 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6369 // Use the value of p_ch that we remembered. This is needed for when the |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6370 // GUI starts up, we can't be sure in what order things happen. And when |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6371 // p_ch was changed in another tab page. |
824 | 6372 curtab->tp_ch_used = p_ch; |
170 | 6373 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6374 // Find bottom frame with width of screen. |
7 | 6375 frp = lastwin->w_frame; |
6376 while (frp->fr_width != Columns && frp->fr_parent != NULL) | |
6377 frp = frp->fr_parent; | |
6378 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6379 // Avoid changing the height of a window with 'winfixheight' set. |
7 | 6380 while (frp->fr_prev != NULL && frp->fr_layout == FR_LEAF |
6381 && frp->fr_win->w_p_wfh) | |
6382 frp = frp->fr_prev; | |
6383 | |
6384 if (starting != NO_SCREEN) | |
6385 { | |
6386 cmdline_row = Rows - p_ch; | |
6387 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6388 if (p_ch > old_p_ch) // p_ch got bigger |
7 | 6389 { |
6390 while (p_ch > old_p_ch) | |
6391 { | |
6392 if (frp == NULL) | |
6393 { | |
25306
078edc1821bf
patch 8.2.3190: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
25157
diff
changeset
|
6394 emsg(_(e_not_enough_room)); |
7 | 6395 p_ch = old_p_ch; |
1404 | 6396 curtab->tp_ch_used = p_ch; |
7 | 6397 cmdline_row = Rows - p_ch; |
6398 break; | |
6399 } | |
6400 h = frp->fr_height - frame_minheight(frp, NULL); | |
6401 if (h > p_ch - old_p_ch) | |
6402 h = p_ch - old_p_ch; | |
6403 old_p_ch += h; | |
6404 frame_add_height(frp, -h); | |
6405 frp = frp->fr_prev; | |
6406 } | |
6407 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6408 // Recompute window positions. |
7 | 6409 (void)win_comp_pos(); |
6410 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6411 // clear the lines added to cmdline |
7 | 6412 if (full_screen) |
6413 screen_fill((int)(cmdline_row), (int)Rows, 0, | |
6414 (int)Columns, ' ', ' ', 0); | |
6415 msg_row = cmdline_row; | |
6416 redraw_cmdline = TRUE; | |
6417 return; | |
6418 } | |
6419 | |
6420 if (msg_row < cmdline_row) | |
6421 msg_row = cmdline_row; | |
6422 redraw_cmdline = TRUE; | |
6423 } | |
6424 frame_add_height(frp, (int)(old_p_ch - p_ch)); | |
6425 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6426 // Recompute window positions. |
7 | 6427 if (frp != lastwin->w_frame) |
6428 (void)win_comp_pos(); | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
6429 } |
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
6430 |
7 | 6431 /* |
6432 * Resize frame "frp" to be "n" lines higher (negative for less high). | |
6433 * Also resize the frames it is contained in. | |
6434 */ | |
6435 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6436 frame_add_height(frame_T *frp, int n) |
7 | 6437 { |
6438 frame_new_height(frp, frp->fr_height + n, FALSE, FALSE); | |
6439 for (;;) | |
6440 { | |
6441 frp = frp->fr_parent; | |
6442 if (frp == NULL) | |
6443 break; | |
6444 frp->fr_height += n; | |
6445 } | |
6446 } | |
6447 | |
6448 /* | |
6449 * Add or remove a status line for the bottom window(s), according to the | |
6450 * value of 'laststatus'. | |
6451 */ | |
6452 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6453 last_status( |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6454 int morewin) // pretend there are two or more windows |
7 | 6455 { |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6456 // Don't make a difference between horizontal or vertical split. |
7 | 6457 last_status_rec(topframe, (p_ls == 2 |
10357
59d01e335858
commit https://github.com/vim/vim/commit/459ca563128f2edb7e3bb190090bbb755a56dd55
Christian Brabandt <cb@256bit.org>
parents:
10349
diff
changeset
|
6458 || (p_ls == 1 && (morewin || !ONE_WINDOW)))); |
7 | 6459 } |
6460 | |
6461 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6462 last_status_rec(frame_T *fr, int statusline) |
7 | 6463 { |
6464 frame_T *fp; | |
6465 win_T *wp; | |
6466 | |
6467 if (fr->fr_layout == FR_LEAF) | |
6468 { | |
6469 wp = fr->fr_win; | |
6470 if (wp->w_status_height != 0 && !statusline) | |
6471 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6472 // remove status line |
7 | 6473 win_new_height(wp, wp->w_height + 1); |
6474 wp->w_status_height = 0; | |
6475 comp_col(); | |
6476 } | |
6477 else if (wp->w_status_height == 0 && statusline) | |
6478 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6479 // Find a frame to take a line from. |
7 | 6480 fp = fr; |
6481 while (fp->fr_height <= frame_minheight(fp, NULL)) | |
6482 { | |
6483 if (fp == topframe) | |
6484 { | |
25306
078edc1821bf
patch 8.2.3190: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
25157
diff
changeset
|
6485 emsg(_(e_not_enough_room)); |
7 | 6486 return; |
6487 } | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6488 // In a column of frames: go to frame above. If already at |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6489 // the top or in a row of frames: go to parent. |
7 | 6490 if (fp->fr_parent->fr_layout == FR_COL && fp->fr_prev != NULL) |
6491 fp = fp->fr_prev; | |
6492 else | |
6493 fp = fp->fr_parent; | |
6494 } | |
6495 wp->w_status_height = 1; | |
6496 if (fp != fr) | |
6497 { | |
6498 frame_new_height(fp, fp->fr_height - 1, FALSE, FALSE); | |
6499 frame_fix_height(wp); | |
6500 (void)win_comp_pos(); | |
6501 } | |
6502 else | |
6503 win_new_height(wp, wp->w_height - 1); | |
6504 comp_col(); | |
737 | 6505 redraw_all_later(SOME_VALID); |
7 | 6506 } |
6507 } | |
6508 else if (fr->fr_layout == FR_ROW) | |
6509 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6510 // vertically split windows, set status line for each one |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
6511 FOR_ALL_FRAMES(fp, fr->fr_child) |
7 | 6512 last_status_rec(fp, statusline); |
6513 } | |
6514 else | |
6515 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6516 // horizontally split window, set status line for last one |
7 | 6517 for (fp = fr->fr_child; fp->fr_next != NULL; fp = fp->fr_next) |
6518 ; | |
6519 last_status_rec(fp, statusline); | |
6520 } | |
6521 } | |
6522 | |
667 | 6523 /* |
668 | 6524 * Return the number of lines used by the tab page line. |
667 | 6525 */ |
6526 int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6527 tabline_height(void) |
667 | 6528 { |
685 | 6529 #ifdef FEAT_GUI_TABLINE |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6530 // When the GUI has the tabline then this always returns zero. |
685 | 6531 if (gui_use_tabline()) |
6532 return 0; | |
6533 #endif | |
675 | 6534 switch (p_stal) |
668 | 6535 { |
6536 case 0: return 0; | |
6537 case 1: return (first_tabpage->tp_next == NULL) ? 0 : 1; | |
6538 } | |
667 | 6539 return 1; |
6540 } | |
6541 | |
7 | 6542 /* |
6543 * Return the minimal number of rows that is needed on the screen to display | |
6544 * the current number of windows. | |
6545 */ | |
6546 int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6547 min_rows(void) |
7 | 6548 { |
6549 int total; | |
671 | 6550 tabpage_T *tp; |
6551 int n; | |
7 | 6552 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6553 if (firstwin == NULL) // not initialized yet |
7 | 6554 return MIN_LINES; |
6555 | |
671 | 6556 total = 0; |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9599
diff
changeset
|
6557 FOR_ALL_TABPAGES(tp) |
671 | 6558 { |
6559 n = frame_minheight(tp->tp_topframe, NULL); | |
6560 if (total < n) | |
6561 total = n; | |
6562 } | |
685 | 6563 total += tabline_height(); |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6564 total += 1; // count the room for the command line |
7 | 6565 return total; |
6566 } | |
6567 | |
6568 /* | |
18467
99fc29219b3e
patch 8.1.2227: layout wrong if 'lines' changes while cmdline window is open
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
6569 * Return TRUE if there is only one window and only one tab page, not |
672 | 6570 * counting a help or preview window, unless it is the current window. |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
6571 * Does not count unlisted windows. |
7 | 6572 */ |
6573 int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6574 only_one_window(void) |
7 | 6575 { |
6576 int count = 0; | |
6577 win_T *wp; | |
6578 | |
19275
2142fb624658
patch 8.2.0196: blocking commands for a finished job in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19271
diff
changeset
|
6579 #if defined(FEAT_PROP_POPUP) |
2142fb624658
patch 8.2.0196: blocking commands for a finished job in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19271
diff
changeset
|
6580 // If the current window is a popup then there always is another window. |
2142fb624658
patch 8.2.0196: blocking commands for a finished job in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19271
diff
changeset
|
6581 if (popup_is_popup(curwin)) |
2142fb624658
patch 8.2.0196: blocking commands for a finished job in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19271
diff
changeset
|
6582 return FALSE; |
2142fb624658
patch 8.2.0196: blocking commands for a finished job in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19271
diff
changeset
|
6583 #endif |
2142fb624658
patch 8.2.0196: blocking commands for a finished job in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19271
diff
changeset
|
6584 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6585 // If there is another tab page there always is another window. |
667 | 6586 if (first_tabpage->tp_next != NULL) |
6587 return FALSE; | |
6588 | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9599
diff
changeset
|
6589 FOR_ALL_WINDOWS(wp) |
4021 | 6590 if (wp->w_buffer != NULL |
11800
5ceaecedbad2
patch 8.0.0782: using freed memory in quickfix code
Christian Brabandt <cb@256bit.org>
parents:
11593
diff
changeset
|
6591 && (!((bt_help(wp->w_buffer) && !bt_help(curbuf)) |
7 | 6592 # ifdef FEAT_QUICKFIX |
6593 || wp->w_p_pvw | |
6594 # endif | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13308
diff
changeset
|
6595 ) || wp == curwin) && wp != aucmd_win) |
7 | 6596 ++count; |
6597 return (count <= 1); | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
6598 } |
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
6599 |
7 | 6600 /* |
6601 * Correct the cursor line number in other windows. Used after changing the | |
6602 * current buffer, and before applying autocommands. | |
6603 * When "do_curwin" is TRUE, also check current window. | |
6604 */ | |
6605 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6606 check_lnums(int do_curwin) |
7 | 6607 { |
6608 win_T *wp; | |
671 | 6609 tabpage_T *tp; |
6610 | |
6611 FOR_ALL_TAB_WINDOWS(tp, wp) | |
7 | 6612 if ((do_curwin || wp != curwin) && wp->w_buffer == curbuf) |
6613 { | |
16401
3b2db762a509
patch 8.1.1205: a BufReadPre autocommand may cause the cursor to move
Bram Moolenaar <Bram@vim.org>
parents:
16354
diff
changeset
|
6614 // save the original cursor position and topline |
3b2db762a509
patch 8.1.1205: a BufReadPre autocommand may cause the cursor to move
Bram Moolenaar <Bram@vim.org>
parents:
16354
diff
changeset
|
6615 wp->w_save_cursor.w_cursor_save = wp->w_cursor; |
3b2db762a509
patch 8.1.1205: a BufReadPre autocommand may cause the cursor to move
Bram Moolenaar <Bram@vim.org>
parents:
16354
diff
changeset
|
6616 wp->w_save_cursor.w_topline_save = wp->w_topline; |
3b2db762a509
patch 8.1.1205: a BufReadPre autocommand may cause the cursor to move
Bram Moolenaar <Bram@vim.org>
parents:
16354
diff
changeset
|
6617 |
7 | 6618 if (wp->w_cursor.lnum > curbuf->b_ml.ml_line_count) |
6619 wp->w_cursor.lnum = curbuf->b_ml.ml_line_count; | |
6620 if (wp->w_topline > curbuf->b_ml.ml_line_count) | |
6621 wp->w_topline = curbuf->b_ml.ml_line_count; | |
16401
3b2db762a509
patch 8.1.1205: a BufReadPre autocommand may cause the cursor to move
Bram Moolenaar <Bram@vim.org>
parents:
16354
diff
changeset
|
6622 |
3b2db762a509
patch 8.1.1205: a BufReadPre autocommand may cause the cursor to move
Bram Moolenaar <Bram@vim.org>
parents:
16354
diff
changeset
|
6623 // save the corrected cursor position and topline |
3b2db762a509
patch 8.1.1205: a BufReadPre autocommand may cause the cursor to move
Bram Moolenaar <Bram@vim.org>
parents:
16354
diff
changeset
|
6624 wp->w_save_cursor.w_cursor_corr = wp->w_cursor; |
3b2db762a509
patch 8.1.1205: a BufReadPre autocommand may cause the cursor to move
Bram Moolenaar <Bram@vim.org>
parents:
16354
diff
changeset
|
6625 wp->w_save_cursor.w_topline_corr = wp->w_topline; |
3b2db762a509
patch 8.1.1205: a BufReadPre autocommand may cause the cursor to move
Bram Moolenaar <Bram@vim.org>
parents:
16354
diff
changeset
|
6626 } |
3b2db762a509
patch 8.1.1205: a BufReadPre autocommand may cause the cursor to move
Bram Moolenaar <Bram@vim.org>
parents:
16354
diff
changeset
|
6627 } |
3b2db762a509
patch 8.1.1205: a BufReadPre autocommand may cause the cursor to move
Bram Moolenaar <Bram@vim.org>
parents:
16354
diff
changeset
|
6628 |
3b2db762a509
patch 8.1.1205: a BufReadPre autocommand may cause the cursor to move
Bram Moolenaar <Bram@vim.org>
parents:
16354
diff
changeset
|
6629 /* |
3b2db762a509
patch 8.1.1205: a BufReadPre autocommand may cause the cursor to move
Bram Moolenaar <Bram@vim.org>
parents:
16354
diff
changeset
|
6630 * Reset cursor and topline to its stored values from check_lnums(). |
3b2db762a509
patch 8.1.1205: a BufReadPre autocommand may cause the cursor to move
Bram Moolenaar <Bram@vim.org>
parents:
16354
diff
changeset
|
6631 * check_lnums() must have been called first! |
3b2db762a509
patch 8.1.1205: a BufReadPre autocommand may cause the cursor to move
Bram Moolenaar <Bram@vim.org>
parents:
16354
diff
changeset
|
6632 */ |
3b2db762a509
patch 8.1.1205: a BufReadPre autocommand may cause the cursor to move
Bram Moolenaar <Bram@vim.org>
parents:
16354
diff
changeset
|
6633 void |
3b2db762a509
patch 8.1.1205: a BufReadPre autocommand may cause the cursor to move
Bram Moolenaar <Bram@vim.org>
parents:
16354
diff
changeset
|
6634 reset_lnums() |
3b2db762a509
patch 8.1.1205: a BufReadPre autocommand may cause the cursor to move
Bram Moolenaar <Bram@vim.org>
parents:
16354
diff
changeset
|
6635 { |
3b2db762a509
patch 8.1.1205: a BufReadPre autocommand may cause the cursor to move
Bram Moolenaar <Bram@vim.org>
parents:
16354
diff
changeset
|
6636 win_T *wp; |
3b2db762a509
patch 8.1.1205: a BufReadPre autocommand may cause the cursor to move
Bram Moolenaar <Bram@vim.org>
parents:
16354
diff
changeset
|
6637 tabpage_T *tp; |
3b2db762a509
patch 8.1.1205: a BufReadPre autocommand may cause the cursor to move
Bram Moolenaar <Bram@vim.org>
parents:
16354
diff
changeset
|
6638 |
3b2db762a509
patch 8.1.1205: a BufReadPre autocommand may cause the cursor to move
Bram Moolenaar <Bram@vim.org>
parents:
16354
diff
changeset
|
6639 FOR_ALL_TAB_WINDOWS(tp, wp) |
3b2db762a509
patch 8.1.1205: a BufReadPre autocommand may cause the cursor to move
Bram Moolenaar <Bram@vim.org>
parents:
16354
diff
changeset
|
6640 if (wp->w_buffer == curbuf) |
3b2db762a509
patch 8.1.1205: a BufReadPre autocommand may cause the cursor to move
Bram Moolenaar <Bram@vim.org>
parents:
16354
diff
changeset
|
6641 { |
3b2db762a509
patch 8.1.1205: a BufReadPre autocommand may cause the cursor to move
Bram Moolenaar <Bram@vim.org>
parents:
16354
diff
changeset
|
6642 // Restore the value if the autocommand didn't change it. |
3b2db762a509
patch 8.1.1205: a BufReadPre autocommand may cause the cursor to move
Bram Moolenaar <Bram@vim.org>
parents:
16354
diff
changeset
|
6643 if (EQUAL_POS(wp->w_save_cursor.w_cursor_corr, wp->w_cursor)) |
3b2db762a509
patch 8.1.1205: a BufReadPre autocommand may cause the cursor to move
Bram Moolenaar <Bram@vim.org>
parents:
16354
diff
changeset
|
6644 wp->w_cursor = wp->w_save_cursor.w_cursor_save; |
3b2db762a509
patch 8.1.1205: a BufReadPre autocommand may cause the cursor to move
Bram Moolenaar <Bram@vim.org>
parents:
16354
diff
changeset
|
6645 if (wp->w_save_cursor.w_topline_corr == wp->w_topline) |
3b2db762a509
patch 8.1.1205: a BufReadPre autocommand may cause the cursor to move
Bram Moolenaar <Bram@vim.org>
parents:
16354
diff
changeset
|
6646 wp->w_topline = wp->w_save_cursor.w_topline_save; |
7 | 6647 } |
6648 } | |
6649 | |
6650 /* | |
6651 * A snapshot of the window sizes, to restore them after closing the help | |
6652 * window. | |
6653 * Only these fields are used: | |
6654 * fr_layout | |
6655 * fr_width | |
6656 * fr_height | |
6657 * fr_next | |
6658 * fr_child | |
6659 * fr_win (only valid for the old curwin, NULL otherwise) | |
6660 */ | |
6661 | |
6662 /* | |
6663 * Create a snapshot of the current frame sizes. | |
6664 */ | |
1906 | 6665 void |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6666 make_snapshot(int idx) |
7 | 6667 { |
1906 | 6668 clear_snapshot(curtab, idx); |
6669 make_snapshot_rec(topframe, &curtab->tp_snapshot[idx]); | |
7 | 6670 } |
6671 | |
6672 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6673 make_snapshot_rec(frame_T *fr, frame_T **frp) |
7 | 6674 { |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16802
diff
changeset
|
6675 *frp = ALLOC_CLEAR_ONE(frame_T); |
7 | 6676 if (*frp == NULL) |
6677 return; | |
6678 (*frp)->fr_layout = fr->fr_layout; | |
6679 (*frp)->fr_width = fr->fr_width; | |
6680 (*frp)->fr_height = fr->fr_height; | |
6681 if (fr->fr_next != NULL) | |
6682 make_snapshot_rec(fr->fr_next, &((*frp)->fr_next)); | |
6683 if (fr->fr_child != NULL) | |
6684 make_snapshot_rec(fr->fr_child, &((*frp)->fr_child)); | |
6685 if (fr->fr_layout == FR_LEAF && fr->fr_win == curwin) | |
6686 (*frp)->fr_win = curwin; | |
6687 } | |
6688 | |
6689 /* | |
6690 * Remove any existing snapshot. | |
6691 */ | |
6692 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6693 clear_snapshot(tabpage_T *tp, int idx) |
7 | 6694 { |
1906 | 6695 clear_snapshot_rec(tp->tp_snapshot[idx]); |
6696 tp->tp_snapshot[idx] = NULL; | |
7 | 6697 } |
6698 | |
6699 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6700 clear_snapshot_rec(frame_T *fr) |
7 | 6701 { |
6702 if (fr != NULL) | |
6703 { | |
6704 clear_snapshot_rec(fr->fr_next); | |
6705 clear_snapshot_rec(fr->fr_child); | |
6706 vim_free(fr); | |
6707 } | |
6708 } | |
6709 | |
6710 /* | |
6711 * Restore a previously created snapshot, if there is any. | |
6712 * This is only done if the screen size didn't change and the window layout is | |
6713 * still the same. | |
6714 */ | |
1906 | 6715 void |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6716 restore_snapshot( |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6717 int idx, |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6718 int close_curwin) // closing current window |
7 | 6719 { |
6720 win_T *wp; | |
6721 | |
1906 | 6722 if (curtab->tp_snapshot[idx] != NULL |
6723 && curtab->tp_snapshot[idx]->fr_width == topframe->fr_width | |
6724 && curtab->tp_snapshot[idx]->fr_height == topframe->fr_height | |
6725 && check_snapshot_rec(curtab->tp_snapshot[idx], topframe) == OK) | |
6726 { | |
6727 wp = restore_snapshot_rec(curtab->tp_snapshot[idx], topframe); | |
7 | 6728 win_comp_pos(); |
6729 if (wp != NULL && close_curwin) | |
6730 win_goto(wp); | |
15380
f62d6bd18a49
patch 8.1.0698: clearing the window is used too often
Bram Moolenaar <Bram@vim.org>
parents:
15227
diff
changeset
|
6731 redraw_all_later(NOT_VALID); |
7 | 6732 } |
1906 | 6733 clear_snapshot(curtab, idx); |
7 | 6734 } |
6735 | |
6736 /* | |
6737 * Check if frames "sn" and "fr" have the same layout, same following frames | |
10883
cb71a5468aca
patch 8.0.0331: restoring help snapshot accesses freed memory
Christian Brabandt <cb@256bit.org>
parents:
10835
diff
changeset
|
6738 * and same children. And the window pointer is valid. |
7 | 6739 */ |
6740 static int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6741 check_snapshot_rec(frame_T *sn, frame_T *fr) |
7 | 6742 { |
6743 if (sn->fr_layout != fr->fr_layout | |
6744 || (sn->fr_next == NULL) != (fr->fr_next == NULL) | |
6745 || (sn->fr_child == NULL) != (fr->fr_child == NULL) | |
6746 || (sn->fr_next != NULL | |
6747 && check_snapshot_rec(sn->fr_next, fr->fr_next) == FAIL) | |
6748 || (sn->fr_child != NULL | |
10883
cb71a5468aca
patch 8.0.0331: restoring help snapshot accesses freed memory
Christian Brabandt <cb@256bit.org>
parents:
10835
diff
changeset
|
6749 && check_snapshot_rec(sn->fr_child, fr->fr_child) == FAIL) |
11191
445fd6be2009
patch 8.0.0482: the setbufvar() function may mess up the window layout
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
6750 || (sn->fr_win != NULL && !win_valid(sn->fr_win))) |
7 | 6751 return FAIL; |
6752 return OK; | |
6753 } | |
6754 | |
6755 /* | |
6756 * Copy the size of snapshot frame "sn" to frame "fr". Do the same for all | |
6757 * following frames and children. | |
6758 * Returns a pointer to the old current window, or NULL. | |
6759 */ | |
6760 static win_T * | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6761 restore_snapshot_rec(frame_T *sn, frame_T *fr) |
7 | 6762 { |
6763 win_T *wp = NULL; | |
6764 win_T *wp2; | |
6765 | |
6766 fr->fr_height = sn->fr_height; | |
6767 fr->fr_width = sn->fr_width; | |
6768 if (fr->fr_layout == FR_LEAF) | |
6769 { | |
6770 frame_new_height(fr, fr->fr_height, FALSE, FALSE); | |
779 | 6771 frame_new_width(fr, fr->fr_width, FALSE, FALSE); |
7 | 6772 wp = sn->fr_win; |
6773 } | |
6774 if (sn->fr_next != NULL) | |
6775 { | |
6776 wp2 = restore_snapshot_rec(sn->fr_next, fr->fr_next); | |
6777 if (wp2 != NULL) | |
6778 wp = wp2; | |
6779 } | |
6780 if (sn->fr_child != NULL) | |
6781 { | |
6782 wp2 = restore_snapshot_rec(sn->fr_child, fr->fr_child); | |
6783 if (wp2 != NULL) | |
6784 wp = wp2; | |
6785 } | |
6786 return wp; | |
6787 } | |
6788 | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
6789 #if defined(FEAT_GUI) || defined(PROTO) |
7 | 6790 /* |
6791 * Return TRUE if there is any vertically split window. | |
6792 */ | |
6793 int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6794 win_hasvertsplit(void) |
7 | 6795 { |
6796 frame_T *fr; | |
6797 | |
6798 if (topframe->fr_layout == FR_ROW) | |
6799 return TRUE; | |
6800 | |
6801 if (topframe->fr_layout == FR_COL) | |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
6802 FOR_ALL_FRAMES(fr, topframe->fr_child) |
7 | 6803 if (fr->fr_layout == FR_ROW) |
6804 return TRUE; | |
6805 | |
6806 return FALSE; | |
6807 } | |
6808 #endif | |
1326 | 6809 |
4379 | 6810 #if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) || defined(PROTO) |
6811 int | |
4401 | 6812 get_win_number(win_T *wp, win_T *first_win) |
4379 | 6813 { |
6814 int i = 1; | |
6815 win_T *w; | |
6816 | |
4401 | 6817 for (w = first_win; w != NULL && w != wp; w = W_NEXT(w)) |
4379 | 6818 ++i; |
6819 | |
6820 if (w == NULL) | |
6821 return 0; | |
6822 else | |
6823 return i; | |
6824 } | |
4401 | 6825 |
6826 int | |
4936
ae05437a744a
updated for version 7.3.1213
Bram Moolenaar <bram@vim.org>
parents:
4918
diff
changeset
|
6827 get_tab_number(tabpage_T *tp UNUSED) |
4401 | 6828 { |
6829 int i = 1; | |
6830 tabpage_T *t; | |
6831 | |
6832 for (t = first_tabpage; t != NULL && t != tp; t = t->tp_next) | |
6833 ++i; | |
6834 | |
6835 if (t == NULL) | |
6836 return 0; | |
6837 else | |
6838 return i; | |
6839 } | |
6840 #endif | |
5004
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6841 |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6842 /* |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6843 * Return TRUE if "topfrp" and its children are at the right height. |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6844 */ |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6845 static int |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6846 frame_check_height(frame_T *topfrp, int height) |
5004
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6847 { |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6848 frame_T *frp; |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6849 |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6850 if (topfrp->fr_height != height) |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6851 return FALSE; |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6852 |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6853 if (topfrp->fr_layout == FR_ROW) |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
6854 FOR_ALL_FRAMES(frp, topfrp->fr_child) |
5004
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6855 if (frp->fr_height != height) |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6856 return FALSE; |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6857 |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6858 return TRUE; |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6859 } |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
6860 |
5004
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6861 /* |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6862 * Return TRUE if "topfrp" and its children are at the right width. |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6863 */ |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6864 static int |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6865 frame_check_width(frame_T *topfrp, int width) |
5004
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6866 { |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6867 frame_T *frp; |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6868 |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6869 if (topfrp->fr_width != width) |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6870 return FALSE; |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6871 |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6872 if (topfrp->fr_layout == FR_COL) |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
6873 FOR_ALL_FRAMES(frp, topfrp->fr_child) |
5004
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6874 if (frp->fr_width != width) |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6875 return FALSE; |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6876 |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6877 return TRUE; |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6878 } |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6879 |
17940
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6880 #if defined(FEAT_SYN_HL) || defined(PROTO) |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6881 /* |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6882 * Simple int comparison function for use with qsort() |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6883 */ |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6884 static int |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6885 int_cmp(const void *a, const void *b) |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6886 { |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6887 return *(const int *)a - *(const int *)b; |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6888 } |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6889 |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6890 /* |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6891 * Handle setting 'colorcolumn' or 'textwidth' in window "wp". |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6892 * Returns error message, NULL if it's OK. |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6893 */ |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6894 char * |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6895 check_colorcolumn(win_T *wp) |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6896 { |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6897 char_u *s; |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6898 int col; |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6899 int count = 0; |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6900 int color_cols[256]; |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6901 int i; |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6902 int j = 0; |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6903 |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6904 if (wp->w_buffer == NULL) |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6905 return NULL; // buffer was closed |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6906 |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6907 for (s = wp->w_p_cc; *s != NUL && count < 255;) |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6908 { |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6909 if (*s == '-' || *s == '+') |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6910 { |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6911 // -N and +N: add to 'textwidth' |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6912 col = (*s == '-') ? -1 : 1; |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6913 ++s; |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6914 if (!VIM_ISDIGIT(*s)) |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6915 return e_invarg; |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6916 col = col * getdigits(&s); |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6917 if (wp->w_buffer->b_p_tw == 0) |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6918 goto skip; // 'textwidth' not set, skip this item |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6919 col += wp->w_buffer->b_p_tw; |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6920 if (col < 0) |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6921 goto skip; |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6922 } |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6923 else if (VIM_ISDIGIT(*s)) |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6924 col = getdigits(&s); |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6925 else |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6926 return e_invarg; |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6927 color_cols[count++] = col - 1; // 1-based to 0-based |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6928 skip: |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6929 if (*s == NUL) |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6930 break; |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6931 if (*s != ',') |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6932 return e_invarg; |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6933 if (*++s == NUL) |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6934 return e_invarg; // illegal trailing comma as in "set cc=80," |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6935 } |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6936 |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6937 vim_free(wp->w_p_cc_cols); |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6938 if (count == 0) |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6939 wp->w_p_cc_cols = NULL; |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6940 else |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6941 { |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6942 wp->w_p_cc_cols = ALLOC_MULT(int, count + 1); |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6943 if (wp->w_p_cc_cols != NULL) |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6944 { |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6945 // sort the columns for faster usage on screen redraw inside |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6946 // win_line() |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6947 qsort(color_cols, count, sizeof(int), int_cmp); |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6948 |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6949 for (i = 0; i < count; ++i) |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6950 // skip duplicates |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6951 if (j == 0 || wp->w_p_cc_cols[j - 1] != color_cols[i]) |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6952 wp->w_p_cc_cols[j++] = color_cols[i]; |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6953 wp->w_p_cc_cols[j] = -1; // end marker |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6954 } |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6955 } |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6956 |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6957 return NULL; // no error |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6958 } |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6959 #endif |