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