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