Mercurial > vim
annotate src/window.c @ 26653:9838e43e6bb7
Added tag v8.2.3855 for changeset a3f38923c0377e4cefc82953a896709e8f206cee
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 19 Dec 2021 20:30:04 +0100 |
parents | fac6673086df |
children | fc859aea8cec |
rev | line source |
---|---|
10042
4aead6a9b7a9
commit https://github.com/vim/vim/commit/edf3f97ae2af024708ebb4ac614227327033ca47
Christian Brabandt <cb@256bit.org>
parents:
10013
diff
changeset
|
1 /* vi:set ts=8 sts=4 sw=4 noet: |
7 | 2 * |
3 * VIM - Vi IMproved by Bram Moolenaar | |
4 * | |
5 * Do ":help uganda" in Vim to read a list of people who contributed. | |
6 * Do ":help credits" in Vim to see a list of people who contributed. | |
7 * See README.txt for an overview of the Vim source code. | |
8 */ | |
9 | |
10 #include "vim.h" | |
11 | |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
12 static void cmd_with_count(char *cmd, char_u *bufp, size_t bufsize, long Prenum); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
13 static void win_init(win_T *newp, win_T *oldp, int flags); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
14 static void win_init_some(win_T *newp, win_T *oldp); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
15 static void frame_comp_pos(frame_T *topfrp, int *row, int *col); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
16 static void frame_setheight(frame_T *curfrp, int height); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
17 static void frame_setwidth(frame_T *curfrp, int width); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
18 static void win_exchange(long); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
19 static void win_rotate(int, int); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
20 static void win_totop(int size, int flags); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
21 static void win_equal_rec(win_T *next_curwin, int current, frame_T *topfr, int dir, int col, int row, int width, int height); |
26117
d4d9c7c55a5f
patch 8.2.3591: no event is triggered when closing a window
Bram Moolenaar <Bram@vim.org>
parents:
26077
diff
changeset
|
22 static void trigger_winclosed(win_T *win); |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
23 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
|
24 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
|
25 static tabpage_T *alt_tabpage(void); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
26 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
|
27 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
|
28 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
|
29 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
|
30 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
|
31 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
|
32 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
|
33 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
|
34 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
|
35 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
|
36 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
|
37 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
|
38 static tabpage_T *alloc_tabpage(void); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
39 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
|
40 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
|
41 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
|
42 static int frame_minheight(frame_T *topfrp, win_T *next_curwin); |
17789
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17670
diff
changeset
|
43 static int may_open_tabpage(void); |
25501
a1ed55c02e80
patch 8.2.3287: channel events not handled in BufEnter autocommand
Bram Moolenaar <Bram@vim.org>
parents:
25499
diff
changeset
|
44 static int win_enter_ext(win_T *wp, int flags); |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
45 static void win_free(win_T *wp, tabpage_T *tp); |
17789
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17670
diff
changeset
|
46 static int win_unlisted(win_T *wp); |
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17670
diff
changeset
|
47 static void win_append(win_T *after, win_T *wp); |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
48 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
|
49 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
|
50 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
|
51 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
|
52 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
|
53 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
|
54 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
|
55 |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
56 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
|
57 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
|
58 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
|
59 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
|
60 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
|
61 |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
62 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
|
63 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
|
64 |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
65 static win_T *win_alloc(win_T *after, int hidden); |
7 | 66 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
67 #define NOWIN (win_T *)-1 // non-existing window |
7 | 68 |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
69 #define ROWS_AVAIL (Rows - p_ch - tabline_height()) |
826 | 70 |
25499
5ebf9bb1cbcd
patch 8.2.3286: win_enter_ext() has too many boolean arguments
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
71 // flags for win_enter_ext() |
5ebf9bb1cbcd
patch 8.2.3286: win_enter_ext() has too many boolean arguments
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
72 #define WEE_UNDO_SYNC 0x01 |
5ebf9bb1cbcd
patch 8.2.3286: win_enter_ext() has too many boolean arguments
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
73 #define WEE_CURWIN_INVALID 0x02 |
5ebf9bb1cbcd
patch 8.2.3286: win_enter_ext() has too many boolean arguments
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
74 #define WEE_TRIGGER_NEW_AUTOCMDS 0x04 |
5ebf9bb1cbcd
patch 8.2.3286: win_enter_ext() has too many boolean arguments
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
75 #define WEE_TRIGGER_ENTER_AUTOCMDS 0x08 |
5ebf9bb1cbcd
patch 8.2.3286: win_enter_ext() has too many boolean arguments
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
76 #define WEE_TRIGGER_LEAVE_AUTOCMDS 0x10 |
25501
a1ed55c02e80
patch 8.2.3287: channel events not handled in BufEnter autocommand
Bram Moolenaar <Bram@vim.org>
parents:
25499
diff
changeset
|
77 #define WEE_ALLOW_PARSE_MESSAGES 0x20 |
25499
5ebf9bb1cbcd
patch 8.2.3286: win_enter_ext() has too many boolean arguments
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
78 |
826 | 79 static char *m_onlyone = N_("Already only one window"); |
80 | |
17516
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
81 // When non-zero splitting a window is forbidden. Used to avoid that nasty |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
82 // autocommands mess up the window structure. |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
83 static int split_disallowed = 0; |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
84 |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
85 // #define WIN_DEBUG |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
86 #ifdef WIN_DEBUG |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
87 /* |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
88 * Call this method to log the current window layout. |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
89 */ |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
90 static void |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
91 log_frame_layout(frame_T *frame) |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
92 { |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
93 ch_log(NULL, "layout %s, wi: %d, he: %d, wwi: %d, whe: %d, id: %d", |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
94 frame->fr_layout == FR_LEAF ? "LEAF" |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
95 : frame->fr_layout == FR_ROW ? "ROW" : "COL", |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
96 frame->fr_width, |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
97 frame->fr_height, |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
98 frame->fr_win == NULL ? -1 : frame->fr_win->w_width, |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
99 frame->fr_win == NULL ? -1 : frame->fr_win->w_height, |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
100 frame->fr_win == NULL ? -1 : frame->fr_win->w_id); |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
101 if (frame->fr_child != NULL) |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
102 { |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
103 ch_log(NULL, "children"); |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
104 log_frame_layout(frame->fr_child); |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
105 if (frame->fr_next != NULL) |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
106 ch_log(NULL, "END of children"); |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
107 } |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
108 if (frame->fr_next != NULL) |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
109 log_frame_layout(frame->fr_next); |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
110 } |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
111 #endif |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
112 |
7 | 113 /* |
15933
b2423b31266f
patch 8.1.0972: cannot switch from terminal window to next tabpage
Bram Moolenaar <Bram@vim.org>
parents:
15850
diff
changeset
|
114 * All CTRL-W window commands are handled here, called from normal_cmd(). |
7 | 115 */ |
116 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
117 do_window( |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
118 int nchar, |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
119 long Prenum, |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
120 int xchar) // extra char from ":wincmd gx" or NUL |
7 | 121 { |
122 long Prenum1; | |
123 win_T *wp; | |
124 #if defined(FEAT_SEARCHPATH) || defined(FEAT_FIND_ID) | |
125 char_u *ptr; | |
681 | 126 linenr_T lnum = -1; |
7 | 127 #endif |
128 #ifdef FEAT_FIND_ID | |
129 int type = FIND_DEFINE; | |
130 int len; | |
131 #endif | |
132 char_u cbuf[40]; | |
133 | |
19271
ebeeb4b4a1fa
patch 8.2.0194: some commands can cause problems in terminal popup
Bram Moolenaar <Bram@vim.org>
parents:
19265
diff
changeset
|
134 if (ERROR_IF_ANY_POPUP_WINDOW) |
16874
da5f5836e90c
patch 8.1.1438: some commands cause trouble in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
16863
diff
changeset
|
135 return; |
7 | 136 |
137 #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
|
138 # define CHECK_CMDWIN \ |
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
139 do { \ |
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
140 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
|
141 { \ |
25064
8f2262c72178
patch 8.2.3069: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
24216
diff
changeset
|
142 emsg(_(e_invalid_in_cmdline_window)); \ |
13632
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
143 return; \ |
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
144 } \ |
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
145 } while (0) |
7 | 146 #else |
13632
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
147 # define CHECK_CMDWIN do { /**/ } while (0) |
7 | 148 #endif |
149 | |
16874
da5f5836e90c
patch 8.1.1438: some commands cause trouble in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
16863
diff
changeset
|
150 Prenum1 = Prenum == 0 ? 1 : Prenum; |
da5f5836e90c
patch 8.1.1438: some commands cause trouble in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
16863
diff
changeset
|
151 |
7 | 152 switch (nchar) |
153 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
154 // split current window in two parts, horizontally |
7 | 155 case 'S': |
156 case Ctrl_S: | |
157 case 's': | |
13632
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
158 CHECK_CMDWIN; |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
159 reset_VIsual_and_resel(); // stop Visual mode |
635 | 160 #ifdef FEAT_QUICKFIX |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
161 // When splitting the quickfix window open a new buffer in it, |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
162 // don't replicate the quickfix buffer. |
635 | 163 if (bt_quickfix(curbuf)) |
164 goto newwindow; | |
165 #endif | |
7 | 166 #ifdef FEAT_GUI |
167 need_mouse_correct = TRUE; | |
168 #endif | |
7009 | 169 (void)win_split((int)Prenum, 0); |
7 | 170 break; |
171 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
172 // split current window in two parts, vertically |
7 | 173 case Ctrl_V: |
174 case 'v': | |
13632
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
175 CHECK_CMDWIN; |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
176 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
|
177 #ifdef FEAT_QUICKFIX |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
178 // When splitting the quickfix window open a new buffer in it, |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
179 // don't replicate the quickfix buffer. |
1664 | 180 if (bt_quickfix(curbuf)) |
181 goto newwindow; | |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8536
diff
changeset
|
182 #endif |
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8536
diff
changeset
|
183 #ifdef FEAT_GUI |
7 | 184 need_mouse_correct = TRUE; |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8536
diff
changeset
|
185 #endif |
7009 | 186 (void)win_split((int)Prenum, WSP_VERT); |
7 | 187 break; |
188 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
189 // split current window and edit alternate file |
7 | 190 case Ctrl_HAT: |
191 case '^': | |
13632
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
192 CHECK_CMDWIN; |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
193 reset_VIsual_and_resel(); // stop Visual mode |
15006
1fd8e32532f7
patch 8.1.0514: CTRL-W ^ does not work when alternate buffer has no name
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
194 |
1fd8e32532f7
patch 8.1.0514: CTRL-W ^ does not work when alternate buffer has no name
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
195 if (buflist_findnr(Prenum == 0 |
1fd8e32532f7
patch 8.1.0514: CTRL-W ^ does not work when alternate buffer has no name
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
196 ? curwin->w_alt_fnum : Prenum) == NULL) |
1fd8e32532f7
patch 8.1.0514: CTRL-W ^ does not work when alternate buffer has no name
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
197 { |
1fd8e32532f7
patch 8.1.0514: CTRL-W ^ does not work when alternate buffer has no name
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
198 if (Prenum == 0) |
25064
8f2262c72178
patch 8.2.3069: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
24216
diff
changeset
|
199 emsg(_(e_no_alternate_file)); |
15006
1fd8e32532f7
patch 8.1.0514: CTRL-W ^ does not work when alternate buffer has no name
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
200 else |
26602
fac6673086df
patch 8.2.3830: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26532
diff
changeset
|
201 semsg(_(e_buffer_nr_not_found), Prenum); |
15006
1fd8e32532f7
patch 8.1.0514: CTRL-W ^ does not work when alternate buffer has no name
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
202 break; |
1fd8e32532f7
patch 8.1.0514: CTRL-W ^ does not work when alternate buffer has no name
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
203 } |
1fd8e32532f7
patch 8.1.0514: CTRL-W ^ does not work when alternate buffer has no name
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
204 |
1fd8e32532f7
patch 8.1.0514: CTRL-W ^ does not work when alternate buffer has no name
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
205 if (!curbuf_locked() && win_split(0, 0) == OK) |
1fd8e32532f7
patch 8.1.0514: CTRL-W ^ does not work when alternate buffer has no name
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
206 (void)buflist_getfile( |
1fd8e32532f7
patch 8.1.0514: CTRL-W ^ does not work when alternate buffer has no name
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
207 Prenum == 0 ? curwin->w_alt_fnum : Prenum, |
1fd8e32532f7
patch 8.1.0514: CTRL-W ^ does not work when alternate buffer has no name
Bram Moolenaar <Bram@vim.org>
parents:
14862
diff
changeset
|
208 (linenr_T)0, GETF_ALT, FALSE); |
7 | 209 break; |
210 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
211 // open new window |
7 | 212 case Ctrl_N: |
213 case 'n': | |
13632
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
214 CHECK_CMDWIN; |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
215 reset_VIsual_and_resel(); // stop Visual mode |
635 | 216 #ifdef FEAT_QUICKFIX |
217 newwindow: | |
218 #endif | |
7 | 219 if (Prenum) |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
220 // window height |
1664 | 221 vim_snprintf((char *)cbuf, sizeof(cbuf) - 5, "%ld", Prenum); |
7 | 222 else |
223 cbuf[0] = NUL; | |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8536
diff
changeset
|
224 #if defined(FEAT_QUICKFIX) |
1664 | 225 if (nchar == 'v' || nchar == Ctrl_V) |
226 STRCAT(cbuf, "v"); | |
227 #endif | |
7 | 228 STRCAT(cbuf, "new"); |
229 do_cmdline_cmd(cbuf); | |
230 break; | |
231 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
232 // quit current window |
7 | 233 case Ctrl_Q: |
234 case 'q': | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
235 reset_VIsual_and_resel(); // stop Visual mode |
6432 | 236 cmd_with_count("quit", cbuf, sizeof(cbuf), Prenum); |
6398 | 237 do_cmdline_cmd(cbuf); |
7 | 238 break; |
239 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
240 // close current window |
7 | 241 case Ctrl_C: |
242 case 'c': | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
243 reset_VIsual_and_resel(); // stop Visual mode |
6432 | 244 cmd_with_count("close", cbuf, sizeof(cbuf), Prenum); |
6398 | 245 do_cmdline_cmd(cbuf); |
7 | 246 break; |
247 | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
248 #if defined(FEAT_QUICKFIX) |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
249 // close preview window |
7 | 250 case Ctrl_Z: |
251 case 'z': | |
13632
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
252 CHECK_CMDWIN; |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
253 reset_VIsual_and_resel(); // stop Visual mode |
7 | 254 do_cmdline_cmd((char_u *)"pclose"); |
255 break; | |
256 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
257 // cursor to preview window |
7 | 258 case 'P': |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9599
diff
changeset
|
259 FOR_ALL_WINDOWS(wp) |
7 | 260 if (wp->w_p_pvw) |
261 break; | |
262 if (wp == NULL) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15436
diff
changeset
|
263 emsg(_("E441: There is no preview window")); |
7 | 264 else |
265 win_goto(wp); | |
266 break; | |
267 #endif | |
268 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
269 // close all but current window |
7 | 270 case Ctrl_O: |
271 case 'o': | |
13632
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
272 CHECK_CMDWIN; |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
273 reset_VIsual_and_resel(); // stop Visual mode |
6432 | 274 cmd_with_count("only", cbuf, sizeof(cbuf), Prenum); |
6398 | 275 do_cmdline_cmd(cbuf); |
7 | 276 break; |
277 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
278 // cursor to next window with wrap around |
7 | 279 case Ctrl_W: |
280 case 'w': | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
281 // cursor to previous window with wrap around |
7 | 282 case 'W': |
13632
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
283 CHECK_CMDWIN; |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
284 if (ONE_WINDOW && Prenum != 1) // just one window |
7 | 285 beep_flush(); |
286 else | |
287 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
288 if (Prenum) // go to specified window |
7 | 289 { |
290 for (wp = firstwin; --Prenum > 0; ) | |
291 { | |
292 if (wp->w_next == NULL) | |
293 break; | |
294 else | |
295 wp = wp->w_next; | |
296 } | |
297 } | |
298 else | |
299 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
300 if (nchar == 'W') // go to previous window |
7 | 301 { |
302 wp = curwin->w_prev; | |
303 if (wp == NULL) | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
304 wp = lastwin; // wrap around |
7 | 305 } |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
306 else // go to next window |
7 | 307 { |
308 wp = curwin->w_next; | |
309 if (wp == NULL) | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
310 wp = firstwin; // wrap around |
7 | 311 } |
312 } | |
313 win_goto(wp); | |
314 } | |
315 break; | |
316 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
317 // cursor to window below |
7 | 318 case 'j': |
319 case K_DOWN: | |
320 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
|
321 CHECK_CMDWIN; |
7 | 322 win_goto_ver(FALSE, Prenum1); |
323 break; | |
324 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
325 // cursor to window above |
7 | 326 case 'k': |
327 case K_UP: | |
328 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
|
329 CHECK_CMDWIN; |
7 | 330 win_goto_ver(TRUE, Prenum1); |
331 break; | |
332 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
333 // cursor to left window |
7 | 334 case 'h': |
335 case K_LEFT: | |
336 case Ctrl_H: | |
337 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
|
338 CHECK_CMDWIN; |
7 | 339 win_goto_hor(TRUE, Prenum1); |
340 break; | |
341 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
342 // cursor to right window |
7 | 343 case 'l': |
344 case K_RIGHT: | |
345 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
|
346 CHECK_CMDWIN; |
7 | 347 win_goto_hor(FALSE, Prenum1); |
348 break; | |
349 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
350 // move window to new tab page |
826 | 351 case 'T': |
20737
0b4a9642b39c
patch 8.2.0921: CTRL-W T in cmdline window causes trouble
Bram Moolenaar <Bram@vim.org>
parents:
20711
diff
changeset
|
352 CHECK_CMDWIN; |
1906 | 353 if (one_window()) |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15490
diff
changeset
|
354 msg(_(m_onlyone)); |
826 | 355 else |
356 { | |
357 tabpage_T *oldtab = curtab; | |
358 tabpage_T *newtab; | |
359 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
360 // First create a new tab with the window, then go back to |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
361 // the old tab and close the window there. |
944 | 362 wp = curwin; |
826 | 363 if (win_new_tabpage((int)Prenum) == OK |
364 && valid_tabpage(oldtab)) | |
365 { | |
366 newtab = curtab; | |
4354 | 367 goto_tabpage_tp(oldtab, TRUE, TRUE); |
826 | 368 if (curwin == wp) |
369 win_close(curwin, FALSE); | |
370 if (valid_tabpage(newtab)) | |
4354 | 371 goto_tabpage_tp(newtab, TRUE, TRUE); |
826 | 372 } |
373 } | |
374 break; | |
375 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
376 // cursor to top-left window |
7 | 377 case 't': |
378 case Ctrl_T: | |
379 win_goto(firstwin); | |
380 break; | |
381 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
382 // cursor to bottom-right window |
7 | 383 case 'b': |
384 case Ctrl_B: | |
385 win_goto(lastwin); | |
386 break; | |
387 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
388 // cursor to last accessed (previous) window |
7 | 389 case 'p': |
390 case Ctrl_P: | |
8833
dc10bd23f918
commit https://github.com/vim/vim/commit/3dda7db4e1f7c4a8110a1f83001ec36b46693d27
Christian Brabandt <cb@256bit.org>
parents:
8804
diff
changeset
|
391 if (!win_valid(prevwin)) |
7 | 392 beep_flush(); |
393 else | |
394 win_goto(prevwin); | |
395 break; | |
396 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
397 // exchange current and next window |
7 | 398 case 'x': |
399 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
|
400 CHECK_CMDWIN; |
7 | 401 win_exchange(Prenum); |
402 break; | |
403 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
404 // rotate windows downwards |
7 | 405 case Ctrl_R: |
406 case 'r': | |
13632
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
407 CHECK_CMDWIN; |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
408 reset_VIsual_and_resel(); // stop Visual mode |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
409 win_rotate(FALSE, (int)Prenum1); // downwards |
7 | 410 break; |
411 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
412 // rotate windows upwards |
7 | 413 case 'R': |
13632
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
414 CHECK_CMDWIN; |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
415 reset_VIsual_and_resel(); // stop Visual mode |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
416 win_rotate(TRUE, (int)Prenum1); // upwards |
7 | 417 break; |
418 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
419 // move window to the very top/bottom/left/right |
7 | 420 case 'K': |
421 case 'J': | |
422 case 'H': | |
423 case 'L': | |
13632
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
424 CHECK_CMDWIN; |
7 | 425 win_totop((int)Prenum, |
426 ((nchar == 'H' || nchar == 'L') ? WSP_VERT : 0) | |
427 | ((nchar == 'H' || nchar == 'K') ? WSP_TOP : WSP_BOT)); | |
428 break; | |
429 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
430 // make all windows the same height |
7 | 431 case '=': |
432 #ifdef FEAT_GUI | |
433 need_mouse_correct = TRUE; | |
434 #endif | |
435 win_equal(NULL, FALSE, 'b'); | |
436 break; | |
437 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
438 // increase current window height |
7 | 439 case '+': |
440 #ifdef FEAT_GUI | |
441 need_mouse_correct = TRUE; | |
442 #endif | |
443 win_setheight(curwin->w_height + (int)Prenum1); | |
444 break; | |
445 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
446 // decrease current window height |
7 | 447 case '-': |
448 #ifdef FEAT_GUI | |
449 need_mouse_correct = TRUE; | |
450 #endif | |
451 win_setheight(curwin->w_height - (int)Prenum1); | |
452 break; | |
453 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
454 // set current window height |
7 | 455 case Ctrl__: |
456 case '_': | |
457 #ifdef FEAT_GUI | |
458 need_mouse_correct = TRUE; | |
459 #endif | |
460 win_setheight(Prenum ? (int)Prenum : 9999); | |
461 break; | |
462 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
463 // increase current window width |
7 | 464 case '>': |
465 #ifdef FEAT_GUI | |
466 need_mouse_correct = TRUE; | |
467 #endif | |
468 win_setwidth(curwin->w_width + (int)Prenum1); | |
469 break; | |
470 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
471 // decrease current window width |
7 | 472 case '<': |
473 #ifdef FEAT_GUI | |
474 need_mouse_correct = TRUE; | |
475 #endif | |
476 win_setwidth(curwin->w_width - (int)Prenum1); | |
477 break; | |
478 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
479 // set current window width |
7 | 480 case '|': |
481 #ifdef FEAT_GUI | |
482 need_mouse_correct = TRUE; | |
483 #endif | |
484 win_setwidth(Prenum != 0 ? (int)Prenum : 9999); | |
485 break; | |
486 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
487 // jump to tag and split window if tag exists (in preview window) |
7 | 488 #if defined(FEAT_QUICKFIX) |
489 case '}': | |
13632
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
490 CHECK_CMDWIN; |
7 | 491 if (Prenum) |
492 g_do_tagpreview = Prenum; | |
493 else | |
494 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
|
495 #endif |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
496 // FALLTHROUGH |
7 | 497 case ']': |
498 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
|
499 CHECK_CMDWIN; |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
500 // keep Visual mode, can select words to use as a tag |
7 | 501 if (Prenum) |
502 postponed_split = Prenum; | |
503 else | |
504 postponed_split = -1; | |
6251 | 505 #ifdef FEAT_QUICKFIX |
6264 | 506 if (nchar != '}') |
507 g_do_tagpreview = 0; | |
6251 | 508 #endif |
6239 | 509 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
510 // Execute the command right here, required when "wincmd ]" |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
511 // was used in a function. |
7 | 512 do_nv_ident(Ctrl_RSB, NUL); |
513 break; | |
514 | |
515 #ifdef FEAT_SEARCHPATH | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
516 // edit file name under cursor in a new window |
7 | 517 case 'f': |
681 | 518 case 'F': |
7 | 519 case Ctrl_F: |
820 | 520 wingotofile: |
13632
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
521 CHECK_CMDWIN; |
344 | 522 |
681 | 523 ptr = grab_file_name(Prenum1, &lnum); |
7 | 524 if (ptr != NULL) |
525 { | |
9349
b24900b73f90
commit https://github.com/vim/vim/commit/5d2ca0402954ff79b73d9c86cc16c8a6454b75a7
Christian Brabandt <cb@256bit.org>
parents:
9223
diff
changeset
|
526 tabpage_T *oldtab = curtab; |
b24900b73f90
commit https://github.com/vim/vim/commit/5d2ca0402954ff79b73d9c86cc16c8a6454b75a7
Christian Brabandt <cb@256bit.org>
parents:
9223
diff
changeset
|
527 win_T *oldwin = curwin; |
820 | 528 # ifdef FEAT_GUI |
7 | 529 need_mouse_correct = TRUE; |
820 | 530 # endif |
7 | 531 setpcmark(); |
532 if (win_split(0, 0) == OK) | |
533 { | |
2583 | 534 RESET_BINDING(curwin); |
9349
b24900b73f90
commit https://github.com/vim/vim/commit/5d2ca0402954ff79b73d9c86cc16c8a6454b75a7
Christian Brabandt <cb@256bit.org>
parents:
9223
diff
changeset
|
535 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
|
536 ECMD_HIDE, NULL) == FAIL) |
b24900b73f90
commit https://github.com/vim/vim/commit/5d2ca0402954ff79b73d9c86cc16c8a6454b75a7
Christian Brabandt <cb@256bit.org>
parents:
9223
diff
changeset
|
537 { |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
538 // Failed to open the file, close the window |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
539 // opened for it. |
9349
b24900b73f90
commit https://github.com/vim/vim/commit/5d2ca0402954ff79b73d9c86cc16c8a6454b75a7
Christian Brabandt <cb@256bit.org>
parents:
9223
diff
changeset
|
540 win_close(curwin, FALSE); |
b24900b73f90
commit https://github.com/vim/vim/commit/5d2ca0402954ff79b73d9c86cc16c8a6454b75a7
Christian Brabandt <cb@256bit.org>
parents:
9223
diff
changeset
|
541 goto_tabpage_win(oldtab, oldwin); |
b24900b73f90
commit https://github.com/vim/vim/commit/5d2ca0402954ff79b73d9c86cc16c8a6454b75a7
Christian Brabandt <cb@256bit.org>
parents:
9223
diff
changeset
|
542 } |
b24900b73f90
commit https://github.com/vim/vim/commit/5d2ca0402954ff79b73d9c86cc16c8a6454b75a7
Christian Brabandt <cb@256bit.org>
parents:
9223
diff
changeset
|
543 else if (nchar == 'F' && lnum >= 0) |
681 | 544 { |
545 curwin->w_cursor.lnum = lnum; | |
546 check_cursor_lnum(); | |
547 beginline(BL_SOL | BL_FIX); | |
548 } | |
7 | 549 } |
550 vim_free(ptr); | |
551 } | |
552 break; | |
553 #endif | |
554 | |
555 #ifdef FEAT_FIND_ID | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
556 // Go to the first occurrence of the identifier under cursor along path in a |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
557 // new window -- webb |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
558 case 'i': // Go to any match |
7 | 559 case Ctrl_I: |
560 type = FIND_ANY; | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
561 // FALLTHROUGH |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
562 case 'd': // Go to definition, using 'define' |
7 | 563 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
|
564 CHECK_CMDWIN; |
7 | 565 if ((len = find_ident_under_cursor(&ptr, FIND_IDENT)) == 0) |
566 break; | |
567 find_pattern_in_path(ptr, 0, len, TRUE, | |
568 Prenum == 0 ? TRUE : FALSE, type, | |
569 Prenum1, ACTION_SPLIT, (linenr_T)1, (linenr_T)MAXLNUM); | |
570 curwin->w_set_curswant = TRUE; | |
571 break; | |
572 #endif | |
573 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
574 // Quickfix window only: view the result under the cursor in a new split. |
14397
19d99d9e670c
patch 8.1.0213: CTRL-W CR does not work properly in a quickfix window
Christian Brabandt <cb@256bit.org>
parents:
14093
diff
changeset
|
575 #if defined(FEAT_QUICKFIX) |
170 | 576 case K_KENTER: |
577 case CAR: | |
578 if (bt_quickfix(curbuf)) | |
14397
19d99d9e670c
patch 8.1.0213: CTRL-W CR does not work properly in a quickfix window
Christian Brabandt <cb@256bit.org>
parents:
14093
diff
changeset
|
579 qf_view_result(TRUE); |
19d99d9e670c
patch 8.1.0213: CTRL-W CR does not work properly in a quickfix window
Christian Brabandt <cb@256bit.org>
parents:
14093
diff
changeset
|
580 break; |
170 | 581 #endif |
582 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
583 // CTRL-W g extended commands |
7 | 584 case 'g': |
585 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
|
586 CHECK_CMDWIN; |
7 | 587 #ifdef USE_ON_FLY_SCROLL |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
588 dont_scroll = TRUE; // disallow scrolling here |
7 | 589 #endif |
590 ++no_mapping; | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
591 ++allow_keys; // no mapping for xchar, but allow key codes |
7 | 592 if (xchar == NUL) |
1389 | 593 xchar = plain_vgetc(); |
7 | 594 LANGMAP_ADJUST(xchar, TRUE); |
595 --no_mapping; | |
596 --allow_keys; | |
597 #ifdef FEAT_CMDL_INFO | |
598 (void)add_to_showcmd(xchar); | |
599 #endif | |
600 switch (xchar) | |
601 { | |
602 #if defined(FEAT_QUICKFIX) | |
603 case '}': | |
604 xchar = Ctrl_RSB; | |
605 if (Prenum) | |
606 g_do_tagpreview = Prenum; | |
607 else | |
608 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
|
609 #endif |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
610 // FALLTHROUGH |
7 | 611 case ']': |
612 case Ctrl_RSB: | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
613 // keep Visual mode, can select words to use as a tag |
7 | 614 if (Prenum) |
615 postponed_split = Prenum; | |
616 else | |
617 postponed_split = -1; | |
618 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
619 // Execute the command right here, required when |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
620 // "wincmd g}" was used in a function. |
7 | 621 do_nv_ident('g', xchar); |
622 break; | |
623 | |
820 | 624 #ifdef FEAT_SEARCHPATH |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
625 case 'f': // CTRL-W gf: "gf" in a new tab page |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
626 case 'F': // CTRL-W gF: "gF" in a new tab page |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22470
diff
changeset
|
627 cmdmod.cmod_tab = tabpage_index(curtab) + 1; |
839 | 628 nchar = xchar; |
820 | 629 goto wingotofile; |
630 #endif | |
15933
b2423b31266f
patch 8.1.0972: cannot switch from terminal window to next tabpage
Bram Moolenaar <Bram@vim.org>
parents:
15850
diff
changeset
|
631 case 't': // CTRL-W gt: go to next tab page |
b2423b31266f
patch 8.1.0972: cannot switch from terminal window to next tabpage
Bram Moolenaar <Bram@vim.org>
parents:
15850
diff
changeset
|
632 goto_tabpage((int)Prenum); |
b2423b31266f
patch 8.1.0972: cannot switch from terminal window to next tabpage
Bram Moolenaar <Bram@vim.org>
parents:
15850
diff
changeset
|
633 break; |
b2423b31266f
patch 8.1.0972: cannot switch from terminal window to next tabpage
Bram Moolenaar <Bram@vim.org>
parents:
15850
diff
changeset
|
634 |
15937
c38fb03a6055
patch 8.1.0974: cannot switch from terminal window to previous tabpage
Bram Moolenaar <Bram@vim.org>
parents:
15933
diff
changeset
|
635 case 'T': // CTRL-W gT: go to previous tab page |
c38fb03a6055
patch 8.1.0974: cannot switch from terminal window to previous tabpage
Bram Moolenaar <Bram@vim.org>
parents:
15933
diff
changeset
|
636 goto_tabpage(-(int)Prenum1); |
c38fb03a6055
patch 8.1.0974: cannot switch from terminal window to previous tabpage
Bram Moolenaar <Bram@vim.org>
parents:
15933
diff
changeset
|
637 break; |
c38fb03a6055
patch 8.1.0974: cannot switch from terminal window to previous tabpage
Bram Moolenaar <Bram@vim.org>
parents:
15933
diff
changeset
|
638 |
21703
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21020
diff
changeset
|
639 case TAB: // CTRL-W g<Tab>: go to last used tab page |
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21020
diff
changeset
|
640 if (goto_tabpage_lastused() == FAIL) |
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21020
diff
changeset
|
641 beep_flush(); |
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21020
diff
changeset
|
642 break; |
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21020
diff
changeset
|
643 |
7 | 644 default: |
645 beep_flush(); | |
646 break; | |
647 } | |
648 break; | |
649 | |
650 default: beep_flush(); | |
651 break; | |
652 } | |
653 } | |
654 | |
6489 | 655 /* |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16447
diff
changeset
|
656 * Figure out the address type for ":wincmd". |
6489 | 657 */ |
658 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
659 get_wincmd_addr_type(char_u *arg, exarg_T *eap) |
6489 | 660 { |
661 switch (*arg) | |
662 { | |
663 case 'S': | |
664 case Ctrl_S: | |
665 case 's': | |
666 case Ctrl_N: | |
667 case 'n': | |
668 case 'j': | |
669 case Ctrl_J: | |
670 case 'k': | |
671 case Ctrl_K: | |
672 case 'T': | |
673 case Ctrl_R: | |
674 case 'r': | |
675 case 'R': | |
676 case 'K': | |
677 case 'J': | |
678 case '+': | |
679 case '-': | |
680 case Ctrl__: | |
681 case '_': | |
682 case '|': | |
683 case ']': | |
684 case Ctrl_RSB: | |
685 case 'g': | |
686 case Ctrl_G: | |
687 case Ctrl_V: | |
688 case 'v': | |
689 case 'h': | |
690 case Ctrl_H: | |
691 case 'l': | |
692 case Ctrl_L: | |
693 case 'H': | |
694 case 'L': | |
695 case '>': | |
696 case '<': | |
697 #if defined(FEAT_QUICKFIX) | |
698 case '}': | |
699 #endif | |
700 #ifdef FEAT_SEARCHPATH | |
701 case 'f': | |
702 case 'F': | |
703 case Ctrl_F: | |
704 #endif | |
705 #ifdef FEAT_FIND_ID | |
706 case 'i': | |
707 case Ctrl_I: | |
708 case 'd': | |
709 case Ctrl_D: | |
710 #endif | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16447
diff
changeset
|
711 // window size or any count |
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16447
diff
changeset
|
712 eap->addr_type = ADDR_OTHER; |
6489 | 713 break; |
714 | |
715 case Ctrl_HAT: | |
716 case '^': | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16447
diff
changeset
|
717 // buffer number |
6489 | 718 eap->addr_type = ADDR_BUFFERS; |
719 break; | |
720 | |
721 case Ctrl_Q: | |
722 case 'q': | |
723 case Ctrl_C: | |
724 case 'c': | |
725 case Ctrl_O: | |
726 case 'o': | |
727 case Ctrl_W: | |
728 case 'w': | |
729 case 'W': | |
730 case 'x': | |
731 case Ctrl_X: | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16447
diff
changeset
|
732 // window number |
6489 | 733 eap->addr_type = ADDR_WINDOWS; |
734 break; | |
735 | |
736 #if defined(FEAT_QUICKFIX) | |
737 case Ctrl_Z: | |
738 case 'z': | |
739 case 'P': | |
740 #endif | |
741 case 't': | |
742 case Ctrl_T: | |
743 case 'b': | |
744 case Ctrl_B: | |
745 case 'p': | |
746 case Ctrl_P: | |
747 case '=': | |
748 case CAR: | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16447
diff
changeset
|
749 // no count |
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16447
diff
changeset
|
750 eap->addr_type = ADDR_NONE; |
6489 | 751 break; |
752 } | |
753 } | |
754 | |
6432 | 755 static void |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
756 cmd_with_count( |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
757 char *cmd, |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
758 char_u *bufp, |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
759 size_t bufsize, |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
760 long Prenum) |
6432 | 761 { |
762 if (Prenum > 0) | |
24216
77cb22562852
patch 8.2.2649: Vim9: some wincmd arguments cause a white space error
Bram Moolenaar <Bram@vim.org>
parents:
24108
diff
changeset
|
763 vim_snprintf((char *)bufp, bufsize, "%s %ld", cmd, Prenum); |
77cb22562852
patch 8.2.2649: Vim9: some wincmd arguments cause a white space error
Bram Moolenaar <Bram@vim.org>
parents:
24108
diff
changeset
|
764 else |
77cb22562852
patch 8.2.2649: Vim9: some wincmd arguments cause a white space error
Bram Moolenaar <Bram@vim.org>
parents:
24108
diff
changeset
|
765 STRCPY(bufp, cmd); |
6432 | 766 } |
767 | |
7 | 768 /* |
17516
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
769 * If "split_disallowed" is set given an error and return FAIL. |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
770 * Otherwise return OK. |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
771 */ |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
772 static int |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
773 check_split_disallowed() |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
774 { |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
775 if (split_disallowed > 0) |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
776 { |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
777 emsg(_("E242: Can't split a window while closing another")); |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
778 return FAIL; |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
779 } |
23869
5a4f9c5c1b99
patch 8.2.2476: using freed memory when splitting window while closing buffer
Bram Moolenaar <Bram@vim.org>
parents:
23402
diff
changeset
|
780 if (curwin->w_buffer->b_locked_split) |
5a4f9c5c1b99
patch 8.2.2476: using freed memory when splitting window while closing buffer
Bram Moolenaar <Bram@vim.org>
parents:
23402
diff
changeset
|
781 { |
5a4f9c5c1b99
patch 8.2.2476: using freed memory when splitting window while closing buffer
Bram Moolenaar <Bram@vim.org>
parents:
23402
diff
changeset
|
782 emsg(_(e_cannot_split_window_when_closing_buffer)); |
5a4f9c5c1b99
patch 8.2.2476: using freed memory when splitting window while closing buffer
Bram Moolenaar <Bram@vim.org>
parents:
23402
diff
changeset
|
783 return FAIL; |
5a4f9c5c1b99
patch 8.2.2476: using freed memory when splitting window while closing buffer
Bram Moolenaar <Bram@vim.org>
parents:
23402
diff
changeset
|
784 } |
17516
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
785 return OK; |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
786 } |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
787 |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
788 /* |
7 | 789 * split the current window, implements CTRL-W s and :split |
790 * | |
791 * "size" is the height or width for the new window, 0 to use half of current | |
792 * height or width. | |
793 * | |
794 * "flags": | |
795 * WSP_ROOM: require enough room for new window | |
796 * WSP_VERT: vertical split. | |
797 * WSP_TOP: open window at the top-left of the shell (help window). | |
798 * WSP_BOT: open window at the bottom-right of the shell (quickfix window). | |
799 * WSP_HELP: creating the help window, keep layout snapshot | |
800 * | |
801 * return FAIL for failure, OK otherwise | |
802 */ | |
803 int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
804 win_split(int size, int flags) |
7 | 805 { |
19271
ebeeb4b4a1fa
patch 8.2.0194: some commands can cause problems in terminal popup
Bram Moolenaar <Bram@vim.org>
parents:
19265
diff
changeset
|
806 if (ERROR_IF_ANY_POPUP_WINDOW) |
16874
da5f5836e90c
patch 8.1.1438: some commands cause trouble in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
16863
diff
changeset
|
807 return FAIL; |
da5f5836e90c
patch 8.1.1438: some commands cause trouble in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
16863
diff
changeset
|
808 |
23869
5a4f9c5c1b99
patch 8.2.2476: using freed memory when splitting window while closing buffer
Bram Moolenaar <Bram@vim.org>
parents:
23402
diff
changeset
|
809 if (check_split_disallowed() == FAIL) |
5a4f9c5c1b99
patch 8.2.2476: using freed memory when splitting window while closing buffer
Bram Moolenaar <Bram@vim.org>
parents:
23402
diff
changeset
|
810 return FAIL; |
5a4f9c5c1b99
patch 8.2.2476: using freed memory when splitting window while closing buffer
Bram Moolenaar <Bram@vim.org>
parents:
23402
diff
changeset
|
811 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
812 // When the ":tab" modifier was used open a new tab page instead. |
682 | 813 if (may_open_tabpage() == OK) |
814 return OK; | |
815 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
816 // Add flags from ":vertical", ":topleft" and ":botright". |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22470
diff
changeset
|
817 flags |= cmdmod.cmod_split; |
7 | 818 if ((flags & WSP_TOP) && (flags & WSP_BOT)) |
819 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15436
diff
changeset
|
820 emsg(_("E442: Can't split topleft and botright at the same time")); |
7 | 821 return FAIL; |
822 } | |
823 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
824 // When creating the help window make a snapshot of the window layout. |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
825 // Otherwise clear the snapshot, it's now invalid. |
7 | 826 if (flags & WSP_HELP) |
1906 | 827 make_snapshot(SNAP_HELP_IDX); |
7 | 828 else |
1906 | 829 clear_snapshot(curtab, SNAP_HELP_IDX); |
7 | 830 |
831 return win_split_ins(size, flags, NULL, 0); | |
832 } | |
833 | |
834 /* | |
3263 | 835 * When "new_wp" is NULL: split the current window in two. |
836 * When "new_wp" is not NULL: insert this window at the far | |
7 | 837 * top/left/right/bottom. |
838 * return FAIL for failure, OK otherwise | |
839 */ | |
1906 | 840 int |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
841 win_split_ins( |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
842 int size, |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
843 int flags, |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
844 win_T *new_wp, |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
845 int dir) |
7 | 846 { |
3263 | 847 win_T *wp = new_wp; |
7 | 848 win_T *oldwin; |
849 int new_size = size; | |
850 int i; | |
851 int need_status = 0; | |
852 int do_equal = FALSE; | |
853 int needed; | |
854 int available; | |
855 int oldwin_height = 0; | |
856 int layout; | |
6077 | 857 frame_T *frp, *curfrp, *frp2, *prevfrp; |
7 | 858 int before; |
6052 | 859 int minheight; |
6066 | 860 int wmh1; |
13670
3085d67d24c8
patch 8.0.1707: when 'wfh' is set ":bel 10new" scrolls window
Christian Brabandt <cb@256bit.org>
parents:
13632
diff
changeset
|
861 int did_set_fraction = FALSE; |
7 | 862 |
863 if (flags & WSP_TOP) | |
864 oldwin = firstwin; | |
865 else if (flags & WSP_BOT) | |
866 oldwin = lastwin; | |
867 else | |
868 oldwin = curwin; | |
869 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
870 // 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
|
871 if (ONE_WINDOW && p_ls == 1 && oldwin->w_status_height == 0) |
7 | 872 { |
12998
dd734ee3e2fe
patch 8.0.1375: window size wrong after maximizing with WinBar
Christian Brabandt <cb@256bit.org>
parents:
12916
diff
changeset
|
873 if (VISIBLE_HEIGHT(oldwin) <= p_wmh && new_wp == NULL) |
7 | 874 { |
25306
078edc1821bf
patch 8.2.3190: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
25157
diff
changeset
|
875 emsg(_(e_not_enough_room)); |
7 | 876 return FAIL; |
877 } | |
878 need_status = STATUS_HEIGHT; | |
879 } | |
880 | |
1114 | 881 #ifdef FEAT_GUI |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
882 // May be needed for the scrollbars that are going to change. |
1114 | 883 if (gui.in_use) |
884 out_flush(); | |
885 #endif | |
886 | |
7 | 887 if (flags & WSP_VERT) |
888 { | |
6068 | 889 int wmw1; |
890 int minwidth; | |
891 | |
7 | 892 layout = FR_ROW; |
893 | |
894 /* | |
895 * Check if we are able to split the current window and compute its | |
896 * width. | |
897 */ | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
898 // Current window requires at least 1 space. |
6066 | 899 wmw1 = (p_wmw == 0 ? 1 : p_wmw); |
900 needed = wmw1 + 1; | |
7 | 901 if (flags & WSP_ROOM) |
6066 | 902 needed += p_wiw - wmw1; |
6077 | 903 if (flags & (WSP_BOT | WSP_TOP)) |
7 | 904 { |
6066 | 905 minwidth = frame_minwidth(topframe, NOWIN); |
7 | 906 available = topframe->fr_width; |
6052 | 907 needed += minwidth; |
7 | 908 } |
6077 | 909 else if (p_ea) |
910 { | |
911 minwidth = frame_minwidth(oldwin->w_frame, NOWIN); | |
912 prevfrp = oldwin->w_frame; | |
913 for (frp = oldwin->w_frame->fr_parent; frp != NULL; | |
914 frp = frp->fr_parent) | |
915 { | |
916 if (frp->fr_layout == FR_ROW) | |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
917 FOR_ALL_FRAMES(frp2, frp->fr_child) |
6077 | 918 if (frp2 != prevfrp) |
919 minwidth += frame_minwidth(frp2, NOWIN); | |
920 prevfrp = frp; | |
921 } | |
922 available = topframe->fr_width; | |
923 needed += minwidth; | |
924 } | |
7 | 925 else |
6052 | 926 { |
6066 | 927 minwidth = frame_minwidth(oldwin->w_frame, NOWIN); |
928 available = oldwin->w_frame->fr_width; | |
929 needed += minwidth; | |
6052 | 930 } |
3263 | 931 if (available < needed && new_wp == NULL) |
7 | 932 { |
25306
078edc1821bf
patch 8.2.3190: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
25157
diff
changeset
|
933 emsg(_(e_not_enough_room)); |
7 | 934 return FAIL; |
935 } | |
936 if (new_size == 0) | |
937 new_size = oldwin->w_width / 2; | |
6052 | 938 if (new_size > available - minwidth - 1) |
939 new_size = available - minwidth - 1; | |
6066 | 940 if (new_size < wmw1) |
941 new_size = wmw1; | |
7 | 942 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
943 // if it doesn't fit in the current window, need win_equal() |
7 | 944 if (oldwin->w_width - new_size - 1 < p_wmw) |
945 do_equal = TRUE; | |
779 | 946 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
947 // We don't like to take lines for the new window from a |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
948 // 'winfixwidth' window. Take them from a window to the left or right |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
949 // instead, if possible. Add one for the separator. |
779 | 950 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
|
951 win_setwidth_win(oldwin->w_width + new_size + 1, oldwin); |
1354 | 952 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
953 // Only make all windows the same width if one of them (except oldwin) |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
954 // is wider than one of the split windows. |
1354 | 955 if (!do_equal && p_ea && size == 0 && *p_ead != 'v' |
17516
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
956 && oldwin->w_frame->fr_parent != NULL) |
1354 | 957 { |
958 frp = oldwin->w_frame->fr_parent->fr_child; | |
959 while (frp != NULL) | |
960 { | |
961 if (frp->fr_win != oldwin && frp->fr_win != NULL | |
962 && (frp->fr_win->w_width > new_size | |
963 || frp->fr_win->w_width > oldwin->w_width | |
6373 | 964 - new_size - 1)) |
1354 | 965 { |
966 do_equal = TRUE; | |
967 break; | |
968 } | |
969 frp = frp->fr_next; | |
970 } | |
971 } | |
7 | 972 } |
973 else | |
974 { | |
975 layout = FR_COL; | |
976 | |
977 /* | |
978 * Check if we are able to split the current window and compute its | |
979 * height. | |
980 */ | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
981 // 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
|
982 wmh1 = (p_wmh == 0 ? 1 : p_wmh) + WINBAR_HEIGHT(curwin); |
6066 | 983 needed = wmh1 + STATUS_HEIGHT; |
7 | 984 if (flags & WSP_ROOM) |
6066 | 985 needed += p_wh - wmh1; |
6077 | 986 if (flags & (WSP_BOT | WSP_TOP)) |
7 | 987 { |
6066 | 988 minheight = frame_minheight(topframe, NOWIN) + need_status; |
7 | 989 available = topframe->fr_height; |
6052 | 990 needed += minheight; |
7 | 991 } |
6077 | 992 else if (p_ea) |
993 { | |
994 minheight = frame_minheight(oldwin->w_frame, NOWIN) + need_status; | |
995 prevfrp = oldwin->w_frame; | |
996 for (frp = oldwin->w_frame->fr_parent; frp != NULL; | |
997 frp = frp->fr_parent) | |
998 { | |
999 if (frp->fr_layout == FR_COL) | |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
1000 FOR_ALL_FRAMES(frp2, frp->fr_child) |
6077 | 1001 if (frp2 != prevfrp) |
1002 minheight += frame_minheight(frp2, NOWIN); | |
1003 prevfrp = frp; | |
1004 } | |
1005 available = topframe->fr_height; | |
1006 needed += minheight; | |
1007 } | |
7 | 1008 else |
1009 { | |
6066 | 1010 minheight = frame_minheight(oldwin->w_frame, NOWIN) + need_status; |
1011 available = oldwin->w_frame->fr_height; | |
1012 needed += minheight; | |
7 | 1013 } |
3263 | 1014 if (available < needed && new_wp == NULL) |
7 | 1015 { |
25306
078edc1821bf
patch 8.2.3190: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
25157
diff
changeset
|
1016 emsg(_(e_not_enough_room)); |
7 | 1017 return FAIL; |
1018 } | |
1019 oldwin_height = oldwin->w_height; | |
1020 if (need_status) | |
1021 { | |
1022 oldwin->w_status_height = STATUS_HEIGHT; | |
1023 oldwin_height -= STATUS_HEIGHT; | |
1024 } | |
1025 if (new_size == 0) | |
1026 new_size = oldwin_height / 2; | |
6052 | 1027 if (new_size > available - minheight - STATUS_HEIGHT) |
1028 new_size = available - minheight - STATUS_HEIGHT; | |
6066 | 1029 if (new_size < wmh1) |
1030 new_size = wmh1; | |
7 | 1031 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1032 // if it doesn't fit in the current window, need win_equal() |
7 | 1033 if (oldwin_height - new_size - STATUS_HEIGHT < p_wmh) |
1034 do_equal = TRUE; | |
1035 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1036 // We don't like to take lines for the new window from a |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1037 // 'winfixheight' window. Take them from a window above or below |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1038 // instead, if possible. |
7 | 1039 if (oldwin->w_p_wfh) |
1040 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1041 // Set w_fraction now so that the cursor keeps the same relative |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1042 // vertical position using the old height. |
13670
3085d67d24c8
patch 8.0.1707: when 'wfh' is set ":bel 10new" scrolls window
Christian Brabandt <cb@256bit.org>
parents:
13632
diff
changeset
|
1043 set_fraction(oldwin); |
3085d67d24c8
patch 8.0.1707: when 'wfh' is set ":bel 10new" scrolls window
Christian Brabandt <cb@256bit.org>
parents:
13632
diff
changeset
|
1044 did_set_fraction = TRUE; |
3085d67d24c8
patch 8.0.1707: when 'wfh' is set ":bel 10new" scrolls window
Christian Brabandt <cb@256bit.org>
parents:
13632
diff
changeset
|
1045 |
7 | 1046 win_setheight_win(oldwin->w_height + new_size + STATUS_HEIGHT, |
1047 oldwin); | |
1048 oldwin_height = oldwin->w_height; | |
1049 if (need_status) | |
1050 oldwin_height -= STATUS_HEIGHT; | |
1051 } | |
1354 | 1052 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1053 // Only make all windows the same height if one of them (except oldwin) |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1054 // 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
|
1055 if (!do_equal && p_ea && size == 0 && *p_ead != 'h' |
1354 | 1056 && oldwin->w_frame->fr_parent != NULL) |
1057 { | |
1058 frp = oldwin->w_frame->fr_parent->fr_child; | |
1059 while (frp != NULL) | |
1060 { | |
1061 if (frp->fr_win != oldwin && frp->fr_win != NULL | |
1062 && (frp->fr_win->w_height > new_size | |
1063 || frp->fr_win->w_height > oldwin_height - new_size | |
1064 - STATUS_HEIGHT)) | |
1065 { | |
1066 do_equal = TRUE; | |
1067 break; | |
1068 } | |
1069 frp = frp->fr_next; | |
1070 } | |
1071 } | |
7 | 1072 } |
1073 | |
1074 /* | |
1075 * allocate new window structure and link it in the window list | |
1076 */ | |
1077 if ((flags & WSP_TOP) == 0 | |
1078 && ((flags & WSP_BOT) | |
1079 || (flags & WSP_BELOW) | |
1080 || (!(flags & WSP_ABOVE) | |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8536
diff
changeset
|
1081 && ( (flags & WSP_VERT) ? p_spr : p_sb)))) |
7 | 1082 { |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1083 // new window below/right of current one |
3263 | 1084 if (new_wp == NULL) |
1906 | 1085 wp = win_alloc(oldwin, FALSE); |
7 | 1086 else |
1087 win_append(oldwin, wp); | |
1088 } | |
1089 else | |
1090 { | |
3263 | 1091 if (new_wp == NULL) |
1906 | 1092 wp = win_alloc(oldwin->w_prev, FALSE); |
7 | 1093 else |
1094 win_append(oldwin->w_prev, wp); | |
1095 } | |
1096 | |
3263 | 1097 if (new_wp == NULL) |
7 | 1098 { |
1099 if (wp == NULL) | |
1100 return FAIL; | |
1101 | |
1906 | 1102 new_frame(wp); |
1103 if (wp->w_frame == NULL) | |
1104 { | |
1105 win_free(wp, NULL); | |
1106 return FAIL; | |
1107 } | |
1108 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1109 // make the contents of the new window the same as the current one |
1822 | 1110 win_init(wp, curwin, flags); |
7 | 1111 } |
1112 | |
1113 /* | |
1114 * Reorganise the tree of frames to insert the new window. | |
1115 */ | |
1116 if (flags & (WSP_TOP | WSP_BOT)) | |
1117 { | |
1118 if ((topframe->fr_layout == FR_COL && (flags & WSP_VERT) == 0) | |
1119 || (topframe->fr_layout == FR_ROW && (flags & WSP_VERT) != 0)) | |
1120 { | |
1121 curfrp = topframe->fr_child; | |
1122 if (flags & WSP_BOT) | |
1123 while (curfrp->fr_next != NULL) | |
1124 curfrp = curfrp->fr_next; | |
1125 } | |
1126 else | |
1127 curfrp = topframe; | |
1128 before = (flags & WSP_TOP); | |
1129 } | |
1130 else | |
1131 { | |
1132 curfrp = oldwin->w_frame; | |
1133 if (flags & WSP_BELOW) | |
1134 before = FALSE; | |
1135 else if (flags & WSP_ABOVE) | |
1136 before = TRUE; | |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8536
diff
changeset
|
1137 else if (flags & WSP_VERT) |
7 | 1138 before = !p_spr; |
1139 else | |
1140 before = !p_sb; | |
1141 } | |
1142 if (curfrp->fr_parent == NULL || curfrp->fr_parent->fr_layout != layout) | |
1143 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1144 // Need to create a new frame in the tree to make a branch. |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16802
diff
changeset
|
1145 frp = ALLOC_CLEAR_ONE(frame_T); |
7 | 1146 *frp = *curfrp; |
1147 curfrp->fr_layout = layout; | |
1148 frp->fr_parent = curfrp; | |
1149 frp->fr_next = NULL; | |
1150 frp->fr_prev = NULL; | |
1151 curfrp->fr_child = frp; | |
1152 curfrp->fr_win = NULL; | |
1153 curfrp = frp; | |
1154 if (frp->fr_win != NULL) | |
1155 oldwin->w_frame = frp; | |
1156 else | |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
1157 FOR_ALL_FRAMES(frp, frp->fr_child) |
7 | 1158 frp->fr_parent = curfrp; |
1159 } | |
1160 | |
3263 | 1161 if (new_wp == NULL) |
1906 | 1162 frp = wp->w_frame; |
7 | 1163 else |
3263 | 1164 frp = new_wp->w_frame; |
7 | 1165 frp->fr_parent = curfrp->fr_parent; |
1166 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1167 // Insert the new frame at the right place in the frame list. |
7 | 1168 if (before) |
1169 frame_insert(curfrp, frp); | |
1170 else | |
1171 frame_append(curfrp, frp); | |
1172 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1173 // Set w_fraction now so that the cursor keeps the same relative |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1174 // vertical position. |
13670
3085d67d24c8
patch 8.0.1707: when 'wfh' is set ":bel 10new" scrolls window
Christian Brabandt <cb@256bit.org>
parents:
13632
diff
changeset
|
1175 if (!did_set_fraction) |
3085d67d24c8
patch 8.0.1707: when 'wfh' is set ":bel 10new" scrolls window
Christian Brabandt <cb@256bit.org>
parents:
13632
diff
changeset
|
1176 set_fraction(oldwin); |
2665 | 1177 wp->w_fraction = oldwin->w_fraction; |
1178 | |
7 | 1179 if (flags & WSP_VERT) |
1180 { | |
1181 wp->w_p_scr = curwin->w_p_scr; | |
2665 | 1182 |
7 | 1183 if (need_status) |
1184 { | |
2115
5fd44cf99b6d
updated for version 7.2.398
Bram Moolenaar <bram@zimbu.org>
parents:
2064
diff
changeset
|
1185 win_new_height(oldwin, oldwin->w_height - 1); |
7 | 1186 oldwin->w_status_height = need_status; |
1187 } | |
1188 if (flags & (WSP_TOP | WSP_BOT)) | |
1189 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1190 // set height and row of new window to full height |
685 | 1191 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
|
1192 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
|
1193 - WINBAR_HEIGHT(wp)); |
7 | 1194 wp->w_status_height = (p_ls > 0); |
1195 } | |
1196 else | |
1197 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1198 // height and row of new window is same as current window |
7 | 1199 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
|
1200 win_new_height(wp, VISIBLE_HEIGHT(oldwin)); |
7 | 1201 wp->w_status_height = oldwin->w_status_height; |
1202 } | |
1203 frp->fr_height = curfrp->fr_height; | |
1204 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1205 // "new_size" of the current window goes to the new window, use |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1206 // one column for the vertical separator |
2115
5fd44cf99b6d
updated for version 7.2.398
Bram Moolenaar <bram@zimbu.org>
parents:
2064
diff
changeset
|
1207 win_new_width(wp, new_size); |
7 | 1208 if (before) |
1209 wp->w_vsep_width = 1; | |
1210 else | |
1211 { | |
1212 wp->w_vsep_width = oldwin->w_vsep_width; | |
1213 oldwin->w_vsep_width = 1; | |
1214 } | |
1215 if (flags & (WSP_TOP | WSP_BOT)) | |
1216 { | |
1217 if (flags & WSP_BOT) | |
1218 frame_add_vsep(curfrp); | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1219 // Set width of neighbor frame |
7 | 1220 frame_new_width(curfrp, curfrp->fr_width |
779 | 1221 - (new_size + ((flags & WSP_TOP) != 0)), flags & WSP_TOP, |
1222 FALSE); | |
7 | 1223 } |
1224 else | |
779 | 1225 win_new_width(oldwin, oldwin->w_width - (new_size + 1)); |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1226 if (before) // new window left of current one |
7 | 1227 { |
1228 wp->w_wincol = oldwin->w_wincol; | |
1229 oldwin->w_wincol += new_size + 1; | |
1230 } | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1231 else // new window right of current one |
7 | 1232 wp->w_wincol = oldwin->w_wincol + oldwin->w_width + 1; |
1233 frame_fix_width(oldwin); | |
1234 frame_fix_width(wp); | |
1235 } | |
1236 else | |
1237 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1238 // width and column of new window is same as current window |
7 | 1239 if (flags & (WSP_TOP | WSP_BOT)) |
1240 { | |
1241 wp->w_wincol = 0; | |
2115
5fd44cf99b6d
updated for version 7.2.398
Bram Moolenaar <bram@zimbu.org>
parents:
2064
diff
changeset
|
1242 win_new_width(wp, Columns); |
7 | 1243 wp->w_vsep_width = 0; |
1244 } | |
1245 else | |
1246 { | |
1247 wp->w_wincol = oldwin->w_wincol; | |
2115
5fd44cf99b6d
updated for version 7.2.398
Bram Moolenaar <bram@zimbu.org>
parents:
2064
diff
changeset
|
1248 win_new_width(wp, oldwin->w_width); |
7 | 1249 wp->w_vsep_width = oldwin->w_vsep_width; |
1250 } | |
1251 frp->fr_width = curfrp->fr_width; | |
1252 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1253 // "new_size" of the current window goes to the new window, use |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1254 // one row for the status line |
7 | 1255 win_new_height(wp, new_size); |
1256 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
|
1257 { |
12491
7ab796b041bd
patch 8.0.1125: wrong window height when splitting window with window toolbar
Christian Brabandt <cb@256bit.org>
parents:
12487
diff
changeset
|
1258 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
|
1259 + WINBAR_HEIGHT(wp) ; |
9102
0e90f3e13d88
commit https://github.com/vim/vim/commit/991dea3ab185fb35e577ab0bdfd443cd4b43ccc6
Christian Brabandt <cb@256bit.org>
parents:
8833
diff
changeset
|
1260 |
0e90f3e13d88
commit https://github.com/vim/vim/commit/991dea3ab185fb35e577ab0bdfd443cd4b43ccc6
Christian Brabandt <cb@256bit.org>
parents:
8833
diff
changeset
|
1261 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
|
1262 new_fr_height -= STATUS_HEIGHT; |
0e90f3e13d88
commit https://github.com/vim/vim/commit/991dea3ab185fb35e577ab0bdfd443cd4b43ccc6
Christian Brabandt <cb@256bit.org>
parents:
8833
diff
changeset
|
1263 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
|
1264 } |
7 | 1265 else |
1266 win_new_height(oldwin, oldwin_height - (new_size + STATUS_HEIGHT)); | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1267 if (before) // new window above current one |
7 | 1268 { |
1269 wp->w_winrow = oldwin->w_winrow; | |
1270 wp->w_status_height = STATUS_HEIGHT; | |
1271 oldwin->w_winrow += wp->w_height + STATUS_HEIGHT; | |
1272 } | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1273 else // new window below current one |
7 | 1274 { |
12998
dd734ee3e2fe
patch 8.0.1375: window size wrong after maximizing with WinBar
Christian Brabandt <cb@256bit.org>
parents:
12916
diff
changeset
|
1275 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
|
1276 + STATUS_HEIGHT; |
7 | 1277 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
|
1278 if (!(flags & WSP_BOT)) |
0e90f3e13d88
commit https://github.com/vim/vim/commit/991dea3ab185fb35e577ab0bdfd443cd4b43ccc6
Christian Brabandt <cb@256bit.org>
parents:
8833
diff
changeset
|
1279 oldwin->w_status_height = STATUS_HEIGHT; |
7 | 1280 } |
1281 if (flags & WSP_BOT) | |
1282 frame_add_statusline(curfrp); | |
1283 frame_fix_height(wp); | |
1284 frame_fix_height(oldwin); | |
1285 } | |
1286 | |
1287 if (flags & (WSP_TOP | WSP_BOT)) | |
1288 (void)win_comp_pos(); | |
1289 | |
22464
b74bdd85bb26
patch 8.2.1780: statusline not updated when splitting windows
Bram Moolenaar <Bram@vim.org>
parents:
22399
diff
changeset
|
1290 // Both windows need redrawing. Update all status lines, in case they |
b74bdd85bb26
patch 8.2.1780: statusline not updated when splitting windows
Bram Moolenaar <Bram@vim.org>
parents:
22399
diff
changeset
|
1291 // show something related to the window count or position. |
7 | 1292 redraw_win_later(wp, NOT_VALID); |
1293 redraw_win_later(oldwin, NOT_VALID); | |
22464
b74bdd85bb26
patch 8.2.1780: statusline not updated when splitting windows
Bram Moolenaar <Bram@vim.org>
parents:
22399
diff
changeset
|
1294 status_redraw_all(); |
7 | 1295 |
1296 if (need_status) | |
1297 { | |
1298 msg_row = Rows - 1; | |
1299 msg_col = sc_col; | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1300 msg_clr_eos_force(); // Old command/ruler may still be there |
7 | 1301 comp_col(); |
1302 msg_row = Rows - 1; | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1303 msg_col = 0; // put position back at start of line |
7 | 1304 } |
1305 | |
1306 /* | |
2115
5fd44cf99b6d
updated for version 7.2.398
Bram Moolenaar <bram@zimbu.org>
parents:
2064
diff
changeset
|
1307 * equalize the window sizes. |
7 | 1308 */ |
1309 if (do_equal || dir != 0) | |
1310 win_equal(wp, TRUE, | |
1311 (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
|
1312 : dir == 'h' ? 'b' : 'v'); |
7 | 1313 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1314 // Don't change the window height/width to 'winheight' / 'winwidth' if a |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1315 // size was given. |
7 | 1316 if (flags & WSP_VERT) |
1317 { | |
1318 i = p_wiw; | |
1319 if (size != 0) | |
1320 p_wiw = size; | |
1321 | |
1322 # ifdef FEAT_GUI | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1323 // When 'guioptions' includes 'L' or 'R' may have to add scrollbars. |
7 | 1324 if (gui.in_use) |
1325 gui_init_which_components(NULL); | |
1326 # endif | |
1327 } | |
1328 else | |
1329 { | |
1330 i = p_wh; | |
1331 if (size != 0) | |
1332 p_wh = size; | |
1333 } | |
2115
5fd44cf99b6d
updated for version 7.2.398
Bram Moolenaar <bram@zimbu.org>
parents:
2064
diff
changeset
|
1334 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1335 // Keep same changelist position in new window. |
6096 | 1336 wp->w_changelistidx = oldwin->w_changelistidx; |
1337 | |
2115
5fd44cf99b6d
updated for version 7.2.398
Bram Moolenaar <bram@zimbu.org>
parents:
2064
diff
changeset
|
1338 /* |
5fd44cf99b6d
updated for version 7.2.398
Bram Moolenaar <bram@zimbu.org>
parents:
2064
diff
changeset
|
1339 * make the new window the current window |
5fd44cf99b6d
updated for version 7.2.398
Bram Moolenaar <bram@zimbu.org>
parents:
2064
diff
changeset
|
1340 */ |
25501
a1ed55c02e80
patch 8.2.3287: channel events not handled in BufEnter autocommand
Bram Moolenaar <Bram@vim.org>
parents:
25499
diff
changeset
|
1341 (void)win_enter_ext(wp, WEE_TRIGGER_NEW_AUTOCMDS |
a1ed55c02e80
patch 8.2.3287: channel events not handled in BufEnter autocommand
Bram Moolenaar <Bram@vim.org>
parents:
25499
diff
changeset
|
1342 | WEE_TRIGGER_ENTER_AUTOCMDS | WEE_TRIGGER_LEAVE_AUTOCMDS); |
7 | 1343 if (flags & WSP_VERT) |
1344 p_wiw = i; | |
1345 else | |
1346 p_wh = i; | |
1347 | |
1348 return OK; | |
1349 } | |
1350 | |
1906 | 1351 |
675 | 1352 /* |
1353 * Initialize window "newp" from window "oldp". | |
1354 * Used when splitting a window and when creating a new tab page. | |
1355 * The windows will both edit the same buffer. | |
1822 | 1356 * WSP_NEWLOC may be specified in flags to prevent the location list from |
1357 * being copied. | |
675 | 1358 */ |
1359 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1360 win_init(win_T *newp, win_T *oldp, int flags UNUSED) |
675 | 1361 { |
1362 int i; | |
1363 | |
1364 newp->w_buffer = oldp->w_buffer; | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2201
diff
changeset
|
1365 #ifdef FEAT_SYN_HL |
2253
12ebd6f6dfce
Fixed: after ":ownsyntax perl" and ":e" syntax was cleared in other window.
Bram Moolenaar <bram@vim.org>
parents:
2252
diff
changeset
|
1366 newp->w_s = &(oldp->w_buffer->b_s); |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2201
diff
changeset
|
1367 #endif |
675 | 1368 oldp->w_buffer->b_nwindows++; |
1369 newp->w_cursor = oldp->w_cursor; | |
1370 newp->w_valid = 0; | |
1371 newp->w_curswant = oldp->w_curswant; | |
1372 newp->w_set_curswant = oldp->w_set_curswant; | |
1373 newp->w_topline = oldp->w_topline; | |
1374 #ifdef FEAT_DIFF | |
1375 newp->w_topfill = oldp->w_topfill; | |
1376 #endif | |
1377 newp->w_leftcol = oldp->w_leftcol; | |
1378 newp->w_pcmark = oldp->w_pcmark; | |
1379 newp->w_prev_pcmark = oldp->w_prev_pcmark; | |
1380 newp->w_alt_fnum = oldp->w_alt_fnum; | |
826 | 1381 newp->w_wrow = oldp->w_wrow; |
675 | 1382 newp->w_fraction = oldp->w_fraction; |
1383 newp->w_prev_fraction_row = oldp->w_prev_fraction_row; | |
1384 copy_jumplist(oldp, newp); | |
1385 #ifdef FEAT_QUICKFIX | |
1822 | 1386 if (flags & WSP_NEWLOC) |
1387 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1388 // Don't copy the location list. |
1822 | 1389 newp->w_llist = NULL; |
1390 newp->w_llist_ref = NULL; | |
1391 } | |
1392 else | |
14844
a74786d0370c
patch 8.1.0434: copy_loclist() is too long
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
1393 copy_loclist_stack(oldp, newp); |
675 | 1394 #endif |
5584 | 1395 newp->w_localdir = (oldp->w_localdir == NULL) |
1396 ? NULL : vim_strsave(oldp->w_localdir); | |
21723
5b0796787cb2
patch 8.2.1411: when splitting a window localdir is copied but prevdir is not
Bram Moolenaar <Bram@vim.org>
parents:
21703
diff
changeset
|
1397 newp->w_prevdir = (oldp->w_prevdir == NULL) |
5b0796787cb2
patch 8.2.1411: when splitting a window localdir is copied but prevdir is not
Bram Moolenaar <Bram@vim.org>
parents:
21703
diff
changeset
|
1398 ? NULL : vim_strsave(oldp->w_prevdir); |
675 | 1399 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1400 // copy tagstack and folds |
675 | 1401 for (i = 0; i < oldp->w_tagstacklen; i++) |
1402 { | |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16427
diff
changeset
|
1403 taggy_T *tag = &newp->w_tagstack[i]; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16427
diff
changeset
|
1404 *tag = oldp->w_tagstack[i]; |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16427
diff
changeset
|
1405 if (tag->tagname != NULL) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16427
diff
changeset
|
1406 tag->tagname = vim_strsave(tag->tagname); |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16427
diff
changeset
|
1407 if (tag->user_data != NULL) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16427
diff
changeset
|
1408 tag->user_data = vim_strsave(tag->user_data); |
675 | 1409 } |
1410 newp->w_tagstackidx = oldp->w_tagstackidx; | |
1411 newp->w_tagstacklen = oldp->w_tagstacklen; | |
3068 | 1412 #ifdef FEAT_FOLDING |
675 | 1413 copyFoldingState(oldp, newp); |
3068 | 1414 #endif |
1906 | 1415 |
1416 win_init_some(newp, oldp); | |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2306
diff
changeset
|
1417 |
3068 | 1418 #ifdef FEAT_SYN_HL |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2306
diff
changeset
|
1419 check_colorcolumn(newp); |
3068 | 1420 #endif |
26193
c83460a14407
patch 8.2.3628: looking terminal colors is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26171
diff
changeset
|
1421 #ifdef FEAT_TERMINAL |
c83460a14407
patch 8.2.3628: looking terminal colors is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26171
diff
changeset
|
1422 term_update_wincolor(newp); |
c83460a14407
patch 8.2.3628: looking terminal colors is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26171
diff
changeset
|
1423 #endif |
1906 | 1424 } |
1425 | |
1426 /* | |
6222 | 1427 * Initialize window "newp" from window "old". |
1906 | 1428 * Only the essential things are copied. |
1429 */ | |
1430 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1431 win_init_some(win_T *newp, win_T *oldp) |
1906 | 1432 { |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1433 // Use the same argument list. |
1906 | 1434 newp->w_alist = oldp->w_alist; |
1435 ++newp->w_alist->al_refcount; | |
1436 newp->w_arg_idx = oldp->w_arg_idx; | |
1437 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1438 // copy options from existing window |
1906 | 1439 win_copy_options(oldp, newp); |
675 | 1440 } |
1441 | |
16902
23645f9a5ce2
patch 8.1.1452: line and col property of popup windows not properly checked
Bram Moolenaar <Bram@vim.org>
parents:
16890
diff
changeset
|
1442 /* |
23645f9a5ce2
patch 8.1.1452: line and col property of popup windows not properly checked
Bram Moolenaar <Bram@vim.org>
parents:
16890
diff
changeset
|
1443 * Return TRUE if "win" is a global popup or a popup in the current tab page. |
23645f9a5ce2
patch 8.1.1452: line and col property of popup windows not properly checked
Bram Moolenaar <Bram@vim.org>
parents:
16890
diff
changeset
|
1444 */ |
17051
221d4b82bc0b
patch 8.1.1525: cannot move a popup window with the mouse
Bram Moolenaar <Bram@vim.org>
parents:
17043
diff
changeset
|
1445 int |
16780
491c01280a5d
patch 8.1.1392: build failure in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
16778
diff
changeset
|
1446 win_valid_popup(win_T *win UNUSED) |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
1447 { |
18763
49b78d6465e5
patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents:
18590
diff
changeset
|
1448 #ifdef FEAT_PROP_POPUP |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
1449 win_T *wp; |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
1450 |
19888
435726a03481
patch 8.2.0500: using the same loop in many places
Bram Moolenaar <Bram@vim.org>
parents:
19291
diff
changeset
|
1451 FOR_ALL_POPUPWINS(wp) |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
1452 if (wp == win) |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
1453 return TRUE; |
19888
435726a03481
patch 8.2.0500: using the same loop in many places
Bram Moolenaar <Bram@vim.org>
parents:
19291
diff
changeset
|
1454 FOR_ALL_POPUPWINS_IN_TAB(curtab, wp) |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
1455 if (wp == win) |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
1456 return TRUE; |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
1457 #endif |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
1458 return FALSE; |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
1459 } |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
1460 |
7 | 1461 /* |
9875
42adbf172ecd
commit https://github.com/vim/vim/commit/e59215c7dcae17b03daf39517560cfaa03314f5a
Christian Brabandt <cb@256bit.org>
parents:
9858
diff
changeset
|
1462 * Check if "win" is a pointer to an existing window in the current tab page. |
7 | 1463 */ |
1464 int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1465 win_valid(win_T *win) |
7 | 1466 { |
1467 win_T *wp; | |
1468 | |
1469 if (win == NULL) | |
1470 return FALSE; | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9599
diff
changeset
|
1471 FOR_ALL_WINDOWS(wp) |
7 | 1472 if (wp == win) |
1473 return TRUE; | |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
1474 return win_valid_popup(win); |
7 | 1475 } |
1476 | |
1477 /* | |
22838
80bd5de5dcab
patch 8.2.1966: popup becomes current window after closing a terminal window
Bram Moolenaar <Bram@vim.org>
parents:
22800
diff
changeset
|
1478 * Find window "id" in the current tab page. |
22900
2c1520981e63
patch 8.2.1997: window changes when using bufload() while in a terminal popup
Bram Moolenaar <Bram@vim.org>
parents:
22838
diff
changeset
|
1479 * Also find popup windows. |
22838
80bd5de5dcab
patch 8.2.1966: popup becomes current window after closing a terminal window
Bram Moolenaar <Bram@vim.org>
parents:
22800
diff
changeset
|
1480 * Return NULL if not found. |
80bd5de5dcab
patch 8.2.1966: popup becomes current window after closing a terminal window
Bram Moolenaar <Bram@vim.org>
parents:
22800
diff
changeset
|
1481 */ |
80bd5de5dcab
patch 8.2.1966: popup becomes current window after closing a terminal window
Bram Moolenaar <Bram@vim.org>
parents:
22800
diff
changeset
|
1482 win_T * |
80bd5de5dcab
patch 8.2.1966: popup becomes current window after closing a terminal window
Bram Moolenaar <Bram@vim.org>
parents:
22800
diff
changeset
|
1483 win_find_by_id(int id) |
80bd5de5dcab
patch 8.2.1966: popup becomes current window after closing a terminal window
Bram Moolenaar <Bram@vim.org>
parents:
22800
diff
changeset
|
1484 { |
80bd5de5dcab
patch 8.2.1966: popup becomes current window after closing a terminal window
Bram Moolenaar <Bram@vim.org>
parents:
22800
diff
changeset
|
1485 win_T *wp; |
80bd5de5dcab
patch 8.2.1966: popup becomes current window after closing a terminal window
Bram Moolenaar <Bram@vim.org>
parents:
22800
diff
changeset
|
1486 |
80bd5de5dcab
patch 8.2.1966: popup becomes current window after closing a terminal window
Bram Moolenaar <Bram@vim.org>
parents:
22800
diff
changeset
|
1487 FOR_ALL_WINDOWS(wp) |
80bd5de5dcab
patch 8.2.1966: popup becomes current window after closing a terminal window
Bram Moolenaar <Bram@vim.org>
parents:
22800
diff
changeset
|
1488 if (wp->w_id == id) |
80bd5de5dcab
patch 8.2.1966: popup becomes current window after closing a terminal window
Bram Moolenaar <Bram@vim.org>
parents:
22800
diff
changeset
|
1489 return wp; |
22900
2c1520981e63
patch 8.2.1997: window changes when using bufload() while in a terminal popup
Bram Moolenaar <Bram@vim.org>
parents:
22838
diff
changeset
|
1490 #ifdef FEAT_PROP_POPUP |
2c1520981e63
patch 8.2.1997: window changes when using bufload() while in a terminal popup
Bram Moolenaar <Bram@vim.org>
parents:
22838
diff
changeset
|
1491 FOR_ALL_POPUPWINS(wp) |
2c1520981e63
patch 8.2.1997: window changes when using bufload() while in a terminal popup
Bram Moolenaar <Bram@vim.org>
parents:
22838
diff
changeset
|
1492 if (wp->w_id == id) |
2c1520981e63
patch 8.2.1997: window changes when using bufload() while in a terminal popup
Bram Moolenaar <Bram@vim.org>
parents:
22838
diff
changeset
|
1493 return wp; |
2c1520981e63
patch 8.2.1997: window changes when using bufload() while in a terminal popup
Bram Moolenaar <Bram@vim.org>
parents:
22838
diff
changeset
|
1494 FOR_ALL_POPUPWINS_IN_TAB(curtab, wp) |
2c1520981e63
patch 8.2.1997: window changes when using bufload() while in a terminal popup
Bram Moolenaar <Bram@vim.org>
parents:
22838
diff
changeset
|
1495 if (wp->w_id == id) |
2c1520981e63
patch 8.2.1997: window changes when using bufload() while in a terminal popup
Bram Moolenaar <Bram@vim.org>
parents:
22838
diff
changeset
|
1496 return wp; |
2c1520981e63
patch 8.2.1997: window changes when using bufload() while in a terminal popup
Bram Moolenaar <Bram@vim.org>
parents:
22838
diff
changeset
|
1497 #endif |
22838
80bd5de5dcab
patch 8.2.1966: popup becomes current window after closing a terminal window
Bram Moolenaar <Bram@vim.org>
parents:
22800
diff
changeset
|
1498 return NULL; |
80bd5de5dcab
patch 8.2.1966: popup becomes current window after closing a terminal window
Bram Moolenaar <Bram@vim.org>
parents:
22800
diff
changeset
|
1499 } |
80bd5de5dcab
patch 8.2.1966: popup becomes current window after closing a terminal window
Bram Moolenaar <Bram@vim.org>
parents:
22800
diff
changeset
|
1500 |
80bd5de5dcab
patch 8.2.1966: popup becomes current window after closing a terminal window
Bram Moolenaar <Bram@vim.org>
parents:
22800
diff
changeset
|
1501 /* |
9875
42adbf172ecd
commit https://github.com/vim/vim/commit/e59215c7dcae17b03daf39517560cfaa03314f5a
Christian Brabandt <cb@256bit.org>
parents:
9858
diff
changeset
|
1502 * 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
|
1503 */ |
42adbf172ecd
commit https://github.com/vim/vim/commit/e59215c7dcae17b03daf39517560cfaa03314f5a
Christian Brabandt <cb@256bit.org>
parents:
9858
diff
changeset
|
1504 int |
42adbf172ecd
commit https://github.com/vim/vim/commit/e59215c7dcae17b03daf39517560cfaa03314f5a
Christian Brabandt <cb@256bit.org>
parents:
9858
diff
changeset
|
1505 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
|
1506 { |
42adbf172ecd
commit https://github.com/vim/vim/commit/e59215c7dcae17b03daf39517560cfaa03314f5a
Christian Brabandt <cb@256bit.org>
parents:
9858
diff
changeset
|
1507 win_T *wp; |
42adbf172ecd
commit https://github.com/vim/vim/commit/e59215c7dcae17b03daf39517560cfaa03314f5a
Christian Brabandt <cb@256bit.org>
parents:
9858
diff
changeset
|
1508 tabpage_T *tp; |
42adbf172ecd
commit https://github.com/vim/vim/commit/e59215c7dcae17b03daf39517560cfaa03314f5a
Christian Brabandt <cb@256bit.org>
parents:
9858
diff
changeset
|
1509 |
42adbf172ecd
commit https://github.com/vim/vim/commit/e59215c7dcae17b03daf39517560cfaa03314f5a
Christian Brabandt <cb@256bit.org>
parents:
9858
diff
changeset
|
1510 if (win == NULL) |
42adbf172ecd
commit https://github.com/vim/vim/commit/e59215c7dcae17b03daf39517560cfaa03314f5a
Christian Brabandt <cb@256bit.org>
parents:
9858
diff
changeset
|
1511 return FALSE; |
42adbf172ecd
commit https://github.com/vim/vim/commit/e59215c7dcae17b03daf39517560cfaa03314f5a
Christian Brabandt <cb@256bit.org>
parents:
9858
diff
changeset
|
1512 FOR_ALL_TABPAGES(tp) |
42adbf172ecd
commit https://github.com/vim/vim/commit/e59215c7dcae17b03daf39517560cfaa03314f5a
Christian Brabandt <cb@256bit.org>
parents:
9858
diff
changeset
|
1513 { |
42adbf172ecd
commit https://github.com/vim/vim/commit/e59215c7dcae17b03daf39517560cfaa03314f5a
Christian Brabandt <cb@256bit.org>
parents:
9858
diff
changeset
|
1514 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
|
1515 { |
42adbf172ecd
commit https://github.com/vim/vim/commit/e59215c7dcae17b03daf39517560cfaa03314f5a
Christian Brabandt <cb@256bit.org>
parents:
9858
diff
changeset
|
1516 if (wp == win) |
42adbf172ecd
commit https://github.com/vim/vim/commit/e59215c7dcae17b03daf39517560cfaa03314f5a
Christian Brabandt <cb@256bit.org>
parents:
9858
diff
changeset
|
1517 return TRUE; |
42adbf172ecd
commit https://github.com/vim/vim/commit/e59215c7dcae17b03daf39517560cfaa03314f5a
Christian Brabandt <cb@256bit.org>
parents:
9858
diff
changeset
|
1518 } |
18763
49b78d6465e5
patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents:
18590
diff
changeset
|
1519 #ifdef FEAT_PROP_POPUP |
19888
435726a03481
patch 8.2.0500: using the same loop in many places
Bram Moolenaar <Bram@vim.org>
parents:
19291
diff
changeset
|
1520 FOR_ALL_POPUPWINS_IN_TAB(tp, wp) |
16902
23645f9a5ce2
patch 8.1.1452: line and col property of popup windows not properly checked
Bram Moolenaar <Bram@vim.org>
parents:
16890
diff
changeset
|
1521 if (wp == win) |
23645f9a5ce2
patch 8.1.1452: line and col property of popup windows not properly checked
Bram Moolenaar <Bram@vim.org>
parents:
16890
diff
changeset
|
1522 return TRUE; |
23645f9a5ce2
patch 8.1.1452: line and col property of popup windows not properly checked
Bram Moolenaar <Bram@vim.org>
parents:
16890
diff
changeset
|
1523 #endif |
9875
42adbf172ecd
commit https://github.com/vim/vim/commit/e59215c7dcae17b03daf39517560cfaa03314f5a
Christian Brabandt <cb@256bit.org>
parents:
9858
diff
changeset
|
1524 } |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
1525 return win_valid_popup(win); |
9875
42adbf172ecd
commit https://github.com/vim/vim/commit/e59215c7dcae17b03daf39517560cfaa03314f5a
Christian Brabandt <cb@256bit.org>
parents:
9858
diff
changeset
|
1526 } |
42adbf172ecd
commit https://github.com/vim/vim/commit/e59215c7dcae17b03daf39517560cfaa03314f5a
Christian Brabandt <cb@256bit.org>
parents:
9858
diff
changeset
|
1527 |
42adbf172ecd
commit https://github.com/vim/vim/commit/e59215c7dcae17b03daf39517560cfaa03314f5a
Christian Brabandt <cb@256bit.org>
parents:
9858
diff
changeset
|
1528 /* |
7 | 1529 * Return the number of windows. |
1530 */ | |
1531 int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1532 win_count(void) |
7 | 1533 { |
1534 win_T *wp; | |
1535 int count = 0; | |
1536 | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9599
diff
changeset
|
1537 FOR_ALL_WINDOWS(wp) |
7 | 1538 ++count; |
1539 return count; | |
1540 } | |
1541 | |
1542 /* | |
1543 * Make "count" windows on the screen. | |
1544 * Return actual number of windows on the screen. | |
1545 * Must be called when there is just one window, filling the whole screen | |
1546 * (excluding the command line). | |
1547 */ | |
1548 int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1549 make_windows( |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1550 int count, |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1551 int vertical UNUSED) // split windows vertically if TRUE |
7 | 1552 { |
1553 int maxcount; | |
1554 int todo; | |
1555 | |
1556 if (vertical) | |
1557 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1558 // Each windows needs at least 'winminwidth' lines and a separator |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1559 // column. |
7 | 1560 maxcount = (curwin->w_width + curwin->w_vsep_width |
1561 - (p_wiw - p_wmw)) / (p_wmw + 1); | |
1562 } | |
1563 else | |
1564 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1565 // 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
|
1566 maxcount = (VISIBLE_HEIGHT(curwin) + curwin->w_status_height |
7 | 1567 - (p_wh - p_wmh)) / (p_wmh + STATUS_HEIGHT); |
1568 } | |
1569 | |
1570 if (maxcount < 2) | |
1571 maxcount = 2; | |
1572 if (count > maxcount) | |
1573 count = maxcount; | |
1574 | |
1575 /* | |
1576 * add status line now, otherwise first window will be too big | |
1577 */ | |
1578 if (count > 1) | |
1579 last_status(TRUE); | |
1580 | |
1581 /* | |
1582 * Don't execute autocommands while creating the windows. Must do that | |
1583 * when putting the buffers in the windows. | |
1584 */ | |
1410 | 1585 block_autocmds(); |
7 | 1586 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1587 // todo is number of windows left to create |
7 | 1588 for (todo = count - 1; todo > 0; --todo) |
1589 if (vertical) | |
1590 { | |
1591 if (win_split(curwin->w_width - (curwin->w_width - todo) | |
1592 / (todo + 1) - 1, WSP_VERT | WSP_ABOVE) == FAIL) | |
1593 break; | |
1594 } | |
1595 else | |
1596 { | |
1597 if (win_split(curwin->w_height - (curwin->w_height - todo | |
1598 * STATUS_HEIGHT) / (todo + 1) | |
1599 - STATUS_HEIGHT, WSP_ABOVE) == FAIL) | |
1600 break; | |
1601 } | |
1602 | |
1410 | 1603 unblock_autocmds(); |
7 | 1604 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1605 // return actual number of windows |
7 | 1606 return (count - todo); |
1607 } | |
1608 | |
1609 /* | |
1610 * Exchange current and next window | |
1611 */ | |
1612 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1613 win_exchange(long Prenum) |
7 | 1614 { |
1615 frame_T *frp; | |
1616 frame_T *frp2; | |
1617 win_T *wp; | |
1618 win_T *wp2; | |
1619 int temp; | |
1620 | |
19271
ebeeb4b4a1fa
patch 8.2.0194: some commands can cause problems in terminal popup
Bram Moolenaar <Bram@vim.org>
parents:
19265
diff
changeset
|
1621 if (ERROR_IF_ANY_POPUP_WINDOW) |
16874
da5f5836e90c
patch 8.1.1438: some commands cause trouble in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
16863
diff
changeset
|
1622 return; |
da5f5836e90c
patch 8.1.1438: some commands cause trouble in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
16863
diff
changeset
|
1623 if (ONE_WINDOW) // just one window |
7 | 1624 { |
1625 beep_flush(); | |
1626 return; | |
1627 } | |
1628 | |
1629 #ifdef FEAT_GUI | |
1630 need_mouse_correct = TRUE; | |
1631 #endif | |
1632 | |
1633 /* | |
1634 * find window to exchange with | |
1635 */ | |
1636 if (Prenum) | |
1637 { | |
1638 frp = curwin->w_frame->fr_parent->fr_child; | |
1639 while (frp != NULL && --Prenum > 0) | |
1640 frp = frp->fr_next; | |
1641 } | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1642 else if (curwin->w_frame->fr_next != NULL) // Swap with next |
7 | 1643 frp = curwin->w_frame->fr_next; |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1644 else // Swap last window in row/col with previous |
7 | 1645 frp = curwin->w_frame->fr_prev; |
1646 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1647 // We can only exchange a window with another window, not with a frame |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1648 // containing windows. |
7 | 1649 if (frp == NULL || frp->fr_win == NULL || frp->fr_win == curwin) |
1650 return; | |
1651 wp = frp->fr_win; | |
1652 | |
1653 /* | |
1654 * 1. remove curwin from the list. Remember after which window it was in wp2 | |
1655 * 2. insert curwin before wp in the list | |
1656 * if wp != wp2 | |
1657 * 3. remove wp from the list | |
1658 * 4. insert wp after wp2 | |
1659 * 5. exchange the status line height and vsep width. | |
1660 */ | |
1661 wp2 = curwin->w_prev; | |
1662 frp2 = curwin->w_frame->fr_prev; | |
1663 if (wp->w_prev != curwin) | |
1664 { | |
671 | 1665 win_remove(curwin, NULL); |
7 | 1666 frame_remove(curwin->w_frame); |
1667 win_append(wp->w_prev, curwin); | |
1668 frame_insert(frp, curwin->w_frame); | |
1669 } | |
1670 if (wp != wp2) | |
1671 { | |
671 | 1672 win_remove(wp, NULL); |
7 | 1673 frame_remove(wp->w_frame); |
1674 win_append(wp2, wp); | |
1675 if (frp2 == NULL) | |
1676 frame_insert(wp->w_frame->fr_parent->fr_child, wp->w_frame); | |
1677 else | |
1678 frame_append(frp2, wp->w_frame); | |
1679 } | |
1680 temp = curwin->w_status_height; | |
1681 curwin->w_status_height = wp->w_status_height; | |
1682 wp->w_status_height = temp; | |
1683 temp = curwin->w_vsep_width; | |
1684 curwin->w_vsep_width = wp->w_vsep_width; | |
1685 wp->w_vsep_width = temp; | |
1686 | |
25553
8b5dc14345ce
patch 8.2.3313: unused code in win_exchange() and frame_remove()
Bram Moolenaar <Bram@vim.org>
parents:
25505
diff
changeset
|
1687 frame_fix_height(curwin); |
8b5dc14345ce
patch 8.2.3313: unused code in win_exchange() and frame_remove()
Bram Moolenaar <Bram@vim.org>
parents:
25505
diff
changeset
|
1688 frame_fix_height(wp); |
8b5dc14345ce
patch 8.2.3313: unused code in win_exchange() and frame_remove()
Bram Moolenaar <Bram@vim.org>
parents:
25505
diff
changeset
|
1689 frame_fix_width(curwin); |
8b5dc14345ce
patch 8.2.3313: unused code in win_exchange() and frame_remove()
Bram Moolenaar <Bram@vim.org>
parents:
25505
diff
changeset
|
1690 frame_fix_width(wp); |
7 | 1691 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1692 (void)win_comp_pos(); // recompute window positions |
7 | 1693 |
1694 win_enter(wp, TRUE); | |
15380
f62d6bd18a49
patch 8.1.0698: clearing the window is used too often
Bram Moolenaar <Bram@vim.org>
parents:
15227
diff
changeset
|
1695 redraw_all_later(NOT_VALID); |
7 | 1696 } |
1697 | |
1698 /* | |
1699 * rotate windows: if upwards TRUE the second window becomes the first one | |
1700 * if upwards FALSE the first window becomes the second one | |
1701 */ | |
1702 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1703 win_rotate(int upwards, int count) |
7 | 1704 { |
1705 win_T *wp1; | |
1706 win_T *wp2; | |
1707 frame_T *frp; | |
1708 int n; | |
1709 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1710 if (ONE_WINDOW) // nothing to do |
7 | 1711 { |
1712 beep_flush(); | |
1713 return; | |
1714 } | |
1715 | |
1716 #ifdef FEAT_GUI | |
1717 need_mouse_correct = TRUE; | |
1718 #endif | |
1719 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1720 // Check if all frames in this row/col have one window. |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
1721 FOR_ALL_FRAMES(frp, curwin->w_frame->fr_parent->fr_child) |
7 | 1722 if (frp->fr_win == NULL) |
1723 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15436
diff
changeset
|
1724 emsg(_("E443: Cannot rotate when another window is split")); |
7 | 1725 return; |
1726 } | |
1727 | |
1728 while (count--) | |
1729 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1730 if (upwards) // first window becomes last window |
7 | 1731 { |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1732 // remove first window/frame from the list |
7 | 1733 frp = curwin->w_frame->fr_parent->fr_child; |
1734 wp1 = frp->fr_win; | |
671 | 1735 win_remove(wp1, NULL); |
7 | 1736 frame_remove(frp); |
1737 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1738 // find last frame and append removed window/frame after it |
7 | 1739 for ( ; frp->fr_next != NULL; frp = frp->fr_next) |
1740 ; | |
1741 win_append(frp->fr_win, wp1); | |
1742 frame_append(frp, wp1->w_frame); | |
1743 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1744 wp2 = frp->fr_win; // previously last window |
7 | 1745 } |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1746 else // last window becomes first window |
7 | 1747 { |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1748 // find last window/frame in the list and remove it |
7 | 1749 for (frp = curwin->w_frame; frp->fr_next != NULL; |
1750 frp = frp->fr_next) | |
1751 ; | |
1752 wp1 = frp->fr_win; | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1753 wp2 = wp1->w_prev; // will become last window |
671 | 1754 win_remove(wp1, NULL); |
7 | 1755 frame_remove(frp); |
1756 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1757 // append the removed window/frame before the first in the list |
7 | 1758 win_append(frp->fr_parent->fr_child->fr_win->w_prev, wp1); |
1759 frame_insert(frp->fr_parent->fr_child, frp); | |
1760 } | |
1761 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1762 // exchange status height and vsep width of old and new last window |
7 | 1763 n = wp2->w_status_height; |
1764 wp2->w_status_height = wp1->w_status_height; | |
1765 wp1->w_status_height = n; | |
1766 frame_fix_height(wp1); | |
1767 frame_fix_height(wp2); | |
1768 n = wp2->w_vsep_width; | |
1769 wp2->w_vsep_width = wp1->w_vsep_width; | |
1770 wp1->w_vsep_width = n; | |
1771 frame_fix_width(wp1); | |
1772 frame_fix_width(wp2); | |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8536
diff
changeset
|
1773 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1774 // recompute w_winrow and w_wincol for all windows |
7 | 1775 (void)win_comp_pos(); |
1776 } | |
1777 | |
15380
f62d6bd18a49
patch 8.1.0698: clearing the window is used too often
Bram Moolenaar <Bram@vim.org>
parents:
15227
diff
changeset
|
1778 redraw_all_later(NOT_VALID); |
7 | 1779 } |
1780 | |
1781 /* | |
1782 * Move the current window to the very top/bottom/left/right of the screen. | |
1783 */ | |
1784 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1785 win_totop(int size, int flags) |
7 | 1786 { |
1787 int dir; | |
1788 int height = curwin->w_height; | |
1789 | |
10357
59d01e335858
commit https://github.com/vim/vim/commit/459ca563128f2edb7e3bb190090bbb755a56dd55
Christian Brabandt <cb@256bit.org>
parents:
10349
diff
changeset
|
1790 if (ONE_WINDOW) |
7 | 1791 { |
1792 beep_flush(); | |
1793 return; | |
1794 } | |
17516
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
1795 if (check_split_disallowed() == FAIL) |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
1796 return; |
7 | 1797 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1798 // Remove the window and frame from the tree of frames. |
671 | 1799 (void)winframe_remove(curwin, &dir, NULL); |
1800 win_remove(curwin, NULL); | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1801 last_status(FALSE); // may need to remove last status line |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1802 (void)win_comp_pos(); // recompute window positions |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1803 |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1804 // Split a window on the desired side and put the window there. |
7 | 1805 (void)win_split_ins(size, flags, curwin, dir); |
1806 if (!(flags & WSP_VERT)) | |
1807 { | |
1808 win_setheight(height); | |
1809 if (p_ea) | |
1810 win_equal(curwin, TRUE, 'v'); | |
1811 } | |
1812 | |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8536
diff
changeset
|
1813 #if defined(FEAT_GUI) |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1814 // When 'guioptions' includes 'L' or 'R' may have to remove or add |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1815 // scrollbars. Have to update them anyway. |
1906 | 1816 gui_may_update_scrollbars(); |
1817 #endif | |
7 | 1818 } |
1819 | |
1820 /* | |
1821 * Move window "win1" to below/right of "win2" and make "win1" the current | |
1822 * window. Only works within the same frame! | |
1823 */ | |
1824 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1825 win_move_after(win_T *win1, win_T *win2) |
7 | 1826 { |
1827 int height; | |
1828 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1829 // check if the arguments are reasonable |
7 | 1830 if (win1 == win2) |
1831 return; | |
1832 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1833 // check if there is something to do |
7 | 1834 if (win2->w_next != win1) |
1835 { | |
17516
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
1836 if (win1->w_frame->fr_parent != win2->w_frame->fr_parent) |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
1837 { |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
1838 iemsg("INTERNAL: trying to move a window into another frame"); |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
1839 return; |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
1840 } |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
1841 |
21020
6c634e63989c
patch 8.2.1061: insufficient testing for src/window.c
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1842 // may need to move the status line/vertical separator of the last |
6c634e63989c
patch 8.2.1061: insufficient testing for src/window.c
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1843 // window |
7 | 1844 if (win1 == lastwin) |
1845 { | |
1846 height = win1->w_prev->w_status_height; | |
1847 win1->w_prev->w_status_height = win1->w_status_height; | |
1848 win1->w_status_height = height; | |
1070 | 1849 if (win1->w_prev->w_vsep_width == 1) |
1850 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1851 // Remove the vertical separator from the last-but-one window, |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1852 // add it to the last window. Adjust the frame widths. |
1070 | 1853 win1->w_prev->w_vsep_width = 0; |
1854 win1->w_prev->w_frame->fr_width -= 1; | |
1855 win1->w_vsep_width = 1; | |
1856 win1->w_frame->fr_width += 1; | |
1857 } | |
7 | 1858 } |
1859 else if (win2 == lastwin) | |
1860 { | |
1861 height = win1->w_status_height; | |
1862 win1->w_status_height = win2->w_status_height; | |
1863 win2->w_status_height = height; | |
1070 | 1864 if (win1->w_vsep_width == 1) |
1865 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1866 // Remove the vertical separator from win1, add it to the last |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1867 // window, win2. Adjust the frame widths. |
1070 | 1868 win2->w_vsep_width = 1; |
1869 win2->w_frame->fr_width += 1; | |
1870 win1->w_vsep_width = 0; | |
1871 win1->w_frame->fr_width -= 1; | |
1872 } | |
7 | 1873 } |
671 | 1874 win_remove(win1, NULL); |
7 | 1875 frame_remove(win1->w_frame); |
1876 win_append(win2, win1); | |
1877 frame_append(win2->w_frame, win1->w_frame); | |
1878 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1879 (void)win_comp_pos(); // recompute w_winrow for all windows |
7 | 1880 redraw_later(NOT_VALID); |
1881 } | |
1882 win_enter(win1, FALSE); | |
1883 } | |
1884 | |
1885 /* | |
1886 * Make all windows the same height. | |
1887 * 'next_curwin' will soon be the current window, make sure it has enough | |
1888 * rows. | |
1889 */ | |
1890 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1891 win_equal( |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1892 win_T *next_curwin, // pointer to current window to be or NULL |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1893 int current, // do only frame with current window |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1894 int dir) // 'v' for vertically, 'h' for horizontally, |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1895 // 'b' for both, 0 for using p_ead |
7 | 1896 { |
1897 if (dir == 0) | |
1898 dir = *p_ead; | |
1899 win_equal_rec(next_curwin == NULL ? curwin : next_curwin, current, | |
685 | 1900 topframe, dir, 0, tabline_height(), |
667 | 1901 (int)Columns, topframe->fr_height); |
7 | 1902 } |
1903 | |
1904 /* | |
1905 * Set a frame to a new position and height, spreading the available room | |
1906 * equally over contained frames. | |
1907 * The window "next_curwin" (if not NULL) should at least get the size from | |
1908 * 'winheight' and 'winwidth' if possible. | |
1909 */ | |
1910 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1911 win_equal_rec( |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1912 win_T *next_curwin, // pointer to current window to be or NULL |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1913 int current, // do only frame with current window |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1914 frame_T *topfr, // frame to set size off |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1915 int dir, // 'v', 'h' or 'b', see win_equal() |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1916 int col, // horizontal position for frame |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1917 int row, // vertical position for frame |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1918 int width, // new width of frame |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1919 int height) // new height of frame |
7 | 1920 { |
1921 int n, m; | |
1922 int extra_sep = 0; | |
1923 int wincount, totwincount = 0; | |
1924 frame_T *fr; | |
1925 int next_curwin_size = 0; | |
1926 int room = 0; | |
1927 int new_size; | |
1928 int has_next_curwin = 0; | |
1929 int hnc; | |
1930 | |
1931 if (topfr->fr_layout == FR_LEAF) | |
1932 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1933 // Set the width/height of this frame. |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1934 // Redraw when size or position changes |
7 | 1935 if (topfr->fr_height != height || topfr->fr_win->w_winrow != row |
1936 || topfr->fr_width != width || topfr->fr_win->w_wincol != col | |
1937 ) | |
1938 { | |
1939 topfr->fr_win->w_winrow = row; | |
1940 frame_new_height(topfr, height, FALSE, FALSE); | |
1941 topfr->fr_win->w_wincol = col; | |
779 | 1942 frame_new_width(topfr, width, FALSE, FALSE); |
15380
f62d6bd18a49
patch 8.1.0698: clearing the window is used too often
Bram Moolenaar <Bram@vim.org>
parents:
15227
diff
changeset
|
1943 redraw_all_later(NOT_VALID); |
7 | 1944 } |
1945 } | |
1946 else if (topfr->fr_layout == FR_ROW) | |
1947 { | |
1948 topfr->fr_width = width; | |
1949 topfr->fr_height = height; | |
1950 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1951 if (dir != 'v') // equalize frame widths |
7 | 1952 { |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1953 // Compute the maximum number of windows horizontally in this |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1954 // frame. |
7 | 1955 n = frame_minwidth(topfr, NOWIN); |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1956 // add one for the rightmost window, it doesn't have a separator |
7 | 1957 if (col + width == Columns) |
1958 extra_sep = 1; | |
1959 else | |
1960 extra_sep = 0; | |
1961 totwincount = (n + extra_sep) / (p_wmw + 1); | |
779 | 1962 has_next_curwin = frame_has_win(topfr, next_curwin); |
1963 | |
1964 /* | |
1965 * Compute width for "next_curwin" window and room available for | |
1966 * other windows. | |
1967 * "m" is the minimal width when counting p_wiw for "next_curwin". | |
1968 */ | |
7 | 1969 m = frame_minwidth(topfr, next_curwin); |
1970 room = width - m; | |
1971 if (room < 0) | |
1972 { | |
1973 next_curwin_size = p_wiw + room; | |
1974 room = 0; | |
1975 } | |
1976 else | |
1977 { | |
779 | 1978 next_curwin_size = -1; |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
1979 FOR_ALL_FRAMES(fr, topfr->fr_child) |
779 | 1980 { |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1981 // If 'winfixwidth' set keep the window width if |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1982 // possible. |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1983 // Watch out for this window being the next_curwin. |
779 | 1984 if (frame_fixed_width(fr)) |
1985 { | |
1986 n = frame_minwidth(fr, NOWIN); | |
1987 new_size = fr->fr_width; | |
1988 if (frame_has_win(fr, next_curwin)) | |
1989 { | |
1990 room += p_wiw - p_wmw; | |
1991 next_curwin_size = 0; | |
1992 if (new_size < p_wiw) | |
1993 new_size = p_wiw; | |
1994 } | |
1995 else | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1996 // These windows don't use up room. |
779 | 1997 totwincount -= (n + (fr->fr_next == NULL |
1998 ? extra_sep : 0)) / (p_wmw + 1); | |
1999 room -= new_size - n; | |
2000 if (room < 0) | |
2001 { | |
2002 new_size += room; | |
2003 room = 0; | |
2004 } | |
2005 fr->fr_newwidth = new_size; | |
2006 } | |
2007 } | |
2008 if (next_curwin_size == -1) | |
2009 { | |
2010 if (!has_next_curwin) | |
2011 next_curwin_size = 0; | |
2012 else if (totwincount > 1 | |
2013 && (room + (totwincount - 2)) | |
2014 / (totwincount - 1) > p_wiw) | |
2015 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2016 // Can make all windows wider than 'winwidth', spread |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2017 // the room equally. |
834 | 2018 next_curwin_size = (room + p_wiw |
2019 + (totwincount - 1) * p_wmw | |
2020 + (totwincount - 1)) / totwincount; | |
779 | 2021 room -= next_curwin_size - p_wiw; |
2022 } | |
2023 else | |
2024 next_curwin_size = p_wiw; | |
2025 } | |
7 | 2026 } |
779 | 2027 |
2028 if (has_next_curwin) | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2029 --totwincount; // don't count curwin |
7 | 2030 } |
2031 | |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
2032 FOR_ALL_FRAMES(fr, topfr->fr_child) |
7 | 2033 { |
2034 wincount = 1; | |
2035 if (fr->fr_next == NULL) | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2036 // last frame gets all that remains (avoid roundoff error) |
7 | 2037 new_size = width; |
2038 else if (dir == 'v') | |
2039 new_size = fr->fr_width; | |
779 | 2040 else if (frame_fixed_width(fr)) |
2041 { | |
2042 new_size = fr->fr_newwidth; | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2043 wincount = 0; // doesn't count as a sizeable window |
779 | 2044 } |
7 | 2045 else |
2046 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2047 // Compute the maximum number of windows horiz. in "fr". |
7 | 2048 n = frame_minwidth(fr, NOWIN); |
2049 wincount = (n + (fr->fr_next == NULL ? extra_sep : 0)) | |
2050 / (p_wmw + 1); | |
2051 m = frame_minwidth(fr, next_curwin); | |
779 | 2052 if (has_next_curwin) |
2053 hnc = frame_has_win(fr, next_curwin); | |
2054 else | |
2055 hnc = FALSE; | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2056 if (hnc) // don't count next_curwin |
7 | 2057 --wincount; |
779 | 2058 if (totwincount == 0) |
2059 new_size = room; | |
2060 else | |
2061 new_size = (wincount * room + ((unsigned)totwincount >> 1)) | |
7 | 2062 / totwincount; |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2063 if (hnc) // add next_curwin size |
7 | 2064 { |
2065 next_curwin_size -= p_wiw - (m - n); | |
2066 new_size += next_curwin_size; | |
779 | 2067 room -= new_size - next_curwin_size; |
7 | 2068 } |
779 | 2069 else |
2070 room -= new_size; | |
2071 new_size += n; | |
7 | 2072 } |
2073 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2074 // Skip frame that is full width when splitting or closing a |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2075 // window, unless equalizing all frames. |
7 | 2076 if (!current || dir != 'v' || topfr->fr_parent != NULL |
2077 || (new_size != fr->fr_width) | |
2078 || frame_has_win(fr, next_curwin)) | |
2079 win_equal_rec(next_curwin, current, fr, dir, col, row, | |
779 | 2080 new_size, height); |
2081 col += new_size; | |
2082 width -= new_size; | |
7 | 2083 totwincount -= wincount; |
2084 } | |
2085 } | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2086 else // topfr->fr_layout == FR_COL |
7 | 2087 { |
2088 topfr->fr_width = width; | |
2089 topfr->fr_height = height; | |
2090 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2091 if (dir != 'h') // equalize frame heights |
7 | 2092 { |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2093 // Compute maximum number of windows vertically in this frame. |
7 | 2094 n = frame_minheight(topfr, NOWIN); |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2095 // add one for the bottom window if it doesn't have a statusline |
7 | 2096 if (row + height == cmdline_row && p_ls == 0) |
2097 extra_sep = 1; | |
2098 else | |
2099 extra_sep = 0; | |
2100 totwincount = (n + extra_sep) / (p_wmh + 1); | |
2101 has_next_curwin = frame_has_win(topfr, next_curwin); | |
2102 | |
2103 /* | |
2104 * Compute height for "next_curwin" window and room available for | |
2105 * other windows. | |
2106 * "m" is the minimal height when counting p_wh for "next_curwin". | |
2107 */ | |
2108 m = frame_minheight(topfr, next_curwin); | |
2109 room = height - m; | |
2110 if (room < 0) | |
2111 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2112 // The room is less then 'winheight', use all space for the |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2113 // current window. |
7 | 2114 next_curwin_size = p_wh + room; |
2115 room = 0; | |
2116 } | |
2117 else | |
2118 { | |
2119 next_curwin_size = -1; | |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
2120 FOR_ALL_FRAMES(fr, topfr->fr_child) |
7 | 2121 { |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2122 // If 'winfixheight' set keep the window height if |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2123 // possible. |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2124 // Watch out for this window being the next_curwin. |
7 | 2125 if (frame_fixed_height(fr)) |
2126 { | |
2127 n = frame_minheight(fr, NOWIN); | |
2128 new_size = fr->fr_height; | |
2129 if (frame_has_win(fr, next_curwin)) | |
2130 { | |
2131 room += p_wh - p_wmh; | |
2132 next_curwin_size = 0; | |
2133 if (new_size < p_wh) | |
2134 new_size = p_wh; | |
2135 } | |
2136 else | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2137 // These windows don't use up room. |
7 | 2138 totwincount -= (n + (fr->fr_next == NULL |
2139 ? extra_sep : 0)) / (p_wmh + 1); | |
2140 room -= new_size - n; | |
2141 if (room < 0) | |
2142 { | |
2143 new_size += room; | |
2144 room = 0; | |
2145 } | |
2146 fr->fr_newheight = new_size; | |
2147 } | |
2148 } | |
2149 if (next_curwin_size == -1) | |
2150 { | |
2151 if (!has_next_curwin) | |
2152 next_curwin_size = 0; | |
2153 else if (totwincount > 1 | |
2154 && (room + (totwincount - 2)) | |
2155 / (totwincount - 1) > p_wh) | |
2156 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2157 // can make all windows higher than 'winheight', |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2158 // spread the room equally. |
834 | 2159 next_curwin_size = (room + p_wh |
2160 + (totwincount - 1) * p_wmh | |
7 | 2161 + (totwincount - 1)) / totwincount; |
2162 room -= next_curwin_size - p_wh; | |
2163 } | |
2164 else | |
2165 next_curwin_size = p_wh; | |
2166 } | |
2167 } | |
2168 | |
2169 if (has_next_curwin) | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2170 --totwincount; // don't count curwin |
7 | 2171 } |
2172 | |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
2173 FOR_ALL_FRAMES(fr, topfr->fr_child) |
7 | 2174 { |
2175 wincount = 1; | |
2176 if (fr->fr_next == NULL) | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2177 // last frame gets all that remains (avoid roundoff error) |
7 | 2178 new_size = height; |
2179 else if (dir == 'h') | |
2180 new_size = fr->fr_height; | |
2181 else if (frame_fixed_height(fr)) | |
2182 { | |
2183 new_size = fr->fr_newheight; | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2184 wincount = 0; // doesn't count as a sizeable window |
7 | 2185 } |
2186 else | |
2187 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2188 // Compute the maximum number of windows vert. in "fr". |
7 | 2189 n = frame_minheight(fr, NOWIN); |
2190 wincount = (n + (fr->fr_next == NULL ? extra_sep : 0)) | |
2191 / (p_wmh + 1); | |
2192 m = frame_minheight(fr, next_curwin); | |
2193 if (has_next_curwin) | |
2194 hnc = frame_has_win(fr, next_curwin); | |
2195 else | |
2196 hnc = FALSE; | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2197 if (hnc) // don't count next_curwin |
7 | 2198 --wincount; |
2199 if (totwincount == 0) | |
2200 new_size = room; | |
2201 else | |
2202 new_size = (wincount * room + ((unsigned)totwincount >> 1)) | |
2203 / totwincount; | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2204 if (hnc) // add next_curwin size |
7 | 2205 { |
2206 next_curwin_size -= p_wh - (m - n); | |
2207 new_size += next_curwin_size; | |
2208 room -= new_size - next_curwin_size; | |
2209 } | |
2210 else | |
2211 room -= new_size; | |
2212 new_size += n; | |
2213 } | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2214 // Skip frame that is full width when splitting or closing a |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2215 // window, unless equalizing all frames. |
7 | 2216 if (!current || dir != 'h' || topfr->fr_parent != NULL |
2217 || (new_size != fr->fr_height) | |
2218 || frame_has_win(fr, next_curwin)) | |
2219 win_equal_rec(next_curwin, current, fr, dir, col, row, | |
2220 width, new_size); | |
2221 row += new_size; | |
2222 height -= new_size; | |
2223 totwincount -= wincount; | |
2224 } | |
2225 } | |
2226 } | |
2227 | |
14035
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
2228 #ifdef FEAT_JOB_CHANNEL |
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
2229 static void |
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
2230 leaving_window(win_T *win) |
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
2231 { |
14049
3e6477e767ba
patch 8.1.0042: if omni completion opens a window Insert mode is stopped
Christian Brabandt <cb@256bit.org>
parents:
14037
diff
changeset
|
2232 // Only matters for a prompt window. |
3e6477e767ba
patch 8.1.0042: if omni completion opens a window Insert mode is stopped
Christian Brabandt <cb@256bit.org>
parents:
14037
diff
changeset
|
2233 if (!bt_prompt(win->w_buffer)) |
3e6477e767ba
patch 8.1.0042: if omni completion opens a window Insert mode is stopped
Christian Brabandt <cb@256bit.org>
parents:
14037
diff
changeset
|
2234 return; |
3e6477e767ba
patch 8.1.0042: if omni completion opens a window Insert mode is stopped
Christian Brabandt <cb@256bit.org>
parents:
14037
diff
changeset
|
2235 |
14035
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
2236 // When leaving a prompt window stop Insert mode and perhaps restart |
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
2237 // it when entering that window again. |
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
2238 win->w_buffer->b_prompt_insert = restart_edit; |
14093
a9d94f10ecef
patch 8.1.0064: typing CTRL-W in a prompt buffer shows mode "-- --"
Christian Brabandt <cb@256bit.org>
parents:
14057
diff
changeset
|
2239 if (restart_edit != 0 && mode_displayed) |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2240 clear_cmdline = TRUE; // unshow mode later |
14035
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
2241 restart_edit = NUL; |
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
2242 |
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
2243 // When leaving the window (or closing the window) was done from a |
14049
3e6477e767ba
patch 8.1.0042: if omni completion opens a window Insert mode is stopped
Christian Brabandt <cb@256bit.org>
parents:
14037
diff
changeset
|
2244 // callback we need to break out of the Insert mode loop and restart Insert |
3e6477e767ba
patch 8.1.0042: if omni completion opens a window Insert mode is stopped
Christian Brabandt <cb@256bit.org>
parents:
14037
diff
changeset
|
2245 // mode when entering the window again. |
14035
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
2246 if (State & INSERT) |
14037
afce2005fdc8
patch 8.1.0036: not restoring Insert mode if leaving prompt buffer with mouse
Christian Brabandt <cb@256bit.org>
parents:
14035
diff
changeset
|
2247 { |
14035
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
2248 stop_insert_mode = TRUE; |
14049
3e6477e767ba
patch 8.1.0042: if omni completion opens a window Insert mode is stopped
Christian Brabandt <cb@256bit.org>
parents:
14037
diff
changeset
|
2249 if (win->w_buffer->b_prompt_insert == NUL) |
14037
afce2005fdc8
patch 8.1.0036: not restoring Insert mode if leaving prompt buffer with mouse
Christian Brabandt <cb@256bit.org>
parents:
14035
diff
changeset
|
2250 win->w_buffer->b_prompt_insert = 'A'; |
afce2005fdc8
patch 8.1.0036: not restoring Insert mode if leaving prompt buffer with mouse
Christian Brabandt <cb@256bit.org>
parents:
14035
diff
changeset
|
2251 } |
14035
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
2252 } |
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
2253 |
22470
f7471450243c
patch 8.2.1783: try-catch test fails
Bram Moolenaar <Bram@vim.org>
parents:
22464
diff
changeset
|
2254 void |
14035
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
2255 entering_window(win_T *win) |
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
2256 { |
14049
3e6477e767ba
patch 8.1.0042: if omni completion opens a window Insert mode is stopped
Christian Brabandt <cb@256bit.org>
parents:
14037
diff
changeset
|
2257 // Only matters for a prompt window. |
3e6477e767ba
patch 8.1.0042: if omni completion opens a window Insert mode is stopped
Christian Brabandt <cb@256bit.org>
parents:
14037
diff
changeset
|
2258 if (!bt_prompt(win->w_buffer)) |
3e6477e767ba
patch 8.1.0042: if omni completion opens a window Insert mode is stopped
Christian Brabandt <cb@256bit.org>
parents:
14037
diff
changeset
|
2259 return; |
3e6477e767ba
patch 8.1.0042: if omni completion opens a window Insert mode is stopped
Christian Brabandt <cb@256bit.org>
parents:
14037
diff
changeset
|
2260 |
14037
afce2005fdc8
patch 8.1.0036: not restoring Insert mode if leaving prompt buffer with mouse
Christian Brabandt <cb@256bit.org>
parents:
14035
diff
changeset
|
2261 // When switching to a prompt buffer that was in Insert mode, don't stop |
afce2005fdc8
patch 8.1.0036: not restoring Insert mode if leaving prompt buffer with mouse
Christian Brabandt <cb@256bit.org>
parents:
14035
diff
changeset
|
2262 // Insert mode, it may have been set in leaving_window(). |
14049
3e6477e767ba
patch 8.1.0042: if omni completion opens a window Insert mode is stopped
Christian Brabandt <cb@256bit.org>
parents:
14037
diff
changeset
|
2263 if (win->w_buffer->b_prompt_insert != NUL) |
14037
afce2005fdc8
patch 8.1.0036: not restoring Insert mode if leaving prompt buffer with mouse
Christian Brabandt <cb@256bit.org>
parents:
14035
diff
changeset
|
2264 stop_insert_mode = FALSE; |
afce2005fdc8
patch 8.1.0036: not restoring Insert mode if leaving prompt buffer with mouse
Christian Brabandt <cb@256bit.org>
parents:
14035
diff
changeset
|
2265 |
14049
3e6477e767ba
patch 8.1.0042: if omni completion opens a window Insert mode is stopped
Christian Brabandt <cb@256bit.org>
parents:
14037
diff
changeset
|
2266 // When entering the prompt window restart Insert mode if we were in Insert |
26280
b93e176e7998
patch 8.2.3671: restarting Insert mode in prompt buffer too often
Bram Moolenaar <Bram@vim.org>
parents:
26193
diff
changeset
|
2267 // mode when we left it and not already in Insert mode. |
b93e176e7998
patch 8.2.3671: restarting Insert mode in prompt buffer too often
Bram Moolenaar <Bram@vim.org>
parents:
26193
diff
changeset
|
2268 if ((State & INSERT) == 0) |
b93e176e7998
patch 8.2.3671: restarting Insert mode in prompt buffer too often
Bram Moolenaar <Bram@vim.org>
parents:
26193
diff
changeset
|
2269 restart_edit = win->w_buffer->b_prompt_insert; |
14035
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
2270 } |
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
2271 #endif |
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
2272 |
7 | 2273 /* |
11199
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
2274 * Close all windows for buffer "buf". |
7 | 2275 */ |
2276 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2277 close_windows( |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2278 buf_T *buf, |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2279 int keep_curwin) // don't close "curwin" |
7 | 2280 { |
671 | 2281 win_T *wp; |
2282 tabpage_T *tp, *nexttp; | |
685 | 2283 int h = tabline_height(); |
9599
42a8a81decdf
commit https://github.com/vim/vim/commit/12c11d553053f5a9eae9eb3c518279b12fa928c2
Christian Brabandt <cb@256bit.org>
parents:
9595
diff
changeset
|
2284 int count = tabpage_index(NULL); |
7 | 2285 |
2286 ++RedrawingDisabled; | |
671 | 2287 |
10357
59d01e335858
commit https://github.com/vim/vim/commit/459ca563128f2edb7e3bb190090bbb755a56dd55
Christian Brabandt <cb@256bit.org>
parents:
10349
diff
changeset
|
2288 for (wp = firstwin; wp != NULL && !ONE_WINDOW; ) |
7 | 2289 { |
3570 | 2290 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
|
2291 && !(wp->w_closing || wp->w_buffer->b_locked > 0)) |
7 | 2292 { |
11199
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
2293 if (win_close(wp, FALSE) == FAIL) |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2294 // If closing the window fails give up, to avoid looping |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2295 // forever. |
11199
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
2296 break; |
671 | 2297 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2298 // Start all over, autocommands may change the window layout. |
671 | 2299 wp = firstwin; |
7 | 2300 } |
2301 else | |
671 | 2302 wp = wp->w_next; |
7 | 2303 } |
671 | 2304 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2305 // Also check windows in other tab pages. |
671 | 2306 for (tp = first_tabpage; tp != NULL; tp = nexttp) |
2307 { | |
2308 nexttp = tp->tp_next; | |
672 | 2309 if (tp != curtab) |
19888
435726a03481
patch 8.2.0500: using the same loop in many places
Bram Moolenaar <Bram@vim.org>
parents:
19291
diff
changeset
|
2310 FOR_ALL_WINDOWS_IN_TAB(tp, wp) |
3570 | 2311 if (wp->w_buffer == buf |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13308
diff
changeset
|
2312 && !(wp->w_closing || wp->w_buffer->b_locked > 0)) |
671 | 2313 { |
2314 win_close_othertab(wp, FALSE, tp); | |
2315 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2316 // Start all over, the tab page may be closed and |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2317 // autocommands may change the window layout. |
671 | 2318 nexttp = first_tabpage; |
2319 break; | |
2320 } | |
2321 } | |
2322 | |
7 | 2323 --RedrawingDisabled; |
671 | 2324 |
9599
42a8a81decdf
commit https://github.com/vim/vim/commit/12c11d553053f5a9eae9eb3c518279b12fa928c2
Christian Brabandt <cb@256bit.org>
parents:
9595
diff
changeset
|
2325 if (count != tabpage_index(NULL)) |
42a8a81decdf
commit https://github.com/vim/vim/commit/12c11d553053f5a9eae9eb3c518279b12fa928c2
Christian Brabandt <cb@256bit.org>
parents:
9595
diff
changeset
|
2326 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
|
2327 |
4305 | 2328 redraw_tabline = TRUE; |
685 | 2329 if (h != tabline_height()) |
671 | 2330 shell_new_rows(); |
7 | 2331 } |
2332 | |
2333 /* | |
1906 | 2334 * Return TRUE if the current window is the only window that exists (ignoring |
2335 * "aucmd_win"). | |
672 | 2336 * Returns FALSE if there is a window, possibly in another tab page. |
667 | 2337 */ |
672 | 2338 static int |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2339 last_window(void) |
667 | 2340 { |
1906 | 2341 return (one_window() && first_tabpage->tp_next == NULL); |
2342 } | |
2343 | |
2344 /* | |
2345 * Return TRUE if there is only one window other than "aucmd_win" in the | |
2346 * current tab page. | |
2347 */ | |
3365 | 2348 int |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2349 one_window(void) |
1906 | 2350 { |
2351 win_T *wp; | |
2352 int seen_one = FALSE; | |
2353 | |
2354 FOR_ALL_WINDOWS(wp) | |
2355 { | |
2356 if (wp != aucmd_win) | |
2357 { | |
2358 if (seen_one) | |
2359 return FALSE; | |
2360 seen_one = TRUE; | |
2361 } | |
2362 } | |
2363 return TRUE; | |
667 | 2364 } |
2365 | |
2366 /* | |
3535 | 2367 * Close the possibly last window in a tab page. |
2368 * Returns TRUE when the window was closed already. | |
2369 */ | |
2370 static int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2371 close_last_window_tabpage( |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2372 win_T *win, |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2373 int free_buf, |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2374 tabpage_T *prev_curtab) |
3535 | 2375 { |
10349
cf988222b150
commit https://github.com/vim/vim/commit/a1f4cb93ba50ea9e40cd4b1f5592b8a6d1398660
Christian Brabandt <cb@256bit.org>
parents:
10106
diff
changeset
|
2376 if (ONE_WINDOW) |
3535 | 2377 { |
4354 | 2378 buf_T *old_curbuf = curbuf; |
2379 | |
3535 | 2380 /* |
2381 * Closing the last window in a tab page. First go to another tab | |
2382 * page and then close the window and the tab page. This avoids that | |
2383 * curwin and curtab are invalid while we are freeing memory, they may | |
2384 * be used in GUI events. | |
3582 | 2385 * Don't trigger autocommands yet, they may use wrong values, so do |
2386 * that below. | |
3535 | 2387 */ |
4354 | 2388 goto_tabpage_tp(alt_tabpage(), FALSE, TRUE); |
3535 | 2389 redraw_tabline = TRUE; |
2390 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2391 // Safety check: Autocommands may have closed the window when jumping |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2392 // to the other tab page. |
3535 | 2393 if (valid_tabpage(prev_curtab) && prev_curtab->tp_firstwin == win) |
2394 { | |
2395 int h = tabline_height(); | |
2396 | |
2397 win_close_othertab(win, free_buf, prev_curtab); | |
2398 if (h != tabline_height()) | |
2399 shell_new_rows(); | |
2400 } | |
14035
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
2401 #ifdef FEAT_JOB_CHANNEL |
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
2402 entering_window(curwin); |
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
2403 #endif |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2404 // Since goto_tabpage_tp above did not trigger *Enter autocommands, do |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2405 // that now. |
9599
42a8a81decdf
commit https://github.com/vim/vim/commit/12c11d553053f5a9eae9eb3c518279b12fa928c2
Christian Brabandt <cb@256bit.org>
parents:
9595
diff
changeset
|
2406 apply_autocmds(EVENT_TABCLOSED, NULL, NULL, FALSE, curbuf); |
4354 | 2407 apply_autocmds(EVENT_WINENTER, NULL, NULL, FALSE, curbuf); |
3582 | 2408 apply_autocmds(EVENT_TABENTER, NULL, NULL, FALSE, curbuf); |
4354 | 2409 if (old_curbuf != curbuf) |
2410 apply_autocmds(EVENT_BUFENTER, NULL, NULL, FALSE, curbuf); | |
3535 | 2411 return TRUE; |
2412 } | |
2413 return FALSE; | |
2414 } | |
2415 | |
2416 /* | |
17043
d99805d25b42
patch 8.1.1521: when a popup window is closed the buffer remains
Bram Moolenaar <Bram@vim.org>
parents:
16902
diff
changeset
|
2417 * Close the buffer of "win" and unload it if "action" is DOBUF_UNLOAD. |
d99805d25b42
patch 8.1.1521: when a popup window is closed the buffer remains
Bram Moolenaar <Bram@vim.org>
parents:
16902
diff
changeset
|
2418 * "action" can also be zero (do nothing) or DOBUF_WIPE. |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2419 * "abort_if_last" is passed to close_buffer(): abort closing if all other |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2420 * windows are closed. |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2421 */ |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2422 static void |
17043
d99805d25b42
patch 8.1.1521: when a popup window is closed the buffer remains
Bram Moolenaar <Bram@vim.org>
parents:
16902
diff
changeset
|
2423 win_close_buffer(win_T *win, int action, int abort_if_last) |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2424 { |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2425 #ifdef FEAT_SYN_HL |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2426 // Free independent synblock before the buffer is freed. |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2427 if (win->w_buffer != NULL) |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2428 reset_synblock(win); |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2429 #endif |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2430 |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2431 #ifdef FEAT_QUICKFIX |
26458
824fe105f5b9
patch 8.2.3759: quickfix buffer becomes hidden while still in a window
Bram Moolenaar <Bram@vim.org>
parents:
26416
diff
changeset
|
2432 // When a quickfix/location list window is closed and the buffer is |
824fe105f5b9
patch 8.2.3759: quickfix buffer becomes hidden while still in a window
Bram Moolenaar <Bram@vim.org>
parents:
26416
diff
changeset
|
2433 // displayed in only one window, then unlist the buffer. |
824fe105f5b9
patch 8.2.3759: quickfix buffer becomes hidden while still in a window
Bram Moolenaar <Bram@vim.org>
parents:
26416
diff
changeset
|
2434 if (win->w_buffer != NULL && bt_quickfix(win->w_buffer) |
824fe105f5b9
patch 8.2.3759: quickfix buffer becomes hidden while still in a window
Bram Moolenaar <Bram@vim.org>
parents:
26416
diff
changeset
|
2435 && win->w_buffer->b_nwindows == 1) |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2436 win->w_buffer->b_p_bl = FALSE; |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2437 #endif |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2438 |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2439 // Close the link to the buffer. |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2440 if (win->w_buffer != NULL) |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2441 { |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2442 bufref_T bufref; |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2443 |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2444 set_bufref(&bufref, curbuf); |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2445 win->w_closing = TRUE; |
18886
050f5eaa9e50
patch 8.2.0004: get E685 and E931 if buffer reload is interrupted
Bram Moolenaar <Bram@vim.org>
parents:
18816
diff
changeset
|
2446 close_buffer(win, win->w_buffer, action, abort_if_last, FALSE); |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2447 if (win_valid_any_tab(win)) |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2448 win->w_closing = FALSE; |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2449 // Make sure curbuf is valid. It can become invalid if 'bufhidden' is |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2450 // "wipe". |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2451 if (!bufref_valid(&bufref)) |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2452 curbuf = firstbuf; |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2453 } |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2454 } |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2455 |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2456 /* |
819 | 2457 * Close window "win". Only works for the current tab page. |
7 | 2458 * If "free_buf" is TRUE related buffer may be unloaded. |
2459 * | |
3365 | 2460 * Called by :quit, :close, :xit, :wq and findtag(). |
5302 | 2461 * Returns FAIL when the window was not closed. |
7 | 2462 */ |
5302 | 2463 int |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2464 win_close(win_T *win, int free_buf) |
7 | 2465 { |
2466 win_T *wp; | |
2467 int other_buffer = FALSE; | |
2468 int close_curwin = FALSE; | |
2469 int dir; | |
2470 int help_window = FALSE; | |
847 | 2471 tabpage_T *prev_curtab = curtab; |
11593
c4e7fe672a72
patch 8.0.0679: using freed memory
Christian Brabandt <cb@256bit.org>
parents:
11591
diff
changeset
|
2472 frame_T *win_frame = win->w_frame->fr_parent; |
18590
41484f342f80
patch 8.1.2289: after :diffsplit closing the window does not disable diff
Bram Moolenaar <Bram@vim.org>
parents:
18467
diff
changeset
|
2473 #ifdef FEAT_DIFF |
41484f342f80
patch 8.1.2289: after :diffsplit closing the window does not disable diff
Bram Moolenaar <Bram@vim.org>
parents:
18467
diff
changeset
|
2474 int had_diffmode = win->w_p_diff; |
41484f342f80
patch 8.1.2289: after :diffsplit closing the window does not disable diff
Bram Moolenaar <Bram@vim.org>
parents:
18467
diff
changeset
|
2475 #endif |
25505
040a45d39570
patch 8.2.3289: compiler warning for unused variable with small features
Bram Moolenaar <Bram@vim.org>
parents:
25501
diff
changeset
|
2476 #ifdef MESSAGE_QUEUE |
25501
a1ed55c02e80
patch 8.2.3287: channel events not handled in BufEnter autocommand
Bram Moolenaar <Bram@vim.org>
parents:
25499
diff
changeset
|
2477 int did_decrement = FALSE; |
25505
040a45d39570
patch 8.2.3289: compiler warning for unused variable with small features
Bram Moolenaar <Bram@vim.org>
parents:
25501
diff
changeset
|
2478 #endif |
7 | 2479 |
19275
2142fb624658
patch 8.2.0196: blocking commands for a finished job in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19271
diff
changeset
|
2480 #if defined(FEAT_TERMINAL) && defined(FEAT_PROP_POPUP) |
2142fb624658
patch 8.2.0196: blocking commands for a finished job in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19271
diff
changeset
|
2481 // Can close a popup window with a terminal if the job has finished. |
2142fb624658
patch 8.2.0196: blocking commands for a finished job in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19271
diff
changeset
|
2482 if (may_close_term_popup() == OK) |
2142fb624658
patch 8.2.0196: blocking commands for a finished job in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19271
diff
changeset
|
2483 return OK; |
2142fb624658
patch 8.2.0196: blocking commands for a finished job in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19271
diff
changeset
|
2484 #endif |
19271
ebeeb4b4a1fa
patch 8.2.0194: some commands can cause problems in terminal popup
Bram Moolenaar <Bram@vim.org>
parents:
19265
diff
changeset
|
2485 if (ERROR_IF_ANY_POPUP_WINDOW) |
16874
da5f5836e90c
patch 8.1.1438: some commands cause trouble in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
16863
diff
changeset
|
2486 return FAIL; |
da5f5836e90c
patch 8.1.1438: some commands cause trouble in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
16863
diff
changeset
|
2487 |
667 | 2488 if (last_window()) |
7 | 2489 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15436
diff
changeset
|
2490 emsg(_("E444: Cannot close last window")); |
5302 | 2491 return FAIL; |
7 | 2492 } |
2493 | |
10106
58e6dd1d8be3
commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents:
10082
diff
changeset
|
2494 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
|
2495 && win->w_buffer->b_locked > 0)) |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2496 return FAIL; // window is already being closed |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2497 if (win_unlisted(win)) |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2498 { |
21016
0738c44504cb
patch 8.2.1059: crash when using :tabonly in an autocommand
Bram Moolenaar <Bram@vim.org>
parents:
20737
diff
changeset
|
2499 emsg(_(e_autocmd_close)); |
5302 | 2500 return FAIL; |
1906 | 2501 } |
2502 if ((firstwin == aucmd_win || lastwin == aucmd_win) && one_window()) | |
2503 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15436
diff
changeset
|
2504 emsg(_("E814: Cannot close window, only autocmd window would remain")); |
5302 | 2505 return FAIL; |
1906 | 2506 } |
2507 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2508 // When closing the last window in a tab page first go to another tab page |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2509 // and then close the window and the tab page to avoid that curwin and |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2510 // curtab are invalid while we are freeing memory. |
3535 | 2511 if (close_last_window_tabpage(win, free_buf, prev_curtab)) |
5302 | 2512 return FAIL; |
856 | 2513 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2514 // When closing the help window, try restoring a snapshot after closing |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2515 // 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
|
2516 if (bt_help(win->w_buffer)) |
7 | 2517 help_window = TRUE; |
2518 else | |
1906 | 2519 clear_snapshot(curtab, SNAP_HELP_IDX); |
7 | 2520 |
2521 if (win == curwin) | |
2522 { | |
14035
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
2523 #ifdef FEAT_JOB_CHANNEL |
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
2524 leaving_window(curwin); |
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
2525 #endif |
7 | 2526 /* |
2527 * Guess which window is going to be the new current window. | |
2528 * This may change because of the autocommands (sigh). | |
2529 */ | |
671 | 2530 wp = frame2win(win_altframe(win, NULL)); |
7 | 2531 |
2532 /* | |
3570 | 2533 * Be careful: If autocommands delete the window or cause this window |
2534 * to be the last one left, return now. | |
7 | 2535 */ |
2536 if (wp->w_buffer != curbuf) | |
2537 { | |
2538 other_buffer = TRUE; | |
3570 | 2539 win->w_closing = TRUE; |
7 | 2540 apply_autocmds(EVENT_BUFLEAVE, NULL, NULL, FALSE, curbuf); |
3570 | 2541 if (!win_valid(win)) |
5302 | 2542 return FAIL; |
3570 | 2543 win->w_closing = FALSE; |
2544 if (last_window()) | |
5302 | 2545 return FAIL; |
7 | 2546 } |
3570 | 2547 win->w_closing = TRUE; |
7 | 2548 apply_autocmds(EVENT_WINLEAVE, NULL, NULL, FALSE, curbuf); |
3570 | 2549 if (!win_valid(win)) |
5302 | 2550 return FAIL; |
3570 | 2551 win->w_closing = FALSE; |
2552 if (last_window()) | |
5302 | 2553 return FAIL; |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13308
diff
changeset
|
2554 #ifdef FEAT_EVAL |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2555 // autocmds may abort script processing |
7 | 2556 if (aborting()) |
5302 | 2557 return FAIL; |
7 | 2558 #endif |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13308
diff
changeset
|
2559 } |
7 | 2560 |
1101 | 2561 #ifdef FEAT_GUI |
16019
096b8ccd855e
patch 8.1.1015: quickfix buffer shows up in list, can't get buffer number
Bram Moolenaar <Bram@vim.org>
parents:
15977
diff
changeset
|
2562 // Avoid trouble with scrollbars that are going to be deleted in |
096b8ccd855e
patch 8.1.1015: quickfix buffer shows up in list, can't get buffer number
Bram Moolenaar <Bram@vim.org>
parents:
15977
diff
changeset
|
2563 // win_free(). |
1101 | 2564 if (gui.in_use) |
2565 out_flush(); | |
2566 #endif | |
2567 | |
18763
49b78d6465e5
patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents:
18590
diff
changeset
|
2568 #ifdef FEAT_PROP_POPUP |
17863
08f1dd29550e
patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents:
17823
diff
changeset
|
2569 if (popup_win_closed(win) && !win_valid(win)) |
08f1dd29550e
patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents:
17823
diff
changeset
|
2570 return FAIL; |
08f1dd29550e
patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents:
17823
diff
changeset
|
2571 #endif |
26117
d4d9c7c55a5f
patch 8.2.3591: no event is triggered when closing a window
Bram Moolenaar <Bram@vim.org>
parents:
26077
diff
changeset
|
2572 |
d4d9c7c55a5f
patch 8.2.3591: no event is triggered when closing a window
Bram Moolenaar <Bram@vim.org>
parents:
26077
diff
changeset
|
2573 // Trigger WinClosed just before starting to free window-related resources. |
d4d9c7c55a5f
patch 8.2.3591: no event is triggered when closing a window
Bram Moolenaar <Bram@vim.org>
parents:
26077
diff
changeset
|
2574 trigger_winclosed(win); |
d4d9c7c55a5f
patch 8.2.3591: no event is triggered when closing a window
Bram Moolenaar <Bram@vim.org>
parents:
26077
diff
changeset
|
2575 // autocmd may have freed the window already. |
d4d9c7c55a5f
patch 8.2.3591: no event is triggered when closing a window
Bram Moolenaar <Bram@vim.org>
parents:
26077
diff
changeset
|
2576 if (!win_valid_any_tab(win)) |
d4d9c7c55a5f
patch 8.2.3591: no event is triggered when closing a window
Bram Moolenaar <Bram@vim.org>
parents:
26077
diff
changeset
|
2577 return OK; |
d4d9c7c55a5f
patch 8.2.3591: no event is triggered when closing a window
Bram Moolenaar <Bram@vim.org>
parents:
26077
diff
changeset
|
2578 |
17043
d99805d25b42
patch 8.1.1521: when a popup window is closed the buffer remains
Bram Moolenaar <Bram@vim.org>
parents:
16902
diff
changeset
|
2579 win_close_buffer(win, free_buf ? DOBUF_UNLOAD : 0, TRUE); |
847 | 2580 |
4021 | 2581 if (only_one_window() && win_valid(win) && win->w_buffer == NULL |
2582 && (last_window() || curtab != prev_curtab | |
2583 || close_last_window_tabpage(win, free_buf, prev_curtab))) | |
5233
1899acc5aebd
updated for version 7.4a.042
Bram Moolenaar <bram@vim.org>
parents:
5202
diff
changeset
|
2584 { |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2585 // Autocommands have closed all windows, quit now. Restore |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2586 // curwin->w_buffer, otherwise writing viminfo may fail. |
5233
1899acc5aebd
updated for version 7.4a.042
Bram Moolenaar <bram@vim.org>
parents:
5202
diff
changeset
|
2587 if (curwin->w_buffer == NULL) |
1899acc5aebd
updated for version 7.4a.042
Bram Moolenaar <bram@vim.org>
parents:
5202
diff
changeset
|
2588 curwin->w_buffer = curbuf; |
4021 | 2589 getout(0); |
5233
1899acc5aebd
updated for version 7.4a.042
Bram Moolenaar <bram@vim.org>
parents:
5202
diff
changeset
|
2590 } |
4021 | 2591 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2592 // Autocommands may have moved to another tab page. |
10076
bc30991c3e98
commit https://github.com/vim/vim/commit/11fbc2866ccc11b4dd1726abdaf582a78ef3f743
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2593 if (curtab != prev_curtab && win_valid_any_tab(win) |
bc30991c3e98
commit https://github.com/vim/vim/commit/11fbc2866ccc11b4dd1726abdaf582a78ef3f743
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2594 && win->w_buffer == NULL) |
bc30991c3e98
commit https://github.com/vim/vim/commit/11fbc2866ccc11b4dd1726abdaf582a78ef3f743
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2595 { |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2596 // Need to close the window anyway, since the buffer is NULL. |
10076
bc30991c3e98
commit https://github.com/vim/vim/commit/11fbc2866ccc11b4dd1726abdaf582a78ef3f743
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2597 win_close_othertab(win, FALSE, prev_curtab); |
bc30991c3e98
commit https://github.com/vim/vim/commit/11fbc2866ccc11b4dd1726abdaf582a78ef3f743
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2598 return FAIL; |
bc30991c3e98
commit https://github.com/vim/vim/commit/11fbc2866ccc11b4dd1726abdaf582a78ef3f743
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2599 } |
bc30991c3e98
commit https://github.com/vim/vim/commit/11fbc2866ccc11b4dd1726abdaf582a78ef3f743
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2600 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2601 // Autocommands may have closed the window already or closed the only |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2602 // other window. |
10076
bc30991c3e98
commit https://github.com/vim/vim/commit/11fbc2866ccc11b4dd1726abdaf582a78ef3f743
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2603 if (!win_valid(win) || last_window() |
3535 | 2604 || close_last_window_tabpage(win, free_buf, prev_curtab)) |
5302 | 2605 return FAIL; |
7 | 2606 |
17516
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
2607 // Now we are really going to close the window. Disallow any autocommand |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
2608 // to split a window to avoid trouble. |
22800
8e7cbf73c3a0
patch 8.2.1948: GUI: crash when handling message while closing a window
Bram Moolenaar <Bram@vim.org>
parents:
22713
diff
changeset
|
2609 // Also bail out of parse_queued_messages() to avoid it tries to update the |
8e7cbf73c3a0
patch 8.2.1948: GUI: crash when handling message while closing a window
Bram Moolenaar <Bram@vim.org>
parents:
22713
diff
changeset
|
2610 // screen. |
17516
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
2611 ++split_disallowed; |
22800
8e7cbf73c3a0
patch 8.2.1948: GUI: crash when handling message while closing a window
Bram Moolenaar <Bram@vim.org>
parents:
22713
diff
changeset
|
2612 #ifdef MESSAGE_QUEUE |
8e7cbf73c3a0
patch 8.2.1948: GUI: crash when handling message while closing a window
Bram Moolenaar <Bram@vim.org>
parents:
22713
diff
changeset
|
2613 ++dont_parse_messages; |
8e7cbf73c3a0
patch 8.2.1948: GUI: crash when handling message while closing a window
Bram Moolenaar <Bram@vim.org>
parents:
22713
diff
changeset
|
2614 #endif |
17516
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
2615 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2616 // Free the memory used for the window and get the window that received |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2617 // the screen space. |
847 | 2618 wp = win_free_mem(win, &dir, NULL); |
2619 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2620 // Make sure curwin isn't invalid. It can cause severe trouble when |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2621 // printing an error message. For win_equal() curbuf needs to be valid |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2622 // too. |
847 | 2623 if (win == curwin) |
7 | 2624 { |
2625 curwin = wp; | |
2626 #ifdef FEAT_QUICKFIX | |
2627 if (wp->w_p_pvw || bt_quickfix(wp->w_buffer)) | |
2628 { | |
2629 /* | |
1346 | 2630 * If the cursor goes to the preview or the quickfix window, try |
7 | 2631 * finding another window to go to. |
2632 */ | |
2633 for (;;) | |
2634 { | |
2635 if (wp->w_next == NULL) | |
2636 wp = firstwin; | |
2637 else | |
2638 wp = wp->w_next; | |
2639 if (wp == curwin) | |
2640 break; | |
2641 if (!wp->w_p_pvw && !bt_quickfix(wp->w_buffer)) | |
2642 { | |
2643 curwin = wp; | |
2644 break; | |
2645 } | |
2646 } | |
2647 } | |
2648 #endif | |
2649 curbuf = curwin->w_buffer; | |
2650 close_curwin = TRUE; | |
11193
75ccc8a15a51
patch 8.0.0483: illegal memory access when using :all
Christian Brabandt <cb@256bit.org>
parents:
11191
diff
changeset
|
2651 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2652 // The cursor position may be invalid if the buffer changed after last |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2653 // using the window. |
11193
75ccc8a15a51
patch 8.0.0483: illegal memory access when using :all
Christian Brabandt <cb@256bit.org>
parents:
11191
diff
changeset
|
2654 check_cursor(); |
7 | 2655 } |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8536
diff
changeset
|
2656 if (p_ea && (*p_ead == 'b' || *p_ead == dir)) |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2657 // If the frame of the closed window contains the new current window, |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2658 // only resize that frame. Otherwise resize all windows. |
11593
c4e7fe672a72
patch 8.0.0679: using freed memory
Christian Brabandt <cb@256bit.org>
parents:
11591
diff
changeset
|
2659 win_equal(curwin, curwin->w_frame->fr_parent == win_frame, dir); |
7 | 2660 else |
2661 win_comp_pos(); | |
2662 if (close_curwin) | |
2663 { | |
25501
a1ed55c02e80
patch 8.2.3287: channel events not handled in BufEnter autocommand
Bram Moolenaar <Bram@vim.org>
parents:
25499
diff
changeset
|
2664 // Pass WEE_ALLOW_PARSE_MESSAGES to decrement dont_parse_messages |
a1ed55c02e80
patch 8.2.3287: channel events not handled in BufEnter autocommand
Bram Moolenaar <Bram@vim.org>
parents:
25499
diff
changeset
|
2665 // before autocommands. |
25505
040a45d39570
patch 8.2.3289: compiler warning for unused variable with small features
Bram Moolenaar <Bram@vim.org>
parents:
25501
diff
changeset
|
2666 #ifdef MESSAGE_QUEUE |
040a45d39570
patch 8.2.3289: compiler warning for unused variable with small features
Bram Moolenaar <Bram@vim.org>
parents:
25501
diff
changeset
|
2667 did_decrement = |
040a45d39570
patch 8.2.3289: compiler warning for unused variable with small features
Bram Moolenaar <Bram@vim.org>
parents:
25501
diff
changeset
|
2668 #else |
040a45d39570
patch 8.2.3289: compiler warning for unused variable with small features
Bram Moolenaar <Bram@vim.org>
parents:
25501
diff
changeset
|
2669 (void) |
040a45d39570
patch 8.2.3289: compiler warning for unused variable with small features
Bram Moolenaar <Bram@vim.org>
parents:
25501
diff
changeset
|
2670 #endif |
040a45d39570
patch 8.2.3289: compiler warning for unused variable with small features
Bram Moolenaar <Bram@vim.org>
parents:
25501
diff
changeset
|
2671 win_enter_ext(wp, |
25501
a1ed55c02e80
patch 8.2.3287: channel events not handled in BufEnter autocommand
Bram Moolenaar <Bram@vim.org>
parents:
25499
diff
changeset
|
2672 WEE_CURWIN_INVALID | WEE_TRIGGER_ENTER_AUTOCMDS |
a1ed55c02e80
patch 8.2.3287: channel events not handled in BufEnter autocommand
Bram Moolenaar <Bram@vim.org>
parents:
25499
diff
changeset
|
2673 | WEE_TRIGGER_LEAVE_AUTOCMDS | WEE_ALLOW_PARSE_MESSAGES); |
7 | 2674 if (other_buffer) |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2675 // careful: after this wp and win may be invalid! |
7 | 2676 apply_autocmds(EVENT_BUFENTER, NULL, NULL, FALSE, curbuf); |
2677 } | |
2678 | |
17516
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
2679 --split_disallowed; |
22800
8e7cbf73c3a0
patch 8.2.1948: GUI: crash when handling message while closing a window
Bram Moolenaar <Bram@vim.org>
parents:
22713
diff
changeset
|
2680 #ifdef MESSAGE_QUEUE |
25501
a1ed55c02e80
patch 8.2.3287: channel events not handled in BufEnter autocommand
Bram Moolenaar <Bram@vim.org>
parents:
25499
diff
changeset
|
2681 if (!did_decrement) |
a1ed55c02e80
patch 8.2.3287: channel events not handled in BufEnter autocommand
Bram Moolenaar <Bram@vim.org>
parents:
25499
diff
changeset
|
2682 --dont_parse_messages; |
22800
8e7cbf73c3a0
patch 8.2.1948: GUI: crash when handling message while closing a window
Bram Moolenaar <Bram@vim.org>
parents:
22713
diff
changeset
|
2683 #endif |
17516
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
2684 |
7 | 2685 /* |
667 | 2686 * If last window has a status line now and we don't want one, |
2687 * remove the status line. | |
7 | 2688 */ |
2689 last_status(FALSE); | |
2690 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2691 // After closing the help window, try restoring the window layout from |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2692 // before it was opened. |
7 | 2693 if (help_window) |
1906 | 2694 restore_snapshot(SNAP_HELP_IDX, close_curwin); |
7 | 2695 |
18590
41484f342f80
patch 8.1.2289: after :diffsplit closing the window does not disable diff
Bram Moolenaar <Bram@vim.org>
parents:
18467
diff
changeset
|
2696 #ifdef FEAT_DIFF |
41484f342f80
patch 8.1.2289: after :diffsplit closing the window does not disable diff
Bram Moolenaar <Bram@vim.org>
parents:
18467
diff
changeset
|
2697 // If the window had 'diff' set and now there is only one window left in |
41484f342f80
patch 8.1.2289: after :diffsplit closing the window does not disable diff
Bram Moolenaar <Bram@vim.org>
parents:
18467
diff
changeset
|
2698 // the tab page with 'diff' set, and "closeoff" is in 'diffopt', then |
41484f342f80
patch 8.1.2289: after :diffsplit closing the window does not disable diff
Bram Moolenaar <Bram@vim.org>
parents:
18467
diff
changeset
|
2699 // execute ":diffoff!". |
41484f342f80
patch 8.1.2289: after :diffsplit closing the window does not disable diff
Bram Moolenaar <Bram@vim.org>
parents:
18467
diff
changeset
|
2700 if (diffopt_closeoff() && had_diffmode && curtab == prev_curtab) |
41484f342f80
patch 8.1.2289: after :diffsplit closing the window does not disable diff
Bram Moolenaar <Bram@vim.org>
parents:
18467
diff
changeset
|
2701 { |
41484f342f80
patch 8.1.2289: after :diffsplit closing the window does not disable diff
Bram Moolenaar <Bram@vim.org>
parents:
18467
diff
changeset
|
2702 int diffcount = 0; |
41484f342f80
patch 8.1.2289: after :diffsplit closing the window does not disable diff
Bram Moolenaar <Bram@vim.org>
parents:
18467
diff
changeset
|
2703 win_T *dwin; |
41484f342f80
patch 8.1.2289: after :diffsplit closing the window does not disable diff
Bram Moolenaar <Bram@vim.org>
parents:
18467
diff
changeset
|
2704 |
41484f342f80
patch 8.1.2289: after :diffsplit closing the window does not disable diff
Bram Moolenaar <Bram@vim.org>
parents:
18467
diff
changeset
|
2705 FOR_ALL_WINDOWS(dwin) |
41484f342f80
patch 8.1.2289: after :diffsplit closing the window does not disable diff
Bram Moolenaar <Bram@vim.org>
parents:
18467
diff
changeset
|
2706 if (dwin->w_p_diff) |
41484f342f80
patch 8.1.2289: after :diffsplit closing the window does not disable diff
Bram Moolenaar <Bram@vim.org>
parents:
18467
diff
changeset
|
2707 ++diffcount; |
41484f342f80
patch 8.1.2289: after :diffsplit closing the window does not disable diff
Bram Moolenaar <Bram@vim.org>
parents:
18467
diff
changeset
|
2708 if (diffcount == 1) |
41484f342f80
patch 8.1.2289: after :diffsplit closing the window does not disable diff
Bram Moolenaar <Bram@vim.org>
parents:
18467
diff
changeset
|
2709 do_cmdline_cmd((char_u *)"diffoff!"); |
41484f342f80
patch 8.1.2289: after :diffsplit closing the window does not disable diff
Bram Moolenaar <Bram@vim.org>
parents:
18467
diff
changeset
|
2710 } |
41484f342f80
patch 8.1.2289: after :diffsplit closing the window does not disable diff
Bram Moolenaar <Bram@vim.org>
parents:
18467
diff
changeset
|
2711 #endif |
41484f342f80
patch 8.1.2289: after :diffsplit closing the window does not disable diff
Bram Moolenaar <Bram@vim.org>
parents:
18467
diff
changeset
|
2712 |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8536
diff
changeset
|
2713 #if defined(FEAT_GUI) |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2714 // When 'guioptions' includes 'L' or 'R' may have to remove scrollbars. |
7 | 2715 if (gui.in_use && !win_hasvertsplit()) |
2716 gui_init_which_components(NULL); | |
2717 #endif | |
2718 | |
2719 redraw_all_later(NOT_VALID); | |
5302 | 2720 return OK; |
7 | 2721 } |
2722 | |
26117
d4d9c7c55a5f
patch 8.2.3591: no event is triggered when closing a window
Bram Moolenaar <Bram@vim.org>
parents:
26077
diff
changeset
|
2723 static void |
d4d9c7c55a5f
patch 8.2.3591: no event is triggered when closing a window
Bram Moolenaar <Bram@vim.org>
parents:
26077
diff
changeset
|
2724 trigger_winclosed(win_T *win) |
d4d9c7c55a5f
patch 8.2.3591: no event is triggered when closing a window
Bram Moolenaar <Bram@vim.org>
parents:
26077
diff
changeset
|
2725 { |
d4d9c7c55a5f
patch 8.2.3591: no event is triggered when closing a window
Bram Moolenaar <Bram@vim.org>
parents:
26077
diff
changeset
|
2726 static int recursive = FALSE; |
d4d9c7c55a5f
patch 8.2.3591: no event is triggered when closing a window
Bram Moolenaar <Bram@vim.org>
parents:
26077
diff
changeset
|
2727 char_u winid[NUMBUFLEN]; |
d4d9c7c55a5f
patch 8.2.3591: no event is triggered when closing a window
Bram Moolenaar <Bram@vim.org>
parents:
26077
diff
changeset
|
2728 |
d4d9c7c55a5f
patch 8.2.3591: no event is triggered when closing a window
Bram Moolenaar <Bram@vim.org>
parents:
26077
diff
changeset
|
2729 if (recursive) |
d4d9c7c55a5f
patch 8.2.3591: no event is triggered when closing a window
Bram Moolenaar <Bram@vim.org>
parents:
26077
diff
changeset
|
2730 return; |
d4d9c7c55a5f
patch 8.2.3591: no event is triggered when closing a window
Bram Moolenaar <Bram@vim.org>
parents:
26077
diff
changeset
|
2731 recursive = TRUE; |
d4d9c7c55a5f
patch 8.2.3591: no event is triggered when closing a window
Bram Moolenaar <Bram@vim.org>
parents:
26077
diff
changeset
|
2732 vim_snprintf((char *)winid, sizeof(winid), "%i", win->w_id); |
d4d9c7c55a5f
patch 8.2.3591: no event is triggered when closing a window
Bram Moolenaar <Bram@vim.org>
parents:
26077
diff
changeset
|
2733 apply_autocmds(EVENT_WINCLOSED, winid, winid, FALSE, win->w_buffer); |
d4d9c7c55a5f
patch 8.2.3591: no event is triggered when closing a window
Bram Moolenaar <Bram@vim.org>
parents:
26077
diff
changeset
|
2734 recursive = FALSE; |
d4d9c7c55a5f
patch 8.2.3591: no event is triggered when closing a window
Bram Moolenaar <Bram@vim.org>
parents:
26077
diff
changeset
|
2735 } |
d4d9c7c55a5f
patch 8.2.3591: no event is triggered when closing a window
Bram Moolenaar <Bram@vim.org>
parents:
26077
diff
changeset
|
2736 |
7 | 2737 /* |
671 | 2738 * Close window "win" in tab page "tp", which is not the current tab page. |
3535 | 2739 * This may be the last window in that tab page and result in closing the tab, |
671 | 2740 * thus "tp" may become invalid! |
856 | 2741 * Caller must check if buffer is hidden and whether the tabline needs to be |
2742 * updated. | |
671 | 2743 */ |
2744 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2745 win_close_othertab(win_T *win, int free_buf, tabpage_T *tp) |
671 | 2746 { |
2747 win_T *wp; | |
2748 int dir; | |
2749 tabpage_T *ptp = NULL; | |
2191 | 2750 int free_tp = FALSE; |
671 | 2751 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2752 // Get here with win->w_buffer == NULL when win_close() detects the tab |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2753 // page changed. |
10106
58e6dd1d8be3
commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents:
10082
diff
changeset
|
2754 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
|
2755 && win->w_buffer->b_locked > 0)) |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2756 return; // window is already being closed |
3570 | 2757 |
26117
d4d9c7c55a5f
patch 8.2.3591: no event is triggered when closing a window
Bram Moolenaar <Bram@vim.org>
parents:
26077
diff
changeset
|
2758 // Trigger WinClosed just before starting to free window-related resources. |
d4d9c7c55a5f
patch 8.2.3591: no event is triggered when closing a window
Bram Moolenaar <Bram@vim.org>
parents:
26077
diff
changeset
|
2759 trigger_winclosed(win); |
d4d9c7c55a5f
patch 8.2.3591: no event is triggered when closing a window
Bram Moolenaar <Bram@vim.org>
parents:
26077
diff
changeset
|
2760 // autocmd may have freed the window already. |
d4d9c7c55a5f
patch 8.2.3591: no event is triggered when closing a window
Bram Moolenaar <Bram@vim.org>
parents:
26077
diff
changeset
|
2761 if (!win_valid_any_tab(win)) |
d4d9c7c55a5f
patch 8.2.3591: no event is triggered when closing a window
Bram Moolenaar <Bram@vim.org>
parents:
26077
diff
changeset
|
2762 return; |
d4d9c7c55a5f
patch 8.2.3591: no event is triggered when closing a window
Bram Moolenaar <Bram@vim.org>
parents:
26077
diff
changeset
|
2763 |
10076
bc30991c3e98
commit https://github.com/vim/vim/commit/11fbc2866ccc11b4dd1726abdaf582a78ef3f743
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2764 if (win->w_buffer != NULL) |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2765 // Close the link to the buffer. |
18886
050f5eaa9e50
patch 8.2.0004: get E685 and E931 if buffer reload is interrupted
Bram Moolenaar <Bram@vim.org>
parents:
18816
diff
changeset
|
2766 close_buffer(win, win->w_buffer, free_buf ? DOBUF_UNLOAD : 0, |
050f5eaa9e50
patch 8.2.0004: get E685 and E931 if buffer reload is interrupted
Bram Moolenaar <Bram@vim.org>
parents:
18816
diff
changeset
|
2767 FALSE, FALSE); |
671 | 2768 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2769 // Careful: Autocommands may have closed the tab page or made it the |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2770 // current tab page. |
671 | 2771 for (ptp = first_tabpage; ptp != NULL && ptp != tp; ptp = ptp->tp_next) |
2772 ; | |
672 | 2773 if (ptp == NULL || tp == curtab) |
671 | 2774 return; |
2775 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2776 // Autocommands may have closed the window already. |
671 | 2777 for (wp = tp->tp_firstwin; wp != NULL && wp != win; wp = wp->w_next) |
2778 ; | |
2779 if (wp == NULL) | |
2780 return; | |
2781 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2782 // When closing the last window in a tab page remove the tab page. |
7009 | 2783 if (tp->tp_firstwin == tp->tp_lastwin) |
671 | 2784 { |
2785 if (tp == first_tabpage) | |
2786 first_tabpage = tp->tp_next; | |
2787 else | |
2788 { | |
2789 for (ptp = first_tabpage; ptp != NULL && ptp->tp_next != tp; | |
2790 ptp = ptp->tp_next) | |
2791 ; | |
2792 if (ptp == NULL) | |
2793 { | |
10359
66f1b5bf3fa6
commit https://github.com/vim/vim/commit/95f096030ed1a8afea028f2ea295d6f6a70f466f
Christian Brabandt <cb@256bit.org>
parents:
10357
diff
changeset
|
2794 internal_error("win_close_othertab()"); |
671 | 2795 return; |
2796 } | |
2797 ptp->tp_next = tp->tp_next; | |
2798 } | |
2191 | 2799 free_tp = TRUE; |
2800 } | |
2801 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2802 // Free the memory used for the window. |
2191 | 2803 win_free_mem(win, &dir, tp); |
2804 | |
2805 if (free_tp) | |
847 | 2806 free_tabpage(tp); |
671 | 2807 } |
2808 | |
2809 /* | |
355 | 2810 * Free the memory used for a window. |
2811 * Returns a pointer to the window that got the freed up space. | |
2812 */ | |
2813 static win_T * | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2814 win_free_mem( |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2815 win_T *win, |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2816 int *dirp, // set to 'v' or 'h' for direction if 'ea' |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2817 tabpage_T *tp) // tab page "win" is in, NULL for current |
355 | 2818 { |
2819 frame_T *frp; | |
2820 win_T *wp; | |
22399
75513701ddd2
patch 8.2.1748: closing split window in other tab may cause a crash
Bram Moolenaar <Bram@vim.org>
parents:
21727
diff
changeset
|
2821 tabpage_T *win_tp = tp == NULL ? curtab : tp; |
355 | 2822 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2823 // Remove the window and its frame from the tree of frames. |
355 | 2824 frp = win->w_frame; |
671 | 2825 wp = winframe_remove(win, dirp, tp); |
355 | 2826 vim_free(frp); |
671 | 2827 win_free(win, tp); |
355 | 2828 |
22399
75513701ddd2
patch 8.2.1748: closing split window in other tab may cause a crash
Bram Moolenaar <Bram@vim.org>
parents:
21727
diff
changeset
|
2829 // When deleting the current window in the tab, select a new current |
75513701ddd2
patch 8.2.1748: closing split window in other tab may cause a crash
Bram Moolenaar <Bram@vim.org>
parents:
21727
diff
changeset
|
2830 // window. |
75513701ddd2
patch 8.2.1748: closing split window in other tab may cause a crash
Bram Moolenaar <Bram@vim.org>
parents:
21727
diff
changeset
|
2831 if (win == win_tp->tp_curwin) |
75513701ddd2
patch 8.2.1748: closing split window in other tab may cause a crash
Bram Moolenaar <Bram@vim.org>
parents:
21727
diff
changeset
|
2832 win_tp->tp_curwin = wp; |
819 | 2833 |
355 | 2834 return wp; |
2835 } | |
2836 | |
2837 #if defined(EXITFREE) || defined(PROTO) | |
2838 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2839 win_free_all(void) |
355 | 2840 { |
2841 int dummy; | |
2842 | |
671 | 2843 while (first_tabpage->tp_next != NULL) |
2844 tabpage_close(TRUE); | |
2845 | |
1906 | 2846 if (aucmd_win != NULL) |
2847 { | |
2848 (void)win_free_mem(aucmd_win, &dummy, NULL); | |
2849 aucmd_win = NULL; | |
2850 } | |
1918 | 2851 |
2852 while (firstwin != NULL) | |
2853 (void)win_free_mem(firstwin, &dummy, NULL); | |
6060 | 2854 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2855 // No window should be used after this. Set curwin to NULL to crash |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2856 // instead of using freed memory. |
6060 | 2857 curwin = NULL; |
355 | 2858 } |
2859 #endif | |
2860 | |
2861 /* | |
7 | 2862 * Remove a window and its frame from the tree of frames. |
2863 * Returns a pointer to the window that got the freed up space. | |
2864 */ | |
1906 | 2865 win_T * |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2866 winframe_remove( |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2867 win_T *win, |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2868 int *dirp UNUSED, // set to 'v' or 'h' for direction if 'ea' |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2869 tabpage_T *tp) // tab page "win" is in, NULL for current |
7 | 2870 { |
2871 frame_T *frp, *frp2, *frp3; | |
2872 frame_T *frp_close = win->w_frame; | |
2873 win_T *wp; | |
2874 | |
2875 /* | |
671 | 2876 * If there is only one window there is nothing to remove. |
2877 */ | |
10349
cf988222b150
commit https://github.com/vim/vim/commit/a1f4cb93ba50ea9e40cd4b1f5592b8a6d1398660
Christian Brabandt <cb@256bit.org>
parents:
10106
diff
changeset
|
2878 if (tp == NULL ? ONE_WINDOW : tp->tp_firstwin == tp->tp_lastwin) |
671 | 2879 return NULL; |
2880 | |
2881 /* | |
7 | 2882 * Remove the window from its frame. |
2883 */ | |
671 | 2884 frp2 = win_altframe(win, tp); |
7 | 2885 wp = frame2win(frp2); |
2886 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2887 // Remove this frame from the list of frames. |
7 | 2888 frame_remove(frp_close); |
2889 | |
2890 if (frp_close->fr_parent->fr_layout == FR_COL) | |
2891 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2892 // When 'winfixheight' is set, try to find another frame in the column |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2893 // (as close to the closed frame as possible) to distribute the height |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2894 // to. |
1346 | 2895 if (frp2->fr_win != NULL && frp2->fr_win->w_p_wfh) |
2896 { | |
2897 frp = frp_close->fr_prev; | |
2898 frp3 = frp_close->fr_next; | |
2899 while (frp != NULL || frp3 != NULL) | |
2900 { | |
2901 if (frp != NULL) | |
2902 { | |
16166
a3284dd27de6
patch 8.1.1088: height of quickfix window not retained with vertical split
Bram Moolenaar <Bram@vim.org>
parents:
16019
diff
changeset
|
2903 if (!frame_fixed_height(frp)) |
1346 | 2904 { |
2905 frp2 = frp; | |
16166
a3284dd27de6
patch 8.1.1088: height of quickfix window not retained with vertical split
Bram Moolenaar <Bram@vim.org>
parents:
16019
diff
changeset
|
2906 wp = frame2win(frp2); |
1346 | 2907 break; |
2908 } | |
2909 frp = frp->fr_prev; | |
2910 } | |
2911 if (frp3 != NULL) | |
2912 { | |
2913 if (frp3->fr_win != NULL && !frp3->fr_win->w_p_wfh) | |
2914 { | |
2915 frp2 = frp3; | |
2916 wp = frp3->fr_win; | |
2917 break; | |
2918 } | |
2919 frp3 = frp3->fr_next; | |
2920 } | |
2921 } | |
2922 } | |
7 | 2923 frame_new_height(frp2, frp2->fr_height + frp_close->fr_height, |
2924 frp2 == frp_close->fr_next ? TRUE : FALSE, FALSE); | |
2925 *dirp = 'v'; | |
2926 } | |
2927 else | |
2928 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2929 // When 'winfixwidth' is set, try to find another frame in the column |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2930 // (as close to the closed frame as possible) to distribute the width |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2931 // to. |
1346 | 2932 if (frp2->fr_win != NULL && frp2->fr_win->w_p_wfw) |
2933 { | |
2934 frp = frp_close->fr_prev; | |
2935 frp3 = frp_close->fr_next; | |
2936 while (frp != NULL || frp3 != NULL) | |
2937 { | |
2938 if (frp != NULL) | |
2939 { | |
16166
a3284dd27de6
patch 8.1.1088: height of quickfix window not retained with vertical split
Bram Moolenaar <Bram@vim.org>
parents:
16019
diff
changeset
|
2940 if (!frame_fixed_width(frp)) |
1346 | 2941 { |
2942 frp2 = frp; | |
16166
a3284dd27de6
patch 8.1.1088: height of quickfix window not retained with vertical split
Bram Moolenaar <Bram@vim.org>
parents:
16019
diff
changeset
|
2943 wp = frame2win(frp2); |
1346 | 2944 break; |
2945 } | |
2946 frp = frp->fr_prev; | |
2947 } | |
2948 if (frp3 != NULL) | |
2949 { | |
2950 if (frp3->fr_win != NULL && !frp3->fr_win->w_p_wfw) | |
2951 { | |
2952 frp2 = frp3; | |
2953 wp = frp3->fr_win; | |
2954 break; | |
2955 } | |
2956 frp3 = frp3->fr_next; | |
2957 } | |
2958 } | |
2959 } | |
7 | 2960 frame_new_width(frp2, frp2->fr_width + frp_close->fr_width, |
779 | 2961 frp2 == frp_close->fr_next ? TRUE : FALSE, FALSE); |
7 | 2962 *dirp = 'h'; |
2963 } | |
2964 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2965 // If rows/columns go to a window below/right its positions need to be |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2966 // updated. Can only be done after the sizes have been updated. |
7 | 2967 if (frp2 == frp_close->fr_next) |
2968 { | |
2969 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
|
2970 int col = win->w_wincol; |
7 | 2971 |
2972 frame_comp_pos(frp2, &row, &col); | |
2973 } | |
2974 | |
2975 if (frp2->fr_next == NULL && frp2->fr_prev == NULL) | |
2976 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2977 // There is no other frame in this list, move its info to the parent |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2978 // and remove it. |
7 | 2979 frp2->fr_parent->fr_layout = frp2->fr_layout; |
2980 frp2->fr_parent->fr_child = frp2->fr_child; | |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
2981 FOR_ALL_FRAMES(frp, frp2->fr_child) |
7 | 2982 frp->fr_parent = frp2->fr_parent; |
2983 frp2->fr_parent->fr_win = frp2->fr_win; | |
2984 if (frp2->fr_win != NULL) | |
2985 frp2->fr_win->w_frame = frp2->fr_parent; | |
2986 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
|
2987 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
|
2988 topframe->fr_child = frp; |
7 | 2989 vim_free(frp2); |
2990 | |
2991 frp2 = frp->fr_parent; | |
2992 if (frp2 != NULL && frp2->fr_layout == frp->fr_layout) | |
2993 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2994 // The frame above the parent has the same layout, have to merge |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2995 // the frames into this list. |
7 | 2996 if (frp2->fr_child == frp) |
2997 frp2->fr_child = frp->fr_child; | |
2998 frp->fr_child->fr_prev = frp->fr_prev; | |
2999 if (frp->fr_prev != NULL) | |
3000 frp->fr_prev->fr_next = frp->fr_child; | |
3001 for (frp3 = frp->fr_child; ; frp3 = frp3->fr_next) | |
3002 { | |
3003 frp3->fr_parent = frp2; | |
3004 if (frp3->fr_next == NULL) | |
3005 { | |
3006 frp3->fr_next = frp->fr_next; | |
3007 if (frp->fr_next != NULL) | |
3008 frp->fr_next->fr_prev = frp3; | |
3009 break; | |
3010 } | |
3011 } | |
13144
20fb8c711050
patch 8.0.1446: acessing freed memory after window command in auto command
Christian Brabandt <cb@256bit.org>
parents:
13103
diff
changeset
|
3012 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
|
3013 topframe->fr_child = frp2; |
7 | 3014 vim_free(frp); |
3015 } | |
3016 } | |
3017 | |
3018 return wp; | |
3019 } | |
3020 | |
3021 /* | |
13837
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
3022 * Return a pointer to the frame that will receive the empty screen space that |
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
3023 * is left over after "win" is closed. |
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
3024 * |
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
3025 * If 'splitbelow' or 'splitright' is set, the space goes above or to the left |
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
3026 * by default. Otherwise, the free space goes below or to the right. The |
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
3027 * result is that opening a window and then immediately closing it will |
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
3028 * preserve the initial window layout. The 'wfh' and 'wfw' settings are |
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
3029 * respected when possible. |
7 | 3030 */ |
3031 static frame_T * | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3032 win_altframe( |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3033 win_T *win, |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3034 tabpage_T *tp) // tab page "win" is in, NULL for current |
7 | 3035 { |
3036 frame_T *frp; | |
13837
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
3037 frame_T *other_fr, *target_fr; |
7 | 3038 |
10349
cf988222b150
commit https://github.com/vim/vim/commit/a1f4cb93ba50ea9e40cd4b1f5592b8a6d1398660
Christian Brabandt <cb@256bit.org>
parents:
10106
diff
changeset
|
3039 if (tp == NULL ? ONE_WINDOW : tp->tp_firstwin == tp->tp_lastwin) |
667 | 3040 return alt_tabpage()->tp_curwin->w_frame; |
3041 | |
7 | 3042 frp = win->w_frame; |
13837
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
3043 |
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
3044 if (frp->fr_prev == NULL) |
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
3045 return frp->fr_next; |
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
3046 if (frp->fr_next == NULL) |
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
3047 return frp->fr_prev; |
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
3048 |
20049
8c401bc7f32b
patch 8.2.0580: window size wrong if 'ea' is off and 'splitright' is on
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
3049 // By default the next window will get the space that was abandoned by this |
8c401bc7f32b
patch 8.2.0580: window size wrong if 'ea' is off and 'splitright' is on
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
3050 // window |
13837
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
3051 target_fr = frp->fr_next; |
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
3052 other_fr = frp->fr_prev; |
20049
8c401bc7f32b
patch 8.2.0580: window size wrong if 'ea' is off and 'splitright' is on
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
3053 |
8c401bc7f32b
patch 8.2.0580: window size wrong if 'ea' is off and 'splitright' is on
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
3054 // If this is part of a column of windows and 'splitbelow' is true then the |
8c401bc7f32b
patch 8.2.0580: window size wrong if 'ea' is off and 'splitright' is on
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
3055 // previous window will get the space. |
8c401bc7f32b
patch 8.2.0580: window size wrong if 'ea' is off and 'splitright' is on
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
3056 if (frp->fr_parent != NULL && frp->fr_parent->fr_layout == FR_COL && p_sb) |
8c401bc7f32b
patch 8.2.0580: window size wrong if 'ea' is off and 'splitright' is on
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
3057 { |
8c401bc7f32b
patch 8.2.0580: window size wrong if 'ea' is off and 'splitright' is on
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
3058 target_fr = frp->fr_prev; |
8c401bc7f32b
patch 8.2.0580: window size wrong if 'ea' is off and 'splitright' is on
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
3059 other_fr = frp->fr_next; |
8c401bc7f32b
patch 8.2.0580: window size wrong if 'ea' is off and 'splitright' is on
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
3060 } |
8c401bc7f32b
patch 8.2.0580: window size wrong if 'ea' is off and 'splitright' is on
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
3061 |
8c401bc7f32b
patch 8.2.0580: window size wrong if 'ea' is off and 'splitright' is on
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
3062 // If this is part of a row of windows, and 'splitright' is true then the |
8c401bc7f32b
patch 8.2.0580: window size wrong if 'ea' is off and 'splitright' is on
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
3063 // previous window will get the space. |
8c401bc7f32b
patch 8.2.0580: window size wrong if 'ea' is off and 'splitright' is on
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
3064 if (frp->fr_parent != NULL && frp->fr_parent->fr_layout == FR_ROW && p_spr) |
13837
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
3065 { |
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
3066 target_fr = frp->fr_prev; |
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
3067 other_fr = frp->fr_next; |
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
3068 } |
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
3069 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3070 // If 'wfh' or 'wfw' is set for the target and not for the alternate |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3071 // window, reverse the selection. |
355 | 3072 if (frp->fr_parent != NULL && frp->fr_parent->fr_layout == FR_ROW) |
13837
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
3073 { |
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
3074 if (frame_fixed_width(target_fr) && !frame_fixed_width(other_fr)) |
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
3075 target_fr = other_fr; |
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
3076 } |
7 | 3077 else |
13837
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
3078 { |
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
3079 if (frame_fixed_height(target_fr) && !frame_fixed_height(other_fr)) |
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
3080 target_fr = other_fr; |
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
3081 } |
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
3082 |
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
3083 return target_fr; |
7 | 3084 } |
3085 | |
3086 /* | |
667 | 3087 * Return the tabpage that will be used if the current one is closed. |
3088 */ | |
3089 static tabpage_T * | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3090 alt_tabpage(void) |
667 | 3091 { |
672 | 3092 tabpage_T *tp; |
3093 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3094 // Use the next tab page if possible. |
682 | 3095 if (curtab->tp_next != NULL) |
672 | 3096 return curtab->tp_next; |
3097 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3098 // Find the last but one tab page. |
682 | 3099 for (tp = first_tabpage; tp->tp_next != curtab; tp = tp->tp_next) |
3100 ; | |
674 | 3101 return tp; |
667 | 3102 } |
3103 | |
3104 /* | |
7 | 3105 * Find the left-upper window in frame "frp". |
3106 */ | |
3107 static win_T * | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3108 frame2win(frame_T *frp) |
7 | 3109 { |
3110 while (frp->fr_win == NULL) | |
3111 frp = frp->fr_child; | |
3112 return frp->fr_win; | |
3113 } | |
3114 | |
3115 /* | |
3116 * Return TRUE if frame "frp" contains window "wp". | |
3117 */ | |
3118 static int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3119 frame_has_win(frame_T *frp, win_T *wp) |
7 | 3120 { |
3121 frame_T *p; | |
3122 | |
3123 if (frp->fr_layout == FR_LEAF) | |
3124 return frp->fr_win == wp; | |
3125 | |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
3126 FOR_ALL_FRAMES(p, frp->fr_child) |
7 | 3127 if (frame_has_win(p, wp)) |
3128 return TRUE; | |
3129 return FALSE; | |
3130 } | |
3131 | |
3132 /* | |
3133 * Set a new height for a frame. Recursively sets the height for contained | |
3134 * frames and windows. Caller must take care of positions. | |
3135 */ | |
3136 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3137 frame_new_height( |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3138 frame_T *topfrp, |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3139 int height, |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3140 int topfirst, // resize topmost contained frame first |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3141 int wfh) // obey 'winfixheight' when there is a choice; |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3142 // may cause the height not to be set |
7 | 3143 { |
3144 frame_T *frp; | |
3145 int extra_lines; | |
3146 int h; | |
3147 | |
3148 if (topfrp->fr_win != NULL) | |
3149 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3150 // Simple case: just one window. |
7 | 3151 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
|
3152 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
|
3153 - WINBAR_HEIGHT(topfrp->fr_win)); |
7 | 3154 } |
3155 else if (topfrp->fr_layout == FR_ROW) | |
3156 { | |
3157 do | |
3158 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3159 // All frames in this row get the same new height. |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
3160 FOR_ALL_FRAMES(frp, topfrp->fr_child) |
7 | 3161 { |
3162 frame_new_height(frp, height, topfirst, wfh); | |
3163 if (frp->fr_height > height) | |
3164 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3165 // Could not fit the windows, make the whole row higher. |
7 | 3166 height = frp->fr_height; |
3167 break; | |
3168 } | |
3169 } | |
3170 } | |
3171 while (frp != NULL); | |
3172 } | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3173 else // fr_layout == FR_COL |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3174 { |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3175 // Complicated case: Resize a column of frames. Resize the bottom |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3176 // frame first, frames above that when needed. |
7 | 3177 |
3178 frp = topfrp->fr_child; | |
3179 if (wfh) | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3180 // Advance past frames with one window with 'wfh' set. |
7 | 3181 while (frame_fixed_height(frp)) |
3182 { | |
3183 frp = frp->fr_next; | |
3184 if (frp == NULL) | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3185 return; // no frame without 'wfh', give up |
7 | 3186 } |
3187 if (!topfirst) | |
3188 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3189 // Find the bottom frame of this column |
7 | 3190 while (frp->fr_next != NULL) |
3191 frp = frp->fr_next; | |
3192 if (wfh) | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3193 // Advance back for frames with one window with 'wfh' set. |
7 | 3194 while (frame_fixed_height(frp)) |
3195 frp = frp->fr_prev; | |
3196 } | |
3197 | |
3198 extra_lines = height - topfrp->fr_height; | |
3199 if (extra_lines < 0) | |
3200 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3201 // reduce height of contained frames, bottom or top frame first |
7 | 3202 while (frp != NULL) |
3203 { | |
3204 h = frame_minheight(frp, NULL); | |
3205 if (frp->fr_height + extra_lines < h) | |
3206 { | |
3207 extra_lines += frp->fr_height - h; | |
3208 frame_new_height(frp, h, topfirst, wfh); | |
3209 } | |
3210 else | |
3211 { | |
3212 frame_new_height(frp, frp->fr_height + extra_lines, | |
3213 topfirst, wfh); | |
3214 break; | |
3215 } | |
3216 if (topfirst) | |
3217 { | |
3218 do | |
3219 frp = frp->fr_next; | |
3220 while (wfh && frp != NULL && frame_fixed_height(frp)); | |
3221 } | |
3222 else | |
3223 { | |
3224 do | |
3225 frp = frp->fr_prev; | |
3226 while (wfh && frp != NULL && frame_fixed_height(frp)); | |
3227 } | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3228 // Increase "height" if we could not reduce enough frames. |
7 | 3229 if (frp == NULL) |
3230 height -= extra_lines; | |
3231 } | |
3232 } | |
3233 else if (extra_lines > 0) | |
3234 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3235 // increase height of bottom or top frame |
7 | 3236 frame_new_height(frp, frp->fr_height + extra_lines, topfirst, wfh); |
3237 } | |
3238 } | |
3239 topfrp->fr_height = height; | |
3240 } | |
3241 | |
3242 /* | |
3243 * Return TRUE if height of frame "frp" should not be changed because of | |
3244 * the 'winfixheight' option. | |
3245 */ | |
3246 static int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3247 frame_fixed_height(frame_T *frp) |
7 | 3248 { |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3249 // frame with one window: fixed height if 'winfixheight' set. |
7 | 3250 if (frp->fr_win != NULL) |
3251 return frp->fr_win->w_p_wfh; | |
3252 | |
3253 if (frp->fr_layout == FR_ROW) | |
3254 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3255 // The frame is fixed height if one of the frames in the row is fixed |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3256 // height. |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
3257 FOR_ALL_FRAMES(frp, frp->fr_child) |
7 | 3258 if (frame_fixed_height(frp)) |
3259 return TRUE; | |
3260 return FALSE; | |
3261 } | |
3262 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3263 // frp->fr_layout == FR_COL: The frame is fixed height if all of the |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3264 // frames in the row are fixed height. |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
3265 FOR_ALL_FRAMES(frp, frp->fr_child) |
7 | 3266 if (!frame_fixed_height(frp)) |
3267 return FALSE; | |
3268 return TRUE; | |
3269 } | |
3270 | |
3271 /* | |
779 | 3272 * Return TRUE if width of frame "frp" should not be changed because of |
3273 * the 'winfixwidth' option. | |
3274 */ | |
3275 static int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3276 frame_fixed_width(frame_T *frp) |
779 | 3277 { |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3278 // frame with one window: fixed width if 'winfixwidth' set. |
779 | 3279 if (frp->fr_win != NULL) |
3280 return frp->fr_win->w_p_wfw; | |
3281 | |
3282 if (frp->fr_layout == FR_COL) | |
3283 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3284 // The frame is fixed width if one of the frames in the row is fixed |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3285 // width. |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
3286 FOR_ALL_FRAMES(frp, frp->fr_child) |
779 | 3287 if (frame_fixed_width(frp)) |
3288 return TRUE; | |
3289 return FALSE; | |
3290 } | |
3291 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3292 // frp->fr_layout == FR_ROW: The frame is fixed width if all of the |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3293 // frames in the row are fixed width. |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
3294 FOR_ALL_FRAMES(frp, frp->fr_child) |
779 | 3295 if (!frame_fixed_width(frp)) |
3296 return FALSE; | |
3297 return TRUE; | |
3298 } | |
3299 | |
3300 /* | |
7 | 3301 * Add a status line to windows at the bottom of "frp". |
3302 * Note: Does not check if there is room! | |
3303 */ | |
3304 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3305 frame_add_statusline(frame_T *frp) |
7 | 3306 { |
3307 win_T *wp; | |
3308 | |
3309 if (frp->fr_layout == FR_LEAF) | |
3310 { | |
3311 wp = frp->fr_win; | |
3312 if (wp->w_status_height == 0) | |
3313 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3314 if (wp->w_height > 0) // don't make it negative |
7 | 3315 --wp->w_height; |
3316 wp->w_status_height = STATUS_HEIGHT; | |
3317 } | |
3318 } | |
3319 else if (frp->fr_layout == FR_ROW) | |
3320 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3321 // Handle all the frames in the row. |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
3322 FOR_ALL_FRAMES(frp, frp->fr_child) |
7 | 3323 frame_add_statusline(frp); |
3324 } | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3325 else // frp->fr_layout == FR_COL |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3326 { |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3327 // Only need to handle the last frame in the column. |
7 | 3328 for (frp = frp->fr_child; frp->fr_next != NULL; frp = frp->fr_next) |
3329 ; | |
3330 frame_add_statusline(frp); | |
3331 } | |
3332 } | |
3333 | |
3334 /* | |
3335 * Set width of a frame. Handles recursively going through contained frames. | |
3336 * May remove separator line for windows at the right side (for win_close()). | |
3337 */ | |
3338 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3339 frame_new_width( |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3340 frame_T *topfrp, |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3341 int width, |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3342 int leftfirst, // resize leftmost contained frame first |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3343 int wfw) // obey 'winfixwidth' when there is a choice; |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3344 // may cause the width not to be set |
7 | 3345 { |
3346 frame_T *frp; | |
3347 int extra_cols; | |
3348 int w; | |
3349 win_T *wp; | |
3350 | |
3351 if (topfrp->fr_layout == FR_LEAF) | |
3352 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3353 // Simple case: just one window. |
7 | 3354 wp = topfrp->fr_win; |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3355 // Find out if there are any windows right of this one. |
7 | 3356 for (frp = topfrp; frp->fr_parent != NULL; frp = frp->fr_parent) |
3357 if (frp->fr_parent->fr_layout == FR_ROW && frp->fr_next != NULL) | |
3358 break; | |
3359 if (frp->fr_parent == NULL) | |
3360 wp->w_vsep_width = 0; | |
3361 win_new_width(wp, width - wp->w_vsep_width); | |
3362 } | |
3363 else if (topfrp->fr_layout == FR_COL) | |
3364 { | |
779 | 3365 do |
3366 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3367 // All frames in this column get the same new width. |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
3368 FOR_ALL_FRAMES(frp, topfrp->fr_child) |
779 | 3369 { |
3370 frame_new_width(frp, width, leftfirst, wfw); | |
3371 if (frp->fr_width > width) | |
3372 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3373 // Could not fit the windows, make whole column wider. |
779 | 3374 width = frp->fr_width; |
3375 break; | |
3376 } | |
3377 } | |
3378 } while (frp != NULL); | |
7 | 3379 } |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3380 else // fr_layout == FR_ROW |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3381 { |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3382 // Complicated case: Resize a row of frames. Resize the rightmost |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3383 // frame first, frames left of it when needed. |
7 | 3384 |
3385 frp = topfrp->fr_child; | |
779 | 3386 if (wfw) |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3387 // Advance past frames with one window with 'wfw' set. |
779 | 3388 while (frame_fixed_width(frp)) |
3389 { | |
3390 frp = frp->fr_next; | |
3391 if (frp == NULL) | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3392 return; // no frame without 'wfw', give up |
779 | 3393 } |
7 | 3394 if (!leftfirst) |
779 | 3395 { |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3396 // Find the rightmost frame of this row |
7 | 3397 while (frp->fr_next != NULL) |
3398 frp = frp->fr_next; | |
779 | 3399 if (wfw) |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3400 // Advance back for frames with one window with 'wfw' set. |
779 | 3401 while (frame_fixed_width(frp)) |
3402 frp = frp->fr_prev; | |
3403 } | |
7 | 3404 |
3405 extra_cols = width - topfrp->fr_width; | |
3406 if (extra_cols < 0) | |
3407 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3408 // reduce frame width, rightmost frame first |
7 | 3409 while (frp != NULL) |
3410 { | |
3411 w = frame_minwidth(frp, NULL); | |
3412 if (frp->fr_width + extra_cols < w) | |
3413 { | |
3414 extra_cols += frp->fr_width - w; | |
779 | 3415 frame_new_width(frp, w, leftfirst, wfw); |
7 | 3416 } |
3417 else | |
3418 { | |
779 | 3419 frame_new_width(frp, frp->fr_width + extra_cols, |
3420 leftfirst, wfw); | |
7 | 3421 break; |
3422 } | |
3423 if (leftfirst) | |
779 | 3424 { |
3425 do | |
3426 frp = frp->fr_next; | |
3427 while (wfw && frp != NULL && frame_fixed_width(frp)); | |
3428 } | |
7 | 3429 else |
779 | 3430 { |
3431 do | |
3432 frp = frp->fr_prev; | |
3433 while (wfw && frp != NULL && frame_fixed_width(frp)); | |
3434 } | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3435 // Increase "width" if we could not reduce enough frames. |
779 | 3436 if (frp == NULL) |
3437 width -= extra_cols; | |
7 | 3438 } |
3439 } | |
3440 else if (extra_cols > 0) | |
3441 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3442 // increase width of rightmost frame |
779 | 3443 frame_new_width(frp, frp->fr_width + extra_cols, leftfirst, wfw); |
7 | 3444 } |
3445 } | |
3446 topfrp->fr_width = width; | |
3447 } | |
3448 | |
3449 /* | |
3450 * Add the vertical separator to windows at the right side of "frp". | |
3451 * Note: Does not check if there is room! | |
3452 */ | |
3453 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3454 frame_add_vsep(frame_T *frp) |
7 | 3455 { |
3456 win_T *wp; | |
3457 | |
3458 if (frp->fr_layout == FR_LEAF) | |
3459 { | |
3460 wp = frp->fr_win; | |
3461 if (wp->w_vsep_width == 0) | |
3462 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3463 if (wp->w_width > 0) // don't make it negative |
7 | 3464 --wp->w_width; |
3465 wp->w_vsep_width = 1; | |
3466 } | |
3467 } | |
3468 else if (frp->fr_layout == FR_COL) | |
3469 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3470 // Handle all the frames in the column. |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
3471 FOR_ALL_FRAMES(frp, frp->fr_child) |
7 | 3472 frame_add_vsep(frp); |
3473 } | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3474 else // frp->fr_layout == FR_ROW |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3475 { |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3476 // Only need to handle the last frame in the row. |
7 | 3477 frp = frp->fr_child; |
3478 while (frp->fr_next != NULL) | |
3479 frp = frp->fr_next; | |
3480 frame_add_vsep(frp); | |
3481 } | |
3482 } | |
3483 | |
3484 /* | |
3485 * Set frame width from the window it contains. | |
3486 */ | |
3487 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3488 frame_fix_width(win_T *wp) |
7 | 3489 { |
3490 wp->w_frame->fr_width = wp->w_width + wp->w_vsep_width; | |
3491 } | |
3492 | |
3493 /* | |
3494 * Set frame height from the window it contains. | |
3495 */ | |
3496 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3497 frame_fix_height(win_T *wp) |
7 | 3498 { |
12998
dd734ee3e2fe
patch 8.0.1375: window size wrong after maximizing with WinBar
Christian Brabandt <cb@256bit.org>
parents:
12916
diff
changeset
|
3499 wp->w_frame->fr_height = VISIBLE_HEIGHT(wp) + wp->w_status_height; |
7 | 3500 } |
3501 | |
3502 /* | |
3503 * Compute the minimal height for frame "topfrp". | |
3504 * Uses the 'winminheight' option. | |
3505 * When "next_curwin" isn't NULL, use p_wh for this window. | |
3506 * When "next_curwin" is NOWIN, don't use at least one line for the current | |
3507 * window. | |
3508 */ | |
3509 static int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3510 frame_minheight(frame_T *topfrp, win_T *next_curwin) |
7 | 3511 { |
3512 frame_T *frp; | |
3513 int m; | |
3514 int n; | |
3515 | |
3516 if (topfrp->fr_win != NULL) | |
3517 { | |
3518 if (topfrp->fr_win == next_curwin) | |
3519 m = p_wh + topfrp->fr_win->w_status_height; | |
3520 else | |
3521 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3522 // window: minimal height of the window plus status line |
7 | 3523 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
|
3524 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
|
3525 { |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3526 // Current window is minimal one line high and WinBar is |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3527 // visible. |
12998
dd734ee3e2fe
patch 8.0.1375: window size wrong after maximizing with WinBar
Christian Brabandt <cb@256bit.org>
parents:
12916
diff
changeset
|
3528 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
|
3529 ++m; |
dd734ee3e2fe
patch 8.0.1375: window size wrong after maximizing with WinBar
Christian Brabandt <cb@256bit.org>
parents:
12916
diff
changeset
|
3530 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
|
3531 } |
7 | 3532 } |
3533 } | |
3534 else if (topfrp->fr_layout == FR_ROW) | |
3535 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3536 // get the minimal height from each frame in this row |
7 | 3537 m = 0; |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
3538 FOR_ALL_FRAMES(frp, topfrp->fr_child) |
7 | 3539 { |
3540 n = frame_minheight(frp, next_curwin); | |
3541 if (n > m) | |
3542 m = n; | |
3543 } | |
3544 } | |
3545 else | |
3546 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3547 // Add up the minimal heights for all frames in this column. |
7 | 3548 m = 0; |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
3549 FOR_ALL_FRAMES(frp, topfrp->fr_child) |
7 | 3550 m += frame_minheight(frp, next_curwin); |
3551 } | |
3552 | |
3553 return m; | |
3554 } | |
3555 | |
3556 /* | |
3557 * Compute the minimal width for frame "topfrp". | |
3558 * When "next_curwin" isn't NULL, use p_wiw for this window. | |
3559 * When "next_curwin" is NOWIN, don't use at least one column for the current | |
3560 * window. | |
3561 */ | |
3562 static int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3563 frame_minwidth( |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3564 frame_T *topfrp, |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3565 win_T *next_curwin) // use p_wh and p_wiw for next_curwin |
7 | 3566 { |
3567 frame_T *frp; | |
3568 int m, n; | |
3569 | |
3570 if (topfrp->fr_win != NULL) | |
3571 { | |
3572 if (topfrp->fr_win == next_curwin) | |
3573 m = p_wiw + topfrp->fr_win->w_vsep_width; | |
3574 else | |
3575 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3576 // window: minimal width of the window plus separator column |
7 | 3577 m = p_wmw + topfrp->fr_win->w_vsep_width; |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3578 // Current window is minimal one column wide |
7 | 3579 if (p_wmw == 0 && topfrp->fr_win == curwin && next_curwin == NULL) |
3580 ++m; | |
3581 } | |
3582 } | |
3583 else if (topfrp->fr_layout == FR_COL) | |
3584 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3585 // get the minimal width from each frame in this column |
7 | 3586 m = 0; |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
3587 FOR_ALL_FRAMES(frp, topfrp->fr_child) |
7 | 3588 { |
3589 n = frame_minwidth(frp, next_curwin); | |
3590 if (n > m) | |
3591 m = n; | |
3592 } | |
3593 } | |
3594 else | |
3595 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3596 // Add up the minimal widths for all frames in this row. |
7 | 3597 m = 0; |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
3598 FOR_ALL_FRAMES(frp, topfrp->fr_child) |
7 | 3599 m += frame_minwidth(frp, next_curwin); |
3600 } | |
3601 | |
3602 return m; | |
3603 } | |
3604 | |
3605 | |
3606 /* | |
3607 * Try to close all windows except current one. | |
3608 * Buffers in the other windows become hidden if 'hidden' is set, or '!' is | |
3609 * used and the buffer was modified. | |
3610 * | |
3611 * Used by ":bdel" and ":only". | |
3612 */ | |
3613 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3614 close_others( |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3615 int message, |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3616 int forceit) // always hide all other windows |
7 | 3617 { |
3618 win_T *wp; | |
3619 win_T *nextwp; | |
3620 int r; | |
3621 | |
1906 | 3622 if (one_window()) |
7 | 3623 { |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13308
diff
changeset
|
3624 if (message && !autocmd_busy) |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15490
diff
changeset
|
3625 msg(_(m_onlyone)); |
7 | 3626 return; |
3627 } | |
3628 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3629 // Be very careful here: autocommands may change the window layout. |
7 | 3630 for (wp = firstwin; win_valid(wp); wp = nextwp) |
3631 { | |
3632 nextwp = wp->w_next; | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3633 if (wp != curwin) // don't close current window |
7 | 3634 { |
3635 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3636 // Check if it's allowed to abandon this window |
7 | 3637 r = can_abandon(wp->w_buffer, forceit); |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3638 if (!win_valid(wp)) // autocommands messed wp up |
7 | 3639 { |
3640 nextwp = firstwin; | |
3641 continue; | |
3642 } | |
3643 if (!r) | |
3644 { | |
3645 #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) | |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22470
diff
changeset
|
3646 if (message && (p_confirm |
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22470
diff
changeset
|
3647 || (cmdmod.cmod_flags & CMOD_CONFIRM)) && p_write) |
7 | 3648 { |
3649 dialog_changed(wp->w_buffer, FALSE); | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3650 if (!win_valid(wp)) // autocommands messed wp up |
7 | 3651 { |
3652 nextwp = firstwin; | |
3653 continue; | |
3654 } | |
3655 } | |
3656 if (bufIsChanged(wp->w_buffer)) | |
3657 #endif | |
3658 continue; | |
3659 } | |
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
|
3660 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
|
3661 && !bufIsChanged(wp->w_buffer)); |
7 | 3662 } |
3663 } | |
3664 | |
10357
59d01e335858
commit https://github.com/vim/vim/commit/459ca563128f2edb7e3bb190090bbb755a56dd55
Christian Brabandt <cb@256bit.org>
parents:
10349
diff
changeset
|
3665 if (message && !ONE_WINDOW) |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15436
diff
changeset
|
3666 emsg(_("E445: Other window contains changes")); |
7 | 3667 } |
3668 | |
17789
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17670
diff
changeset
|
3669 static void |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3670 win_init_empty(win_T *wp) |
1918 | 3671 { |
3672 redraw_win_later(wp, NOT_VALID); | |
3673 wp->w_lines_valid = 0; | |
3674 wp->w_cursor.lnum = 1; | |
3675 wp->w_curswant = wp->w_cursor.col = 0; | |
3676 wp->w_cursor.coladd = 0; | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3677 wp->w_pcmark.lnum = 1; // pcmark not cleared but set to line 1 |
1918 | 3678 wp->w_pcmark.col = 0; |
3679 wp->w_prev_pcmark.lnum = 0; | |
3680 wp->w_prev_pcmark.col = 0; | |
3681 wp->w_topline = 1; | |
7 | 3682 #ifdef FEAT_DIFF |
1918 | 3683 wp->w_topfill = 0; |
3684 #endif | |
3685 wp->w_botline = 2; | |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
3686 #if defined(FEAT_SYN_HL) || defined(FEAT_SPELL) |
3068 | 3687 wp->w_s = &wp->w_buffer->b_s; |
3688 #endif | |
26193
c83460a14407
patch 8.2.3628: looking terminal colors is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26171
diff
changeset
|
3689 #ifdef FEAT_TERMINAL |
c83460a14407
patch 8.2.3628: looking terminal colors is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26171
diff
changeset
|
3690 term_reset_wincolor(wp); |
c83460a14407
patch 8.2.3628: looking terminal colors is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26171
diff
changeset
|
3691 #endif |
7 | 3692 } |
3693 | |
3694 /* | |
17789
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17670
diff
changeset
|
3695 * Init the current window "curwin". |
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17670
diff
changeset
|
3696 * Called when a new file is being edited. |
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17670
diff
changeset
|
3697 */ |
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17670
diff
changeset
|
3698 void |
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17670
diff
changeset
|
3699 curwin_init(void) |
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17670
diff
changeset
|
3700 { |
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17670
diff
changeset
|
3701 win_init_empty(curwin); |
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17670
diff
changeset
|
3702 } |
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17670
diff
changeset
|
3703 |
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17670
diff
changeset
|
3704 /* |
7 | 3705 * Allocate the first window and put an empty buffer in it. |
3706 * Called from main(). | |
667 | 3707 * Return FAIL when something goes wrong (out of memory). |
7 | 3708 */ |
667 | 3709 int |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3710 win_alloc_first(void) |
7 | 3711 { |
675 | 3712 if (win_alloc_firstwin(NULL) == FAIL) |
667 | 3713 return FAIL; |
3714 | |
672 | 3715 first_tabpage = alloc_tabpage(); |
667 | 3716 if (first_tabpage == NULL) |
3717 return FAIL; | |
3718 first_tabpage->tp_topframe = topframe; | |
672 | 3719 curtab = first_tabpage; |
19155
013f20a3bc6b
patch 8.2.0137: crash when using win_execute() from a new tab
Bram Moolenaar <Bram@vim.org>
parents:
19143
diff
changeset
|
3720 curtab->tp_firstwin = firstwin; |
013f20a3bc6b
patch 8.2.0137: crash when using win_execute() from a new tab
Bram Moolenaar <Bram@vim.org>
parents:
19143
diff
changeset
|
3721 curtab->tp_lastwin = lastwin; |
013f20a3bc6b
patch 8.2.0137: crash when using win_execute() from a new tab
Bram Moolenaar <Bram@vim.org>
parents:
19143
diff
changeset
|
3722 curtab->tp_curwin = curwin; |
1906 | 3723 |
667 | 3724 return OK; |
3725 } | |
3726 | |
1906 | 3727 /* |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
3728 * Allocate and init a window that is not a regular window. |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
3729 * This can only be done after the first window is fully initialized, thus it |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
3730 * can't be in win_alloc_first(). |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
3731 */ |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
3732 win_T * |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
3733 win_alloc_popup_win(void) |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
3734 { |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
3735 win_T *wp; |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
3736 |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
3737 wp = win_alloc(NULL, TRUE); |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
3738 if (wp != NULL) |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
3739 { |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
3740 // We need to initialize options with something, using the current |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
3741 // window makes most sense. |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
3742 win_init_some(wp, curwin); |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
3743 |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
3744 RESET_BINDING(wp); |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
3745 new_frame(wp); |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
3746 } |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
3747 return wp; |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
3748 } |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
3749 |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
3750 /* |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
3751 * Initialize window "wp" to display buffer "buf". |
1906 | 3752 */ |
3753 void | |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
3754 win_init_popup_win(win_T *wp, buf_T *buf) |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
3755 { |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
3756 wp->w_buffer = buf; |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
3757 ++buf->b_nwindows; |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
3758 win_init_empty(wp); // set cursor and topline to safe values |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
3759 |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
3760 // Make sure w_localdir and globaldir are NULL to avoid a chdir() in |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
3761 // win_enter_ext(). |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
3762 VIM_CLEAR(wp->w_localdir); |
1906 | 3763 } |
3764 | |
667 | 3765 /* |
675 | 3766 * Allocate the first window or the first window in a new tab page. |
3767 * 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
|
3768 * When "oldwin" is not NULL copy info from it to the new window. |
667 | 3769 * Return FAIL when something goes wrong (out of memory). |
3770 */ | |
3771 static int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3772 win_alloc_firstwin(win_T *oldwin) |
667 | 3773 { |
1906 | 3774 curwin = win_alloc(NULL, FALSE); |
675 | 3775 if (oldwin == NULL) |
3776 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3777 // Very first window, need to create an empty buffer for it and |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3778 // initialize from scratch. |
675 | 3779 curbuf = buflist_new(NULL, NULL, 1L, BLN_LISTED); |
3780 if (curwin == NULL || curbuf == NULL) | |
3781 return FAIL; | |
3782 curwin->w_buffer = curbuf; | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2201
diff
changeset
|
3783 #ifdef FEAT_SYN_HL |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2201
diff
changeset
|
3784 curwin->w_s = &(curbuf->b_s); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2201
diff
changeset
|
3785 #endif |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3786 curbuf->b_nwindows = 1; // there is one window |
675 | 3787 curwin->w_alist = &global_alist; |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3788 curwin_init(); // init current window |
675 | 3789 } |
3790 else | |
3791 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3792 // First window in new tab page, initialize it from "oldwin". |
1822 | 3793 win_init(curwin, oldwin, 0); |
675 | 3794 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3795 // We don't want cursor- and scroll-binding in the first window. |
2583 | 3796 RESET_BINDING(curwin); |
675 | 3797 } |
7 | 3798 |
1906 | 3799 new_frame(curwin); |
3800 if (curwin->w_frame == NULL) | |
667 | 3801 return FAIL; |
1906 | 3802 topframe = curwin->w_frame; |
7 | 3803 topframe->fr_width = Columns; |
3804 topframe->fr_height = Rows - p_ch; | |
667 | 3805 |
3806 return OK; | |
3807 } | |
3808 | |
3809 /* | |
1906 | 3810 * Create a frame for window "wp". |
3811 */ | |
3812 static void | |
3813 new_frame(win_T *wp) | |
3814 { | |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16802
diff
changeset
|
3815 frame_T *frp = ALLOC_CLEAR_ONE(frame_T); |
1906 | 3816 |
3817 wp->w_frame = frp; | |
3818 if (frp != NULL) | |
3819 { | |
3820 frp->fr_layout = FR_LEAF; | |
3821 frp->fr_win = wp; | |
3822 } | |
3823 } | |
3824 | |
3825 /* | |
667 | 3826 * Initialize the window and frame size to the maximum. |
3827 */ | |
3828 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3829 win_init_size(void) |
667 | 3830 { |
3831 firstwin->w_height = ROWS_AVAIL; | |
3832 topframe->fr_height = ROWS_AVAIL; | |
3833 firstwin->w_width = Columns; | |
3834 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
|
3835 } |
672 | 3836 |
3837 /* | |
3838 * Allocate a new tabpage_T and init the values. | |
3839 * Returns NULL when out of memory. | |
3840 */ | |
3841 static tabpage_T * | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3842 alloc_tabpage(void) |
672 | 3843 { |
3844 tabpage_T *tp; | |
4287 | 3845 # ifdef FEAT_GUI |
3846 int i; | |
3847 # endif | |
3848 | |
672 | 3849 |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16802
diff
changeset
|
3850 tp = ALLOC_CLEAR_ONE(tabpage_T); |
4287 | 3851 if (tp == NULL) |
3852 return NULL; | |
3853 | |
3854 # ifdef FEAT_EVAL | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3855 // init t: variables |
4287 | 3856 tp->tp_vars = dict_alloc(); |
3857 if (tp->tp_vars == NULL) | |
3858 { | |
3859 vim_free(tp); | |
3860 return NULL; | |
3861 } | |
3862 init_var_dict(tp->tp_vars, &tp->tp_winvar, VAR_SCOPE); | |
3863 # endif | |
3864 | |
788 | 3865 # ifdef FEAT_GUI |
4287 | 3866 for (i = 0; i < 3; i++) |
3867 tp->tp_prev_which_scrollbars[i] = -1; | |
788 | 3868 # endif |
672 | 3869 # ifdef FEAT_DIFF |
4287 | 3870 tp->tp_diff_invalid = TRUE; |
672 | 3871 # endif |
4287 | 3872 tp->tp_ch_used = p_ch; |
3873 | |
672 | 3874 return tp; |
3875 } | |
3876 | |
852 | 3877 void |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3878 free_tabpage(tabpage_T *tp) |
672 | 3879 { |
1906 | 3880 int idx; |
3881 | |
672 | 3882 # ifdef FEAT_DIFF |
3883 diff_clear(tp); | |
3884 # endif | |
18763
49b78d6465e5
patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents:
18590
diff
changeset
|
3885 # ifdef FEAT_PROP_POPUP |
16800
12e3a3afdb6a
patch 8.1.1402: "timer" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents:
16796
diff
changeset
|
3886 while (tp->tp_first_popupwin != NULL) |
20384
42ab4d40e78f
patch 8.2.0747: cannot forcefully close all popups
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
3887 popup_close_tabpage(tp, tp->tp_first_popupwin->w_id, TRUE); |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
3888 #endif |
1906 | 3889 for (idx = 0; idx < SNAP_COUNT; ++idx) |
3890 clear_snapshot(tp, idx); | |
819 | 3891 #ifdef FEAT_EVAL |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3892 vars_clear(&tp->tp_vars->dv_hashtab); // free all t: variables |
4287 | 3893 hash_init(&tp->tp_vars->dv_hashtab); |
3894 unref_var_dict(tp->tp_vars); | |
819 | 3895 #endif |
4401 | 3896 |
21703
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21020
diff
changeset
|
3897 if (tp == lastused_tabpage) |
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21020
diff
changeset
|
3898 lastused_tabpage = NULL; |
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21020
diff
changeset
|
3899 |
16427
8c3a1bd270bb
patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents:
16405
diff
changeset
|
3900 vim_free(tp->tp_localdir); |
20711
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20384
diff
changeset
|
3901 vim_free(tp->tp_prevdir); |
16427
8c3a1bd270bb
patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents:
16405
diff
changeset
|
3902 |
4401 | 3903 #ifdef FEAT_PYTHON |
3904 python_tabpage_free(tp); | |
3905 #endif | |
3906 | |
3907 #ifdef FEAT_PYTHON3 | |
3908 python3_tabpage_free(tp); | |
3909 #endif | |
3910 | |
672 | 3911 vim_free(tp); |
3912 } | |
3913 | |
667 | 3914 /* |
675 | 3915 * Create a new Tab page with one window. |
3916 * It will edit the current buffer, like after ":split". | |
682 | 3917 * When "after" is 0 put it just after the current Tab page. |
3918 * Otherwise put it just before tab page "after". | |
667 | 3919 * Return FAIL or OK. |
3920 */ | |
3921 int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3922 win_new_tabpage(int after) |
667 | 3923 { |
672 | 3924 tabpage_T *tp = curtab; |
21727
860cad58f557
patch 8.2.1413: previous tab page not usable from an Ex command
Bram Moolenaar <Bram@vim.org>
parents:
21723
diff
changeset
|
3925 tabpage_T *prev_tp = curtab; |
667 | 3926 tabpage_T *newtp; |
682 | 3927 int n; |
667 | 3928 |
672 | 3929 newtp = alloc_tabpage(); |
667 | 3930 if (newtp == NULL) |
3931 return FAIL; | |
3932 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3933 // Remember the current windows in this Tab page. |
4354 | 3934 if (leave_tabpage(curbuf, TRUE) == FAIL) |
674 | 3935 { |
3936 vim_free(newtp); | |
3937 return FAIL; | |
3938 } | |
672 | 3939 curtab = newtp; |
667 | 3940 |
16427
8c3a1bd270bb
patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents:
16405
diff
changeset
|
3941 newtp->tp_localdir = (tp->tp_localdir == NULL) |
8c3a1bd270bb
patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents:
16405
diff
changeset
|
3942 ? NULL : vim_strsave(tp->tp_localdir); |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3943 // Create a new empty window. |
675 | 3944 if (win_alloc_firstwin(tp->tp_curwin) == OK) |
667 | 3945 { |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3946 // Make the new Tab page the new topframe. |
682 | 3947 if (after == 1) |
3948 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3949 // New tab page becomes the first one. |
682 | 3950 newtp->tp_next = first_tabpage; |
3951 first_tabpage = newtp; | |
3952 } | |
3953 else | |
3954 { | |
3955 if (after > 0) | |
3956 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3957 // Put new tab page before tab page "after". |
682 | 3958 n = 2; |
3959 for (tp = first_tabpage; tp->tp_next != NULL | |
3960 && n < after; tp = tp->tp_next) | |
3961 ++n; | |
3962 } | |
3963 newtp->tp_next = tp->tp_next; | |
3964 tp->tp_next = newtp; | |
3965 } | |
19155
013f20a3bc6b
patch 8.2.0137: crash when using win_execute() from a new tab
Bram Moolenaar <Bram@vim.org>
parents:
19143
diff
changeset
|
3966 newtp->tp_firstwin = newtp->tp_lastwin = newtp->tp_curwin = curwin; |
013f20a3bc6b
patch 8.2.0137: crash when using win_execute() from a new tab
Bram Moolenaar <Bram@vim.org>
parents:
19143
diff
changeset
|
3967 |
667 | 3968 win_init_size(); |
685 | 3969 firstwin->w_winrow = tabline_height(); |
819 | 3970 win_comp_scroll(curwin); |
667 | 3971 |
3972 newtp->tp_topframe = topframe; | |
671 | 3973 last_status(FALSE); |
815 | 3974 |
21727
860cad58f557
patch 8.2.1413: previous tab page not usable from an Ex command
Bram Moolenaar <Bram@vim.org>
parents:
21723
diff
changeset
|
3975 lastused_tabpage = prev_tp; |
21703
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21020
diff
changeset
|
3976 |
815 | 3977 #if defined(FEAT_GUI) |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3978 // When 'guioptions' includes 'L' or 'R' may have to remove or add |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3979 // scrollbars. Have to update them anyway. |
1906 | 3980 gui_may_update_scrollbars(); |
815 | 3981 #endif |
14035
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
3982 #ifdef FEAT_JOB_CHANNEL |
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
3983 entering_window(curwin); |
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
3984 #endif |
815 | 3985 |
15380
f62d6bd18a49
patch 8.1.0698: clearing the window is used too often
Bram Moolenaar <Bram@vim.org>
parents:
15227
diff
changeset
|
3986 redraw_all_later(NOT_VALID); |
9595
0190d5de215f
commit https://github.com/vim/vim/commit/c917da4b3e8801a255dbefea8e4ed19c1c716dd8
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
3987 apply_autocmds(EVENT_WINNEW, NULL, NULL, FALSE, curbuf); |
4354 | 3988 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
|
3989 apply_autocmds(EVENT_TABNEW, NULL, NULL, FALSE, curbuf); |
675 | 3990 apply_autocmds(EVENT_TABENTER, NULL, NULL, FALSE, curbuf); |
667 | 3991 return OK; |
3992 } | |
3993 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3994 // Failed, get back the previous Tab page |
4354 | 3995 enter_tabpage(curtab, curbuf, TRUE, TRUE); |
667 | 3996 return FAIL; |
3997 } | |
3998 | |
3999 /* | |
682 | 4000 * Open a new tab page if ":tab cmd" was used. It will edit the same buffer, |
4001 * like with ":split". | |
4002 * Returns OK if a new tab page was created, FAIL otherwise. | |
4003 */ | |
17789
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17670
diff
changeset
|
4004 static int |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4005 may_open_tabpage(void) |
682 | 4006 { |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22470
diff
changeset
|
4007 int n = (cmdmod.cmod_tab == 0) |
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22470
diff
changeset
|
4008 ? postponed_split_tab : cmdmod.cmod_tab; |
1090 | 4009 |
4010 if (n != 0) | |
682 | 4011 { |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22470
diff
changeset
|
4012 cmdmod.cmod_tab = 0; // reset it to avoid doing it twice |
1090 | 4013 postponed_split_tab = 0; |
682 | 4014 return win_new_tabpage(n); |
4015 } | |
4016 return FAIL; | |
4017 } | |
4018 | |
4019 /* | |
672 | 4020 * Create up to "maxcount" tabpages with empty windows. |
4021 * Returns the number of resulting tab pages. | |
667 | 4022 */ |
672 | 4023 int |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4024 make_tabpages(int maxcount) |
667 | 4025 { |
672 | 4026 int count = maxcount; |
4027 int todo; | |
4028 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4029 // Limit to 'tabpagemax' tabs. |
698 | 4030 if (count > p_tpm) |
4031 count = p_tpm; | |
672 | 4032 |
4033 /* | |
4034 * Don't execute autocommands while creating the tab pages. Must do that | |
4035 * when putting the buffers in the windows. | |
4036 */ | |
1410 | 4037 block_autocmds(); |
672 | 4038 |
4039 for (todo = count - 1; todo > 0; --todo) | |
682 | 4040 if (win_new_tabpage(0) == FAIL) |
667 | 4041 break; |
672 | 4042 |
1410 | 4043 unblock_autocmds(); |
672 | 4044 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4045 // return actual number of tab pages |
672 | 4046 return (count - todo); |
667 | 4047 } |
4048 | |
4049 /* | |
671 | 4050 * Return TRUE when "tpc" points to a valid tab page. |
4051 */ | |
4052 int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4053 valid_tabpage(tabpage_T *tpc) |
671 | 4054 { |
4055 tabpage_T *tp; | |
4056 | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9599
diff
changeset
|
4057 FOR_ALL_TABPAGES(tp) |
671 | 4058 if (tp == tpc) |
4059 return TRUE; | |
4060 return FALSE; | |
4061 } | |
4062 | |
4063 /* | |
11199
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4064 * 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
|
4065 * valid. |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4066 */ |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4067 int |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4068 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
|
4069 { |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4070 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
|
4071 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
|
4072 |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4073 FOR_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
|
4074 { |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4075 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
|
4076 { |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4077 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
|
4078 { |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4079 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
|
4080 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
|
4081 } |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4082 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
|
4083 } |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4084 } |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4085 // shouldn't happen |
11199
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4086 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
|
4087 } |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4088 |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4089 /* |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4090 * 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
|
4091 * 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
|
4092 */ |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4093 void |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4094 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
|
4095 { |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4096 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
|
4097 |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4098 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
|
4099 { |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4100 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
|
4101 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
|
4102 } |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4103 else |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4104 { |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4105 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
|
4106 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
|
4107 ; |
11232
a14090a30a3f
patch 8.0.0502: Coverity complains about possible NULL pointer
Christian Brabandt <cb@256bit.org>
parents:
11207
diff
changeset
|
4108 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
|
4109 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
|
4110 } |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4111 |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4112 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
|
4113 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
|
4114 } |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4115 |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4116 /* |
671 | 4117 * Find tab page "n" (first one is 1). Returns NULL when not found. |
4118 */ | |
4119 tabpage_T * | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4120 find_tabpage(int n) |
671 | 4121 { |
4122 tabpage_T *tp; | |
4123 int i = 1; | |
4124 | |
16427
8c3a1bd270bb
patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents:
16405
diff
changeset
|
4125 if (n == 0) |
8c3a1bd270bb
patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents:
16405
diff
changeset
|
4126 return curtab; |
8c3a1bd270bb
patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents:
16405
diff
changeset
|
4127 |
671 | 4128 for (tp = first_tabpage; tp != NULL && i != n; tp = tp->tp_next) |
4129 ++i; | |
4130 return tp; | |
4131 } | |
4132 | |
4133 /* | |
685 | 4134 * Get index of tab page "tp". First one has index 1. |
686 | 4135 * When not found returns number of tab pages plus one. |
685 | 4136 */ |
4137 int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4138 tabpage_index(tabpage_T *ftp) |
685 | 4139 { |
4140 int i = 1; | |
4141 tabpage_T *tp; | |
4142 | |
4143 for (tp = first_tabpage; tp != NULL && tp != ftp; tp = tp->tp_next) | |
4144 ++i; | |
4145 return i; | |
4146 } | |
4147 | |
4148 /* | |
674 | 4149 * Prepare for leaving the current tab page. |
4352 | 4150 * When autocommands change "curtab" we don't leave the tab page and return |
674 | 4151 * FAIL. |
4152 * Careful: When OK is returned need to get a new tab page very very soon! | |
667 | 4153 */ |
674 | 4154 static int |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4155 leave_tabpage( |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4156 buf_T *new_curbuf UNUSED, // what is going to be the new curbuf, |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4157 // NULL if unknown |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4158 int trigger_leave_autocmds UNUSED) |
667 | 4159 { |
674 | 4160 tabpage_T *tp = curtab; |
4161 | |
14035
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
4162 #ifdef FEAT_JOB_CHANNEL |
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
4163 leaving_window(curwin); |
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
4164 #endif |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4165 reset_VIsual_and_resel(); // stop Visual mode |
4354 | 4166 if (trigger_leave_autocmds) |
4167 { | |
4168 if (new_curbuf != curbuf) | |
4169 { | |
4170 apply_autocmds(EVENT_BUFLEAVE, NULL, NULL, FALSE, curbuf); | |
4171 if (curtab != tp) | |
4172 return FAIL; | |
4173 } | |
4174 apply_autocmds(EVENT_WINLEAVE, NULL, NULL, FALSE, curbuf); | |
674 | 4175 if (curtab != tp) |
4176 return FAIL; | |
4354 | 4177 apply_autocmds(EVENT_TABLEAVE, NULL, NULL, FALSE, curbuf); |
4178 if (curtab != tp) | |
4179 return FAIL; | |
4180 } | |
668 | 4181 #if defined(FEAT_GUI) |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4182 // Remove the scrollbars. They may be added back later. |
668 | 4183 if (gui.in_use) |
4184 gui_remove_scrollbars(); | |
4185 #endif | |
667 | 4186 tp->tp_curwin = curwin; |
671 | 4187 tp->tp_prevwin = prevwin; |
667 | 4188 tp->tp_firstwin = firstwin; |
4189 tp->tp_lastwin = lastwin; | |
668 | 4190 tp->tp_old_Rows = Rows; |
26488
06aa56b32df4
patch 8.2.3774: test for command line height fails
Bram Moolenaar <Bram@vim.org>
parents:
26486
diff
changeset
|
4191 if (tp->tp_old_Columns != -1) |
06aa56b32df4
patch 8.2.3774: test for command line height fails
Bram Moolenaar <Bram@vim.org>
parents:
26486
diff
changeset
|
4192 tp->tp_old_Columns = Columns; |
667 | 4193 firstwin = NULL; |
4194 lastwin = NULL; | |
674 | 4195 return OK; |
667 | 4196 } |
4197 | |
4198 /* | |
4199 * Start using tab page "tp". | |
675 | 4200 * Only to be used after leave_tabpage() or freeing the current tab page. |
4354 | 4201 * Only trigger *Enter autocommands when trigger_enter_autocmds is TRUE. |
4202 * Only trigger *Leave autocommands when trigger_leave_autocmds is TRUE. | |
667 | 4203 */ |
4204 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4205 enter_tabpage( |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4206 tabpage_T *tp, |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4207 buf_T *old_curbuf UNUSED, |
8368
db2a07b710ed
commit https://github.com/vim/vim/commit/f1d2501ebe33e148886c2914acd33140e20ee222
Christian Brabandt <cb@256bit.org>
parents:
8212
diff
changeset
|
4208 int trigger_enter_autocmds, |
db2a07b710ed
commit https://github.com/vim/vim/commit/f1d2501ebe33e148886c2914acd33140e20ee222
Christian Brabandt <cb@256bit.org>
parents:
8212
diff
changeset
|
4209 int trigger_leave_autocmds) |
667 | 4210 { |
19143
bfcafd1a3e37
patch 8.2.0131: command line is not cleared when switching tabs
Bram Moolenaar <Bram@vim.org>
parents:
18886
diff
changeset
|
4211 int row; |
668 | 4212 int old_off = tp->tp_firstwin->w_winrow; |
870 | 4213 win_T *next_prevwin = tp->tp_prevwin; |
21703
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21020
diff
changeset
|
4214 tabpage_T *last_tab = curtab; |
668 | 4215 |
672 | 4216 curtab = tp; |
667 | 4217 firstwin = tp->tp_firstwin; |
4218 lastwin = tp->tp_lastwin; | |
4219 topframe = tp->tp_topframe; | |
870 | 4220 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4221 // We would like doing the TabEnter event first, but we don't have a |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4222 // valid current window yet, which may break some commands. |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4223 // This triggers autocommands, thus may make "tp" invalid. |
25501
a1ed55c02e80
patch 8.2.3287: channel events not handled in BufEnter autocommand
Bram Moolenaar <Bram@vim.org>
parents:
25499
diff
changeset
|
4224 (void)win_enter_ext(tp->tp_curwin, WEE_CURWIN_INVALID |
25499
5ebf9bb1cbcd
patch 8.2.3286: win_enter_ext() has too many boolean arguments
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
4225 | (trigger_enter_autocmds ? WEE_TRIGGER_ENTER_AUTOCMDS : 0) |
5ebf9bb1cbcd
patch 8.2.3286: win_enter_ext() has too many boolean arguments
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
4226 | (trigger_leave_autocmds ? WEE_TRIGGER_LEAVE_AUTOCMDS : 0)); |
870 | 4227 prevwin = next_prevwin; |
4228 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4229 last_status(FALSE); // status line may appear or disappear |
19143
bfcafd1a3e37
patch 8.2.0131: command line is not cleared when switching tabs
Bram Moolenaar <Bram@vim.org>
parents:
18886
diff
changeset
|
4230 row = win_comp_pos(); // recompute w_winrow for all windows |
672 | 4231 #ifdef FEAT_DIFF |
4232 diff_need_scrollbind = TRUE; | |
4233 #endif | |
668 | 4234 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4235 // The tabpage line may have appeared or disappeared, may need to resize |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4236 // the frames for that. When the Vim window was resized need to update |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4237 // frame sizes too. Use the stored value of p_ch, so that it can be |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4238 // different for each tab page. |
16477
8cc31b1b1d23
patch 8.1.1242: no cmdline redraw when tabpages have different 'cmdheight'
Bram Moolenaar <Bram@vim.org>
parents:
16475
diff
changeset
|
4239 if (p_ch != curtab->tp_ch_used) |
8cc31b1b1d23
patch 8.1.1242: no cmdline redraw when tabpages have different 'cmdheight'
Bram Moolenaar <Bram@vim.org>
parents:
16475
diff
changeset
|
4240 clear_cmdline = TRUE; |
824 | 4241 p_ch = curtab->tp_ch_used; |
19143
bfcafd1a3e37
patch 8.2.0131: command line is not cleared when switching tabs
Bram Moolenaar <Bram@vim.org>
parents:
18886
diff
changeset
|
4242 |
bfcafd1a3e37
patch 8.2.0131: command line is not cleared when switching tabs
Bram Moolenaar <Bram@vim.org>
parents:
18886
diff
changeset
|
4243 // When cmdheight is changed in a tab page with '<C-w>-', cmdline_row is |
bfcafd1a3e37
patch 8.2.0131: command line is not cleared when switching tabs
Bram Moolenaar <Bram@vim.org>
parents:
18886
diff
changeset
|
4244 // changed but p_ch and tp_ch_used are not changed. Thus we also need to |
bfcafd1a3e37
patch 8.2.0131: command line is not cleared when switching tabs
Bram Moolenaar <Bram@vim.org>
parents:
18886
diff
changeset
|
4245 // check cmdline_row. |
bfcafd1a3e37
patch 8.2.0131: command line is not cleared when switching tabs
Bram Moolenaar <Bram@vim.org>
parents:
18886
diff
changeset
|
4246 if ((row < cmdline_row) && (cmdline_row <= Rows - p_ch)) |
bfcafd1a3e37
patch 8.2.0131: command line is not cleared when switching tabs
Bram Moolenaar <Bram@vim.org>
parents:
18886
diff
changeset
|
4247 clear_cmdline = TRUE; |
bfcafd1a3e37
patch 8.2.0131: command line is not cleared when switching tabs
Bram Moolenaar <Bram@vim.org>
parents:
18886
diff
changeset
|
4248 |
685 | 4249 if (curtab->tp_old_Rows != Rows || (old_off != firstwin->w_winrow |
4250 #ifdef FEAT_GUI_TABLINE | |
4251 && !gui_use_tabline() | |
4252 #endif | |
4253 )) | |
668 | 4254 shell_new_rows(); |
26488
06aa56b32df4
patch 8.2.3774: test for command line height fails
Bram Moolenaar <Bram@vim.org>
parents:
26486
diff
changeset
|
4255 if (curtab->tp_old_Columns != Columns) |
06aa56b32df4
patch 8.2.3774: test for command line height fails
Bram Moolenaar <Bram@vim.org>
parents:
26486
diff
changeset
|
4256 { |
06aa56b32df4
patch 8.2.3774: test for command line height fails
Bram Moolenaar <Bram@vim.org>
parents:
26486
diff
changeset
|
4257 if (starting == 0) |
06aa56b32df4
patch 8.2.3774: test for command line height fails
Bram Moolenaar <Bram@vim.org>
parents:
26486
diff
changeset
|
4258 { |
06aa56b32df4
patch 8.2.3774: test for command line height fails
Bram Moolenaar <Bram@vim.org>
parents:
26486
diff
changeset
|
4259 shell_new_columns(); // update window widths |
06aa56b32df4
patch 8.2.3774: test for command line height fails
Bram Moolenaar <Bram@vim.org>
parents:
26486
diff
changeset
|
4260 curtab->tp_old_Columns = Columns; |
06aa56b32df4
patch 8.2.3774: test for command line height fails
Bram Moolenaar <Bram@vim.org>
parents:
26486
diff
changeset
|
4261 } |
06aa56b32df4
patch 8.2.3774: test for command line height fails
Bram Moolenaar <Bram@vim.org>
parents:
26486
diff
changeset
|
4262 else |
06aa56b32df4
patch 8.2.3774: test for command line height fails
Bram Moolenaar <Bram@vim.org>
parents:
26486
diff
changeset
|
4263 curtab->tp_old_Columns = -1; // update window widths later |
06aa56b32df4
patch 8.2.3774: test for command line height fails
Bram Moolenaar <Bram@vim.org>
parents:
26486
diff
changeset
|
4264 } |
668 | 4265 |
21703
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21020
diff
changeset
|
4266 lastused_tabpage = last_tab; |
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21020
diff
changeset
|
4267 |
668 | 4268 #if defined(FEAT_GUI) |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4269 // When 'guioptions' includes 'L' or 'R' may have to remove or add |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4270 // scrollbars. Have to update them anyway. |
1906 | 4271 gui_may_update_scrollbars(); |
667 | 4272 #endif |
4273 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4274 // Apply autocommands after updating the display, when 'rows' and |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4275 // 'columns' have been set correctly. |
4354 | 4276 if (trigger_enter_autocmds) |
3582 | 4277 { |
4278 apply_autocmds(EVENT_TABENTER, NULL, NULL, FALSE, curbuf); | |
4279 if (old_curbuf != curbuf) | |
4280 apply_autocmds(EVENT_BUFENTER, NULL, NULL, FALSE, curbuf); | |
4281 } | |
3413 | 4282 |
15380
f62d6bd18a49
patch 8.1.0698: clearing the window is used too often
Bram Moolenaar <Bram@vim.org>
parents:
15227
diff
changeset
|
4283 redraw_all_later(NOT_VALID); |
667 | 4284 } |
4285 | |
4286 /* | |
4287 * Go to tab page "n". For ":tab N" and "Ngt". | |
685 | 4288 * When "n" is 9999 go to the last tab page. |
667 | 4289 */ |
4290 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4291 goto_tabpage(int n) |
667 | 4292 { |
16405
840fa633ad64
patch 8.1.1207: some compilers give warning messages
Bram Moolenaar <Bram@vim.org>
parents:
16401
diff
changeset
|
4293 tabpage_T *tp = NULL; // shut up compiler |
682 | 4294 tabpage_T *ttp; |
667 | 4295 int i; |
4296 | |
857 | 4297 if (text_locked()) |
4298 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4299 // 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
|
4300 text_locked_msg(); |
857 | 4301 return; |
4302 } | |
4303 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4304 // If there is only one it can't work. |
675 | 4305 if (first_tabpage->tp_next == NULL) |
4306 { | |
4307 if (n > 1) | |
4308 beep_flush(); | |
4309 return; | |
4310 } | |
4311 | |
667 | 4312 if (n == 0) |
4313 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4314 // No count, go to next tab page, wrap around end. |
674 | 4315 if (curtab->tp_next == NULL) |
667 | 4316 tp = first_tabpage; |
4317 else | |
674 | 4318 tp = curtab->tp_next; |
667 | 4319 } |
682 | 4320 else if (n < 0) |
4321 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4322 // "gT": go to previous tab page, wrap around end. "N gT" repeats |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4323 // this N times. |
682 | 4324 ttp = curtab; |
4325 for (i = n; i < 0; ++i) | |
4326 { | |
4327 for (tp = first_tabpage; tp->tp_next != ttp && tp->tp_next != NULL; | |
4328 tp = tp->tp_next) | |
4329 ; | |
4330 ttp = tp; | |
4331 } | |
4332 } | |
685 | 4333 else if (n == 9999) |
4334 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4335 // Go to last tab page. |
685 | 4336 for (tp = first_tabpage; tp->tp_next != NULL; tp = tp->tp_next) |
4337 ; | |
4338 } | |
667 | 4339 else |
4340 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4341 // Go to tab page "n". |
685 | 4342 tp = find_tabpage(n); |
671 | 4343 if (tp == NULL) |
4344 { | |
4345 beep_flush(); | |
4346 return; | |
4347 } | |
667 | 4348 } |
4349 | |
4354 | 4350 goto_tabpage_tp(tp, TRUE, TRUE); |
685 | 4351 |
4352 #ifdef FEAT_GUI_TABLINE | |
4353 if (gui_use_tabline()) | |
690 | 4354 gui_mch_set_curtab(tabpage_index(curtab)); |
685 | 4355 #endif |
4356 } | |
4357 | |
4358 /* | |
4359 * Go to tabpage "tp". | |
4354 | 4360 * Only trigger *Enter autocommands when trigger_enter_autocmds is TRUE. |
4361 * Only trigger *Leave autocommands when trigger_leave_autocmds is TRUE. | |
685 | 4362 * Note: doesn't update the GUI tab. |
4363 */ | |
4364 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4365 goto_tabpage_tp( |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4366 tabpage_T *tp, |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4367 int trigger_enter_autocmds, |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4368 int trigger_leave_autocmds) |
685 | 4369 { |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4370 // Don't repeat a message in another tab page. |
2201
4c6b4298852f
Other solution for GTK not changing the locale.
Bram Moolenaar <bram@vim.org>
parents:
2115
diff
changeset
|
4371 set_keep_msg(NULL, 0); |
4c6b4298852f
Other solution for GTK not changing the locale.
Bram Moolenaar <bram@vim.org>
parents:
2115
diff
changeset
|
4372 |
4354 | 4373 if (tp != curtab && leave_tabpage(tp->tp_curwin->w_buffer, |
4374 trigger_leave_autocmds) == OK) | |
674 | 4375 { |
4376 if (valid_tabpage(tp)) | |
4354 | 4377 enter_tabpage(tp, curbuf, trigger_enter_autocmds, |
4378 trigger_leave_autocmds); | |
674 | 4379 else |
4354 | 4380 enter_tabpage(curtab, curbuf, trigger_enter_autocmds, |
4381 trigger_leave_autocmds); | |
674 | 4382 } |
667 | 4383 } |
7 | 4384 |
4385 /* | |
21703
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21020
diff
changeset
|
4386 * Go to the last accessed tab page, if there is one. |
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21020
diff
changeset
|
4387 * Return OK or FAIL |
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21020
diff
changeset
|
4388 */ |
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21020
diff
changeset
|
4389 int |
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21020
diff
changeset
|
4390 goto_tabpage_lastused(void) |
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21020
diff
changeset
|
4391 { |
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21020
diff
changeset
|
4392 if (valid_tabpage(lastused_tabpage)) |
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21020
diff
changeset
|
4393 { |
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21020
diff
changeset
|
4394 goto_tabpage_tp(lastused_tabpage, TRUE, TRUE); |
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21020
diff
changeset
|
4395 return OK; |
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21020
diff
changeset
|
4396 } |
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21020
diff
changeset
|
4397 return FAIL; |
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21020
diff
changeset
|
4398 } |
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21020
diff
changeset
|
4399 |
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21020
diff
changeset
|
4400 /* |
825 | 4401 * Enter window "wp" in tab page "tp". |
4402 * Also updates the GUI tab. | |
4403 */ | |
4404 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4405 goto_tabpage_win(tabpage_T *tp, win_T *wp) |
825 | 4406 { |
4354 | 4407 goto_tabpage_tp(tp, TRUE, TRUE); |
825 | 4408 if (curtab == tp && win_valid(wp)) |
4409 { | |
4410 win_enter(wp, TRUE); | |
4411 # ifdef FEAT_GUI_TABLINE | |
4412 if (gui_use_tabline()) | |
4413 gui_mch_set_curtab(tabpage_index(curtab)); | |
4414 # endif | |
4415 } | |
4416 } | |
4417 | |
4418 /* | |
6775 | 4419 * Move the current tab page to after tab page "nr". |
682 | 4420 */ |
4421 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4422 tabpage_move(int nr) |
682 | 4423 { |
6775 | 4424 int n = 1; |
4425 tabpage_T *tp, *tp_dst; | |
682 | 4426 |
4427 if (first_tabpage->tp_next == NULL) | |
4428 return; | |
4429 | |
6775 | 4430 for (tp = first_tabpage; tp->tp_next != NULL && n < nr; tp = tp->tp_next) |
4431 ++n; | |
4432 | |
4433 if (tp == curtab || (nr > 0 && tp->tp_next != NULL | |
4434 && tp->tp_next == curtab)) | |
4435 return; | |
4436 | |
4437 tp_dst = tp; | |
4438 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4439 // Remove the current tab page from the list of tab pages. |
682 | 4440 if (curtab == first_tabpage) |
4441 first_tabpage = curtab->tp_next; | |
4442 else | |
4443 { | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9599
diff
changeset
|
4444 FOR_ALL_TABPAGES(tp) |
682 | 4445 if (tp->tp_next == curtab) |
4446 break; | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4447 if (tp == NULL) // "cannot happen" |
682 | 4448 return; |
4449 tp->tp_next = curtab->tp_next; | |
4450 } | |
4451 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4452 // Re-insert it at the specified position. |
6775 | 4453 if (nr <= 0) |
682 | 4454 { |
4455 curtab->tp_next = first_tabpage; | |
4456 first_tabpage = curtab; | |
4457 } | |
4458 else | |
4459 { | |
6775 | 4460 curtab->tp_next = tp_dst->tp_next; |
4461 tp_dst->tp_next = curtab; | |
682 | 4462 } |
4463 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4464 // Need to redraw the tabline. Tab page contents doesn't change. |
682 | 4465 redraw_tabline = TRUE; |
4466 } | |
4467 | |
4468 | |
4469 /* | |
7 | 4470 * Go to another window. |
4471 * When jumping to another buffer, stop Visual mode. Do this before | |
4472 * changing windows so we can yank the selection into the '*' register. | |
4473 * When jumping to another window on the same buffer, adjust its cursor | |
4474 * position to keep the same Visual area. | |
4475 */ | |
4476 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4477 win_goto(win_T *wp) |
7 | 4478 { |
2316
db0ea641e382
Fix: cursor line not properly concealed when moving between windows.
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
4479 #ifdef FEAT_CONCEAL |
db0ea641e382
Fix: cursor line not properly concealed when moving between windows.
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
4480 win_T *owp = curwin; |
db0ea641e382
Fix: cursor line not properly concealed when moving between windows.
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
4481 #endif |
db0ea641e382
Fix: cursor line not properly concealed when moving between windows.
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
4482 |
19166
215793f6b59d
patch 8.2.0142: possible to enter popup window with CTRL-W p
Bram Moolenaar <Bram@vim.org>
parents:
19155
diff
changeset
|
4483 #ifdef FEAT_PROP_POPUP |
19271
ebeeb4b4a1fa
patch 8.2.0194: some commands can cause problems in terminal popup
Bram Moolenaar <Bram@vim.org>
parents:
19265
diff
changeset
|
4484 if (ERROR_IF_ANY_POPUP_WINDOW) |
16874
da5f5836e90c
patch 8.1.1438: some commands cause trouble in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
16863
diff
changeset
|
4485 return; |
19166
215793f6b59d
patch 8.2.0142: possible to enter popup window with CTRL-W p
Bram Moolenaar <Bram@vim.org>
parents:
19155
diff
changeset
|
4486 if (popup_is_popup(wp)) |
215793f6b59d
patch 8.2.0142: possible to enter popup window with CTRL-W p
Bram Moolenaar <Bram@vim.org>
parents:
19155
diff
changeset
|
4487 { |
215793f6b59d
patch 8.2.0142: possible to enter popup window with CTRL-W p
Bram Moolenaar <Bram@vim.org>
parents:
19155
diff
changeset
|
4488 emsg(_("E366: Not allowed to enter a popup window")); |
215793f6b59d
patch 8.2.0142: possible to enter popup window with CTRL-W p
Bram Moolenaar <Bram@vim.org>
parents:
19155
diff
changeset
|
4489 return; |
215793f6b59d
patch 8.2.0142: possible to enter popup window with CTRL-W p
Bram Moolenaar <Bram@vim.org>
parents:
19155
diff
changeset
|
4490 } |
215793f6b59d
patch 8.2.0142: possible to enter popup window with CTRL-W p
Bram Moolenaar <Bram@vim.org>
parents:
19155
diff
changeset
|
4491 #endif |
20229
06a1dd50463e
patch 8.2.0670: cannot change window when evaluating 'completefunc'
Bram Moolenaar <Bram@vim.org>
parents:
20049
diff
changeset
|
4492 if (text_and_win_locked()) |
7 | 4493 { |
4494 beep_flush(); | |
633 | 4495 text_locked_msg(); |
7 | 4496 return; |
4497 } | |
819 | 4498 if (curbuf_locked()) |
4499 return; | |
631 | 4500 |
7 | 4501 if (wp->w_buffer != curbuf) |
4502 reset_VIsual_and_resel(); | |
4503 else if (VIsual_active) | |
4504 wp->w_cursor = curwin->w_cursor; | |
4505 | |
4506 #ifdef FEAT_GUI | |
4507 need_mouse_correct = TRUE; | |
4508 #endif | |
4509 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
|
4510 |
db0ea641e382
Fix: cursor line not properly concealed when moving between windows.
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
4511 #ifdef FEAT_CONCEAL |
15436
29f3d59bb6f0
patch 8.1.0726: redrawing specifically for conceal feature
Bram Moolenaar <Bram@vim.org>
parents:
15380
diff
changeset
|
4512 // Conceal cursor line in previous window, unconceal in current window. |
4094 | 4513 if (win_valid(owp) && owp->w_p_cole > 0 && !msg_scrolled) |
15436
29f3d59bb6f0
patch 8.1.0726: redrawing specifically for conceal feature
Bram Moolenaar <Bram@vim.org>
parents:
15380
diff
changeset
|
4514 redrawWinline(owp, owp->w_cursor.lnum); |
4094 | 4515 if (curwin->w_p_cole > 0 && !msg_scrolled) |
4516 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
|
4517 #endif |
7 | 4518 } |
4519 | |
25567
0082503ff2ff
patch 8.2.3320: some local functions are not static
Bram Moolenaar <Bram@vim.org>
parents:
25553
diff
changeset
|
4520 #if defined(FEAT_PERL) || defined(PROTO) |
7 | 4521 /* |
4522 * Find window number "winnr" (counting top to bottom). | |
4523 */ | |
4524 win_T * | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4525 win_find_nr(int winnr) |
7 | 4526 { |
4527 win_T *wp; | |
4528 | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9599
diff
changeset
|
4529 FOR_ALL_WINDOWS(wp) |
7 | 4530 if (--winnr == 0) |
4531 break; | |
4532 return wp; | |
4533 } | |
4534 #endif | |
4535 | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
4536 #if ((defined(FEAT_PYTHON) || defined(FEAT_PYTHON3))) || defined(PROTO) |
4429 | 4537 /* |
4538 * Find the tabpage for window "win". | |
4539 */ | |
4540 tabpage_T * | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4541 win_find_tabpage(win_T *win) |
4429 | 4542 { |
4543 win_T *wp; | |
4544 tabpage_T *tp; | |
4545 | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9599
diff
changeset
|
4546 FOR_ALL_TAB_WINDOWS(tp, wp) |
4429 | 4547 if (wp == win) |
4548 return tp; | |
4549 return NULL; | |
4550 } | |
4551 #endif | |
4552 | |
7 | 4553 /* |
16271
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4554 * Get the above or below neighbor window of the specified window. |
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4555 * up - TRUE for the above neighbor |
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4556 * count - nth neighbor window |
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4557 * Returns the specified window if the neighbor is not found. |
7 | 4558 */ |
16271
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4559 win_T * |
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4560 win_vert_neighbor(tabpage_T *tp, win_T *wp, int up, long count) |
7 | 4561 { |
4562 frame_T *fr; | |
4563 frame_T *nfr; | |
4564 frame_T *foundfr; | |
4565 | |
19291
1d6bc6b31c2e
patch 8.2.0204: crash when using winnr('j') in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19275
diff
changeset
|
4566 #ifdef FEAT_PROP_POPUP |
1d6bc6b31c2e
patch 8.2.0204: crash when using winnr('j') in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19275
diff
changeset
|
4567 if (popup_is_popup(wp)) |
1d6bc6b31c2e
patch 8.2.0204: crash when using winnr('j') in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19275
diff
changeset
|
4568 // popups don't have neighbors. |
1d6bc6b31c2e
patch 8.2.0204: crash when using winnr('j') in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19275
diff
changeset
|
4569 return NULL; |
1d6bc6b31c2e
patch 8.2.0204: crash when using winnr('j') in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19275
diff
changeset
|
4570 #endif |
16271
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4571 foundfr = wp->w_frame; |
7 | 4572 while (count--) |
4573 { | |
4574 /* | |
4575 * First go upwards in the tree of frames until we find a upwards or | |
4576 * downwards neighbor. | |
4577 */ | |
4578 fr = foundfr; | |
4579 for (;;) | |
4580 { | |
16271
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4581 if (fr == tp->tp_topframe) |
7 | 4582 goto end; |
4583 if (up) | |
4584 nfr = fr->fr_prev; | |
4585 else | |
4586 nfr = fr->fr_next; | |
4587 if (fr->fr_parent->fr_layout == FR_COL && nfr != NULL) | |
4588 break; | |
4589 fr = fr->fr_parent; | |
4590 } | |
4591 | |
4592 /* | |
4593 * Now go downwards to find the bottom or top frame in it. | |
4594 */ | |
4595 for (;;) | |
4596 { | |
4597 if (nfr->fr_layout == FR_LEAF) | |
4598 { | |
4599 foundfr = nfr; | |
4600 break; | |
4601 } | |
4602 fr = nfr->fr_child; | |
4603 if (nfr->fr_layout == FR_ROW) | |
4604 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4605 // Find the frame at the cursor row. |
7 | 4606 while (fr->fr_next != NULL |
4607 && frame2win(fr)->w_wincol + fr->fr_width | |
16271
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4608 <= wp->w_wincol + wp->w_wcol) |
7 | 4609 fr = fr->fr_next; |
4610 } | |
4611 if (nfr->fr_layout == FR_COL && up) | |
4612 while (fr->fr_next != NULL) | |
4613 fr = fr->fr_next; | |
4614 nfr = fr; | |
4615 } | |
4616 } | |
4617 end: | |
16271
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4618 return foundfr != NULL ? foundfr->fr_win : NULL; |
7 | 4619 } |
4620 | |
4621 /* | |
16271
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4622 * Move to window above or below "count" times. |
7 | 4623 */ |
4624 static void | |
16271
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4625 win_goto_ver( |
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4626 int up, // TRUE to go to win above |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4627 long count) |
7 | 4628 { |
16271
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4629 win_T *win; |
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4630 |
19265
ce8c47ed54e5
patch 8.2.0191: cannot put a terminal in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19166
diff
changeset
|
4631 #ifdef FEAT_PROP_POPUP |
ce8c47ed54e5
patch 8.2.0191: cannot put a terminal in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19166
diff
changeset
|
4632 if (ERROR_IF_TERM_POPUP_WINDOW) |
ce8c47ed54e5
patch 8.2.0191: cannot put a terminal in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19166
diff
changeset
|
4633 return; |
ce8c47ed54e5
patch 8.2.0191: cannot put a terminal in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19166
diff
changeset
|
4634 #endif |
16271
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4635 win = win_vert_neighbor(curtab, curwin, up, count); |
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4636 if (win != NULL) |
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4637 win_goto(win); |
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4638 } |
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4639 |
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4640 /* |
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4641 * Get the left or right neighbor window of the specified window. |
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4642 * left - TRUE for the left neighbor |
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4643 * count - nth neighbor window |
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4644 * Returns the specified window if the neighbor is not found. |
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4645 */ |
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4646 win_T * |
16354
b3bc3ba07bef
patch 8.1.1182: some function prototypes are outdated
Bram Moolenaar <Bram@vim.org>
parents:
16271
diff
changeset
|
4647 win_horz_neighbor(tabpage_T *tp, win_T *wp, int left, long count) |
16271
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4648 { |
7 | 4649 frame_T *fr; |
4650 frame_T *nfr; | |
4651 frame_T *foundfr; | |
4652 | |
19291
1d6bc6b31c2e
patch 8.2.0204: crash when using winnr('j') in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19275
diff
changeset
|
4653 #ifdef FEAT_PROP_POPUP |
1d6bc6b31c2e
patch 8.2.0204: crash when using winnr('j') in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19275
diff
changeset
|
4654 if (popup_is_popup(wp)) |
1d6bc6b31c2e
patch 8.2.0204: crash when using winnr('j') in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19275
diff
changeset
|
4655 // popups don't have neighbors. |
1d6bc6b31c2e
patch 8.2.0204: crash when using winnr('j') in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19275
diff
changeset
|
4656 return NULL; |
1d6bc6b31c2e
patch 8.2.0204: crash when using winnr('j') in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19275
diff
changeset
|
4657 #endif |
16271
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4658 foundfr = wp->w_frame; |
7 | 4659 while (count--) |
4660 { | |
4661 /* | |
4662 * First go upwards in the tree of frames until we find a left or | |
4663 * right neighbor. | |
4664 */ | |
4665 fr = foundfr; | |
4666 for (;;) | |
4667 { | |
16271
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4668 if (fr == tp->tp_topframe) |
7 | 4669 goto end; |
4670 if (left) | |
4671 nfr = fr->fr_prev; | |
4672 else | |
4673 nfr = fr->fr_next; | |
4674 if (fr->fr_parent->fr_layout == FR_ROW && nfr != NULL) | |
4675 break; | |
4676 fr = fr->fr_parent; | |
4677 } | |
4678 | |
4679 /* | |
4680 * Now go downwards to find the leftmost or rightmost frame in it. | |
4681 */ | |
4682 for (;;) | |
4683 { | |
4684 if (nfr->fr_layout == FR_LEAF) | |
4685 { | |
4686 foundfr = nfr; | |
4687 break; | |
4688 } | |
4689 fr = nfr->fr_child; | |
4690 if (nfr->fr_layout == FR_COL) | |
4691 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4692 // Find the frame at the cursor row. |
7 | 4693 while (fr->fr_next != NULL |
4694 && frame2win(fr)->w_winrow + fr->fr_height | |
16271
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4695 <= wp->w_winrow + wp->w_wrow) |
7 | 4696 fr = fr->fr_next; |
4697 } | |
4698 if (nfr->fr_layout == FR_ROW && left) | |
4699 while (fr->fr_next != NULL) | |
4700 fr = fr->fr_next; | |
4701 nfr = fr; | |
4702 } | |
4703 } | |
4704 end: | |
16271
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4705 return foundfr != NULL ? foundfr->fr_win : NULL; |
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4706 } |
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4707 |
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4708 /* |
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4709 * Move to left or right window. |
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4710 */ |
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4711 static void |
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4712 win_goto_hor( |
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4713 int left, // TRUE to go to left win |
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4714 long count) |
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4715 { |
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4716 win_T *win; |
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4717 |
19265
ce8c47ed54e5
patch 8.2.0191: cannot put a terminal in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19166
diff
changeset
|
4718 #ifdef FEAT_PROP_POPUP |
ce8c47ed54e5
patch 8.2.0191: cannot put a terminal in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19166
diff
changeset
|
4719 if (ERROR_IF_TERM_POPUP_WINDOW) |
ce8c47ed54e5
patch 8.2.0191: cannot put a terminal in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19166
diff
changeset
|
4720 return; |
ce8c47ed54e5
patch 8.2.0191: cannot put a terminal in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19166
diff
changeset
|
4721 #endif |
16271
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4722 win = win_horz_neighbor(curtab, curwin, left, count); |
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4723 if (win != NULL) |
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
4724 win_goto(win); |
7 | 4725 } |
4726 | |
4727 /* | |
4728 * Make window "wp" the current window. | |
4729 */ | |
4730 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4731 win_enter(win_T *wp, int undo_sync) |
7 | 4732 { |
25501
a1ed55c02e80
patch 8.2.3287: channel events not handled in BufEnter autocommand
Bram Moolenaar <Bram@vim.org>
parents:
25499
diff
changeset
|
4733 (void)win_enter_ext(wp, (undo_sync ? WEE_UNDO_SYNC : 0) |
25499
5ebf9bb1cbcd
patch 8.2.3286: win_enter_ext() has too many boolean arguments
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
4734 | WEE_TRIGGER_ENTER_AUTOCMDS | WEE_TRIGGER_LEAVE_AUTOCMDS); |
7 | 4735 } |
4736 | |
4737 /* | |
25499
5ebf9bb1cbcd
patch 8.2.3286: win_enter_ext() has too many boolean arguments
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
4738 * Make window "wp" the current window. |
5ebf9bb1cbcd
patch 8.2.3286: win_enter_ext() has too many boolean arguments
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
4739 * Can be called with "flags" containing WEE_CURWIN_INVALID, which means that |
5ebf9bb1cbcd
patch 8.2.3286: win_enter_ext() has too many boolean arguments
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
4740 * curwin has just been closed and isn't valid. |
25501
a1ed55c02e80
patch 8.2.3287: channel events not handled in BufEnter autocommand
Bram Moolenaar <Bram@vim.org>
parents:
25499
diff
changeset
|
4741 * Returns TRUE when dont_parse_messages was decremented. |
7 | 4742 */ |
25501
a1ed55c02e80
patch 8.2.3287: channel events not handled in BufEnter autocommand
Bram Moolenaar <Bram@vim.org>
parents:
25499
diff
changeset
|
4743 static int |
25499
5ebf9bb1cbcd
patch 8.2.3286: win_enter_ext() has too many boolean arguments
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
4744 win_enter_ext(win_T *wp, int flags) |
7 | 4745 { |
4746 int other_buffer = FALSE; | |
25499
5ebf9bb1cbcd
patch 8.2.3286: win_enter_ext() has too many boolean arguments
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
4747 int curwin_invalid = (flags & WEE_CURWIN_INVALID); |
25501
a1ed55c02e80
patch 8.2.3287: channel events not handled in BufEnter autocommand
Bram Moolenaar <Bram@vim.org>
parents:
25499
diff
changeset
|
4748 int did_decrement = FALSE; |
7 | 4749 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4750 if (wp == curwin && !curwin_invalid) // nothing to do |
25501
a1ed55c02e80
patch 8.2.3287: channel events not handled in BufEnter autocommand
Bram Moolenaar <Bram@vim.org>
parents:
25499
diff
changeset
|
4751 return FALSE; |
7 | 4752 |
14035
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
4753 #ifdef FEAT_JOB_CHANNEL |
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
4754 if (!curwin_invalid) |
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
4755 leaving_window(curwin); |
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
4756 #endif |
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
4757 |
25499
5ebf9bb1cbcd
patch 8.2.3286: win_enter_ext() has too many boolean arguments
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
4758 if (!curwin_invalid && (flags & WEE_TRIGGER_LEAVE_AUTOCMDS)) |
7 | 4759 { |
4760 /* | |
4761 * Be careful: If autocommands delete the window, return now. | |
4762 */ | |
4763 if (wp->w_buffer != curbuf) | |
4764 { | |
4765 apply_autocmds(EVENT_BUFLEAVE, NULL, NULL, FALSE, curbuf); | |
4766 other_buffer = TRUE; | |
4767 if (!win_valid(wp)) | |
25501
a1ed55c02e80
patch 8.2.3287: channel events not handled in BufEnter autocommand
Bram Moolenaar <Bram@vim.org>
parents:
25499
diff
changeset
|
4768 return FALSE; |
7 | 4769 } |
4770 apply_autocmds(EVENT_WINLEAVE, NULL, NULL, FALSE, curbuf); | |
4771 if (!win_valid(wp)) | |
25501
a1ed55c02e80
patch 8.2.3287: channel events not handled in BufEnter autocommand
Bram Moolenaar <Bram@vim.org>
parents:
25499
diff
changeset
|
4772 return FALSE; |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13308
diff
changeset
|
4773 #ifdef FEAT_EVAL |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4774 // autocmds may abort script processing |
7 | 4775 if (aborting()) |
25501
a1ed55c02e80
patch 8.2.3287: channel events not handled in BufEnter autocommand
Bram Moolenaar <Bram@vim.org>
parents:
25499
diff
changeset
|
4776 return FALSE; |
7 | 4777 #endif |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13308
diff
changeset
|
4778 } |
7 | 4779 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4780 // sync undo before leaving the current buffer |
25499
5ebf9bb1cbcd
patch 8.2.3286: win_enter_ext() has too many boolean arguments
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
4781 if ((flags & WEE_UNDO_SYNC) && curbuf != wp->w_buffer) |
825 | 4782 u_sync(FALSE); |
5977 | 4783 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4784 // Might need to scroll the old window before switching, e.g., when the |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4785 // cursor was moved. |
5977 | 4786 update_topline(); |
4787 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4788 // may have to copy the buffer options when 'cpo' contains 'S' |
7 | 4789 if (wp->w_buffer != curbuf) |
4790 buf_copy_options(wp->w_buffer, BCO_ENTER | BCO_NOHELP); | |
4791 if (!curwin_invalid) | |
4792 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4793 prevwin = curwin; // remember for CTRL-W p |
7 | 4794 curwin->w_redr_status = TRUE; |
4795 } | |
4796 curwin = wp; | |
4797 curbuf = wp->w_buffer; | |
4798 check_cursor(); | |
4799 if (!virtual_active()) | |
4800 curwin->w_cursor.coladd = 0; | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4801 changed_line_abv_curs(); // assume cursor position needs updating |
7 | 4802 |
25501
a1ed55c02e80
patch 8.2.3287: channel events not handled in BufEnter autocommand
Bram Moolenaar <Bram@vim.org>
parents:
25499
diff
changeset
|
4803 // Now it is OK to parse messages again, which may be needed in |
a1ed55c02e80
patch 8.2.3287: channel events not handled in BufEnter autocommand
Bram Moolenaar <Bram@vim.org>
parents:
25499
diff
changeset
|
4804 // autocommands. |
a1ed55c02e80
patch 8.2.3287: channel events not handled in BufEnter autocommand
Bram Moolenaar <Bram@vim.org>
parents:
25499
diff
changeset
|
4805 #ifdef MESSAGE_QUEUE |
a1ed55c02e80
patch 8.2.3287: channel events not handled in BufEnter autocommand
Bram Moolenaar <Bram@vim.org>
parents:
25499
diff
changeset
|
4806 if (flags & WEE_ALLOW_PARSE_MESSAGES) |
a1ed55c02e80
patch 8.2.3287: channel events not handled in BufEnter autocommand
Bram Moolenaar <Bram@vim.org>
parents:
25499
diff
changeset
|
4807 { |
a1ed55c02e80
patch 8.2.3287: channel events not handled in BufEnter autocommand
Bram Moolenaar <Bram@vim.org>
parents:
25499
diff
changeset
|
4808 --dont_parse_messages; |
a1ed55c02e80
patch 8.2.3287: channel events not handled in BufEnter autocommand
Bram Moolenaar <Bram@vim.org>
parents:
25499
diff
changeset
|
4809 did_decrement = TRUE; |
a1ed55c02e80
patch 8.2.3287: channel events not handled in BufEnter autocommand
Bram Moolenaar <Bram@vim.org>
parents:
25499
diff
changeset
|
4810 } |
a1ed55c02e80
patch 8.2.3287: channel events not handled in BufEnter autocommand
Bram Moolenaar <Bram@vim.org>
parents:
25499
diff
changeset
|
4811 #endif |
a1ed55c02e80
patch 8.2.3287: channel events not handled in BufEnter autocommand
Bram Moolenaar <Bram@vim.org>
parents:
25499
diff
changeset
|
4812 |
26121
2c64a420ce7e
patch 8.2.3593: directory is wrong after executing "lcd" with win_execute()
Bram Moolenaar <Bram@vim.org>
parents:
26117
diff
changeset
|
4813 fix_current_dir(); |
7 | 4814 |
14035
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
4815 #ifdef FEAT_JOB_CHANNEL |
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
4816 entering_window(curwin); |
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
4817 #endif |
18283
0cb608fc9c60
patch 8.1.2136: using freed memory with autocmd from fuzzer
Bram Moolenaar <Bram@vim.org>
parents:
18255
diff
changeset
|
4818 // Careful: autocommands may close the window and make "wp" invalid |
25499
5ebf9bb1cbcd
patch 8.2.3286: win_enter_ext() has too many boolean arguments
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
4819 if (flags & WEE_TRIGGER_NEW_AUTOCMDS) |
9595
0190d5de215f
commit https://github.com/vim/vim/commit/c917da4b3e8801a255dbefea8e4ed19c1c716dd8
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
4820 apply_autocmds(EVENT_WINNEW, NULL, NULL, FALSE, curbuf); |
25499
5ebf9bb1cbcd
patch 8.2.3286: win_enter_ext() has too many boolean arguments
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
4821 if (flags & WEE_TRIGGER_ENTER_AUTOCMDS) |
4354 | 4822 { |
4823 apply_autocmds(EVENT_WINENTER, NULL, NULL, FALSE, curbuf); | |
4824 if (other_buffer) | |
4825 apply_autocmds(EVENT_BUFENTER, NULL, NULL, FALSE, curbuf); | |
4826 } | |
7 | 4827 |
4828 maketitle(); | |
4829 curwin->w_redr_status = TRUE; | |
18255
3f51e026de28
patch 8.1.2122: cannot build without terminal feature
Bram Moolenaar <Bram@vim.org>
parents:
18253
diff
changeset
|
4830 #ifdef FEAT_TERMINAL |
18283
0cb608fc9c60
patch 8.1.2136: using freed memory with autocmd from fuzzer
Bram Moolenaar <Bram@vim.org>
parents:
18255
diff
changeset
|
4831 if (bt_terminal(curwin->w_buffer)) |
18253
783f796a1426
patch 8.1.2121: mode is not updated when switching to terminal
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
4832 // terminal is likely in another mode |
783f796a1426
patch 8.1.2121: mode is not updated when switching to terminal
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
4833 redraw_mode = TRUE; |
18255
3f51e026de28
patch 8.1.2122: cannot build without terminal feature
Bram Moolenaar <Bram@vim.org>
parents:
18253
diff
changeset
|
4834 #endif |
672 | 4835 redraw_tabline = TRUE; |
7 | 4836 if (restart_edit) |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4837 redraw_later(VALID); // causes status line redraw |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4838 |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4839 // set window height to desired minimal value |
17472
dfd87ef822aa
patch 8.1.1734: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17225
diff
changeset
|
4840 if (curwin->w_height < p_wh && !curwin->w_p_wfh |
18763
49b78d6465e5
patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents:
18590
diff
changeset
|
4841 #ifdef FEAT_PROP_POPUP |
17472
dfd87ef822aa
patch 8.1.1734: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17225
diff
changeset
|
4842 && !popup_is_popup(curwin) |
dfd87ef822aa
patch 8.1.1734: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17225
diff
changeset
|
4843 #endif |
dfd87ef822aa
patch 8.1.1734: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17225
diff
changeset
|
4844 ) |
7 | 4845 win_setheight((int)p_wh); |
4846 else if (curwin->w_height == 0) | |
4847 win_setheight(1); | |
4848 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4849 // set window width to desired minimal value |
779 | 4850 if (curwin->w_width < p_wiw && !curwin->w_p_wfw) |
7 | 4851 win_setwidth((int)p_wiw); |
4852 | |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18010
diff
changeset
|
4853 setmouse(); // in case jumped to/from help buffer |
7 | 4854 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4855 // 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
|
4856 DO_AUTOCHDIR; |
25501
a1ed55c02e80
patch 8.2.3287: channel events not handled in BufEnter autocommand
Bram Moolenaar <Bram@vim.org>
parents:
25499
diff
changeset
|
4857 |
a1ed55c02e80
patch 8.2.3287: channel events not handled in BufEnter autocommand
Bram Moolenaar <Bram@vim.org>
parents:
25499
diff
changeset
|
4858 return did_decrement; |
7 | 4859 } |
4860 | |
26121
2c64a420ce7e
patch 8.2.3593: directory is wrong after executing "lcd" with win_execute()
Bram Moolenaar <Bram@vim.org>
parents:
26117
diff
changeset
|
4861 /* |
2c64a420ce7e
patch 8.2.3593: directory is wrong after executing "lcd" with win_execute()
Bram Moolenaar <Bram@vim.org>
parents:
26117
diff
changeset
|
4862 * Used after making another window the current one: change directory if |
2c64a420ce7e
patch 8.2.3593: directory is wrong after executing "lcd" with win_execute()
Bram Moolenaar <Bram@vim.org>
parents:
26117
diff
changeset
|
4863 * needed. |
2c64a420ce7e
patch 8.2.3593: directory is wrong after executing "lcd" with win_execute()
Bram Moolenaar <Bram@vim.org>
parents:
26117
diff
changeset
|
4864 */ |
2c64a420ce7e
patch 8.2.3593: directory is wrong after executing "lcd" with win_execute()
Bram Moolenaar <Bram@vim.org>
parents:
26117
diff
changeset
|
4865 void |
2c64a420ce7e
patch 8.2.3593: directory is wrong after executing "lcd" with win_execute()
Bram Moolenaar <Bram@vim.org>
parents:
26117
diff
changeset
|
4866 fix_current_dir(void) |
2c64a420ce7e
patch 8.2.3593: directory is wrong after executing "lcd" with win_execute()
Bram Moolenaar <Bram@vim.org>
parents:
26117
diff
changeset
|
4867 { |
26416
7606d9b13068
patch 8.2.3739: in wrong directory when using win_execute() with 'acd' set
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
4868 #ifdef FEAT_AUTOCHDIR |
7606d9b13068
patch 8.2.3739: in wrong directory when using win_execute() with 'acd' set
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
4869 if (p_acd) |
7606d9b13068
patch 8.2.3739: in wrong directory when using win_execute() with 'acd' set
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
4870 do_autochdir(); |
7606d9b13068
patch 8.2.3739: in wrong directory when using win_execute() with 'acd' set
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
4871 else |
7606d9b13068
patch 8.2.3739: in wrong directory when using win_execute() with 'acd' set
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
4872 #endif |
26121
2c64a420ce7e
patch 8.2.3593: directory is wrong after executing "lcd" with win_execute()
Bram Moolenaar <Bram@vim.org>
parents:
26117
diff
changeset
|
4873 if (curwin->w_localdir != NULL || curtab->tp_localdir != NULL) |
2c64a420ce7e
patch 8.2.3593: directory is wrong after executing "lcd" with win_execute()
Bram Moolenaar <Bram@vim.org>
parents:
26117
diff
changeset
|
4874 { |
2c64a420ce7e
patch 8.2.3593: directory is wrong after executing "lcd" with win_execute()
Bram Moolenaar <Bram@vim.org>
parents:
26117
diff
changeset
|
4875 char_u *dirname; |
2c64a420ce7e
patch 8.2.3593: directory is wrong after executing "lcd" with win_execute()
Bram Moolenaar <Bram@vim.org>
parents:
26117
diff
changeset
|
4876 |
2c64a420ce7e
patch 8.2.3593: directory is wrong after executing "lcd" with win_execute()
Bram Moolenaar <Bram@vim.org>
parents:
26117
diff
changeset
|
4877 // Window or tab has a local directory: Save current directory as |
2c64a420ce7e
patch 8.2.3593: directory is wrong after executing "lcd" with win_execute()
Bram Moolenaar <Bram@vim.org>
parents:
26117
diff
changeset
|
4878 // global directory (unless that was done already) and change to the |
2c64a420ce7e
patch 8.2.3593: directory is wrong after executing "lcd" with win_execute()
Bram Moolenaar <Bram@vim.org>
parents:
26117
diff
changeset
|
4879 // local directory. |
2c64a420ce7e
patch 8.2.3593: directory is wrong after executing "lcd" with win_execute()
Bram Moolenaar <Bram@vim.org>
parents:
26117
diff
changeset
|
4880 if (globaldir == NULL) |
2c64a420ce7e
patch 8.2.3593: directory is wrong after executing "lcd" with win_execute()
Bram Moolenaar <Bram@vim.org>
parents:
26117
diff
changeset
|
4881 { |
2c64a420ce7e
patch 8.2.3593: directory is wrong after executing "lcd" with win_execute()
Bram Moolenaar <Bram@vim.org>
parents:
26117
diff
changeset
|
4882 char_u cwd[MAXPATHL]; |
2c64a420ce7e
patch 8.2.3593: directory is wrong after executing "lcd" with win_execute()
Bram Moolenaar <Bram@vim.org>
parents:
26117
diff
changeset
|
4883 |
2c64a420ce7e
patch 8.2.3593: directory is wrong after executing "lcd" with win_execute()
Bram Moolenaar <Bram@vim.org>
parents:
26117
diff
changeset
|
4884 if (mch_dirname(cwd, MAXPATHL) == OK) |
2c64a420ce7e
patch 8.2.3593: directory is wrong after executing "lcd" with win_execute()
Bram Moolenaar <Bram@vim.org>
parents:
26117
diff
changeset
|
4885 globaldir = vim_strsave(cwd); |
2c64a420ce7e
patch 8.2.3593: directory is wrong after executing "lcd" with win_execute()
Bram Moolenaar <Bram@vim.org>
parents:
26117
diff
changeset
|
4886 } |
2c64a420ce7e
patch 8.2.3593: directory is wrong after executing "lcd" with win_execute()
Bram Moolenaar <Bram@vim.org>
parents:
26117
diff
changeset
|
4887 if (curwin->w_localdir != NULL) |
2c64a420ce7e
patch 8.2.3593: directory is wrong after executing "lcd" with win_execute()
Bram Moolenaar <Bram@vim.org>
parents:
26117
diff
changeset
|
4888 dirname = curwin->w_localdir; |
2c64a420ce7e
patch 8.2.3593: directory is wrong after executing "lcd" with win_execute()
Bram Moolenaar <Bram@vim.org>
parents:
26117
diff
changeset
|
4889 else |
2c64a420ce7e
patch 8.2.3593: directory is wrong after executing "lcd" with win_execute()
Bram Moolenaar <Bram@vim.org>
parents:
26117
diff
changeset
|
4890 dirname = curtab->tp_localdir; |
2c64a420ce7e
patch 8.2.3593: directory is wrong after executing "lcd" with win_execute()
Bram Moolenaar <Bram@vim.org>
parents:
26117
diff
changeset
|
4891 |
2c64a420ce7e
patch 8.2.3593: directory is wrong after executing "lcd" with win_execute()
Bram Moolenaar <Bram@vim.org>
parents:
26117
diff
changeset
|
4892 if (mch_chdir((char *)dirname) == 0) |
26171
fa8161b003f6
patch 8.2.3617: ":verbose pwd" does not mention 'autochdir' was applied
Bram Moolenaar <Bram@vim.org>
parents:
26121
diff
changeset
|
4893 { |
fa8161b003f6
patch 8.2.3617: ":verbose pwd" does not mention 'autochdir' was applied
Bram Moolenaar <Bram@vim.org>
parents:
26121
diff
changeset
|
4894 last_chdir_reason = NULL; |
26121
2c64a420ce7e
patch 8.2.3593: directory is wrong after executing "lcd" with win_execute()
Bram Moolenaar <Bram@vim.org>
parents:
26117
diff
changeset
|
4895 shorten_fnames(TRUE); |
26171
fa8161b003f6
patch 8.2.3617: ":verbose pwd" does not mention 'autochdir' was applied
Bram Moolenaar <Bram@vim.org>
parents:
26121
diff
changeset
|
4896 } |
26121
2c64a420ce7e
patch 8.2.3593: directory is wrong after executing "lcd" with win_execute()
Bram Moolenaar <Bram@vim.org>
parents:
26117
diff
changeset
|
4897 } |
2c64a420ce7e
patch 8.2.3593: directory is wrong after executing "lcd" with win_execute()
Bram Moolenaar <Bram@vim.org>
parents:
26117
diff
changeset
|
4898 else if (globaldir != NULL) |
2c64a420ce7e
patch 8.2.3593: directory is wrong after executing "lcd" with win_execute()
Bram Moolenaar <Bram@vim.org>
parents:
26117
diff
changeset
|
4899 { |
2c64a420ce7e
patch 8.2.3593: directory is wrong after executing "lcd" with win_execute()
Bram Moolenaar <Bram@vim.org>
parents:
26117
diff
changeset
|
4900 // Window doesn't have a local directory and we are not in the global |
2c64a420ce7e
patch 8.2.3593: directory is wrong after executing "lcd" with win_execute()
Bram Moolenaar <Bram@vim.org>
parents:
26117
diff
changeset
|
4901 // directory: Change to the global directory. |
2c64a420ce7e
patch 8.2.3593: directory is wrong after executing "lcd" with win_execute()
Bram Moolenaar <Bram@vim.org>
parents:
26117
diff
changeset
|
4902 vim_ignored = mch_chdir((char *)globaldir); |
2c64a420ce7e
patch 8.2.3593: directory is wrong after executing "lcd" with win_execute()
Bram Moolenaar <Bram@vim.org>
parents:
26117
diff
changeset
|
4903 VIM_CLEAR(globaldir); |
26171
fa8161b003f6
patch 8.2.3617: ":verbose pwd" does not mention 'autochdir' was applied
Bram Moolenaar <Bram@vim.org>
parents:
26121
diff
changeset
|
4904 last_chdir_reason = NULL; |
26121
2c64a420ce7e
patch 8.2.3593: directory is wrong after executing "lcd" with win_execute()
Bram Moolenaar <Bram@vim.org>
parents:
26117
diff
changeset
|
4905 shorten_fnames(TRUE); |
2c64a420ce7e
patch 8.2.3593: directory is wrong after executing "lcd" with win_execute()
Bram Moolenaar <Bram@vim.org>
parents:
26117
diff
changeset
|
4906 } |
2c64a420ce7e
patch 8.2.3593: directory is wrong after executing "lcd" with win_execute()
Bram Moolenaar <Bram@vim.org>
parents:
26117
diff
changeset
|
4907 } |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
4908 |
7 | 4909 /* |
825 | 4910 * Jump to the first open window that contains buffer "buf", if one exists. |
4911 * Returns a pointer to the window found, otherwise NULL. | |
7 | 4912 */ |
4913 win_T * | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4914 buf_jump_open_win(buf_T *buf) |
7 | 4915 { |
6307 | 4916 win_T *wp = NULL; |
4917 | |
4918 if (curwin->w_buffer == buf) | |
4919 wp = curwin; | |
4920 else | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9599
diff
changeset
|
4921 FOR_ALL_WINDOWS(wp) |
6307 | 4922 if (wp->w_buffer == buf) |
4923 break; | |
7 | 4924 if (wp != NULL) |
4925 win_enter(wp, FALSE); | |
4926 return wp; | |
4927 } | |
825 | 4928 |
4929 /* | |
4930 * Jump to the first open window in any tab page that contains buffer "buf", | |
4931 * if one exists. | |
4932 * Returns a pointer to the window found, otherwise NULL. | |
4933 */ | |
4934 win_T * | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4935 buf_jump_open_tab(buf_T *buf) |
825 | 4936 { |
6307 | 4937 win_T *wp = buf_jump_open_win(buf); |
825 | 4938 tabpage_T *tp; |
4939 | |
4940 if (wp != NULL) | |
4941 return wp; | |
4942 | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9599
diff
changeset
|
4943 FOR_ALL_TABPAGES(tp) |
825 | 4944 if (tp != curtab) |
4945 { | |
19888
435726a03481
patch 8.2.0500: using the same loop in many places
Bram Moolenaar <Bram@vim.org>
parents:
19291
diff
changeset
|
4946 FOR_ALL_WINDOWS_IN_TAB(tp, wp) |
825 | 4947 if (wp->w_buffer == buf) |
4948 break; | |
4949 if (wp != NULL) | |
4950 { | |
4951 goto_tabpage_win(tp, wp); | |
4952 if (curwin != wp) | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4953 wp = NULL; // something went wrong |
825 | 4954 break; |
4955 } | |
4956 } | |
4957 return wp; | |
4958 } | |
7 | 4959 |
9223
6c4d610fce0a
commit https://github.com/vim/vim/commit/888ccac8902cee186fbd47e971881f6d9b19c068
Christian Brabandt <cb@256bit.org>
parents:
9102
diff
changeset
|
4960 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
|
4961 |
7 | 4962 /* |
1906 | 4963 * Allocate a window structure and link it in the window list when "hidden" is |
4964 * FALSE. | |
7 | 4965 */ |
4966 static win_T * | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4967 win_alloc(win_T *after UNUSED, int hidden UNUSED) |
7 | 4968 { |
3263 | 4969 win_T *new_wp; |
7 | 4970 |
4971 /* | |
4972 * allocate window structure and linesizes arrays | |
4973 */ | |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16802
diff
changeset
|
4974 new_wp = ALLOC_CLEAR_ONE(win_T); |
4287 | 4975 if (new_wp == NULL) |
4976 return NULL; | |
4977 | |
4978 if (win_alloc_lines(new_wp) == FAIL) | |
3263 | 4979 { |
4980 vim_free(new_wp); | |
4287 | 4981 return NULL; |
4982 } | |
4983 | |
8534
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
4984 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
|
4985 |
4287 | 4986 #ifdef FEAT_EVAL |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4987 // init w: variables |
4287 | 4988 new_wp->w_vars = dict_alloc(); |
4989 if (new_wp->w_vars == NULL) | |
4990 { | |
4991 win_free_lsize(new_wp); | |
4992 vim_free(new_wp); | |
4993 return NULL; | |
4994 } | |
4995 init_var_dict(new_wp->w_vars, &new_wp->w_winvar, VAR_SCOPE); | |
4996 #endif | |
4997 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4998 // Don't execute autocommands while the window is not properly |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4999 // initialized yet. gui_create_scrollbar() may trigger a FocusGained |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5000 // event. |
4287 | 5001 block_autocmds(); |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13308
diff
changeset
|
5002 |
4287 | 5003 /* |
5004 * link the window in the window list | |
5005 */ | |
5006 if (!hidden) | |
5007 win_append(after, new_wp); | |
5008 new_wp->w_wincol = 0; | |
5009 new_wp->w_width = Columns; | |
5010 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5011 // position the display and the cursor at the top of the file. |
4287 | 5012 new_wp->w_topline = 1; |
7 | 5013 #ifdef FEAT_DIFF |
4287 | 5014 new_wp->w_topfill = 0; |
5015 #endif | |
5016 new_wp->w_botline = 2; | |
5017 new_wp->w_cursor.lnum = 1; | |
5018 new_wp->w_scbind_pos = 1; | |
5019 | |
15713
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15636
diff
changeset
|
5020 // use global option value for global-local options |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15636
diff
changeset
|
5021 new_wp->w_p_so = -1; |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15636
diff
changeset
|
5022 new_wp->w_p_siso = -1; |
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15636
diff
changeset
|
5023 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5024 // We won't calculate w_fraction until resizing the window |
4287 | 5025 new_wp->w_fraction = 0; |
5026 new_wp->w_prev_fraction_row = -1; | |
7 | 5027 |
5028 #ifdef FEAT_GUI | |
4287 | 5029 if (gui.in_use) |
5030 { | |
5031 gui_create_scrollbar(&new_wp->w_scrollbars[SBAR_LEFT], | |
5032 SBAR_LEFT, new_wp); | |
5033 gui_create_scrollbar(&new_wp->w_scrollbars[SBAR_RIGHT], | |
5034 SBAR_RIGHT, new_wp); | |
5035 } | |
7 | 5036 #endif |
5037 #ifdef FEAT_FOLDING | |
4287 | 5038 foldInitWin(new_wp); |
7 | 5039 #endif |
4287 | 5040 unblock_autocmds(); |
1326 | 5041 #ifdef FEAT_SEARCH_EXTRA |
4287 | 5042 new_wp->w_match_head = NULL; |
5043 new_wp->w_next_match_id = 4; | |
5044 #endif | |
3263 | 5045 return new_wp; |
7 | 5046 } |
5047 | |
5048 /* | |
5237
647596ab1ae2
updated for version 7.4a.044
Bram Moolenaar <bram@vim.org>
parents:
5233
diff
changeset
|
5049 * Remove window 'wp' from the window list and free the structure. |
7 | 5050 */ |
5051 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5052 win_free( |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5053 win_T *wp, |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5054 tabpage_T *tp) // tab page "win" is in, NULL for current |
7 | 5055 { |
5056 int i; | |
5237
647596ab1ae2
updated for version 7.4a.044
Bram Moolenaar <bram@vim.org>
parents:
5233
diff
changeset
|
5057 buf_T *buf; |
647596ab1ae2
updated for version 7.4a.044
Bram Moolenaar <bram@vim.org>
parents:
5233
diff
changeset
|
5058 wininfo_T *wip; |
7 | 5059 |
1918 | 5060 #ifdef FEAT_FOLDING |
5061 clearFolding(wp); | |
5062 #endif | |
5063 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5064 // reduce the reference count to the argument list. |
1918 | 5065 alist_unlink(wp->w_alist); |
5066 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5067 // Don't execute autocommands while the window is halfway being deleted. |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5068 // gui_mch_destroy_scrollbar() may trigger a FocusGained event. |
1410 | 5069 block_autocmds(); |
1114 | 5070 |
2320
966a5609669e
Added Lua interfae. (Luis Carvalho)
Bram Moolenaar <bram@vim.org>
parents:
2316
diff
changeset
|
5071 #ifdef FEAT_LUA |
966a5609669e
Added Lua interfae. (Luis Carvalho)
Bram Moolenaar <bram@vim.org>
parents:
2316
diff
changeset
|
5072 lua_window_free(wp); |
966a5609669e
Added Lua interfae. (Luis Carvalho)
Bram Moolenaar <bram@vim.org>
parents:
2316
diff
changeset
|
5073 #endif |
966a5609669e
Added Lua interfae. (Luis Carvalho)
Bram Moolenaar <bram@vim.org>
parents:
2316
diff
changeset
|
5074 |
14 | 5075 #ifdef FEAT_MZSCHEME |
5076 mzscheme_window_free(wp); | |
5077 #endif | |
5078 | |
7 | 5079 #ifdef FEAT_PERL |
5080 perl_win_free(wp); | |
5081 #endif | |
5082 | |
5083 #ifdef FEAT_PYTHON | |
5084 python_window_free(wp); | |
5085 #endif | |
5086 | |
2329
ad2889f48843
Added support for Python 3. (Roland Puntaier)
Bram Moolenaar <bram@vim.org>
parents:
2320
diff
changeset
|
5087 #ifdef FEAT_PYTHON3 |
ad2889f48843
Added support for Python 3. (Roland Puntaier)
Bram Moolenaar <bram@vim.org>
parents:
2320
diff
changeset
|
5088 python3_window_free(wp); |
ad2889f48843
Added support for Python 3. (Roland Puntaier)
Bram Moolenaar <bram@vim.org>
parents:
2320
diff
changeset
|
5089 #endif |
ad2889f48843
Added support for Python 3. (Roland Puntaier)
Bram Moolenaar <bram@vim.org>
parents:
2320
diff
changeset
|
5090 |
7 | 5091 #ifdef FEAT_TCL |
5092 tcl_window_free(wp); | |
5093 #endif | |
5094 | |
5095 #ifdef FEAT_RUBY | |
5096 ruby_window_free(wp); | |
5097 #endif | |
5098 | |
5099 clear_winopt(&wp->w_onebuf_opt); | |
5100 clear_winopt(&wp->w_allbuf_opt); | |
5101 | |
26077
ad90d7eee236
patch 8.2.3572: memory leak when closing window and using "multispace"
Bram Moolenaar <Bram@vim.org>
parents:
25567
diff
changeset
|
5102 vim_free(wp->w_lcs_chars.multispace); |
ad90d7eee236
patch 8.2.3572: memory leak when closing window and using "multispace"
Bram Moolenaar <Bram@vim.org>
parents:
25567
diff
changeset
|
5103 |
7 | 5104 #ifdef FEAT_EVAL |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5105 vars_clear(&wp->w_vars->dv_hashtab); // free all w: variables |
4287 | 5106 hash_init(&wp->w_vars->dv_hashtab); |
5107 unref_var_dict(wp->w_vars); | |
7 | 5108 #endif |
5109 | |
8833
dc10bd23f918
commit https://github.com/vim/vim/commit/3dda7db4e1f7c4a8110a1f83001ec36b46693d27
Christian Brabandt <cb@256bit.org>
parents:
8804
diff
changeset
|
5110 { |
dc10bd23f918
commit https://github.com/vim/vim/commit/3dda7db4e1f7c4a8110a1f83001ec36b46693d27
Christian Brabandt <cb@256bit.org>
parents:
8804
diff
changeset
|
5111 tabpage_T *ttp; |
dc10bd23f918
commit https://github.com/vim/vim/commit/3dda7db4e1f7c4a8110a1f83001ec36b46693d27
Christian Brabandt <cb@256bit.org>
parents:
8804
diff
changeset
|
5112 |
dc10bd23f918
commit https://github.com/vim/vim/commit/3dda7db4e1f7c4a8110a1f83001ec36b46693d27
Christian Brabandt <cb@256bit.org>
parents:
8804
diff
changeset
|
5113 if (prevwin == wp) |
dc10bd23f918
commit https://github.com/vim/vim/commit/3dda7db4e1f7c4a8110a1f83001ec36b46693d27
Christian Brabandt <cb@256bit.org>
parents:
8804
diff
changeset
|
5114 prevwin = NULL; |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9599
diff
changeset
|
5115 FOR_ALL_TABPAGES(ttp) |
8833
dc10bd23f918
commit https://github.com/vim/vim/commit/3dda7db4e1f7c4a8110a1f83001ec36b46693d27
Christian Brabandt <cb@256bit.org>
parents:
8804
diff
changeset
|
5116 if (ttp->tp_prevwin == wp) |
dc10bd23f918
commit https://github.com/vim/vim/commit/3dda7db4e1f7c4a8110a1f83001ec36b46693d27
Christian Brabandt <cb@256bit.org>
parents:
8804
diff
changeset
|
5117 ttp->tp_prevwin = NULL; |
dc10bd23f918
commit https://github.com/vim/vim/commit/3dda7db4e1f7c4a8110a1f83001ec36b46693d27
Christian Brabandt <cb@256bit.org>
parents:
8804
diff
changeset
|
5118 } |
7 | 5119 win_free_lsize(wp); |
5120 | |
5121 for (i = 0; i < wp->w_tagstacklen; ++i) | |
17932
70ed823bdbb6
patch 8.1.1962: leaking memory when using tagfunc()
Bram Moolenaar <Bram@vim.org>
parents:
17893
diff
changeset
|
5122 { |
7 | 5123 vim_free(wp->w_tagstack[i].tagname); |
17932
70ed823bdbb6
patch 8.1.1962: leaking memory when using tagfunc()
Bram Moolenaar <Bram@vim.org>
parents:
17893
diff
changeset
|
5124 vim_free(wp->w_tagstack[i].user_data); |
70ed823bdbb6
patch 8.1.1962: leaking memory when using tagfunc()
Bram Moolenaar <Bram@vim.org>
parents:
17893
diff
changeset
|
5125 } |
7 | 5126 vim_free(wp->w_localdir); |
20711
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20384
diff
changeset
|
5127 vim_free(wp->w_prevdir); |
1326 | 5128 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5129 // Remove the window from the b_wininfo lists, it may happen that the |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5130 // 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
|
5131 FOR_ALL_BUFFERS(buf) |
19888
435726a03481
patch 8.2.0500: using the same loop in many places
Bram Moolenaar <Bram@vim.org>
parents:
19291
diff
changeset
|
5132 FOR_ALL_BUF_WININFO(buf, wip) |
5237
647596ab1ae2
updated for version 7.4a.044
Bram Moolenaar <bram@vim.org>
parents:
5233
diff
changeset
|
5133 if (wip->wi_win == wp) |
22713
e871a824efc9
patch 8.2.1905: the wininfo list may contain stale entries
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
5134 { |
e871a824efc9
patch 8.2.1905: the wininfo list may contain stale entries
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
5135 wininfo_T *wip2; |
e871a824efc9
patch 8.2.1905: the wininfo list may contain stale entries
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
5136 |
e871a824efc9
patch 8.2.1905: the wininfo list may contain stale entries
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
5137 // If there already is an entry with "wi_win" set to NULL it |
e871a824efc9
patch 8.2.1905: the wininfo list may contain stale entries
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
5138 // must be removed, it would never be used. |
25157
9a2e7184b604
patch 8.2.3115: Coverity complains about free_wininfo() use
Bram Moolenaar <Bram@vim.org>
parents:
25064
diff
changeset
|
5139 // Skip "wip" itself, otherwise Coverity complains. |
22713
e871a824efc9
patch 8.2.1905: the wininfo list may contain stale entries
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
5140 for (wip2 = buf->b_wininfo; wip2 != NULL; wip2 = wip2->wi_next) |
25157
9a2e7184b604
patch 8.2.3115: Coverity complains about free_wininfo() use
Bram Moolenaar <Bram@vim.org>
parents:
25064
diff
changeset
|
5141 if (wip2 != wip && wip2->wi_win == NULL) |
22713
e871a824efc9
patch 8.2.1905: the wininfo list may contain stale entries
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
5142 { |
e871a824efc9
patch 8.2.1905: the wininfo list may contain stale entries
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
5143 if (wip2->wi_next != NULL) |
e871a824efc9
patch 8.2.1905: the wininfo list may contain stale entries
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
5144 wip2->wi_next->wi_prev = wip2->wi_prev; |
e871a824efc9
patch 8.2.1905: the wininfo list may contain stale entries
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
5145 if (wip2->wi_prev == NULL) |
e871a824efc9
patch 8.2.1905: the wininfo list may contain stale entries
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
5146 buf->b_wininfo = wip2->wi_next; |
e871a824efc9
patch 8.2.1905: the wininfo list may contain stale entries
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
5147 else |
e871a824efc9
patch 8.2.1905: the wininfo list may contain stale entries
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
5148 wip2->wi_prev->wi_next = wip2->wi_next; |
e871a824efc9
patch 8.2.1905: the wininfo list may contain stale entries
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
5149 free_wininfo(wip2); |
e871a824efc9
patch 8.2.1905: the wininfo list may contain stale entries
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
5150 break; |
e871a824efc9
patch 8.2.1905: the wininfo list may contain stale entries
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
5151 } |
e871a824efc9
patch 8.2.1905: the wininfo list may contain stale entries
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
5152 |
5237
647596ab1ae2
updated for version 7.4a.044
Bram Moolenaar <bram@vim.org>
parents:
5233
diff
changeset
|
5153 wip->wi_win = NULL; |
22713
e871a824efc9
patch 8.2.1905: the wininfo list may contain stale entries
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
5154 } |
5237
647596ab1ae2
updated for version 7.4a.044
Bram Moolenaar <bram@vim.org>
parents:
5233
diff
changeset
|
5155 |
7 | 5156 #ifdef FEAT_SEARCH_EXTRA |
1326 | 5157 clear_matches(wp); |
5158 #endif | |
5159 | |
7 | 5160 free_jumplist(wp); |
5161 | |
643 | 5162 #ifdef FEAT_QUICKFIX |
5163 qf_free_all(wp); | |
5164 #endif | |
5165 | |
7 | 5166 #ifdef FEAT_GUI |
5167 if (gui.in_use) | |
5168 { | |
5169 gui_mch_destroy_scrollbar(&wp->w_scrollbars[SBAR_LEFT]); | |
5170 gui_mch_destroy_scrollbar(&wp->w_scrollbars[SBAR_RIGHT]); | |
5171 } | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5172 #endif // FEAT_GUI |
7 | 5173 |
12487
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
5174 #ifdef FEAT_MENU |
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
5175 remove_winbar(wp); |
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
5176 #endif |
18763
49b78d6465e5
patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents:
18590
diff
changeset
|
5177 #ifdef FEAT_PROP_POPUP |
16890
5131023c5728
patch 8.1.1446: popup window callback not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
16888
diff
changeset
|
5178 free_callback(&wp->w_close_cb); |
16880
998603a243d7
patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents:
16874
diff
changeset
|
5179 free_callback(&wp->w_filter_cb); |
16888
ec61b6b79865
patch 8.1.1445: popup window border highlight not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
16880
diff
changeset
|
5180 for (i = 0; i < 4; ++i) |
ec61b6b79865
patch 8.1.1445: popup window border highlight not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
16880
diff
changeset
|
5181 VIM_CLEAR(wp->w_border_highlight[i]); |
17202
4b40e8821f56
patch 8.1.1600: cannot specify highlighting for popup window scrollbar
Bram Moolenaar <Bram@vim.org>
parents:
17162
diff
changeset
|
5182 vim_free(wp->w_scrollbar_highlight); |
4b40e8821f56
patch 8.1.1600: cannot specify highlighting for popup window scrollbar
Bram Moolenaar <Bram@vim.org>
parents:
17162
diff
changeset
|
5183 vim_free(wp->w_thumb_highlight); |
17119
b439e096a011
patch 8.1.1559: popup window title property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
17111
diff
changeset
|
5184 vim_free(wp->w_popup_title); |
17162
f16cee6adf29
patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents:
17119
diff
changeset
|
5185 list_unref(wp->w_popup_mask); |
17514
984cc7258468
patch 8.1.1755: leaking memory when using a popup window mask
Bram Moolenaar <Bram@vim.org>
parents:
17472
diff
changeset
|
5186 vim_free(wp->w_popup_mask_cells); |
16880
998603a243d7
patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents:
16874
diff
changeset
|
5187 #endif |
12487
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
5188 |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2201
diff
changeset
|
5189 #ifdef FEAT_SYN_HL |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2306
diff
changeset
|
5190 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
|
5191 #endif |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2201
diff
changeset
|
5192 |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
5193 if (win_valid_any_tab(wp)) |
1918 | 5194 win_remove(wp, tp); |
5958 | 5195 if (autocmd_busy) |
5196 { | |
5197 wp->w_next = au_pending_free_win; | |
5198 au_pending_free_win = wp; | |
5199 } | |
5200 else | |
5201 vim_free(wp); | |
1114 | 5202 |
1410 | 5203 unblock_autocmds(); |
7 | 5204 } |
5205 | |
5206 /* | |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
5207 * Return TRUE if "wp" is not in the list of windows: the autocmd window or a |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
5208 * popup window. |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
5209 */ |
17789
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17670
diff
changeset
|
5210 static int |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
5211 win_unlisted(win_T *wp) |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
5212 { |
17225
09fa437d33d8
patch 8.1.1612: cannot show an existing buffer in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
17202
diff
changeset
|
5213 return wp == aucmd_win || WIN_IS_POPUP(wp); |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
5214 } |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
5215 |
18763
49b78d6465e5
patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents:
18590
diff
changeset
|
5216 #if defined(FEAT_PROP_POPUP) || defined(PROTO) |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
5217 /* |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
5218 * Free a popup window. This does not take the window out of the window list |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
5219 * and assumes there is only one toplevel frame, no split. |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
5220 */ |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
5221 void |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
5222 win_free_popup(win_T *win) |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
5223 { |
17225
09fa437d33d8
patch 8.1.1612: cannot show an existing buffer in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
17202
diff
changeset
|
5224 if (bt_popup(win->w_buffer)) |
17823
7e6b7a4f13bc
patch 8.1.1908: every popup window consumes a buffer number
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
5225 win_close_buffer(win, DOBUF_WIPE_REUSE, FALSE); |
17225
09fa437d33d8
patch 8.1.1612: cannot show an existing buffer in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
17202
diff
changeset
|
5226 else |
18886
050f5eaa9e50
patch 8.2.0004: get E685 and E931 if buffer reload is interrupted
Bram Moolenaar <Bram@vim.org>
parents:
18816
diff
changeset
|
5227 close_buffer(win, win->w_buffer, 0, FALSE, FALSE); |
16802
f5487021fdad
patch 8.1.1403: cannot build without the timer feature
Bram Moolenaar <Bram@vim.org>
parents:
16800
diff
changeset
|
5228 # if defined(FEAT_TIMERS) |
16800
12e3a3afdb6a
patch 8.1.1402: "timer" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents:
16796
diff
changeset
|
5229 if (win->w_popup_timer != NULL) |
12e3a3afdb6a
patch 8.1.1402: "timer" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents:
16796
diff
changeset
|
5230 stop_timer(win->w_popup_timer); |
16802
f5487021fdad
patch 8.1.1403: cannot build without the timer feature
Bram Moolenaar <Bram@vim.org>
parents:
16800
diff
changeset
|
5231 # endif |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
5232 vim_free(win->w_frame); |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
5233 win_free(win, NULL); |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
5234 } |
16802
f5487021fdad
patch 8.1.1403: cannot build without the timer feature
Bram Moolenaar <Bram@vim.org>
parents:
16800
diff
changeset
|
5235 #endif |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
5236 |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
5237 /* |
7 | 5238 * Append window "wp" in the window list after window "after". |
5239 */ | |
17789
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17670
diff
changeset
|
5240 static void |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5241 win_append(win_T *after, win_T *wp) |
7 | 5242 { |
5243 win_T *before; | |
5244 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5245 if (after == NULL) // after NULL is in front of the first |
7 | 5246 before = firstwin; |
5247 else | |
5248 before = after->w_next; | |
5249 | |
5250 wp->w_next = before; | |
5251 wp->w_prev = after; | |
5252 if (after == NULL) | |
5253 firstwin = wp; | |
5254 else | |
5255 after->w_next = wp; | |
5256 if (before == NULL) | |
5257 lastwin = wp; | |
5258 else | |
5259 before->w_prev = wp; | |
5260 } | |
5261 | |
5262 /* | |
5263 * Remove a window from the window list. | |
5264 */ | |
1906 | 5265 void |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5266 win_remove( |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5267 win_T *wp, |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5268 tabpage_T *tp) // tab page "win" is in, NULL for current |
7 | 5269 { |
5270 if (wp->w_prev != NULL) | |
5271 wp->w_prev->w_next = wp->w_next; | |
671 | 5272 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
|
5273 firstwin = curtab->tp_firstwin = wp->w_next; |
7 | 5274 else |
671 | 5275 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
|
5276 |
7 | 5277 if (wp->w_next != NULL) |
5278 wp->w_next->w_prev = wp->w_prev; | |
671 | 5279 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
|
5280 lastwin = curtab->tp_lastwin = wp->w_prev; |
7 | 5281 else |
671 | 5282 tp->tp_lastwin = wp->w_prev; |
7 | 5283 } |
5284 | |
5285 /* | |
5286 * Append frame "frp" in a frame list after frame "after". | |
5287 */ | |
5288 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5289 frame_append(frame_T *after, frame_T *frp) |
7 | 5290 { |
5291 frp->fr_next = after->fr_next; | |
5292 after->fr_next = frp; | |
5293 if (frp->fr_next != NULL) | |
5294 frp->fr_next->fr_prev = frp; | |
5295 frp->fr_prev = after; | |
5296 } | |
5297 | |
5298 /* | |
5299 * Insert frame "frp" in a frame list before frame "before". | |
5300 */ | |
5301 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5302 frame_insert(frame_T *before, frame_T *frp) |
7 | 5303 { |
5304 frp->fr_next = before; | |
5305 frp->fr_prev = before->fr_prev; | |
5306 before->fr_prev = frp; | |
5307 if (frp->fr_prev != NULL) | |
5308 frp->fr_prev->fr_next = frp; | |
5309 else | |
5310 frp->fr_parent->fr_child = frp; | |
5311 } | |
5312 | |
5313 /* | |
5314 * Remove a frame from a frame list. | |
5315 */ | |
5316 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5317 frame_remove(frame_T *frp) |
7 | 5318 { |
5319 if (frp->fr_prev != NULL) | |
5320 frp->fr_prev->fr_next = frp->fr_next; | |
5321 else | |
5322 frp->fr_parent->fr_child = frp->fr_next; | |
5323 if (frp->fr_next != NULL) | |
5324 frp->fr_next->fr_prev = frp->fr_prev; | |
5325 } | |
5326 | |
5327 /* | |
5328 * Allocate w_lines[] for window "wp". | |
5329 * Return FAIL for failure, OK for success. | |
5330 */ | |
5331 int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5332 win_alloc_lines(win_T *wp) |
7 | 5333 { |
5334 wp->w_lines_valid = 0; | |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16802
diff
changeset
|
5335 wp->w_lines = ALLOC_CLEAR_MULT(wline_T, Rows ); |
7 | 5336 if (wp->w_lines == NULL) |
5337 return FAIL; | |
5338 return OK; | |
5339 } | |
5340 | |
5341 /* | |
5342 * free lsize arrays for a window | |
5343 */ | |
5344 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5345 win_free_lsize(win_T *wp) |
7 | 5346 { |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5347 // TODO: why would wp be NULL here? |
5952 | 5348 if (wp != NULL) |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13144
diff
changeset
|
5349 VIM_CLEAR(wp->w_lines); |
7 | 5350 } |
5351 | |
5352 /* | |
5353 * Called from win_new_shellsize() after Rows changed. | |
671 | 5354 * This only does the current tab page, others must be done when made active. |
7 | 5355 */ |
5356 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5357 shell_new_rows(void) |
7 | 5358 { |
26488
06aa56b32df4
patch 8.2.3774: test for command line height fails
Bram Moolenaar <Bram@vim.org>
parents:
26486
diff
changeset
|
5359 int h = (int)ROWS_AVAIL; |
7 | 5360 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5361 if (firstwin == NULL) // not initialized yet |
7 | 5362 return; |
26488
06aa56b32df4
patch 8.2.3774: test for command line height fails
Bram Moolenaar <Bram@vim.org>
parents:
26486
diff
changeset
|
5363 if (h < frame_minheight(topframe, NULL)) |
06aa56b32df4
patch 8.2.3774: test for command line height fails
Bram Moolenaar <Bram@vim.org>
parents:
26486
diff
changeset
|
5364 h = frame_minheight(topframe, NULL); |
06aa56b32df4
patch 8.2.3774: test for command line height fails
Bram Moolenaar <Bram@vim.org>
parents:
26486
diff
changeset
|
5365 |
06aa56b32df4
patch 8.2.3774: test for command line height fails
Bram Moolenaar <Bram@vim.org>
parents:
26486
diff
changeset
|
5366 // First try setting the heights of windows with 'winfixheight'. If |
06aa56b32df4
patch 8.2.3774: test for command line height fails
Bram Moolenaar <Bram@vim.org>
parents:
26486
diff
changeset
|
5367 // that doesn't result in the right height, forget about that option. |
06aa56b32df4
patch 8.2.3774: test for command line height fails
Bram Moolenaar <Bram@vim.org>
parents:
26486
diff
changeset
|
5368 frame_new_height(topframe, h, FALSE, TRUE); |
06aa56b32df4
patch 8.2.3774: test for command line height fails
Bram Moolenaar <Bram@vim.org>
parents:
26486
diff
changeset
|
5369 if (!frame_check_height(topframe, h)) |
06aa56b32df4
patch 8.2.3774: test for command line height fails
Bram Moolenaar <Bram@vim.org>
parents:
26486
diff
changeset
|
5370 frame_new_height(topframe, h, FALSE, FALSE); |
7 | 5371 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5372 (void)win_comp_pos(); // recompute w_winrow and w_wincol |
7 | 5373 compute_cmdrow(); |
824 | 5374 curtab->tp_ch_used = p_ch; |
170 | 5375 |
7 | 5376 #if 0 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5377 // Disabled: don't want making the screen smaller make a window larger. |
7 | 5378 if (p_ea) |
5379 win_equal(curwin, FALSE, 'v'); | |
5380 #endif | |
5381 } | |
5382 | |
5383 /* | |
5384 * Called from win_new_shellsize() after Columns changed. | |
5385 */ | |
5386 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5387 shell_new_columns(void) |
7 | 5388 { |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5389 if (firstwin == NULL) // not initialized yet |
7 | 5390 return; |
779 | 5391 |
26488
06aa56b32df4
patch 8.2.3774: test for command line height fails
Bram Moolenaar <Bram@vim.org>
parents:
26486
diff
changeset
|
5392 // First try setting the widths of windows with 'winfixwidth'. If that |
06aa56b32df4
patch 8.2.3774: test for command line height fails
Bram Moolenaar <Bram@vim.org>
parents:
26486
diff
changeset
|
5393 // doesn't result in the right width, forget about that option. |
06aa56b32df4
patch 8.2.3774: test for command line height fails
Bram Moolenaar <Bram@vim.org>
parents:
26486
diff
changeset
|
5394 frame_new_width(topframe, (int)Columns, FALSE, TRUE); |
06aa56b32df4
patch 8.2.3774: test for command line height fails
Bram Moolenaar <Bram@vim.org>
parents:
26486
diff
changeset
|
5395 if (!frame_check_width(topframe, Columns)) |
06aa56b32df4
patch 8.2.3774: test for command line height fails
Bram Moolenaar <Bram@vim.org>
parents:
26486
diff
changeset
|
5396 frame_new_width(topframe, (int)Columns, FALSE, FALSE); |
779 | 5397 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5398 (void)win_comp_pos(); // recompute w_winrow and w_wincol |
7 | 5399 #if 0 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5400 // Disabled: don't want making the screen smaller make a window larger. |
7 | 5401 if (p_ea) |
5402 win_equal(curwin, FALSE, 'h'); | |
5403 #endif | |
5404 } | |
5405 | |
5406 #if defined(FEAT_CMDWIN) || defined(PROTO) | |
5407 /* | |
5408 * Save the size of all windows in "gap". | |
5409 */ | |
5410 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5411 win_size_save(garray_T *gap) |
7 | 5412 |
5413 { | |
5414 win_T *wp; | |
5415 | |
5416 ga_init2(gap, (int)sizeof(int), 1); | |
18467
99fc29219b3e
patch 8.1.2227: layout wrong if 'lines' changes while cmdline window is open
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5417 if (ga_grow(gap, win_count() * 2 + 1) == OK) |
99fc29219b3e
patch 8.1.2227: layout wrong if 'lines' changes while cmdline window is open
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5418 { |
99fc29219b3e
patch 8.1.2227: layout wrong if 'lines' changes while cmdline window is open
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5419 // first entry is value of 'lines' |
99fc29219b3e
patch 8.1.2227: layout wrong if 'lines' changes while cmdline window is open
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5420 ((int *)gap->ga_data)[gap->ga_len++] = Rows; |
99fc29219b3e
patch 8.1.2227: layout wrong if 'lines' changes while cmdline window is open
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5421 |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9599
diff
changeset
|
5422 FOR_ALL_WINDOWS(wp) |
7 | 5423 { |
5424 ((int *)gap->ga_data)[gap->ga_len++] = | |
5425 wp->w_width + wp->w_vsep_width; | |
5426 ((int *)gap->ga_data)[gap->ga_len++] = wp->w_height; | |
5427 } | |
18467
99fc29219b3e
patch 8.1.2227: layout wrong if 'lines' changes while cmdline window is open
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5428 } |
7 | 5429 } |
5430 | |
5431 /* | |
18467
99fc29219b3e
patch 8.1.2227: layout wrong if 'lines' changes while cmdline window is open
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5432 * Restore window sizes, but only if the number of windows is still the same |
99fc29219b3e
patch 8.1.2227: layout wrong if 'lines' changes while cmdline window is open
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5433 * and 'lines' didn't change. |
7 | 5434 * Does not free the growarray. |
5435 */ | |
5436 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5437 win_size_restore(garray_T *gap) |
7 | 5438 { |
5439 win_T *wp; | |
6058 | 5440 int i, j; |
7 | 5441 |
18467
99fc29219b3e
patch 8.1.2227: layout wrong if 'lines' changes while cmdline window is open
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5442 if (win_count() * 2 + 1 == gap->ga_len |
99fc29219b3e
patch 8.1.2227: layout wrong if 'lines' changes while cmdline window is open
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5443 && ((int *)gap->ga_data)[0] == Rows) |
7 | 5444 { |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5445 // The order matters, because frames contain other frames, but it's |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5446 // difficult to get right. The easy way out is to do it twice. |
6058 | 5447 for (j = 0; j < 2; ++j) |
7 | 5448 { |
18467
99fc29219b3e
patch 8.1.2227: layout wrong if 'lines' changes while cmdline window is open
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
5449 i = 1; |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9599
diff
changeset
|
5450 FOR_ALL_WINDOWS(wp) |
6058 | 5451 { |
5452 frame_setwidth(wp->w_frame, ((int *)gap->ga_data)[i++]); | |
5453 win_setheight_win(((int *)gap->ga_data)[i++], wp); | |
5454 } | |
7 | 5455 } |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5456 // recompute the window positions |
7 | 5457 (void)win_comp_pos(); |
5458 } | |
5459 } | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5460 #endif // FEAT_CMDWIN |
7 | 5461 |
5462 /* | |
5463 * Update the position for all windows, using the width and height of the | |
5464 * frames. | |
5465 * Returns the row just after the last window. | |
5466 */ | |
668 | 5467 int |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5468 win_comp_pos(void) |
7 | 5469 { |
685 | 5470 int row = tabline_height(); |
7 | 5471 int col = 0; |
5472 | |
5473 frame_comp_pos(topframe, &row, &col); | |
5474 return row; | |
5475 } | |
5476 | |
5477 /* | |
5478 * Update the position of the windows in frame "topfrp", using the width and | |
5479 * height of the frames. | |
5480 * "*row" and "*col" are the top-left position of the frame. They are updated | |
5481 * to the bottom-right position plus one. | |
5482 */ | |
5483 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5484 frame_comp_pos(frame_T *topfrp, int *row, int *col) |
7 | 5485 { |
5486 win_T *wp; | |
5487 frame_T *frp; | |
5488 int startcol; | |
5489 int startrow; | |
12998
dd734ee3e2fe
patch 8.0.1375: window size wrong after maximizing with WinBar
Christian Brabandt <cb@256bit.org>
parents:
12916
diff
changeset
|
5490 int h; |
7 | 5491 |
5492 wp = topfrp->fr_win; | |
5493 if (wp != NULL) | |
5494 { | |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8536
diff
changeset
|
5495 if (wp->w_winrow != *row || wp->w_wincol != *col) |
7 | 5496 { |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5497 // position changed, redraw |
7 | 5498 wp->w_winrow = *row; |
5499 wp->w_wincol = *col; | |
5500 redraw_win_later(wp, NOT_VALID); | |
5501 wp->w_redr_status = TRUE; | |
5502 } | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5503 // WinBar will not show if the window height is zero |
12998
dd734ee3e2fe
patch 8.0.1375: window size wrong after maximizing with WinBar
Christian Brabandt <cb@256bit.org>
parents:
12916
diff
changeset
|
5504 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
|
5505 *row += h > topfrp->fr_height ? topfrp->fr_height : h; |
7 | 5506 *col += wp->w_width + wp->w_vsep_width; |
5507 } | |
5508 else | |
5509 { | |
5510 startrow = *row; | |
5511 startcol = *col; | |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
5512 FOR_ALL_FRAMES(frp, topfrp->fr_child) |
7 | 5513 { |
5514 if (topfrp->fr_layout == FR_ROW) | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5515 *row = startrow; // all frames are at the same row |
7 | 5516 else |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5517 *col = startcol; // all frames are at the same col |
7 | 5518 frame_comp_pos(frp, row, col); |
5519 } | |
5520 } | |
5521 } | |
5522 | |
5523 /* | |
26468
2fc13817b100
patch 8.2.3764: cannot see any text when window was made zero lines
Bram Moolenaar <Bram@vim.org>
parents:
26458
diff
changeset
|
5524 * Make the current window show at least one line and one column. |
2fc13817b100
patch 8.2.3764: cannot see any text when window was made zero lines
Bram Moolenaar <Bram@vim.org>
parents:
26458
diff
changeset
|
5525 */ |
2fc13817b100
patch 8.2.3764: cannot see any text when window was made zero lines
Bram Moolenaar <Bram@vim.org>
parents:
26458
diff
changeset
|
5526 void |
2fc13817b100
patch 8.2.3764: cannot see any text when window was made zero lines
Bram Moolenaar <Bram@vim.org>
parents:
26458
diff
changeset
|
5527 win_ensure_size() |
2fc13817b100
patch 8.2.3764: cannot see any text when window was made zero lines
Bram Moolenaar <Bram@vim.org>
parents:
26458
diff
changeset
|
5528 { |
2fc13817b100
patch 8.2.3764: cannot see any text when window was made zero lines
Bram Moolenaar <Bram@vim.org>
parents:
26458
diff
changeset
|
5529 if (curwin->w_height == 0) |
2fc13817b100
patch 8.2.3764: cannot see any text when window was made zero lines
Bram Moolenaar <Bram@vim.org>
parents:
26458
diff
changeset
|
5530 win_setheight(1); |
2fc13817b100
patch 8.2.3764: cannot see any text when window was made zero lines
Bram Moolenaar <Bram@vim.org>
parents:
26458
diff
changeset
|
5531 if (curwin->w_width == 0) |
2fc13817b100
patch 8.2.3764: cannot see any text when window was made zero lines
Bram Moolenaar <Bram@vim.org>
parents:
26458
diff
changeset
|
5532 win_setwidth(1); |
2fc13817b100
patch 8.2.3764: cannot see any text when window was made zero lines
Bram Moolenaar <Bram@vim.org>
parents:
26458
diff
changeset
|
5533 } |
2fc13817b100
patch 8.2.3764: cannot see any text when window was made zero lines
Bram Moolenaar <Bram@vim.org>
parents:
26458
diff
changeset
|
5534 |
2fc13817b100
patch 8.2.3764: cannot see any text when window was made zero lines
Bram Moolenaar <Bram@vim.org>
parents:
26458
diff
changeset
|
5535 /* |
7 | 5536 * Set current window height and take care of repositioning other windows to |
5537 * fit around it. | |
5538 */ | |
5539 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5540 win_setheight(int height) |
7 | 5541 { |
5542 win_setheight_win(height, curwin); | |
5543 } | |
5544 | |
5545 /* | |
5546 * Set the window height of window "win" and take care of repositioning other | |
5547 * windows to fit around it. | |
5548 */ | |
5549 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5550 win_setheight_win(int height, win_T *win) |
7 | 5551 { |
5552 int row; | |
5553 | |
5554 if (win == curwin) | |
5555 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5556 // Always keep current window at least one line high, even when |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5557 // 'winminheight' is zero. |
7 | 5558 if (height < p_wmh) |
5559 height = p_wmh; | |
5560 if (height == 0) | |
5561 height = 1; | |
12998
dd734ee3e2fe
patch 8.0.1375: window size wrong after maximizing with WinBar
Christian Brabandt <cb@256bit.org>
parents:
12916
diff
changeset
|
5562 height += WINBAR_HEIGHT(curwin); |
7 | 5563 } |
5564 | |
5565 frame_setheight(win->w_frame, height + win->w_status_height); | |
5566 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5567 // recompute the window positions |
7 | 5568 row = win_comp_pos(); |
5569 | |
5570 /* | |
5571 * If there is extra space created between the last window and the command | |
5572 * line, clear it. | |
5573 */ | |
5574 if (full_screen && msg_scrolled == 0 && row < cmdline_row) | |
5575 screen_fill(row, cmdline_row, 0, (int)Columns, ' ', ' ', 0); | |
5576 cmdline_row = row; | |
5577 msg_row = row; | |
5578 msg_col = 0; | |
5579 | |
5580 redraw_all_later(NOT_VALID); | |
5581 } | |
5582 | |
5583 /* | |
5584 * Set the height of a frame to "height" and take care that all frames and | |
5585 * windows inside it are resized. Also resize frames on the left and right if | |
5586 * the are in the same FR_ROW frame. | |
5587 * | |
5588 * Strategy: | |
5589 * If the frame is part of a FR_COL frame, try fitting the frame in that | |
5590 * frame. If that doesn't work (the FR_COL frame is too small), recursively | |
5591 * go to containing frames to resize them and make room. | |
5592 * If the frame is part of a FR_ROW frame, all frames must be resized as well. | |
5593 * Check for the minimal height of the FR_ROW frame. | |
5594 * At the top level we can also use change the command line height. | |
5595 */ | |
5596 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5597 frame_setheight(frame_T *curfrp, int height) |
7 | 5598 { |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5599 int room; // total number of lines available |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5600 int take; // number of lines taken from other windows |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5601 int room_cmdline; // lines available from cmdline |
7 | 5602 int run; |
5603 frame_T *frp; | |
5604 int h; | |
5605 int room_reserved; | |
5606 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5607 // If the height already is the desired value, nothing to do. |
7 | 5608 if (curfrp->fr_height == height) |
5609 return; | |
5610 | |
5611 if (curfrp->fr_parent == NULL) | |
5612 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5613 // topframe: can only change the command line |
667 | 5614 if (height > ROWS_AVAIL) |
5615 height = ROWS_AVAIL; | |
7 | 5616 if (height > 0) |
5617 frame_new_height(curfrp, height, FALSE, FALSE); | |
5618 } | |
5619 else if (curfrp->fr_parent->fr_layout == FR_ROW) | |
5620 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5621 // Row of frames: Also need to resize frames left and right of this |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5622 // one. First check for the minimal height of these. |
7 | 5623 h = frame_minheight(curfrp->fr_parent, NULL); |
5624 if (height < h) | |
5625 height = h; | |
5626 frame_setheight(curfrp->fr_parent, height); | |
5627 } | |
5628 else | |
5629 { | |
5630 /* | |
5631 * Column of frames: try to change only frames in this column. | |
5632 */ | |
5633 /* | |
5634 * Do this twice: | |
5635 * 1: compute room available, if it's not enough try resizing the | |
5636 * containing frame. | |
5637 * 2: compute the room available and adjust the height to it. | |
5638 * Try not to reduce the height of a window with 'winfixheight' set. | |
5639 */ | |
5640 for (run = 1; run <= 2; ++run) | |
5641 { | |
5642 room = 0; | |
5643 room_reserved = 0; | |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
5644 FOR_ALL_FRAMES(frp, curfrp->fr_parent->fr_child) |
7 | 5645 { |
5646 if (frp != curfrp | |
5647 && frp->fr_win != NULL | |
5648 && frp->fr_win->w_p_wfh) | |
5649 room_reserved += frp->fr_height; | |
5650 room += frp->fr_height; | |
5651 if (frp != curfrp) | |
5652 room -= frame_minheight(frp, NULL); | |
5653 } | |
5654 if (curfrp->fr_width != Columns) | |
5655 room_cmdline = 0; | |
5656 else | |
5657 { | |
5658 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
|
5659 + VISIBLE_HEIGHT(lastwin) |
dd734ee3e2fe
patch 8.0.1375: window size wrong after maximizing with WinBar
Christian Brabandt <cb@256bit.org>
parents:
12916
diff
changeset
|
5660 + lastwin->w_status_height); |
7 | 5661 if (room_cmdline < 0) |
5662 room_cmdline = 0; | |
5663 } | |
5664 | |
5665 if (height <= room + room_cmdline) | |
5666 break; | |
5667 if (run == 2 || curfrp->fr_width == Columns) | |
5668 { | |
5669 if (height > room + room_cmdline) | |
5670 height = room + room_cmdline; | |
5671 break; | |
5672 } | |
5673 frame_setheight(curfrp->fr_parent, height | |
5674 + frame_minheight(curfrp->fr_parent, NOWIN) - (int)p_wmh - 1); | |
5675 } | |
5676 | |
5677 /* | |
5678 * Compute the number of lines we will take from others frames (can be | |
5679 * negative!). | |
5680 */ | |
5681 take = height - curfrp->fr_height; | |
5682 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5683 // If there is not enough room, also reduce the height of a window |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5684 // with 'winfixheight' set. |
7 | 5685 if (height > room + room_cmdline - room_reserved) |
5686 room_reserved = room + room_cmdline - height; | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5687 // If there is only a 'winfixheight' window and making the |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5688 // window smaller, need to make the other window taller. |
7 | 5689 if (take < 0 && room - curfrp->fr_height < room_reserved) |
5690 room_reserved = 0; | |
5691 | |
5692 if (take > 0 && room_cmdline > 0) | |
5693 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5694 // use lines from cmdline first |
7 | 5695 if (take < room_cmdline) |
5696 room_cmdline = take; | |
5697 take -= room_cmdline; | |
5698 topframe->fr_height += room_cmdline; | |
5699 } | |
5700 | |
5701 /* | |
5702 * set the current frame to the new height | |
5703 */ | |
5704 frame_new_height(curfrp, height, FALSE, FALSE); | |
5705 | |
5706 /* | |
5707 * First take lines from the frames after the current frame. If | |
5708 * that is not enough, takes lines from frames above the current | |
5709 * frame. | |
5710 */ | |
5711 for (run = 0; run < 2; ++run) | |
5712 { | |
5713 if (run == 0) | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5714 frp = curfrp->fr_next; // 1st run: start with next window |
7 | 5715 else |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5716 frp = curfrp->fr_prev; // 2nd run: start with prev window |
7 | 5717 while (frp != NULL && take != 0) |
5718 { | |
5719 h = frame_minheight(frp, NULL); | |
5720 if (room_reserved > 0 | |
5721 && frp->fr_win != NULL | |
5722 && frp->fr_win->w_p_wfh) | |
5723 { | |
5724 if (room_reserved >= frp->fr_height) | |
5725 room_reserved -= frp->fr_height; | |
5726 else | |
5727 { | |
5728 if (frp->fr_height - room_reserved > take) | |
5729 room_reserved = frp->fr_height - take; | |
5730 take -= frp->fr_height - room_reserved; | |
5731 frame_new_height(frp, room_reserved, FALSE, FALSE); | |
5732 room_reserved = 0; | |
5733 } | |
5734 } | |
5735 else | |
5736 { | |
5737 if (frp->fr_height - take < h) | |
5738 { | |
5739 take -= frp->fr_height - h; | |
5740 frame_new_height(frp, h, FALSE, FALSE); | |
5741 } | |
5742 else | |
5743 { | |
5744 frame_new_height(frp, frp->fr_height - take, | |
5745 FALSE, FALSE); | |
5746 take = 0; | |
5747 } | |
5748 } | |
5749 if (run == 0) | |
5750 frp = frp->fr_next; | |
5751 else | |
5752 frp = frp->fr_prev; | |
5753 } | |
5754 } | |
5755 } | |
5756 } | |
5757 | |
5758 /* | |
5759 * Set current window width and take care of repositioning other windows to | |
5760 * fit around it. | |
5761 */ | |
5762 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5763 win_setwidth(int width) |
7 | 5764 { |
5765 win_setwidth_win(width, curwin); | |
5766 } | |
5767 | |
5768 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5769 win_setwidth_win(int width, win_T *wp) |
7 | 5770 { |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5771 // Always keep current window at least one column wide, even when |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5772 // 'winminwidth' is zero. |
7 | 5773 if (wp == curwin) |
5774 { | |
5775 if (width < p_wmw) | |
5776 width = p_wmw; | |
5777 if (width == 0) | |
5778 width = 1; | |
5779 } | |
23402
65718283239b
patch 8.2.2244: crash when making the window width negative
Bram Moolenaar <Bram@vim.org>
parents:
23386
diff
changeset
|
5780 else if (width < 0) |
65718283239b
patch 8.2.2244: crash when making the window width negative
Bram Moolenaar <Bram@vim.org>
parents:
23386
diff
changeset
|
5781 width = 0; |
7 | 5782 |
5783 frame_setwidth(wp->w_frame, width + wp->w_vsep_width); | |
5784 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5785 // recompute the window positions |
7 | 5786 (void)win_comp_pos(); |
5787 | |
5788 redraw_all_later(NOT_VALID); | |
5789 } | |
5790 | |
5791 /* | |
5792 * Set the width of a frame to "width" and take care that all frames and | |
5793 * windows inside it are resized. Also resize frames above and below if the | |
5794 * are in the same FR_ROW frame. | |
5795 * | |
5796 * Strategy is similar to frame_setheight(). | |
5797 */ | |
5798 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5799 frame_setwidth(frame_T *curfrp, int width) |
7 | 5800 { |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5801 int room; // total number of lines available |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5802 int take; // number of lines taken from other windows |
7 | 5803 int run; |
5804 frame_T *frp; | |
5805 int w; | |
779 | 5806 int room_reserved; |
7 | 5807 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5808 // If the width already is the desired value, nothing to do. |
7 | 5809 if (curfrp->fr_width == width) |
5810 return; | |
5811 | |
5812 if (curfrp->fr_parent == NULL) | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5813 // topframe: can't change width |
7 | 5814 return; |
5815 | |
5816 if (curfrp->fr_parent->fr_layout == FR_COL) | |
5817 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5818 // Column of frames: Also need to resize frames above and below of |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5819 // this one. First check for the minimal width of these. |
7 | 5820 w = frame_minwidth(curfrp->fr_parent, NULL); |
5821 if (width < w) | |
5822 width = w; | |
5823 frame_setwidth(curfrp->fr_parent, width); | |
5824 } | |
5825 else | |
5826 { | |
5827 /* | |
5828 * Row of frames: try to change only frames in this row. | |
5829 * | |
5830 * Do this twice: | |
5831 * 1: compute room available, if it's not enough try resizing the | |
5832 * containing frame. | |
5833 * 2: compute the room available and adjust the width to it. | |
5834 */ | |
5835 for (run = 1; run <= 2; ++run) | |
5836 { | |
5837 room = 0; | |
779 | 5838 room_reserved = 0; |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
5839 FOR_ALL_FRAMES(frp, curfrp->fr_parent->fr_child) |
7 | 5840 { |
779 | 5841 if (frp != curfrp |
5842 && frp->fr_win != NULL | |
5843 && frp->fr_win->w_p_wfw) | |
5844 room_reserved += frp->fr_width; | |
7 | 5845 room += frp->fr_width; |
5846 if (frp != curfrp) | |
5847 room -= frame_minwidth(frp, NULL); | |
5848 } | |
5849 | |
5850 if (width <= room) | |
5851 break; | |
667 | 5852 if (run == 2 || curfrp->fr_height >= ROWS_AVAIL) |
7 | 5853 { |
5854 if (width > room) | |
5855 width = room; | |
5856 break; | |
5857 } | |
5858 frame_setwidth(curfrp->fr_parent, width | |
5859 + frame_minwidth(curfrp->fr_parent, NOWIN) - (int)p_wmw - 1); | |
5860 } | |
5861 | |
5862 /* | |
5863 * Compute the number of lines we will take from others frames (can be | |
5864 * negative!). | |
5865 */ | |
5866 take = width - curfrp->fr_width; | |
5867 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5868 // If there is not enough room, also reduce the width of a window |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5869 // with 'winfixwidth' set. |
779 | 5870 if (width > room - room_reserved) |
5871 room_reserved = room - width; | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5872 // If there is only a 'winfixwidth' window and making the |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5873 // window smaller, need to make the other window narrower. |
779 | 5874 if (take < 0 && room - curfrp->fr_width < room_reserved) |
5875 room_reserved = 0; | |
5876 | |
7 | 5877 /* |
5878 * set the current frame to the new width | |
5879 */ | |
779 | 5880 frame_new_width(curfrp, width, FALSE, FALSE); |
7 | 5881 |
5882 /* | |
5883 * First take lines from the frames right of the current frame. If | |
5884 * that is not enough, takes lines from frames left of the current | |
5885 * frame. | |
5886 */ | |
5887 for (run = 0; run < 2; ++run) | |
5888 { | |
5889 if (run == 0) | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5890 frp = curfrp->fr_next; // 1st run: start with next window |
7 | 5891 else |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5892 frp = curfrp->fr_prev; // 2nd run: start with prev window |
7 | 5893 while (frp != NULL && take != 0) |
5894 { | |
5895 w = frame_minwidth(frp, NULL); | |
779 | 5896 if (room_reserved > 0 |
5897 && frp->fr_win != NULL | |
5898 && frp->fr_win->w_p_wfw) | |
7 | 5899 { |
779 | 5900 if (room_reserved >= frp->fr_width) |
5901 room_reserved -= frp->fr_width; | |
5902 else | |
5903 { | |
5904 if (frp->fr_width - room_reserved > take) | |
5905 room_reserved = frp->fr_width - take; | |
5906 take -= frp->fr_width - room_reserved; | |
5907 frame_new_width(frp, room_reserved, FALSE, FALSE); | |
5908 room_reserved = 0; | |
5909 } | |
7 | 5910 } |
5911 else | |
5912 { | |
779 | 5913 if (frp->fr_width - take < w) |
5914 { | |
5915 take -= frp->fr_width - w; | |
5916 frame_new_width(frp, w, FALSE, FALSE); | |
5917 } | |
5918 else | |
5919 { | |
5920 frame_new_width(frp, frp->fr_width - take, | |
5921 FALSE, FALSE); | |
5922 take = 0; | |
5923 } | |
7 | 5924 } |
5925 if (run == 0) | |
5926 frp = frp->fr_next; | |
5927 else | |
5928 frp = frp->fr_prev; | |
5929 } | |
5930 } | |
5931 } | |
5932 } | |
5933 | |
5934 /* | |
14057
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
5935 * Check 'winminheight' for a valid value and reduce it if needed. |
7 | 5936 */ |
5937 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5938 win_setminheight(void) |
7 | 5939 { |
5940 int room; | |
14057
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
5941 int needed; |
7 | 5942 int first = TRUE; |
14057
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
5943 |
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
5944 // loop until there is a 'winminheight' that is possible |
7 | 5945 while (p_wmh > 0) |
5946 { | |
24108
0a5eba7e6660
patch 8.2.2595: setting 'winminheight' may cause 'lines' to change
Bram Moolenaar <Bram@vim.org>
parents:
24037
diff
changeset
|
5947 room = Rows - p_ch; |
0a5eba7e6660
patch 8.2.2595: setting 'winminheight' may cause 'lines' to change
Bram Moolenaar <Bram@vim.org>
parents:
24037
diff
changeset
|
5948 needed = min_rows() - 1; // 1 was added for the cmdline |
14057
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
5949 if (room >= needed) |
7 | 5950 break; |
5951 --p_wmh; | |
5952 if (first) | |
5953 { | |
25306
078edc1821bf
patch 8.2.3190: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
25157
diff
changeset
|
5954 emsg(_(e_not_enough_room)); |
7 | 5955 first = FALSE; |
5956 } | |
5957 } | |
5958 } | |
5959 | |
14057
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
5960 /* |
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
5961 * Check 'winminwidth' for a valid value and reduce it if needed. |
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
5962 */ |
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
5963 void |
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
5964 win_setminwidth(void) |
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
5965 { |
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
5966 int room; |
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
5967 int needed; |
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
5968 int first = TRUE; |
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
5969 |
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
5970 // loop until there is a 'winminheight' that is possible |
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
5971 while (p_wmw > 0) |
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
5972 { |
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
5973 room = Columns; |
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
5974 needed = frame_minwidth(topframe, NULL); |
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
5975 if (room >= needed) |
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
5976 break; |
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
5977 --p_wmw; |
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
5978 if (first) |
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
5979 { |
25306
078edc1821bf
patch 8.2.3190: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
25157
diff
changeset
|
5980 emsg(_(e_not_enough_room)); |
14057
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
5981 first = FALSE; |
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
5982 } |
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
5983 } |
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
5984 } |
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
5985 |
7 | 5986 /* |
5987 * Status line of dragwin is dragged "offset" lines down (negative is up). | |
5988 */ | |
5989 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5990 win_drag_status_line(win_T *dragwin, int offset) |
7 | 5991 { |
5992 frame_T *curfr; | |
5993 frame_T *fr; | |
5994 int room; | |
5995 int row; | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5996 int up; // if TRUE, drag status line up, otherwise down |
7 | 5997 int n; |
5998 | |
5999 fr = dragwin->w_frame; | |
6000 curfr = fr; | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6001 if (fr != topframe) // more than one window |
7 | 6002 { |
6003 fr = fr->fr_parent; | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6004 // When the parent frame is not a column of frames, its parent should |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6005 // be. |
7 | 6006 if (fr->fr_layout != FR_COL) |
6007 { | |
6008 curfr = fr; | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6009 if (fr != topframe) // only a row of windows, may drag statusline |
7 | 6010 fr = fr->fr_parent; |
6011 } | |
6012 } | |
6013 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6014 // If this is the last frame in a column, may want to resize the parent |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6015 // frame instead (go two up to skip a row of frames). |
7 | 6016 while (curfr != topframe && curfr->fr_next == NULL) |
6017 { | |
6018 if (fr != topframe) | |
6019 fr = fr->fr_parent; | |
6020 curfr = fr; | |
6021 if (fr != topframe) | |
6022 fr = fr->fr_parent; | |
6023 } | |
6024 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6025 if (offset < 0) // drag up |
7 | 6026 { |
6027 up = TRUE; | |
6028 offset = -offset; | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6029 // sum up the room of the current frame and above it |
7 | 6030 if (fr == curfr) |
6031 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6032 // only one window |
7 | 6033 room = fr->fr_height - frame_minheight(fr, NULL); |
6034 } | |
6035 else | |
6036 { | |
6037 room = 0; | |
6038 for (fr = fr->fr_child; ; fr = fr->fr_next) | |
6039 { | |
6040 room += fr->fr_height - frame_minheight(fr, NULL); | |
6041 if (fr == curfr) | |
6042 break; | |
6043 } | |
6044 } | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6045 fr = curfr->fr_next; // put fr at frame that grows |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6046 } |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6047 else // drag down |
7 | 6048 { |
6049 up = FALSE; | |
6050 /* | |
6051 * Only dragging the last status line can reduce p_ch. | |
6052 */ | |
6053 room = Rows - cmdline_row; | |
6054 if (curfr->fr_next == NULL) | |
6055 room -= 1; | |
6056 else | |
6057 room -= p_ch; | |
6058 if (room < 0) | |
6059 room = 0; | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6060 // sum up the room of frames below of the current one |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
6061 FOR_ALL_FRAMES(fr, curfr->fr_next) |
7 | 6062 room += fr->fr_height - frame_minheight(fr, NULL); |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6063 fr = curfr; // put fr at window that grows |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6064 } |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6065 |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6066 if (room < offset) // Not enough room |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6067 offset = room; // Move as far as we can |
7 | 6068 if (offset <= 0) |
6069 return; | |
6070 | |
6071 /* | |
6072 * Grow frame fr by "offset" lines. | |
6073 * Doesn't happen when dragging the last status line up. | |
6074 */ | |
6075 if (fr != NULL) | |
6076 frame_new_height(fr, fr->fr_height + offset, up, FALSE); | |
6077 | |
6078 if (up) | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6079 fr = curfr; // current frame gets smaller |
7 | 6080 else |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6081 fr = curfr->fr_next; // next frame gets smaller |
7 | 6082 |
6083 /* | |
6084 * Now make the other frames smaller. | |
6085 */ | |
6086 while (fr != NULL && offset > 0) | |
6087 { | |
6088 n = frame_minheight(fr, NULL); | |
6089 if (fr->fr_height - offset <= n) | |
6090 { | |
6091 offset -= fr->fr_height - n; | |
6092 frame_new_height(fr, n, !up, FALSE); | |
6093 } | |
6094 else | |
6095 { | |
6096 frame_new_height(fr, fr->fr_height - offset, !up, FALSE); | |
6097 break; | |
6098 } | |
6099 if (up) | |
6100 fr = fr->fr_prev; | |
6101 else | |
6102 fr = fr->fr_next; | |
6103 } | |
6104 row = win_comp_pos(); | |
6105 screen_fill(row, cmdline_row, 0, (int)Columns, ' ', ' ', 0); | |
6106 cmdline_row = row; | |
6107 p_ch = Rows - cmdline_row; | |
6108 if (p_ch < 1) | |
6109 p_ch = 1; | |
824 | 6110 curtab->tp_ch_used = p_ch; |
737 | 6111 redraw_all_later(SOME_VALID); |
7 | 6112 showmode(); |
6113 } | |
6114 | |
6115 /* | |
6116 * Separator line of dragwin is dragged "offset" lines right (negative is left). | |
6117 */ | |
6118 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6119 win_drag_vsep_line(win_T *dragwin, int offset) |
7 | 6120 { |
6121 frame_T *curfr; | |
6122 frame_T *fr; | |
6123 int room; | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6124 int left; // if TRUE, drag separator line left, otherwise right |
7 | 6125 int n; |
6126 | |
6127 fr = dragwin->w_frame; | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6128 if (fr == topframe) // only one window (cannot happen?) |
7 | 6129 return; |
6130 curfr = fr; | |
6131 fr = fr->fr_parent; | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6132 // When the parent frame is not a row of frames, its parent should be. |
7 | 6133 if (fr->fr_layout != FR_ROW) |
6134 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6135 if (fr == topframe) // only a column of windows (cannot happen?) |
7 | 6136 return; |
6137 curfr = fr; | |
6138 fr = fr->fr_parent; | |
6139 } | |
6140 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6141 // If this is the last frame in a row, may want to resize a parent |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6142 // frame instead. |
7 | 6143 while (curfr->fr_next == NULL) |
6144 { | |
6145 if (fr == topframe) | |
6146 break; | |
6147 curfr = fr; | |
6148 fr = fr->fr_parent; | |
6149 if (fr != topframe) | |
6150 { | |
6151 curfr = fr; | |
6152 fr = fr->fr_parent; | |
6153 } | |
6154 } | |
6155 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6156 if (offset < 0) // drag left |
7 | 6157 { |
6158 left = TRUE; | |
6159 offset = -offset; | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6160 // sum up the room of the current frame and left of it |
7 | 6161 room = 0; |
6162 for (fr = fr->fr_child; ; fr = fr->fr_next) | |
6163 { | |
6164 room += fr->fr_width - frame_minwidth(fr, NULL); | |
6165 if (fr == curfr) | |
6166 break; | |
6167 } | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6168 fr = curfr->fr_next; // put fr at frame that grows |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6169 } |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6170 else // drag right |
7 | 6171 { |
6172 left = FALSE; | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6173 // sum up the room of frames right of the current one |
7 | 6174 room = 0; |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
6175 FOR_ALL_FRAMES(fr, curfr->fr_next) |
7 | 6176 room += fr->fr_width - frame_minwidth(fr, NULL); |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6177 fr = curfr; // put fr at window that grows |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6178 } |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6179 |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6180 if (room < offset) // Not enough room |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6181 offset = room; // Move as far as we can |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6182 if (offset <= 0) // No room at all, quit. |
7 | 6183 return; |
7256
79270eaac6de
commit https://github.com/vim/vim/commit/294a7e55b01149154807a23323038784549b8946
Christian Brabandt <cb@256bit.org>
parents:
7229
diff
changeset
|
6184 if (fr == NULL) |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6185 return; // Safety check, should not happen. |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6186 |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6187 // grow frame fr by offset lines |
779 | 6188 frame_new_width(fr, fr->fr_width + offset, left, FALSE); |
7 | 6189 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6190 // shrink other frames: current and at the left or at the right |
7 | 6191 if (left) |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6192 fr = curfr; // current frame gets smaller |
7 | 6193 else |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6194 fr = curfr->fr_next; // next frame gets smaller |
7 | 6195 |
6196 while (fr != NULL && offset > 0) | |
6197 { | |
6198 n = frame_minwidth(fr, NULL); | |
6199 if (fr->fr_width - offset <= n) | |
6200 { | |
6201 offset -= fr->fr_width - n; | |
779 | 6202 frame_new_width(fr, n, !left, FALSE); |
7 | 6203 } |
6204 else | |
6205 { | |
779 | 6206 frame_new_width(fr, fr->fr_width - offset, !left, FALSE); |
7 | 6207 break; |
6208 } | |
6209 if (left) | |
6210 fr = fr->fr_prev; | |
6211 else | |
6212 fr = fr->fr_next; | |
6213 } | |
6214 (void)win_comp_pos(); | |
6215 redraw_all_later(NOT_VALID); | |
6216 } | |
6217 | |
2665 | 6218 #define FRACTION_MULT 16384L |
6219 | |
6220 /* | |
6221 * 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
|
6222 * Has no effect when the window is less than two lines. |
2665 | 6223 */ |
7311
743c258ca3ab
commit https://github.com/vim/vim/commit/9dc2ce398bb3456cc8f590ef0260459798b34d2a
Christian Brabandt <cb@256bit.org>
parents:
7256
diff
changeset
|
6224 void |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6225 set_fraction(win_T *wp) |
2665 | 6226 { |
12910
d21adefd4a50
patch 8.0.1331: possible crash when window can be zero lines high
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
6227 if (wp->w_height > 1) |
15977
7fbdceabad64
patch 8.1.0994: relative cursor position is not calculated correctly
Bram Moolenaar <Bram@vim.org>
parents:
15937
diff
changeset
|
6228 // When cursor is in the first line the percentage is computed as if |
7fbdceabad64
patch 8.1.0994: relative cursor position is not calculated correctly
Bram Moolenaar <Bram@vim.org>
parents:
15937
diff
changeset
|
6229 // it's halfway that line. Thus with two lines it is 25%, with three |
7fbdceabad64
patch 8.1.0994: relative cursor position is not calculated correctly
Bram Moolenaar <Bram@vim.org>
parents:
15937
diff
changeset
|
6230 // lines 17%, etc. Similarly for the last line: 75%, 83%, etc. |
12910
d21adefd4a50
patch 8.0.1331: possible crash when window can be zero lines high
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
6231 wp->w_fraction = ((long)wp->w_wrow * FRACTION_MULT |
15977
7fbdceabad64
patch 8.1.0994: relative cursor position is not calculated correctly
Bram Moolenaar <Bram@vim.org>
parents:
15937
diff
changeset
|
6232 + FRACTION_MULT / 2) / (long)wp->w_height; |
2665 | 6233 } |
6234 | |
7 | 6235 /* |
6236 * 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
|
6237 * "height" excludes any window toolbar. |
7 | 6238 * This takes care of the things inside the window, not what happens to the |
6239 * window position, the frame or to other windows. | |
6240 */ | |
3697 | 6241 void |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6242 win_new_height(win_T *wp, int height) |
7 | 6243 { |
5875 | 6244 int prev_height = wp->w_height; |
7 | 6245 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6246 // Don't want a negative height. Happens when splitting a tiny window. |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6247 // Will equalize heights soon to fix it. |
7 | 6248 if (height < 0) |
6249 height = 0; | |
826 | 6250 if (wp->w_height == height) |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6251 return; // nothing to do |
7 | 6252 |
5875 | 6253 if (wp->w_height > 0) |
6254 { | |
6255 if (wp == curwin) | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6256 // w_wrow needs to be valid. When setting 'laststatus' this may |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6257 // call win_new_height() recursively. |
5969 | 6258 validate_cursor(); |
6259 if (wp->w_height != prev_height) | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6260 return; // Recursive call already changed the size, bail out here |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6261 // to avoid the following to mess things up. |
5875 | 6262 if (wp->w_wrow != wp->w_prev_fraction_row) |
6263 set_fraction(wp); | |
6264 } | |
7 | 6265 |
6266 wp->w_height = height; | |
6267 wp->w_skipcol = 0; | |
6268 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6269 // There is no point in adjusting the scroll position when exiting. Some |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6270 // values might be invalid. |
10835
c9da7f9137af
patch 8.0.0307: asan detects a memory error when EXITFREE is defined
Christian Brabandt <cb@256bit.org>
parents:
10377
diff
changeset
|
6271 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
|
6272 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
|
6273 } |
942d40a92be6
commit https://github.com/vim/vim/commit/46328f9a1cc8047d1e05095bc9f531038c5a4028
Christian Brabandt <cb@256bit.org>
parents:
9953
diff
changeset
|
6274 |
942d40a92be6
commit https://github.com/vim/vim/commit/46328f9a1cc8047d1e05095bc9f531038c5a4028
Christian Brabandt <cb@256bit.org>
parents:
9953
diff
changeset
|
6275 void |
942d40a92be6
commit https://github.com/vim/vim/commit/46328f9a1cc8047d1e05095bc9f531038c5a4028
Christian Brabandt <cb@256bit.org>
parents:
9953
diff
changeset
|
6276 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
|
6277 { |
942d40a92be6
commit https://github.com/vim/vim/commit/46328f9a1cc8047d1e05095bc9f531038c5a4028
Christian Brabandt <cb@256bit.org>
parents:
9953
diff
changeset
|
6278 linenr_T lnum; |
942d40a92be6
commit https://github.com/vim/vim/commit/46328f9a1cc8047d1e05095bc9f531038c5a4028
Christian Brabandt <cb@256bit.org>
parents:
9953
diff
changeset
|
6279 int sline, line_size; |
942d40a92be6
commit https://github.com/vim/vim/commit/46328f9a1cc8047d1e05095bc9f531038c5a4028
Christian Brabandt <cb@256bit.org>
parents:
9953
diff
changeset
|
6280 int height = wp->w_height; |
942d40a92be6
commit https://github.com/vim/vim/commit/46328f9a1cc8047d1e05095bc9f531038c5a4028
Christian Brabandt <cb@256bit.org>
parents:
9953
diff
changeset
|
6281 |
16650
06fd0eaada01
patch 8.1.1327: unnecessary scroll after horizontal split
Bram Moolenaar <Bram@vim.org>
parents:
16477
diff
changeset
|
6282 // Don't change w_topline in any of these cases: |
06fd0eaada01
patch 8.1.1327: unnecessary scroll after horizontal split
Bram Moolenaar <Bram@vim.org>
parents:
16477
diff
changeset
|
6283 // - window height is 0 |
06fd0eaada01
patch 8.1.1327: unnecessary scroll after horizontal split
Bram Moolenaar <Bram@vim.org>
parents:
16477
diff
changeset
|
6284 // - 'scrollbind' is set and this isn't the current window |
16690
4e3c4e8e465c
patch 8.1.1347: fractional scroll position not restored after closing window
Bram Moolenaar <Bram@vim.org>
parents:
16650
diff
changeset
|
6285 // - window height is sufficient to display the whole buffer and first line |
4e3c4e8e465c
patch 8.1.1347: fractional scroll position not restored after closing window
Bram Moolenaar <Bram@vim.org>
parents:
16650
diff
changeset
|
6286 // is visible. |
16650
06fd0eaada01
patch 8.1.1327: unnecessary scroll after horizontal split
Bram Moolenaar <Bram@vim.org>
parents:
16477
diff
changeset
|
6287 if (height > 0 |
06fd0eaada01
patch 8.1.1327: unnecessary scroll after horizontal split
Bram Moolenaar <Bram@vim.org>
parents:
16477
diff
changeset
|
6288 && (!wp->w_p_scb || wp == curwin) |
16690
4e3c4e8e465c
patch 8.1.1347: fractional scroll position not restored after closing window
Bram Moolenaar <Bram@vim.org>
parents:
16650
diff
changeset
|
6289 && (height < wp->w_buffer->b_ml.ml_line_count || wp->w_topline > 1)) |
7 | 6290 { |
47 | 6291 /* |
6292 * Find a value for w_topline that shows the cursor at the same | |
6293 * relative position in the window as before (more or less). | |
6294 */ | |
7 | 6295 lnum = wp->w_cursor.lnum; |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6296 if (lnum < 1) // can happen when starting up |
7 | 6297 lnum = 1; |
15977
7fbdceabad64
patch 8.1.0994: relative cursor position is not calculated correctly
Bram Moolenaar <Bram@vim.org>
parents:
15937
diff
changeset
|
6298 wp->w_wrow = ((long)wp->w_fraction * (long)height - 1L) |
7fbdceabad64
patch 8.1.0994: relative cursor position is not calculated correctly
Bram Moolenaar <Bram@vim.org>
parents:
15937
diff
changeset
|
6299 / FRACTION_MULT; |
7 | 6300 line_size = plines_win_col(wp, lnum, (long)(wp->w_cursor.col)) - 1; |
6301 sline = wp->w_wrow - line_size; | |
1023 | 6302 |
6303 if (sline >= 0) | |
6304 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6305 // Make sure the whole cursor line is visible, if possible. |
1023 | 6306 int rows = plines_win(wp, lnum, FALSE); |
6307 | |
6308 if (sline > wp->w_height - rows) | |
6309 { | |
6310 sline = wp->w_height - rows; | |
6311 wp->w_wrow -= rows - line_size; | |
6312 } | |
6313 } | |
6314 | |
7 | 6315 if (sline < 0) |
6316 { | |
6317 /* | |
6318 * Cursor line would go off top of screen if w_wrow was this high. | |
1023 | 6319 * Make cursor line the first line in the window. If not enough |
6320 * room use w_skipcol; | |
7 | 6321 */ |
6322 wp->w_wrow = line_size; | |
1023 | 6323 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
|
6324 && (wp->w_width - win_col_off(wp)) > 0) |
1023 | 6325 { |
12515
972ea22c946f
patch 8.0.1136: W_WIDTH() is always the same
Christian Brabandt <cb@256bit.org>
parents:
12513
diff
changeset
|
6326 wp->w_skipcol += wp->w_width - win_col_off(wp); |
1023 | 6327 --wp->w_wrow; |
6328 while (wp->w_wrow >= wp->w_height) | |
6329 { | |
12515
972ea22c946f
patch 8.0.1136: W_WIDTH() is always the same
Christian Brabandt <cb@256bit.org>
parents:
12513
diff
changeset
|
6330 wp->w_skipcol += wp->w_width - win_col_off(wp) |
1023 | 6331 + win_col_off2(wp); |
6332 --wp->w_wrow; | |
6333 } | |
6334 } | |
7 | 6335 } |
5936 | 6336 else if (sline > 0) |
7 | 6337 { |
1023 | 6338 while (sline > 0 && lnum > 1) |
7 | 6339 { |
6340 #ifdef FEAT_FOLDING | |
6341 hasFoldingWin(wp, lnum, &lnum, NULL, TRUE, NULL); | |
6342 if (lnum == 1) | |
6343 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6344 // first line in buffer is folded |
7 | 6345 line_size = 1; |
6346 --sline; | |
6347 break; | |
6348 } | |
6349 #endif | |
6350 --lnum; | |
6351 #ifdef FEAT_DIFF | |
6352 if (lnum == wp->w_topline) | |
6353 line_size = plines_win_nofill(wp, lnum, TRUE) | |
6354 + wp->w_topfill; | |
6355 else | |
6356 #endif | |
6357 line_size = plines_win(wp, lnum, TRUE); | |
6358 sline -= line_size; | |
6359 } | |
47 | 6360 |
7 | 6361 if (sline < 0) |
6362 { | |
6363 /* | |
6364 * Line we want at top would go off top of screen. Use next | |
6365 * line instead. | |
6366 */ | |
6367 #ifdef FEAT_FOLDING | |
6368 hasFoldingWin(wp, lnum, NULL, &lnum, TRUE, NULL); | |
6369 #endif | |
6370 lnum++; | |
6371 wp->w_wrow -= line_size + sline; | |
6372 } | |
5936 | 6373 else if (sline > 0) |
7 | 6374 { |
15977
7fbdceabad64
patch 8.1.0994: relative cursor position is not calculated correctly
Bram Moolenaar <Bram@vim.org>
parents:
15937
diff
changeset
|
6375 // First line of file reached, use that as topline. |
7 | 6376 lnum = 1; |
6377 wp->w_wrow -= sline; | |
6378 } | |
6379 } | |
15977
7fbdceabad64
patch 8.1.0994: relative cursor position is not calculated correctly
Bram Moolenaar <Bram@vim.org>
parents:
15937
diff
changeset
|
6380 set_topline(wp, lnum); |
7 | 6381 } |
6382 | |
6383 if (wp == curwin) | |
6384 { | |
15713
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15636
diff
changeset
|
6385 if (get_scrolloff_value()) |
7 | 6386 update_topline(); |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6387 curs_columns(FALSE); // validate w_wrow |
7 | 6388 } |
5875 | 6389 if (prev_height > 0) |
6390 wp->w_prev_fraction_row = wp->w_wrow; | |
7 | 6391 |
6392 win_comp_scroll(wp); | |
737 | 6393 redraw_win_later(wp, SOME_VALID); |
7 | 6394 wp->w_redr_status = TRUE; |
6395 invalidate_botline_win(wp); | |
6396 } | |
6397 | |
6398 /* | |
6399 * Set the width of a window. | |
6400 */ | |
3697 | 6401 void |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6402 win_new_width(win_T *wp, int width) |
7 | 6403 { |
6404 wp->w_width = width; | |
6405 wp->w_lines_valid = 0; | |
6406 changed_line_abv_curs_win(wp); | |
6407 invalidate_botline_win(wp); | |
6408 if (wp == curwin) | |
6409 { | |
6410 update_topline(); | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6411 curs_columns(TRUE); // validate w_wrow |
7 | 6412 } |
6413 redraw_win_later(wp, NOT_VALID); | |
6414 wp->w_redr_status = TRUE; | |
6415 } | |
6416 | |
6417 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6418 win_comp_scroll(win_T *wp) |
7 | 6419 { |
23386
3105546b941f
patch 8.2.2236: 'scroll' option can change when setting the statusline
Bram Moolenaar <Bram@vim.org>
parents:
22900
diff
changeset
|
6420 #if defined(FEAT_EVAL) |
3105546b941f
patch 8.2.2236: 'scroll' option can change when setting the statusline
Bram Moolenaar <Bram@vim.org>
parents:
22900
diff
changeset
|
6421 int old_w_p_scr = wp->w_p_scr; |
3105546b941f
patch 8.2.2236: 'scroll' option can change when setting the statusline
Bram Moolenaar <Bram@vim.org>
parents:
22900
diff
changeset
|
6422 #endif |
3105546b941f
patch 8.2.2236: 'scroll' option can change when setting the statusline
Bram Moolenaar <Bram@vim.org>
parents:
22900
diff
changeset
|
6423 |
7 | 6424 wp->w_p_scr = ((unsigned)wp->w_height >> 1); |
6425 if (wp->w_p_scr == 0) | |
6426 wp->w_p_scr = 1; | |
23386
3105546b941f
patch 8.2.2236: 'scroll' option can change when setting the statusline
Bram Moolenaar <Bram@vim.org>
parents:
22900
diff
changeset
|
6427 #if defined(FEAT_EVAL) |
3105546b941f
patch 8.2.2236: 'scroll' option can change when setting the statusline
Bram Moolenaar <Bram@vim.org>
parents:
22900
diff
changeset
|
6428 if (wp->w_p_scr != old_w_p_scr) |
3105546b941f
patch 8.2.2236: 'scroll' option can change when setting the statusline
Bram Moolenaar <Bram@vim.org>
parents:
22900
diff
changeset
|
6429 { |
3105546b941f
patch 8.2.2236: 'scroll' option can change when setting the statusline
Bram Moolenaar <Bram@vim.org>
parents:
22900
diff
changeset
|
6430 // Used by "verbose set scroll". |
3105546b941f
patch 8.2.2236: 'scroll' option can change when setting the statusline
Bram Moolenaar <Bram@vim.org>
parents:
22900
diff
changeset
|
6431 wp->w_p_script_ctx[WV_SCROLL].sc_sid = SID_WINLAYOUT; |
3105546b941f
patch 8.2.2236: 'scroll' option can change when setting the statusline
Bram Moolenaar <Bram@vim.org>
parents:
22900
diff
changeset
|
6432 wp->w_p_script_ctx[WV_SCROLL].sc_lnum = 0; |
3105546b941f
patch 8.2.2236: 'scroll' option can change when setting the statusline
Bram Moolenaar <Bram@vim.org>
parents:
22900
diff
changeset
|
6433 } |
3105546b941f
patch 8.2.2236: 'scroll' option can change when setting the statusline
Bram Moolenaar <Bram@vim.org>
parents:
22900
diff
changeset
|
6434 #endif |
7 | 6435 } |
6436 | |
6437 /* | |
6438 * command_height: called whenever p_ch has been changed | |
6439 */ | |
6440 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6441 command_height(void) |
7 | 6442 { |
6443 int h; | |
6444 frame_T *frp; | |
824 | 6445 int old_p_ch = curtab->tp_ch_used; |
6446 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6447 // Use the value of p_ch that we remembered. This is needed for when the |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6448 // GUI starts up, we can't be sure in what order things happen. And when |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6449 // p_ch was changed in another tab page. |
824 | 6450 curtab->tp_ch_used = p_ch; |
170 | 6451 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6452 // Find bottom frame with width of screen. |
7 | 6453 frp = lastwin->w_frame; |
6454 while (frp->fr_width != Columns && frp->fr_parent != NULL) | |
6455 frp = frp->fr_parent; | |
6456 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6457 // Avoid changing the height of a window with 'winfixheight' set. |
7 | 6458 while (frp->fr_prev != NULL && frp->fr_layout == FR_LEAF |
6459 && frp->fr_win->w_p_wfh) | |
6460 frp = frp->fr_prev; | |
6461 | |
6462 if (starting != NO_SCREEN) | |
6463 { | |
6464 cmdline_row = Rows - p_ch; | |
6465 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6466 if (p_ch > old_p_ch) // p_ch got bigger |
7 | 6467 { |
6468 while (p_ch > old_p_ch) | |
6469 { | |
6470 if (frp == NULL) | |
6471 { | |
25306
078edc1821bf
patch 8.2.3190: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
25157
diff
changeset
|
6472 emsg(_(e_not_enough_room)); |
7 | 6473 p_ch = old_p_ch; |
1404 | 6474 curtab->tp_ch_used = p_ch; |
7 | 6475 cmdline_row = Rows - p_ch; |
6476 break; | |
6477 } | |
6478 h = frp->fr_height - frame_minheight(frp, NULL); | |
6479 if (h > p_ch - old_p_ch) | |
6480 h = p_ch - old_p_ch; | |
6481 old_p_ch += h; | |
6482 frame_add_height(frp, -h); | |
6483 frp = frp->fr_prev; | |
6484 } | |
6485 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6486 // Recompute window positions. |
7 | 6487 (void)win_comp_pos(); |
6488 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6489 // clear the lines added to cmdline |
7 | 6490 if (full_screen) |
6491 screen_fill((int)(cmdline_row), (int)Rows, 0, | |
6492 (int)Columns, ' ', ' ', 0); | |
6493 msg_row = cmdline_row; | |
6494 redraw_cmdline = TRUE; | |
6495 return; | |
6496 } | |
6497 | |
6498 if (msg_row < cmdline_row) | |
6499 msg_row = cmdline_row; | |
6500 redraw_cmdline = TRUE; | |
6501 } | |
6502 frame_add_height(frp, (int)(old_p_ch - p_ch)); | |
6503 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6504 // Recompute window positions. |
7 | 6505 if (frp != lastwin->w_frame) |
6506 (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
|
6507 } |
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
6508 |
7 | 6509 /* |
6510 * Resize frame "frp" to be "n" lines higher (negative for less high). | |
6511 * Also resize the frames it is contained in. | |
6512 */ | |
6513 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6514 frame_add_height(frame_T *frp, int n) |
7 | 6515 { |
6516 frame_new_height(frp, frp->fr_height + n, FALSE, FALSE); | |
6517 for (;;) | |
6518 { | |
6519 frp = frp->fr_parent; | |
6520 if (frp == NULL) | |
6521 break; | |
6522 frp->fr_height += n; | |
6523 } | |
6524 } | |
6525 | |
6526 /* | |
6527 * Add or remove a status line for the bottom window(s), according to the | |
6528 * value of 'laststatus'. | |
6529 */ | |
6530 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6531 last_status( |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6532 int morewin) // pretend there are two or more windows |
7 | 6533 { |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6534 // Don't make a difference between horizontal or vertical split. |
7 | 6535 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
|
6536 || (p_ls == 1 && (morewin || !ONE_WINDOW)))); |
7 | 6537 } |
6538 | |
6539 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6540 last_status_rec(frame_T *fr, int statusline) |
7 | 6541 { |
6542 frame_T *fp; | |
6543 win_T *wp; | |
6544 | |
6545 if (fr->fr_layout == FR_LEAF) | |
6546 { | |
6547 wp = fr->fr_win; | |
6548 if (wp->w_status_height != 0 && !statusline) | |
6549 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6550 // remove status line |
7 | 6551 win_new_height(wp, wp->w_height + 1); |
6552 wp->w_status_height = 0; | |
6553 comp_col(); | |
6554 } | |
6555 else if (wp->w_status_height == 0 && statusline) | |
6556 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6557 // Find a frame to take a line from. |
7 | 6558 fp = fr; |
6559 while (fp->fr_height <= frame_minheight(fp, NULL)) | |
6560 { | |
6561 if (fp == topframe) | |
6562 { | |
25306
078edc1821bf
patch 8.2.3190: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
25157
diff
changeset
|
6563 emsg(_(e_not_enough_room)); |
7 | 6564 return; |
6565 } | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6566 // In a column of frames: go to frame above. If already at |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6567 // the top or in a row of frames: go to parent. |
7 | 6568 if (fp->fr_parent->fr_layout == FR_COL && fp->fr_prev != NULL) |
6569 fp = fp->fr_prev; | |
6570 else | |
6571 fp = fp->fr_parent; | |
6572 } | |
6573 wp->w_status_height = 1; | |
6574 if (fp != fr) | |
6575 { | |
6576 frame_new_height(fp, fp->fr_height - 1, FALSE, FALSE); | |
6577 frame_fix_height(wp); | |
6578 (void)win_comp_pos(); | |
6579 } | |
6580 else | |
6581 win_new_height(wp, wp->w_height - 1); | |
6582 comp_col(); | |
737 | 6583 redraw_all_later(SOME_VALID); |
7 | 6584 } |
6585 } | |
6586 else if (fr->fr_layout == FR_ROW) | |
6587 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6588 // vertically split windows, set status line for each one |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
6589 FOR_ALL_FRAMES(fp, fr->fr_child) |
7 | 6590 last_status_rec(fp, statusline); |
6591 } | |
6592 else | |
6593 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6594 // horizontally split window, set status line for last one |
7 | 6595 for (fp = fr->fr_child; fp->fr_next != NULL; fp = fp->fr_next) |
6596 ; | |
6597 last_status_rec(fp, statusline); | |
6598 } | |
6599 } | |
6600 | |
667 | 6601 /* |
668 | 6602 * Return the number of lines used by the tab page line. |
667 | 6603 */ |
6604 int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6605 tabline_height(void) |
667 | 6606 { |
685 | 6607 #ifdef FEAT_GUI_TABLINE |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6608 // When the GUI has the tabline then this always returns zero. |
685 | 6609 if (gui_use_tabline()) |
6610 return 0; | |
6611 #endif | |
675 | 6612 switch (p_stal) |
668 | 6613 { |
6614 case 0: return 0; | |
6615 case 1: return (first_tabpage->tp_next == NULL) ? 0 : 1; | |
6616 } | |
667 | 6617 return 1; |
6618 } | |
6619 | |
7 | 6620 /* |
6621 * Return the minimal number of rows that is needed on the screen to display | |
6622 * the current number of windows. | |
6623 */ | |
6624 int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6625 min_rows(void) |
7 | 6626 { |
6627 int total; | |
671 | 6628 tabpage_T *tp; |
6629 int n; | |
7 | 6630 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6631 if (firstwin == NULL) // not initialized yet |
7 | 6632 return MIN_LINES; |
6633 | |
671 | 6634 total = 0; |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9599
diff
changeset
|
6635 FOR_ALL_TABPAGES(tp) |
671 | 6636 { |
6637 n = frame_minheight(tp->tp_topframe, NULL); | |
6638 if (total < n) | |
6639 total = n; | |
6640 } | |
685 | 6641 total += tabline_height(); |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6642 total += 1; // count the room for the command line |
7 | 6643 return total; |
6644 } | |
6645 | |
6646 /* | |
18467
99fc29219b3e
patch 8.1.2227: layout wrong if 'lines' changes while cmdline window is open
Bram Moolenaar <Bram@vim.org>
parents:
18354
diff
changeset
|
6647 * Return TRUE if there is only one window and only one tab page, not |
672 | 6648 * counting a help or preview window, unless it is the current window. |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
6649 * Does not count unlisted windows. |
7 | 6650 */ |
6651 int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6652 only_one_window(void) |
7 | 6653 { |
6654 int count = 0; | |
6655 win_T *wp; | |
6656 | |
19275
2142fb624658
patch 8.2.0196: blocking commands for a finished job in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19271
diff
changeset
|
6657 #if defined(FEAT_PROP_POPUP) |
2142fb624658
patch 8.2.0196: blocking commands for a finished job in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19271
diff
changeset
|
6658 // If the current window is a popup then there always is another window. |
2142fb624658
patch 8.2.0196: blocking commands for a finished job in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19271
diff
changeset
|
6659 if (popup_is_popup(curwin)) |
2142fb624658
patch 8.2.0196: blocking commands for a finished job in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19271
diff
changeset
|
6660 return FALSE; |
2142fb624658
patch 8.2.0196: blocking commands for a finished job in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19271
diff
changeset
|
6661 #endif |
2142fb624658
patch 8.2.0196: blocking commands for a finished job in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19271
diff
changeset
|
6662 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6663 // If there is another tab page there always is another window. |
667 | 6664 if (first_tabpage->tp_next != NULL) |
6665 return FALSE; | |
6666 | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9599
diff
changeset
|
6667 FOR_ALL_WINDOWS(wp) |
4021 | 6668 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
|
6669 && (!((bt_help(wp->w_buffer) && !bt_help(curbuf)) |
7 | 6670 # ifdef FEAT_QUICKFIX |
6671 || wp->w_p_pvw | |
6672 # endif | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13308
diff
changeset
|
6673 ) || wp == curwin) && wp != aucmd_win) |
7 | 6674 ++count; |
6675 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
|
6676 } |
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
6677 |
7 | 6678 /* |
6679 * Correct the cursor line number in other windows. Used after changing the | |
6680 * current buffer, and before applying autocommands. | |
6681 * When "do_curwin" is TRUE, also check current window. | |
6682 */ | |
6683 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6684 check_lnums(int do_curwin) |
7 | 6685 { |
6686 win_T *wp; | |
671 | 6687 tabpage_T *tp; |
6688 | |
6689 FOR_ALL_TAB_WINDOWS(tp, wp) | |
7 | 6690 if ((do_curwin || wp != curwin) && wp->w_buffer == curbuf) |
6691 { | |
16401
3b2db762a509
patch 8.1.1205: a BufReadPre autocommand may cause the cursor to move
Bram Moolenaar <Bram@vim.org>
parents:
16354
diff
changeset
|
6692 // save the original cursor position and topline |
3b2db762a509
patch 8.1.1205: a BufReadPre autocommand may cause the cursor to move
Bram Moolenaar <Bram@vim.org>
parents:
16354
diff
changeset
|
6693 wp->w_save_cursor.w_cursor_save = wp->w_cursor; |
3b2db762a509
patch 8.1.1205: a BufReadPre autocommand may cause the cursor to move
Bram Moolenaar <Bram@vim.org>
parents:
16354
diff
changeset
|
6694 wp->w_save_cursor.w_topline_save = wp->w_topline; |
3b2db762a509
patch 8.1.1205: a BufReadPre autocommand may cause the cursor to move
Bram Moolenaar <Bram@vim.org>
parents:
16354
diff
changeset
|
6695 |
7 | 6696 if (wp->w_cursor.lnum > curbuf->b_ml.ml_line_count) |
6697 wp->w_cursor.lnum = curbuf->b_ml.ml_line_count; | |
6698 if (wp->w_topline > curbuf->b_ml.ml_line_count) | |
6699 wp->w_topline = curbuf->b_ml.ml_line_count; | |
16401
3b2db762a509
patch 8.1.1205: a BufReadPre autocommand may cause the cursor to move
Bram Moolenaar <Bram@vim.org>
parents:
16354
diff
changeset
|
6700 |
3b2db762a509
patch 8.1.1205: a BufReadPre autocommand may cause the cursor to move
Bram Moolenaar <Bram@vim.org>
parents:
16354
diff
changeset
|
6701 // save the corrected cursor position and topline |
3b2db762a509
patch 8.1.1205: a BufReadPre autocommand may cause the cursor to move
Bram Moolenaar <Bram@vim.org>
parents:
16354
diff
changeset
|
6702 wp->w_save_cursor.w_cursor_corr = wp->w_cursor; |
3b2db762a509
patch 8.1.1205: a BufReadPre autocommand may cause the cursor to move
Bram Moolenaar <Bram@vim.org>
parents:
16354
diff
changeset
|
6703 wp->w_save_cursor.w_topline_corr = wp->w_topline; |
3b2db762a509
patch 8.1.1205: a BufReadPre autocommand may cause the cursor to move
Bram Moolenaar <Bram@vim.org>
parents:
16354
diff
changeset
|
6704 } |
3b2db762a509
patch 8.1.1205: a BufReadPre autocommand may cause the cursor to move
Bram Moolenaar <Bram@vim.org>
parents:
16354
diff
changeset
|
6705 } |
3b2db762a509
patch 8.1.1205: a BufReadPre autocommand may cause the cursor to move
Bram Moolenaar <Bram@vim.org>
parents:
16354
diff
changeset
|
6706 |
3b2db762a509
patch 8.1.1205: a BufReadPre autocommand may cause the cursor to move
Bram Moolenaar <Bram@vim.org>
parents:
16354
diff
changeset
|
6707 /* |
3b2db762a509
patch 8.1.1205: a BufReadPre autocommand may cause the cursor to move
Bram Moolenaar <Bram@vim.org>
parents:
16354
diff
changeset
|
6708 * Reset cursor and topline to its stored values from check_lnums(). |
3b2db762a509
patch 8.1.1205: a BufReadPre autocommand may cause the cursor to move
Bram Moolenaar <Bram@vim.org>
parents:
16354
diff
changeset
|
6709 * check_lnums() must have been called first! |
3b2db762a509
patch 8.1.1205: a BufReadPre autocommand may cause the cursor to move
Bram Moolenaar <Bram@vim.org>
parents:
16354
diff
changeset
|
6710 */ |
3b2db762a509
patch 8.1.1205: a BufReadPre autocommand may cause the cursor to move
Bram Moolenaar <Bram@vim.org>
parents:
16354
diff
changeset
|
6711 void |
3b2db762a509
patch 8.1.1205: a BufReadPre autocommand may cause the cursor to move
Bram Moolenaar <Bram@vim.org>
parents:
16354
diff
changeset
|
6712 reset_lnums() |
3b2db762a509
patch 8.1.1205: a BufReadPre autocommand may cause the cursor to move
Bram Moolenaar <Bram@vim.org>
parents:
16354
diff
changeset
|
6713 { |
3b2db762a509
patch 8.1.1205: a BufReadPre autocommand may cause the cursor to move
Bram Moolenaar <Bram@vim.org>
parents:
16354
diff
changeset
|
6714 win_T *wp; |
3b2db762a509
patch 8.1.1205: a BufReadPre autocommand may cause the cursor to move
Bram Moolenaar <Bram@vim.org>
parents:
16354
diff
changeset
|
6715 tabpage_T *tp; |
3b2db762a509
patch 8.1.1205: a BufReadPre autocommand may cause the cursor to move
Bram Moolenaar <Bram@vim.org>
parents:
16354
diff
changeset
|
6716 |
3b2db762a509
patch 8.1.1205: a BufReadPre autocommand may cause the cursor to move
Bram Moolenaar <Bram@vim.org>
parents:
16354
diff
changeset
|
6717 FOR_ALL_TAB_WINDOWS(tp, wp) |
3b2db762a509
patch 8.1.1205: a BufReadPre autocommand may cause the cursor to move
Bram Moolenaar <Bram@vim.org>
parents:
16354
diff
changeset
|
6718 if (wp->w_buffer == curbuf) |
3b2db762a509
patch 8.1.1205: a BufReadPre autocommand may cause the cursor to move
Bram Moolenaar <Bram@vim.org>
parents:
16354
diff
changeset
|
6719 { |
3b2db762a509
patch 8.1.1205: a BufReadPre autocommand may cause the cursor to move
Bram Moolenaar <Bram@vim.org>
parents:
16354
diff
changeset
|
6720 // Restore the value if the autocommand didn't change it. |
3b2db762a509
patch 8.1.1205: a BufReadPre autocommand may cause the cursor to move
Bram Moolenaar <Bram@vim.org>
parents:
16354
diff
changeset
|
6721 if (EQUAL_POS(wp->w_save_cursor.w_cursor_corr, wp->w_cursor)) |
3b2db762a509
patch 8.1.1205: a BufReadPre autocommand may cause the cursor to move
Bram Moolenaar <Bram@vim.org>
parents:
16354
diff
changeset
|
6722 wp->w_cursor = wp->w_save_cursor.w_cursor_save; |
3b2db762a509
patch 8.1.1205: a BufReadPre autocommand may cause the cursor to move
Bram Moolenaar <Bram@vim.org>
parents:
16354
diff
changeset
|
6723 if (wp->w_save_cursor.w_topline_corr == wp->w_topline) |
3b2db762a509
patch 8.1.1205: a BufReadPre autocommand may cause the cursor to move
Bram Moolenaar <Bram@vim.org>
parents:
16354
diff
changeset
|
6724 wp->w_topline = wp->w_save_cursor.w_topline_save; |
7 | 6725 } |
6726 } | |
6727 | |
6728 /* | |
6729 * A snapshot of the window sizes, to restore them after closing the help | |
6730 * window. | |
6731 * Only these fields are used: | |
6732 * fr_layout | |
6733 * fr_width | |
6734 * fr_height | |
6735 * fr_next | |
6736 * fr_child | |
6737 * fr_win (only valid for the old curwin, NULL otherwise) | |
6738 */ | |
6739 | |
6740 /* | |
6741 * Create a snapshot of the current frame sizes. | |
6742 */ | |
1906 | 6743 void |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6744 make_snapshot(int idx) |
7 | 6745 { |
1906 | 6746 clear_snapshot(curtab, idx); |
6747 make_snapshot_rec(topframe, &curtab->tp_snapshot[idx]); | |
7 | 6748 } |
6749 | |
6750 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6751 make_snapshot_rec(frame_T *fr, frame_T **frp) |
7 | 6752 { |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16802
diff
changeset
|
6753 *frp = ALLOC_CLEAR_ONE(frame_T); |
7 | 6754 if (*frp == NULL) |
6755 return; | |
6756 (*frp)->fr_layout = fr->fr_layout; | |
6757 (*frp)->fr_width = fr->fr_width; | |
6758 (*frp)->fr_height = fr->fr_height; | |
6759 if (fr->fr_next != NULL) | |
6760 make_snapshot_rec(fr->fr_next, &((*frp)->fr_next)); | |
6761 if (fr->fr_child != NULL) | |
6762 make_snapshot_rec(fr->fr_child, &((*frp)->fr_child)); | |
6763 if (fr->fr_layout == FR_LEAF && fr->fr_win == curwin) | |
6764 (*frp)->fr_win = curwin; | |
6765 } | |
6766 | |
6767 /* | |
6768 * Remove any existing snapshot. | |
6769 */ | |
6770 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6771 clear_snapshot(tabpage_T *tp, int idx) |
7 | 6772 { |
1906 | 6773 clear_snapshot_rec(tp->tp_snapshot[idx]); |
6774 tp->tp_snapshot[idx] = NULL; | |
7 | 6775 } |
6776 | |
6777 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6778 clear_snapshot_rec(frame_T *fr) |
7 | 6779 { |
6780 if (fr != NULL) | |
6781 { | |
6782 clear_snapshot_rec(fr->fr_next); | |
6783 clear_snapshot_rec(fr->fr_child); | |
6784 vim_free(fr); | |
6785 } | |
6786 } | |
6787 | |
6788 /* | |
6789 * Restore a previously created snapshot, if there is any. | |
6790 * This is only done if the screen size didn't change and the window layout is | |
6791 * still the same. | |
6792 */ | |
1906 | 6793 void |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6794 restore_snapshot( |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6795 int idx, |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6796 int close_curwin) // closing current window |
7 | 6797 { |
6798 win_T *wp; | |
6799 | |
1906 | 6800 if (curtab->tp_snapshot[idx] != NULL |
6801 && curtab->tp_snapshot[idx]->fr_width == topframe->fr_width | |
6802 && curtab->tp_snapshot[idx]->fr_height == topframe->fr_height | |
6803 && check_snapshot_rec(curtab->tp_snapshot[idx], topframe) == OK) | |
6804 { | |
6805 wp = restore_snapshot_rec(curtab->tp_snapshot[idx], topframe); | |
7 | 6806 win_comp_pos(); |
6807 if (wp != NULL && close_curwin) | |
6808 win_goto(wp); | |
15380
f62d6bd18a49
patch 8.1.0698: clearing the window is used too often
Bram Moolenaar <Bram@vim.org>
parents:
15227
diff
changeset
|
6809 redraw_all_later(NOT_VALID); |
7 | 6810 } |
1906 | 6811 clear_snapshot(curtab, idx); |
7 | 6812 } |
6813 | |
6814 /* | |
6815 * 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
|
6816 * and same children. And the window pointer is valid. |
7 | 6817 */ |
6818 static int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6819 check_snapshot_rec(frame_T *sn, frame_T *fr) |
7 | 6820 { |
6821 if (sn->fr_layout != fr->fr_layout | |
6822 || (sn->fr_next == NULL) != (fr->fr_next == NULL) | |
6823 || (sn->fr_child == NULL) != (fr->fr_child == NULL) | |
6824 || (sn->fr_next != NULL | |
6825 && check_snapshot_rec(sn->fr_next, fr->fr_next) == FAIL) | |
6826 || (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
|
6827 && 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
|
6828 || (sn->fr_win != NULL && !win_valid(sn->fr_win))) |
7 | 6829 return FAIL; |
6830 return OK; | |
6831 } | |
6832 | |
6833 /* | |
6834 * Copy the size of snapshot frame "sn" to frame "fr". Do the same for all | |
6835 * following frames and children. | |
6836 * Returns a pointer to the old current window, or NULL. | |
6837 */ | |
6838 static win_T * | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6839 restore_snapshot_rec(frame_T *sn, frame_T *fr) |
7 | 6840 { |
6841 win_T *wp = NULL; | |
6842 win_T *wp2; | |
6843 | |
6844 fr->fr_height = sn->fr_height; | |
6845 fr->fr_width = sn->fr_width; | |
6846 if (fr->fr_layout == FR_LEAF) | |
6847 { | |
6848 frame_new_height(fr, fr->fr_height, FALSE, FALSE); | |
779 | 6849 frame_new_width(fr, fr->fr_width, FALSE, FALSE); |
7 | 6850 wp = sn->fr_win; |
6851 } | |
6852 if (sn->fr_next != NULL) | |
6853 { | |
6854 wp2 = restore_snapshot_rec(sn->fr_next, fr->fr_next); | |
6855 if (wp2 != NULL) | |
6856 wp = wp2; | |
6857 } | |
6858 if (sn->fr_child != NULL) | |
6859 { | |
6860 wp2 = restore_snapshot_rec(sn->fr_child, fr->fr_child); | |
6861 if (wp2 != NULL) | |
6862 wp = wp2; | |
6863 } | |
6864 return wp; | |
6865 } | |
6866 | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
6867 #if defined(FEAT_GUI) || defined(PROTO) |
7 | 6868 /* |
6869 * Return TRUE if there is any vertically split window. | |
6870 */ | |
6871 int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6872 win_hasvertsplit(void) |
7 | 6873 { |
6874 frame_T *fr; | |
6875 | |
6876 if (topframe->fr_layout == FR_ROW) | |
6877 return TRUE; | |
6878 | |
6879 if (topframe->fr_layout == FR_COL) | |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
6880 FOR_ALL_FRAMES(fr, topframe->fr_child) |
7 | 6881 if (fr->fr_layout == FR_ROW) |
6882 return TRUE; | |
6883 | |
6884 return FALSE; | |
6885 } | |
6886 #endif | |
1326 | 6887 |
4379 | 6888 #if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) || defined(PROTO) |
6889 int | |
4401 | 6890 get_win_number(win_T *wp, win_T *first_win) |
4379 | 6891 { |
6892 int i = 1; | |
6893 win_T *w; | |
6894 | |
4401 | 6895 for (w = first_win; w != NULL && w != wp; w = W_NEXT(w)) |
4379 | 6896 ++i; |
6897 | |
6898 if (w == NULL) | |
6899 return 0; | |
6900 else | |
6901 return i; | |
6902 } | |
4401 | 6903 |
6904 int | |
4936
ae05437a744a
updated for version 7.3.1213
Bram Moolenaar <bram@vim.org>
parents:
4918
diff
changeset
|
6905 get_tab_number(tabpage_T *tp UNUSED) |
4401 | 6906 { |
6907 int i = 1; | |
6908 tabpage_T *t; | |
6909 | |
6910 for (t = first_tabpage; t != NULL && t != tp; t = t->tp_next) | |
6911 ++i; | |
6912 | |
6913 if (t == NULL) | |
6914 return 0; | |
6915 else | |
6916 return i; | |
6917 } | |
6918 #endif | |
5004
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6919 |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6920 /* |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6921 * 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
|
6922 */ |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6923 static int |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6924 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
|
6925 { |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6926 frame_T *frp; |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6927 |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6928 if (topfrp->fr_height != height) |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6929 return FALSE; |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6930 |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6931 if (topfrp->fr_layout == FR_ROW) |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
6932 FOR_ALL_FRAMES(frp, topfrp->fr_child) |
5004
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6933 if (frp->fr_height != height) |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6934 return FALSE; |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6935 |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6936 return TRUE; |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6937 } |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
6938 |
5004
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6939 /* |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6940 * 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
|
6941 */ |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6942 static int |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6943 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
|
6944 { |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6945 frame_T *frp; |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6946 |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6947 if (topfrp->fr_width != width) |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6948 return FALSE; |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6949 |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6950 if (topfrp->fr_layout == FR_COL) |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
6951 FOR_ALL_FRAMES(frp, topfrp->fr_child) |
5004
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6952 if (frp->fr_width != width) |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6953 return FALSE; |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6954 |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6955 return TRUE; |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6956 } |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
6957 |
17940
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6958 #if defined(FEAT_SYN_HL) || defined(PROTO) |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6959 /* |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6960 * Simple int comparison function for use with qsort() |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6961 */ |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6962 static int |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6963 int_cmp(const void *a, const void *b) |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6964 { |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6965 return *(const int *)a - *(const int *)b; |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6966 } |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6967 |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6968 /* |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6969 * Handle setting 'colorcolumn' or 'textwidth' in window "wp". |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6970 * Returns error message, NULL if it's OK. |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6971 */ |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6972 char * |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6973 check_colorcolumn(win_T *wp) |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6974 { |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6975 char_u *s; |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6976 int col; |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6977 int count = 0; |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6978 int color_cols[256]; |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6979 int i; |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6980 int j = 0; |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6981 |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6982 if (wp->w_buffer == NULL) |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6983 return NULL; // buffer was closed |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6984 |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6985 for (s = wp->w_p_cc; *s != NUL && count < 255;) |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6986 { |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6987 if (*s == '-' || *s == '+') |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6988 { |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6989 // -N and +N: add to 'textwidth' |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6990 col = (*s == '-') ? -1 : 1; |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6991 ++s; |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6992 if (!VIM_ISDIGIT(*s)) |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6993 return e_invarg; |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6994 col = col * getdigits(&s); |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6995 if (wp->w_buffer->b_p_tw == 0) |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6996 goto skip; // 'textwidth' not set, skip this item |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6997 col += wp->w_buffer->b_p_tw; |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6998 if (col < 0) |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
6999 goto skip; |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
7000 } |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
7001 else if (VIM_ISDIGIT(*s)) |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
7002 col = getdigits(&s); |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
7003 else |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
7004 return e_invarg; |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
7005 color_cols[count++] = col - 1; // 1-based to 0-based |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
7006 skip: |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
7007 if (*s == NUL) |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
7008 break; |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
7009 if (*s != ',') |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
7010 return e_invarg; |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
7011 if (*++s == NUL) |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
7012 return e_invarg; // illegal trailing comma as in "set cc=80," |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
7013 } |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
7014 |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
7015 vim_free(wp->w_p_cc_cols); |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
7016 if (count == 0) |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
7017 wp->w_p_cc_cols = NULL; |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
7018 else |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
7019 { |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
7020 wp->w_p_cc_cols = ALLOC_MULT(int, count + 1); |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
7021 if (wp->w_p_cc_cols != NULL) |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
7022 { |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
7023 // sort the columns for faster usage on screen redraw inside |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
7024 // win_line() |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
7025 qsort(color_cols, count, sizeof(int), int_cmp); |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
7026 |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
7027 for (i = 0; i < count; ++i) |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
7028 // skip duplicates |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
7029 if (j == 0 || wp->w_p_cc_cols[j - 1] != color_cols[i]) |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
7030 wp->w_p_cc_cols[j++] = color_cols[i]; |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
7031 wp->w_p_cc_cols[j] = -1; // end marker |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
7032 } |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
7033 } |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
7034 |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
7035 return NULL; // no error |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
7036 } |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
7037 #endif |