Mercurial > vim
annotate src/window.c @ 15933:b2423b31266f v8.1.0972
patch 8.1.0972: cannot switch from terminal window to next tabpage
commit https://github.com/vim/vim/commit/72e83c1ae535e2ebc35b114d34d0a811eb62b068
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Feb 22 16:09:52 2019 +0100
patch 8.1.0972: cannot switch from terminal window to next tabpage
Problem: Cannot switch from terminal window to next tabpage.
Solution: Make CTRL-W gt move to next tabpage.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 22 Feb 2019 16:15:06 +0100 |
parents | a6ca8cf07a98 |
children | c38fb03a6055 |
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); |
9595
0190d5de215f
commit https://github.com/vim/vim/commit/c917da4b3e8801a255dbefea8e4ed19c1c716dd8
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
42 static void win_enter_ext(win_T *wp, int undo_sync, int no_curwin, int trigger_new_autocmds, int trigger_enter_autocmds, int trigger_leave_autocmds); |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
43 static void win_free(win_T *wp, tabpage_T *tp); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
44 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
|
45 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
|
46 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
|
47 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
|
48 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
|
49 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
|
50 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
|
51 |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
52 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
|
53 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
|
54 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
|
55 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
|
56 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
|
57 |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
58 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
|
59 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
|
60 |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
61 static win_T *win_alloc(win_T *after, int hidden); |
7 | 62 |
1187 | 63 #define NOWIN (win_T *)-1 /* non-existing window */ |
7 | 64 |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
65 #define ROWS_AVAIL (Rows - p_ch - tabline_height()) |
826 | 66 |
67 static char *m_onlyone = N_("Already only one window"); | |
68 | |
7 | 69 /* |
15933
b2423b31266f
patch 8.1.0972: cannot switch from terminal window to next tabpage
Bram Moolenaar <Bram@vim.org>
parents:
15850
diff
changeset
|
70 * All CTRL-W window commands are handled here, called from normal_cmd(). |
7 | 71 */ |
72 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
73 do_window( |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
74 int nchar, |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
75 long Prenum, |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
76 int xchar) /* extra char from ":wincmd gx" or NUL */ |
7 | 77 { |
78 long Prenum1; | |
79 win_T *wp; | |
80 #if defined(FEAT_SEARCHPATH) || defined(FEAT_FIND_ID) | |
81 char_u *ptr; | |
681 | 82 linenr_T lnum = -1; |
7 | 83 #endif |
84 #ifdef FEAT_FIND_ID | |
85 int type = FIND_DEFINE; | |
86 int len; | |
87 #endif | |
88 char_u cbuf[40]; | |
89 | |
90 if (Prenum == 0) | |
91 Prenum1 = 1; | |
92 else | |
93 Prenum1 = Prenum; | |
94 | |
95 #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
|
96 # define CHECK_CMDWIN \ |
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
97 do { \ |
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
98 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
|
99 { \ |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15436
diff
changeset
|
100 emsg(_(e_cmdwin)); \ |
13632
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
101 return; \ |
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
102 } \ |
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
103 } while (0) |
7 | 104 #else |
13632
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
105 # define CHECK_CMDWIN do { /**/ } while (0) |
7 | 106 #endif |
107 | |
108 switch (nchar) | |
109 { | |
110 /* split current window in two parts, horizontally */ | |
111 case 'S': | |
112 case Ctrl_S: | |
113 case 's': | |
13632
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
114 CHECK_CMDWIN; |
7 | 115 reset_VIsual_and_resel(); /* stop Visual mode */ |
635 | 116 #ifdef FEAT_QUICKFIX |
117 /* When splitting the quickfix window open a new buffer in it, | |
118 * don't replicate the quickfix buffer. */ | |
119 if (bt_quickfix(curbuf)) | |
120 goto newwindow; | |
121 #endif | |
7 | 122 #ifdef FEAT_GUI |
123 need_mouse_correct = TRUE; | |
124 #endif | |
7009 | 125 (void)win_split((int)Prenum, 0); |
7 | 126 break; |
127 | |
128 /* split current window in two parts, vertically */ | |
129 case Ctrl_V: | |
130 case 'v': | |
13632
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
131 CHECK_CMDWIN; |
7 | 132 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
|
133 #ifdef FEAT_QUICKFIX |
1664 | 134 /* When splitting the quickfix window open a new buffer in it, |
135 * don't replicate the quickfix buffer. */ | |
136 if (bt_quickfix(curbuf)) | |
137 goto newwindow; | |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8536
diff
changeset
|
138 #endif |
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8536
diff
changeset
|
139 #ifdef FEAT_GUI |
7 | 140 need_mouse_correct = TRUE; |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8536
diff
changeset
|
141 #endif |
7009 | 142 (void)win_split((int)Prenum, WSP_VERT); |
7 | 143 break; |
144 | |
145 /* split current window and edit alternate file */ | |
146 case Ctrl_HAT: | |
147 case '^': | |
13632
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
148 CHECK_CMDWIN; |
7 | 149 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
|
150 |
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
|
151 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
|
152 ? 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
|
153 { |
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
|
154 if (Prenum == 0) |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15436
diff
changeset
|
155 emsg(_(e_noalt)); |
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
|
156 else |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15436
diff
changeset
|
157 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
|
158 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
|
159 } |
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
|
160 |
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
|
161 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
|
162 (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
|
163 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
|
164 (linenr_T)0, GETF_ALT, FALSE); |
7 | 165 break; |
166 | |
167 /* open new window */ | |
168 case Ctrl_N: | |
169 case 'n': | |
13632
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
170 CHECK_CMDWIN; |
7 | 171 reset_VIsual_and_resel(); /* stop Visual mode */ |
635 | 172 #ifdef FEAT_QUICKFIX |
173 newwindow: | |
174 #endif | |
7 | 175 if (Prenum) |
1664 | 176 /* window height */ |
177 vim_snprintf((char *)cbuf, sizeof(cbuf) - 5, "%ld", Prenum); | |
7 | 178 else |
179 cbuf[0] = NUL; | |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8536
diff
changeset
|
180 #if defined(FEAT_QUICKFIX) |
1664 | 181 if (nchar == 'v' || nchar == Ctrl_V) |
182 STRCAT(cbuf, "v"); | |
183 #endif | |
7 | 184 STRCAT(cbuf, "new"); |
185 do_cmdline_cmd(cbuf); | |
186 break; | |
187 | |
188 /* quit current window */ | |
189 case Ctrl_Q: | |
190 case 'q': | |
191 reset_VIsual_and_resel(); /* stop Visual mode */ | |
6432 | 192 cmd_with_count("quit", cbuf, sizeof(cbuf), Prenum); |
6398 | 193 do_cmdline_cmd(cbuf); |
7 | 194 break; |
195 | |
196 /* close current window */ | |
197 case Ctrl_C: | |
198 case 'c': | |
199 reset_VIsual_and_resel(); /* stop Visual mode */ | |
6432 | 200 cmd_with_count("close", cbuf, sizeof(cbuf), Prenum); |
6398 | 201 do_cmdline_cmd(cbuf); |
7 | 202 break; |
203 | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
204 #if defined(FEAT_QUICKFIX) |
7 | 205 /* close preview window */ |
206 case Ctrl_Z: | |
207 case 'z': | |
13632
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
208 CHECK_CMDWIN; |
7 | 209 reset_VIsual_and_resel(); /* stop Visual mode */ |
210 do_cmdline_cmd((char_u *)"pclose"); | |
211 break; | |
212 | |
213 /* cursor to preview window */ | |
214 case 'P': | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9599
diff
changeset
|
215 FOR_ALL_WINDOWS(wp) |
7 | 216 if (wp->w_p_pvw) |
217 break; | |
218 if (wp == NULL) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15436
diff
changeset
|
219 emsg(_("E441: There is no preview window")); |
7 | 220 else |
221 win_goto(wp); | |
222 break; | |
223 #endif | |
224 | |
225 /* close all but current window */ | |
226 case Ctrl_O: | |
227 case 'o': | |
13632
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
228 CHECK_CMDWIN; |
7 | 229 reset_VIsual_and_resel(); /* stop Visual mode */ |
6432 | 230 cmd_with_count("only", cbuf, sizeof(cbuf), Prenum); |
6398 | 231 do_cmdline_cmd(cbuf); |
7 | 232 break; |
233 | |
234 /* cursor to next window with wrap around */ | |
235 case Ctrl_W: | |
236 case 'w': | |
237 /* cursor to previous window with wrap around */ | |
238 case 'W': | |
13632
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
239 CHECK_CMDWIN; |
10349
cf988222b150
commit https://github.com/vim/vim/commit/a1f4cb93ba50ea9e40cd4b1f5592b8a6d1398660
Christian Brabandt <cb@256bit.org>
parents:
10106
diff
changeset
|
240 if (ONE_WINDOW && Prenum != 1) /* just one window */ |
7 | 241 beep_flush(); |
242 else | |
243 { | |
244 if (Prenum) /* go to specified window */ | |
245 { | |
246 for (wp = firstwin; --Prenum > 0; ) | |
247 { | |
248 if (wp->w_next == NULL) | |
249 break; | |
250 else | |
251 wp = wp->w_next; | |
252 } | |
253 } | |
254 else | |
255 { | |
256 if (nchar == 'W') /* go to previous window */ | |
257 { | |
258 wp = curwin->w_prev; | |
259 if (wp == NULL) | |
260 wp = lastwin; /* wrap around */ | |
261 } | |
262 else /* go to next window */ | |
263 { | |
264 wp = curwin->w_next; | |
265 if (wp == NULL) | |
266 wp = firstwin; /* wrap around */ | |
267 } | |
268 } | |
269 win_goto(wp); | |
270 } | |
271 break; | |
272 | |
273 /* cursor to window below */ | |
274 case 'j': | |
275 case K_DOWN: | |
276 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
|
277 CHECK_CMDWIN; |
7 | 278 win_goto_ver(FALSE, Prenum1); |
279 break; | |
280 | |
281 /* cursor to window above */ | |
282 case 'k': | |
283 case K_UP: | |
284 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
|
285 CHECK_CMDWIN; |
7 | 286 win_goto_ver(TRUE, Prenum1); |
287 break; | |
288 | |
289 /* cursor to left window */ | |
290 case 'h': | |
291 case K_LEFT: | |
292 case Ctrl_H: | |
293 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
|
294 CHECK_CMDWIN; |
7 | 295 win_goto_hor(TRUE, Prenum1); |
296 break; | |
297 | |
298 /* cursor to right window */ | |
299 case 'l': | |
300 case K_RIGHT: | |
301 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
|
302 CHECK_CMDWIN; |
7 | 303 win_goto_hor(FALSE, Prenum1); |
304 break; | |
305 | |
826 | 306 /* move window to new tab page */ |
307 case 'T': | |
1906 | 308 if (one_window()) |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15490
diff
changeset
|
309 msg(_(m_onlyone)); |
826 | 310 else |
311 { | |
312 tabpage_T *oldtab = curtab; | |
313 tabpage_T *newtab; | |
314 | |
315 /* First create a new tab with the window, then go back to | |
316 * the old tab and close the window there. */ | |
944 | 317 wp = curwin; |
826 | 318 if (win_new_tabpage((int)Prenum) == OK |
319 && valid_tabpage(oldtab)) | |
320 { | |
321 newtab = curtab; | |
4354 | 322 goto_tabpage_tp(oldtab, TRUE, TRUE); |
826 | 323 if (curwin == wp) |
324 win_close(curwin, FALSE); | |
325 if (valid_tabpage(newtab)) | |
4354 | 326 goto_tabpage_tp(newtab, TRUE, TRUE); |
826 | 327 } |
328 } | |
329 break; | |
330 | |
7 | 331 /* cursor to top-left window */ |
332 case 't': | |
333 case Ctrl_T: | |
334 win_goto(firstwin); | |
335 break; | |
336 | |
337 /* cursor to bottom-right window */ | |
338 case 'b': | |
339 case Ctrl_B: | |
340 win_goto(lastwin); | |
341 break; | |
342 | |
343 /* cursor to last accessed (previous) window */ | |
344 case 'p': | |
345 case Ctrl_P: | |
8833
dc10bd23f918
commit https://github.com/vim/vim/commit/3dda7db4e1f7c4a8110a1f83001ec36b46693d27
Christian Brabandt <cb@256bit.org>
parents:
8804
diff
changeset
|
346 if (!win_valid(prevwin)) |
7 | 347 beep_flush(); |
348 else | |
349 win_goto(prevwin); | |
350 break; | |
351 | |
352 /* exchange current and next window */ | |
353 case 'x': | |
354 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
|
355 CHECK_CMDWIN; |
7 | 356 win_exchange(Prenum); |
357 break; | |
358 | |
359 /* rotate windows downwards */ | |
360 case Ctrl_R: | |
361 case 'r': | |
13632
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
362 CHECK_CMDWIN; |
7 | 363 reset_VIsual_and_resel(); /* stop Visual mode */ |
364 win_rotate(FALSE, (int)Prenum1); /* downwards */ | |
365 break; | |
366 | |
367 /* rotate windows upwards */ | |
368 case 'R': | |
13632
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
369 CHECK_CMDWIN; |
7 | 370 reset_VIsual_and_resel(); /* stop Visual mode */ |
371 win_rotate(TRUE, (int)Prenum1); /* upwards */ | |
372 break; | |
373 | |
374 /* move window to the very top/bottom/left/right */ | |
375 case 'K': | |
376 case 'J': | |
377 case 'H': | |
378 case 'L': | |
13632
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
379 CHECK_CMDWIN; |
7 | 380 win_totop((int)Prenum, |
381 ((nchar == 'H' || nchar == 'L') ? WSP_VERT : 0) | |
382 | ((nchar == 'H' || nchar == 'K') ? WSP_TOP : WSP_BOT)); | |
383 break; | |
384 | |
385 /* make all windows the same height */ | |
386 case '=': | |
387 #ifdef FEAT_GUI | |
388 need_mouse_correct = TRUE; | |
389 #endif | |
390 win_equal(NULL, FALSE, 'b'); | |
391 break; | |
392 | |
393 /* increase current window height */ | |
394 case '+': | |
395 #ifdef FEAT_GUI | |
396 need_mouse_correct = TRUE; | |
397 #endif | |
398 win_setheight(curwin->w_height + (int)Prenum1); | |
399 break; | |
400 | |
401 /* decrease current window height */ | |
402 case '-': | |
403 #ifdef FEAT_GUI | |
404 need_mouse_correct = TRUE; | |
405 #endif | |
406 win_setheight(curwin->w_height - (int)Prenum1); | |
407 break; | |
408 | |
409 /* set current window height */ | |
410 case Ctrl__: | |
411 case '_': | |
412 #ifdef FEAT_GUI | |
413 need_mouse_correct = TRUE; | |
414 #endif | |
415 win_setheight(Prenum ? (int)Prenum : 9999); | |
416 break; | |
417 | |
418 /* increase current window width */ | |
419 case '>': | |
420 #ifdef FEAT_GUI | |
421 need_mouse_correct = TRUE; | |
422 #endif | |
423 win_setwidth(curwin->w_width + (int)Prenum1); | |
424 break; | |
425 | |
426 /* decrease current window width */ | |
427 case '<': | |
428 #ifdef FEAT_GUI | |
429 need_mouse_correct = TRUE; | |
430 #endif | |
431 win_setwidth(curwin->w_width - (int)Prenum1); | |
432 break; | |
433 | |
434 /* set current window width */ | |
435 case '|': | |
436 #ifdef FEAT_GUI | |
437 need_mouse_correct = TRUE; | |
438 #endif | |
439 win_setwidth(Prenum != 0 ? (int)Prenum : 9999); | |
440 break; | |
441 | |
442 /* jump to tag and split window if tag exists (in preview window) */ | |
443 #if defined(FEAT_QUICKFIX) | |
444 case '}': | |
13632
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
445 CHECK_CMDWIN; |
7 | 446 if (Prenum) |
447 g_do_tagpreview = Prenum; | |
448 else | |
449 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
|
450 #endif |
e769c912fcd9
patch 8.0.1215: newer gcc warns for implicit fallthrough
Christian Brabandt <cb@256bit.org>
parents:
12564
diff
changeset
|
451 /* FALLTHROUGH */ |
7 | 452 case ']': |
453 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
|
454 CHECK_CMDWIN; |
6239 | 455 /* keep Visual mode, can select words to use as a tag */ |
7 | 456 if (Prenum) |
457 postponed_split = Prenum; | |
458 else | |
459 postponed_split = -1; | |
6251 | 460 #ifdef FEAT_QUICKFIX |
6264 | 461 if (nchar != '}') |
462 g_do_tagpreview = 0; | |
6251 | 463 #endif |
6239 | 464 |
465 /* Execute the command right here, required when "wincmd ]" | |
466 * was used in a function. */ | |
7 | 467 do_nv_ident(Ctrl_RSB, NUL); |
468 break; | |
469 | |
470 #ifdef FEAT_SEARCHPATH | |
471 /* edit file name under cursor in a new window */ | |
472 case 'f': | |
681 | 473 case 'F': |
7 | 474 case Ctrl_F: |
820 | 475 wingotofile: |
13632
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
476 CHECK_CMDWIN; |
344 | 477 |
681 | 478 ptr = grab_file_name(Prenum1, &lnum); |
7 | 479 if (ptr != NULL) |
480 { | |
9349
b24900b73f90
commit https://github.com/vim/vim/commit/5d2ca0402954ff79b73d9c86cc16c8a6454b75a7
Christian Brabandt <cb@256bit.org>
parents:
9223
diff
changeset
|
481 tabpage_T *oldtab = curtab; |
b24900b73f90
commit https://github.com/vim/vim/commit/5d2ca0402954ff79b73d9c86cc16c8a6454b75a7
Christian Brabandt <cb@256bit.org>
parents:
9223
diff
changeset
|
482 win_T *oldwin = curwin; |
820 | 483 # ifdef FEAT_GUI |
7 | 484 need_mouse_correct = TRUE; |
820 | 485 # endif |
7 | 486 setpcmark(); |
487 if (win_split(0, 0) == OK) | |
488 { | |
2583 | 489 RESET_BINDING(curwin); |
9349
b24900b73f90
commit https://github.com/vim/vim/commit/5d2ca0402954ff79b73d9c86cc16c8a6454b75a7
Christian Brabandt <cb@256bit.org>
parents:
9223
diff
changeset
|
490 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
|
491 ECMD_HIDE, NULL) == FAIL) |
b24900b73f90
commit https://github.com/vim/vim/commit/5d2ca0402954ff79b73d9c86cc16c8a6454b75a7
Christian Brabandt <cb@256bit.org>
parents:
9223
diff
changeset
|
492 { |
b24900b73f90
commit https://github.com/vim/vim/commit/5d2ca0402954ff79b73d9c86cc16c8a6454b75a7
Christian Brabandt <cb@256bit.org>
parents:
9223
diff
changeset
|
493 /* Failed to open the file, close the window |
b24900b73f90
commit https://github.com/vim/vim/commit/5d2ca0402954ff79b73d9c86cc16c8a6454b75a7
Christian Brabandt <cb@256bit.org>
parents:
9223
diff
changeset
|
494 * opened for it. */ |
b24900b73f90
commit https://github.com/vim/vim/commit/5d2ca0402954ff79b73d9c86cc16c8a6454b75a7
Christian Brabandt <cb@256bit.org>
parents:
9223
diff
changeset
|
495 win_close(curwin, FALSE); |
b24900b73f90
commit https://github.com/vim/vim/commit/5d2ca0402954ff79b73d9c86cc16c8a6454b75a7
Christian Brabandt <cb@256bit.org>
parents:
9223
diff
changeset
|
496 goto_tabpage_win(oldtab, oldwin); |
b24900b73f90
commit https://github.com/vim/vim/commit/5d2ca0402954ff79b73d9c86cc16c8a6454b75a7
Christian Brabandt <cb@256bit.org>
parents:
9223
diff
changeset
|
497 } |
b24900b73f90
commit https://github.com/vim/vim/commit/5d2ca0402954ff79b73d9c86cc16c8a6454b75a7
Christian Brabandt <cb@256bit.org>
parents:
9223
diff
changeset
|
498 else if (nchar == 'F' && lnum >= 0) |
681 | 499 { |
500 curwin->w_cursor.lnum = lnum; | |
501 check_cursor_lnum(); | |
502 beginline(BL_SOL | BL_FIX); | |
503 } | |
7 | 504 } |
505 vim_free(ptr); | |
506 } | |
507 break; | |
508 #endif | |
509 | |
510 #ifdef FEAT_FIND_ID | |
1187 | 511 /* Go to the first occurrence of the identifier under cursor along path in a |
7 | 512 * new window -- webb |
513 */ | |
514 case 'i': /* Go to any match */ | |
515 case Ctrl_I: | |
516 type = FIND_ANY; | |
517 /* FALLTHROUGH */ | |
518 case 'd': /* Go to definition, using 'define' */ | |
519 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
|
520 CHECK_CMDWIN; |
7 | 521 if ((len = find_ident_under_cursor(&ptr, FIND_IDENT)) == 0) |
522 break; | |
523 find_pattern_in_path(ptr, 0, len, TRUE, | |
524 Prenum == 0 ? TRUE : FALSE, type, | |
525 Prenum1, ACTION_SPLIT, (linenr_T)1, (linenr_T)MAXLNUM); | |
526 curwin->w_set_curswant = TRUE; | |
527 break; | |
528 #endif | |
529 | |
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
|
530 /* Quickfix window only: view the result under the cursor in a new split. */ |
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
|
531 #if defined(FEAT_QUICKFIX) |
170 | 532 case K_KENTER: |
533 case CAR: | |
534 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
|
535 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
|
536 break; |
170 | 537 #endif |
538 | |
7 | 539 /* CTRL-W g extended commands */ |
540 case 'g': | |
541 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
|
542 CHECK_CMDWIN; |
7 | 543 #ifdef USE_ON_FLY_SCROLL |
544 dont_scroll = TRUE; /* disallow scrolling here */ | |
545 #endif | |
546 ++no_mapping; | |
547 ++allow_keys; /* no mapping for xchar, but allow key codes */ | |
548 if (xchar == NUL) | |
1389 | 549 xchar = plain_vgetc(); |
7 | 550 LANGMAP_ADJUST(xchar, TRUE); |
551 --no_mapping; | |
552 --allow_keys; | |
553 #ifdef FEAT_CMDL_INFO | |
554 (void)add_to_showcmd(xchar); | |
555 #endif | |
556 switch (xchar) | |
557 { | |
558 #if defined(FEAT_QUICKFIX) | |
559 case '}': | |
560 xchar = Ctrl_RSB; | |
561 if (Prenum) | |
562 g_do_tagpreview = Prenum; | |
563 else | |
564 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
|
565 #endif |
e769c912fcd9
patch 8.0.1215: newer gcc warns for implicit fallthrough
Christian Brabandt <cb@256bit.org>
parents:
12564
diff
changeset
|
566 /* FALLTHROUGH */ |
7 | 567 case ']': |
568 case Ctrl_RSB: | |
6239 | 569 /* keep Visual mode, can select words to use as a tag */ |
7 | 570 if (Prenum) |
571 postponed_split = Prenum; | |
572 else | |
573 postponed_split = -1; | |
574 | |
575 /* Execute the command right here, required when | |
576 * "wincmd g}" was used in a function. */ | |
577 do_nv_ident('g', xchar); | |
578 break; | |
579 | |
820 | 580 #ifdef FEAT_SEARCHPATH |
581 case 'f': /* CTRL-W gf: "gf" in a new tab page */ | |
839 | 582 case 'F': /* CTRL-W gF: "gF" in a new tab page */ |
2064
f398e0cc5b7a
updated for version 7.2.349
Bram Moolenaar <bram@zimbu.org>
parents:
1918
diff
changeset
|
583 cmdmod.tab = tabpage_index(curtab) + 1; |
839 | 584 nchar = xchar; |
820 | 585 goto wingotofile; |
586 #endif | |
15933
b2423b31266f
patch 8.1.0972: cannot switch from terminal window to next tabpage
Bram Moolenaar <Bram@vim.org>
parents:
15850
diff
changeset
|
587 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
|
588 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
|
589 break; |
b2423b31266f
patch 8.1.0972: cannot switch from terminal window to next tabpage
Bram Moolenaar <Bram@vim.org>
parents:
15850
diff
changeset
|
590 |
7 | 591 default: |
592 beep_flush(); | |
593 break; | |
594 } | |
595 break; | |
596 | |
597 default: beep_flush(); | |
598 break; | |
599 } | |
600 } | |
601 | |
6489 | 602 /* |
603 * Figure out the address type for ":wnncmd". | |
604 */ | |
605 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
606 get_wincmd_addr_type(char_u *arg, exarg_T *eap) |
6489 | 607 { |
608 switch (*arg) | |
609 { | |
610 case 'S': | |
611 case Ctrl_S: | |
612 case 's': | |
613 case Ctrl_N: | |
614 case 'n': | |
615 case 'j': | |
616 case Ctrl_J: | |
617 case 'k': | |
618 case Ctrl_K: | |
619 case 'T': | |
620 case Ctrl_R: | |
621 case 'r': | |
622 case 'R': | |
623 case 'K': | |
624 case 'J': | |
625 case '+': | |
626 case '-': | |
627 case Ctrl__: | |
628 case '_': | |
629 case '|': | |
630 case ']': | |
631 case Ctrl_RSB: | |
632 case 'g': | |
633 case Ctrl_G: | |
634 case Ctrl_V: | |
635 case 'v': | |
636 case 'h': | |
637 case Ctrl_H: | |
638 case 'l': | |
639 case Ctrl_L: | |
640 case 'H': | |
641 case 'L': | |
642 case '>': | |
643 case '<': | |
644 #if defined(FEAT_QUICKFIX) | |
645 case '}': | |
646 #endif | |
647 #ifdef FEAT_SEARCHPATH | |
648 case 'f': | |
649 case 'F': | |
650 case Ctrl_F: | |
651 #endif | |
652 #ifdef FEAT_FIND_ID | |
653 case 'i': | |
654 case Ctrl_I: | |
655 case 'd': | |
656 case Ctrl_D: | |
657 #endif | |
658 /* window size or any count */ | |
659 eap->addr_type = ADDR_LINES; | |
660 break; | |
661 | |
662 case Ctrl_HAT: | |
663 case '^': | |
664 /* buffer number */ | |
665 eap->addr_type = ADDR_BUFFERS; | |
666 break; | |
667 | |
668 case Ctrl_Q: | |
669 case 'q': | |
670 case Ctrl_C: | |
671 case 'c': | |
672 case Ctrl_O: | |
673 case 'o': | |
674 case Ctrl_W: | |
675 case 'w': | |
676 case 'W': | |
677 case 'x': | |
678 case Ctrl_X: | |
679 /* window number */ | |
680 eap->addr_type = ADDR_WINDOWS; | |
681 break; | |
682 | |
683 #if defined(FEAT_QUICKFIX) | |
684 case Ctrl_Z: | |
685 case 'z': | |
686 case 'P': | |
687 #endif | |
688 case 't': | |
689 case Ctrl_T: | |
690 case 'b': | |
691 case Ctrl_B: | |
692 case 'p': | |
693 case Ctrl_P: | |
694 case '=': | |
695 case CAR: | |
696 /* no count */ | |
697 eap->addr_type = 0; | |
698 break; | |
699 } | |
700 } | |
701 | |
6432 | 702 static void |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
703 cmd_with_count( |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
704 char *cmd, |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
705 char_u *bufp, |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
706 size_t bufsize, |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
707 long Prenum) |
6432 | 708 { |
709 size_t len = STRLEN(cmd); | |
710 | |
711 STRCPY(bufp, cmd); | |
712 if (Prenum > 0) | |
713 vim_snprintf((char *)bufp + len, bufsize - len, "%ld", Prenum); | |
714 } | |
715 | |
7 | 716 /* |
717 * split the current window, implements CTRL-W s and :split | |
718 * | |
719 * "size" is the height or width for the new window, 0 to use half of current | |
720 * height or width. | |
721 * | |
722 * "flags": | |
723 * WSP_ROOM: require enough room for new window | |
724 * WSP_VERT: vertical split. | |
725 * WSP_TOP: open window at the top-left of the shell (help window). | |
726 * WSP_BOT: open window at the bottom-right of the shell (quickfix window). | |
727 * WSP_HELP: creating the help window, keep layout snapshot | |
728 * | |
729 * return FAIL for failure, OK otherwise | |
730 */ | |
731 int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
732 win_split(int size, int flags) |
7 | 733 { |
682 | 734 /* When the ":tab" modifier was used open a new tab page instead. */ |
735 if (may_open_tabpage() == OK) | |
736 return OK; | |
737 | |
7 | 738 /* Add flags from ":vertical", ":topleft" and ":botright". */ |
739 flags |= cmdmod.split; | |
740 if ((flags & WSP_TOP) && (flags & WSP_BOT)) | |
741 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15436
diff
changeset
|
742 emsg(_("E442: Can't split topleft and botright at the same time")); |
7 | 743 return FAIL; |
744 } | |
745 | |
746 /* When creating the help window make a snapshot of the window layout. | |
747 * Otherwise clear the snapshot, it's now invalid. */ | |
748 if (flags & WSP_HELP) | |
1906 | 749 make_snapshot(SNAP_HELP_IDX); |
7 | 750 else |
1906 | 751 clear_snapshot(curtab, SNAP_HELP_IDX); |
7 | 752 |
753 return win_split_ins(size, flags, NULL, 0); | |
754 } | |
755 | |
756 /* | |
3263 | 757 * When "new_wp" is NULL: split the current window in two. |
758 * When "new_wp" is not NULL: insert this window at the far | |
7 | 759 * top/left/right/bottom. |
760 * return FAIL for failure, OK otherwise | |
761 */ | |
1906 | 762 int |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
763 win_split_ins( |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
764 int size, |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
765 int flags, |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
766 win_T *new_wp, |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
767 int dir) |
7 | 768 { |
3263 | 769 win_T *wp = new_wp; |
7 | 770 win_T *oldwin; |
771 int new_size = size; | |
772 int i; | |
773 int need_status = 0; | |
774 int do_equal = FALSE; | |
775 int needed; | |
776 int available; | |
777 int oldwin_height = 0; | |
778 int layout; | |
6077 | 779 frame_T *frp, *curfrp, *frp2, *prevfrp; |
7 | 780 int before; |
6052 | 781 int minheight; |
6066 | 782 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
|
783 int did_set_fraction = FALSE; |
7 | 784 |
785 if (flags & WSP_TOP) | |
786 oldwin = firstwin; | |
787 else if (flags & WSP_BOT) | |
788 oldwin = lastwin; | |
789 else | |
790 oldwin = curwin; | |
791 | |
792 /* 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
|
793 if (ONE_WINDOW && p_ls == 1 && oldwin->w_status_height == 0) |
7 | 794 { |
12998
dd734ee3e2fe
patch 8.0.1375: window size wrong after maximizing with WinBar
Christian Brabandt <cb@256bit.org>
parents:
12916
diff
changeset
|
795 if (VISIBLE_HEIGHT(oldwin) <= p_wmh && new_wp == NULL) |
7 | 796 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15436
diff
changeset
|
797 emsg(_(e_noroom)); |
7 | 798 return FAIL; |
799 } | |
800 need_status = STATUS_HEIGHT; | |
801 } | |
802 | |
1114 | 803 #ifdef FEAT_GUI |
804 /* May be needed for the scrollbars that are going to change. */ | |
805 if (gui.in_use) | |
806 out_flush(); | |
807 #endif | |
808 | |
7 | 809 if (flags & WSP_VERT) |
810 { | |
6068 | 811 int wmw1; |
812 int minwidth; | |
813 | |
7 | 814 layout = FR_ROW; |
815 | |
816 /* | |
817 * Check if we are able to split the current window and compute its | |
818 * width. | |
819 */ | |
6066 | 820 /* Current window requires at least 1 space. */ |
821 wmw1 = (p_wmw == 0 ? 1 : p_wmw); | |
822 needed = wmw1 + 1; | |
7 | 823 if (flags & WSP_ROOM) |
6066 | 824 needed += p_wiw - wmw1; |
6077 | 825 if (flags & (WSP_BOT | WSP_TOP)) |
7 | 826 { |
6066 | 827 minwidth = frame_minwidth(topframe, NOWIN); |
7 | 828 available = topframe->fr_width; |
6052 | 829 needed += minwidth; |
7 | 830 } |
6077 | 831 else if (p_ea) |
832 { | |
833 minwidth = frame_minwidth(oldwin->w_frame, NOWIN); | |
834 prevfrp = oldwin->w_frame; | |
835 for (frp = oldwin->w_frame->fr_parent; frp != NULL; | |
836 frp = frp->fr_parent) | |
837 { | |
838 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
|
839 FOR_ALL_FRAMES(frp2, frp->fr_child) |
6077 | 840 if (frp2 != prevfrp) |
841 minwidth += frame_minwidth(frp2, NOWIN); | |
842 prevfrp = frp; | |
843 } | |
844 available = topframe->fr_width; | |
845 needed += minwidth; | |
846 } | |
7 | 847 else |
6052 | 848 { |
6066 | 849 minwidth = frame_minwidth(oldwin->w_frame, NOWIN); |
850 available = oldwin->w_frame->fr_width; | |
851 needed += minwidth; | |
6052 | 852 } |
3263 | 853 if (available < needed && new_wp == NULL) |
7 | 854 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15436
diff
changeset
|
855 emsg(_(e_noroom)); |
7 | 856 return FAIL; |
857 } | |
858 if (new_size == 0) | |
859 new_size = oldwin->w_width / 2; | |
6052 | 860 if (new_size > available - minwidth - 1) |
861 new_size = available - minwidth - 1; | |
6066 | 862 if (new_size < wmw1) |
863 new_size = wmw1; | |
7 | 864 |
865 /* if it doesn't fit in the current window, need win_equal() */ | |
866 if (oldwin->w_width - new_size - 1 < p_wmw) | |
867 do_equal = TRUE; | |
779 | 868 |
869 /* We don't like to take lines for the new window from a | |
870 * 'winfixwidth' window. Take them from a window to the left or right | |
11207
e6140f3d2be7
patch 8.0.0490: vertical split makes 'winfixwidth' window smaller
Christian Brabandt <cb@256bit.org>
parents:
11199
diff
changeset
|
871 * instead, if possible. Add one for the separator. */ |
779 | 872 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
|
873 win_setwidth_win(oldwin->w_width + new_size + 1, oldwin); |
1354 | 874 |
875 /* Only make all windows the same width if one of them (except oldwin) | |
876 * is wider than one of the split windows. */ | |
877 if (!do_equal && p_ea && size == 0 && *p_ead != 'v' | |
878 && oldwin->w_frame->fr_parent != NULL) | |
879 { | |
880 frp = oldwin->w_frame->fr_parent->fr_child; | |
881 while (frp != NULL) | |
882 { | |
883 if (frp->fr_win != oldwin && frp->fr_win != NULL | |
884 && (frp->fr_win->w_width > new_size | |
885 || frp->fr_win->w_width > oldwin->w_width | |
6373 | 886 - new_size - 1)) |
1354 | 887 { |
888 do_equal = TRUE; | |
889 break; | |
890 } | |
891 frp = frp->fr_next; | |
892 } | |
893 } | |
7 | 894 } |
895 else | |
896 { | |
897 layout = FR_COL; | |
898 | |
899 /* | |
900 * Check if we are able to split the current window and compute its | |
901 * height. | |
902 */ | |
6066 | 903 /* 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
|
904 wmh1 = (p_wmh == 0 ? 1 : p_wmh) + WINBAR_HEIGHT(curwin); |
6066 | 905 needed = wmh1 + STATUS_HEIGHT; |
7 | 906 if (flags & WSP_ROOM) |
6066 | 907 needed += p_wh - wmh1; |
6077 | 908 if (flags & (WSP_BOT | WSP_TOP)) |
7 | 909 { |
6066 | 910 minheight = frame_minheight(topframe, NOWIN) + need_status; |
7 | 911 available = topframe->fr_height; |
6052 | 912 needed += minheight; |
7 | 913 } |
6077 | 914 else if (p_ea) |
915 { | |
916 minheight = frame_minheight(oldwin->w_frame, NOWIN) + need_status; | |
917 prevfrp = oldwin->w_frame; | |
918 for (frp = oldwin->w_frame->fr_parent; frp != NULL; | |
919 frp = frp->fr_parent) | |
920 { | |
921 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
|
922 FOR_ALL_FRAMES(frp2, frp->fr_child) |
6077 | 923 if (frp2 != prevfrp) |
924 minheight += frame_minheight(frp2, NOWIN); | |
925 prevfrp = frp; | |
926 } | |
927 available = topframe->fr_height; | |
928 needed += minheight; | |
929 } | |
7 | 930 else |
931 { | |
6066 | 932 minheight = frame_minheight(oldwin->w_frame, NOWIN) + need_status; |
933 available = oldwin->w_frame->fr_height; | |
934 needed += minheight; | |
7 | 935 } |
3263 | 936 if (available < needed && new_wp == NULL) |
7 | 937 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15436
diff
changeset
|
938 emsg(_(e_noroom)); |
7 | 939 return FAIL; |
940 } | |
941 oldwin_height = oldwin->w_height; | |
942 if (need_status) | |
943 { | |
944 oldwin->w_status_height = STATUS_HEIGHT; | |
945 oldwin_height -= STATUS_HEIGHT; | |
946 } | |
947 if (new_size == 0) | |
948 new_size = oldwin_height / 2; | |
6052 | 949 if (new_size > available - minheight - STATUS_HEIGHT) |
950 new_size = available - minheight - STATUS_HEIGHT; | |
6066 | 951 if (new_size < wmh1) |
952 new_size = wmh1; | |
7 | 953 |
954 /* if it doesn't fit in the current window, need win_equal() */ | |
955 if (oldwin_height - new_size - STATUS_HEIGHT < p_wmh) | |
956 do_equal = TRUE; | |
957 | |
958 /* We don't like to take lines for the new window from a | |
959 * 'winfixheight' window. Take them from a window above or below | |
960 * instead, if possible. */ | |
961 if (oldwin->w_p_wfh) | |
962 { | |
13670
3085d67d24c8
patch 8.0.1707: when 'wfh' is set ":bel 10new" scrolls window
Christian Brabandt <cb@256bit.org>
parents:
13632
diff
changeset
|
963 /* Set w_fraction now so that the cursor keeps the same relative |
3085d67d24c8
patch 8.0.1707: when 'wfh' is set ":bel 10new" scrolls window
Christian Brabandt <cb@256bit.org>
parents:
13632
diff
changeset
|
964 * vertical position using the old height. */ |
3085d67d24c8
patch 8.0.1707: when 'wfh' is set ":bel 10new" scrolls window
Christian Brabandt <cb@256bit.org>
parents:
13632
diff
changeset
|
965 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
|
966 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
|
967 |
7 | 968 win_setheight_win(oldwin->w_height + new_size + STATUS_HEIGHT, |
969 oldwin); | |
970 oldwin_height = oldwin->w_height; | |
971 if (need_status) | |
972 oldwin_height -= STATUS_HEIGHT; | |
973 } | |
1354 | 974 |
975 /* Only make all windows the same height if one of them (except oldwin) | |
976 * 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
|
977 if (!do_equal && p_ea && size == 0 && *p_ead != 'h' |
1354 | 978 && oldwin->w_frame->fr_parent != NULL) |
979 { | |
980 frp = oldwin->w_frame->fr_parent->fr_child; | |
981 while (frp != NULL) | |
982 { | |
983 if (frp->fr_win != oldwin && frp->fr_win != NULL | |
984 && (frp->fr_win->w_height > new_size | |
985 || frp->fr_win->w_height > oldwin_height - new_size | |
986 - STATUS_HEIGHT)) | |
987 { | |
988 do_equal = TRUE; | |
989 break; | |
990 } | |
991 frp = frp->fr_next; | |
992 } | |
993 } | |
7 | 994 } |
995 | |
996 /* | |
997 * allocate new window structure and link it in the window list | |
998 */ | |
999 if ((flags & WSP_TOP) == 0 | |
1000 && ((flags & WSP_BOT) | |
1001 || (flags & WSP_BELOW) | |
1002 || (!(flags & WSP_ABOVE) | |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8536
diff
changeset
|
1003 && ( (flags & WSP_VERT) ? p_spr : p_sb)))) |
7 | 1004 { |
1005 /* new window below/right of current one */ | |
3263 | 1006 if (new_wp == NULL) |
1906 | 1007 wp = win_alloc(oldwin, FALSE); |
7 | 1008 else |
1009 win_append(oldwin, wp); | |
1010 } | |
1011 else | |
1012 { | |
3263 | 1013 if (new_wp == NULL) |
1906 | 1014 wp = win_alloc(oldwin->w_prev, FALSE); |
7 | 1015 else |
1016 win_append(oldwin->w_prev, wp); | |
1017 } | |
1018 | |
3263 | 1019 if (new_wp == NULL) |
7 | 1020 { |
1021 if (wp == NULL) | |
1022 return FAIL; | |
1023 | |
1906 | 1024 new_frame(wp); |
1025 if (wp->w_frame == NULL) | |
1026 { | |
1027 win_free(wp, NULL); | |
1028 return FAIL; | |
1029 } | |
1030 | |
675 | 1031 /* make the contents of the new window the same as the current one */ |
1822 | 1032 win_init(wp, curwin, flags); |
7 | 1033 } |
1034 | |
1035 /* | |
1036 * Reorganise the tree of frames to insert the new window. | |
1037 */ | |
1038 if (flags & (WSP_TOP | WSP_BOT)) | |
1039 { | |
1040 if ((topframe->fr_layout == FR_COL && (flags & WSP_VERT) == 0) | |
1041 || (topframe->fr_layout == FR_ROW && (flags & WSP_VERT) != 0)) | |
1042 { | |
1043 curfrp = topframe->fr_child; | |
1044 if (flags & WSP_BOT) | |
1045 while (curfrp->fr_next != NULL) | |
1046 curfrp = curfrp->fr_next; | |
1047 } | |
1048 else | |
1049 curfrp = topframe; | |
1050 before = (flags & WSP_TOP); | |
1051 } | |
1052 else | |
1053 { | |
1054 curfrp = oldwin->w_frame; | |
1055 if (flags & WSP_BELOW) | |
1056 before = FALSE; | |
1057 else if (flags & WSP_ABOVE) | |
1058 before = TRUE; | |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8536
diff
changeset
|
1059 else if (flags & WSP_VERT) |
7 | 1060 before = !p_spr; |
1061 else | |
1062 before = !p_sb; | |
1063 } | |
1064 if (curfrp->fr_parent == NULL || curfrp->fr_parent->fr_layout != layout) | |
1065 { | |
1066 /* Need to create a new frame in the tree to make a branch. */ | |
1067 frp = (frame_T *)alloc_clear((unsigned)sizeof(frame_T)); | |
1068 *frp = *curfrp; | |
1069 curfrp->fr_layout = layout; | |
1070 frp->fr_parent = curfrp; | |
1071 frp->fr_next = NULL; | |
1072 frp->fr_prev = NULL; | |
1073 curfrp->fr_child = frp; | |
1074 curfrp->fr_win = NULL; | |
1075 curfrp = frp; | |
1076 if (frp->fr_win != NULL) | |
1077 oldwin->w_frame = frp; | |
1078 else | |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
1079 FOR_ALL_FRAMES(frp, frp->fr_child) |
7 | 1080 frp->fr_parent = curfrp; |
1081 } | |
1082 | |
3263 | 1083 if (new_wp == NULL) |
1906 | 1084 frp = wp->w_frame; |
7 | 1085 else |
3263 | 1086 frp = new_wp->w_frame; |
7 | 1087 frp->fr_parent = curfrp->fr_parent; |
1088 | |
1089 /* Insert the new frame at the right place in the frame list. */ | |
1090 if (before) | |
1091 frame_insert(curfrp, frp); | |
1092 else | |
1093 frame_append(curfrp, frp); | |
1094 | |
2665 | 1095 /* Set w_fraction now so that the cursor keeps the same relative |
1096 * 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
|
1097 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
|
1098 set_fraction(oldwin); |
2665 | 1099 wp->w_fraction = oldwin->w_fraction; |
1100 | |
7 | 1101 if (flags & WSP_VERT) |
1102 { | |
1103 wp->w_p_scr = curwin->w_p_scr; | |
2665 | 1104 |
7 | 1105 if (need_status) |
1106 { | |
2115
5fd44cf99b6d
updated for version 7.2.398
Bram Moolenaar <bram@zimbu.org>
parents:
2064
diff
changeset
|
1107 win_new_height(oldwin, oldwin->w_height - 1); |
7 | 1108 oldwin->w_status_height = need_status; |
1109 } | |
1110 if (flags & (WSP_TOP | WSP_BOT)) | |
1111 { | |
1112 /* set height and row of new window to full height */ | |
685 | 1113 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
|
1114 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
|
1115 - WINBAR_HEIGHT(wp)); |
7 | 1116 wp->w_status_height = (p_ls > 0); |
1117 } | |
1118 else | |
1119 { | |
1120 /* height and row of new window is same as current window */ | |
1121 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
|
1122 win_new_height(wp, VISIBLE_HEIGHT(oldwin)); |
7 | 1123 wp->w_status_height = oldwin->w_status_height; |
1124 } | |
1125 frp->fr_height = curfrp->fr_height; | |
1126 | |
1127 /* "new_size" of the current window goes to the new window, use | |
1128 * one column for the vertical separator */ | |
2115
5fd44cf99b6d
updated for version 7.2.398
Bram Moolenaar <bram@zimbu.org>
parents:
2064
diff
changeset
|
1129 win_new_width(wp, new_size); |
7 | 1130 if (before) |
1131 wp->w_vsep_width = 1; | |
1132 else | |
1133 { | |
1134 wp->w_vsep_width = oldwin->w_vsep_width; | |
1135 oldwin->w_vsep_width = 1; | |
1136 } | |
1137 if (flags & (WSP_TOP | WSP_BOT)) | |
1138 { | |
1139 if (flags & WSP_BOT) | |
1140 frame_add_vsep(curfrp); | |
1141 /* Set width of neighbor frame */ | |
1142 frame_new_width(curfrp, curfrp->fr_width | |
779 | 1143 - (new_size + ((flags & WSP_TOP) != 0)), flags & WSP_TOP, |
1144 FALSE); | |
7 | 1145 } |
1146 else | |
779 | 1147 win_new_width(oldwin, oldwin->w_width - (new_size + 1)); |
7 | 1148 if (before) /* new window left of current one */ |
1149 { | |
1150 wp->w_wincol = oldwin->w_wincol; | |
1151 oldwin->w_wincol += new_size + 1; | |
1152 } | |
1153 else /* new window right of current one */ | |
1154 wp->w_wincol = oldwin->w_wincol + oldwin->w_width + 1; | |
1155 frame_fix_width(oldwin); | |
1156 frame_fix_width(wp); | |
1157 } | |
1158 else | |
1159 { | |
1160 /* width and column of new window is same as current window */ | |
1161 if (flags & (WSP_TOP | WSP_BOT)) | |
1162 { | |
1163 wp->w_wincol = 0; | |
2115
5fd44cf99b6d
updated for version 7.2.398
Bram Moolenaar <bram@zimbu.org>
parents:
2064
diff
changeset
|
1164 win_new_width(wp, Columns); |
7 | 1165 wp->w_vsep_width = 0; |
1166 } | |
1167 else | |
1168 { | |
1169 wp->w_wincol = oldwin->w_wincol; | |
2115
5fd44cf99b6d
updated for version 7.2.398
Bram Moolenaar <bram@zimbu.org>
parents:
2064
diff
changeset
|
1170 win_new_width(wp, oldwin->w_width); |
7 | 1171 wp->w_vsep_width = oldwin->w_vsep_width; |
1172 } | |
1173 frp->fr_width = curfrp->fr_width; | |
1174 | |
1175 /* "new_size" of the current window goes to the new window, use | |
1176 * one row for the status line */ | |
1177 win_new_height(wp, new_size); | |
1178 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
|
1179 { |
12491
7ab796b041bd
patch 8.0.1125: wrong window height when splitting window with window toolbar
Christian Brabandt <cb@256bit.org>
parents:
12487
diff
changeset
|
1180 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
|
1181 + WINBAR_HEIGHT(wp) ; |
9102
0e90f3e13d88
commit https://github.com/vim/vim/commit/991dea3ab185fb35e577ab0bdfd443cd4b43ccc6
Christian Brabandt <cb@256bit.org>
parents:
8833
diff
changeset
|
1182 |
0e90f3e13d88
commit https://github.com/vim/vim/commit/991dea3ab185fb35e577ab0bdfd443cd4b43ccc6
Christian Brabandt <cb@256bit.org>
parents:
8833
diff
changeset
|
1183 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
|
1184 new_fr_height -= STATUS_HEIGHT; |
0e90f3e13d88
commit https://github.com/vim/vim/commit/991dea3ab185fb35e577ab0bdfd443cd4b43ccc6
Christian Brabandt <cb@256bit.org>
parents:
8833
diff
changeset
|
1185 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
|
1186 } |
7 | 1187 else |
1188 win_new_height(oldwin, oldwin_height - (new_size + STATUS_HEIGHT)); | |
1189 if (before) /* new window above current one */ | |
1190 { | |
1191 wp->w_winrow = oldwin->w_winrow; | |
1192 wp->w_status_height = STATUS_HEIGHT; | |
1193 oldwin->w_winrow += wp->w_height + STATUS_HEIGHT; | |
1194 } | |
1195 else /* new window below current one */ | |
1196 { | |
12998
dd734ee3e2fe
patch 8.0.1375: window size wrong after maximizing with WinBar
Christian Brabandt <cb@256bit.org>
parents:
12916
diff
changeset
|
1197 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
|
1198 + STATUS_HEIGHT; |
7 | 1199 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
|
1200 if (!(flags & WSP_BOT)) |
0e90f3e13d88
commit https://github.com/vim/vim/commit/991dea3ab185fb35e577ab0bdfd443cd4b43ccc6
Christian Brabandt <cb@256bit.org>
parents:
8833
diff
changeset
|
1201 oldwin->w_status_height = STATUS_HEIGHT; |
7 | 1202 } |
1203 if (flags & WSP_BOT) | |
1204 frame_add_statusline(curfrp); | |
1205 frame_fix_height(wp); | |
1206 frame_fix_height(oldwin); | |
1207 } | |
1208 | |
1209 if (flags & (WSP_TOP | WSP_BOT)) | |
1210 (void)win_comp_pos(); | |
1211 | |
1212 /* | |
1213 * Both windows need redrawing | |
1214 */ | |
1215 redraw_win_later(wp, NOT_VALID); | |
1216 wp->w_redr_status = TRUE; | |
1217 redraw_win_later(oldwin, NOT_VALID); | |
1218 oldwin->w_redr_status = TRUE; | |
1219 | |
1220 if (need_status) | |
1221 { | |
1222 msg_row = Rows - 1; | |
1223 msg_col = sc_col; | |
1224 msg_clr_eos_force(); /* Old command/ruler may still be there */ | |
1225 comp_col(); | |
1226 msg_row = Rows - 1; | |
1227 msg_col = 0; /* put position back at start of line */ | |
1228 } | |
1229 | |
1230 /* | |
2115
5fd44cf99b6d
updated for version 7.2.398
Bram Moolenaar <bram@zimbu.org>
parents:
2064
diff
changeset
|
1231 * equalize the window sizes. |
7 | 1232 */ |
1233 if (do_equal || dir != 0) | |
1234 win_equal(wp, TRUE, | |
1235 (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
|
1236 : dir == 'h' ? 'b' : 'v'); |
7 | 1237 |
1238 /* Don't change the window height/width to 'winheight' / 'winwidth' if a | |
1239 * size was given. */ | |
1240 if (flags & WSP_VERT) | |
1241 { | |
1242 i = p_wiw; | |
1243 if (size != 0) | |
1244 p_wiw = size; | |
1245 | |
1246 # ifdef FEAT_GUI | |
1247 /* When 'guioptions' includes 'L' or 'R' may have to add scrollbars. */ | |
1248 if (gui.in_use) | |
1249 gui_init_which_components(NULL); | |
1250 # endif | |
1251 } | |
1252 else | |
1253 { | |
1254 i = p_wh; | |
1255 if (size != 0) | |
1256 p_wh = size; | |
1257 } | |
2115
5fd44cf99b6d
updated for version 7.2.398
Bram Moolenaar <bram@zimbu.org>
parents:
2064
diff
changeset
|
1258 |
6096 | 1259 #ifdef FEAT_JUMPLIST |
1260 /* Keep same changelist position in new window. */ | |
1261 wp->w_changelistidx = oldwin->w_changelistidx; | |
1262 #endif | |
1263 | |
2115
5fd44cf99b6d
updated for version 7.2.398
Bram Moolenaar <bram@zimbu.org>
parents:
2064
diff
changeset
|
1264 /* |
5fd44cf99b6d
updated for version 7.2.398
Bram Moolenaar <bram@zimbu.org>
parents:
2064
diff
changeset
|
1265 * make the new window the current window |
5fd44cf99b6d
updated for version 7.2.398
Bram Moolenaar <bram@zimbu.org>
parents:
2064
diff
changeset
|
1266 */ |
9595
0190d5de215f
commit https://github.com/vim/vim/commit/c917da4b3e8801a255dbefea8e4ed19c1c716dd8
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
1267 win_enter_ext(wp, FALSE, FALSE, TRUE, TRUE, TRUE); |
7 | 1268 if (flags & WSP_VERT) |
1269 p_wiw = i; | |
1270 else | |
1271 p_wh = i; | |
1272 | |
1273 return OK; | |
1274 } | |
1275 | |
1906 | 1276 |
675 | 1277 /* |
1278 * Initialize window "newp" from window "oldp". | |
1279 * Used when splitting a window and when creating a new tab page. | |
1280 * The windows will both edit the same buffer. | |
1822 | 1281 * WSP_NEWLOC may be specified in flags to prevent the location list from |
1282 * being copied. | |
675 | 1283 */ |
1284 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1285 win_init(win_T *newp, win_T *oldp, int flags UNUSED) |
675 | 1286 { |
1287 int i; | |
1288 | |
1289 newp->w_buffer = oldp->w_buffer; | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2201
diff
changeset
|
1290 #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
|
1291 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
|
1292 #endif |
675 | 1293 oldp->w_buffer->b_nwindows++; |
1294 newp->w_cursor = oldp->w_cursor; | |
1295 newp->w_valid = 0; | |
1296 newp->w_curswant = oldp->w_curswant; | |
1297 newp->w_set_curswant = oldp->w_set_curswant; | |
1298 newp->w_topline = oldp->w_topline; | |
1299 #ifdef FEAT_DIFF | |
1300 newp->w_topfill = oldp->w_topfill; | |
1301 #endif | |
1302 newp->w_leftcol = oldp->w_leftcol; | |
1303 newp->w_pcmark = oldp->w_pcmark; | |
1304 newp->w_prev_pcmark = oldp->w_prev_pcmark; | |
1305 newp->w_alt_fnum = oldp->w_alt_fnum; | |
826 | 1306 newp->w_wrow = oldp->w_wrow; |
675 | 1307 newp->w_fraction = oldp->w_fraction; |
1308 newp->w_prev_fraction_row = oldp->w_prev_fraction_row; | |
1309 #ifdef FEAT_JUMPLIST | |
1310 copy_jumplist(oldp, newp); | |
1311 #endif | |
1312 #ifdef FEAT_QUICKFIX | |
1822 | 1313 if (flags & WSP_NEWLOC) |
1314 { | |
1315 /* Don't copy the location list. */ | |
1316 newp->w_llist = NULL; | |
1317 newp->w_llist_ref = NULL; | |
1318 } | |
1319 else | |
14844
a74786d0370c
patch 8.1.0434: copy_loclist() is too long
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
1320 copy_loclist_stack(oldp, newp); |
675 | 1321 #endif |
5584 | 1322 newp->w_localdir = (oldp->w_localdir == NULL) |
1323 ? NULL : vim_strsave(oldp->w_localdir); | |
675 | 1324 |
1906 | 1325 /* copy tagstack and folds */ |
675 | 1326 for (i = 0; i < oldp->w_tagstacklen; i++) |
1327 { | |
1328 newp->w_tagstack[i] = oldp->w_tagstack[i]; | |
1329 if (newp->w_tagstack[i].tagname != NULL) | |
1330 newp->w_tagstack[i].tagname = | |
1331 vim_strsave(newp->w_tagstack[i].tagname); | |
1332 } | |
1333 newp->w_tagstackidx = oldp->w_tagstackidx; | |
1334 newp->w_tagstacklen = oldp->w_tagstacklen; | |
3068 | 1335 #ifdef FEAT_FOLDING |
675 | 1336 copyFoldingState(oldp, newp); |
3068 | 1337 #endif |
1906 | 1338 |
1339 win_init_some(newp, oldp); | |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2306
diff
changeset
|
1340 |
3068 | 1341 #ifdef FEAT_SYN_HL |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2306
diff
changeset
|
1342 check_colorcolumn(newp); |
3068 | 1343 #endif |
1906 | 1344 } |
1345 | |
1346 /* | |
6222 | 1347 * Initialize window "newp" from window "old". |
1906 | 1348 * Only the essential things are copied. |
1349 */ | |
1350 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1351 win_init_some(win_T *newp, win_T *oldp) |
1906 | 1352 { |
1353 /* Use the same argument list. */ | |
1354 newp->w_alist = oldp->w_alist; | |
1355 ++newp->w_alist->al_refcount; | |
1356 newp->w_arg_idx = oldp->w_arg_idx; | |
1357 | |
1358 /* copy options from existing window */ | |
1359 win_copy_options(oldp, newp); | |
675 | 1360 } |
1361 | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
1362 |
7 | 1363 /* |
9875
42adbf172ecd
commit https://github.com/vim/vim/commit/e59215c7dcae17b03daf39517560cfaa03314f5a
Christian Brabandt <cb@256bit.org>
parents:
9858
diff
changeset
|
1364 * Check if "win" is a pointer to an existing window in the current tab page. |
7 | 1365 */ |
1366 int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1367 win_valid(win_T *win) |
7 | 1368 { |
1369 win_T *wp; | |
1370 | |
1371 if (win == NULL) | |
1372 return FALSE; | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9599
diff
changeset
|
1373 FOR_ALL_WINDOWS(wp) |
7 | 1374 if (wp == win) |
1375 return TRUE; | |
1376 return FALSE; | |
1377 } | |
1378 | |
1379 /* | |
9875
42adbf172ecd
commit https://github.com/vim/vim/commit/e59215c7dcae17b03daf39517560cfaa03314f5a
Christian Brabandt <cb@256bit.org>
parents:
9858
diff
changeset
|
1380 * 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
|
1381 */ |
42adbf172ecd
commit https://github.com/vim/vim/commit/e59215c7dcae17b03daf39517560cfaa03314f5a
Christian Brabandt <cb@256bit.org>
parents:
9858
diff
changeset
|
1382 int |
42adbf172ecd
commit https://github.com/vim/vim/commit/e59215c7dcae17b03daf39517560cfaa03314f5a
Christian Brabandt <cb@256bit.org>
parents:
9858
diff
changeset
|
1383 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
|
1384 { |
42adbf172ecd
commit https://github.com/vim/vim/commit/e59215c7dcae17b03daf39517560cfaa03314f5a
Christian Brabandt <cb@256bit.org>
parents:
9858
diff
changeset
|
1385 win_T *wp; |
42adbf172ecd
commit https://github.com/vim/vim/commit/e59215c7dcae17b03daf39517560cfaa03314f5a
Christian Brabandt <cb@256bit.org>
parents:
9858
diff
changeset
|
1386 tabpage_T *tp; |
42adbf172ecd
commit https://github.com/vim/vim/commit/e59215c7dcae17b03daf39517560cfaa03314f5a
Christian Brabandt <cb@256bit.org>
parents:
9858
diff
changeset
|
1387 |
42adbf172ecd
commit https://github.com/vim/vim/commit/e59215c7dcae17b03daf39517560cfaa03314f5a
Christian Brabandt <cb@256bit.org>
parents:
9858
diff
changeset
|
1388 if (win == NULL) |
42adbf172ecd
commit https://github.com/vim/vim/commit/e59215c7dcae17b03daf39517560cfaa03314f5a
Christian Brabandt <cb@256bit.org>
parents:
9858
diff
changeset
|
1389 return FALSE; |
42adbf172ecd
commit https://github.com/vim/vim/commit/e59215c7dcae17b03daf39517560cfaa03314f5a
Christian Brabandt <cb@256bit.org>
parents:
9858
diff
changeset
|
1390 FOR_ALL_TABPAGES(tp) |
42adbf172ecd
commit https://github.com/vim/vim/commit/e59215c7dcae17b03daf39517560cfaa03314f5a
Christian Brabandt <cb@256bit.org>
parents:
9858
diff
changeset
|
1391 { |
42adbf172ecd
commit https://github.com/vim/vim/commit/e59215c7dcae17b03daf39517560cfaa03314f5a
Christian Brabandt <cb@256bit.org>
parents:
9858
diff
changeset
|
1392 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
|
1393 { |
42adbf172ecd
commit https://github.com/vim/vim/commit/e59215c7dcae17b03daf39517560cfaa03314f5a
Christian Brabandt <cb@256bit.org>
parents:
9858
diff
changeset
|
1394 if (wp == win) |
42adbf172ecd
commit https://github.com/vim/vim/commit/e59215c7dcae17b03daf39517560cfaa03314f5a
Christian Brabandt <cb@256bit.org>
parents:
9858
diff
changeset
|
1395 return TRUE; |
42adbf172ecd
commit https://github.com/vim/vim/commit/e59215c7dcae17b03daf39517560cfaa03314f5a
Christian Brabandt <cb@256bit.org>
parents:
9858
diff
changeset
|
1396 } |
42adbf172ecd
commit https://github.com/vim/vim/commit/e59215c7dcae17b03daf39517560cfaa03314f5a
Christian Brabandt <cb@256bit.org>
parents:
9858
diff
changeset
|
1397 } |
42adbf172ecd
commit https://github.com/vim/vim/commit/e59215c7dcae17b03daf39517560cfaa03314f5a
Christian Brabandt <cb@256bit.org>
parents:
9858
diff
changeset
|
1398 return FALSE; |
42adbf172ecd
commit https://github.com/vim/vim/commit/e59215c7dcae17b03daf39517560cfaa03314f5a
Christian Brabandt <cb@256bit.org>
parents:
9858
diff
changeset
|
1399 } |
42adbf172ecd
commit https://github.com/vim/vim/commit/e59215c7dcae17b03daf39517560cfaa03314f5a
Christian Brabandt <cb@256bit.org>
parents:
9858
diff
changeset
|
1400 |
42adbf172ecd
commit https://github.com/vim/vim/commit/e59215c7dcae17b03daf39517560cfaa03314f5a
Christian Brabandt <cb@256bit.org>
parents:
9858
diff
changeset
|
1401 /* |
7 | 1402 * Return the number of windows. |
1403 */ | |
1404 int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1405 win_count(void) |
7 | 1406 { |
1407 win_T *wp; | |
1408 int count = 0; | |
1409 | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9599
diff
changeset
|
1410 FOR_ALL_WINDOWS(wp) |
7 | 1411 ++count; |
1412 return count; | |
1413 } | |
1414 | |
1415 /* | |
1416 * Make "count" windows on the screen. | |
1417 * Return actual number of windows on the screen. | |
1418 * Must be called when there is just one window, filling the whole screen | |
1419 * (excluding the command line). | |
1420 */ | |
1421 int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1422 make_windows( |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1423 int count, |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1424 int vertical UNUSED) /* split windows vertically if TRUE */ |
7 | 1425 { |
1426 int maxcount; | |
1427 int todo; | |
1428 | |
1429 if (vertical) | |
1430 { | |
1431 /* Each windows needs at least 'winminwidth' lines and a separator | |
1432 * column. */ | |
1433 maxcount = (curwin->w_width + curwin->w_vsep_width | |
1434 - (p_wiw - p_wmw)) / (p_wmw + 1); | |
1435 } | |
1436 else | |
1437 { | |
1438 /* 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
|
1439 maxcount = (VISIBLE_HEIGHT(curwin) + curwin->w_status_height |
7 | 1440 - (p_wh - p_wmh)) / (p_wmh + STATUS_HEIGHT); |
1441 } | |
1442 | |
1443 if (maxcount < 2) | |
1444 maxcount = 2; | |
1445 if (count > maxcount) | |
1446 count = maxcount; | |
1447 | |
1448 /* | |
1449 * add status line now, otherwise first window will be too big | |
1450 */ | |
1451 if (count > 1) | |
1452 last_status(TRUE); | |
1453 | |
1454 /* | |
1455 * Don't execute autocommands while creating the windows. Must do that | |
1456 * when putting the buffers in the windows. | |
1457 */ | |
1410 | 1458 block_autocmds(); |
7 | 1459 |
1460 /* todo is number of windows left to create */ | |
1461 for (todo = count - 1; todo > 0; --todo) | |
1462 if (vertical) | |
1463 { | |
1464 if (win_split(curwin->w_width - (curwin->w_width - todo) | |
1465 / (todo + 1) - 1, WSP_VERT | WSP_ABOVE) == FAIL) | |
1466 break; | |
1467 } | |
1468 else | |
1469 { | |
1470 if (win_split(curwin->w_height - (curwin->w_height - todo | |
1471 * STATUS_HEIGHT) / (todo + 1) | |
1472 - STATUS_HEIGHT, WSP_ABOVE) == FAIL) | |
1473 break; | |
1474 } | |
1475 | |
1410 | 1476 unblock_autocmds(); |
7 | 1477 |
1478 /* return actual number of windows */ | |
1479 return (count - todo); | |
1480 } | |
1481 | |
1482 /* | |
1483 * Exchange current and next window | |
1484 */ | |
1485 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1486 win_exchange(long Prenum) |
7 | 1487 { |
1488 frame_T *frp; | |
1489 frame_T *frp2; | |
1490 win_T *wp; | |
1491 win_T *wp2; | |
1492 int temp; | |
1493 | |
10357
59d01e335858
commit https://github.com/vim/vim/commit/459ca563128f2edb7e3bb190090bbb755a56dd55
Christian Brabandt <cb@256bit.org>
parents:
10349
diff
changeset
|
1494 if (ONE_WINDOW) /* just one window */ |
7 | 1495 { |
1496 beep_flush(); | |
1497 return; | |
1498 } | |
1499 | |
1500 #ifdef FEAT_GUI | |
1501 need_mouse_correct = TRUE; | |
1502 #endif | |
1503 | |
1504 /* | |
1505 * find window to exchange with | |
1506 */ | |
1507 if (Prenum) | |
1508 { | |
1509 frp = curwin->w_frame->fr_parent->fr_child; | |
1510 while (frp != NULL && --Prenum > 0) | |
1511 frp = frp->fr_next; | |
1512 } | |
1513 else if (curwin->w_frame->fr_next != NULL) /* Swap with next */ | |
1514 frp = curwin->w_frame->fr_next; | |
1515 else /* Swap last window in row/col with previous */ | |
1516 frp = curwin->w_frame->fr_prev; | |
1517 | |
1518 /* We can only exchange a window with another window, not with a frame | |
1519 * containing windows. */ | |
1520 if (frp == NULL || frp->fr_win == NULL || frp->fr_win == curwin) | |
1521 return; | |
1522 wp = frp->fr_win; | |
1523 | |
1524 /* | |
1525 * 1. remove curwin from the list. Remember after which window it was in wp2 | |
1526 * 2. insert curwin before wp in the list | |
1527 * if wp != wp2 | |
1528 * 3. remove wp from the list | |
1529 * 4. insert wp after wp2 | |
1530 * 5. exchange the status line height and vsep width. | |
1531 */ | |
1532 wp2 = curwin->w_prev; | |
1533 frp2 = curwin->w_frame->fr_prev; | |
1534 if (wp->w_prev != curwin) | |
1535 { | |
671 | 1536 win_remove(curwin, NULL); |
7 | 1537 frame_remove(curwin->w_frame); |
1538 win_append(wp->w_prev, curwin); | |
1539 frame_insert(frp, curwin->w_frame); | |
1540 } | |
1541 if (wp != wp2) | |
1542 { | |
671 | 1543 win_remove(wp, NULL); |
7 | 1544 frame_remove(wp->w_frame); |
1545 win_append(wp2, wp); | |
1546 if (frp2 == NULL) | |
1547 frame_insert(wp->w_frame->fr_parent->fr_child, wp->w_frame); | |
1548 else | |
1549 frame_append(frp2, wp->w_frame); | |
1550 } | |
1551 temp = curwin->w_status_height; | |
1552 curwin->w_status_height = wp->w_status_height; | |
1553 wp->w_status_height = temp; | |
1554 temp = curwin->w_vsep_width; | |
1555 curwin->w_vsep_width = wp->w_vsep_width; | |
1556 wp->w_vsep_width = temp; | |
1557 | |
1558 /* If the windows are not in the same frame, exchange the sizes to avoid | |
1559 * messing up the window layout. Otherwise fix the frame sizes. */ | |
1560 if (curwin->w_frame->fr_parent != wp->w_frame->fr_parent) | |
1561 { | |
1562 temp = curwin->w_height; | |
1563 curwin->w_height = wp->w_height; | |
1564 wp->w_height = temp; | |
1565 temp = curwin->w_width; | |
1566 curwin->w_width = wp->w_width; | |
1567 wp->w_width = temp; | |
1568 } | |
1569 else | |
1570 { | |
1571 frame_fix_height(curwin); | |
1572 frame_fix_height(wp); | |
1573 frame_fix_width(curwin); | |
1574 frame_fix_width(wp); | |
1575 } | |
1576 | |
1577 (void)win_comp_pos(); /* recompute window positions */ | |
1578 | |
1579 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
|
1580 redraw_all_later(NOT_VALID); |
7 | 1581 } |
1582 | |
1583 /* | |
1584 * rotate windows: if upwards TRUE the second window becomes the first one | |
1585 * if upwards FALSE the first window becomes the second one | |
1586 */ | |
1587 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1588 win_rotate(int upwards, int count) |
7 | 1589 { |
1590 win_T *wp1; | |
1591 win_T *wp2; | |
1592 frame_T *frp; | |
1593 int n; | |
1594 | |
10349
cf988222b150
commit https://github.com/vim/vim/commit/a1f4cb93ba50ea9e40cd4b1f5592b8a6d1398660
Christian Brabandt <cb@256bit.org>
parents:
10106
diff
changeset
|
1595 if (ONE_WINDOW) /* nothing to do */ |
7 | 1596 { |
1597 beep_flush(); | |
1598 return; | |
1599 } | |
1600 | |
1601 #ifdef FEAT_GUI | |
1602 need_mouse_correct = TRUE; | |
1603 #endif | |
1604 | |
1605 /* 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
|
1606 FOR_ALL_FRAMES(frp, curwin->w_frame->fr_parent->fr_child) |
7 | 1607 if (frp->fr_win == NULL) |
1608 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15436
diff
changeset
|
1609 emsg(_("E443: Cannot rotate when another window is split")); |
7 | 1610 return; |
1611 } | |
1612 | |
1613 while (count--) | |
1614 { | |
1615 if (upwards) /* first window becomes last window */ | |
1616 { | |
1617 /* remove first window/frame from the list */ | |
1618 frp = curwin->w_frame->fr_parent->fr_child; | |
1619 wp1 = frp->fr_win; | |
671 | 1620 win_remove(wp1, NULL); |
7 | 1621 frame_remove(frp); |
1622 | |
1623 /* find last frame and append removed window/frame after it */ | |
1624 for ( ; frp->fr_next != NULL; frp = frp->fr_next) | |
1625 ; | |
1626 win_append(frp->fr_win, wp1); | |
1627 frame_append(frp, wp1->w_frame); | |
1628 | |
1629 wp2 = frp->fr_win; /* previously last window */ | |
1630 } | |
1631 else /* last window becomes first window */ | |
1632 { | |
1633 /* find last window/frame in the list and remove it */ | |
1634 for (frp = curwin->w_frame; frp->fr_next != NULL; | |
1635 frp = frp->fr_next) | |
1636 ; | |
1637 wp1 = frp->fr_win; | |
1638 wp2 = wp1->w_prev; /* will become last window */ | |
671 | 1639 win_remove(wp1, NULL); |
7 | 1640 frame_remove(frp); |
1641 | |
1642 /* append the removed window/frame before the first in the list */ | |
1643 win_append(frp->fr_parent->fr_child->fr_win->w_prev, wp1); | |
1644 frame_insert(frp->fr_parent->fr_child, frp); | |
1645 } | |
1646 | |
1647 /* exchange status height and vsep width of old and new last window */ | |
1648 n = wp2->w_status_height; | |
1649 wp2->w_status_height = wp1->w_status_height; | |
1650 wp1->w_status_height = n; | |
1651 frame_fix_height(wp1); | |
1652 frame_fix_height(wp2); | |
1653 n = wp2->w_vsep_width; | |
1654 wp2->w_vsep_width = wp1->w_vsep_width; | |
1655 wp1->w_vsep_width = n; | |
1656 frame_fix_width(wp1); | |
1657 frame_fix_width(wp2); | |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8536
diff
changeset
|
1658 |
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8536
diff
changeset
|
1659 /* recompute w_winrow and w_wincol for all windows */ |
7 | 1660 (void)win_comp_pos(); |
1661 } | |
1662 | |
15380
f62d6bd18a49
patch 8.1.0698: clearing the window is used too often
Bram Moolenaar <Bram@vim.org>
parents:
15227
diff
changeset
|
1663 redraw_all_later(NOT_VALID); |
7 | 1664 } |
1665 | |
1666 /* | |
1667 * Move the current window to the very top/bottom/left/right of the screen. | |
1668 */ | |
1669 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1670 win_totop(int size, int flags) |
7 | 1671 { |
1672 int dir; | |
1673 int height = curwin->w_height; | |
1674 | |
10357
59d01e335858
commit https://github.com/vim/vim/commit/459ca563128f2edb7e3bb190090bbb755a56dd55
Christian Brabandt <cb@256bit.org>
parents:
10349
diff
changeset
|
1675 if (ONE_WINDOW) |
7 | 1676 { |
1677 beep_flush(); | |
1678 return; | |
1679 } | |
1680 | |
1681 /* Remove the window and frame from the tree of frames. */ | |
671 | 1682 (void)winframe_remove(curwin, &dir, NULL); |
1683 win_remove(curwin, NULL); | |
7 | 1684 last_status(FALSE); /* may need to remove last status line */ |
1685 (void)win_comp_pos(); /* recompute window positions */ | |
1686 | |
1687 /* Split a window on the desired side and put the window there. */ | |
1688 (void)win_split_ins(size, flags, curwin, dir); | |
1689 if (!(flags & WSP_VERT)) | |
1690 { | |
1691 win_setheight(height); | |
1692 if (p_ea) | |
1693 win_equal(curwin, TRUE, 'v'); | |
1694 } | |
1695 | |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8536
diff
changeset
|
1696 #if defined(FEAT_GUI) |
7 | 1697 /* When 'guioptions' includes 'L' or 'R' may have to remove or add |
1698 * scrollbars. Have to update them anyway. */ | |
1906 | 1699 gui_may_update_scrollbars(); |
1700 #endif | |
7 | 1701 } |
1702 | |
1703 /* | |
1704 * Move window "win1" to below/right of "win2" and make "win1" the current | |
1705 * window. Only works within the same frame! | |
1706 */ | |
1707 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1708 win_move_after(win_T *win1, win_T *win2) |
7 | 1709 { |
1710 int height; | |
1711 | |
1712 /* check if the arguments are reasonable */ | |
1713 if (win1 == win2) | |
1714 return; | |
1715 | |
1716 /* check if there is something to do */ | |
1717 if (win2->w_next != win1) | |
1718 { | |
1719 /* may need move the status line/vertical separator of the last window | |
1720 * */ | |
1721 if (win1 == lastwin) | |
1722 { | |
1723 height = win1->w_prev->w_status_height; | |
1724 win1->w_prev->w_status_height = win1->w_status_height; | |
1725 win1->w_status_height = height; | |
1070 | 1726 if (win1->w_prev->w_vsep_width == 1) |
1727 { | |
1728 /* Remove the vertical separator from the last-but-one window, | |
1729 * add it to the last window. Adjust the frame widths. */ | |
1730 win1->w_prev->w_vsep_width = 0; | |
1731 win1->w_prev->w_frame->fr_width -= 1; | |
1732 win1->w_vsep_width = 1; | |
1733 win1->w_frame->fr_width += 1; | |
1734 } | |
7 | 1735 } |
1736 else if (win2 == lastwin) | |
1737 { | |
1738 height = win1->w_status_height; | |
1739 win1->w_status_height = win2->w_status_height; | |
1740 win2->w_status_height = height; | |
1070 | 1741 if (win1->w_vsep_width == 1) |
1742 { | |
1743 /* Remove the vertical separator from win1, add it to the last | |
1744 * window, win2. Adjust the frame widths. */ | |
1745 win2->w_vsep_width = 1; | |
1746 win2->w_frame->fr_width += 1; | |
1747 win1->w_vsep_width = 0; | |
1748 win1->w_frame->fr_width -= 1; | |
1749 } | |
7 | 1750 } |
671 | 1751 win_remove(win1, NULL); |
7 | 1752 frame_remove(win1->w_frame); |
1753 win_append(win2, win1); | |
1754 frame_append(win2->w_frame, win1->w_frame); | |
1755 | |
1756 (void)win_comp_pos(); /* recompute w_winrow for all windows */ | |
1757 redraw_later(NOT_VALID); | |
1758 } | |
1759 win_enter(win1, FALSE); | |
1760 } | |
1761 | |
1762 /* | |
1763 * Make all windows the same height. | |
1764 * 'next_curwin' will soon be the current window, make sure it has enough | |
1765 * rows. | |
1766 */ | |
1767 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1768 win_equal( |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1769 win_T *next_curwin, /* pointer to current window to be or NULL */ |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1770 int current, /* do only frame with current window */ |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1771 int dir) /* 'v' for vertically, 'h' for horizontally, |
7 | 1772 'b' for both, 0 for using p_ead */ |
1773 { | |
1774 if (dir == 0) | |
1775 dir = *p_ead; | |
1776 win_equal_rec(next_curwin == NULL ? curwin : next_curwin, current, | |
685 | 1777 topframe, dir, 0, tabline_height(), |
667 | 1778 (int)Columns, topframe->fr_height); |
7 | 1779 } |
1780 | |
1781 /* | |
1782 * Set a frame to a new position and height, spreading the available room | |
1783 * equally over contained frames. | |
1784 * The window "next_curwin" (if not NULL) should at least get the size from | |
1785 * 'winheight' and 'winwidth' if possible. | |
1786 */ | |
1787 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1788 win_equal_rec( |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1789 win_T *next_curwin, /* pointer to current window to be or NULL */ |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1790 int current, /* do only frame with current window */ |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1791 frame_T *topfr, /* frame to set size off */ |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1792 int dir, /* 'v', 'h' or 'b', see win_equal() */ |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1793 int col, /* horizontal position for frame */ |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1794 int row, /* vertical position for frame */ |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1795 int width, /* new width of frame */ |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1796 int height) /* new height of frame */ |
7 | 1797 { |
1798 int n, m; | |
1799 int extra_sep = 0; | |
1800 int wincount, totwincount = 0; | |
1801 frame_T *fr; | |
1802 int next_curwin_size = 0; | |
1803 int room = 0; | |
1804 int new_size; | |
1805 int has_next_curwin = 0; | |
1806 int hnc; | |
1807 | |
1808 if (topfr->fr_layout == FR_LEAF) | |
1809 { | |
1810 /* Set the width/height of this frame. | |
1811 * Redraw when size or position changes */ | |
1812 if (topfr->fr_height != height || topfr->fr_win->w_winrow != row | |
1813 || topfr->fr_width != width || topfr->fr_win->w_wincol != col | |
1814 ) | |
1815 { | |
1816 topfr->fr_win->w_winrow = row; | |
1817 frame_new_height(topfr, height, FALSE, FALSE); | |
1818 topfr->fr_win->w_wincol = col; | |
779 | 1819 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
|
1820 redraw_all_later(NOT_VALID); |
7 | 1821 } |
1822 } | |
1823 else if (topfr->fr_layout == FR_ROW) | |
1824 { | |
1825 topfr->fr_width = width; | |
1826 topfr->fr_height = height; | |
1827 | |
1828 if (dir != 'v') /* equalize frame widths */ | |
1829 { | |
1830 /* Compute the maximum number of windows horizontally in this | |
1831 * frame. */ | |
1832 n = frame_minwidth(topfr, NOWIN); | |
1833 /* add one for the rightmost window, it doesn't have a separator */ | |
1834 if (col + width == Columns) | |
1835 extra_sep = 1; | |
1836 else | |
1837 extra_sep = 0; | |
1838 totwincount = (n + extra_sep) / (p_wmw + 1); | |
779 | 1839 has_next_curwin = frame_has_win(topfr, next_curwin); |
1840 | |
1841 /* | |
1842 * Compute width for "next_curwin" window and room available for | |
1843 * other windows. | |
1844 * "m" is the minimal width when counting p_wiw for "next_curwin". | |
1845 */ | |
7 | 1846 m = frame_minwidth(topfr, next_curwin); |
1847 room = width - m; | |
1848 if (room < 0) | |
1849 { | |
1850 next_curwin_size = p_wiw + room; | |
1851 room = 0; | |
1852 } | |
1853 else | |
1854 { | |
779 | 1855 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
|
1856 FOR_ALL_FRAMES(fr, topfr->fr_child) |
779 | 1857 { |
1858 /* If 'winfixwidth' set keep the window width if | |
1859 * possible. | |
1860 * Watch out for this window being the next_curwin. */ | |
1861 if (frame_fixed_width(fr)) | |
1862 { | |
1863 n = frame_minwidth(fr, NOWIN); | |
1864 new_size = fr->fr_width; | |
1865 if (frame_has_win(fr, next_curwin)) | |
1866 { | |
1867 room += p_wiw - p_wmw; | |
1868 next_curwin_size = 0; | |
1869 if (new_size < p_wiw) | |
1870 new_size = p_wiw; | |
1871 } | |
1872 else | |
1873 /* These windows don't use up room. */ | |
1874 totwincount -= (n + (fr->fr_next == NULL | |
1875 ? extra_sep : 0)) / (p_wmw + 1); | |
1876 room -= new_size - n; | |
1877 if (room < 0) | |
1878 { | |
1879 new_size += room; | |
1880 room = 0; | |
1881 } | |
1882 fr->fr_newwidth = new_size; | |
1883 } | |
1884 } | |
1885 if (next_curwin_size == -1) | |
1886 { | |
1887 if (!has_next_curwin) | |
1888 next_curwin_size = 0; | |
1889 else if (totwincount > 1 | |
1890 && (room + (totwincount - 2)) | |
1891 / (totwincount - 1) > p_wiw) | |
1892 { | |
834 | 1893 /* Can make all windows wider than 'winwidth', spread |
1894 * the room equally. */ | |
1895 next_curwin_size = (room + p_wiw | |
1896 + (totwincount - 1) * p_wmw | |
1897 + (totwincount - 1)) / totwincount; | |
779 | 1898 room -= next_curwin_size - p_wiw; |
1899 } | |
1900 else | |
1901 next_curwin_size = p_wiw; | |
1902 } | |
7 | 1903 } |
779 | 1904 |
1905 if (has_next_curwin) | |
7 | 1906 --totwincount; /* don't count curwin */ |
1907 } | |
1908 | |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
1909 FOR_ALL_FRAMES(fr, topfr->fr_child) |
7 | 1910 { |
1911 wincount = 1; | |
1912 if (fr->fr_next == NULL) | |
1913 /* last frame gets all that remains (avoid roundoff error) */ | |
1914 new_size = width; | |
1915 else if (dir == 'v') | |
1916 new_size = fr->fr_width; | |
779 | 1917 else if (frame_fixed_width(fr)) |
1918 { | |
1919 new_size = fr->fr_newwidth; | |
1920 wincount = 0; /* doesn't count as a sizeable window */ | |
1921 } | |
7 | 1922 else |
1923 { | |
1924 /* Compute the maximum number of windows horiz. in "fr". */ | |
1925 n = frame_minwidth(fr, NOWIN); | |
1926 wincount = (n + (fr->fr_next == NULL ? extra_sep : 0)) | |
1927 / (p_wmw + 1); | |
1928 m = frame_minwidth(fr, next_curwin); | |
779 | 1929 if (has_next_curwin) |
1930 hnc = frame_has_win(fr, next_curwin); | |
1931 else | |
1932 hnc = FALSE; | |
1933 if (hnc) /* don't count next_curwin */ | |
7 | 1934 --wincount; |
779 | 1935 if (totwincount == 0) |
1936 new_size = room; | |
1937 else | |
1938 new_size = (wincount * room + ((unsigned)totwincount >> 1)) | |
7 | 1939 / totwincount; |
779 | 1940 if (hnc) /* add next_curwin size */ |
7 | 1941 { |
1942 next_curwin_size -= p_wiw - (m - n); | |
1943 new_size += next_curwin_size; | |
779 | 1944 room -= new_size - next_curwin_size; |
7 | 1945 } |
779 | 1946 else |
1947 room -= new_size; | |
1948 new_size += n; | |
7 | 1949 } |
1950 | |
779 | 1951 /* Skip frame that is full width when splitting or closing a |
7 | 1952 * window, unless equalizing all frames. */ |
1953 if (!current || dir != 'v' || topfr->fr_parent != NULL | |
1954 || (new_size != fr->fr_width) | |
1955 || frame_has_win(fr, next_curwin)) | |
1956 win_equal_rec(next_curwin, current, fr, dir, col, row, | |
779 | 1957 new_size, height); |
1958 col += new_size; | |
1959 width -= new_size; | |
7 | 1960 totwincount -= wincount; |
1961 } | |
1962 } | |
1963 else /* topfr->fr_layout == FR_COL */ | |
1964 { | |
1965 topfr->fr_width = width; | |
1966 topfr->fr_height = height; | |
1967 | |
1968 if (dir != 'h') /* equalize frame heights */ | |
1969 { | |
1970 /* Compute maximum number of windows vertically in this frame. */ | |
1971 n = frame_minheight(topfr, NOWIN); | |
1972 /* add one for the bottom window if it doesn't have a statusline */ | |
1973 if (row + height == cmdline_row && p_ls == 0) | |
1974 extra_sep = 1; | |
1975 else | |
1976 extra_sep = 0; | |
1977 totwincount = (n + extra_sep) / (p_wmh + 1); | |
1978 has_next_curwin = frame_has_win(topfr, next_curwin); | |
1979 | |
1980 /* | |
1981 * Compute height for "next_curwin" window and room available for | |
1982 * other windows. | |
1983 * "m" is the minimal height when counting p_wh for "next_curwin". | |
1984 */ | |
1985 m = frame_minheight(topfr, next_curwin); | |
1986 room = height - m; | |
1987 if (room < 0) | |
1988 { | |
1989 /* The room is less then 'winheight', use all space for the | |
1990 * current window. */ | |
1991 next_curwin_size = p_wh + room; | |
1992 room = 0; | |
1993 } | |
1994 else | |
1995 { | |
1996 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
|
1997 FOR_ALL_FRAMES(fr, topfr->fr_child) |
7 | 1998 { |
1999 /* If 'winfixheight' set keep the window height if | |
2000 * possible. | |
2001 * Watch out for this window being the next_curwin. */ | |
2002 if (frame_fixed_height(fr)) | |
2003 { | |
2004 n = frame_minheight(fr, NOWIN); | |
2005 new_size = fr->fr_height; | |
2006 if (frame_has_win(fr, next_curwin)) | |
2007 { | |
2008 room += p_wh - p_wmh; | |
2009 next_curwin_size = 0; | |
2010 if (new_size < p_wh) | |
2011 new_size = p_wh; | |
2012 } | |
2013 else | |
2014 /* These windows don't use up room. */ | |
2015 totwincount -= (n + (fr->fr_next == NULL | |
2016 ? extra_sep : 0)) / (p_wmh + 1); | |
2017 room -= new_size - n; | |
2018 if (room < 0) | |
2019 { | |
2020 new_size += room; | |
2021 room = 0; | |
2022 } | |
2023 fr->fr_newheight = new_size; | |
2024 } | |
2025 } | |
2026 if (next_curwin_size == -1) | |
2027 { | |
2028 if (!has_next_curwin) | |
2029 next_curwin_size = 0; | |
2030 else if (totwincount > 1 | |
2031 && (room + (totwincount - 2)) | |
2032 / (totwincount - 1) > p_wh) | |
2033 { | |
834 | 2034 /* can make all windows higher than 'winheight', |
2035 * spread the room equally. */ | |
2036 next_curwin_size = (room + p_wh | |
2037 + (totwincount - 1) * p_wmh | |
7 | 2038 + (totwincount - 1)) / totwincount; |
2039 room -= next_curwin_size - p_wh; | |
2040 } | |
2041 else | |
2042 next_curwin_size = p_wh; | |
2043 } | |
2044 } | |
2045 | |
2046 if (has_next_curwin) | |
2047 --totwincount; /* don't count curwin */ | |
2048 } | |
2049 | |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
2050 FOR_ALL_FRAMES(fr, topfr->fr_child) |
7 | 2051 { |
2052 wincount = 1; | |
2053 if (fr->fr_next == NULL) | |
2054 /* last frame gets all that remains (avoid roundoff error) */ | |
2055 new_size = height; | |
2056 else if (dir == 'h') | |
2057 new_size = fr->fr_height; | |
2058 else if (frame_fixed_height(fr)) | |
2059 { | |
2060 new_size = fr->fr_newheight; | |
2061 wincount = 0; /* doesn't count as a sizeable window */ | |
2062 } | |
2063 else | |
2064 { | |
2065 /* Compute the maximum number of windows vert. in "fr". */ | |
2066 n = frame_minheight(fr, NOWIN); | |
2067 wincount = (n + (fr->fr_next == NULL ? extra_sep : 0)) | |
2068 / (p_wmh + 1); | |
2069 m = frame_minheight(fr, next_curwin); | |
2070 if (has_next_curwin) | |
2071 hnc = frame_has_win(fr, next_curwin); | |
2072 else | |
2073 hnc = FALSE; | |
2074 if (hnc) /* don't count next_curwin */ | |
2075 --wincount; | |
2076 if (totwincount == 0) | |
2077 new_size = room; | |
2078 else | |
2079 new_size = (wincount * room + ((unsigned)totwincount >> 1)) | |
2080 / totwincount; | |
2081 if (hnc) /* add next_curwin size */ | |
2082 { | |
2083 next_curwin_size -= p_wh - (m - n); | |
2084 new_size += next_curwin_size; | |
2085 room -= new_size - next_curwin_size; | |
2086 } | |
2087 else | |
2088 room -= new_size; | |
2089 new_size += n; | |
2090 } | |
2091 /* Skip frame that is full width when splitting or closing a | |
2092 * window, unless equalizing all frames. */ | |
2093 if (!current || dir != 'h' || topfr->fr_parent != NULL | |
2094 || (new_size != fr->fr_height) | |
2095 || frame_has_win(fr, next_curwin)) | |
2096 win_equal_rec(next_curwin, current, fr, dir, col, row, | |
2097 width, new_size); | |
2098 row += new_size; | |
2099 height -= new_size; | |
2100 totwincount -= wincount; | |
2101 } | |
2102 } | |
2103 } | |
2104 | |
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
|
2105 #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
|
2106 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
|
2107 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
|
2108 { |
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
|
2109 // 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
|
2110 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
|
2111 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
|
2112 |
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
|
2113 // 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
|
2114 // 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
|
2115 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
|
2116 if (restart_edit != 0 && mode_displayed) |
a9d94f10ecef
patch 8.1.0064: typing CTRL-W in a prompt buffer shows mode "-- --"
Christian Brabandt <cb@256bit.org>
parents:
14057
diff
changeset
|
2117 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
|
2118 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
|
2119 |
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
2120 // 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
|
2121 // 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
|
2122 // 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
|
2123 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
|
2124 { |
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
|
2125 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
|
2126 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
|
2127 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
|
2128 } |
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
|
2129 } |
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
2130 |
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
2131 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
|
2132 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
|
2133 { |
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
|
2134 // 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
|
2135 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
|
2136 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
|
2137 |
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
|
2138 // 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
|
2139 // 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
|
2140 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
|
2141 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
|
2142 |
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
|
2143 // 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
|
2144 // 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
|
2145 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
|
2146 } |
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
2147 #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
|
2148 |
7 | 2149 /* |
11199
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
2150 * Close all windows for buffer "buf". |
7 | 2151 */ |
2152 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2153 close_windows( |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2154 buf_T *buf, |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2155 int keep_curwin) /* don't close "curwin" */ |
7 | 2156 { |
671 | 2157 win_T *wp; |
2158 tabpage_T *tp, *nexttp; | |
685 | 2159 int h = tabline_height(); |
9599
42a8a81decdf
commit https://github.com/vim/vim/commit/12c11d553053f5a9eae9eb3c518279b12fa928c2
Christian Brabandt <cb@256bit.org>
parents:
9595
diff
changeset
|
2160 int count = tabpage_index(NULL); |
7 | 2161 |
2162 ++RedrawingDisabled; | |
671 | 2163 |
10357
59d01e335858
commit https://github.com/vim/vim/commit/459ca563128f2edb7e3bb190090bbb755a56dd55
Christian Brabandt <cb@256bit.org>
parents:
10349
diff
changeset
|
2164 for (wp = firstwin; wp != NULL && !ONE_WINDOW; ) |
7 | 2165 { |
3570 | 2166 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
|
2167 && !(wp->w_closing || wp->w_buffer->b_locked > 0)) |
7 | 2168 { |
11199
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
2169 if (win_close(wp, FALSE) == FAIL) |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
2170 /* If closing the window fails give up, to avoid looping |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
2171 * forever. */ |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
2172 break; |
671 | 2173 |
2174 /* Start all over, autocommands may change the window layout. */ | |
2175 wp = firstwin; | |
7 | 2176 } |
2177 else | |
671 | 2178 wp = wp->w_next; |
7 | 2179 } |
671 | 2180 |
2181 /* Also check windows in other tab pages. */ | |
2182 for (tp = first_tabpage; tp != NULL; tp = nexttp) | |
2183 { | |
2184 nexttp = tp->tp_next; | |
672 | 2185 if (tp != curtab) |
671 | 2186 for (wp = tp->tp_firstwin; wp != NULL; wp = wp->w_next) |
3570 | 2187 if (wp->w_buffer == buf |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13308
diff
changeset
|
2188 && !(wp->w_closing || wp->w_buffer->b_locked > 0)) |
671 | 2189 { |
2190 win_close_othertab(wp, FALSE, tp); | |
2191 | |
2192 /* Start all over, the tab page may be closed and | |
2193 * autocommands may change the window layout. */ | |
2194 nexttp = first_tabpage; | |
2195 break; | |
2196 } | |
2197 } | |
2198 | |
7 | 2199 --RedrawingDisabled; |
671 | 2200 |
9599
42a8a81decdf
commit https://github.com/vim/vim/commit/12c11d553053f5a9eae9eb3c518279b12fa928c2
Christian Brabandt <cb@256bit.org>
parents:
9595
diff
changeset
|
2201 if (count != tabpage_index(NULL)) |
42a8a81decdf
commit https://github.com/vim/vim/commit/12c11d553053f5a9eae9eb3c518279b12fa928c2
Christian Brabandt <cb@256bit.org>
parents:
9595
diff
changeset
|
2202 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
|
2203 |
4305 | 2204 redraw_tabline = TRUE; |
685 | 2205 if (h != tabline_height()) |
671 | 2206 shell_new_rows(); |
7 | 2207 } |
2208 | |
2209 /* | |
1906 | 2210 * Return TRUE if the current window is the only window that exists (ignoring |
2211 * "aucmd_win"). | |
672 | 2212 * Returns FALSE if there is a window, possibly in another tab page. |
667 | 2213 */ |
672 | 2214 static int |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2215 last_window(void) |
667 | 2216 { |
1906 | 2217 return (one_window() && first_tabpage->tp_next == NULL); |
2218 } | |
2219 | |
2220 /* | |
2221 * Return TRUE if there is only one window other than "aucmd_win" in the | |
2222 * current tab page. | |
2223 */ | |
3365 | 2224 int |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2225 one_window(void) |
1906 | 2226 { |
2227 win_T *wp; | |
2228 int seen_one = FALSE; | |
2229 | |
2230 FOR_ALL_WINDOWS(wp) | |
2231 { | |
2232 if (wp != aucmd_win) | |
2233 { | |
2234 if (seen_one) | |
2235 return FALSE; | |
2236 seen_one = TRUE; | |
2237 } | |
2238 } | |
2239 return TRUE; | |
667 | 2240 } |
2241 | |
2242 /* | |
3535 | 2243 * Close the possibly last window in a tab page. |
2244 * Returns TRUE when the window was closed already. | |
2245 */ | |
2246 static int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2247 close_last_window_tabpage( |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2248 win_T *win, |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2249 int free_buf, |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2250 tabpage_T *prev_curtab) |
3535 | 2251 { |
10349
cf988222b150
commit https://github.com/vim/vim/commit/a1f4cb93ba50ea9e40cd4b1f5592b8a6d1398660
Christian Brabandt <cb@256bit.org>
parents:
10106
diff
changeset
|
2252 if (ONE_WINDOW) |
3535 | 2253 { |
4354 | 2254 buf_T *old_curbuf = curbuf; |
2255 | |
3535 | 2256 /* |
2257 * Closing the last window in a tab page. First go to another tab | |
2258 * page and then close the window and the tab page. This avoids that | |
2259 * curwin and curtab are invalid while we are freeing memory, they may | |
2260 * be used in GUI events. | |
3582 | 2261 * Don't trigger autocommands yet, they may use wrong values, so do |
2262 * that below. | |
3535 | 2263 */ |
4354 | 2264 goto_tabpage_tp(alt_tabpage(), FALSE, TRUE); |
3535 | 2265 redraw_tabline = TRUE; |
2266 | |
2267 /* Safety check: Autocommands may have closed the window when jumping | |
2268 * to the other tab page. */ | |
2269 if (valid_tabpage(prev_curtab) && prev_curtab->tp_firstwin == win) | |
2270 { | |
2271 int h = tabline_height(); | |
2272 | |
2273 win_close_othertab(win, free_buf, prev_curtab); | |
2274 if (h != tabline_height()) | |
2275 shell_new_rows(); | |
2276 } | |
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
|
2277 #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
|
2278 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
|
2279 #endif |
3582 | 2280 /* Since goto_tabpage_tp above did not trigger *Enter autocommands, do |
2281 * that now. */ | |
9599
42a8a81decdf
commit https://github.com/vim/vim/commit/12c11d553053f5a9eae9eb3c518279b12fa928c2
Christian Brabandt <cb@256bit.org>
parents:
9595
diff
changeset
|
2282 apply_autocmds(EVENT_TABCLOSED, NULL, NULL, FALSE, curbuf); |
4354 | 2283 apply_autocmds(EVENT_WINENTER, NULL, NULL, FALSE, curbuf); |
3582 | 2284 apply_autocmds(EVENT_TABENTER, NULL, NULL, FALSE, curbuf); |
4354 | 2285 if (old_curbuf != curbuf) |
2286 apply_autocmds(EVENT_BUFENTER, NULL, NULL, FALSE, curbuf); | |
3535 | 2287 return TRUE; |
2288 } | |
2289 return FALSE; | |
2290 } | |
2291 | |
2292 /* | |
819 | 2293 * Close window "win". Only works for the current tab page. |
7 | 2294 * If "free_buf" is TRUE related buffer may be unloaded. |
2295 * | |
3365 | 2296 * Called by :quit, :close, :xit, :wq and findtag(). |
5302 | 2297 * Returns FAIL when the window was not closed. |
7 | 2298 */ |
5302 | 2299 int |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2300 win_close(win_T *win, int free_buf) |
7 | 2301 { |
2302 win_T *wp; | |
2303 int other_buffer = FALSE; | |
2304 int close_curwin = FALSE; | |
2305 int dir; | |
2306 int help_window = FALSE; | |
847 | 2307 tabpage_T *prev_curtab = curtab; |
11593
c4e7fe672a72
patch 8.0.0679: using freed memory
Christian Brabandt <cb@256bit.org>
parents:
11591
diff
changeset
|
2308 frame_T *win_frame = win->w_frame->fr_parent; |
7 | 2309 |
667 | 2310 if (last_window()) |
7 | 2311 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15436
diff
changeset
|
2312 emsg(_("E444: Cannot close last window")); |
5302 | 2313 return FAIL; |
7 | 2314 } |
2315 | |
10106
58e6dd1d8be3
commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents:
10082
diff
changeset
|
2316 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
|
2317 && win->w_buffer->b_locked > 0)) |
5302 | 2318 return FAIL; /* window is already being closed */ |
1906 | 2319 if (win == aucmd_win) |
2320 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15436
diff
changeset
|
2321 emsg(_("E813: Cannot close autocmd window")); |
5302 | 2322 return FAIL; |
1906 | 2323 } |
2324 if ((firstwin == aucmd_win || lastwin == aucmd_win) && one_window()) | |
2325 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15436
diff
changeset
|
2326 emsg(_("E814: Cannot close window, only autocmd window would remain")); |
5302 | 2327 return FAIL; |
1906 | 2328 } |
2329 | |
3535 | 2330 /* When closing the last window in a tab page first go to another tab page |
2331 * and then close the window and the tab page to avoid that curwin and | |
2332 * curtab are invalid while we are freeing memory. */ | |
2333 if (close_last_window_tabpage(win, free_buf, prev_curtab)) | |
5302 | 2334 return FAIL; |
856 | 2335 |
7 | 2336 /* When closing the help window, try restoring a snapshot after closing |
2337 * 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
|
2338 if (bt_help(win->w_buffer)) |
7 | 2339 help_window = TRUE; |
2340 else | |
1906 | 2341 clear_snapshot(curtab, SNAP_HELP_IDX); |
7 | 2342 |
2343 if (win == curwin) | |
2344 { | |
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
|
2345 #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
|
2346 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
|
2347 #endif |
7 | 2348 /* |
2349 * Guess which window is going to be the new current window. | |
2350 * This may change because of the autocommands (sigh). | |
2351 */ | |
671 | 2352 wp = frame2win(win_altframe(win, NULL)); |
7 | 2353 |
2354 /* | |
3570 | 2355 * Be careful: If autocommands delete the window or cause this window |
2356 * to be the last one left, return now. | |
7 | 2357 */ |
2358 if (wp->w_buffer != curbuf) | |
2359 { | |
2360 other_buffer = TRUE; | |
3570 | 2361 win->w_closing = TRUE; |
7 | 2362 apply_autocmds(EVENT_BUFLEAVE, NULL, NULL, FALSE, curbuf); |
3570 | 2363 if (!win_valid(win)) |
5302 | 2364 return FAIL; |
3570 | 2365 win->w_closing = FALSE; |
2366 if (last_window()) | |
5302 | 2367 return FAIL; |
7 | 2368 } |
3570 | 2369 win->w_closing = TRUE; |
7 | 2370 apply_autocmds(EVENT_WINLEAVE, NULL, NULL, FALSE, curbuf); |
3570 | 2371 if (!win_valid(win)) |
5302 | 2372 return FAIL; |
3570 | 2373 win->w_closing = FALSE; |
2374 if (last_window()) | |
5302 | 2375 return FAIL; |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13308
diff
changeset
|
2376 #ifdef FEAT_EVAL |
7 | 2377 /* autocmds may abort script processing */ |
2378 if (aborting()) | |
5302 | 2379 return FAIL; |
7 | 2380 #endif |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13308
diff
changeset
|
2381 } |
7 | 2382 |
1101 | 2383 #ifdef FEAT_GUI |
2384 /* Avoid trouble with scrollbars that are going to be deleted in | |
2385 * win_free(). */ | |
2386 if (gui.in_use) | |
2387 out_flush(); | |
2388 #endif | |
2389 | |
3068 | 2390 #ifdef FEAT_SYN_HL |
2391 /* Free independent synblock before the buffer is freed. */ | |
3242 | 2392 if (win->w_buffer != NULL) |
2393 reset_synblock(win); | |
3068 | 2394 #endif |
2395 | |
7 | 2396 /* |
2397 * Close the link to the buffer. | |
2398 */ | |
3242 | 2399 if (win->w_buffer != NULL) |
3570 | 2400 { |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9349
diff
changeset
|
2401 bufref_T bufref; |
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9349
diff
changeset
|
2402 |
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9349
diff
changeset
|
2403 set_bufref(&bufref, curbuf); |
3570 | 2404 win->w_closing = TRUE; |
3768 | 2405 close_buffer(win, win->w_buffer, free_buf ? DOBUF_UNLOAD : 0, TRUE); |
10076
bc30991c3e98
commit https://github.com/vim/vim/commit/11fbc2866ccc11b4dd1726abdaf582a78ef3f743
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2406 if (win_valid_any_tab(win)) |
3570 | 2407 win->w_closing = FALSE; |
7677
85a7a945fb87
commit https://github.com/vim/vim/commit/62ef797496c6243d111c596a592a8ef8c1d1e710
Christian Brabandt <cb@256bit.org>
parents:
7408
diff
changeset
|
2408 /* Make sure curbuf is valid. It can become invalid if 'bufhidden' is |
85a7a945fb87
commit https://github.com/vim/vim/commit/62ef797496c6243d111c596a592a8ef8c1d1e710
Christian Brabandt <cb@256bit.org>
parents:
7408
diff
changeset
|
2409 * "wipe". */ |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9349
diff
changeset
|
2410 if (!bufref_valid(&bufref)) |
7677
85a7a945fb87
commit https://github.com/vim/vim/commit/62ef797496c6243d111c596a592a8ef8c1d1e710
Christian Brabandt <cb@256bit.org>
parents:
7408
diff
changeset
|
2411 curbuf = firstbuf; |
3570 | 2412 } |
847 | 2413 |
4021 | 2414 if (only_one_window() && win_valid(win) && win->w_buffer == NULL |
2415 && (last_window() || curtab != prev_curtab | |
2416 || 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
|
2417 { |
11800
5ceaecedbad2
patch 8.0.0782: using freed memory in quickfix code
Christian Brabandt <cb@256bit.org>
parents:
11593
diff
changeset
|
2418 /* Autocommands have closed all windows, quit now. Restore |
5233
1899acc5aebd
updated for version 7.4a.042
Bram Moolenaar <bram@vim.org>
parents:
5202
diff
changeset
|
2419 * curwin->w_buffer, otherwise writing viminfo may fail. */ |
1899acc5aebd
updated for version 7.4a.042
Bram Moolenaar <bram@vim.org>
parents:
5202
diff
changeset
|
2420 if (curwin->w_buffer == NULL) |
1899acc5aebd
updated for version 7.4a.042
Bram Moolenaar <bram@vim.org>
parents:
5202
diff
changeset
|
2421 curwin->w_buffer = curbuf; |
4021 | 2422 getout(0); |
5233
1899acc5aebd
updated for version 7.4a.042
Bram Moolenaar <bram@vim.org>
parents:
5202
diff
changeset
|
2423 } |
4021 | 2424 |
10076
bc30991c3e98
commit https://github.com/vim/vim/commit/11fbc2866ccc11b4dd1726abdaf582a78ef3f743
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2425 /* Autocommands may have moved to another tab page. */ |
bc30991c3e98
commit https://github.com/vim/vim/commit/11fbc2866ccc11b4dd1726abdaf582a78ef3f743
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2426 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
|
2427 && win->w_buffer == NULL) |
bc30991c3e98
commit https://github.com/vim/vim/commit/11fbc2866ccc11b4dd1726abdaf582a78ef3f743
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2428 { |
bc30991c3e98
commit https://github.com/vim/vim/commit/11fbc2866ccc11b4dd1726abdaf582a78ef3f743
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2429 /* Need to close the window anyway, since the buffer is NULL. */ |
bc30991c3e98
commit https://github.com/vim/vim/commit/11fbc2866ccc11b4dd1726abdaf582a78ef3f743
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2430 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
|
2431 return FAIL; |
bc30991c3e98
commit https://github.com/vim/vim/commit/11fbc2866ccc11b4dd1726abdaf582a78ef3f743
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2432 } |
bc30991c3e98
commit https://github.com/vim/vim/commit/11fbc2866ccc11b4dd1726abdaf582a78ef3f743
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2433 |
bc30991c3e98
commit https://github.com/vim/vim/commit/11fbc2866ccc11b4dd1726abdaf582a78ef3f743
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2434 /* Autocommands may have closed the window already or closed the only |
bc30991c3e98
commit https://github.com/vim/vim/commit/11fbc2866ccc11b4dd1726abdaf582a78ef3f743
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2435 * other window. */ |
bc30991c3e98
commit https://github.com/vim/vim/commit/11fbc2866ccc11b4dd1726abdaf582a78ef3f743
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2436 if (!win_valid(win) || last_window() |
3535 | 2437 || close_last_window_tabpage(win, free_buf, prev_curtab)) |
5302 | 2438 return FAIL; |
7 | 2439 |
3068 | 2440 /* Free the memory used for the window and get the window that received |
2441 * the screen space. */ | |
847 | 2442 wp = win_free_mem(win, &dir, NULL); |
2443 | |
7 | 2444 /* Make sure curwin isn't invalid. It can cause severe trouble when |
2445 * printing an error message. For win_equal() curbuf needs to be valid | |
2446 * too. */ | |
847 | 2447 if (win == curwin) |
7 | 2448 { |
2449 curwin = wp; | |
2450 #ifdef FEAT_QUICKFIX | |
2451 if (wp->w_p_pvw || bt_quickfix(wp->w_buffer)) | |
2452 { | |
2453 /* | |
1346 | 2454 * If the cursor goes to the preview or the quickfix window, try |
7 | 2455 * finding another window to go to. |
2456 */ | |
2457 for (;;) | |
2458 { | |
2459 if (wp->w_next == NULL) | |
2460 wp = firstwin; | |
2461 else | |
2462 wp = wp->w_next; | |
2463 if (wp == curwin) | |
2464 break; | |
2465 if (!wp->w_p_pvw && !bt_quickfix(wp->w_buffer)) | |
2466 { | |
2467 curwin = wp; | |
2468 break; | |
2469 } | |
2470 } | |
2471 } | |
2472 #endif | |
2473 curbuf = curwin->w_buffer; | |
2474 close_curwin = TRUE; | |
11193
75ccc8a15a51
patch 8.0.0483: illegal memory access when using :all
Christian Brabandt <cb@256bit.org>
parents:
11191
diff
changeset
|
2475 |
75ccc8a15a51
patch 8.0.0483: illegal memory access when using :all
Christian Brabandt <cb@256bit.org>
parents:
11191
diff
changeset
|
2476 /* The cursor position may be invalid if the buffer changed after last |
75ccc8a15a51
patch 8.0.0483: illegal memory access when using :all
Christian Brabandt <cb@256bit.org>
parents:
11191
diff
changeset
|
2477 * using the window. */ |
75ccc8a15a51
patch 8.0.0483: illegal memory access when using :all
Christian Brabandt <cb@256bit.org>
parents:
11191
diff
changeset
|
2478 check_cursor(); |
7 | 2479 } |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8536
diff
changeset
|
2480 if (p_ea && (*p_ead == 'b' || *p_ead == dir)) |
11591
d06a3db9b651
patch 8.0.0678: closing a window does not trigger resizing
Christian Brabandt <cb@256bit.org>
parents:
11232
diff
changeset
|
2481 /* If the frame of the closed window contains the new current window, |
d06a3db9b651
patch 8.0.0678: closing a window does not trigger resizing
Christian Brabandt <cb@256bit.org>
parents:
11232
diff
changeset
|
2482 * 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
|
2483 win_equal(curwin, curwin->w_frame->fr_parent == win_frame, dir); |
7 | 2484 else |
2485 win_comp_pos(); | |
2486 if (close_curwin) | |
2487 { | |
9595
0190d5de215f
commit https://github.com/vim/vim/commit/c917da4b3e8801a255dbefea8e4ed19c1c716dd8
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
2488 win_enter_ext(wp, FALSE, TRUE, FALSE, TRUE, TRUE); |
7 | 2489 if (other_buffer) |
2490 /* careful: after this wp and win may be invalid! */ | |
2491 apply_autocmds(EVENT_BUFENTER, NULL, NULL, FALSE, curbuf); | |
2492 } | |
2493 | |
2494 /* | |
667 | 2495 * If last window has a status line now and we don't want one, |
2496 * remove the status line. | |
7 | 2497 */ |
2498 last_status(FALSE); | |
2499 | |
2500 /* After closing the help window, try restoring the window layout from | |
2501 * before it was opened. */ | |
2502 if (help_window) | |
1906 | 2503 restore_snapshot(SNAP_HELP_IDX, close_curwin); |
7 | 2504 |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8536
diff
changeset
|
2505 #if defined(FEAT_GUI) |
7 | 2506 /* When 'guioptions' includes 'L' or 'R' may have to remove scrollbars. */ |
2507 if (gui.in_use && !win_hasvertsplit()) | |
2508 gui_init_which_components(NULL); | |
2509 #endif | |
2510 | |
2511 redraw_all_later(NOT_VALID); | |
5302 | 2512 return OK; |
7 | 2513 } |
2514 | |
2515 /* | |
671 | 2516 * Close window "win" in tab page "tp", which is not the current tab page. |
3535 | 2517 * This may be the last window in that tab page and result in closing the tab, |
671 | 2518 * thus "tp" may become invalid! |
856 | 2519 * Caller must check if buffer is hidden and whether the tabline needs to be |
2520 * updated. | |
671 | 2521 */ |
2522 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2523 win_close_othertab(win_T *win, int free_buf, tabpage_T *tp) |
671 | 2524 { |
2525 win_T *wp; | |
2526 int dir; | |
2527 tabpage_T *ptp = NULL; | |
2191 | 2528 int free_tp = FALSE; |
671 | 2529 |
10076
bc30991c3e98
commit https://github.com/vim/vim/commit/11fbc2866ccc11b4dd1726abdaf582a78ef3f743
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2530 /* Get here with win->w_buffer == NULL when win_close() detects the tab |
bc30991c3e98
commit https://github.com/vim/vim/commit/11fbc2866ccc11b4dd1726abdaf582a78ef3f743
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2531 * page changed. */ |
10106
58e6dd1d8be3
commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents:
10082
diff
changeset
|
2532 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
|
2533 && win->w_buffer->b_locked > 0)) |
3570 | 2534 return; /* window is already being closed */ |
2535 | |
10076
bc30991c3e98
commit https://github.com/vim/vim/commit/11fbc2866ccc11b4dd1726abdaf582a78ef3f743
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2536 if (win->w_buffer != NULL) |
bc30991c3e98
commit https://github.com/vim/vim/commit/11fbc2866ccc11b4dd1726abdaf582a78ef3f743
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2537 /* Close the link to the buffer. */ |
bc30991c3e98
commit https://github.com/vim/vim/commit/11fbc2866ccc11b4dd1726abdaf582a78ef3f743
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2538 close_buffer(win, win->w_buffer, free_buf ? DOBUF_UNLOAD : 0, FALSE); |
671 | 2539 |
2540 /* Careful: Autocommands may have closed the tab page or made it the | |
2541 * current tab page. */ | |
2542 for (ptp = first_tabpage; ptp != NULL && ptp != tp; ptp = ptp->tp_next) | |
2543 ; | |
672 | 2544 if (ptp == NULL || tp == curtab) |
671 | 2545 return; |
2546 | |
2547 /* Autocommands may have closed the window already. */ | |
2548 for (wp = tp->tp_firstwin; wp != NULL && wp != win; wp = wp->w_next) | |
2549 ; | |
2550 if (wp == NULL) | |
2551 return; | |
2552 | |
2553 /* When closing the last window in a tab page remove the tab page. */ | |
7009 | 2554 if (tp->tp_firstwin == tp->tp_lastwin) |
671 | 2555 { |
2556 if (tp == first_tabpage) | |
2557 first_tabpage = tp->tp_next; | |
2558 else | |
2559 { | |
2560 for (ptp = first_tabpage; ptp != NULL && ptp->tp_next != tp; | |
2561 ptp = ptp->tp_next) | |
2562 ; | |
2563 if (ptp == NULL) | |
2564 { | |
10359
66f1b5bf3fa6
commit https://github.com/vim/vim/commit/95f096030ed1a8afea028f2ea295d6f6a70f466f
Christian Brabandt <cb@256bit.org>
parents:
10357
diff
changeset
|
2565 internal_error("win_close_othertab()"); |
671 | 2566 return; |
2567 } | |
2568 ptp->tp_next = tp->tp_next; | |
2569 } | |
2191 | 2570 free_tp = TRUE; |
2571 } | |
2572 | |
2573 /* Free the memory used for the window. */ | |
2574 win_free_mem(win, &dir, tp); | |
2575 | |
2576 if (free_tp) | |
847 | 2577 free_tabpage(tp); |
671 | 2578 } |
2579 | |
2580 /* | |
355 | 2581 * Free the memory used for a window. |
2582 * Returns a pointer to the window that got the freed up space. | |
2583 */ | |
2584 static win_T * | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2585 win_free_mem( |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2586 win_T *win, |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2587 int *dirp, /* set to 'v' or 'h' for direction if 'ea' */ |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2588 tabpage_T *tp) /* tab page "win" is in, NULL for current */ |
355 | 2589 { |
2590 frame_T *frp; | |
2591 win_T *wp; | |
2592 | |
667 | 2593 /* Remove the window and its frame from the tree of frames. */ |
355 | 2594 frp = win->w_frame; |
671 | 2595 wp = winframe_remove(win, dirp, tp); |
355 | 2596 vim_free(frp); |
671 | 2597 win_free(win, tp); |
355 | 2598 |
819 | 2599 /* When deleting the current window of another tab page select a new |
2600 * current window. */ | |
2601 if (tp != NULL && win == tp->tp_curwin) | |
2602 tp->tp_curwin = wp; | |
2603 | |
355 | 2604 return wp; |
2605 } | |
2606 | |
2607 #if defined(EXITFREE) || defined(PROTO) | |
2608 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2609 win_free_all(void) |
355 | 2610 { |
2611 int dummy; | |
2612 | |
671 | 2613 while (first_tabpage->tp_next != NULL) |
2614 tabpage_close(TRUE); | |
2615 | |
1906 | 2616 if (aucmd_win != NULL) |
2617 { | |
2618 (void)win_free_mem(aucmd_win, &dummy, NULL); | |
2619 aucmd_win = NULL; | |
2620 } | |
1918 | 2621 |
2622 while (firstwin != NULL) | |
2623 (void)win_free_mem(firstwin, &dummy, NULL); | |
6060 | 2624 |
2625 /* No window should be used after this. Set curwin to NULL to crash | |
2626 * instead of using freed memory. */ | |
2627 curwin = NULL; | |
355 | 2628 } |
2629 #endif | |
2630 | |
2631 /* | |
7 | 2632 * Remove a window and its frame from the tree of frames. |
2633 * Returns a pointer to the window that got the freed up space. | |
2634 */ | |
1906 | 2635 win_T * |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2636 winframe_remove( |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2637 win_T *win, |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2638 int *dirp UNUSED, /* set to 'v' or 'h' for direction if 'ea' */ |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2639 tabpage_T *tp) /* tab page "win" is in, NULL for current */ |
7 | 2640 { |
2641 frame_T *frp, *frp2, *frp3; | |
2642 frame_T *frp_close = win->w_frame; | |
2643 win_T *wp; | |
2644 | |
2645 /* | |
671 | 2646 * If there is only one window there is nothing to remove. |
2647 */ | |
10349
cf988222b150
commit https://github.com/vim/vim/commit/a1f4cb93ba50ea9e40cd4b1f5592b8a6d1398660
Christian Brabandt <cb@256bit.org>
parents:
10106
diff
changeset
|
2648 if (tp == NULL ? ONE_WINDOW : tp->tp_firstwin == tp->tp_lastwin) |
671 | 2649 return NULL; |
2650 | |
2651 /* | |
7 | 2652 * Remove the window from its frame. |
2653 */ | |
671 | 2654 frp2 = win_altframe(win, tp); |
7 | 2655 wp = frame2win(frp2); |
2656 | |
2657 /* Remove this frame from the list of frames. */ | |
2658 frame_remove(frp_close); | |
2659 | |
2660 if (frp_close->fr_parent->fr_layout == FR_COL) | |
2661 { | |
1346 | 2662 /* When 'winfixheight' is set, try to find another frame in the column |
2663 * (as close to the closed frame as possible) to distribute the height | |
2664 * to. */ | |
2665 if (frp2->fr_win != NULL && frp2->fr_win->w_p_wfh) | |
2666 { | |
2667 frp = frp_close->fr_prev; | |
2668 frp3 = frp_close->fr_next; | |
2669 while (frp != NULL || frp3 != NULL) | |
2670 { | |
2671 if (frp != NULL) | |
2672 { | |
2673 if (frp->fr_win != NULL && !frp->fr_win->w_p_wfh) | |
2674 { | |
2675 frp2 = frp; | |
2676 wp = frp->fr_win; | |
2677 break; | |
2678 } | |
2679 frp = frp->fr_prev; | |
2680 } | |
2681 if (frp3 != NULL) | |
2682 { | |
2683 if (frp3->fr_win != NULL && !frp3->fr_win->w_p_wfh) | |
2684 { | |
2685 frp2 = frp3; | |
2686 wp = frp3->fr_win; | |
2687 break; | |
2688 } | |
2689 frp3 = frp3->fr_next; | |
2690 } | |
2691 } | |
2692 } | |
7 | 2693 frame_new_height(frp2, frp2->fr_height + frp_close->fr_height, |
2694 frp2 == frp_close->fr_next ? TRUE : FALSE, FALSE); | |
2695 *dirp = 'v'; | |
2696 } | |
2697 else | |
2698 { | |
1346 | 2699 /* When 'winfixwidth' is set, try to find another frame in the column |
2700 * (as close to the closed frame as possible) to distribute the width | |
2701 * to. */ | |
2702 if (frp2->fr_win != NULL && frp2->fr_win->w_p_wfw) | |
2703 { | |
2704 frp = frp_close->fr_prev; | |
2705 frp3 = frp_close->fr_next; | |
2706 while (frp != NULL || frp3 != NULL) | |
2707 { | |
2708 if (frp != NULL) | |
2709 { | |
2710 if (frp->fr_win != NULL && !frp->fr_win->w_p_wfw) | |
2711 { | |
2712 frp2 = frp; | |
2713 wp = frp->fr_win; | |
2714 break; | |
2715 } | |
2716 frp = frp->fr_prev; | |
2717 } | |
2718 if (frp3 != NULL) | |
2719 { | |
2720 if (frp3->fr_win != NULL && !frp3->fr_win->w_p_wfw) | |
2721 { | |
2722 frp2 = frp3; | |
2723 wp = frp3->fr_win; | |
2724 break; | |
2725 } | |
2726 frp3 = frp3->fr_next; | |
2727 } | |
2728 } | |
2729 } | |
7 | 2730 frame_new_width(frp2, frp2->fr_width + frp_close->fr_width, |
779 | 2731 frp2 == frp_close->fr_next ? TRUE : FALSE, FALSE); |
7 | 2732 *dirp = 'h'; |
2733 } | |
2734 | |
2735 /* If rows/columns go to a window below/right its positions need to be | |
2736 * updated. Can only be done after the sizes have been updated. */ | |
2737 if (frp2 == frp_close->fr_next) | |
2738 { | |
2739 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
|
2740 int col = win->w_wincol; |
7 | 2741 |
2742 frame_comp_pos(frp2, &row, &col); | |
2743 } | |
2744 | |
2745 if (frp2->fr_next == NULL && frp2->fr_prev == NULL) | |
2746 { | |
2747 /* There is no other frame in this list, move its info to the parent | |
2748 * and remove it. */ | |
2749 frp2->fr_parent->fr_layout = frp2->fr_layout; | |
2750 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
|
2751 FOR_ALL_FRAMES(frp, frp2->fr_child) |
7 | 2752 frp->fr_parent = frp2->fr_parent; |
2753 frp2->fr_parent->fr_win = frp2->fr_win; | |
2754 if (frp2->fr_win != NULL) | |
2755 frp2->fr_win->w_frame = frp2->fr_parent; | |
2756 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
|
2757 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
|
2758 topframe->fr_child = frp; |
7 | 2759 vim_free(frp2); |
2760 | |
2761 frp2 = frp->fr_parent; | |
2762 if (frp2 != NULL && frp2->fr_layout == frp->fr_layout) | |
2763 { | |
2764 /* The frame above the parent has the same layout, have to merge | |
2765 * the frames into this list. */ | |
2766 if (frp2->fr_child == frp) | |
2767 frp2->fr_child = frp->fr_child; | |
2768 frp->fr_child->fr_prev = frp->fr_prev; | |
2769 if (frp->fr_prev != NULL) | |
2770 frp->fr_prev->fr_next = frp->fr_child; | |
2771 for (frp3 = frp->fr_child; ; frp3 = frp3->fr_next) | |
2772 { | |
2773 frp3->fr_parent = frp2; | |
2774 if (frp3->fr_next == NULL) | |
2775 { | |
2776 frp3->fr_next = frp->fr_next; | |
2777 if (frp->fr_next != NULL) | |
2778 frp->fr_next->fr_prev = frp3; | |
2779 break; | |
2780 } | |
2781 } | |
13144
20fb8c711050
patch 8.0.1446: acessing freed memory after window command in auto command
Christian Brabandt <cb@256bit.org>
parents:
13103
diff
changeset
|
2782 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
|
2783 topframe->fr_child = frp2; |
7 | 2784 vim_free(frp); |
2785 } | |
2786 } | |
2787 | |
2788 return wp; | |
2789 } | |
2790 | |
2791 /* | |
13837
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
2792 * 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
|
2793 * 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
|
2794 * |
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
2795 * 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
|
2796 * 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
|
2797 * 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
|
2798 * 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
|
2799 * respected when possible. |
7 | 2800 */ |
2801 static frame_T * | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2802 win_altframe( |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2803 win_T *win, |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2804 tabpage_T *tp) /* tab page "win" is in, NULL for current */ |
7 | 2805 { |
2806 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
|
2807 frame_T *other_fr, *target_fr; |
7 | 2808 |
10349
cf988222b150
commit https://github.com/vim/vim/commit/a1f4cb93ba50ea9e40cd4b1f5592b8a6d1398660
Christian Brabandt <cb@256bit.org>
parents:
10106
diff
changeset
|
2809 if (tp == NULL ? ONE_WINDOW : tp->tp_firstwin == tp->tp_lastwin) |
667 | 2810 return alt_tabpage()->tp_curwin->w_frame; |
2811 | |
7 | 2812 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
|
2813 |
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
2814 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
|
2815 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
|
2816 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
|
2817 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
|
2818 |
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
2819 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
|
2820 other_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
|
2821 if (p_spr || p_sb) |
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
2822 { |
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
2823 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
|
2824 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
|
2825 } |
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
2826 |
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
2827 /* If 'wfh' or 'wfw' is set for the target and not for the alternate |
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
2828 * window, reverse the selection. */ |
355 | 2829 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
|
2830 { |
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
2831 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
|
2832 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
|
2833 } |
7 | 2834 else |
13837
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
2835 { |
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
2836 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
|
2837 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
|
2838 } |
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
2839 |
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
2840 return target_fr; |
7 | 2841 } |
2842 | |
2843 /* | |
667 | 2844 * Return the tabpage that will be used if the current one is closed. |
2845 */ | |
2846 static tabpage_T * | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2847 alt_tabpage(void) |
667 | 2848 { |
672 | 2849 tabpage_T *tp; |
2850 | |
682 | 2851 /* Use the next tab page if possible. */ |
2852 if (curtab->tp_next != NULL) | |
672 | 2853 return curtab->tp_next; |
2854 | |
682 | 2855 /* Find the last but one tab page. */ |
2856 for (tp = first_tabpage; tp->tp_next != curtab; tp = tp->tp_next) | |
2857 ; | |
674 | 2858 return tp; |
667 | 2859 } |
2860 | |
2861 /* | |
7 | 2862 * Find the left-upper window in frame "frp". |
2863 */ | |
2864 static win_T * | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2865 frame2win(frame_T *frp) |
7 | 2866 { |
2867 while (frp->fr_win == NULL) | |
2868 frp = frp->fr_child; | |
2869 return frp->fr_win; | |
2870 } | |
2871 | |
2872 /* | |
2873 * Return TRUE if frame "frp" contains window "wp". | |
2874 */ | |
2875 static int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2876 frame_has_win(frame_T *frp, win_T *wp) |
7 | 2877 { |
2878 frame_T *p; | |
2879 | |
2880 if (frp->fr_layout == FR_LEAF) | |
2881 return frp->fr_win == wp; | |
2882 | |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
2883 FOR_ALL_FRAMES(p, frp->fr_child) |
7 | 2884 if (frame_has_win(p, wp)) |
2885 return TRUE; | |
2886 return FALSE; | |
2887 } | |
2888 | |
2889 /* | |
2890 * Set a new height for a frame. Recursively sets the height for contained | |
2891 * frames and windows. Caller must take care of positions. | |
2892 */ | |
2893 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2894 frame_new_height( |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2895 frame_T *topfrp, |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2896 int height, |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2897 int topfirst, /* resize topmost contained frame first */ |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2898 int wfh) /* obey 'winfixheight' when there is a choice; |
7 | 2899 may cause the height not to be set */ |
2900 { | |
2901 frame_T *frp; | |
2902 int extra_lines; | |
2903 int h; | |
2904 | |
2905 if (topfrp->fr_win != NULL) | |
2906 { | |
2907 /* Simple case: just one window. */ | |
2908 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
|
2909 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
|
2910 - WINBAR_HEIGHT(topfrp->fr_win)); |
7 | 2911 } |
2912 else if (topfrp->fr_layout == FR_ROW) | |
2913 { | |
2914 do | |
2915 { | |
2916 /* 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
|
2917 FOR_ALL_FRAMES(frp, topfrp->fr_child) |
7 | 2918 { |
2919 frame_new_height(frp, height, topfirst, wfh); | |
2920 if (frp->fr_height > height) | |
2921 { | |
2922 /* Could not fit the windows, make the whole row higher. */ | |
2923 height = frp->fr_height; | |
2924 break; | |
2925 } | |
2926 } | |
2927 } | |
2928 while (frp != NULL); | |
2929 } | |
779 | 2930 else /* fr_layout == FR_COL */ |
7 | 2931 { |
2932 /* Complicated case: Resize a column of frames. Resize the bottom | |
2933 * frame first, frames above that when needed. */ | |
2934 | |
2935 frp = topfrp->fr_child; | |
2936 if (wfh) | |
2937 /* Advance past frames with one window with 'wfh' set. */ | |
2938 while (frame_fixed_height(frp)) | |
2939 { | |
2940 frp = frp->fr_next; | |
2941 if (frp == NULL) | |
2942 return; /* no frame without 'wfh', give up */ | |
2943 } | |
2944 if (!topfirst) | |
2945 { | |
2946 /* Find the bottom frame of this column */ | |
2947 while (frp->fr_next != NULL) | |
2948 frp = frp->fr_next; | |
2949 if (wfh) | |
2950 /* Advance back for frames with one window with 'wfh' set. */ | |
2951 while (frame_fixed_height(frp)) | |
2952 frp = frp->fr_prev; | |
2953 } | |
2954 | |
2955 extra_lines = height - topfrp->fr_height; | |
2956 if (extra_lines < 0) | |
2957 { | |
2958 /* reduce height of contained frames, bottom or top frame first */ | |
2959 while (frp != NULL) | |
2960 { | |
2961 h = frame_minheight(frp, NULL); | |
2962 if (frp->fr_height + extra_lines < h) | |
2963 { | |
2964 extra_lines += frp->fr_height - h; | |
2965 frame_new_height(frp, h, topfirst, wfh); | |
2966 } | |
2967 else | |
2968 { | |
2969 frame_new_height(frp, frp->fr_height + extra_lines, | |
2970 topfirst, wfh); | |
2971 break; | |
2972 } | |
2973 if (topfirst) | |
2974 { | |
2975 do | |
2976 frp = frp->fr_next; | |
2977 while (wfh && frp != NULL && frame_fixed_height(frp)); | |
2978 } | |
2979 else | |
2980 { | |
2981 do | |
2982 frp = frp->fr_prev; | |
2983 while (wfh && frp != NULL && frame_fixed_height(frp)); | |
2984 } | |
2985 /* Increase "height" if we could not reduce enough frames. */ | |
2986 if (frp == NULL) | |
2987 height -= extra_lines; | |
2988 } | |
2989 } | |
2990 else if (extra_lines > 0) | |
2991 { | |
2992 /* increase height of bottom or top frame */ | |
2993 frame_new_height(frp, frp->fr_height + extra_lines, topfirst, wfh); | |
2994 } | |
2995 } | |
2996 topfrp->fr_height = height; | |
2997 } | |
2998 | |
2999 /* | |
3000 * Return TRUE if height of frame "frp" should not be changed because of | |
3001 * the 'winfixheight' option. | |
3002 */ | |
3003 static int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3004 frame_fixed_height(frame_T *frp) |
7 | 3005 { |
3006 /* frame with one window: fixed height if 'winfixheight' set. */ | |
3007 if (frp->fr_win != NULL) | |
3008 return frp->fr_win->w_p_wfh; | |
3009 | |
3010 if (frp->fr_layout == FR_ROW) | |
3011 { | |
3012 /* The frame is fixed height if one of the frames in the row is fixed | |
3013 * height. */ | |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
3014 FOR_ALL_FRAMES(frp, frp->fr_child) |
7 | 3015 if (frame_fixed_height(frp)) |
3016 return TRUE; | |
3017 return FALSE; | |
3018 } | |
3019 | |
3020 /* frp->fr_layout == FR_COL: The frame is fixed height if all of the | |
3021 * 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
|
3022 FOR_ALL_FRAMES(frp, frp->fr_child) |
7 | 3023 if (!frame_fixed_height(frp)) |
3024 return FALSE; | |
3025 return TRUE; | |
3026 } | |
3027 | |
3028 /* | |
779 | 3029 * Return TRUE if width of frame "frp" should not be changed because of |
3030 * the 'winfixwidth' option. | |
3031 */ | |
3032 static int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3033 frame_fixed_width(frame_T *frp) |
779 | 3034 { |
3035 /* frame with one window: fixed width if 'winfixwidth' set. */ | |
3036 if (frp->fr_win != NULL) | |
3037 return frp->fr_win->w_p_wfw; | |
3038 | |
3039 if (frp->fr_layout == FR_COL) | |
3040 { | |
3041 /* The frame is fixed width if one of the frames in the row is fixed | |
3042 * width. */ | |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
3043 FOR_ALL_FRAMES(frp, frp->fr_child) |
779 | 3044 if (frame_fixed_width(frp)) |
3045 return TRUE; | |
3046 return FALSE; | |
3047 } | |
3048 | |
3049 /* frp->fr_layout == FR_ROW: The frame is fixed width if all of the | |
3050 * 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
|
3051 FOR_ALL_FRAMES(frp, frp->fr_child) |
779 | 3052 if (!frame_fixed_width(frp)) |
3053 return FALSE; | |
3054 return TRUE; | |
3055 } | |
3056 | |
3057 /* | |
7 | 3058 * Add a status line to windows at the bottom of "frp". |
3059 * Note: Does not check if there is room! | |
3060 */ | |
3061 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3062 frame_add_statusline(frame_T *frp) |
7 | 3063 { |
3064 win_T *wp; | |
3065 | |
3066 if (frp->fr_layout == FR_LEAF) | |
3067 { | |
3068 wp = frp->fr_win; | |
3069 if (wp->w_status_height == 0) | |
3070 { | |
3071 if (wp->w_height > 0) /* don't make it negative */ | |
3072 --wp->w_height; | |
3073 wp->w_status_height = STATUS_HEIGHT; | |
3074 } | |
3075 } | |
3076 else if (frp->fr_layout == FR_ROW) | |
3077 { | |
3078 /* 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
|
3079 FOR_ALL_FRAMES(frp, frp->fr_child) |
7 | 3080 frame_add_statusline(frp); |
3081 } | |
3082 else /* frp->fr_layout == FR_COL */ | |
3083 { | |
3084 /* Only need to handle the last frame in the column. */ | |
3085 for (frp = frp->fr_child; frp->fr_next != NULL; frp = frp->fr_next) | |
3086 ; | |
3087 frame_add_statusline(frp); | |
3088 } | |
3089 } | |
3090 | |
3091 /* | |
3092 * Set width of a frame. Handles recursively going through contained frames. | |
3093 * May remove separator line for windows at the right side (for win_close()). | |
3094 */ | |
3095 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3096 frame_new_width( |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3097 frame_T *topfrp, |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3098 int width, |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3099 int leftfirst, /* resize leftmost contained frame first */ |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3100 int wfw) /* obey 'winfixwidth' when there is a choice; |
779 | 3101 may cause the width not to be set */ |
7 | 3102 { |
3103 frame_T *frp; | |
3104 int extra_cols; | |
3105 int w; | |
3106 win_T *wp; | |
3107 | |
3108 if (topfrp->fr_layout == FR_LEAF) | |
3109 { | |
3110 /* Simple case: just one window. */ | |
3111 wp = topfrp->fr_win; | |
3112 /* Find out if there are any windows right of this one. */ | |
3113 for (frp = topfrp; frp->fr_parent != NULL; frp = frp->fr_parent) | |
3114 if (frp->fr_parent->fr_layout == FR_ROW && frp->fr_next != NULL) | |
3115 break; | |
3116 if (frp->fr_parent == NULL) | |
3117 wp->w_vsep_width = 0; | |
3118 win_new_width(wp, width - wp->w_vsep_width); | |
3119 } | |
3120 else if (topfrp->fr_layout == FR_COL) | |
3121 { | |
779 | 3122 do |
3123 { | |
3124 /* 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
|
3125 FOR_ALL_FRAMES(frp, topfrp->fr_child) |
779 | 3126 { |
3127 frame_new_width(frp, width, leftfirst, wfw); | |
3128 if (frp->fr_width > width) | |
3129 { | |
3130 /* Could not fit the windows, make whole column wider. */ | |
3131 width = frp->fr_width; | |
3132 break; | |
3133 } | |
3134 } | |
3135 } while (frp != NULL); | |
7 | 3136 } |
3137 else /* fr_layout == FR_ROW */ | |
3138 { | |
3139 /* Complicated case: Resize a row of frames. Resize the rightmost | |
3140 * frame first, frames left of it when needed. */ | |
3141 | |
3142 frp = topfrp->fr_child; | |
779 | 3143 if (wfw) |
3144 /* Advance past frames with one window with 'wfw' set. */ | |
3145 while (frame_fixed_width(frp)) | |
3146 { | |
3147 frp = frp->fr_next; | |
3148 if (frp == NULL) | |
3149 return; /* no frame without 'wfw', give up */ | |
3150 } | |
7 | 3151 if (!leftfirst) |
779 | 3152 { |
3153 /* Find the rightmost frame of this row */ | |
7 | 3154 while (frp->fr_next != NULL) |
3155 frp = frp->fr_next; | |
779 | 3156 if (wfw) |
3157 /* Advance back for frames with one window with 'wfw' set. */ | |
3158 while (frame_fixed_width(frp)) | |
3159 frp = frp->fr_prev; | |
3160 } | |
7 | 3161 |
3162 extra_cols = width - topfrp->fr_width; | |
3163 if (extra_cols < 0) | |
3164 { | |
3165 /* reduce frame width, rightmost frame first */ | |
3166 while (frp != NULL) | |
3167 { | |
3168 w = frame_minwidth(frp, NULL); | |
3169 if (frp->fr_width + extra_cols < w) | |
3170 { | |
3171 extra_cols += frp->fr_width - w; | |
779 | 3172 frame_new_width(frp, w, leftfirst, wfw); |
7 | 3173 } |
3174 else | |
3175 { | |
779 | 3176 frame_new_width(frp, frp->fr_width + extra_cols, |
3177 leftfirst, wfw); | |
7 | 3178 break; |
3179 } | |
3180 if (leftfirst) | |
779 | 3181 { |
3182 do | |
3183 frp = frp->fr_next; | |
3184 while (wfw && frp != NULL && frame_fixed_width(frp)); | |
3185 } | |
7 | 3186 else |
779 | 3187 { |
3188 do | |
3189 frp = frp->fr_prev; | |
3190 while (wfw && frp != NULL && frame_fixed_width(frp)); | |
3191 } | |
3192 /* Increase "width" if we could not reduce enough frames. */ | |
3193 if (frp == NULL) | |
3194 width -= extra_cols; | |
7 | 3195 } |
3196 } | |
3197 else if (extra_cols > 0) | |
3198 { | |
3199 /* increase width of rightmost frame */ | |
779 | 3200 frame_new_width(frp, frp->fr_width + extra_cols, leftfirst, wfw); |
7 | 3201 } |
3202 } | |
3203 topfrp->fr_width = width; | |
3204 } | |
3205 | |
3206 /* | |
3207 * Add the vertical separator to windows at the right side of "frp". | |
3208 * Note: Does not check if there is room! | |
3209 */ | |
3210 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3211 frame_add_vsep(frame_T *frp) |
7 | 3212 { |
3213 win_T *wp; | |
3214 | |
3215 if (frp->fr_layout == FR_LEAF) | |
3216 { | |
3217 wp = frp->fr_win; | |
3218 if (wp->w_vsep_width == 0) | |
3219 { | |
3220 if (wp->w_width > 0) /* don't make it negative */ | |
3221 --wp->w_width; | |
3222 wp->w_vsep_width = 1; | |
3223 } | |
3224 } | |
3225 else if (frp->fr_layout == FR_COL) | |
3226 { | |
3227 /* 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
|
3228 FOR_ALL_FRAMES(frp, frp->fr_child) |
7 | 3229 frame_add_vsep(frp); |
3230 } | |
3231 else /* frp->fr_layout == FR_ROW */ | |
3232 { | |
3233 /* Only need to handle the last frame in the row. */ | |
3234 frp = frp->fr_child; | |
3235 while (frp->fr_next != NULL) | |
3236 frp = frp->fr_next; | |
3237 frame_add_vsep(frp); | |
3238 } | |
3239 } | |
3240 | |
3241 /* | |
3242 * Set frame width from the window it contains. | |
3243 */ | |
3244 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3245 frame_fix_width(win_T *wp) |
7 | 3246 { |
3247 wp->w_frame->fr_width = wp->w_width + wp->w_vsep_width; | |
3248 } | |
3249 | |
3250 /* | |
3251 * Set frame height from the window it contains. | |
3252 */ | |
3253 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3254 frame_fix_height(win_T *wp) |
7 | 3255 { |
12998
dd734ee3e2fe
patch 8.0.1375: window size wrong after maximizing with WinBar
Christian Brabandt <cb@256bit.org>
parents:
12916
diff
changeset
|
3256 wp->w_frame->fr_height = VISIBLE_HEIGHT(wp) + wp->w_status_height; |
7 | 3257 } |
3258 | |
3259 /* | |
3260 * Compute the minimal height for frame "topfrp". | |
3261 * Uses the 'winminheight' option. | |
3262 * When "next_curwin" isn't NULL, use p_wh for this window. | |
3263 * When "next_curwin" is NOWIN, don't use at least one line for the current | |
3264 * window. | |
3265 */ | |
3266 static int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3267 frame_minheight(frame_T *topfrp, win_T *next_curwin) |
7 | 3268 { |
3269 frame_T *frp; | |
3270 int m; | |
3271 int n; | |
3272 | |
3273 if (topfrp->fr_win != NULL) | |
3274 { | |
3275 if (topfrp->fr_win == next_curwin) | |
3276 m = p_wh + topfrp->fr_win->w_status_height; | |
3277 else | |
3278 { | |
3279 /* window: minimal height of the window plus status line */ | |
3280 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
|
3281 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
|
3282 { |
dd734ee3e2fe
patch 8.0.1375: window size wrong after maximizing with WinBar
Christian Brabandt <cb@256bit.org>
parents:
12916
diff
changeset
|
3283 /* Current window is minimal one line high and WinBar is |
dd734ee3e2fe
patch 8.0.1375: window size wrong after maximizing with WinBar
Christian Brabandt <cb@256bit.org>
parents:
12916
diff
changeset
|
3284 * visible. */ |
dd734ee3e2fe
patch 8.0.1375: window size wrong after maximizing with WinBar
Christian Brabandt <cb@256bit.org>
parents:
12916
diff
changeset
|
3285 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
|
3286 ++m; |
dd734ee3e2fe
patch 8.0.1375: window size wrong after maximizing with WinBar
Christian Brabandt <cb@256bit.org>
parents:
12916
diff
changeset
|
3287 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
|
3288 } |
7 | 3289 } |
3290 } | |
3291 else if (topfrp->fr_layout == FR_ROW) | |
3292 { | |
3293 /* get the minimal height from each frame in this row */ | |
3294 m = 0; | |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
3295 FOR_ALL_FRAMES(frp, topfrp->fr_child) |
7 | 3296 { |
3297 n = frame_minheight(frp, next_curwin); | |
3298 if (n > m) | |
3299 m = n; | |
3300 } | |
3301 } | |
3302 else | |
3303 { | |
3304 /* Add up the minimal heights for all frames in this column. */ | |
3305 m = 0; | |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
3306 FOR_ALL_FRAMES(frp, topfrp->fr_child) |
7 | 3307 m += frame_minheight(frp, next_curwin); |
3308 } | |
3309 | |
3310 return m; | |
3311 } | |
3312 | |
3313 /* | |
3314 * Compute the minimal width for frame "topfrp". | |
3315 * When "next_curwin" isn't NULL, use p_wiw for this window. | |
3316 * When "next_curwin" is NOWIN, don't use at least one column for the current | |
3317 * window. | |
3318 */ | |
3319 static int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3320 frame_minwidth( |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3321 frame_T *topfrp, |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3322 win_T *next_curwin) /* use p_wh and p_wiw for next_curwin */ |
7 | 3323 { |
3324 frame_T *frp; | |
3325 int m, n; | |
3326 | |
3327 if (topfrp->fr_win != NULL) | |
3328 { | |
3329 if (topfrp->fr_win == next_curwin) | |
3330 m = p_wiw + topfrp->fr_win->w_vsep_width; | |
3331 else | |
3332 { | |
3333 /* window: minimal width of the window plus separator column */ | |
3334 m = p_wmw + topfrp->fr_win->w_vsep_width; | |
3335 /* Current window is minimal one column wide */ | |
3336 if (p_wmw == 0 && topfrp->fr_win == curwin && next_curwin == NULL) | |
3337 ++m; | |
3338 } | |
3339 } | |
3340 else if (topfrp->fr_layout == FR_COL) | |
3341 { | |
3342 /* get the minimal width from each frame in this column */ | |
3343 m = 0; | |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
3344 FOR_ALL_FRAMES(frp, topfrp->fr_child) |
7 | 3345 { |
3346 n = frame_minwidth(frp, next_curwin); | |
3347 if (n > m) | |
3348 m = n; | |
3349 } | |
3350 } | |
3351 else | |
3352 { | |
3353 /* Add up the minimal widths for all frames in this row. */ | |
3354 m = 0; | |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
3355 FOR_ALL_FRAMES(frp, topfrp->fr_child) |
7 | 3356 m += frame_minwidth(frp, next_curwin); |
3357 } | |
3358 | |
3359 return m; | |
3360 } | |
3361 | |
3362 | |
3363 /* | |
3364 * Try to close all windows except current one. | |
3365 * Buffers in the other windows become hidden if 'hidden' is set, or '!' is | |
3366 * used and the buffer was modified. | |
3367 * | |
3368 * Used by ":bdel" and ":only". | |
3369 */ | |
3370 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3371 close_others( |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3372 int message, |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3373 int forceit) /* always hide all other windows */ |
7 | 3374 { |
3375 win_T *wp; | |
3376 win_T *nextwp; | |
3377 int r; | |
3378 | |
1906 | 3379 if (one_window()) |
7 | 3380 { |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13308
diff
changeset
|
3381 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
|
3382 msg(_(m_onlyone)); |
7 | 3383 return; |
3384 } | |
3385 | |
3386 /* Be very careful here: autocommands may change the window layout. */ | |
3387 for (wp = firstwin; win_valid(wp); wp = nextwp) | |
3388 { | |
3389 nextwp = wp->w_next; | |
3390 if (wp != curwin) /* don't close current window */ | |
3391 { | |
3392 | |
3393 /* Check if it's allowed to abandon this window */ | |
3394 r = can_abandon(wp->w_buffer, forceit); | |
3395 if (!win_valid(wp)) /* autocommands messed wp up */ | |
3396 { | |
3397 nextwp = firstwin; | |
3398 continue; | |
3399 } | |
3400 if (!r) | |
3401 { | |
3402 #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) | |
3403 if (message && (p_confirm || cmdmod.confirm) && p_write) | |
3404 { | |
3405 dialog_changed(wp->w_buffer, FALSE); | |
3406 if (!win_valid(wp)) /* autocommands messed wp up */ | |
3407 { | |
3408 nextwp = firstwin; | |
3409 continue; | |
3410 } | |
3411 } | |
3412 if (bufIsChanged(wp->w_buffer)) | |
3413 #endif | |
3414 continue; | |
3415 } | |
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
|
3416 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
|
3417 && !bufIsChanged(wp->w_buffer)); |
7 | 3418 } |
3419 } | |
3420 | |
10357
59d01e335858
commit https://github.com/vim/vim/commit/459ca563128f2edb7e3bb190090bbb755a56dd55
Christian Brabandt <cb@256bit.org>
parents:
10349
diff
changeset
|
3421 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
|
3422 emsg(_("E445: Other window contains changes")); |
7 | 3423 } |
3424 | |
3425 /* | |
675 | 3426 * Init the current window "curwin". |
3427 * Called when a new file is being edited. | |
7 | 3428 */ |
3429 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3430 curwin_init(void) |
7 | 3431 { |
1918 | 3432 win_init_empty(curwin); |
3433 } | |
3434 | |
3435 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3436 win_init_empty(win_T *wp) |
1918 | 3437 { |
3438 redraw_win_later(wp, NOT_VALID); | |
3439 wp->w_lines_valid = 0; | |
3440 wp->w_cursor.lnum = 1; | |
3441 wp->w_curswant = wp->w_cursor.col = 0; | |
3442 wp->w_cursor.coladd = 0; | |
3443 wp->w_pcmark.lnum = 1; /* pcmark not cleared but set to line 1 */ | |
3444 wp->w_pcmark.col = 0; | |
3445 wp->w_prev_pcmark.lnum = 0; | |
3446 wp->w_prev_pcmark.col = 0; | |
3447 wp->w_topline = 1; | |
7 | 3448 #ifdef FEAT_DIFF |
1918 | 3449 wp->w_topfill = 0; |
3450 #endif | |
3451 wp->w_botline = 2; | |
3068 | 3452 #ifdef FEAT_SYN_HL |
3453 wp->w_s = &wp->w_buffer->b_s; | |
3454 #endif | |
7 | 3455 } |
3456 | |
3457 /* | |
3458 * Allocate the first window and put an empty buffer in it. | |
3459 * Called from main(). | |
667 | 3460 * Return FAIL when something goes wrong (out of memory). |
7 | 3461 */ |
667 | 3462 int |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3463 win_alloc_first(void) |
7 | 3464 { |
675 | 3465 if (win_alloc_firstwin(NULL) == FAIL) |
667 | 3466 return FAIL; |
3467 | |
672 | 3468 first_tabpage = alloc_tabpage(); |
667 | 3469 if (first_tabpage == NULL) |
3470 return FAIL; | |
3471 first_tabpage->tp_topframe = topframe; | |
672 | 3472 curtab = first_tabpage; |
1906 | 3473 |
667 | 3474 return OK; |
3475 } | |
3476 | |
1906 | 3477 /* |
3478 * Init "aucmd_win". This can only be done after the first | |
3479 * window is fully initialized, thus it can't be in win_alloc_first(). | |
3480 */ | |
3481 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3482 win_alloc_aucmd_win(void) |
1906 | 3483 { |
3484 aucmd_win = win_alloc(NULL, TRUE); | |
3485 if (aucmd_win != NULL) | |
3486 { | |
3487 win_init_some(aucmd_win, curwin); | |
2583 | 3488 RESET_BINDING(aucmd_win); |
1906 | 3489 new_frame(aucmd_win); |
3490 } | |
3491 } | |
3492 | |
667 | 3493 /* |
675 | 3494 * Allocate the first window or the first window in a new tab page. |
3495 * 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
|
3496 * When "oldwin" is not NULL copy info from it to the new window. |
667 | 3497 * Return FAIL when something goes wrong (out of memory). |
3498 */ | |
3499 static int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3500 win_alloc_firstwin(win_T *oldwin) |
667 | 3501 { |
1906 | 3502 curwin = win_alloc(NULL, FALSE); |
675 | 3503 if (oldwin == NULL) |
3504 { | |
3505 /* Very first window, need to create an empty buffer for it and | |
3506 * initialize from scratch. */ | |
3507 curbuf = buflist_new(NULL, NULL, 1L, BLN_LISTED); | |
3508 if (curwin == NULL || curbuf == NULL) | |
3509 return FAIL; | |
3510 curwin->w_buffer = curbuf; | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2201
diff
changeset
|
3511 #ifdef FEAT_SYN_HL |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2201
diff
changeset
|
3512 curwin->w_s = &(curbuf->b_s); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2201
diff
changeset
|
3513 #endif |
675 | 3514 curbuf->b_nwindows = 1; /* there is one window */ |
3515 curwin->w_alist = &global_alist; | |
3516 curwin_init(); /* init current window */ | |
3517 } | |
3518 else | |
3519 { | |
3520 /* First window in new tab page, initialize it from "oldwin". */ | |
1822 | 3521 win_init(curwin, oldwin, 0); |
675 | 3522 |
2583 | 3523 /* We don't want cursor- and scroll-binding in the first window. */ |
3524 RESET_BINDING(curwin); | |
675 | 3525 } |
7 | 3526 |
1906 | 3527 new_frame(curwin); |
3528 if (curwin->w_frame == NULL) | |
667 | 3529 return FAIL; |
1906 | 3530 topframe = curwin->w_frame; |
7 | 3531 topframe->fr_width = Columns; |
3532 topframe->fr_height = Rows - p_ch; | |
667 | 3533 |
3534 return OK; | |
3535 } | |
3536 | |
3537 /* | |
1906 | 3538 * Create a frame for window "wp". |
3539 */ | |
3540 static void | |
3541 new_frame(win_T *wp) | |
3542 { | |
3543 frame_T *frp = (frame_T *)alloc_clear((unsigned)sizeof(frame_T)); | |
3544 | |
3545 wp->w_frame = frp; | |
3546 if (frp != NULL) | |
3547 { | |
3548 frp->fr_layout = FR_LEAF; | |
3549 frp->fr_win = wp; | |
3550 } | |
3551 } | |
3552 | |
3553 /* | |
667 | 3554 * Initialize the window and frame size to the maximum. |
3555 */ | |
3556 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3557 win_init_size(void) |
667 | 3558 { |
3559 firstwin->w_height = ROWS_AVAIL; | |
3560 topframe->fr_height = ROWS_AVAIL; | |
3561 firstwin->w_width = Columns; | |
3562 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
|
3563 } |
672 | 3564 |
3565 /* | |
3566 * Allocate a new tabpage_T and init the values. | |
3567 * Returns NULL when out of memory. | |
3568 */ | |
3569 static tabpage_T * | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3570 alloc_tabpage(void) |
672 | 3571 { |
3572 tabpage_T *tp; | |
4287 | 3573 # ifdef FEAT_GUI |
3574 int i; | |
3575 # endif | |
3576 | |
672 | 3577 |
3578 tp = (tabpage_T *)alloc_clear((unsigned)sizeof(tabpage_T)); | |
4287 | 3579 if (tp == NULL) |
3580 return NULL; | |
3581 | |
3582 # ifdef FEAT_EVAL | |
3583 /* init t: variables */ | |
3584 tp->tp_vars = dict_alloc(); | |
3585 if (tp->tp_vars == NULL) | |
3586 { | |
3587 vim_free(tp); | |
3588 return NULL; | |
3589 } | |
3590 init_var_dict(tp->tp_vars, &tp->tp_winvar, VAR_SCOPE); | |
3591 # endif | |
3592 | |
788 | 3593 # ifdef FEAT_GUI |
4287 | 3594 for (i = 0; i < 3; i++) |
3595 tp->tp_prev_which_scrollbars[i] = -1; | |
788 | 3596 # endif |
672 | 3597 # ifdef FEAT_DIFF |
4287 | 3598 tp->tp_diff_invalid = TRUE; |
672 | 3599 # endif |
4287 | 3600 tp->tp_ch_used = p_ch; |
3601 | |
672 | 3602 return tp; |
3603 } | |
3604 | |
852 | 3605 void |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3606 free_tabpage(tabpage_T *tp) |
672 | 3607 { |
1906 | 3608 int idx; |
3609 | |
672 | 3610 # ifdef FEAT_DIFF |
3611 diff_clear(tp); | |
3612 # endif | |
1906 | 3613 for (idx = 0; idx < SNAP_COUNT; ++idx) |
3614 clear_snapshot(tp, idx); | |
819 | 3615 #ifdef FEAT_EVAL |
4287 | 3616 vars_clear(&tp->tp_vars->dv_hashtab); /* free all t: variables */ |
3617 hash_init(&tp->tp_vars->dv_hashtab); | |
3618 unref_var_dict(tp->tp_vars); | |
819 | 3619 #endif |
4401 | 3620 |
3621 #ifdef FEAT_PYTHON | |
3622 python_tabpage_free(tp); | |
3623 #endif | |
3624 | |
3625 #ifdef FEAT_PYTHON3 | |
3626 python3_tabpage_free(tp); | |
3627 #endif | |
3628 | |
672 | 3629 vim_free(tp); |
3630 } | |
3631 | |
667 | 3632 /* |
675 | 3633 * Create a new Tab page with one window. |
3634 * It will edit the current buffer, like after ":split". | |
682 | 3635 * When "after" is 0 put it just after the current Tab page. |
3636 * Otherwise put it just before tab page "after". | |
667 | 3637 * Return FAIL or OK. |
3638 */ | |
3639 int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3640 win_new_tabpage(int after) |
667 | 3641 { |
672 | 3642 tabpage_T *tp = curtab; |
667 | 3643 tabpage_T *newtp; |
682 | 3644 int n; |
667 | 3645 |
672 | 3646 newtp = alloc_tabpage(); |
667 | 3647 if (newtp == NULL) |
3648 return FAIL; | |
3649 | |
3650 /* Remember the current windows in this Tab page. */ | |
4354 | 3651 if (leave_tabpage(curbuf, TRUE) == FAIL) |
674 | 3652 { |
3653 vim_free(newtp); | |
3654 return FAIL; | |
3655 } | |
672 | 3656 curtab = newtp; |
667 | 3657 |
3658 /* Create a new empty window. */ | |
675 | 3659 if (win_alloc_firstwin(tp->tp_curwin) == OK) |
667 | 3660 { |
3661 /* Make the new Tab page the new topframe. */ | |
682 | 3662 if (after == 1) |
3663 { | |
3664 /* New tab page becomes the first one. */ | |
3665 newtp->tp_next = first_tabpage; | |
3666 first_tabpage = newtp; | |
3667 } | |
3668 else | |
3669 { | |
3670 if (after > 0) | |
3671 { | |
3672 /* Put new tab page before tab page "after". */ | |
3673 n = 2; | |
3674 for (tp = first_tabpage; tp->tp_next != NULL | |
3675 && n < after; tp = tp->tp_next) | |
3676 ++n; | |
3677 } | |
3678 newtp->tp_next = tp->tp_next; | |
3679 tp->tp_next = newtp; | |
3680 } | |
667 | 3681 win_init_size(); |
685 | 3682 firstwin->w_winrow = tabline_height(); |
819 | 3683 win_comp_scroll(curwin); |
667 | 3684 |
3685 newtp->tp_topframe = topframe; | |
671 | 3686 last_status(FALSE); |
815 | 3687 |
3688 #if defined(FEAT_GUI) | |
3689 /* When 'guioptions' includes 'L' or 'R' may have to remove or add | |
3690 * scrollbars. Have to update them anyway. */ | |
1906 | 3691 gui_may_update_scrollbars(); |
815 | 3692 #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
|
3693 #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
|
3694 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
|
3695 #endif |
815 | 3696 |
15380
f62d6bd18a49
patch 8.1.0698: clearing the window is used too often
Bram Moolenaar <Bram@vim.org>
parents:
15227
diff
changeset
|
3697 redraw_all_later(NOT_VALID); |
9595
0190d5de215f
commit https://github.com/vim/vim/commit/c917da4b3e8801a255dbefea8e4ed19c1c716dd8
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
3698 apply_autocmds(EVENT_WINNEW, NULL, NULL, FALSE, curbuf); |
4354 | 3699 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
|
3700 apply_autocmds(EVENT_TABNEW, NULL, NULL, FALSE, curbuf); |
675 | 3701 apply_autocmds(EVENT_TABENTER, NULL, NULL, FALSE, curbuf); |
667 | 3702 return OK; |
3703 } | |
3704 | |
3705 /* Failed, get back the previous Tab page */ | |
4354 | 3706 enter_tabpage(curtab, curbuf, TRUE, TRUE); |
667 | 3707 return FAIL; |
3708 } | |
3709 | |
3710 /* | |
682 | 3711 * Open a new tab page if ":tab cmd" was used. It will edit the same buffer, |
3712 * like with ":split". | |
3713 * Returns OK if a new tab page was created, FAIL otherwise. | |
3714 */ | |
3715 int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3716 may_open_tabpage(void) |
682 | 3717 { |
1090 | 3718 int n = (cmdmod.tab == 0) ? postponed_split_tab : cmdmod.tab; |
3719 | |
3720 if (n != 0) | |
682 | 3721 { |
3722 cmdmod.tab = 0; /* reset it to avoid doing it twice */ | |
1090 | 3723 postponed_split_tab = 0; |
682 | 3724 return win_new_tabpage(n); |
3725 } | |
3726 return FAIL; | |
3727 } | |
3728 | |
3729 /* | |
672 | 3730 * Create up to "maxcount" tabpages with empty windows. |
3731 * Returns the number of resulting tab pages. | |
667 | 3732 */ |
672 | 3733 int |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3734 make_tabpages(int maxcount) |
667 | 3735 { |
672 | 3736 int count = maxcount; |
3737 int todo; | |
3738 | |
698 | 3739 /* Limit to 'tabpagemax' tabs. */ |
3740 if (count > p_tpm) | |
3741 count = p_tpm; | |
672 | 3742 |
3743 /* | |
3744 * Don't execute autocommands while creating the tab pages. Must do that | |
3745 * when putting the buffers in the windows. | |
3746 */ | |
1410 | 3747 block_autocmds(); |
672 | 3748 |
3749 for (todo = count - 1; todo > 0; --todo) | |
682 | 3750 if (win_new_tabpage(0) == FAIL) |
667 | 3751 break; |
672 | 3752 |
1410 | 3753 unblock_autocmds(); |
672 | 3754 |
3755 /* return actual number of tab pages */ | |
3756 return (count - todo); | |
667 | 3757 } |
3758 | |
3759 /* | |
671 | 3760 * Return TRUE when "tpc" points to a valid tab page. |
3761 */ | |
3762 int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3763 valid_tabpage(tabpage_T *tpc) |
671 | 3764 { |
3765 tabpage_T *tp; | |
3766 | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9599
diff
changeset
|
3767 FOR_ALL_TABPAGES(tp) |
671 | 3768 if (tp == tpc) |
3769 return TRUE; | |
3770 return FALSE; | |
3771 } | |
3772 | |
3773 /* | |
11199
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
3774 * 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
|
3775 * valid. |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
3776 */ |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
3777 int |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
3778 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
|
3779 { |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
3780 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
|
3781 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
|
3782 |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
3783 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
|
3784 { |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
3785 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
|
3786 { |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
3787 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
|
3788 { |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
3789 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
|
3790 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
|
3791 } |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
3792 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
|
3793 } |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
3794 } |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
3795 /* shouldn't happen */ |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
3796 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
|
3797 } |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
3798 |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
3799 /* |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
3800 * 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
|
3801 * 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
|
3802 */ |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
3803 void |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
3804 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
|
3805 { |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
3806 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
|
3807 |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
3808 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
|
3809 { |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
3810 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
|
3811 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
|
3812 } |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
3813 else |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
3814 { |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
3815 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
|
3816 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
|
3817 ; |
11232
a14090a30a3f
patch 8.0.0502: Coverity complains about possible NULL pointer
Christian Brabandt <cb@256bit.org>
parents:
11207
diff
changeset
|
3818 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
|
3819 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
|
3820 } |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
3821 |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
3822 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
|
3823 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
|
3824 } |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
3825 |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
3826 /* |
671 | 3827 * Find tab page "n" (first one is 1). Returns NULL when not found. |
3828 */ | |
3829 tabpage_T * | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3830 find_tabpage(int n) |
671 | 3831 { |
3832 tabpage_T *tp; | |
3833 int i = 1; | |
3834 | |
3835 for (tp = first_tabpage; tp != NULL && i != n; tp = tp->tp_next) | |
3836 ++i; | |
3837 return tp; | |
3838 } | |
3839 | |
3840 /* | |
685 | 3841 * Get index of tab page "tp". First one has index 1. |
686 | 3842 * When not found returns number of tab pages plus one. |
685 | 3843 */ |
3844 int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3845 tabpage_index(tabpage_T *ftp) |
685 | 3846 { |
3847 int i = 1; | |
3848 tabpage_T *tp; | |
3849 | |
3850 for (tp = first_tabpage; tp != NULL && tp != ftp; tp = tp->tp_next) | |
3851 ++i; | |
3852 return i; | |
3853 } | |
3854 | |
3855 /* | |
674 | 3856 * Prepare for leaving the current tab page. |
4352 | 3857 * When autocommands change "curtab" we don't leave the tab page and return |
674 | 3858 * FAIL. |
3859 * Careful: When OK is returned need to get a new tab page very very soon! | |
667 | 3860 */ |
674 | 3861 static int |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3862 leave_tabpage( |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3863 buf_T *new_curbuf UNUSED, /* what is going to be the new curbuf, |
674 | 3864 NULL if unknown */ |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3865 int trigger_leave_autocmds UNUSED) |
667 | 3866 { |
674 | 3867 tabpage_T *tp = curtab; |
3868 | |
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
|
3869 #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
|
3870 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
|
3871 #endif |
819 | 3872 reset_VIsual_and_resel(); /* stop Visual mode */ |
4354 | 3873 if (trigger_leave_autocmds) |
3874 { | |
3875 if (new_curbuf != curbuf) | |
3876 { | |
3877 apply_autocmds(EVENT_BUFLEAVE, NULL, NULL, FALSE, curbuf); | |
3878 if (curtab != tp) | |
3879 return FAIL; | |
3880 } | |
3881 apply_autocmds(EVENT_WINLEAVE, NULL, NULL, FALSE, curbuf); | |
674 | 3882 if (curtab != tp) |
3883 return FAIL; | |
4354 | 3884 apply_autocmds(EVENT_TABLEAVE, NULL, NULL, FALSE, curbuf); |
3885 if (curtab != tp) | |
3886 return FAIL; | |
3887 } | |
668 | 3888 #if defined(FEAT_GUI) |
3889 /* Remove the scrollbars. They may be added back later. */ | |
3890 if (gui.in_use) | |
3891 gui_remove_scrollbars(); | |
3892 #endif | |
667 | 3893 tp->tp_curwin = curwin; |
671 | 3894 tp->tp_prevwin = prevwin; |
667 | 3895 tp->tp_firstwin = firstwin; |
3896 tp->tp_lastwin = lastwin; | |
668 | 3897 tp->tp_old_Rows = Rows; |
3898 tp->tp_old_Columns = Columns; | |
667 | 3899 firstwin = NULL; |
3900 lastwin = NULL; | |
674 | 3901 return OK; |
667 | 3902 } |
3903 | |
3904 /* | |
3905 * Start using tab page "tp". | |
675 | 3906 * Only to be used after leave_tabpage() or freeing the current tab page. |
4354 | 3907 * Only trigger *Enter autocommands when trigger_enter_autocmds is TRUE. |
3908 * Only trigger *Leave autocommands when trigger_leave_autocmds is TRUE. | |
667 | 3909 */ |
3910 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3911 enter_tabpage( |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3912 tabpage_T *tp, |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3913 buf_T *old_curbuf UNUSED, |
8368
db2a07b710ed
commit https://github.com/vim/vim/commit/f1d2501ebe33e148886c2914acd33140e20ee222
Christian Brabandt <cb@256bit.org>
parents:
8212
diff
changeset
|
3914 int trigger_enter_autocmds, |
db2a07b710ed
commit https://github.com/vim/vim/commit/f1d2501ebe33e148886c2914acd33140e20ee222
Christian Brabandt <cb@256bit.org>
parents:
8212
diff
changeset
|
3915 int trigger_leave_autocmds) |
667 | 3916 { |
668 | 3917 int old_off = tp->tp_firstwin->w_winrow; |
870 | 3918 win_T *next_prevwin = tp->tp_prevwin; |
668 | 3919 |
672 | 3920 curtab = tp; |
667 | 3921 firstwin = tp->tp_firstwin; |
3922 lastwin = tp->tp_lastwin; | |
3923 topframe = tp->tp_topframe; | |
870 | 3924 |
3925 /* We would like doing the TabEnter event first, but we don't have a | |
3926 * valid current window yet, which may break some commands. | |
3927 * This triggers autocommands, thus may make "tp" invalid. */ | |
9595
0190d5de215f
commit https://github.com/vim/vim/commit/c917da4b3e8801a255dbefea8e4ed19c1c716dd8
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
3928 win_enter_ext(tp->tp_curwin, FALSE, TRUE, FALSE, |
4918
0792cc5133ce
updated for version 7.3.1204
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3929 trigger_enter_autocmds, trigger_leave_autocmds); |
870 | 3930 prevwin = next_prevwin; |
3931 | |
668 | 3932 last_status(FALSE); /* status line may appear or disappear */ |
3933 (void)win_comp_pos(); /* recompute w_winrow for all windows */ | |
672 | 3934 #ifdef FEAT_DIFF |
3935 diff_need_scrollbind = TRUE; | |
3936 #endif | |
668 | 3937 |
3938 /* The tabpage line may have appeared or disappeared, may need to resize | |
3939 * the frames for that. When the Vim window was resized need to update | |
824 | 3940 * frame sizes too. Use the stored value of p_ch, so that it can be |
3941 * different for each tab page. */ | |
3942 p_ch = curtab->tp_ch_used; | |
685 | 3943 if (curtab->tp_old_Rows != Rows || (old_off != firstwin->w_winrow |
3944 #ifdef FEAT_GUI_TABLINE | |
3945 && !gui_use_tabline() | |
3946 #endif | |
3947 )) | |
668 | 3948 shell_new_rows(); |
674 | 3949 if (curtab->tp_old_Columns != Columns && starting == 0) |
668 | 3950 shell_new_columns(); /* update window widths */ |
3951 | |
3952 #if defined(FEAT_GUI) | |
3953 /* When 'guioptions' includes 'L' or 'R' may have to remove or add | |
3954 * scrollbars. Have to update them anyway. */ | |
1906 | 3955 gui_may_update_scrollbars(); |
667 | 3956 #endif |
3957 | |
3413 | 3958 /* Apply autocommands after updating the display, when 'rows' and |
3959 * 'columns' have been set correctly. */ | |
4354 | 3960 if (trigger_enter_autocmds) |
3582 | 3961 { |
3962 apply_autocmds(EVENT_TABENTER, NULL, NULL, FALSE, curbuf); | |
3963 if (old_curbuf != curbuf) | |
3964 apply_autocmds(EVENT_BUFENTER, NULL, NULL, FALSE, curbuf); | |
3965 } | |
3413 | 3966 |
15380
f62d6bd18a49
patch 8.1.0698: clearing the window is used too often
Bram Moolenaar <Bram@vim.org>
parents:
15227
diff
changeset
|
3967 redraw_all_later(NOT_VALID); |
667 | 3968 } |
3969 | |
3970 /* | |
3971 * Go to tab page "n". For ":tab N" and "Ngt". | |
685 | 3972 * When "n" is 9999 go to the last tab page. |
667 | 3973 */ |
3974 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3975 goto_tabpage(int n) |
667 | 3976 { |
3977 tabpage_T *tp; | |
682 | 3978 tabpage_T *ttp; |
667 | 3979 int i; |
3980 | |
857 | 3981 if (text_locked()) |
3982 { | |
3983 /* 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
|
3984 text_locked_msg(); |
857 | 3985 return; |
3986 } | |
3987 | |
675 | 3988 /* If there is only one it can't work. */ |
3989 if (first_tabpage->tp_next == NULL) | |
3990 { | |
3991 if (n > 1) | |
3992 beep_flush(); | |
3993 return; | |
3994 } | |
3995 | |
667 | 3996 if (n == 0) |
3997 { | |
3998 /* No count, go to next tab page, wrap around end. */ | |
674 | 3999 if (curtab->tp_next == NULL) |
667 | 4000 tp = first_tabpage; |
4001 else | |
674 | 4002 tp = curtab->tp_next; |
667 | 4003 } |
682 | 4004 else if (n < 0) |
4005 { | |
4006 /* "gT": go to previous tab page, wrap around end. "N gT" repeats | |
4007 * this N times. */ | |
4008 ttp = curtab; | |
4009 for (i = n; i < 0; ++i) | |
4010 { | |
4011 for (tp = first_tabpage; tp->tp_next != ttp && tp->tp_next != NULL; | |
4012 tp = tp->tp_next) | |
4013 ; | |
4014 ttp = tp; | |
4015 } | |
4016 } | |
685 | 4017 else if (n == 9999) |
4018 { | |
4019 /* Go to last tab page. */ | |
4020 for (tp = first_tabpage; tp->tp_next != NULL; tp = tp->tp_next) | |
4021 ; | |
4022 } | |
667 | 4023 else |
4024 { | |
4025 /* Go to tab page "n". */ | |
685 | 4026 tp = find_tabpage(n); |
671 | 4027 if (tp == NULL) |
4028 { | |
4029 beep_flush(); | |
4030 return; | |
4031 } | |
667 | 4032 } |
4033 | |
4354 | 4034 goto_tabpage_tp(tp, TRUE, TRUE); |
685 | 4035 |
4036 #ifdef FEAT_GUI_TABLINE | |
4037 if (gui_use_tabline()) | |
690 | 4038 gui_mch_set_curtab(tabpage_index(curtab)); |
685 | 4039 #endif |
4040 } | |
4041 | |
4042 /* | |
4043 * Go to tabpage "tp". | |
4354 | 4044 * Only trigger *Enter autocommands when trigger_enter_autocmds is TRUE. |
4045 * Only trigger *Leave autocommands when trigger_leave_autocmds is TRUE. | |
685 | 4046 * Note: doesn't update the GUI tab. |
4047 */ | |
4048 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4049 goto_tabpage_tp( |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4050 tabpage_T *tp, |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4051 int trigger_enter_autocmds, |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4052 int trigger_leave_autocmds) |
685 | 4053 { |
2201
4c6b4298852f
Other solution for GTK not changing the locale.
Bram Moolenaar <bram@vim.org>
parents:
2115
diff
changeset
|
4054 /* Don't repeat a message in another tab page. */ |
4c6b4298852f
Other solution for GTK not changing the locale.
Bram Moolenaar <bram@vim.org>
parents:
2115
diff
changeset
|
4055 set_keep_msg(NULL, 0); |
4c6b4298852f
Other solution for GTK not changing the locale.
Bram Moolenaar <bram@vim.org>
parents:
2115
diff
changeset
|
4056 |
4354 | 4057 if (tp != curtab && leave_tabpage(tp->tp_curwin->w_buffer, |
4058 trigger_leave_autocmds) == OK) | |
674 | 4059 { |
4060 if (valid_tabpage(tp)) | |
4354 | 4061 enter_tabpage(tp, curbuf, trigger_enter_autocmds, |
4062 trigger_leave_autocmds); | |
674 | 4063 else |
4354 | 4064 enter_tabpage(curtab, curbuf, trigger_enter_autocmds, |
4065 trigger_leave_autocmds); | |
674 | 4066 } |
667 | 4067 } |
7 | 4068 |
4069 /* | |
825 | 4070 * Enter window "wp" in tab page "tp". |
4071 * Also updates the GUI tab. | |
4072 */ | |
4073 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4074 goto_tabpage_win(tabpage_T *tp, win_T *wp) |
825 | 4075 { |
4354 | 4076 goto_tabpage_tp(tp, TRUE, TRUE); |
825 | 4077 if (curtab == tp && win_valid(wp)) |
4078 { | |
4079 win_enter(wp, TRUE); | |
4080 # ifdef FEAT_GUI_TABLINE | |
4081 if (gui_use_tabline()) | |
4082 gui_mch_set_curtab(tabpage_index(curtab)); | |
4083 # endif | |
4084 } | |
4085 } | |
4086 | |
4087 /* | |
6775 | 4088 * Move the current tab page to after tab page "nr". |
682 | 4089 */ |
4090 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4091 tabpage_move(int nr) |
682 | 4092 { |
6775 | 4093 int n = 1; |
4094 tabpage_T *tp, *tp_dst; | |
682 | 4095 |
4096 if (first_tabpage->tp_next == NULL) | |
4097 return; | |
4098 | |
6775 | 4099 for (tp = first_tabpage; tp->tp_next != NULL && n < nr; tp = tp->tp_next) |
4100 ++n; | |
4101 | |
4102 if (tp == curtab || (nr > 0 && tp->tp_next != NULL | |
4103 && tp->tp_next == curtab)) | |
4104 return; | |
4105 | |
4106 tp_dst = tp; | |
4107 | |
682 | 4108 /* Remove the current tab page from the list of tab pages. */ |
4109 if (curtab == first_tabpage) | |
4110 first_tabpage = curtab->tp_next; | |
4111 else | |
4112 { | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9599
diff
changeset
|
4113 FOR_ALL_TABPAGES(tp) |
682 | 4114 if (tp->tp_next == curtab) |
4115 break; | |
4116 if (tp == NULL) /* "cannot happen" */ | |
4117 return; | |
4118 tp->tp_next = curtab->tp_next; | |
4119 } | |
4120 | |
4121 /* Re-insert it at the specified position. */ | |
6775 | 4122 if (nr <= 0) |
682 | 4123 { |
4124 curtab->tp_next = first_tabpage; | |
4125 first_tabpage = curtab; | |
4126 } | |
4127 else | |
4128 { | |
6775 | 4129 curtab->tp_next = tp_dst->tp_next; |
4130 tp_dst->tp_next = curtab; | |
682 | 4131 } |
4132 | |
4133 /* Need to redraw the tabline. Tab page contents doesn't change. */ | |
4134 redraw_tabline = TRUE; | |
4135 } | |
4136 | |
4137 | |
4138 /* | |
7 | 4139 * Go to another window. |
4140 * When jumping to another buffer, stop Visual mode. Do this before | |
4141 * changing windows so we can yank the selection into the '*' register. | |
4142 * When jumping to another window on the same buffer, adjust its cursor | |
4143 * position to keep the same Visual area. | |
4144 */ | |
4145 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4146 win_goto(win_T *wp) |
7 | 4147 { |
2316
db0ea641e382
Fix: cursor line not properly concealed when moving between windows.
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
4148 #ifdef FEAT_CONCEAL |
db0ea641e382
Fix: cursor line not properly concealed when moving between windows.
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
4149 win_T *owp = curwin; |
db0ea641e382
Fix: cursor line not properly concealed when moving between windows.
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
4150 #endif |
db0ea641e382
Fix: cursor line not properly concealed when moving between windows.
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
4151 |
633 | 4152 if (text_locked()) |
7 | 4153 { |
4154 beep_flush(); | |
633 | 4155 text_locked_msg(); |
7 | 4156 return; |
4157 } | |
819 | 4158 if (curbuf_locked()) |
4159 return; | |
631 | 4160 |
7 | 4161 if (wp->w_buffer != curbuf) |
4162 reset_VIsual_and_resel(); | |
4163 else if (VIsual_active) | |
4164 wp->w_cursor = curwin->w_cursor; | |
4165 | |
4166 #ifdef FEAT_GUI | |
4167 need_mouse_correct = TRUE; | |
4168 #endif | |
4169 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
|
4170 |
db0ea641e382
Fix: cursor line not properly concealed when moving between windows.
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
4171 #ifdef FEAT_CONCEAL |
15436
29f3d59bb6f0
patch 8.1.0726: redrawing specifically for conceal feature
Bram Moolenaar <Bram@vim.org>
parents:
15380
diff
changeset
|
4172 // Conceal cursor line in previous window, unconceal in current window. |
4094 | 4173 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
|
4174 redrawWinline(owp, owp->w_cursor.lnum); |
4094 | 4175 if (curwin->w_p_cole > 0 && !msg_scrolled) |
4176 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
|
4177 #endif |
7 | 4178 } |
4179 | |
4180 #if defined(FEAT_PERL) || defined(PROTO) | |
4181 /* | |
4182 * Find window number "winnr" (counting top to bottom). | |
4183 */ | |
4184 win_T * | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4185 win_find_nr(int winnr) |
7 | 4186 { |
4187 win_T *wp; | |
4188 | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9599
diff
changeset
|
4189 FOR_ALL_WINDOWS(wp) |
7 | 4190 if (--winnr == 0) |
4191 break; | |
4192 return wp; | |
4193 } | |
4194 #endif | |
4195 | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
4196 #if ((defined(FEAT_PYTHON) || defined(FEAT_PYTHON3))) || defined(PROTO) |
4429 | 4197 /* |
4198 * Find the tabpage for window "win". | |
4199 */ | |
4200 tabpage_T * | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4201 win_find_tabpage(win_T *win) |
4429 | 4202 { |
4203 win_T *wp; | |
4204 tabpage_T *tp; | |
4205 | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9599
diff
changeset
|
4206 FOR_ALL_TAB_WINDOWS(tp, wp) |
4429 | 4207 if (wp == win) |
4208 return tp; | |
4209 return NULL; | |
4210 } | |
4211 #endif | |
4212 | |
7 | 4213 /* |
4214 * Move to window above or below "count" times. | |
4215 */ | |
4216 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4217 win_goto_ver( |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4218 int up, /* TRUE to go to win above */ |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4219 long count) |
7 | 4220 { |
4221 frame_T *fr; | |
4222 frame_T *nfr; | |
4223 frame_T *foundfr; | |
4224 | |
4225 foundfr = curwin->w_frame; | |
4226 while (count--) | |
4227 { | |
4228 /* | |
4229 * First go upwards in the tree of frames until we find a upwards or | |
4230 * downwards neighbor. | |
4231 */ | |
4232 fr = foundfr; | |
4233 for (;;) | |
4234 { | |
4235 if (fr == topframe) | |
4236 goto end; | |
4237 if (up) | |
4238 nfr = fr->fr_prev; | |
4239 else | |
4240 nfr = fr->fr_next; | |
4241 if (fr->fr_parent->fr_layout == FR_COL && nfr != NULL) | |
4242 break; | |
4243 fr = fr->fr_parent; | |
4244 } | |
4245 | |
4246 /* | |
4247 * Now go downwards to find the bottom or top frame in it. | |
4248 */ | |
4249 for (;;) | |
4250 { | |
4251 if (nfr->fr_layout == FR_LEAF) | |
4252 { | |
4253 foundfr = nfr; | |
4254 break; | |
4255 } | |
4256 fr = nfr->fr_child; | |
4257 if (nfr->fr_layout == FR_ROW) | |
4258 { | |
4259 /* Find the frame at the cursor row. */ | |
4260 while (fr->fr_next != NULL | |
4261 && frame2win(fr)->w_wincol + fr->fr_width | |
4262 <= curwin->w_wincol + curwin->w_wcol) | |
4263 fr = fr->fr_next; | |
4264 } | |
4265 if (nfr->fr_layout == FR_COL && up) | |
4266 while (fr->fr_next != NULL) | |
4267 fr = fr->fr_next; | |
4268 nfr = fr; | |
4269 } | |
4270 } | |
4271 end: | |
4272 if (foundfr != NULL) | |
4273 win_goto(foundfr->fr_win); | |
4274 } | |
4275 | |
4276 /* | |
4277 * Move to left or right window. | |
4278 */ | |
4279 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4280 win_goto_hor( |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4281 int left, /* TRUE to go to left win */ |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4282 long count) |
7 | 4283 { |
4284 frame_T *fr; | |
4285 frame_T *nfr; | |
4286 frame_T *foundfr; | |
4287 | |
4288 foundfr = curwin->w_frame; | |
4289 while (count--) | |
4290 { | |
4291 /* | |
4292 * First go upwards in the tree of frames until we find a left or | |
4293 * right neighbor. | |
4294 */ | |
4295 fr = foundfr; | |
4296 for (;;) | |
4297 { | |
4298 if (fr == topframe) | |
4299 goto end; | |
4300 if (left) | |
4301 nfr = fr->fr_prev; | |
4302 else | |
4303 nfr = fr->fr_next; | |
4304 if (fr->fr_parent->fr_layout == FR_ROW && nfr != NULL) | |
4305 break; | |
4306 fr = fr->fr_parent; | |
4307 } | |
4308 | |
4309 /* | |
4310 * Now go downwards to find the leftmost or rightmost frame in it. | |
4311 */ | |
4312 for (;;) | |
4313 { | |
4314 if (nfr->fr_layout == FR_LEAF) | |
4315 { | |
4316 foundfr = nfr; | |
4317 break; | |
4318 } | |
4319 fr = nfr->fr_child; | |
4320 if (nfr->fr_layout == FR_COL) | |
4321 { | |
4322 /* Find the frame at the cursor row. */ | |
4323 while (fr->fr_next != NULL | |
4324 && frame2win(fr)->w_winrow + fr->fr_height | |
4325 <= curwin->w_winrow + curwin->w_wrow) | |
4326 fr = fr->fr_next; | |
4327 } | |
4328 if (nfr->fr_layout == FR_ROW && left) | |
4329 while (fr->fr_next != NULL) | |
4330 fr = fr->fr_next; | |
4331 nfr = fr; | |
4332 } | |
4333 } | |
4334 end: | |
4335 if (foundfr != NULL) | |
4336 win_goto(foundfr->fr_win); | |
4337 } | |
4338 | |
4339 /* | |
4340 * Make window "wp" the current window. | |
4341 */ | |
4342 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4343 win_enter(win_T *wp, int undo_sync) |
7 | 4344 { |
9595
0190d5de215f
commit https://github.com/vim/vim/commit/c917da4b3e8801a255dbefea8e4ed19c1c716dd8
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
4345 win_enter_ext(wp, undo_sync, FALSE, FALSE, TRUE, TRUE); |
7 | 4346 } |
4347 | |
4348 /* | |
4349 * Make window wp the current window. | |
4350 * Can be called with "curwin_invalid" TRUE, which means that curwin has just | |
4351 * been closed and isn't valid. | |
4352 */ | |
4353 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4354 win_enter_ext( |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4355 win_T *wp, |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4356 int undo_sync, |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4357 int curwin_invalid, |
13632
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
4358 int trigger_new_autocmds, |
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
4359 int trigger_enter_autocmds, |
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
4360 int trigger_leave_autocmds) |
7 | 4361 { |
4362 int other_buffer = FALSE; | |
4363 | |
4364 if (wp == curwin && !curwin_invalid) /* nothing to do */ | |
4365 return; | |
4366 | |
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
|
4367 #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
|
4368 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
|
4369 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
|
4370 #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
|
4371 |
4354 | 4372 if (!curwin_invalid && trigger_leave_autocmds) |
7 | 4373 { |
4374 /* | |
4375 * Be careful: If autocommands delete the window, return now. | |
4376 */ | |
4377 if (wp->w_buffer != curbuf) | |
4378 { | |
4379 apply_autocmds(EVENT_BUFLEAVE, NULL, NULL, FALSE, curbuf); | |
4380 other_buffer = TRUE; | |
4381 if (!win_valid(wp)) | |
4382 return; | |
4383 } | |
4384 apply_autocmds(EVENT_WINLEAVE, NULL, NULL, FALSE, curbuf); | |
4385 if (!win_valid(wp)) | |
4386 return; | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13308
diff
changeset
|
4387 #ifdef FEAT_EVAL |
7 | 4388 /* autocmds may abort script processing */ |
4389 if (aborting()) | |
4390 return; | |
4391 #endif | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13308
diff
changeset
|
4392 } |
7 | 4393 |
4394 /* sync undo before leaving the current buffer */ | |
4395 if (undo_sync && curbuf != wp->w_buffer) | |
825 | 4396 u_sync(FALSE); |
5977 | 4397 |
4398 /* Might need to scroll the old window before switching, e.g., when the | |
4399 * cursor was moved. */ | |
4400 update_topline(); | |
4401 | |
7 | 4402 /* may have to copy the buffer options when 'cpo' contains 'S' */ |
4403 if (wp->w_buffer != curbuf) | |
4404 buf_copy_options(wp->w_buffer, BCO_ENTER | BCO_NOHELP); | |
4405 if (!curwin_invalid) | |
4406 { | |
4407 prevwin = curwin; /* remember for CTRL-W p */ | |
4408 curwin->w_redr_status = TRUE; | |
4409 } | |
4410 curwin = wp; | |
4411 curbuf = wp->w_buffer; | |
4412 check_cursor(); | |
4413 if (!virtual_active()) | |
4414 curwin->w_cursor.coladd = 0; | |
4415 changed_line_abv_curs(); /* assume cursor position needs updating */ | |
4416 | |
4417 if (curwin->w_localdir != NULL) | |
4418 { | |
4419 /* Window has a local directory: Save current directory as global | |
4420 * directory (unless that was done already) and change to the local | |
4421 * directory. */ | |
4422 if (globaldir == NULL) | |
4423 { | |
4424 char_u cwd[MAXPATHL]; | |
4425 | |
4426 if (mch_dirname(cwd, MAXPATHL) == OK) | |
4427 globaldir = vim_strsave(cwd); | |
4428 } | |
1757 | 4429 if (mch_chdir((char *)curwin->w_localdir) == 0) |
4430 shorten_fnames(TRUE); | |
7 | 4431 } |
4432 else if (globaldir != NULL) | |
4433 { | |
4434 /* Window doesn't have a local directory and we are not in the global | |
4435 * 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
|
4436 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
|
4437 VIM_CLEAR(globaldir); |
7 | 4438 shorten_fnames(TRUE); |
4439 } | |
4440 | |
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
|
4441 #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
|
4442 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
|
4443 #endif |
9595
0190d5de215f
commit https://github.com/vim/vim/commit/c917da4b3e8801a255dbefea8e4ed19c1c716dd8
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
4444 if (trigger_new_autocmds) |
0190d5de215f
commit https://github.com/vim/vim/commit/c917da4b3e8801a255dbefea8e4ed19c1c716dd8
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
4445 apply_autocmds(EVENT_WINNEW, NULL, NULL, FALSE, curbuf); |
4354 | 4446 if (trigger_enter_autocmds) |
4447 { | |
4448 apply_autocmds(EVENT_WINENTER, NULL, NULL, FALSE, curbuf); | |
4449 if (other_buffer) | |
4450 apply_autocmds(EVENT_BUFENTER, NULL, NULL, FALSE, curbuf); | |
4451 } | |
7 | 4452 |
4453 #ifdef FEAT_TITLE | |
4454 maketitle(); | |
4455 #endif | |
4456 curwin->w_redr_status = TRUE; | |
672 | 4457 redraw_tabline = TRUE; |
7 | 4458 if (restart_edit) |
4459 redraw_later(VALID); /* causes status line redraw */ | |
4460 | |
4461 /* set window height to desired minimal value */ | |
4462 if (curwin->w_height < p_wh && !curwin->w_p_wfh) | |
4463 win_setheight((int)p_wh); | |
4464 else if (curwin->w_height == 0) | |
4465 win_setheight(1); | |
4466 | |
4467 /* set window width to desired minimal value */ | |
779 | 4468 if (curwin->w_width < p_wiw && !curwin->w_p_wfw) |
7 | 4469 win_setwidth((int)p_wiw); |
4470 | |
4471 #ifdef FEAT_MOUSE | |
4472 setmouse(); /* in case jumped to/from help buffer */ | |
4473 #endif | |
4474 | |
961 | 4475 /* 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
|
4476 DO_AUTOCHDIR; |
7 | 4477 } |
4478 | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
4479 |
7 | 4480 /* |
825 | 4481 * Jump to the first open window that contains buffer "buf", if one exists. |
4482 * Returns a pointer to the window found, otherwise NULL. | |
7 | 4483 */ |
4484 win_T * | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4485 buf_jump_open_win(buf_T *buf) |
7 | 4486 { |
6307 | 4487 win_T *wp = NULL; |
4488 | |
4489 if (curwin->w_buffer == buf) | |
4490 wp = curwin; | |
4491 else | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9599
diff
changeset
|
4492 FOR_ALL_WINDOWS(wp) |
6307 | 4493 if (wp->w_buffer == buf) |
4494 break; | |
7 | 4495 if (wp != NULL) |
4496 win_enter(wp, FALSE); | |
4497 return wp; | |
4498 } | |
825 | 4499 |
4500 /* | |
4501 * Jump to the first open window in any tab page that contains buffer "buf", | |
4502 * if one exists. | |
4503 * Returns a pointer to the window found, otherwise NULL. | |
4504 */ | |
4505 win_T * | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4506 buf_jump_open_tab(buf_T *buf) |
825 | 4507 { |
6307 | 4508 win_T *wp = buf_jump_open_win(buf); |
825 | 4509 tabpage_T *tp; |
4510 | |
4511 if (wp != NULL) | |
4512 return wp; | |
4513 | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9599
diff
changeset
|
4514 FOR_ALL_TABPAGES(tp) |
825 | 4515 if (tp != curtab) |
4516 { | |
4517 for (wp = tp->tp_firstwin; wp != NULL; wp = wp->w_next) | |
4518 if (wp->w_buffer == buf) | |
4519 break; | |
4520 if (wp != NULL) | |
4521 { | |
4522 goto_tabpage_win(tp, wp); | |
4523 if (curwin != wp) | |
4524 wp = NULL; /* something went wrong */ | |
4525 break; | |
4526 } | |
4527 } | |
4528 return wp; | |
4529 } | |
7 | 4530 |
9223
6c4d610fce0a
commit https://github.com/vim/vim/commit/888ccac8902cee186fbd47e971881f6d9b19c068
Christian Brabandt <cb@256bit.org>
parents:
9102
diff
changeset
|
4531 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
|
4532 |
7 | 4533 /* |
1906 | 4534 * Allocate a window structure and link it in the window list when "hidden" is |
4535 * FALSE. | |
7 | 4536 */ |
4537 static win_T * | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4538 win_alloc(win_T *after UNUSED, int hidden UNUSED) |
7 | 4539 { |
3263 | 4540 win_T *new_wp; |
7 | 4541 |
4542 /* | |
4543 * allocate window structure and linesizes arrays | |
4544 */ | |
3263 | 4545 new_wp = (win_T *)alloc_clear((unsigned)sizeof(win_T)); |
4287 | 4546 if (new_wp == NULL) |
4547 return NULL; | |
4548 | |
4549 if (win_alloc_lines(new_wp) == FAIL) | |
3263 | 4550 { |
4551 vim_free(new_wp); | |
4287 | 4552 return NULL; |
4553 } | |
4554 | |
8534
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
4555 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
|
4556 |
4287 | 4557 #ifdef FEAT_EVAL |
4558 /* init w: variables */ | |
4559 new_wp->w_vars = dict_alloc(); | |
4560 if (new_wp->w_vars == NULL) | |
4561 { | |
4562 win_free_lsize(new_wp); | |
4563 vim_free(new_wp); | |
4564 return NULL; | |
4565 } | |
4566 init_var_dict(new_wp->w_vars, &new_wp->w_winvar, VAR_SCOPE); | |
4567 #endif | |
4568 | |
4569 /* Don't execute autocommands while the window is not properly | |
4570 * initialized yet. gui_create_scrollbar() may trigger a FocusGained | |
4571 * event. */ | |
4572 block_autocmds(); | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13308
diff
changeset
|
4573 |
4287 | 4574 /* |
4575 * link the window in the window list | |
4576 */ | |
4577 if (!hidden) | |
4578 win_append(after, new_wp); | |
4579 new_wp->w_wincol = 0; | |
4580 new_wp->w_width = Columns; | |
4581 | |
4582 /* position the display and the cursor at the top of the file. */ | |
4583 new_wp->w_topline = 1; | |
7 | 4584 #ifdef FEAT_DIFF |
4287 | 4585 new_wp->w_topfill = 0; |
4586 #endif | |
4587 new_wp->w_botline = 2; | |
4588 new_wp->w_cursor.lnum = 1; | |
4589 new_wp->w_scbind_pos = 1; | |
4590 | |
15713
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15636
diff
changeset
|
4591 // 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
|
4592 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
|
4593 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
|
4594 |
4287 | 4595 /* We won't calculate w_fraction until resizing the window */ |
4596 new_wp->w_fraction = 0; | |
4597 new_wp->w_prev_fraction_row = -1; | |
7 | 4598 |
4599 #ifdef FEAT_GUI | |
4287 | 4600 if (gui.in_use) |
4601 { | |
4602 gui_create_scrollbar(&new_wp->w_scrollbars[SBAR_LEFT], | |
4603 SBAR_LEFT, new_wp); | |
4604 gui_create_scrollbar(&new_wp->w_scrollbars[SBAR_RIGHT], | |
4605 SBAR_RIGHT, new_wp); | |
4606 } | |
7 | 4607 #endif |
4608 #ifdef FEAT_FOLDING | |
4287 | 4609 foldInitWin(new_wp); |
7 | 4610 #endif |
4287 | 4611 unblock_autocmds(); |
1326 | 4612 #ifdef FEAT_SEARCH_EXTRA |
4287 | 4613 new_wp->w_match_head = NULL; |
4614 new_wp->w_next_match_id = 4; | |
4615 #endif | |
3263 | 4616 return new_wp; |
7 | 4617 } |
4618 | |
4619 /* | |
5237
647596ab1ae2
updated for version 7.4a.044
Bram Moolenaar <bram@vim.org>
parents:
5233
diff
changeset
|
4620 * Remove window 'wp' from the window list and free the structure. |
7 | 4621 */ |
4622 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4623 win_free( |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4624 win_T *wp, |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4625 tabpage_T *tp) /* tab page "win" is in, NULL for current */ |
7 | 4626 { |
4627 int i; | |
5237
647596ab1ae2
updated for version 7.4a.044
Bram Moolenaar <bram@vim.org>
parents:
5233
diff
changeset
|
4628 buf_T *buf; |
647596ab1ae2
updated for version 7.4a.044
Bram Moolenaar <bram@vim.org>
parents:
5233
diff
changeset
|
4629 wininfo_T *wip; |
7 | 4630 |
1918 | 4631 #ifdef FEAT_FOLDING |
4632 clearFolding(wp); | |
4633 #endif | |
4634 | |
4635 /* reduce the reference count to the argument list. */ | |
4636 alist_unlink(wp->w_alist); | |
4637 | |
1114 | 4638 /* Don't execute autocommands while the window is halfway being deleted. |
4639 * gui_mch_destroy_scrollbar() may trigger a FocusGained event. */ | |
1410 | 4640 block_autocmds(); |
1114 | 4641 |
2320
966a5609669e
Added Lua interfae. (Luis Carvalho)
Bram Moolenaar <bram@vim.org>
parents:
2316
diff
changeset
|
4642 #ifdef FEAT_LUA |
966a5609669e
Added Lua interfae. (Luis Carvalho)
Bram Moolenaar <bram@vim.org>
parents:
2316
diff
changeset
|
4643 lua_window_free(wp); |
966a5609669e
Added Lua interfae. (Luis Carvalho)
Bram Moolenaar <bram@vim.org>
parents:
2316
diff
changeset
|
4644 #endif |
966a5609669e
Added Lua interfae. (Luis Carvalho)
Bram Moolenaar <bram@vim.org>
parents:
2316
diff
changeset
|
4645 |
14 | 4646 #ifdef FEAT_MZSCHEME |
4647 mzscheme_window_free(wp); | |
4648 #endif | |
4649 | |
7 | 4650 #ifdef FEAT_PERL |
4651 perl_win_free(wp); | |
4652 #endif | |
4653 | |
4654 #ifdef FEAT_PYTHON | |
4655 python_window_free(wp); | |
4656 #endif | |
4657 | |
2329
ad2889f48843
Added support for Python 3. (Roland Puntaier)
Bram Moolenaar <bram@vim.org>
parents:
2320
diff
changeset
|
4658 #ifdef FEAT_PYTHON3 |
ad2889f48843
Added support for Python 3. (Roland Puntaier)
Bram Moolenaar <bram@vim.org>
parents:
2320
diff
changeset
|
4659 python3_window_free(wp); |
ad2889f48843
Added support for Python 3. (Roland Puntaier)
Bram Moolenaar <bram@vim.org>
parents:
2320
diff
changeset
|
4660 #endif |
ad2889f48843
Added support for Python 3. (Roland Puntaier)
Bram Moolenaar <bram@vim.org>
parents:
2320
diff
changeset
|
4661 |
7 | 4662 #ifdef FEAT_TCL |
4663 tcl_window_free(wp); | |
4664 #endif | |
4665 | |
4666 #ifdef FEAT_RUBY | |
4667 ruby_window_free(wp); | |
4668 #endif | |
4669 | |
4670 clear_winopt(&wp->w_onebuf_opt); | |
4671 clear_winopt(&wp->w_allbuf_opt); | |
4672 | |
4673 #ifdef FEAT_EVAL | |
4287 | 4674 vars_clear(&wp->w_vars->dv_hashtab); /* free all w: variables */ |
4675 hash_init(&wp->w_vars->dv_hashtab); | |
4676 unref_var_dict(wp->w_vars); | |
7 | 4677 #endif |
4678 | |
8833
dc10bd23f918
commit https://github.com/vim/vim/commit/3dda7db4e1f7c4a8110a1f83001ec36b46693d27
Christian Brabandt <cb@256bit.org>
parents:
8804
diff
changeset
|
4679 { |
dc10bd23f918
commit https://github.com/vim/vim/commit/3dda7db4e1f7c4a8110a1f83001ec36b46693d27
Christian Brabandt <cb@256bit.org>
parents:
8804
diff
changeset
|
4680 tabpage_T *ttp; |
dc10bd23f918
commit https://github.com/vim/vim/commit/3dda7db4e1f7c4a8110a1f83001ec36b46693d27
Christian Brabandt <cb@256bit.org>
parents:
8804
diff
changeset
|
4681 |
dc10bd23f918
commit https://github.com/vim/vim/commit/3dda7db4e1f7c4a8110a1f83001ec36b46693d27
Christian Brabandt <cb@256bit.org>
parents:
8804
diff
changeset
|
4682 if (prevwin == wp) |
dc10bd23f918
commit https://github.com/vim/vim/commit/3dda7db4e1f7c4a8110a1f83001ec36b46693d27
Christian Brabandt <cb@256bit.org>
parents:
8804
diff
changeset
|
4683 prevwin = NULL; |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9599
diff
changeset
|
4684 FOR_ALL_TABPAGES(ttp) |
8833
dc10bd23f918
commit https://github.com/vim/vim/commit/3dda7db4e1f7c4a8110a1f83001ec36b46693d27
Christian Brabandt <cb@256bit.org>
parents:
8804
diff
changeset
|
4685 if (ttp->tp_prevwin == wp) |
dc10bd23f918
commit https://github.com/vim/vim/commit/3dda7db4e1f7c4a8110a1f83001ec36b46693d27
Christian Brabandt <cb@256bit.org>
parents:
8804
diff
changeset
|
4686 ttp->tp_prevwin = NULL; |
dc10bd23f918
commit https://github.com/vim/vim/commit/3dda7db4e1f7c4a8110a1f83001ec36b46693d27
Christian Brabandt <cb@256bit.org>
parents:
8804
diff
changeset
|
4687 } |
7 | 4688 win_free_lsize(wp); |
4689 | |
4690 for (i = 0; i < wp->w_tagstacklen; ++i) | |
4691 vim_free(wp->w_tagstack[i].tagname); | |
4692 | |
4693 vim_free(wp->w_localdir); | |
1326 | 4694 |
5237
647596ab1ae2
updated for version 7.4a.044
Bram Moolenaar <bram@vim.org>
parents:
5233
diff
changeset
|
4695 /* Remove the window from the b_wininfo lists, it may happen that the |
647596ab1ae2
updated for version 7.4a.044
Bram Moolenaar <bram@vim.org>
parents:
5233
diff
changeset
|
4696 * 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
|
4697 FOR_ALL_BUFFERS(buf) |
5237
647596ab1ae2
updated for version 7.4a.044
Bram Moolenaar <bram@vim.org>
parents:
5233
diff
changeset
|
4698 for (wip = buf->b_wininfo; wip != NULL; wip = wip->wi_next) |
647596ab1ae2
updated for version 7.4a.044
Bram Moolenaar <bram@vim.org>
parents:
5233
diff
changeset
|
4699 if (wip->wi_win == wp) |
647596ab1ae2
updated for version 7.4a.044
Bram Moolenaar <bram@vim.org>
parents:
5233
diff
changeset
|
4700 wip->wi_win = NULL; |
647596ab1ae2
updated for version 7.4a.044
Bram Moolenaar <bram@vim.org>
parents:
5233
diff
changeset
|
4701 |
7 | 4702 #ifdef FEAT_SEARCH_EXTRA |
1326 | 4703 clear_matches(wp); |
4704 #endif | |
4705 | |
7 | 4706 #ifdef FEAT_JUMPLIST |
4707 free_jumplist(wp); | |
4708 #endif | |
4709 | |
643 | 4710 #ifdef FEAT_QUICKFIX |
4711 qf_free_all(wp); | |
4712 #endif | |
4713 | |
7 | 4714 #ifdef FEAT_GUI |
4715 if (gui.in_use) | |
4716 { | |
4717 gui_mch_destroy_scrollbar(&wp->w_scrollbars[SBAR_LEFT]); | |
4718 gui_mch_destroy_scrollbar(&wp->w_scrollbars[SBAR_RIGHT]); | |
4719 } | |
4720 #endif /* FEAT_GUI */ | |
4721 | |
12487
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
4722 #ifdef FEAT_MENU |
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
4723 remove_winbar(wp); |
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
4724 #endif |
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
4725 |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2201
diff
changeset
|
4726 #ifdef FEAT_SYN_HL |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2306
diff
changeset
|
4727 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
|
4728 #endif |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2201
diff
changeset
|
4729 |
1918 | 4730 if (wp != aucmd_win) |
4731 win_remove(wp, tp); | |
5958 | 4732 if (autocmd_busy) |
4733 { | |
4734 wp->w_next = au_pending_free_win; | |
4735 au_pending_free_win = wp; | |
4736 } | |
4737 else | |
4738 vim_free(wp); | |
1114 | 4739 |
1410 | 4740 unblock_autocmds(); |
7 | 4741 } |
4742 | |
4743 /* | |
4744 * Append window "wp" in the window list after window "after". | |
4745 */ | |
1906 | 4746 void |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4747 win_append(win_T *after, win_T *wp) |
7 | 4748 { |
4749 win_T *before; | |
4750 | |
4751 if (after == NULL) /* after NULL is in front of the first */ | |
4752 before = firstwin; | |
4753 else | |
4754 before = after->w_next; | |
4755 | |
4756 wp->w_next = before; | |
4757 wp->w_prev = after; | |
4758 if (after == NULL) | |
4759 firstwin = wp; | |
4760 else | |
4761 after->w_next = wp; | |
4762 if (before == NULL) | |
4763 lastwin = wp; | |
4764 else | |
4765 before->w_prev = wp; | |
4766 } | |
4767 | |
4768 /* | |
4769 * Remove a window from the window list. | |
4770 */ | |
1906 | 4771 void |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4772 win_remove( |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4773 win_T *wp, |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4774 tabpage_T *tp) /* tab page "win" is in, NULL for current */ |
7 | 4775 { |
4776 if (wp->w_prev != NULL) | |
4777 wp->w_prev->w_next = wp->w_next; | |
671 | 4778 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
|
4779 firstwin = curtab->tp_firstwin = wp->w_next; |
7 | 4780 else |
671 | 4781 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
|
4782 |
7 | 4783 if (wp->w_next != NULL) |
4784 wp->w_next->w_prev = wp->w_prev; | |
671 | 4785 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
|
4786 lastwin = curtab->tp_lastwin = wp->w_prev; |
7 | 4787 else |
671 | 4788 tp->tp_lastwin = wp->w_prev; |
7 | 4789 } |
4790 | |
4791 /* | |
4792 * Append frame "frp" in a frame list after frame "after". | |
4793 */ | |
4794 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4795 frame_append(frame_T *after, frame_T *frp) |
7 | 4796 { |
4797 frp->fr_next = after->fr_next; | |
4798 after->fr_next = frp; | |
4799 if (frp->fr_next != NULL) | |
4800 frp->fr_next->fr_prev = frp; | |
4801 frp->fr_prev = after; | |
4802 } | |
4803 | |
4804 /* | |
4805 * Insert frame "frp" in a frame list before frame "before". | |
4806 */ | |
4807 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4808 frame_insert(frame_T *before, frame_T *frp) |
7 | 4809 { |
4810 frp->fr_next = before; | |
4811 frp->fr_prev = before->fr_prev; | |
4812 before->fr_prev = frp; | |
4813 if (frp->fr_prev != NULL) | |
4814 frp->fr_prev->fr_next = frp; | |
4815 else | |
4816 frp->fr_parent->fr_child = frp; | |
4817 } | |
4818 | |
4819 /* | |
4820 * Remove a frame from a frame list. | |
4821 */ | |
4822 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4823 frame_remove(frame_T *frp) |
7 | 4824 { |
4825 if (frp->fr_prev != NULL) | |
4826 frp->fr_prev->fr_next = frp->fr_next; | |
4827 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
|
4828 { |
7 | 4829 frp->fr_parent->fr_child = frp->fr_next; |
13144
20fb8c711050
patch 8.0.1446: acessing freed memory after window command in auto command
Christian Brabandt <cb@256bit.org>
parents:
13103
diff
changeset
|
4830 /* special case: 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
|
4831 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
|
4832 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
|
4833 } |
7 | 4834 if (frp->fr_next != NULL) |
4835 frp->fr_next->fr_prev = frp->fr_prev; | |
4836 } | |
4837 | |
4838 /* | |
4839 * Allocate w_lines[] for window "wp". | |
4840 * Return FAIL for failure, OK for success. | |
4841 */ | |
4842 int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4843 win_alloc_lines(win_T *wp) |
7 | 4844 { |
4845 wp->w_lines_valid = 0; | |
1042 | 4846 wp->w_lines = (wline_T *)alloc_clear((unsigned)(Rows * sizeof(wline_T))); |
7 | 4847 if (wp->w_lines == NULL) |
4848 return FAIL; | |
4849 return OK; | |
4850 } | |
4851 | |
4852 /* | |
4853 * free lsize arrays for a window | |
4854 */ | |
4855 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4856 win_free_lsize(win_T *wp) |
7 | 4857 { |
5952 | 4858 /* TODO: why would wp be NULL here? */ |
4859 if (wp != NULL) | |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13144
diff
changeset
|
4860 VIM_CLEAR(wp->w_lines); |
7 | 4861 } |
4862 | |
4863 /* | |
4864 * Called from win_new_shellsize() after Rows changed. | |
671 | 4865 * This only does the current tab page, others must be done when made active. |
7 | 4866 */ |
4867 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4868 shell_new_rows(void) |
7 | 4869 { |
667 | 4870 int h = (int)ROWS_AVAIL; |
7 | 4871 |
4872 if (firstwin == NULL) /* not initialized yet */ | |
4873 return; | |
4874 if (h < frame_minheight(topframe, NULL)) | |
4875 h = frame_minheight(topframe, NULL); | |
779 | 4876 |
4877 /* First try setting the heights of windows with 'winfixheight'. If | |
7 | 4878 * that doesn't result in the right height, forget about that option. */ |
4879 frame_new_height(topframe, h, FALSE, TRUE); | |
5004
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
4880 if (!frame_check_height(topframe, h)) |
7 | 4881 frame_new_height(topframe, h, FALSE, FALSE); |
4882 | |
4883 (void)win_comp_pos(); /* recompute w_winrow and w_wincol */ | |
4884 compute_cmdrow(); | |
824 | 4885 curtab->tp_ch_used = p_ch; |
170 | 4886 |
7 | 4887 #if 0 |
4888 /* Disabled: don't want making the screen smaller make a window larger. */ | |
4889 if (p_ea) | |
4890 win_equal(curwin, FALSE, 'v'); | |
4891 #endif | |
4892 } | |
4893 | |
4894 /* | |
4895 * Called from win_new_shellsize() after Columns changed. | |
4896 */ | |
4897 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4898 shell_new_columns(void) |
7 | 4899 { |
4900 if (firstwin == NULL) /* not initialized yet */ | |
4901 return; | |
779 | 4902 |
4903 /* First try setting the widths of windows with 'winfixwidth'. If that | |
4904 * doesn't result in the right width, forget about that option. */ | |
4905 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
|
4906 if (!frame_check_width(topframe, Columns)) |
779 | 4907 frame_new_width(topframe, (int)Columns, FALSE, FALSE); |
4908 | |
7 | 4909 (void)win_comp_pos(); /* recompute w_winrow and w_wincol */ |
4910 #if 0 | |
4911 /* Disabled: don't want making the screen smaller make a window larger. */ | |
4912 if (p_ea) | |
4913 win_equal(curwin, FALSE, 'h'); | |
4914 #endif | |
4915 } | |
4916 | |
4917 #if defined(FEAT_CMDWIN) || defined(PROTO) | |
4918 /* | |
4919 * Save the size of all windows in "gap". | |
4920 */ | |
4921 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4922 win_size_save(garray_T *gap) |
7 | 4923 |
4924 { | |
4925 win_T *wp; | |
4926 | |
4927 ga_init2(gap, (int)sizeof(int), 1); | |
4928 if (ga_grow(gap, win_count() * 2) == OK) | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9599
diff
changeset
|
4929 FOR_ALL_WINDOWS(wp) |
7 | 4930 { |
4931 ((int *)gap->ga_data)[gap->ga_len++] = | |
4932 wp->w_width + wp->w_vsep_width; | |
4933 ((int *)gap->ga_data)[gap->ga_len++] = wp->w_height; | |
4934 } | |
4935 } | |
4936 | |
4937 /* | |
4938 * Restore window sizes, but only if the number of windows is still the same. | |
4939 * Does not free the growarray. | |
4940 */ | |
4941 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4942 win_size_restore(garray_T *gap) |
7 | 4943 { |
4944 win_T *wp; | |
6058 | 4945 int i, j; |
7 | 4946 |
4947 if (win_count() * 2 == gap->ga_len) | |
4948 { | |
6058 | 4949 /* The order matters, because frames contain other frames, but it's |
4950 * difficult to get right. The easy way out is to do it twice. */ | |
4951 for (j = 0; j < 2; ++j) | |
7 | 4952 { |
6058 | 4953 i = 0; |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9599
diff
changeset
|
4954 FOR_ALL_WINDOWS(wp) |
6058 | 4955 { |
4956 frame_setwidth(wp->w_frame, ((int *)gap->ga_data)[i++]); | |
4957 win_setheight_win(((int *)gap->ga_data)[i++], wp); | |
4958 } | |
7 | 4959 } |
4960 /* recompute the window positions */ | |
4961 (void)win_comp_pos(); | |
4962 } | |
4963 } | |
4964 #endif /* FEAT_CMDWIN */ | |
4965 | |
4966 /* | |
4967 * Update the position for all windows, using the width and height of the | |
4968 * frames. | |
4969 * Returns the row just after the last window. | |
4970 */ | |
668 | 4971 int |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4972 win_comp_pos(void) |
7 | 4973 { |
685 | 4974 int row = tabline_height(); |
7 | 4975 int col = 0; |
4976 | |
4977 frame_comp_pos(topframe, &row, &col); | |
4978 return row; | |
4979 } | |
4980 | |
4981 /* | |
4982 * Update the position of the windows in frame "topfrp", using the width and | |
4983 * height of the frames. | |
4984 * "*row" and "*col" are the top-left position of the frame. They are updated | |
4985 * to the bottom-right position plus one. | |
4986 */ | |
4987 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4988 frame_comp_pos(frame_T *topfrp, int *row, int *col) |
7 | 4989 { |
4990 win_T *wp; | |
4991 frame_T *frp; | |
4992 int startcol; | |
4993 int startrow; | |
12998
dd734ee3e2fe
patch 8.0.1375: window size wrong after maximizing with WinBar
Christian Brabandt <cb@256bit.org>
parents:
12916
diff
changeset
|
4994 int h; |
7 | 4995 |
4996 wp = topfrp->fr_win; | |
4997 if (wp != NULL) | |
4998 { | |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8536
diff
changeset
|
4999 if (wp->w_winrow != *row || wp->w_wincol != *col) |
7 | 5000 { |
5001 /* position changed, redraw */ | |
5002 wp->w_winrow = *row; | |
5003 wp->w_wincol = *col; | |
5004 redraw_win_later(wp, NOT_VALID); | |
5005 wp->w_redr_status = TRUE; | |
5006 } | |
12998
dd734ee3e2fe
patch 8.0.1375: window size wrong after maximizing with WinBar
Christian Brabandt <cb@256bit.org>
parents:
12916
diff
changeset
|
5007 /* WinBar will not show if the window height is zero */ |
dd734ee3e2fe
patch 8.0.1375: window size wrong after maximizing with WinBar
Christian Brabandt <cb@256bit.org>
parents:
12916
diff
changeset
|
5008 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
|
5009 *row += h > topfrp->fr_height ? topfrp->fr_height : h; |
7 | 5010 *col += wp->w_width + wp->w_vsep_width; |
5011 } | |
5012 else | |
5013 { | |
5014 startrow = *row; | |
5015 startcol = *col; | |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
5016 FOR_ALL_FRAMES(frp, topfrp->fr_child) |
7 | 5017 { |
5018 if (topfrp->fr_layout == FR_ROW) | |
5019 *row = startrow; /* all frames are at the same row */ | |
5020 else | |
5021 *col = startcol; /* all frames are at the same col */ | |
5022 frame_comp_pos(frp, row, col); | |
5023 } | |
5024 } | |
5025 } | |
5026 | |
5027 /* | |
5028 * Set current window height and take care of repositioning other windows to | |
5029 * fit around it. | |
5030 */ | |
5031 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5032 win_setheight(int height) |
7 | 5033 { |
5034 win_setheight_win(height, curwin); | |
5035 } | |
5036 | |
5037 /* | |
5038 * Set the window height of window "win" and take care of repositioning other | |
5039 * windows to fit around it. | |
5040 */ | |
5041 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5042 win_setheight_win(int height, win_T *win) |
7 | 5043 { |
5044 int row; | |
5045 | |
5046 if (win == curwin) | |
5047 { | |
5048 /* Always keep current window at least one line high, even when | |
5049 * 'winminheight' is zero. */ | |
5050 if (height < p_wmh) | |
5051 height = p_wmh; | |
5052 if (height == 0) | |
5053 height = 1; | |
12998
dd734ee3e2fe
patch 8.0.1375: window size wrong after maximizing with WinBar
Christian Brabandt <cb@256bit.org>
parents:
12916
diff
changeset
|
5054 height += WINBAR_HEIGHT(curwin); |
7 | 5055 } |
5056 | |
5057 frame_setheight(win->w_frame, height + win->w_status_height); | |
5058 | |
5059 /* recompute the window positions */ | |
5060 row = win_comp_pos(); | |
5061 | |
5062 /* | |
5063 * If there is extra space created between the last window and the command | |
5064 * line, clear it. | |
5065 */ | |
5066 if (full_screen && msg_scrolled == 0 && row < cmdline_row) | |
5067 screen_fill(row, cmdline_row, 0, (int)Columns, ' ', ' ', 0); | |
5068 cmdline_row = row; | |
5069 msg_row = row; | |
5070 msg_col = 0; | |
5071 | |
5072 redraw_all_later(NOT_VALID); | |
5073 } | |
5074 | |
5075 /* | |
5076 * Set the height of a frame to "height" and take care that all frames and | |
5077 * windows inside it are resized. Also resize frames on the left and right if | |
5078 * the are in the same FR_ROW frame. | |
5079 * | |
5080 * Strategy: | |
5081 * If the frame is part of a FR_COL frame, try fitting the frame in that | |
5082 * frame. If that doesn't work (the FR_COL frame is too small), recursively | |
5083 * go to containing frames to resize them and make room. | |
5084 * If the frame is part of a FR_ROW frame, all frames must be resized as well. | |
5085 * Check for the minimal height of the FR_ROW frame. | |
5086 * At the top level we can also use change the command line height. | |
5087 */ | |
5088 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5089 frame_setheight(frame_T *curfrp, int height) |
7 | 5090 { |
5091 int room; /* total number of lines available */ | |
5092 int take; /* number of lines taken from other windows */ | |
5093 int room_cmdline; /* lines available from cmdline */ | |
5094 int run; | |
5095 frame_T *frp; | |
5096 int h; | |
5097 int room_reserved; | |
5098 | |
5099 /* If the height already is the desired value, nothing to do. */ | |
5100 if (curfrp->fr_height == height) | |
5101 return; | |
5102 | |
5103 if (curfrp->fr_parent == NULL) | |
5104 { | |
5105 /* topframe: can only change the command line */ | |
667 | 5106 if (height > ROWS_AVAIL) |
5107 height = ROWS_AVAIL; | |
7 | 5108 if (height > 0) |
5109 frame_new_height(curfrp, height, FALSE, FALSE); | |
5110 } | |
5111 else if (curfrp->fr_parent->fr_layout == FR_ROW) | |
5112 { | |
5113 /* Row of frames: Also need to resize frames left and right of this | |
5114 * one. First check for the minimal height of these. */ | |
5115 h = frame_minheight(curfrp->fr_parent, NULL); | |
5116 if (height < h) | |
5117 height = h; | |
5118 frame_setheight(curfrp->fr_parent, height); | |
5119 } | |
5120 else | |
5121 { | |
5122 /* | |
5123 * Column of frames: try to change only frames in this column. | |
5124 */ | |
5125 /* | |
5126 * Do this twice: | |
5127 * 1: compute room available, if it's not enough try resizing the | |
5128 * containing frame. | |
5129 * 2: compute the room available and adjust the height to it. | |
5130 * Try not to reduce the height of a window with 'winfixheight' set. | |
5131 */ | |
5132 for (run = 1; run <= 2; ++run) | |
5133 { | |
5134 room = 0; | |
5135 room_reserved = 0; | |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
5136 FOR_ALL_FRAMES(frp, curfrp->fr_parent->fr_child) |
7 | 5137 { |
5138 if (frp != curfrp | |
5139 && frp->fr_win != NULL | |
5140 && frp->fr_win->w_p_wfh) | |
5141 room_reserved += frp->fr_height; | |
5142 room += frp->fr_height; | |
5143 if (frp != curfrp) | |
5144 room -= frame_minheight(frp, NULL); | |
5145 } | |
5146 if (curfrp->fr_width != Columns) | |
5147 room_cmdline = 0; | |
5148 else | |
5149 { | |
5150 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
|
5151 + VISIBLE_HEIGHT(lastwin) |
dd734ee3e2fe
patch 8.0.1375: window size wrong after maximizing with WinBar
Christian Brabandt <cb@256bit.org>
parents:
12916
diff
changeset
|
5152 + lastwin->w_status_height); |
7 | 5153 if (room_cmdline < 0) |
5154 room_cmdline = 0; | |
5155 } | |
5156 | |
5157 if (height <= room + room_cmdline) | |
5158 break; | |
5159 if (run == 2 || curfrp->fr_width == Columns) | |
5160 { | |
5161 if (height > room + room_cmdline) | |
5162 height = room + room_cmdline; | |
5163 break; | |
5164 } | |
5165 frame_setheight(curfrp->fr_parent, height | |
5166 + frame_minheight(curfrp->fr_parent, NOWIN) - (int)p_wmh - 1); | |
5167 } | |
5168 | |
5169 /* | |
5170 * Compute the number of lines we will take from others frames (can be | |
5171 * negative!). | |
5172 */ | |
5173 take = height - curfrp->fr_height; | |
5174 | |
5175 /* If there is not enough room, also reduce the height of a window | |
5176 * with 'winfixheight' set. */ | |
5177 if (height > room + room_cmdline - room_reserved) | |
5178 room_reserved = room + room_cmdline - height; | |
5179 /* If there is only a 'winfixheight' window and making the | |
5180 * window smaller, need to make the other window taller. */ | |
5181 if (take < 0 && room - curfrp->fr_height < room_reserved) | |
5182 room_reserved = 0; | |
5183 | |
5184 if (take > 0 && room_cmdline > 0) | |
5185 { | |
5186 /* use lines from cmdline first */ | |
5187 if (take < room_cmdline) | |
5188 room_cmdline = take; | |
5189 take -= room_cmdline; | |
5190 topframe->fr_height += room_cmdline; | |
5191 } | |
5192 | |
5193 /* | |
5194 * set the current frame to the new height | |
5195 */ | |
5196 frame_new_height(curfrp, height, FALSE, FALSE); | |
5197 | |
5198 /* | |
5199 * First take lines from the frames after the current frame. If | |
5200 * that is not enough, takes lines from frames above the current | |
5201 * frame. | |
5202 */ | |
5203 for (run = 0; run < 2; ++run) | |
5204 { | |
5205 if (run == 0) | |
5206 frp = curfrp->fr_next; /* 1st run: start with next window */ | |
5207 else | |
5208 frp = curfrp->fr_prev; /* 2nd run: start with prev window */ | |
5209 while (frp != NULL && take != 0) | |
5210 { | |
5211 h = frame_minheight(frp, NULL); | |
5212 if (room_reserved > 0 | |
5213 && frp->fr_win != NULL | |
5214 && frp->fr_win->w_p_wfh) | |
5215 { | |
5216 if (room_reserved >= frp->fr_height) | |
5217 room_reserved -= frp->fr_height; | |
5218 else | |
5219 { | |
5220 if (frp->fr_height - room_reserved > take) | |
5221 room_reserved = frp->fr_height - take; | |
5222 take -= frp->fr_height - room_reserved; | |
5223 frame_new_height(frp, room_reserved, FALSE, FALSE); | |
5224 room_reserved = 0; | |
5225 } | |
5226 } | |
5227 else | |
5228 { | |
5229 if (frp->fr_height - take < h) | |
5230 { | |
5231 take -= frp->fr_height - h; | |
5232 frame_new_height(frp, h, FALSE, FALSE); | |
5233 } | |
5234 else | |
5235 { | |
5236 frame_new_height(frp, frp->fr_height - take, | |
5237 FALSE, FALSE); | |
5238 take = 0; | |
5239 } | |
5240 } | |
5241 if (run == 0) | |
5242 frp = frp->fr_next; | |
5243 else | |
5244 frp = frp->fr_prev; | |
5245 } | |
5246 } | |
5247 } | |
5248 } | |
5249 | |
5250 /* | |
5251 * Set current window width and take care of repositioning other windows to | |
5252 * fit around it. | |
5253 */ | |
5254 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5255 win_setwidth(int width) |
7 | 5256 { |
5257 win_setwidth_win(width, curwin); | |
5258 } | |
5259 | |
5260 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5261 win_setwidth_win(int width, win_T *wp) |
7 | 5262 { |
5263 /* Always keep current window at least one column wide, even when | |
5264 * 'winminwidth' is zero. */ | |
5265 if (wp == curwin) | |
5266 { | |
5267 if (width < p_wmw) | |
5268 width = p_wmw; | |
5269 if (width == 0) | |
5270 width = 1; | |
5271 } | |
5272 | |
5273 frame_setwidth(wp->w_frame, width + wp->w_vsep_width); | |
5274 | |
5275 /* recompute the window positions */ | |
5276 (void)win_comp_pos(); | |
5277 | |
5278 redraw_all_later(NOT_VALID); | |
5279 } | |
5280 | |
5281 /* | |
5282 * Set the width of a frame to "width" and take care that all frames and | |
5283 * windows inside it are resized. Also resize frames above and below if the | |
5284 * are in the same FR_ROW frame. | |
5285 * | |
5286 * Strategy is similar to frame_setheight(). | |
5287 */ | |
5288 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5289 frame_setwidth(frame_T *curfrp, int width) |
7 | 5290 { |
5291 int room; /* total number of lines available */ | |
5292 int take; /* number of lines taken from other windows */ | |
5293 int run; | |
5294 frame_T *frp; | |
5295 int w; | |
779 | 5296 int room_reserved; |
7 | 5297 |
5298 /* If the width already is the desired value, nothing to do. */ | |
5299 if (curfrp->fr_width == width) | |
5300 return; | |
5301 | |
5302 if (curfrp->fr_parent == NULL) | |
5303 /* topframe: can't change width */ | |
5304 return; | |
5305 | |
5306 if (curfrp->fr_parent->fr_layout == FR_COL) | |
5307 { | |
5308 /* Column of frames: Also need to resize frames above and below of | |
5309 * this one. First check for the minimal width of these. */ | |
5310 w = frame_minwidth(curfrp->fr_parent, NULL); | |
5311 if (width < w) | |
5312 width = w; | |
5313 frame_setwidth(curfrp->fr_parent, width); | |
5314 } | |
5315 else | |
5316 { | |
5317 /* | |
5318 * Row of frames: try to change only frames in this row. | |
5319 * | |
5320 * Do this twice: | |
5321 * 1: compute room available, if it's not enough try resizing the | |
5322 * containing frame. | |
5323 * 2: compute the room available and adjust the width to it. | |
5324 */ | |
5325 for (run = 1; run <= 2; ++run) | |
5326 { | |
5327 room = 0; | |
779 | 5328 room_reserved = 0; |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
5329 FOR_ALL_FRAMES(frp, curfrp->fr_parent->fr_child) |
7 | 5330 { |
779 | 5331 if (frp != curfrp |
5332 && frp->fr_win != NULL | |
5333 && frp->fr_win->w_p_wfw) | |
5334 room_reserved += frp->fr_width; | |
7 | 5335 room += frp->fr_width; |
5336 if (frp != curfrp) | |
5337 room -= frame_minwidth(frp, NULL); | |
5338 } | |
5339 | |
5340 if (width <= room) | |
5341 break; | |
667 | 5342 if (run == 2 || curfrp->fr_height >= ROWS_AVAIL) |
7 | 5343 { |
5344 if (width > room) | |
5345 width = room; | |
5346 break; | |
5347 } | |
5348 frame_setwidth(curfrp->fr_parent, width | |
5349 + frame_minwidth(curfrp->fr_parent, NOWIN) - (int)p_wmw - 1); | |
5350 } | |
5351 | |
5352 /* | |
5353 * Compute the number of lines we will take from others frames (can be | |
5354 * negative!). | |
5355 */ | |
5356 take = width - curfrp->fr_width; | |
5357 | |
779 | 5358 /* If there is not enough room, also reduce the width of a window |
5359 * with 'winfixwidth' set. */ | |
5360 if (width > room - room_reserved) | |
5361 room_reserved = room - width; | |
5362 /* If there is only a 'winfixwidth' window and making the | |
5363 * window smaller, need to make the other window narrower. */ | |
5364 if (take < 0 && room - curfrp->fr_width < room_reserved) | |
5365 room_reserved = 0; | |
5366 | |
7 | 5367 /* |
5368 * set the current frame to the new width | |
5369 */ | |
779 | 5370 frame_new_width(curfrp, width, FALSE, FALSE); |
7 | 5371 |
5372 /* | |
5373 * First take lines from the frames right of the current frame. If | |
5374 * that is not enough, takes lines from frames left of the current | |
5375 * frame. | |
5376 */ | |
5377 for (run = 0; run < 2; ++run) | |
5378 { | |
5379 if (run == 0) | |
5380 frp = curfrp->fr_next; /* 1st run: start with next window */ | |
5381 else | |
5382 frp = curfrp->fr_prev; /* 2nd run: start with prev window */ | |
5383 while (frp != NULL && take != 0) | |
5384 { | |
5385 w = frame_minwidth(frp, NULL); | |
779 | 5386 if (room_reserved > 0 |
5387 && frp->fr_win != NULL | |
5388 && frp->fr_win->w_p_wfw) | |
7 | 5389 { |
779 | 5390 if (room_reserved >= frp->fr_width) |
5391 room_reserved -= frp->fr_width; | |
5392 else | |
5393 { | |
5394 if (frp->fr_width - room_reserved > take) | |
5395 room_reserved = frp->fr_width - take; | |
5396 take -= frp->fr_width - room_reserved; | |
5397 frame_new_width(frp, room_reserved, FALSE, FALSE); | |
5398 room_reserved = 0; | |
5399 } | |
7 | 5400 } |
5401 else | |
5402 { | |
779 | 5403 if (frp->fr_width - take < w) |
5404 { | |
5405 take -= frp->fr_width - w; | |
5406 frame_new_width(frp, w, FALSE, FALSE); | |
5407 } | |
5408 else | |
5409 { | |
5410 frame_new_width(frp, frp->fr_width - take, | |
5411 FALSE, FALSE); | |
5412 take = 0; | |
5413 } | |
7 | 5414 } |
5415 if (run == 0) | |
5416 frp = frp->fr_next; | |
5417 else | |
5418 frp = frp->fr_prev; | |
5419 } | |
5420 } | |
5421 } | |
5422 } | |
5423 | |
5424 /* | |
14057
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
5425 * Check 'winminheight' for a valid value and reduce it if needed. |
7 | 5426 */ |
5427 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5428 win_setminheight(void) |
7 | 5429 { |
5430 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
|
5431 int needed; |
7 | 5432 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
|
5433 |
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
5434 // loop until there is a 'winminheight' that is possible |
7 | 5435 while (p_wmh > 0) |
5436 { | |
14057
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
5437 room = Rows - p_ch; |
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
5438 needed = frame_minheight(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
|
5439 if (room >= needed) |
7 | 5440 break; |
5441 --p_wmh; | |
5442 if (first) | |
5443 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15436
diff
changeset
|
5444 emsg(_(e_noroom)); |
7 | 5445 first = FALSE; |
5446 } | |
5447 } | |
5448 } | |
5449 | |
14057
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
5450 /* |
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
5451 * 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
|
5452 */ |
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
5453 void |
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
5454 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
|
5455 { |
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
5456 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
|
5457 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
|
5458 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
|
5459 |
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
5460 // 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
|
5461 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
|
5462 { |
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
5463 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
|
5464 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
|
5465 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
|
5466 break; |
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
5467 --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
|
5468 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
|
5469 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15436
diff
changeset
|
5470 emsg(_(e_noroom)); |
14057
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
5471 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
|
5472 } |
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
5473 } |
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
5474 } |
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
5475 |
7229
ae360f1df2aa
commit https://github.com/vim/vim/commit/6a2697ffd7e894861853b351689b0ddec8901c96
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
5476 #if defined(FEAT_MOUSE) || defined(PROTO) |
7 | 5477 |
5478 /* | |
5479 * Status line of dragwin is dragged "offset" lines down (negative is up). | |
5480 */ | |
5481 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5482 win_drag_status_line(win_T *dragwin, int offset) |
7 | 5483 { |
5484 frame_T *curfr; | |
5485 frame_T *fr; | |
5486 int room; | |
5487 int row; | |
5488 int up; /* if TRUE, drag status line up, otherwise down */ | |
5489 int n; | |
5490 | |
5491 fr = dragwin->w_frame; | |
5492 curfr = fr; | |
5493 if (fr != topframe) /* more than one window */ | |
5494 { | |
5495 fr = fr->fr_parent; | |
5496 /* When the parent frame is not a column of frames, its parent should | |
5497 * be. */ | |
5498 if (fr->fr_layout != FR_COL) | |
5499 { | |
5500 curfr = fr; | |
5501 if (fr != topframe) /* only a row of windows, may drag statusline */ | |
5502 fr = fr->fr_parent; | |
5503 } | |
5504 } | |
5505 | |
5506 /* If this is the last frame in a column, may want to resize the parent | |
5507 * frame instead (go two up to skip a row of frames). */ | |
5508 while (curfr != topframe && curfr->fr_next == NULL) | |
5509 { | |
5510 if (fr != topframe) | |
5511 fr = fr->fr_parent; | |
5512 curfr = fr; | |
5513 if (fr != topframe) | |
5514 fr = fr->fr_parent; | |
5515 } | |
5516 | |
5517 if (offset < 0) /* drag up */ | |
5518 { | |
5519 up = TRUE; | |
5520 offset = -offset; | |
5521 /* sum up the room of the current frame and above it */ | |
5522 if (fr == curfr) | |
5523 { | |
5524 /* only one window */ | |
5525 room = fr->fr_height - frame_minheight(fr, NULL); | |
5526 } | |
5527 else | |
5528 { | |
5529 room = 0; | |
5530 for (fr = fr->fr_child; ; fr = fr->fr_next) | |
5531 { | |
5532 room += fr->fr_height - frame_minheight(fr, NULL); | |
5533 if (fr == curfr) | |
5534 break; | |
5535 } | |
5536 } | |
5537 fr = curfr->fr_next; /* put fr at frame that grows */ | |
5538 } | |
5539 else /* drag down */ | |
5540 { | |
5541 up = FALSE; | |
5542 /* | |
5543 * Only dragging the last status line can reduce p_ch. | |
5544 */ | |
5545 room = Rows - cmdline_row; | |
5546 if (curfr->fr_next == NULL) | |
5547 room -= 1; | |
5548 else | |
5549 room -= p_ch; | |
5550 if (room < 0) | |
5551 room = 0; | |
5552 /* 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
|
5553 FOR_ALL_FRAMES(fr, curfr->fr_next) |
7 | 5554 room += fr->fr_height - frame_minheight(fr, NULL); |
5555 fr = curfr; /* put fr at window that grows */ | |
5556 } | |
5557 | |
5558 if (room < offset) /* Not enough room */ | |
5559 offset = room; /* Move as far as we can */ | |
5560 if (offset <= 0) | |
5561 return; | |
5562 | |
5563 /* | |
5564 * Grow frame fr by "offset" lines. | |
5565 * Doesn't happen when dragging the last status line up. | |
5566 */ | |
5567 if (fr != NULL) | |
5568 frame_new_height(fr, fr->fr_height + offset, up, FALSE); | |
5569 | |
5570 if (up) | |
5571 fr = curfr; /* current frame gets smaller */ | |
5572 else | |
5573 fr = curfr->fr_next; /* next frame gets smaller */ | |
5574 | |
5575 /* | |
5576 * Now make the other frames smaller. | |
5577 */ | |
5578 while (fr != NULL && offset > 0) | |
5579 { | |
5580 n = frame_minheight(fr, NULL); | |
5581 if (fr->fr_height - offset <= n) | |
5582 { | |
5583 offset -= fr->fr_height - n; | |
5584 frame_new_height(fr, n, !up, FALSE); | |
5585 } | |
5586 else | |
5587 { | |
5588 frame_new_height(fr, fr->fr_height - offset, !up, FALSE); | |
5589 break; | |
5590 } | |
5591 if (up) | |
5592 fr = fr->fr_prev; | |
5593 else | |
5594 fr = fr->fr_next; | |
5595 } | |
5596 row = win_comp_pos(); | |
5597 screen_fill(row, cmdline_row, 0, (int)Columns, ' ', ' ', 0); | |
5598 cmdline_row = row; | |
5599 p_ch = Rows - cmdline_row; | |
5600 if (p_ch < 1) | |
5601 p_ch = 1; | |
824 | 5602 curtab->tp_ch_used = p_ch; |
737 | 5603 redraw_all_later(SOME_VALID); |
7 | 5604 showmode(); |
5605 } | |
5606 | |
5607 /* | |
5608 * Separator line of dragwin is dragged "offset" lines right (negative is left). | |
5609 */ | |
5610 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5611 win_drag_vsep_line(win_T *dragwin, int offset) |
7 | 5612 { |
5613 frame_T *curfr; | |
5614 frame_T *fr; | |
5615 int room; | |
5616 int left; /* if TRUE, drag separator line left, otherwise right */ | |
5617 int n; | |
5618 | |
5619 fr = dragwin->w_frame; | |
840 | 5620 if (fr == topframe) /* only one window (cannot happen?) */ |
7 | 5621 return; |
5622 curfr = fr; | |
5623 fr = fr->fr_parent; | |
5624 /* When the parent frame is not a row of frames, its parent should be. */ | |
5625 if (fr->fr_layout != FR_ROW) | |
5626 { | |
5627 if (fr == topframe) /* only a column of windows (cannot happen?) */ | |
5628 return; | |
5629 curfr = fr; | |
5630 fr = fr->fr_parent; | |
5631 } | |
5632 | |
5633 /* If this is the last frame in a row, may want to resize a parent | |
5634 * frame instead. */ | |
5635 while (curfr->fr_next == NULL) | |
5636 { | |
5637 if (fr == topframe) | |
5638 break; | |
5639 curfr = fr; | |
5640 fr = fr->fr_parent; | |
5641 if (fr != topframe) | |
5642 { | |
5643 curfr = fr; | |
5644 fr = fr->fr_parent; | |
5645 } | |
5646 } | |
5647 | |
5648 if (offset < 0) /* drag left */ | |
5649 { | |
5650 left = TRUE; | |
5651 offset = -offset; | |
5652 /* sum up the room of the current frame and left of it */ | |
5653 room = 0; | |
5654 for (fr = fr->fr_child; ; fr = fr->fr_next) | |
5655 { | |
5656 room += fr->fr_width - frame_minwidth(fr, NULL); | |
5657 if (fr == curfr) | |
5658 break; | |
5659 } | |
5660 fr = curfr->fr_next; /* put fr at frame that grows */ | |
5661 } | |
5662 else /* drag right */ | |
5663 { | |
5664 left = FALSE; | |
5665 /* sum up the room of frames right of the current one */ | |
5666 room = 0; | |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
5667 FOR_ALL_FRAMES(fr, curfr->fr_next) |
7 | 5668 room += fr->fr_width - frame_minwidth(fr, NULL); |
5669 fr = curfr; /* put fr at window that grows */ | |
5670 } | |
5671 | |
5672 if (room < offset) /* Not enough room */ | |
5673 offset = room; /* Move as far as we can */ | |
5674 if (offset <= 0) /* No room at all, quit. */ | |
5675 return; | |
7256
79270eaac6de
commit https://github.com/vim/vim/commit/294a7e55b01149154807a23323038784549b8946
Christian Brabandt <cb@256bit.org>
parents:
7229
diff
changeset
|
5676 if (fr == NULL) |
79270eaac6de
commit https://github.com/vim/vim/commit/294a7e55b01149154807a23323038784549b8946
Christian Brabandt <cb@256bit.org>
parents:
7229
diff
changeset
|
5677 return; /* Safety check, should not happen. */ |
7 | 5678 |
5679 /* grow frame fr by offset lines */ | |
779 | 5680 frame_new_width(fr, fr->fr_width + offset, left, FALSE); |
7 | 5681 |
5682 /* shrink other frames: current and at the left or at the right */ | |
5683 if (left) | |
5684 fr = curfr; /* current frame gets smaller */ | |
5685 else | |
5686 fr = curfr->fr_next; /* next frame gets smaller */ | |
5687 | |
5688 while (fr != NULL && offset > 0) | |
5689 { | |
5690 n = frame_minwidth(fr, NULL); | |
5691 if (fr->fr_width - offset <= n) | |
5692 { | |
5693 offset -= fr->fr_width - n; | |
779 | 5694 frame_new_width(fr, n, !left, FALSE); |
7 | 5695 } |
5696 else | |
5697 { | |
779 | 5698 frame_new_width(fr, fr->fr_width - offset, !left, FALSE); |
7 | 5699 break; |
5700 } | |
5701 if (left) | |
5702 fr = fr->fr_prev; | |
5703 else | |
5704 fr = fr->fr_next; | |
5705 } | |
5706 (void)win_comp_pos(); | |
5707 redraw_all_later(NOT_VALID); | |
5708 } | |
5709 #endif /* FEAT_MOUSE */ | |
5710 | |
2665 | 5711 #define FRACTION_MULT 16384L |
5712 | |
5713 /* | |
5714 * 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
|
5715 * Has no effect when the window is less than two lines. |
2665 | 5716 */ |
7311
743c258ca3ab
commit https://github.com/vim/vim/commit/9dc2ce398bb3456cc8f590ef0260459798b34d2a
Christian Brabandt <cb@256bit.org>
parents:
7256
diff
changeset
|
5717 void |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5718 set_fraction(win_T *wp) |
2665 | 5719 { |
12910
d21adefd4a50
patch 8.0.1331: possible crash when window can be zero lines high
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
5720 if (wp->w_height > 1) |
d21adefd4a50
patch 8.0.1331: possible crash when window can be zero lines high
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
5721 wp->w_fraction = ((long)wp->w_wrow * FRACTION_MULT |
5875 | 5722 + wp->w_height / 2) / (long)wp->w_height; |
2665 | 5723 } |
5724 | |
7 | 5725 /* |
5726 * 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
|
5727 * "height" excludes any window toolbar. |
7 | 5728 * This takes care of the things inside the window, not what happens to the |
5729 * window position, the frame or to other windows. | |
5730 */ | |
3697 | 5731 void |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5732 win_new_height(win_T *wp, int height) |
7 | 5733 { |
5875 | 5734 int prev_height = wp->w_height; |
7 | 5735 |
5736 /* Don't want a negative height. Happens when splitting a tiny window. | |
5737 * Will equalize heights soon to fix it. */ | |
5738 if (height < 0) | |
5739 height = 0; | |
826 | 5740 if (wp->w_height == height) |
5741 return; /* nothing to do */ | |
7 | 5742 |
5875 | 5743 if (wp->w_height > 0) |
5744 { | |
5745 if (wp == curwin) | |
5969 | 5746 /* w_wrow needs to be valid. When setting 'laststatus' this may |
5747 * call win_new_height() recursively. */ | |
5748 validate_cursor(); | |
5749 if (wp->w_height != prev_height) | |
5750 return; /* Recursive call already changed the size, bail out here | |
5751 to avoid the following to mess things up. */ | |
5875 | 5752 if (wp->w_wrow != wp->w_prev_fraction_row) |
5753 set_fraction(wp); | |
5754 } | |
7 | 5755 |
5756 wp->w_height = height; | |
5757 wp->w_skipcol = 0; | |
5758 | |
10835
c9da7f9137af
patch 8.0.0307: asan detects a memory error when EXITFREE is defined
Christian Brabandt <cb@256bit.org>
parents:
10377
diff
changeset
|
5759 /* There is no point in adjusting the scroll position when exiting. Some |
c9da7f9137af
patch 8.0.0307: asan detects a memory error when EXITFREE is defined
Christian Brabandt <cb@256bit.org>
parents:
10377
diff
changeset
|
5760 * values might be invalid. */ |
c9da7f9137af
patch 8.0.0307: asan detects a memory error when EXITFREE is defined
Christian Brabandt <cb@256bit.org>
parents:
10377
diff
changeset
|
5761 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
|
5762 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
|
5763 } |
942d40a92be6
commit https://github.com/vim/vim/commit/46328f9a1cc8047d1e05095bc9f531038c5a4028
Christian Brabandt <cb@256bit.org>
parents:
9953
diff
changeset
|
5764 |
942d40a92be6
commit https://github.com/vim/vim/commit/46328f9a1cc8047d1e05095bc9f531038c5a4028
Christian Brabandt <cb@256bit.org>
parents:
9953
diff
changeset
|
5765 void |
942d40a92be6
commit https://github.com/vim/vim/commit/46328f9a1cc8047d1e05095bc9f531038c5a4028
Christian Brabandt <cb@256bit.org>
parents:
9953
diff
changeset
|
5766 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
|
5767 { |
942d40a92be6
commit https://github.com/vim/vim/commit/46328f9a1cc8047d1e05095bc9f531038c5a4028
Christian Brabandt <cb@256bit.org>
parents:
9953
diff
changeset
|
5768 linenr_T lnum; |
942d40a92be6
commit https://github.com/vim/vim/commit/46328f9a1cc8047d1e05095bc9f531038c5a4028
Christian Brabandt <cb@256bit.org>
parents:
9953
diff
changeset
|
5769 int sline, line_size; |
942d40a92be6
commit https://github.com/vim/vim/commit/46328f9a1cc8047d1e05095bc9f531038c5a4028
Christian Brabandt <cb@256bit.org>
parents:
9953
diff
changeset
|
5770 int height = wp->w_height; |
942d40a92be6
commit https://github.com/vim/vim/commit/46328f9a1cc8047d1e05095bc9f531038c5a4028
Christian Brabandt <cb@256bit.org>
parents:
9953
diff
changeset
|
5771 |
7 | 5772 /* Don't change w_topline when height is zero. Don't set w_topline when |
5773 * 'scrollbind' is set and this isn't the current window. */ | |
13384
6740c499de13
patch 8.0.1566: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13380
diff
changeset
|
5774 if (height > 0 && (!wp->w_p_scb || wp == curwin)) |
7 | 5775 { |
47 | 5776 /* |
5777 * Find a value for w_topline that shows the cursor at the same | |
5778 * relative position in the window as before (more or less). | |
5779 */ | |
7 | 5780 lnum = wp->w_cursor.lnum; |
5781 if (lnum < 1) /* can happen when starting up */ | |
5782 lnum = 1; | |
5875 | 5783 wp->w_wrow = ((long)wp->w_fraction * (long)height - 1L |
5784 + FRACTION_MULT / 2) / FRACTION_MULT; | |
7 | 5785 line_size = plines_win_col(wp, lnum, (long)(wp->w_cursor.col)) - 1; |
5786 sline = wp->w_wrow - line_size; | |
1023 | 5787 |
5788 if (sline >= 0) | |
5789 { | |
5790 /* Make sure the whole cursor line is visible, if possible. */ | |
5791 int rows = plines_win(wp, lnum, FALSE); | |
5792 | |
5793 if (sline > wp->w_height - rows) | |
5794 { | |
5795 sline = wp->w_height - rows; | |
5796 wp->w_wrow -= rows - line_size; | |
5797 } | |
5798 } | |
5799 | |
7 | 5800 if (sline < 0) |
5801 { | |
5802 /* | |
5803 * Cursor line would go off top of screen if w_wrow was this high. | |
1023 | 5804 * Make cursor line the first line in the window. If not enough |
5805 * room use w_skipcol; | |
7 | 5806 */ |
5807 wp->w_wrow = line_size; | |
1023 | 5808 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
|
5809 && (wp->w_width - win_col_off(wp)) > 0) |
1023 | 5810 { |
12515
972ea22c946f
patch 8.0.1136: W_WIDTH() is always the same
Christian Brabandt <cb@256bit.org>
parents:
12513
diff
changeset
|
5811 wp->w_skipcol += wp->w_width - win_col_off(wp); |
1023 | 5812 --wp->w_wrow; |
5813 while (wp->w_wrow >= wp->w_height) | |
5814 { | |
12515
972ea22c946f
patch 8.0.1136: W_WIDTH() is always the same
Christian Brabandt <cb@256bit.org>
parents:
12513
diff
changeset
|
5815 wp->w_skipcol += wp->w_width - win_col_off(wp) |
1023 | 5816 + win_col_off2(wp); |
5817 --wp->w_wrow; | |
5818 } | |
5819 } | |
6052 | 5820 set_topline(wp, lnum); |
7 | 5821 } |
5936 | 5822 else if (sline > 0) |
7 | 5823 { |
1023 | 5824 while (sline > 0 && lnum > 1) |
7 | 5825 { |
5826 #ifdef FEAT_FOLDING | |
5827 hasFoldingWin(wp, lnum, &lnum, NULL, TRUE, NULL); | |
5828 if (lnum == 1) | |
5829 { | |
5830 /* first line in buffer is folded */ | |
5831 line_size = 1; | |
5832 --sline; | |
5833 break; | |
5834 } | |
5835 #endif | |
5836 --lnum; | |
5837 #ifdef FEAT_DIFF | |
5838 if (lnum == wp->w_topline) | |
5839 line_size = plines_win_nofill(wp, lnum, TRUE) | |
5840 + wp->w_topfill; | |
5841 else | |
5842 #endif | |
5843 line_size = plines_win(wp, lnum, TRUE); | |
5844 sline -= line_size; | |
5845 } | |
47 | 5846 |
7 | 5847 if (sline < 0) |
5848 { | |
5849 /* | |
5850 * Line we want at top would go off top of screen. Use next | |
5851 * line instead. | |
5852 */ | |
5853 #ifdef FEAT_FOLDING | |
5854 hasFoldingWin(wp, lnum, NULL, &lnum, TRUE, NULL); | |
5855 #endif | |
5856 lnum++; | |
5857 wp->w_wrow -= line_size + sline; | |
5858 } | |
5936 | 5859 else if (sline > 0) |
7 | 5860 { |
5861 /* First line of file reached, use that as topline. */ | |
5862 lnum = 1; | |
5863 wp->w_wrow -= sline; | |
5864 } | |
5936 | 5865 |
6052 | 5866 set_topline(wp, lnum); |
7 | 5867 } |
5868 } | |
5869 | |
5870 if (wp == curwin) | |
5871 { | |
15713
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15636
diff
changeset
|
5872 if (get_scrolloff_value()) |
7 | 5873 update_topline(); |
5874 curs_columns(FALSE); /* validate w_wrow */ | |
5875 } | |
5875 | 5876 if (prev_height > 0) |
5877 wp->w_prev_fraction_row = wp->w_wrow; | |
7 | 5878 |
5879 win_comp_scroll(wp); | |
737 | 5880 redraw_win_later(wp, SOME_VALID); |
7 | 5881 wp->w_redr_status = TRUE; |
5882 invalidate_botline_win(wp); | |
5883 } | |
5884 | |
5885 /* | |
5886 * Set the width of a window. | |
5887 */ | |
3697 | 5888 void |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5889 win_new_width(win_T *wp, int width) |
7 | 5890 { |
5891 wp->w_width = width; | |
5892 wp->w_lines_valid = 0; | |
5893 changed_line_abv_curs_win(wp); | |
5894 invalidate_botline_win(wp); | |
5895 if (wp == curwin) | |
5896 { | |
5897 update_topline(); | |
5898 curs_columns(TRUE); /* validate w_wrow */ | |
5899 } | |
5900 redraw_win_later(wp, NOT_VALID); | |
5901 wp->w_redr_status = TRUE; | |
5902 } | |
5903 | |
5904 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5905 win_comp_scroll(win_T *wp) |
7 | 5906 { |
5907 wp->w_p_scr = ((unsigned)wp->w_height >> 1); | |
5908 if (wp->w_p_scr == 0) | |
5909 wp->w_p_scr = 1; | |
5910 } | |
5911 | |
5912 /* | |
5913 * command_height: called whenever p_ch has been changed | |
5914 */ | |
5915 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5916 command_height(void) |
7 | 5917 { |
5918 int h; | |
5919 frame_T *frp; | |
824 | 5920 int old_p_ch = curtab->tp_ch_used; |
5921 | |
5922 /* Use the value of p_ch that we remembered. This is needed for when the | |
5923 * GUI starts up, we can't be sure in what order things happen. And when | |
5924 * p_ch was changed in another tab page. */ | |
5925 curtab->tp_ch_used = p_ch; | |
170 | 5926 |
7 | 5927 /* Find bottom frame with width of screen. */ |
5928 frp = lastwin->w_frame; | |
5929 while (frp->fr_width != Columns && frp->fr_parent != NULL) | |
5930 frp = frp->fr_parent; | |
5931 | |
5932 /* Avoid changing the height of a window with 'winfixheight' set. */ | |
5933 while (frp->fr_prev != NULL && frp->fr_layout == FR_LEAF | |
5934 && frp->fr_win->w_p_wfh) | |
5935 frp = frp->fr_prev; | |
5936 | |
5937 if (starting != NO_SCREEN) | |
5938 { | |
5939 cmdline_row = Rows - p_ch; | |
5940 | |
5941 if (p_ch > old_p_ch) /* p_ch got bigger */ | |
5942 { | |
5943 while (p_ch > old_p_ch) | |
5944 { | |
5945 if (frp == NULL) | |
5946 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15436
diff
changeset
|
5947 emsg(_(e_noroom)); |
7 | 5948 p_ch = old_p_ch; |
1404 | 5949 curtab->tp_ch_used = p_ch; |
7 | 5950 cmdline_row = Rows - p_ch; |
5951 break; | |
5952 } | |
5953 h = frp->fr_height - frame_minheight(frp, NULL); | |
5954 if (h > p_ch - old_p_ch) | |
5955 h = p_ch - old_p_ch; | |
5956 old_p_ch += h; | |
5957 frame_add_height(frp, -h); | |
5958 frp = frp->fr_prev; | |
5959 } | |
5960 | |
5961 /* Recompute window positions. */ | |
5962 (void)win_comp_pos(); | |
5963 | |
5964 /* clear the lines added to cmdline */ | |
5965 if (full_screen) | |
5966 screen_fill((int)(cmdline_row), (int)Rows, 0, | |
5967 (int)Columns, ' ', ' ', 0); | |
5968 msg_row = cmdline_row; | |
5969 redraw_cmdline = TRUE; | |
5970 return; | |
5971 } | |
5972 | |
5973 if (msg_row < cmdline_row) | |
5974 msg_row = cmdline_row; | |
5975 redraw_cmdline = TRUE; | |
5976 } | |
5977 frame_add_height(frp, (int)(old_p_ch - p_ch)); | |
5978 | |
5979 /* Recompute window positions. */ | |
5980 if (frp != lastwin->w_frame) | |
5981 (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
|
5982 } |
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
5983 |
7 | 5984 /* |
5985 * Resize frame "frp" to be "n" lines higher (negative for less high). | |
5986 * Also resize the frames it is contained in. | |
5987 */ | |
5988 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5989 frame_add_height(frame_T *frp, int n) |
7 | 5990 { |
5991 frame_new_height(frp, frp->fr_height + n, FALSE, FALSE); | |
5992 for (;;) | |
5993 { | |
5994 frp = frp->fr_parent; | |
5995 if (frp == NULL) | |
5996 break; | |
5997 frp->fr_height += n; | |
5998 } | |
5999 } | |
6000 | |
6001 /* | |
6002 * Add or remove a status line for the bottom window(s), according to the | |
6003 * value of 'laststatus'. | |
6004 */ | |
6005 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6006 last_status( |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6007 int morewin) /* pretend there are two or more windows */ |
7 | 6008 { |
6009 /* Don't make a difference between horizontal or vertical split. */ | |
6010 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
|
6011 || (p_ls == 1 && (morewin || !ONE_WINDOW)))); |
7 | 6012 } |
6013 | |
6014 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6015 last_status_rec(frame_T *fr, int statusline) |
7 | 6016 { |
6017 frame_T *fp; | |
6018 win_T *wp; | |
6019 | |
6020 if (fr->fr_layout == FR_LEAF) | |
6021 { | |
6022 wp = fr->fr_win; | |
6023 if (wp->w_status_height != 0 && !statusline) | |
6024 { | |
6025 /* remove status line */ | |
6026 win_new_height(wp, wp->w_height + 1); | |
6027 wp->w_status_height = 0; | |
6028 comp_col(); | |
6029 } | |
6030 else if (wp->w_status_height == 0 && statusline) | |
6031 { | |
6032 /* Find a frame to take a line from. */ | |
6033 fp = fr; | |
6034 while (fp->fr_height <= frame_minheight(fp, NULL)) | |
6035 { | |
6036 if (fp == topframe) | |
6037 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15436
diff
changeset
|
6038 emsg(_(e_noroom)); |
7 | 6039 return; |
6040 } | |
6041 /* In a column of frames: go to frame above. If already at | |
6042 * the top or in a row of frames: go to parent. */ | |
6043 if (fp->fr_parent->fr_layout == FR_COL && fp->fr_prev != NULL) | |
6044 fp = fp->fr_prev; | |
6045 else | |
6046 fp = fp->fr_parent; | |
6047 } | |
6048 wp->w_status_height = 1; | |
6049 if (fp != fr) | |
6050 { | |
6051 frame_new_height(fp, fp->fr_height - 1, FALSE, FALSE); | |
6052 frame_fix_height(wp); | |
6053 (void)win_comp_pos(); | |
6054 } | |
6055 else | |
6056 win_new_height(wp, wp->w_height - 1); | |
6057 comp_col(); | |
737 | 6058 redraw_all_later(SOME_VALID); |
7 | 6059 } |
6060 } | |
6061 else if (fr->fr_layout == FR_ROW) | |
6062 { | |
6063 /* 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
|
6064 FOR_ALL_FRAMES(fp, fr->fr_child) |
7 | 6065 last_status_rec(fp, statusline); |
6066 } | |
6067 else | |
6068 { | |
6069 /* horizontally split window, set status line for last one */ | |
6070 for (fp = fr->fr_child; fp->fr_next != NULL; fp = fp->fr_next) | |
6071 ; | |
6072 last_status_rec(fp, statusline); | |
6073 } | |
6074 } | |
6075 | |
667 | 6076 /* |
668 | 6077 * Return the number of lines used by the tab page line. |
667 | 6078 */ |
6079 int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6080 tabline_height(void) |
667 | 6081 { |
685 | 6082 #ifdef FEAT_GUI_TABLINE |
6083 /* When the GUI has the tabline then this always returns zero. */ | |
6084 if (gui_use_tabline()) | |
6085 return 0; | |
6086 #endif | |
675 | 6087 switch (p_stal) |
668 | 6088 { |
6089 case 0: return 0; | |
6090 case 1: return (first_tabpage->tp_next == NULL) ? 0 : 1; | |
6091 } | |
667 | 6092 return 1; |
6093 } | |
6094 | |
7 | 6095 /* |
6096 * Return the minimal number of rows that is needed on the screen to display | |
6097 * the current number of windows. | |
6098 */ | |
6099 int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6100 min_rows(void) |
7 | 6101 { |
6102 int total; | |
671 | 6103 tabpage_T *tp; |
6104 int n; | |
7 | 6105 |
6106 if (firstwin == NULL) /* not initialized yet */ | |
6107 return MIN_LINES; | |
6108 | |
671 | 6109 total = 0; |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9599
diff
changeset
|
6110 FOR_ALL_TABPAGES(tp) |
671 | 6111 { |
6112 n = frame_minheight(tp->tp_topframe, NULL); | |
6113 if (total < n) | |
6114 total = n; | |
6115 } | |
685 | 6116 total += tabline_height(); |
671 | 6117 total += 1; /* count the room for the command line */ |
7 | 6118 return total; |
6119 } | |
6120 | |
6121 /* | |
672 | 6122 * Return TRUE if there is only one window (in the current tab page), not |
6123 * counting a help or preview window, unless it is the current window. | |
1906 | 6124 * Does not count "aucmd_win". |
7 | 6125 */ |
6126 int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6127 only_one_window(void) |
7 | 6128 { |
6129 int count = 0; | |
6130 win_T *wp; | |
6131 | |
667 | 6132 /* If there is another tab page there always is another window. */ |
6133 if (first_tabpage->tp_next != NULL) | |
6134 return FALSE; | |
6135 | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9599
diff
changeset
|
6136 FOR_ALL_WINDOWS(wp) |
4021 | 6137 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
|
6138 && (!((bt_help(wp->w_buffer) && !bt_help(curbuf)) |
7 | 6139 # ifdef FEAT_QUICKFIX |
6140 || wp->w_p_pvw | |
6141 # endif | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13308
diff
changeset
|
6142 ) || wp == curwin) && wp != aucmd_win) |
7 | 6143 ++count; |
6144 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
|
6145 } |
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
6146 |
7 | 6147 /* |
6148 * Correct the cursor line number in other windows. Used after changing the | |
6149 * current buffer, and before applying autocommands. | |
6150 * When "do_curwin" is TRUE, also check current window. | |
6151 */ | |
6152 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6153 check_lnums(int do_curwin) |
7 | 6154 { |
6155 win_T *wp; | |
671 | 6156 tabpage_T *tp; |
6157 | |
6158 FOR_ALL_TAB_WINDOWS(tp, wp) | |
7 | 6159 if ((do_curwin || wp != curwin) && wp->w_buffer == curbuf) |
6160 { | |
6161 if (wp->w_cursor.lnum > curbuf->b_ml.ml_line_count) | |
6162 wp->w_cursor.lnum = curbuf->b_ml.ml_line_count; | |
6163 if (wp->w_topline > curbuf->b_ml.ml_line_count) | |
6164 wp->w_topline = curbuf->b_ml.ml_line_count; | |
6165 } | |
6166 } | |
6167 | |
6168 /* | |
6169 * A snapshot of the window sizes, to restore them after closing the help | |
6170 * window. | |
6171 * Only these fields are used: | |
6172 * fr_layout | |
6173 * fr_width | |
6174 * fr_height | |
6175 * fr_next | |
6176 * fr_child | |
6177 * fr_win (only valid for the old curwin, NULL otherwise) | |
6178 */ | |
6179 | |
6180 /* | |
6181 * Create a snapshot of the current frame sizes. | |
6182 */ | |
1906 | 6183 void |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6184 make_snapshot(int idx) |
7 | 6185 { |
1906 | 6186 clear_snapshot(curtab, idx); |
6187 make_snapshot_rec(topframe, &curtab->tp_snapshot[idx]); | |
7 | 6188 } |
6189 | |
6190 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6191 make_snapshot_rec(frame_T *fr, frame_T **frp) |
7 | 6192 { |
6193 *frp = (frame_T *)alloc_clear((unsigned)sizeof(frame_T)); | |
6194 if (*frp == NULL) | |
6195 return; | |
6196 (*frp)->fr_layout = fr->fr_layout; | |
6197 (*frp)->fr_width = fr->fr_width; | |
6198 (*frp)->fr_height = fr->fr_height; | |
6199 if (fr->fr_next != NULL) | |
6200 make_snapshot_rec(fr->fr_next, &((*frp)->fr_next)); | |
6201 if (fr->fr_child != NULL) | |
6202 make_snapshot_rec(fr->fr_child, &((*frp)->fr_child)); | |
6203 if (fr->fr_layout == FR_LEAF && fr->fr_win == curwin) | |
6204 (*frp)->fr_win = curwin; | |
6205 } | |
6206 | |
6207 /* | |
6208 * Remove any existing snapshot. | |
6209 */ | |
6210 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6211 clear_snapshot(tabpage_T *tp, int idx) |
7 | 6212 { |
1906 | 6213 clear_snapshot_rec(tp->tp_snapshot[idx]); |
6214 tp->tp_snapshot[idx] = NULL; | |
7 | 6215 } |
6216 | |
6217 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6218 clear_snapshot_rec(frame_T *fr) |
7 | 6219 { |
6220 if (fr != NULL) | |
6221 { | |
6222 clear_snapshot_rec(fr->fr_next); | |
6223 clear_snapshot_rec(fr->fr_child); | |
6224 vim_free(fr); | |
6225 } | |
6226 } | |
6227 | |
6228 /* | |
6229 * Restore a previously created snapshot, if there is any. | |
6230 * This is only done if the screen size didn't change and the window layout is | |
6231 * still the same. | |
6232 */ | |
1906 | 6233 void |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6234 restore_snapshot( |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6235 int idx, |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6236 int close_curwin) /* closing current window */ |
7 | 6237 { |
6238 win_T *wp; | |
6239 | |
1906 | 6240 if (curtab->tp_snapshot[idx] != NULL |
6241 && curtab->tp_snapshot[idx]->fr_width == topframe->fr_width | |
6242 && curtab->tp_snapshot[idx]->fr_height == topframe->fr_height | |
6243 && check_snapshot_rec(curtab->tp_snapshot[idx], topframe) == OK) | |
6244 { | |
6245 wp = restore_snapshot_rec(curtab->tp_snapshot[idx], topframe); | |
7 | 6246 win_comp_pos(); |
6247 if (wp != NULL && close_curwin) | |
6248 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
|
6249 redraw_all_later(NOT_VALID); |
7 | 6250 } |
1906 | 6251 clear_snapshot(curtab, idx); |
7 | 6252 } |
6253 | |
6254 /* | |
6255 * 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
|
6256 * and same children. And the window pointer is valid. |
7 | 6257 */ |
6258 static int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6259 check_snapshot_rec(frame_T *sn, frame_T *fr) |
7 | 6260 { |
6261 if (sn->fr_layout != fr->fr_layout | |
6262 || (sn->fr_next == NULL) != (fr->fr_next == NULL) | |
6263 || (sn->fr_child == NULL) != (fr->fr_child == NULL) | |
6264 || (sn->fr_next != NULL | |
6265 && check_snapshot_rec(sn->fr_next, fr->fr_next) == FAIL) | |
6266 || (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
|
6267 && 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
|
6268 || (sn->fr_win != NULL && !win_valid(sn->fr_win))) |
7 | 6269 return FAIL; |
6270 return OK; | |
6271 } | |
6272 | |
6273 /* | |
6274 * Copy the size of snapshot frame "sn" to frame "fr". Do the same for all | |
6275 * following frames and children. | |
6276 * Returns a pointer to the old current window, or NULL. | |
6277 */ | |
6278 static win_T * | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6279 restore_snapshot_rec(frame_T *sn, frame_T *fr) |
7 | 6280 { |
6281 win_T *wp = NULL; | |
6282 win_T *wp2; | |
6283 | |
6284 fr->fr_height = sn->fr_height; | |
6285 fr->fr_width = sn->fr_width; | |
6286 if (fr->fr_layout == FR_LEAF) | |
6287 { | |
6288 frame_new_height(fr, fr->fr_height, FALSE, FALSE); | |
779 | 6289 frame_new_width(fr, fr->fr_width, FALSE, FALSE); |
7 | 6290 wp = sn->fr_win; |
6291 } | |
6292 if (sn->fr_next != NULL) | |
6293 { | |
6294 wp2 = restore_snapshot_rec(sn->fr_next, fr->fr_next); | |
6295 if (wp2 != NULL) | |
6296 wp = wp2; | |
6297 } | |
6298 if (sn->fr_child != NULL) | |
6299 { | |
6300 wp2 = restore_snapshot_rec(sn->fr_child, fr->fr_child); | |
6301 if (wp2 != NULL) | |
6302 wp = wp2; | |
6303 } | |
6304 return wp; | |
6305 } | |
6306 | |
5202
8edba3805d78
updated for version 7.4a.027
Bram Moolenaar <bram@vim.org>
parents:
5098
diff
changeset
|
6307 #if defined(FEAT_EVAL) || defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) \ |
8edba3805d78
updated for version 7.4a.027
Bram Moolenaar <bram@vim.org>
parents:
5098
diff
changeset
|
6308 || defined(PROTO) |
4429 | 6309 /* |
6310 * Set "win" to be the curwin and "tp" to be the current tab page. | |
6222 | 6311 * restore_win() MUST be called to undo, also when FAIL is returned. |
6312 * No autocommands will be executed until restore_win() is called. | |
4918
0792cc5133ce
updated for version 7.3.1204
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
6313 * When "no_display" is TRUE the display won't be affected, no redraw is |
0792cc5133ce
updated for version 7.3.1204
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
6314 * triggered, another tabpage access is limited. |
4429 | 6315 * Returns FAIL if switching to "win" failed. |
6316 */ | |
6317 int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6318 switch_win( |
12564
183dc24cf861
patch 8.0.1160: getting tab-local variable fails after closing window
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
6319 win_T **save_curwin, |
183dc24cf861
patch 8.0.1160: getting tab-local variable fails after closing window
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
6320 tabpage_T **save_curtab, |
183dc24cf861
patch 8.0.1160: getting tab-local variable fails after closing window
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
6321 win_T *win, |
183dc24cf861
patch 8.0.1160: getting tab-local variable fails after closing window
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
6322 tabpage_T *tp, |
183dc24cf861
patch 8.0.1160: getting tab-local variable fails after closing window
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
6323 int no_display) |
4429 | 6324 { |
6325 block_autocmds(); | |
6326 *save_curwin = curwin; | |
6327 if (tp != NULL) | |
6328 { | |
6329 *save_curtab = curtab; | |
4918
0792cc5133ce
updated for version 7.3.1204
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
6330 if (no_display) |
0792cc5133ce
updated for version 7.3.1204
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
6331 { |
0792cc5133ce
updated for version 7.3.1204
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
6332 curtab->tp_firstwin = firstwin; |
0792cc5133ce
updated for version 7.3.1204
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
6333 curtab->tp_lastwin = lastwin; |
0792cc5133ce
updated for version 7.3.1204
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
6334 curtab = tp; |
0792cc5133ce
updated for version 7.3.1204
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
6335 firstwin = curtab->tp_firstwin; |
0792cc5133ce
updated for version 7.3.1204
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
6336 lastwin = curtab->tp_lastwin; |
0792cc5133ce
updated for version 7.3.1204
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
6337 } |
0792cc5133ce
updated for version 7.3.1204
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
6338 else |
0792cc5133ce
updated for version 7.3.1204
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
6339 goto_tabpage_tp(tp, FALSE, FALSE); |
4429 | 6340 } |
6341 if (!win_valid(win)) | |
6342 return FAIL; | |
6343 curwin = win; | |
6344 curbuf = curwin->w_buffer; | |
6345 return OK; | |
6346 } | |
6347 | |
6348 /* | |
6349 * Restore current tabpage and window saved by switch_win(), if still valid. | |
4918
0792cc5133ce
updated for version 7.3.1204
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
6350 * When "no_display" is TRUE the display won't be affected, no redraw is |
0792cc5133ce
updated for version 7.3.1204
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
6351 * triggered. |
4429 | 6352 */ |
6353 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6354 restore_win( |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6355 win_T *save_curwin UNUSED, |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6356 tabpage_T *save_curtab UNUSED, |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6357 int no_display UNUSED) |
4429 | 6358 { |
6359 if (save_curtab != NULL && valid_tabpage(save_curtab)) | |
4918
0792cc5133ce
updated for version 7.3.1204
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
6360 { |
0792cc5133ce
updated for version 7.3.1204
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
6361 if (no_display) |
0792cc5133ce
updated for version 7.3.1204
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
6362 { |
0792cc5133ce
updated for version 7.3.1204
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
6363 curtab->tp_firstwin = firstwin; |
0792cc5133ce
updated for version 7.3.1204
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
6364 curtab->tp_lastwin = lastwin; |
0792cc5133ce
updated for version 7.3.1204
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
6365 curtab = save_curtab; |
0792cc5133ce
updated for version 7.3.1204
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
6366 firstwin = curtab->tp_firstwin; |
0792cc5133ce
updated for version 7.3.1204
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
6367 lastwin = curtab->tp_lastwin; |
0792cc5133ce
updated for version 7.3.1204
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
6368 } |
0792cc5133ce
updated for version 7.3.1204
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
6369 else |
0792cc5133ce
updated for version 7.3.1204
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
6370 goto_tabpage_tp(save_curtab, FALSE, FALSE); |
0792cc5133ce
updated for version 7.3.1204
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
6371 } |
4429 | 6372 if (win_valid(save_curwin)) |
6373 { | |
6374 curwin = save_curwin; | |
6375 curbuf = curwin->w_buffer; | |
6376 } | |
6377 unblock_autocmds(); | |
6378 } | |
6379 | |
6380 /* | |
6381 * Make "buf" the current buffer. restore_buffer() MUST be called to undo. | |
6382 * No autocommands will be executed. Use aucmd_prepbuf() if there are any. | |
6383 */ | |
6384 void | |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9349
diff
changeset
|
6385 switch_buffer(bufref_T *save_curbuf, buf_T *buf) |
4429 | 6386 { |
6387 block_autocmds(); | |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9349
diff
changeset
|
6388 set_bufref(save_curbuf, curbuf); |
4429 | 6389 --curbuf->b_nwindows; |
6390 curbuf = buf; | |
6391 curwin->w_buffer = buf; | |
6392 ++curbuf->b_nwindows; | |
6393 } | |
6394 | |
6395 /* | |
6396 * Restore the current buffer after using switch_buffer(). | |
6397 */ | |
6398 void | |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9349
diff
changeset
|
6399 restore_buffer(bufref_T *save_curbuf) |
4429 | 6400 { |
6401 unblock_autocmds(); | |
6402 /* Check for valid buffer, just in case. */ | |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9349
diff
changeset
|
6403 if (bufref_valid(save_curbuf)) |
4429 | 6404 { |
6405 --curbuf->b_nwindows; | |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9349
diff
changeset
|
6406 curwin->w_buffer = save_curbuf->br_buf; |
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9349
diff
changeset
|
6407 curbuf = save_curbuf->br_buf; |
4429 | 6408 ++curbuf->b_nwindows; |
6409 } | |
6410 } | |
6411 #endif | |
6412 | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
6413 #if defined(FEAT_GUI) || defined(PROTO) |
7 | 6414 /* |
6415 * Return TRUE if there is any vertically split window. | |
6416 */ | |
6417 int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6418 win_hasvertsplit(void) |
7 | 6419 { |
6420 frame_T *fr; | |
6421 | |
6422 if (topframe->fr_layout == FR_ROW) | |
6423 return TRUE; | |
6424 | |
6425 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
|
6426 FOR_ALL_FRAMES(fr, topframe->fr_child) |
7 | 6427 if (fr->fr_layout == FR_ROW) |
6428 return TRUE; | |
6429 | |
6430 return FALSE; | |
6431 } | |
6432 #endif | |
1326 | 6433 |
6434 #if defined(FEAT_SEARCH_EXTRA) || defined(PROTO) | |
6435 /* | |
6436 * Add match to the match list of window 'wp'. The pattern 'pat' will be | |
1698 | 6437 * highlighted with the group 'grp' with priority 'prio'. |
1326 | 6438 * Optionally, a desired ID 'id' can be specified (greater than or equal to 1). |
6439 * If no particular ID is desired, -1 must be specified for 'id'. | |
6440 * Return ID of added match, -1 on failure. | |
6441 */ | |
6442 int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6443 match_add( |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6444 win_T *wp, |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6445 char_u *grp, |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6446 char_u *pat, |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6447 int prio, |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6448 int id, |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6449 list_T *pos_list, |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6450 char_u *conceal_char UNUSED) /* pointer to conceal replacement char */ |
1326 | 6451 { |
5979 | 6452 matchitem_T *cur; |
6453 matchitem_T *prev; | |
6454 matchitem_T *m; | |
1326 | 6455 int hlg_id; |
5979 | 6456 regprog_T *regprog = NULL; |
6457 int rtype = SOME_VALID; | |
6458 | |
6459 if (*grp == NUL || (pat != NULL && *pat == NUL)) | |
1326 | 6460 return -1; |
6461 if (id < -1 || id == 0) | |
6462 { | |
15490
98c35d312987
patch 8.1.0753: printf format not checked for semsg()
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
6463 semsg(_("E799: Invalid ID: %d (must be greater than or equal to 1)"), id); |
1326 | 6464 return -1; |
6465 } | |
6466 if (id != -1) | |
6467 { | |
6468 cur = wp->w_match_head; | |
6469 while (cur != NULL) | |
6470 { | |
6471 if (cur->id == id) | |
6472 { | |
15490
98c35d312987
patch 8.1.0753: printf format not checked for semsg()
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
6473 semsg(_("E801: ID already taken: %d"), id); |
1326 | 6474 return -1; |
6475 } | |
6476 cur = cur->next; | |
6477 } | |
6478 } | |
1570 | 6479 if ((hlg_id = syn_namen2id(grp, (int)STRLEN(grp))) == 0) |
1326 | 6480 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15436
diff
changeset
|
6481 semsg(_(e_nogroup), grp); |
1326 | 6482 return -1; |
6483 } | |
5979 | 6484 if (pat != NULL && (regprog = vim_regcomp(pat, RE_MAGIC)) == NULL) |
1326 | 6485 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15436
diff
changeset
|
6486 semsg(_(e_invarg2), pat); |
1326 | 6487 return -1; |
6488 } | |
6489 | |
6490 /* Find available match ID. */ | |
6491 while (id == -1) | |
6492 { | |
6493 cur = wp->w_match_head; | |
6494 while (cur != NULL && cur->id != wp->w_next_match_id) | |
6495 cur = cur->next; | |
6496 if (cur == NULL) | |
6497 id = wp->w_next_match_id; | |
6498 wp->w_next_match_id++; | |
6499 } | |
6500 | |
6501 /* Build new match. */ | |
5987 | 6502 m = (matchitem_T *)alloc_clear(sizeof(matchitem_T)); |
1326 | 6503 m->id = id; |
6504 m->priority = prio; | |
5979 | 6505 m->pattern = pat == NULL ? NULL : vim_strsave(pat); |
1326 | 6506 m->hlg_id = hlg_id; |
1338 | 6507 m->match.regprog = regprog; |
6508 m->match.rmm_ic = FALSE; | |
6509 m->match.rmm_maxcol = 0; | |
15605
62b3805506b3
patch 8.1.0810: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
6510 # if defined(FEAT_CONCEAL) |
6947 | 6511 m->conceal_char = 0; |
6512 if (conceal_char != NULL) | |
6513 m->conceal_char = (*mb_ptr2char)(conceal_char); | |
8804
75446578a52f
commit https://github.com/vim/vim/commit/42356150badca33b4e42dc8172abbceff2e86cbe
Christian Brabandt <cb@256bit.org>
parents:
8651
diff
changeset
|
6514 # endif |
1326 | 6515 |
5979 | 6516 /* Set up position matches */ |
6517 if (pos_list != NULL) | |
6518 { | |
6519 linenr_T toplnum = 0; | |
6520 linenr_T botlnum = 0; | |
6521 listitem_T *li; | |
6522 int i; | |
6523 | |
6007 | 6524 for (i = 0, li = pos_list->lv_first; li != NULL && i < MAXPOSMATCH; |
5979 | 6525 i++, li = li->li_next) |
6526 { | |
6527 linenr_T lnum = 0; | |
6528 colnr_T col = 0; | |
6529 int len = 1; | |
6530 list_T *subl; | |
6531 listitem_T *subli; | |
5987 | 6532 int error = FALSE; |
5979 | 6533 |
6534 if (li->li_tv.v_type == VAR_LIST) | |
6535 { | |
6536 subl = li->li_tv.vval.v_list; | |
6537 if (subl == NULL) | |
6538 goto fail; | |
6539 subli = subl->lv_first; | |
6540 if (subli == NULL) | |
6541 goto fail; | |
15211
de63593896b3
patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents:
15006
diff
changeset
|
6542 lnum = tv_get_number_chk(&subli->li_tv, &error); |
5979 | 6543 if (error == TRUE) |
6544 goto fail; | |
6545 if (lnum == 0) | |
6546 { | |
6547 --i; | |
6548 continue; | |
6549 } | |
6007 | 6550 m->pos.pos[i].lnum = lnum; |
5979 | 6551 subli = subli->li_next; |
6552 if (subli != NULL) | |
6553 { | |
15211
de63593896b3
patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents:
15006
diff
changeset
|
6554 col = tv_get_number_chk(&subli->li_tv, &error); |
5979 | 6555 if (error == TRUE) |
6556 goto fail; | |
6557 subli = subli->li_next; | |
6558 if (subli != NULL) | |
6559 { | |
15211
de63593896b3
patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents:
15006
diff
changeset
|
6560 len = tv_get_number_chk(&subli->li_tv, &error); |
5979 | 6561 if (error == TRUE) |
6562 goto fail; | |
6563 } | |
6564 } | |
6565 m->pos.pos[i].col = col; | |
6566 m->pos.pos[i].len = len; | |
6567 } | |
6568 else if (li->li_tv.v_type == VAR_NUMBER) | |
6569 { | |
6570 if (li->li_tv.vval.v_number == 0) | |
6007 | 6571 { |
6572 --i; | |
5979 | 6573 continue; |
6007 | 6574 } |
5979 | 6575 m->pos.pos[i].lnum = li->li_tv.vval.v_number; |
6576 m->pos.pos[i].col = 0; | |
6577 m->pos.pos[i].len = 0; | |
6578 } | |
6579 else | |
6580 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15436
diff
changeset
|
6581 emsg(_("List or number required")); |
5979 | 6582 goto fail; |
6583 } | |
6584 if (toplnum == 0 || lnum < toplnum) | |
6585 toplnum = lnum; | |
6005 | 6586 if (botlnum == 0 || lnum >= botlnum) |
6587 botlnum = lnum + 1; | |
5979 | 6588 } |
6589 | |
6590 /* Calculate top and bottom lines for redrawing area */ | |
6591 if (toplnum != 0) | |
6592 { | |
6593 if (wp->w_buffer->b_mod_set) | |
6594 { | |
6595 if (wp->w_buffer->b_mod_top > toplnum) | |
6596 wp->w_buffer->b_mod_top = toplnum; | |
6597 if (wp->w_buffer->b_mod_bot < botlnum) | |
6598 wp->w_buffer->b_mod_bot = botlnum; | |
6599 } | |
6600 else | |
6601 { | |
6018 | 6602 wp->w_buffer->b_mod_set = TRUE; |
5979 | 6603 wp->w_buffer->b_mod_top = toplnum; |
6604 wp->w_buffer->b_mod_bot = botlnum; | |
6018 | 6605 wp->w_buffer->b_mod_xlines = 0; |
5979 | 6606 } |
6607 m->pos.toplnum = toplnum; | |
6608 m->pos.botlnum = botlnum; | |
6609 rtype = VALID; | |
6610 } | |
6611 } | |
6612 | |
1326 | 6613 /* Insert new match. The match list is in ascending order with regard to |
6614 * the match priorities. */ | |
6615 cur = wp->w_match_head; | |
6616 prev = cur; | |
6617 while (cur != NULL && prio >= cur->priority) | |
6618 { | |
6619 prev = cur; | |
6620 cur = cur->next; | |
6621 } | |
6622 if (cur == prev) | |
6623 wp->w_match_head = m; | |
6624 else | |
6625 prev->next = m; | |
6626 m->next = cur; | |
6627 | |
5979 | 6628 redraw_later(rtype); |
1326 | 6629 return id; |
5979 | 6630 |
6631 fail: | |
6632 vim_free(m); | |
6633 return -1; | |
1326 | 6634 } |
6635 | |
6636 /* | |
6637 * Delete match with ID 'id' in the match list of window 'wp'. | |
6638 * Print error messages if 'perr' is TRUE. | |
6639 */ | |
6640 int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6641 match_delete(win_T *wp, int id, int perr) |
1326 | 6642 { |
5979 | 6643 matchitem_T *cur = wp->w_match_head; |
6644 matchitem_T *prev = cur; | |
6645 int rtype = SOME_VALID; | |
1326 | 6646 |
6647 if (id < 1) | |
6648 { | |
6649 if (perr == TRUE) | |
15490
98c35d312987
patch 8.1.0753: printf format not checked for semsg()
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
6650 semsg(_("E802: Invalid ID: %d (must be greater than or equal to 1)"), |
1326 | 6651 id); |
6652 return -1; | |
6653 } | |
6654 while (cur != NULL && cur->id != id) | |
6655 { | |
6656 prev = cur; | |
6657 cur = cur->next; | |
6658 } | |
6659 if (cur == NULL) | |
6660 { | |
6661 if (perr == TRUE) | |
15490
98c35d312987
patch 8.1.0753: printf format not checked for semsg()
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
6662 semsg(_("E803: ID not found: %d"), id); |
1326 | 6663 return -1; |
6664 } | |
6665 if (cur == prev) | |
6666 wp->w_match_head = cur->next; | |
6667 else | |
6668 prev->next = cur->next; | |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4442
diff
changeset
|
6669 vim_regfree(cur->match.regprog); |
1326 | 6670 vim_free(cur->pattern); |
5979 | 6671 if (cur->pos.toplnum != 0) |
6672 { | |
6673 if (wp->w_buffer->b_mod_set) | |
6674 { | |
6675 if (wp->w_buffer->b_mod_top > cur->pos.toplnum) | |
6676 wp->w_buffer->b_mod_top = cur->pos.toplnum; | |
6677 if (wp->w_buffer->b_mod_bot < cur->pos.botlnum) | |
6678 wp->w_buffer->b_mod_bot = cur->pos.botlnum; | |
6679 } | |
6680 else | |
6681 { | |
6018 | 6682 wp->w_buffer->b_mod_set = TRUE; |
5979 | 6683 wp->w_buffer->b_mod_top = cur->pos.toplnum; |
6684 wp->w_buffer->b_mod_bot = cur->pos.botlnum; | |
6018 | 6685 wp->w_buffer->b_mod_xlines = 0; |
5979 | 6686 } |
6687 rtype = VALID; | |
6688 } | |
1326 | 6689 vim_free(cur); |
5979 | 6690 redraw_later(rtype); |
1326 | 6691 return 0; |
6692 } | |
6693 | |
6694 /* | |
6695 * Delete all matches in the match list of window 'wp'. | |
6696 */ | |
6697 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6698 clear_matches(win_T *wp) |
1326 | 6699 { |
6700 matchitem_T *m; | |
6701 | |
6702 while (wp->w_match_head != NULL) | |
6703 { | |
6704 m = wp->w_match_head->next; | |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4442
diff
changeset
|
6705 vim_regfree(wp->w_match_head->match.regprog); |
1326 | 6706 vim_free(wp->w_match_head->pattern); |
6707 vim_free(wp->w_match_head); | |
6708 wp->w_match_head = m; | |
6709 } | |
6710 redraw_later(SOME_VALID); | |
6711 } | |
6712 | |
6713 /* | |
6714 * Get match from ID 'id' in window 'wp'. | |
6715 * Return NULL if match not found. | |
6716 */ | |
6717 matchitem_T * | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6718 get_match(win_T *wp, int id) |
1326 | 6719 { |
6720 matchitem_T *cur = wp->w_match_head; | |
6721 | |
6722 while (cur != NULL && cur->id != id) | |
6723 cur = cur->next; | |
6724 return cur; | |
6725 } | |
6726 #endif | |
4379 | 6727 |
6728 #if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) || defined(PROTO) | |
6729 int | |
4401 | 6730 get_win_number(win_T *wp, win_T *first_win) |
4379 | 6731 { |
6732 int i = 1; | |
6733 win_T *w; | |
6734 | |
4401 | 6735 for (w = first_win; w != NULL && w != wp; w = W_NEXT(w)) |
4379 | 6736 ++i; |
6737 | |
6738 if (w == NULL) | |
6739 return 0; | |
6740 else | |
6741 return i; | |
6742 } | |
4401 | 6743 |
6744 int | |
4936
ae05437a744a
updated for version 7.3.1213
Bram Moolenaar <bram@vim.org>
parents:
4918
diff
changeset
|
6745 get_tab_number(tabpage_T *tp UNUSED) |
4401 | 6746 { |
6747 int i = 1; | |
6748 tabpage_T *t; | |
6749 | |
6750 for (t = first_tabpage; t != NULL && t != tp; t = t->tp_next) | |
6751 ++i; | |
6752 | |
6753 if (t == NULL) | |
6754 return 0; | |
6755 else | |
6756 return i; | |
6757 } | |
6758 #endif | |
5004
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6759 |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6760 /* |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6761 * 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
|
6762 */ |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6763 static int |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6764 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
|
6765 { |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6766 frame_T *frp; |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6767 |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6768 if (topfrp->fr_height != height) |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6769 return FALSE; |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6770 |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6771 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
|
6772 FOR_ALL_FRAMES(frp, topfrp->fr_child) |
5004
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6773 if (frp->fr_height != height) |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6774 return FALSE; |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6775 |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6776 return TRUE; |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6777 } |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
6778 |
5004
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6779 /* |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6780 * 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
|
6781 */ |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6782 static int |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6783 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
|
6784 { |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6785 frame_T *frp; |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6786 |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6787 if (topfrp->fr_width != width) |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6788 return FALSE; |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6789 |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6790 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
|
6791 FOR_ALL_FRAMES(frp, topfrp->fr_child) |
5004
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6792 if (frp->fr_width != width) |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6793 return FALSE; |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6794 |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6795 return TRUE; |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6796 } |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6797 |
8534
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
6798 #if defined(FEAT_EVAL) || defined(PROTO) |
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
6799 int |
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
6800 win_getid(typval_T *argvars) |
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
6801 { |
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
6802 int winnr; |
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
6803 win_T *wp; |
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
6804 |
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
6805 if (argvars[0].v_type == VAR_UNKNOWN) |
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
6806 return curwin->w_id; |
15211
de63593896b3
patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents:
15006
diff
changeset
|
6807 winnr = tv_get_number(&argvars[0]); |
8534
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
6808 if (winnr > 0) |
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
6809 { |
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
6810 if (argvars[1].v_type == VAR_UNKNOWN) |
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
6811 wp = firstwin; |
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
6812 else |
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
6813 { |
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
6814 tabpage_T *tp; |
15211
de63593896b3
patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents:
15006
diff
changeset
|
6815 int tabnr = tv_get_number(&argvars[1]); |
8534
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
6816 |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9599
diff
changeset
|
6817 FOR_ALL_TABPAGES(tp) |
8534
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
6818 if (--tabnr == 0) |
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
6819 break; |
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
6820 if (tp == NULL) |
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
6821 return -1; |
10377
dd397210a2d3
commit https://github.com/vim/vim/commit/8e639052638a9bb8c7dd6e3e10776b1218cec1a3
Christian Brabandt <cb@256bit.org>
parents:
10359
diff
changeset
|
6822 if (tp == curtab) |
dd397210a2d3
commit https://github.com/vim/vim/commit/8e639052638a9bb8c7dd6e3e10776b1218cec1a3
Christian Brabandt <cb@256bit.org>
parents:
10359
diff
changeset
|
6823 wp = firstwin; |
dd397210a2d3
commit https://github.com/vim/vim/commit/8e639052638a9bb8c7dd6e3e10776b1218cec1a3
Christian Brabandt <cb@256bit.org>
parents:
10359
diff
changeset
|
6824 else |
dd397210a2d3
commit https://github.com/vim/vim/commit/8e639052638a9bb8c7dd6e3e10776b1218cec1a3
Christian Brabandt <cb@256bit.org>
parents:
10359
diff
changeset
|
6825 wp = tp->tp_firstwin; |
8534
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
6826 } |
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
6827 for ( ; wp != NULL; wp = wp->w_next) |
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
6828 if (--winnr == 0) |
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
6829 return wp->w_id; |
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
6830 } |
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
6831 return 0; |
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
6832 } |
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
6833 |
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
6834 int |
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
6835 win_gotoid(typval_T *argvars) |
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
6836 { |
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
6837 win_T *wp; |
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
6838 tabpage_T *tp; |
15211
de63593896b3
patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents:
15006
diff
changeset
|
6839 int id = tv_get_number(&argvars[0]); |
8534
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
6840 |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9599
diff
changeset
|
6841 FOR_ALL_TAB_WINDOWS(tp, wp) |
8534
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
6842 if (wp->w_id == id) |
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
6843 { |
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
6844 goto_tabpage_win(tp, wp); |
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
6845 return 1; |
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
6846 } |
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
6847 return 0; |
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
6848 } |
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
6849 |
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
6850 void |
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
6851 win_id2tabwin(typval_T *argvars, list_T *list) |
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
6852 { |
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
6853 win_T *wp; |
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
6854 tabpage_T *tp; |
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
6855 int winnr = 1; |
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
6856 int tabnr = 1; |
15211
de63593896b3
patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents:
15006
diff
changeset
|
6857 int id = tv_get_number(&argvars[0]); |
8534
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
6858 |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9599
diff
changeset
|
6859 FOR_ALL_TABPAGES(tp) |
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9599
diff
changeset
|
6860 { |
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9599
diff
changeset
|
6861 FOR_ALL_WINDOWS_IN_TAB(tp, wp) |
8534
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
6862 { |
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
6863 if (wp->w_id == id) |
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
6864 { |
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
6865 list_append_number(list, tabnr); |
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
6866 list_append_number(list, winnr); |
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
6867 return; |
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
6868 } |
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
6869 ++winnr; |
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
6870 } |
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
6871 ++tabnr; |
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
6872 winnr = 1; |
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
6873 } |
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
6874 list_append_number(list, 0); |
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
6875 list_append_number(list, 0); |
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
6876 } |
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
6877 |
9858
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
6878 win_T * |
15770
77e97f159554
patch 8.1.0892: failure when closing a window when location list is in use
Bram Moolenaar <Bram@vim.org>
parents:
15713
diff
changeset
|
6879 win_id2wp(int id) |
9858
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
6880 { |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
6881 win_T *wp; |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
6882 tabpage_T *tp; |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
6883 |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
6884 FOR_ALL_TAB_WINDOWS(tp, wp) |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
6885 if (wp->w_id == id) |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
6886 return wp; |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
6887 |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
6888 return NULL; |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
6889 } |
3e96d9ed2ca1
commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents:
9649
diff
changeset
|
6890 |
8534
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
6891 int |
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
6892 win_id2win(typval_T *argvars) |
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
6893 { |
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
6894 win_T *wp; |
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
6895 int nr = 1; |
15211
de63593896b3
patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents:
15006
diff
changeset
|
6896 int id = tv_get_number(&argvars[0]); |
8534
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
6897 |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9599
diff
changeset
|
6898 FOR_ALL_WINDOWS(wp) |
8534
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
6899 { |
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
6900 if (wp->w_id == id) |
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
6901 return nr; |
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
6902 ++nr; |
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
6903 } |
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
6904 return 0; |
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
6905 } |
8536
09041d2fd7d0
commit https://github.com/vim/vim/commit/9cdf86b86f5fdb5a45b682f336846f9d9a9c6f1f
Christian Brabandt <cb@256bit.org>
parents:
8534
diff
changeset
|
6906 |
09041d2fd7d0
commit https://github.com/vim/vim/commit/9cdf86b86f5fdb5a45b682f336846f9d9a9c6f1f
Christian Brabandt <cb@256bit.org>
parents:
8534
diff
changeset
|
6907 void |
09041d2fd7d0
commit https://github.com/vim/vim/commit/9cdf86b86f5fdb5a45b682f336846f9d9a9c6f1f
Christian Brabandt <cb@256bit.org>
parents:
8534
diff
changeset
|
6908 win_findbuf(typval_T *argvars, list_T *list) |
09041d2fd7d0
commit https://github.com/vim/vim/commit/9cdf86b86f5fdb5a45b682f336846f9d9a9c6f1f
Christian Brabandt <cb@256bit.org>
parents:
8534
diff
changeset
|
6909 { |
09041d2fd7d0
commit https://github.com/vim/vim/commit/9cdf86b86f5fdb5a45b682f336846f9d9a9c6f1f
Christian Brabandt <cb@256bit.org>
parents:
8534
diff
changeset
|
6910 win_T *wp; |
09041d2fd7d0
commit https://github.com/vim/vim/commit/9cdf86b86f5fdb5a45b682f336846f9d9a9c6f1f
Christian Brabandt <cb@256bit.org>
parents:
8534
diff
changeset
|
6911 tabpage_T *tp; |
15211
de63593896b3
patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents:
15006
diff
changeset
|
6912 int bufnr = tv_get_number(&argvars[0]); |
8536
09041d2fd7d0
commit https://github.com/vim/vim/commit/9cdf86b86f5fdb5a45b682f336846f9d9a9c6f1f
Christian Brabandt <cb@256bit.org>
parents:
8534
diff
changeset
|
6913 |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9599
diff
changeset
|
6914 FOR_ALL_TAB_WINDOWS(tp, wp) |
8536
09041d2fd7d0
commit https://github.com/vim/vim/commit/9cdf86b86f5fdb5a45b682f336846f9d9a9c6f1f
Christian Brabandt <cb@256bit.org>
parents:
8534
diff
changeset
|
6915 if (wp->w_buffer->b_fnum == bufnr) |
09041d2fd7d0
commit https://github.com/vim/vim/commit/9cdf86b86f5fdb5a45b682f336846f9d9a9c6f1f
Christian Brabandt <cb@256bit.org>
parents:
8534
diff
changeset
|
6916 list_append_number(list, wp->w_id); |
09041d2fd7d0
commit https://github.com/vim/vim/commit/9cdf86b86f5fdb5a45b682f336846f9d9a9c6f1f
Christian Brabandt <cb@256bit.org>
parents:
8534
diff
changeset
|
6917 } |
09041d2fd7d0
commit https://github.com/vim/vim/commit/9cdf86b86f5fdb5a45b682f336846f9d9a9c6f1f
Christian Brabandt <cb@256bit.org>
parents:
8534
diff
changeset
|
6918 |
14587
d33220d3bc27
patch 8.1.0307: there is no good way to get the window layout
Christian Brabandt <cb@256bit.org>
parents:
14397
diff
changeset
|
6919 /* |
d33220d3bc27
patch 8.1.0307: there is no good way to get the window layout
Christian Brabandt <cb@256bit.org>
parents:
14397
diff
changeset
|
6920 * Get the layout of the given tab page for winlayout(). |
d33220d3bc27
patch 8.1.0307: there is no good way to get the window layout
Christian Brabandt <cb@256bit.org>
parents:
14397
diff
changeset
|
6921 */ |
d33220d3bc27
patch 8.1.0307: there is no good way to get the window layout
Christian Brabandt <cb@256bit.org>
parents:
14397
diff
changeset
|
6922 void |
d33220d3bc27
patch 8.1.0307: there is no good way to get the window layout
Christian Brabandt <cb@256bit.org>
parents:
14397
diff
changeset
|
6923 get_framelayout(frame_T *fr, list_T *l, int outer) |
d33220d3bc27
patch 8.1.0307: there is no good way to get the window layout
Christian Brabandt <cb@256bit.org>
parents:
14397
diff
changeset
|
6924 { |
d33220d3bc27
patch 8.1.0307: there is no good way to get the window layout
Christian Brabandt <cb@256bit.org>
parents:
14397
diff
changeset
|
6925 frame_T *child; |
d33220d3bc27
patch 8.1.0307: there is no good way to get the window layout
Christian Brabandt <cb@256bit.org>
parents:
14397
diff
changeset
|
6926 list_T *fr_list; |
d33220d3bc27
patch 8.1.0307: there is no good way to get the window layout
Christian Brabandt <cb@256bit.org>
parents:
14397
diff
changeset
|
6927 list_T *win_list; |
d33220d3bc27
patch 8.1.0307: there is no good way to get the window layout
Christian Brabandt <cb@256bit.org>
parents:
14397
diff
changeset
|
6928 |
d33220d3bc27
patch 8.1.0307: there is no good way to get the window layout
Christian Brabandt <cb@256bit.org>
parents:
14397
diff
changeset
|
6929 if (fr == NULL) |
d33220d3bc27
patch 8.1.0307: there is no good way to get the window layout
Christian Brabandt <cb@256bit.org>
parents:
14397
diff
changeset
|
6930 return; |
d33220d3bc27
patch 8.1.0307: there is no good way to get the window layout
Christian Brabandt <cb@256bit.org>
parents:
14397
diff
changeset
|
6931 |
d33220d3bc27
patch 8.1.0307: there is no good way to get the window layout
Christian Brabandt <cb@256bit.org>
parents:
14397
diff
changeset
|
6932 if (outer) |
d33220d3bc27
patch 8.1.0307: there is no good way to get the window layout
Christian Brabandt <cb@256bit.org>
parents:
14397
diff
changeset
|
6933 // outermost call from f_winlayout() |
d33220d3bc27
patch 8.1.0307: there is no good way to get the window layout
Christian Brabandt <cb@256bit.org>
parents:
14397
diff
changeset
|
6934 fr_list = l; |
d33220d3bc27
patch 8.1.0307: there is no good way to get the window layout
Christian Brabandt <cb@256bit.org>
parents:
14397
diff
changeset
|
6935 else |
d33220d3bc27
patch 8.1.0307: there is no good way to get the window layout
Christian Brabandt <cb@256bit.org>
parents:
14397
diff
changeset
|
6936 { |
d33220d3bc27
patch 8.1.0307: there is no good way to get the window layout
Christian Brabandt <cb@256bit.org>
parents:
14397
diff
changeset
|
6937 fr_list = list_alloc(); |
d33220d3bc27
patch 8.1.0307: there is no good way to get the window layout
Christian Brabandt <cb@256bit.org>
parents:
14397
diff
changeset
|
6938 if (fr_list == NULL) |
d33220d3bc27
patch 8.1.0307: there is no good way to get the window layout
Christian Brabandt <cb@256bit.org>
parents:
14397
diff
changeset
|
6939 return; |
d33220d3bc27
patch 8.1.0307: there is no good way to get the window layout
Christian Brabandt <cb@256bit.org>
parents:
14397
diff
changeset
|
6940 list_append_list(l, fr_list); |
d33220d3bc27
patch 8.1.0307: there is no good way to get the window layout
Christian Brabandt <cb@256bit.org>
parents:
14397
diff
changeset
|
6941 } |
d33220d3bc27
patch 8.1.0307: there is no good way to get the window layout
Christian Brabandt <cb@256bit.org>
parents:
14397
diff
changeset
|
6942 |
d33220d3bc27
patch 8.1.0307: there is no good way to get the window layout
Christian Brabandt <cb@256bit.org>
parents:
14397
diff
changeset
|
6943 if (fr->fr_layout == FR_LEAF) |
d33220d3bc27
patch 8.1.0307: there is no good way to get the window layout
Christian Brabandt <cb@256bit.org>
parents:
14397
diff
changeset
|
6944 { |
d33220d3bc27
patch 8.1.0307: there is no good way to get the window layout
Christian Brabandt <cb@256bit.org>
parents:
14397
diff
changeset
|
6945 if (fr->fr_win != NULL) |
d33220d3bc27
patch 8.1.0307: there is no good way to get the window layout
Christian Brabandt <cb@256bit.org>
parents:
14397
diff
changeset
|
6946 { |
d33220d3bc27
patch 8.1.0307: there is no good way to get the window layout
Christian Brabandt <cb@256bit.org>
parents:
14397
diff
changeset
|
6947 list_append_string(fr_list, (char_u *)"leaf", -1); |
d33220d3bc27
patch 8.1.0307: there is no good way to get the window layout
Christian Brabandt <cb@256bit.org>
parents:
14397
diff
changeset
|
6948 list_append_number(fr_list, fr->fr_win->w_id); |
d33220d3bc27
patch 8.1.0307: there is no good way to get the window layout
Christian Brabandt <cb@256bit.org>
parents:
14397
diff
changeset
|
6949 } |
d33220d3bc27
patch 8.1.0307: there is no good way to get the window layout
Christian Brabandt <cb@256bit.org>
parents:
14397
diff
changeset
|
6950 } |
d33220d3bc27
patch 8.1.0307: there is no good way to get the window layout
Christian Brabandt <cb@256bit.org>
parents:
14397
diff
changeset
|
6951 else |
d33220d3bc27
patch 8.1.0307: there is no good way to get the window layout
Christian Brabandt <cb@256bit.org>
parents:
14397
diff
changeset
|
6952 { |
d33220d3bc27
patch 8.1.0307: there is no good way to get the window layout
Christian Brabandt <cb@256bit.org>
parents:
14397
diff
changeset
|
6953 list_append_string(fr_list, |
d33220d3bc27
patch 8.1.0307: there is no good way to get the window layout
Christian Brabandt <cb@256bit.org>
parents:
14397
diff
changeset
|
6954 fr->fr_layout == FR_ROW ? (char_u *)"row" : (char_u *)"col", -1); |
d33220d3bc27
patch 8.1.0307: there is no good way to get the window layout
Christian Brabandt <cb@256bit.org>
parents:
14397
diff
changeset
|
6955 |
d33220d3bc27
patch 8.1.0307: there is no good way to get the window layout
Christian Brabandt <cb@256bit.org>
parents:
14397
diff
changeset
|
6956 win_list = list_alloc(); |
d33220d3bc27
patch 8.1.0307: there is no good way to get the window layout
Christian Brabandt <cb@256bit.org>
parents:
14397
diff
changeset
|
6957 if (win_list == NULL) |
d33220d3bc27
patch 8.1.0307: there is no good way to get the window layout
Christian Brabandt <cb@256bit.org>
parents:
14397
diff
changeset
|
6958 return; |
d33220d3bc27
patch 8.1.0307: there is no good way to get the window layout
Christian Brabandt <cb@256bit.org>
parents:
14397
diff
changeset
|
6959 list_append_list(fr_list, win_list); |
d33220d3bc27
patch 8.1.0307: there is no good way to get the window layout
Christian Brabandt <cb@256bit.org>
parents:
14397
diff
changeset
|
6960 child = fr->fr_child; |
d33220d3bc27
patch 8.1.0307: there is no good way to get the window layout
Christian Brabandt <cb@256bit.org>
parents:
14397
diff
changeset
|
6961 while (child != NULL) |
d33220d3bc27
patch 8.1.0307: there is no good way to get the window layout
Christian Brabandt <cb@256bit.org>
parents:
14397
diff
changeset
|
6962 { |
d33220d3bc27
patch 8.1.0307: there is no good way to get the window layout
Christian Brabandt <cb@256bit.org>
parents:
14397
diff
changeset
|
6963 get_framelayout(child, win_list, FALSE); |
d33220d3bc27
patch 8.1.0307: there is no good way to get the window layout
Christian Brabandt <cb@256bit.org>
parents:
14397
diff
changeset
|
6964 child = child->fr_next; |
d33220d3bc27
patch 8.1.0307: there is no good way to get the window layout
Christian Brabandt <cb@256bit.org>
parents:
14397
diff
changeset
|
6965 } |
d33220d3bc27
patch 8.1.0307: there is no good way to get the window layout
Christian Brabandt <cb@256bit.org>
parents:
14397
diff
changeset
|
6966 } |
d33220d3bc27
patch 8.1.0307: there is no good way to get the window layout
Christian Brabandt <cb@256bit.org>
parents:
14397
diff
changeset
|
6967 } |
8536
09041d2fd7d0
commit https://github.com/vim/vim/commit/9cdf86b86f5fdb5a45b682f336846f9d9a9c6f1f
Christian Brabandt <cb@256bit.org>
parents:
8534
diff
changeset
|
6968 #endif |