Mercurial > vim
annotate src/window.c @ 32429:bfc23ba1bba5 v9.0.1546
patch 9.0.1546: some commands for opening a file don't use 'switchbuf'
Commit: https://github.com/vim/vim/commit/54be5fb382d2bf25fd1b17ddab8b21f599019b81
Author: Yegappan Lakshmanan <yegappan@yahoo.com>
Date: Fri May 12 17:49:13 2023 +0100
patch 9.0.1546: some commands for opening a file don't use 'switchbuf'
Problem: Some commands for opening a file don't use 'switchbuf'.
Solution: Use 'switchbuf' for more commands. (Yegappan Lakshmanan,
closes #12383, closes #12381)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 12 May 2023 19:00:04 +0200 |
parents | c114eebb5268 |
children | 48b95cef8fa2 |
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); |
30219
bc8ad1c28b51
patch 9.0.0445: when opening/closing window text moves up/down
Bram Moolenaar <Bram@vim.org>
parents:
30134
diff
changeset
|
28 static void win_fix_scroll(int resize); |
bc8ad1c28b51
patch 9.0.0445: when opening/closing window text moves up/down
Bram Moolenaar <Bram@vim.org>
parents:
30134
diff
changeset
|
29 static void win_fix_cursor(int normal); |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
30 static void frame_new_height(frame_T *topfrp, int height, int topfirst, int wfh); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
31 static int frame_fixed_height(frame_T *frp); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
32 static int frame_fixed_width(frame_T *frp); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
33 static void frame_add_statusline(frame_T *frp); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
34 static void frame_new_width(frame_T *topfrp, int width, int leftfirst, int wfw); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
35 static void frame_add_vsep(frame_T *frp); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
36 static int frame_minwidth(frame_T *topfrp, win_T *next_curwin); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
37 static void frame_fix_width(win_T *wp); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
38 static int win_alloc_firstwin(win_T *oldwin); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
39 static void new_frame(win_T *wp); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
40 static tabpage_T *alloc_tabpage(void); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
41 static int leave_tabpage(buf_T *new_curbuf, int trigger_leave_autocmds); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
42 static void enter_tabpage(tabpage_T *tp, buf_T *old_curbuf, int trigger_enter_autocmds, int trigger_leave_autocmds); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
43 static void frame_fix_height(win_T *wp); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
44 static int frame_minheight(frame_T *topfrp, win_T *next_curwin); |
17789
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17670
diff
changeset
|
45 static int 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
|
46 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
|
47 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
|
48 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
|
49 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
|
50 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
|
51 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
|
52 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
|
53 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
|
54 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
|
55 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
|
56 |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
57 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
|
58 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
|
59 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
|
60 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
|
61 static win_T *restore_snapshot_rec(frame_T *sn, frame_T *fr); |
28688
264fa41e6704
patch 8.2.4868: when closing help window autocmds triggered for wrong window
Bram Moolenaar <Bram@vim.org>
parents:
28429
diff
changeset
|
62 static win_T *get_snapshot_curwin(int idx); |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
63 |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
64 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
|
65 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
|
66 |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7677
diff
changeset
|
67 static win_T *win_alloc(win_T *after, int hidden); |
7 | 68 |
27752
c1d1639b52dd
patch 8.2.4402: missing parenthesis may cause unexpected problems
Bram Moolenaar <Bram@vim.org>
parents:
27659
diff
changeset
|
69 #define NOWIN ((win_T *)-1) // non-existing window |
7 | 70 |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
71 #define ROWS_AVAIL (Rows - p_ch - tabline_height()) |
826 | 72 |
25499
5ebf9bb1cbcd
patch 8.2.3286: win_enter_ext() has too many boolean arguments
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
73 // 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
|
74 #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
|
75 #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
|
76 #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
|
77 #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
|
78 #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
|
79 #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
|
80 |
826 | 81 static char *m_onlyone = N_("Already only one window"); |
82 | |
17516
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
83 // 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
|
84 // 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
|
85 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
|
86 |
31146
f6d4c6a3b41c
patch 9.0.0907: restoring window after WinScrolled may fail
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
87 // When non-zero closing a window is forbidden. Used to avoid that nasty |
f6d4c6a3b41c
patch 9.0.0907: restoring window after WinScrolled may fail
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
88 // autocommands mess up the window structure. |
f6d4c6a3b41c
patch 9.0.0907: restoring window after WinScrolled may fail
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
89 static int close_disallowed = 0; |
f6d4c6a3b41c
patch 9.0.0907: restoring window after WinScrolled may fail
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
90 |
f6d4c6a3b41c
patch 9.0.0907: restoring window after WinScrolled may fail
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
91 /* |
f6d4c6a3b41c
patch 9.0.0907: restoring window after WinScrolled may fail
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
92 * Disallow changing the window layout (split window, close window, move |
f6d4c6a3b41c
patch 9.0.0907: restoring window after WinScrolled may fail
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
93 * window). Resizing is still allowed. |
f6d4c6a3b41c
patch 9.0.0907: restoring window after WinScrolled may fail
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
94 * Used for autocommands that temporarily use another window and need to |
f6d4c6a3b41c
patch 9.0.0907: restoring window after WinScrolled may fail
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
95 * make sure the previously selected window is still there. |
f6d4c6a3b41c
patch 9.0.0907: restoring window after WinScrolled may fail
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
96 * Must be matched with exactly one call to window_layout_unlock()! |
f6d4c6a3b41c
patch 9.0.0907: restoring window after WinScrolled may fail
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
97 */ |
f6d4c6a3b41c
patch 9.0.0907: restoring window after WinScrolled may fail
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
98 static void |
f6d4c6a3b41c
patch 9.0.0907: restoring window after WinScrolled may fail
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
99 window_layout_lock(void) |
f6d4c6a3b41c
patch 9.0.0907: restoring window after WinScrolled may fail
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
100 { |
f6d4c6a3b41c
patch 9.0.0907: restoring window after WinScrolled may fail
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
101 ++split_disallowed; |
f6d4c6a3b41c
patch 9.0.0907: restoring window after WinScrolled may fail
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
102 ++close_disallowed; |
f6d4c6a3b41c
patch 9.0.0907: restoring window after WinScrolled may fail
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
103 } |
f6d4c6a3b41c
patch 9.0.0907: restoring window after WinScrolled may fail
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
104 |
f6d4c6a3b41c
patch 9.0.0907: restoring window after WinScrolled may fail
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
105 static void |
f6d4c6a3b41c
patch 9.0.0907: restoring window after WinScrolled may fail
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
106 window_layout_unlock(void) |
f6d4c6a3b41c
patch 9.0.0907: restoring window after WinScrolled may fail
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
107 { |
f6d4c6a3b41c
patch 9.0.0907: restoring window after WinScrolled may fail
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
108 --split_disallowed; |
f6d4c6a3b41c
patch 9.0.0907: restoring window after WinScrolled may fail
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
109 --close_disallowed; |
f6d4c6a3b41c
patch 9.0.0907: restoring window after WinScrolled may fail
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
110 } |
f6d4c6a3b41c
patch 9.0.0907: restoring window after WinScrolled may fail
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
111 |
f6d4c6a3b41c
patch 9.0.0907: restoring window after WinScrolled may fail
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
112 /* |
f6d4c6a3b41c
patch 9.0.0907: restoring window after WinScrolled may fail
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
113 * When the window layout cannot be changed give an error and return TRUE. |
31150
bcda71c89776
patch 9.0.0909: error message for layout change does not match action
Bram Moolenaar <Bram@vim.org>
parents:
31146
diff
changeset
|
114 * "cmd" indicates the action being performed and is used to pick the relevant |
bcda71c89776
patch 9.0.0909: error message for layout change does not match action
Bram Moolenaar <Bram@vim.org>
parents:
31146
diff
changeset
|
115 * error message. |
31146
f6d4c6a3b41c
patch 9.0.0907: restoring window after WinScrolled may fail
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
116 */ |
f6d4c6a3b41c
patch 9.0.0907: restoring window after WinScrolled may fail
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
117 int |
31150
bcda71c89776
patch 9.0.0909: error message for layout change does not match action
Bram Moolenaar <Bram@vim.org>
parents:
31146
diff
changeset
|
118 window_layout_locked(enum CMD_index cmd) |
31146
f6d4c6a3b41c
patch 9.0.0907: restoring window after WinScrolled may fail
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
119 { |
f6d4c6a3b41c
patch 9.0.0907: restoring window after WinScrolled may fail
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
120 if (split_disallowed > 0 || close_disallowed > 0) |
f6d4c6a3b41c
patch 9.0.0907: restoring window after WinScrolled may fail
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
121 { |
31150
bcda71c89776
patch 9.0.0909: error message for layout change does not match action
Bram Moolenaar <Bram@vim.org>
parents:
31146
diff
changeset
|
122 if (close_disallowed == 0 && cmd == CMD_tabnew) |
31146
f6d4c6a3b41c
patch 9.0.0907: restoring window after WinScrolled may fail
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
123 emsg(_(e_cannot_split_window_when_closing_buffer)); |
f6d4c6a3b41c
patch 9.0.0907: restoring window after WinScrolled may fail
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
124 else |
f6d4c6a3b41c
patch 9.0.0907: restoring window after WinScrolled may fail
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
125 emsg(_(e_not_allowed_to_change_window_layout_in_this_autocmd)); |
f6d4c6a3b41c
patch 9.0.0907: restoring window after WinScrolled may fail
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
126 return TRUE; |
f6d4c6a3b41c
patch 9.0.0907: restoring window after WinScrolled may fail
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
127 } |
f6d4c6a3b41c
patch 9.0.0907: restoring window after WinScrolled may fail
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
128 return FALSE; |
f6d4c6a3b41c
patch 9.0.0907: restoring window after WinScrolled may fail
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
129 } |
f6d4c6a3b41c
patch 9.0.0907: restoring window after WinScrolled may fail
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
130 |
17516
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
131 // #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
|
132 #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
|
133 /* |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
134 * 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
|
135 */ |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
136 static void |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
137 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
|
138 { |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
139 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
|
140 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
|
141 : 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
|
142 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
|
143 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
|
144 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
|
145 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
|
146 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
|
147 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
|
148 { |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
149 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
|
150 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
|
151 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
|
152 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
|
153 } |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
154 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
|
155 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
|
156 } |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
157 #endif |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
158 |
7 | 159 /* |
27805
afbe86e8b24a
patch 8.2.4428: crash when switching tabpage while in the cmdline window
Bram Moolenaar <Bram@vim.org>
parents:
27752
diff
changeset
|
160 * Return the current window, unless in the cmdline window and "prevwin" is |
afbe86e8b24a
patch 8.2.4428: crash when switching tabpage while in the cmdline window
Bram Moolenaar <Bram@vim.org>
parents:
27752
diff
changeset
|
161 * set, then return "prevwin". |
afbe86e8b24a
patch 8.2.4428: crash when switching tabpage while in the cmdline window
Bram Moolenaar <Bram@vim.org>
parents:
27752
diff
changeset
|
162 */ |
afbe86e8b24a
patch 8.2.4428: crash when switching tabpage while in the cmdline window
Bram Moolenaar <Bram@vim.org>
parents:
27752
diff
changeset
|
163 win_T * |
afbe86e8b24a
patch 8.2.4428: crash when switching tabpage while in the cmdline window
Bram Moolenaar <Bram@vim.org>
parents:
27752
diff
changeset
|
164 prevwin_curwin(void) |
afbe86e8b24a
patch 8.2.4428: crash when switching tabpage while in the cmdline window
Bram Moolenaar <Bram@vim.org>
parents:
27752
diff
changeset
|
165 { |
30645
101f08b49ed3
patch 9.0.0657: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
30624
diff
changeset
|
166 // In cmdwin, the alternative buffer should be used. |
101f08b49ed3
patch 9.0.0657: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
30624
diff
changeset
|
167 return is_in_cmdwin() && prevwin != NULL ? prevwin : curwin; |
27805
afbe86e8b24a
patch 8.2.4428: crash when switching tabpage while in the cmdline window
Bram Moolenaar <Bram@vim.org>
parents:
27752
diff
changeset
|
168 } |
afbe86e8b24a
patch 8.2.4428: crash when switching tabpage while in the cmdline window
Bram Moolenaar <Bram@vim.org>
parents:
27752
diff
changeset
|
169 |
afbe86e8b24a
patch 8.2.4428: crash when switching tabpage while in the cmdline window
Bram Moolenaar <Bram@vim.org>
parents:
27752
diff
changeset
|
170 /* |
15933
b2423b31266f
patch 8.1.0972: cannot switch from terminal window to next tabpage
Bram Moolenaar <Bram@vim.org>
parents:
15850
diff
changeset
|
171 * All CTRL-W window commands are handled here, called from normal_cmd(). |
7 | 172 */ |
173 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
174 do_window( |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
175 int nchar, |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
176 long Prenum, |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
177 int xchar) // extra char from ":wincmd gx" or NUL |
7 | 178 { |
179 long Prenum1; | |
180 win_T *wp; | |
181 char_u *ptr; | |
681 | 182 linenr_T lnum = -1; |
7 | 183 #ifdef FEAT_FIND_ID |
184 int type = FIND_DEFINE; | |
185 int len; | |
186 #endif | |
187 char_u cbuf[40]; | |
188 | |
19271
ebeeb4b4a1fa
patch 8.2.0194: some commands can cause problems in terminal popup
Bram Moolenaar <Bram@vim.org>
parents:
19265
diff
changeset
|
189 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
|
190 return; |
7 | 191 |
30645
101f08b49ed3
patch 9.0.0657: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
30624
diff
changeset
|
192 #define CHECK_CMDWIN \ |
13632
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
193 do { \ |
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
194 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
|
195 { \ |
25064
8f2262c72178
patch 8.2.3069: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
24216
diff
changeset
|
196 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
|
197 return; \ |
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
198 } \ |
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
199 } while (0) |
7 | 200 |
16874
da5f5836e90c
patch 8.1.1438: some commands cause trouble in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
16863
diff
changeset
|
201 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
|
202 |
7 | 203 switch (nchar) |
204 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
205 // split current window in two parts, horizontally |
7 | 206 case 'S': |
207 case Ctrl_S: | |
208 case 's': | |
13632
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
209 CHECK_CMDWIN; |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
210 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
|
211 // 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
|
212 // don't replicate the quickfix buffer. |
635 | 213 if (bt_quickfix(curbuf)) |
214 goto newwindow; | |
7 | 215 #ifdef FEAT_GUI |
216 need_mouse_correct = TRUE; | |
217 #endif | |
7009 | 218 (void)win_split((int)Prenum, 0); |
7 | 219 break; |
220 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
221 // split current window in two parts, vertically |
7 | 222 case Ctrl_V: |
223 case 'v': | |
13632
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
224 CHECK_CMDWIN; |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
225 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
|
226 // 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
|
227 // don't replicate the quickfix buffer. |
1664 | 228 if (bt_quickfix(curbuf)) |
229 goto newwindow; | |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8536
diff
changeset
|
230 #ifdef FEAT_GUI |
7 | 231 need_mouse_correct = TRUE; |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8536
diff
changeset
|
232 #endif |
7009 | 233 (void)win_split((int)Prenum, WSP_VERT); |
7 | 234 break; |
235 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
236 // split current window and edit alternate file |
7 | 237 case Ctrl_HAT: |
238 case '^': | |
13632
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
239 CHECK_CMDWIN; |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
240 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
|
241 |
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
|
242 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
|
243 ? 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
|
244 { |
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
|
245 if (Prenum == 0) |
25064
8f2262c72178
patch 8.2.3069: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
24216
diff
changeset
|
246 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
|
247 else |
26602
fac6673086df
patch 8.2.3830: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26532
diff
changeset
|
248 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
|
249 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
|
250 } |
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
|
251 |
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
|
252 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
|
253 (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
|
254 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
|
255 (linenr_T)0, GETF_ALT, FALSE); |
7 | 256 break; |
257 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
258 // open new window |
7 | 259 case Ctrl_N: |
260 case 'n': | |
13632
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
261 CHECK_CMDWIN; |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
262 reset_VIsual_and_resel(); // stop Visual mode |
635 | 263 newwindow: |
7 | 264 if (Prenum) |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
265 // window height |
1664 | 266 vim_snprintf((char *)cbuf, sizeof(cbuf) - 5, "%ld", Prenum); |
7 | 267 else |
268 cbuf[0] = NUL; | |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8536
diff
changeset
|
269 #if defined(FEAT_QUICKFIX) |
1664 | 270 if (nchar == 'v' || nchar == Ctrl_V) |
271 STRCAT(cbuf, "v"); | |
272 #endif | |
7 | 273 STRCAT(cbuf, "new"); |
274 do_cmdline_cmd(cbuf); | |
275 break; | |
276 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
277 // quit current window |
7 | 278 case Ctrl_Q: |
279 case 'q': | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
280 reset_VIsual_and_resel(); // stop Visual mode |
6432 | 281 cmd_with_count("quit", cbuf, sizeof(cbuf), Prenum); |
6398 | 282 do_cmdline_cmd(cbuf); |
7 | 283 break; |
284 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
285 // close current window |
7 | 286 case Ctrl_C: |
287 case 'c': | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
288 reset_VIsual_and_resel(); // stop Visual mode |
6432 | 289 cmd_with_count("close", cbuf, sizeof(cbuf), Prenum); |
6398 | 290 do_cmdline_cmd(cbuf); |
7 | 291 break; |
292 | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
293 #if defined(FEAT_QUICKFIX) |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
294 // close preview window |
7 | 295 case Ctrl_Z: |
296 case 'z': | |
13632
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
297 CHECK_CMDWIN; |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
298 reset_VIsual_and_resel(); // stop Visual mode |
7 | 299 do_cmdline_cmd((char_u *)"pclose"); |
300 break; | |
301 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
302 // cursor to preview window |
7 | 303 case 'P': |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9599
diff
changeset
|
304 FOR_ALL_WINDOWS(wp) |
7 | 305 if (wp->w_p_pvw) |
306 break; | |
307 if (wp == NULL) | |
26913
d4e61d61afd9
patch 8.2.3985: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26893
diff
changeset
|
308 emsg(_(e_there_is_no_preview_window)); |
7 | 309 else |
310 win_goto(wp); | |
311 break; | |
312 #endif | |
313 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
314 // close all but current window |
7 | 315 case Ctrl_O: |
316 case 'o': | |
13632
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
317 CHECK_CMDWIN; |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
318 reset_VIsual_and_resel(); // stop Visual mode |
6432 | 319 cmd_with_count("only", cbuf, sizeof(cbuf), Prenum); |
6398 | 320 do_cmdline_cmd(cbuf); |
7 | 321 break; |
322 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
323 // cursor to next window with wrap around |
7 | 324 case Ctrl_W: |
325 case 'w': | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
326 // cursor to previous window with wrap around |
7 | 327 case 'W': |
13632
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
328 CHECK_CMDWIN; |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
329 if (ONE_WINDOW && Prenum != 1) // just one window |
7 | 330 beep_flush(); |
331 else | |
332 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
333 if (Prenum) // go to specified window |
7 | 334 { |
335 for (wp = firstwin; --Prenum > 0; ) | |
336 { | |
337 if (wp->w_next == NULL) | |
338 break; | |
339 else | |
340 wp = wp->w_next; | |
341 } | |
342 } | |
343 else | |
344 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
345 if (nchar == 'W') // go to previous window |
7 | 346 { |
347 wp = curwin->w_prev; | |
348 if (wp == NULL) | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
349 wp = lastwin; // wrap around |
7 | 350 } |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
351 else // go to next window |
7 | 352 { |
353 wp = curwin->w_next; | |
354 if (wp == NULL) | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
355 wp = firstwin; // wrap around |
7 | 356 } |
357 } | |
358 win_goto(wp); | |
359 } | |
360 break; | |
361 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
362 // cursor to window below |
7 | 363 case 'j': |
364 case K_DOWN: | |
365 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
|
366 CHECK_CMDWIN; |
7 | 367 win_goto_ver(FALSE, Prenum1); |
368 break; | |
369 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
370 // cursor to window above |
7 | 371 case 'k': |
372 case K_UP: | |
373 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
|
374 CHECK_CMDWIN; |
7 | 375 win_goto_ver(TRUE, Prenum1); |
376 break; | |
377 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
378 // cursor to left window |
7 | 379 case 'h': |
380 case K_LEFT: | |
381 case Ctrl_H: | |
382 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
|
383 CHECK_CMDWIN; |
7 | 384 win_goto_hor(TRUE, Prenum1); |
385 break; | |
386 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
387 // cursor to right window |
7 | 388 case 'l': |
389 case K_RIGHT: | |
390 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
|
391 CHECK_CMDWIN; |
7 | 392 win_goto_hor(FALSE, Prenum1); |
393 break; | |
394 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
395 // move window to new tab page |
826 | 396 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
|
397 CHECK_CMDWIN; |
1906 | 398 if (one_window()) |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15490
diff
changeset
|
399 msg(_(m_onlyone)); |
826 | 400 else |
401 { | |
402 tabpage_T *oldtab = curtab; | |
403 tabpage_T *newtab; | |
404 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
405 // 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
|
406 // the old tab and close the window there. |
944 | 407 wp = curwin; |
826 | 408 if (win_new_tabpage((int)Prenum) == OK |
409 && valid_tabpage(oldtab)) | |
410 { | |
411 newtab = curtab; | |
4354 | 412 goto_tabpage_tp(oldtab, TRUE, TRUE); |
826 | 413 if (curwin == wp) |
414 win_close(curwin, FALSE); | |
415 if (valid_tabpage(newtab)) | |
4354 | 416 goto_tabpage_tp(newtab, TRUE, TRUE); |
826 | 417 } |
418 } | |
419 break; | |
420 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
421 // cursor to top-left window |
7 | 422 case 't': |
423 case Ctrl_T: | |
424 win_goto(firstwin); | |
425 break; | |
426 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
427 // cursor to bottom-right window |
7 | 428 case 'b': |
429 case Ctrl_B: | |
430 win_goto(lastwin); | |
431 break; | |
432 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
433 // cursor to last accessed (previous) window |
7 | 434 case 'p': |
435 case Ctrl_P: | |
8833
dc10bd23f918
commit https://github.com/vim/vim/commit/3dda7db4e1f7c4a8110a1f83001ec36b46693d27
Christian Brabandt <cb@256bit.org>
parents:
8804
diff
changeset
|
436 if (!win_valid(prevwin)) |
7 | 437 beep_flush(); |
438 else | |
439 win_goto(prevwin); | |
440 break; | |
441 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
442 // exchange current and next window |
7 | 443 case 'x': |
444 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
|
445 CHECK_CMDWIN; |
7 | 446 win_exchange(Prenum); |
447 break; | |
448 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
449 // rotate windows downwards |
7 | 450 case Ctrl_R: |
451 case 'r': | |
13632
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
452 CHECK_CMDWIN; |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
453 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
|
454 win_rotate(FALSE, (int)Prenum1); // downwards |
7 | 455 break; |
456 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
457 // rotate windows upwards |
7 | 458 case 'R': |
13632
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
459 CHECK_CMDWIN; |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
460 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
|
461 win_rotate(TRUE, (int)Prenum1); // upwards |
7 | 462 break; |
463 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
464 // move window to the very top/bottom/left/right |
7 | 465 case 'K': |
466 case 'J': | |
467 case 'H': | |
468 case 'L': | |
13632
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
469 CHECK_CMDWIN; |
7 | 470 win_totop((int)Prenum, |
471 ((nchar == 'H' || nchar == 'L') ? WSP_VERT : 0) | |
472 | ((nchar == 'H' || nchar == 'K') ? WSP_TOP : WSP_BOT)); | |
473 break; | |
474 | |
30009
b97a870a7c63
patch 9.0.0342: ":wincmd =" equalizes in two directions
Bram Moolenaar <Bram@vim.org>
parents:
30005
diff
changeset
|
475 // make all windows the same width and/or height |
7 | 476 case '=': |
30009
b97a870a7c63
patch 9.0.0342: ":wincmd =" equalizes in two directions
Bram Moolenaar <Bram@vim.org>
parents:
30005
diff
changeset
|
477 { |
b97a870a7c63
patch 9.0.0342: ":wincmd =" equalizes in two directions
Bram Moolenaar <Bram@vim.org>
parents:
30005
diff
changeset
|
478 int mod = cmdmod.cmod_split & (WSP_VERT | WSP_HOR); |
7 | 479 #ifdef FEAT_GUI |
30009
b97a870a7c63
patch 9.0.0342: ":wincmd =" equalizes in two directions
Bram Moolenaar <Bram@vim.org>
parents:
30005
diff
changeset
|
480 need_mouse_correct = TRUE; |
7 | 481 #endif |
30009
b97a870a7c63
patch 9.0.0342: ":wincmd =" equalizes in two directions
Bram Moolenaar <Bram@vim.org>
parents:
30005
diff
changeset
|
482 win_equal(NULL, FALSE, |
b97a870a7c63
patch 9.0.0342: ":wincmd =" equalizes in two directions
Bram Moolenaar <Bram@vim.org>
parents:
30005
diff
changeset
|
483 mod == WSP_VERT ? 'v' : mod == WSP_HOR ? 'h' : 'b'); |
b97a870a7c63
patch 9.0.0342: ":wincmd =" equalizes in two directions
Bram Moolenaar <Bram@vim.org>
parents:
30005
diff
changeset
|
484 } |
7 | 485 break; |
486 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
487 // increase current window height |
7 | 488 case '+': |
489 #ifdef FEAT_GUI | |
490 need_mouse_correct = TRUE; | |
491 #endif | |
492 win_setheight(curwin->w_height + (int)Prenum1); | |
493 break; | |
494 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
495 // decrease current window height |
7 | 496 case '-': |
497 #ifdef FEAT_GUI | |
498 need_mouse_correct = TRUE; | |
499 #endif | |
500 win_setheight(curwin->w_height - (int)Prenum1); | |
501 break; | |
502 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
503 // set current window height |
7 | 504 case Ctrl__: |
505 case '_': | |
506 #ifdef FEAT_GUI | |
507 need_mouse_correct = TRUE; | |
508 #endif | |
509 win_setheight(Prenum ? (int)Prenum : 9999); | |
510 break; | |
511 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
512 // increase current window width |
7 | 513 case '>': |
514 #ifdef FEAT_GUI | |
515 need_mouse_correct = TRUE; | |
516 #endif | |
517 win_setwidth(curwin->w_width + (int)Prenum1); | |
518 break; | |
519 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
520 // decrease current window width |
7 | 521 case '<': |
522 #ifdef FEAT_GUI | |
523 need_mouse_correct = TRUE; | |
524 #endif | |
525 win_setwidth(curwin->w_width - (int)Prenum1); | |
526 break; | |
527 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
528 // set current window width |
7 | 529 case '|': |
530 #ifdef FEAT_GUI | |
531 need_mouse_correct = TRUE; | |
532 #endif | |
533 win_setwidth(Prenum != 0 ? (int)Prenum : 9999); | |
534 break; | |
535 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
536 // jump to tag and split window if tag exists (in preview window) |
7 | 537 #if defined(FEAT_QUICKFIX) |
538 case '}': | |
13632
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
539 CHECK_CMDWIN; |
7 | 540 if (Prenum) |
541 g_do_tagpreview = Prenum; | |
542 else | |
543 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
|
544 #endif |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
545 // FALLTHROUGH |
7 | 546 case ']': |
547 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
|
548 CHECK_CMDWIN; |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
549 // keep Visual mode, can select words to use as a tag |
7 | 550 if (Prenum) |
551 postponed_split = Prenum; | |
552 else | |
553 postponed_split = -1; | |
6251 | 554 #ifdef FEAT_QUICKFIX |
6264 | 555 if (nchar != '}') |
556 g_do_tagpreview = 0; | |
6251 | 557 #endif |
6239 | 558 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
559 // 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
|
560 // was used in a function. |
7 | 561 do_nv_ident(Ctrl_RSB, NUL); |
31437
ede2bd5f3426
patch 9.0.1051: after a failed CTRL-W ] next command splits window
Bram Moolenaar <Bram@vim.org>
parents:
31384
diff
changeset
|
562 postponed_split = 0; |
7 | 563 break; |
564 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
565 // edit file name under cursor in a new window |
7 | 566 case 'f': |
681 | 567 case 'F': |
7 | 568 case Ctrl_F: |
820 | 569 wingotofile: |
13632
cec5137d5332
patch 8.0.1688: some macros are used without a semicolon
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
570 CHECK_CMDWIN; |
31227
1a9e44a45614
patch 9.0.0947: invalid memory access in substitute with function
Bram Moolenaar <Bram@vim.org>
parents:
31190
diff
changeset
|
571 if (check_text_or_curbuf_locked(NULL)) |
1a9e44a45614
patch 9.0.0947: invalid memory access in substitute with function
Bram Moolenaar <Bram@vim.org>
parents:
31190
diff
changeset
|
572 break; |
344 | 573 |
681 | 574 ptr = grab_file_name(Prenum1, &lnum); |
7 | 575 if (ptr != NULL) |
576 { | |
9349
b24900b73f90
commit https://github.com/vim/vim/commit/5d2ca0402954ff79b73d9c86cc16c8a6454b75a7
Christian Brabandt <cb@256bit.org>
parents:
9223
diff
changeset
|
577 tabpage_T *oldtab = curtab; |
b24900b73f90
commit https://github.com/vim/vim/commit/5d2ca0402954ff79b73d9c86cc16c8a6454b75a7
Christian Brabandt <cb@256bit.org>
parents:
9223
diff
changeset
|
578 win_T *oldwin = curwin; |
29853
31c598083364
patch 9.0.0265: no good reason why the "gf" command isn't in the tiny version
Bram Moolenaar <Bram@vim.org>
parents:
29849
diff
changeset
|
579 #ifdef FEAT_GUI |
7 | 580 need_mouse_correct = TRUE; |
29853
31c598083364
patch 9.0.0265: no good reason why the "gf" command isn't in the tiny version
Bram Moolenaar <Bram@vim.org>
parents:
29849
diff
changeset
|
581 #endif |
7 | 582 setpcmark(); |
32429
bfc23ba1bba5
patch 9.0.1546: some commands for opening a file don't use 'switchbuf'
Bram Moolenaar <Bram@vim.org>
parents:
32363
diff
changeset
|
583 |
bfc23ba1bba5
patch 9.0.1546: some commands for opening a file don't use 'switchbuf'
Bram Moolenaar <Bram@vim.org>
parents:
32363
diff
changeset
|
584 // If 'switchbuf' is set to 'useopen' or 'usetab' and the |
bfc23ba1bba5
patch 9.0.1546: some commands for opening a file don't use 'switchbuf'
Bram Moolenaar <Bram@vim.org>
parents:
32363
diff
changeset
|
585 // file is already opened in a window, then jump to it. |
bfc23ba1bba5
patch 9.0.1546: some commands for opening a file don't use 'switchbuf'
Bram Moolenaar <Bram@vim.org>
parents:
32363
diff
changeset
|
586 wp = NULL; |
bfc23ba1bba5
patch 9.0.1546: some commands for opening a file don't use 'switchbuf'
Bram Moolenaar <Bram@vim.org>
parents:
32363
diff
changeset
|
587 if ((swb_flags & (SWB_USEOPEN | SWB_USETAB)) |
bfc23ba1bba5
patch 9.0.1546: some commands for opening a file don't use 'switchbuf'
Bram Moolenaar <Bram@vim.org>
parents:
32363
diff
changeset
|
588 && cmdmod.cmod_tab == 0) |
bfc23ba1bba5
patch 9.0.1546: some commands for opening a file don't use 'switchbuf'
Bram Moolenaar <Bram@vim.org>
parents:
32363
diff
changeset
|
589 { |
bfc23ba1bba5
patch 9.0.1546: some commands for opening a file don't use 'switchbuf'
Bram Moolenaar <Bram@vim.org>
parents:
32363
diff
changeset
|
590 buf_T *existing_buf = buflist_findname_exp(ptr); |
bfc23ba1bba5
patch 9.0.1546: some commands for opening a file don't use 'switchbuf'
Bram Moolenaar <Bram@vim.org>
parents:
32363
diff
changeset
|
591 |
bfc23ba1bba5
patch 9.0.1546: some commands for opening a file don't use 'switchbuf'
Bram Moolenaar <Bram@vim.org>
parents:
32363
diff
changeset
|
592 if (existing_buf != NULL) |
bfc23ba1bba5
patch 9.0.1546: some commands for opening a file don't use 'switchbuf'
Bram Moolenaar <Bram@vim.org>
parents:
32363
diff
changeset
|
593 { |
bfc23ba1bba5
patch 9.0.1546: some commands for opening a file don't use 'switchbuf'
Bram Moolenaar <Bram@vim.org>
parents:
32363
diff
changeset
|
594 if (swb_flags & SWB_USEOPEN) |
bfc23ba1bba5
patch 9.0.1546: some commands for opening a file don't use 'switchbuf'
Bram Moolenaar <Bram@vim.org>
parents:
32363
diff
changeset
|
595 wp = buf_jump_open_win(existing_buf); |
bfc23ba1bba5
patch 9.0.1546: some commands for opening a file don't use 'switchbuf'
Bram Moolenaar <Bram@vim.org>
parents:
32363
diff
changeset
|
596 |
bfc23ba1bba5
patch 9.0.1546: some commands for opening a file don't use 'switchbuf'
Bram Moolenaar <Bram@vim.org>
parents:
32363
diff
changeset
|
597 // If 'switchbuf' contains "usetab": jump to first |
bfc23ba1bba5
patch 9.0.1546: some commands for opening a file don't use 'switchbuf'
Bram Moolenaar <Bram@vim.org>
parents:
32363
diff
changeset
|
598 // window in any tab page containing "existing_buf" |
bfc23ba1bba5
patch 9.0.1546: some commands for opening a file don't use 'switchbuf'
Bram Moolenaar <Bram@vim.org>
parents:
32363
diff
changeset
|
599 // if one exists. |
bfc23ba1bba5
patch 9.0.1546: some commands for opening a file don't use 'switchbuf'
Bram Moolenaar <Bram@vim.org>
parents:
32363
diff
changeset
|
600 if (wp == NULL && (swb_flags & SWB_USETAB)) |
bfc23ba1bba5
patch 9.0.1546: some commands for opening a file don't use 'switchbuf'
Bram Moolenaar <Bram@vim.org>
parents:
32363
diff
changeset
|
601 wp = buf_jump_open_tab(existing_buf); |
bfc23ba1bba5
patch 9.0.1546: some commands for opening a file don't use 'switchbuf'
Bram Moolenaar <Bram@vim.org>
parents:
32363
diff
changeset
|
602 } |
bfc23ba1bba5
patch 9.0.1546: some commands for opening a file don't use 'switchbuf'
Bram Moolenaar <Bram@vim.org>
parents:
32363
diff
changeset
|
603 } |
bfc23ba1bba5
patch 9.0.1546: some commands for opening a file don't use 'switchbuf'
Bram Moolenaar <Bram@vim.org>
parents:
32363
diff
changeset
|
604 |
bfc23ba1bba5
patch 9.0.1546: some commands for opening a file don't use 'switchbuf'
Bram Moolenaar <Bram@vim.org>
parents:
32363
diff
changeset
|
605 if (wp == NULL && win_split(0, 0) == OK) |
7 | 606 { |
2583 | 607 RESET_BINDING(curwin); |
9349
b24900b73f90
commit https://github.com/vim/vim/commit/5d2ca0402954ff79b73d9c86cc16c8a6454b75a7
Christian Brabandt <cb@256bit.org>
parents:
9223
diff
changeset
|
608 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
|
609 ECMD_HIDE, NULL) == FAIL) |
b24900b73f90
commit https://github.com/vim/vim/commit/5d2ca0402954ff79b73d9c86cc16c8a6454b75a7
Christian Brabandt <cb@256bit.org>
parents:
9223
diff
changeset
|
610 { |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
611 // 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
|
612 // opened for it. |
9349
b24900b73f90
commit https://github.com/vim/vim/commit/5d2ca0402954ff79b73d9c86cc16c8a6454b75a7
Christian Brabandt <cb@256bit.org>
parents:
9223
diff
changeset
|
613 win_close(curwin, FALSE); |
b24900b73f90
commit https://github.com/vim/vim/commit/5d2ca0402954ff79b73d9c86cc16c8a6454b75a7
Christian Brabandt <cb@256bit.org>
parents:
9223
diff
changeset
|
614 goto_tabpage_win(oldtab, oldwin); |
b24900b73f90
commit https://github.com/vim/vim/commit/5d2ca0402954ff79b73d9c86cc16c8a6454b75a7
Christian Brabandt <cb@256bit.org>
parents:
9223
diff
changeset
|
615 } |
32429
bfc23ba1bba5
patch 9.0.1546: some commands for opening a file don't use 'switchbuf'
Bram Moolenaar <Bram@vim.org>
parents:
32363
diff
changeset
|
616 else |
bfc23ba1bba5
patch 9.0.1546: some commands for opening a file don't use 'switchbuf'
Bram Moolenaar <Bram@vim.org>
parents:
32363
diff
changeset
|
617 wp = curwin; |
bfc23ba1bba5
patch 9.0.1546: some commands for opening a file don't use 'switchbuf'
Bram Moolenaar <Bram@vim.org>
parents:
32363
diff
changeset
|
618 } |
bfc23ba1bba5
patch 9.0.1546: some commands for opening a file don't use 'switchbuf'
Bram Moolenaar <Bram@vim.org>
parents:
32363
diff
changeset
|
619 |
bfc23ba1bba5
patch 9.0.1546: some commands for opening a file don't use 'switchbuf'
Bram Moolenaar <Bram@vim.org>
parents:
32363
diff
changeset
|
620 if (wp != NULL && nchar == 'F' && lnum >= 0) |
bfc23ba1bba5
patch 9.0.1546: some commands for opening a file don't use 'switchbuf'
Bram Moolenaar <Bram@vim.org>
parents:
32363
diff
changeset
|
621 { |
bfc23ba1bba5
patch 9.0.1546: some commands for opening a file don't use 'switchbuf'
Bram Moolenaar <Bram@vim.org>
parents:
32363
diff
changeset
|
622 curwin->w_cursor.lnum = lnum; |
bfc23ba1bba5
patch 9.0.1546: some commands for opening a file don't use 'switchbuf'
Bram Moolenaar <Bram@vim.org>
parents:
32363
diff
changeset
|
623 check_cursor_lnum(); |
bfc23ba1bba5
patch 9.0.1546: some commands for opening a file don't use 'switchbuf'
Bram Moolenaar <Bram@vim.org>
parents:
32363
diff
changeset
|
624 beginline(BL_SOL | BL_FIX); |
7 | 625 } |
626 vim_free(ptr); | |
627 } | |
628 break; | |
629 | |
630 #ifdef FEAT_FIND_ID | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
631 // 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
|
632 // new window -- webb |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
633 case 'i': // Go to any match |
7 | 634 case Ctrl_I: |
635 type = FIND_ANY; | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
636 // FALLTHROUGH |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
637 case 'd': // Go to definition, using 'define' |
7 | 638 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
|
639 CHECK_CMDWIN; |
7 | 640 if ((len = find_ident_under_cursor(&ptr, FIND_IDENT)) == 0) |
641 break; | |
28913
22f743798f84
patch 8.2.4979: accessing freed memory when line is flushed
Bram Moolenaar <Bram@vim.org>
parents:
28809
diff
changeset
|
642 |
22f743798f84
patch 8.2.4979: accessing freed memory when line is flushed
Bram Moolenaar <Bram@vim.org>
parents:
28809
diff
changeset
|
643 // Make a copy, if the line was changed it will be freed. |
22f743798f84
patch 8.2.4979: accessing freed memory when line is flushed
Bram Moolenaar <Bram@vim.org>
parents:
28809
diff
changeset
|
644 ptr = vim_strnsave(ptr, len); |
22f743798f84
patch 8.2.4979: accessing freed memory when line is flushed
Bram Moolenaar <Bram@vim.org>
parents:
28809
diff
changeset
|
645 if (ptr == NULL) |
22f743798f84
patch 8.2.4979: accessing freed memory when line is flushed
Bram Moolenaar <Bram@vim.org>
parents:
28809
diff
changeset
|
646 break; |
22f743798f84
patch 8.2.4979: accessing freed memory when line is flushed
Bram Moolenaar <Bram@vim.org>
parents:
28809
diff
changeset
|
647 |
7 | 648 find_pattern_in_path(ptr, 0, len, TRUE, |
649 Prenum == 0 ? TRUE : FALSE, type, | |
650 Prenum1, ACTION_SPLIT, (linenr_T)1, (linenr_T)MAXLNUM); | |
28913
22f743798f84
patch 8.2.4979: accessing freed memory when line is flushed
Bram Moolenaar <Bram@vim.org>
parents:
28809
diff
changeset
|
651 vim_free(ptr); |
7 | 652 curwin->w_set_curswant = TRUE; |
653 break; | |
654 #endif | |
655 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
656 // 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
|
657 #if defined(FEAT_QUICKFIX) |
170 | 658 case K_KENTER: |
659 case CAR: | |
660 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
|
661 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
|
662 break; |
170 | 663 #endif |
664 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
665 // CTRL-W g extended commands |
7 | 666 case 'g': |
667 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
|
668 CHECK_CMDWIN; |
7 | 669 #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
|
670 dont_scroll = TRUE; // disallow scrolling here |
7 | 671 #endif |
672 ++no_mapping; | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
673 ++allow_keys; // no mapping for xchar, but allow key codes |
7 | 674 if (xchar == NUL) |
1389 | 675 xchar = plain_vgetc(); |
7 | 676 LANGMAP_ADJUST(xchar, TRUE); |
677 --no_mapping; | |
678 --allow_keys; | |
679 (void)add_to_showcmd(xchar); | |
30825
c7983f593fa7
patch 9.0.0747: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
30695
diff
changeset
|
680 |
7 | 681 switch (xchar) |
682 { | |
683 #if defined(FEAT_QUICKFIX) | |
684 case '}': | |
685 xchar = Ctrl_RSB; | |
686 if (Prenum) | |
687 g_do_tagpreview = Prenum; | |
688 else | |
689 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
|
690 #endif |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
691 // FALLTHROUGH |
7 | 692 case ']': |
693 case Ctrl_RSB: | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
694 // keep Visual mode, can select words to use as a tag |
7 | 695 if (Prenum) |
696 postponed_split = Prenum; | |
697 else | |
698 postponed_split = -1; | |
699 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
700 // 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
|
701 // "wincmd g}" was used in a function. |
7 | 702 do_nv_ident('g', xchar); |
31437
ede2bd5f3426
patch 9.0.1051: after a failed CTRL-W ] next command splits window
Bram Moolenaar <Bram@vim.org>
parents:
31384
diff
changeset
|
703 postponed_split = 0; |
7 | 704 break; |
705 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
706 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
|
707 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
|
708 cmdmod.cmod_tab = tabpage_index(curtab) + 1; |
839 | 709 nchar = xchar; |
820 | 710 goto wingotofile; |
29853
31c598083364
patch 9.0.0265: no good reason why the "gf" command isn't in the tiny version
Bram Moolenaar <Bram@vim.org>
parents:
29849
diff
changeset
|
711 |
15933
b2423b31266f
patch 8.1.0972: cannot switch from terminal window to next tabpage
Bram Moolenaar <Bram@vim.org>
parents:
15850
diff
changeset
|
712 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
|
713 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
|
714 break; |
b2423b31266f
patch 8.1.0972: cannot switch from terminal window to next tabpage
Bram Moolenaar <Bram@vim.org>
parents:
15850
diff
changeset
|
715 |
15937
c38fb03a6055
patch 8.1.0974: cannot switch from terminal window to previous tabpage
Bram Moolenaar <Bram@vim.org>
parents:
15933
diff
changeset
|
716 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
|
717 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
|
718 break; |
c38fb03a6055
patch 8.1.0974: cannot switch from terminal window to previous tabpage
Bram Moolenaar <Bram@vim.org>
parents:
15933
diff
changeset
|
719 |
21703
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21020
diff
changeset
|
720 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
|
721 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
|
722 beep_flush(); |
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21020
diff
changeset
|
723 break; |
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21020
diff
changeset
|
724 |
7 | 725 default: |
726 beep_flush(); | |
727 break; | |
728 } | |
729 break; | |
730 | |
731 default: beep_flush(); | |
732 break; | |
733 } | |
734 } | |
735 | |
6489 | 736 /* |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16447
diff
changeset
|
737 * Figure out the address type for ":wincmd". |
6489 | 738 */ |
739 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
740 get_wincmd_addr_type(char_u *arg, exarg_T *eap) |
6489 | 741 { |
742 switch (*arg) | |
743 { | |
744 case 'S': | |
745 case Ctrl_S: | |
746 case 's': | |
747 case Ctrl_N: | |
748 case 'n': | |
749 case 'j': | |
750 case Ctrl_J: | |
751 case 'k': | |
752 case Ctrl_K: | |
753 case 'T': | |
754 case Ctrl_R: | |
755 case 'r': | |
756 case 'R': | |
757 case 'K': | |
758 case 'J': | |
759 case '+': | |
760 case '-': | |
761 case Ctrl__: | |
762 case '_': | |
763 case '|': | |
764 case ']': | |
765 case Ctrl_RSB: | |
766 case 'g': | |
767 case Ctrl_G: | |
768 case Ctrl_V: | |
769 case 'v': | |
770 case 'h': | |
771 case Ctrl_H: | |
772 case 'l': | |
773 case Ctrl_L: | |
774 case 'H': | |
775 case 'L': | |
776 case '>': | |
777 case '<': | |
778 #if defined(FEAT_QUICKFIX) | |
779 case '}': | |
780 #endif | |
781 case 'f': | |
782 case 'F': | |
783 case Ctrl_F: | |
784 #ifdef FEAT_FIND_ID | |
785 case 'i': | |
786 case Ctrl_I: | |
787 case 'd': | |
788 case Ctrl_D: | |
789 #endif | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16447
diff
changeset
|
790 // 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
|
791 eap->addr_type = ADDR_OTHER; |
6489 | 792 break; |
793 | |
794 case Ctrl_HAT: | |
795 case '^': | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16447
diff
changeset
|
796 // buffer number |
6489 | 797 eap->addr_type = ADDR_BUFFERS; |
798 break; | |
799 | |
800 case Ctrl_Q: | |
801 case 'q': | |
802 case Ctrl_C: | |
803 case 'c': | |
804 case Ctrl_O: | |
805 case 'o': | |
806 case Ctrl_W: | |
807 case 'w': | |
808 case 'W': | |
809 case 'x': | |
810 case Ctrl_X: | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16447
diff
changeset
|
811 // window number |
6489 | 812 eap->addr_type = ADDR_WINDOWS; |
813 break; | |
814 | |
815 #if defined(FEAT_QUICKFIX) | |
816 case Ctrl_Z: | |
817 case 'z': | |
818 case 'P': | |
819 #endif | |
820 case 't': | |
821 case Ctrl_T: | |
822 case 'b': | |
823 case Ctrl_B: | |
824 case 'p': | |
825 case Ctrl_P: | |
826 case '=': | |
827 case CAR: | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16447
diff
changeset
|
828 // no count |
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16447
diff
changeset
|
829 eap->addr_type = ADDR_NONE; |
6489 | 830 break; |
831 } | |
832 } | |
833 | |
6432 | 834 static void |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
835 cmd_with_count( |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
836 char *cmd, |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
837 char_u *bufp, |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
838 size_t bufsize, |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
839 long Prenum) |
6432 | 840 { |
841 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
|
842 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
|
843 else |
77cb22562852
patch 8.2.2649: Vim9: some wincmd arguments cause a white space error
Bram Moolenaar <Bram@vim.org>
parents:
24108
diff
changeset
|
844 STRCPY(bufp, cmd); |
6432 | 845 } |
846 | |
7 | 847 /* |
27583
d4921b91542c
patch 8.2.4318: various comment and indent mistakes, returning wrong zero
Bram Moolenaar <Bram@vim.org>
parents:
27440
diff
changeset
|
848 * If "split_disallowed" is set give an error and return FAIL. |
17516
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
849 * 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
|
850 */ |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
851 static int |
32009
4545f58c8490
patch 9.0.1336: functions without arguments are not always declared properly
Bram Moolenaar <Bram@vim.org>
parents:
31960
diff
changeset
|
852 check_split_disallowed(void) |
17516
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
853 { |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
854 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
|
855 { |
26893
79c76ca2c53c
patch 8.2.3975: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26883
diff
changeset
|
856 emsg(_(e_cant_split_window_while_closing_another)); |
17516
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
857 return FAIL; |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
858 } |
23869
5a4f9c5c1b99
patch 8.2.2476: using freed memory when splitting window while closing buffer
Bram Moolenaar <Bram@vim.org>
parents:
23402
diff
changeset
|
859 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
|
860 { |
5a4f9c5c1b99
patch 8.2.2476: using freed memory when splitting window while closing buffer
Bram Moolenaar <Bram@vim.org>
parents:
23402
diff
changeset
|
861 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
|
862 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
|
863 } |
17516
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
864 return OK; |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
865 } |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
866 |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
867 /* |
7 | 868 * split the current window, implements CTRL-W s and :split |
869 * | |
870 * "size" is the height or width for the new window, 0 to use half of current | |
871 * height or width. | |
872 * | |
873 * "flags": | |
874 * WSP_ROOM: require enough room for new window | |
875 * WSP_VERT: vertical split. | |
876 * WSP_TOP: open window at the top-left of the shell (help window). | |
877 * WSP_BOT: open window at the bottom-right of the shell (quickfix window). | |
878 * WSP_HELP: creating the help window, keep layout snapshot | |
879 * | |
880 * return FAIL for failure, OK otherwise | |
881 */ | |
882 int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
883 win_split(int size, int flags) |
7 | 884 { |
19271
ebeeb4b4a1fa
patch 8.2.0194: some commands can cause problems in terminal popup
Bram Moolenaar <Bram@vim.org>
parents:
19265
diff
changeset
|
885 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
|
886 return FAIL; |
da5f5836e90c
patch 8.1.1438: some commands cause trouble in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
16863
diff
changeset
|
887 |
23869
5a4f9c5c1b99
patch 8.2.2476: using freed memory when splitting window while closing buffer
Bram Moolenaar <Bram@vim.org>
parents:
23402
diff
changeset
|
888 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
|
889 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
|
890 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
891 // When the ":tab" modifier was used open a new tab page instead. |
682 | 892 if (may_open_tabpage() == OK) |
893 return OK; | |
894 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
895 // 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
|
896 flags |= cmdmod.cmod_split; |
7 | 897 if ((flags & WSP_TOP) && (flags & WSP_BOT)) |
898 { | |
26913
d4e61d61afd9
patch 8.2.3985: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26893
diff
changeset
|
899 emsg(_(e_cant_split_topleft_and_botright_at_the_same_time)); |
7 | 900 return FAIL; |
901 } | |
902 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
903 // 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
|
904 // Otherwise clear the snapshot, it's now invalid. |
7 | 905 if (flags & WSP_HELP) |
1906 | 906 make_snapshot(SNAP_HELP_IDX); |
7 | 907 else |
1906 | 908 clear_snapshot(curtab, SNAP_HELP_IDX); |
7 | 909 |
910 return win_split_ins(size, flags, NULL, 0); | |
911 } | |
912 | |
913 /* | |
3263 | 914 * When "new_wp" is NULL: split the current window in two. |
915 * When "new_wp" is not NULL: insert this window at the far | |
7 | 916 * top/left/right/bottom. |
31227
1a9e44a45614
patch 9.0.0947: invalid memory access in substitute with function
Bram Moolenaar <Bram@vim.org>
parents:
31190
diff
changeset
|
917 * Return FAIL for failure, OK otherwise. |
7 | 918 */ |
1906 | 919 int |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
920 win_split_ins( |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
921 int size, |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
922 int flags, |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
923 win_T *new_wp, |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
924 int dir) |
7 | 925 { |
3263 | 926 win_T *wp = new_wp; |
7 | 927 win_T *oldwin; |
928 int new_size = size; | |
929 int i; | |
930 int need_status = 0; | |
931 int do_equal = FALSE; | |
932 int needed; | |
933 int available; | |
934 int oldwin_height = 0; | |
935 int layout; | |
6077 | 936 frame_T *frp, *curfrp, *frp2, *prevfrp; |
7 | 937 int before; |
6052 | 938 int minheight; |
6066 | 939 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
|
940 int did_set_fraction = FALSE; |
7 | 941 |
942 if (flags & WSP_TOP) | |
943 oldwin = firstwin; | |
944 else if (flags & WSP_BOT) | |
945 oldwin = lastwin; | |
946 else | |
947 oldwin = curwin; | |
948 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
949 // 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
|
950 if (ONE_WINDOW && p_ls == 1 && oldwin->w_status_height == 0) |
7 | 951 { |
12998
dd734ee3e2fe
patch 8.0.1375: window size wrong after maximizing with WinBar
Christian Brabandt <cb@256bit.org>
parents:
12916
diff
changeset
|
952 if (VISIBLE_HEIGHT(oldwin) <= p_wmh && new_wp == NULL) |
7 | 953 { |
25306
078edc1821bf
patch 8.2.3190: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
25157
diff
changeset
|
954 emsg(_(e_not_enough_room)); |
7 | 955 return FAIL; |
956 } | |
957 need_status = STATUS_HEIGHT; | |
958 } | |
959 | |
1114 | 960 #ifdef FEAT_GUI |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
961 // May be needed for the scrollbars that are going to change. |
1114 | 962 if (gui.in_use) |
963 out_flush(); | |
964 #endif | |
965 | |
7 | 966 if (flags & WSP_VERT) |
967 { | |
6068 | 968 int wmw1; |
969 int minwidth; | |
970 | |
7 | 971 layout = FR_ROW; |
972 | |
973 /* | |
974 * Check if we are able to split the current window and compute its | |
975 * width. | |
976 */ | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
977 // Current window requires at least 1 space. |
6066 | 978 wmw1 = (p_wmw == 0 ? 1 : p_wmw); |
979 needed = wmw1 + 1; | |
7 | 980 if (flags & WSP_ROOM) |
6066 | 981 needed += p_wiw - wmw1; |
6077 | 982 if (flags & (WSP_BOT | WSP_TOP)) |
7 | 983 { |
6066 | 984 minwidth = frame_minwidth(topframe, NOWIN); |
7 | 985 available = topframe->fr_width; |
6052 | 986 needed += minwidth; |
7 | 987 } |
6077 | 988 else if (p_ea) |
989 { | |
990 minwidth = frame_minwidth(oldwin->w_frame, NOWIN); | |
991 prevfrp = oldwin->w_frame; | |
992 for (frp = oldwin->w_frame->fr_parent; frp != NULL; | |
993 frp = frp->fr_parent) | |
994 { | |
995 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
|
996 FOR_ALL_FRAMES(frp2, frp->fr_child) |
6077 | 997 if (frp2 != prevfrp) |
998 minwidth += frame_minwidth(frp2, NOWIN); | |
999 prevfrp = frp; | |
1000 } | |
1001 available = topframe->fr_width; | |
1002 needed += minwidth; | |
1003 } | |
7 | 1004 else |
6052 | 1005 { |
6066 | 1006 minwidth = frame_minwidth(oldwin->w_frame, NOWIN); |
1007 available = oldwin->w_frame->fr_width; | |
1008 needed += minwidth; | |
6052 | 1009 } |
3263 | 1010 if (available < needed && new_wp == NULL) |
7 | 1011 { |
25306
078edc1821bf
patch 8.2.3190: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
25157
diff
changeset
|
1012 emsg(_(e_not_enough_room)); |
7 | 1013 return FAIL; |
1014 } | |
1015 if (new_size == 0) | |
1016 new_size = oldwin->w_width / 2; | |
6052 | 1017 if (new_size > available - minwidth - 1) |
1018 new_size = available - minwidth - 1; | |
6066 | 1019 if (new_size < wmw1) |
1020 new_size = wmw1; | |
7 | 1021 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1022 // if it doesn't fit in the current window, need win_equal() |
7 | 1023 if (oldwin->w_width - new_size - 1 < p_wmw) |
1024 do_equal = TRUE; | |
779 | 1025 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1026 // 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
|
1027 // '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
|
1028 // instead, if possible. Add one for the separator. |
779 | 1029 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
|
1030 win_setwidth_win(oldwin->w_width + new_size + 1, oldwin); |
1354 | 1031 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1032 // 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
|
1033 // is wider than one of the split windows. |
1354 | 1034 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
|
1035 && oldwin->w_frame->fr_parent != NULL) |
1354 | 1036 { |
1037 frp = oldwin->w_frame->fr_parent->fr_child; | |
1038 while (frp != NULL) | |
1039 { | |
1040 if (frp->fr_win != oldwin && frp->fr_win != NULL | |
1041 && (frp->fr_win->w_width > new_size | |
1042 || frp->fr_win->w_width > oldwin->w_width | |
6373 | 1043 - new_size - 1)) |
1354 | 1044 { |
1045 do_equal = TRUE; | |
1046 break; | |
1047 } | |
1048 frp = frp->fr_next; | |
1049 } | |
1050 } | |
7 | 1051 } |
1052 else | |
1053 { | |
1054 layout = FR_COL; | |
1055 | |
1056 /* | |
1057 * Check if we are able to split the current window and compute its | |
1058 * height. | |
1059 */ | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1060 // 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
|
1061 wmh1 = (p_wmh == 0 ? 1 : p_wmh) + WINBAR_HEIGHT(curwin); |
6066 | 1062 needed = wmh1 + STATUS_HEIGHT; |
7 | 1063 if (flags & WSP_ROOM) |
6066 | 1064 needed += p_wh - wmh1; |
6077 | 1065 if (flags & (WSP_BOT | WSP_TOP)) |
7 | 1066 { |
6066 | 1067 minheight = frame_minheight(topframe, NOWIN) + need_status; |
7 | 1068 available = topframe->fr_height; |
6052 | 1069 needed += minheight; |
7 | 1070 } |
6077 | 1071 else if (p_ea) |
1072 { | |
1073 minheight = frame_minheight(oldwin->w_frame, NOWIN) + need_status; | |
1074 prevfrp = oldwin->w_frame; | |
1075 for (frp = oldwin->w_frame->fr_parent; frp != NULL; | |
1076 frp = frp->fr_parent) | |
1077 { | |
1078 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
|
1079 FOR_ALL_FRAMES(frp2, frp->fr_child) |
6077 | 1080 if (frp2 != prevfrp) |
1081 minheight += frame_minheight(frp2, NOWIN); | |
1082 prevfrp = frp; | |
1083 } | |
1084 available = topframe->fr_height; | |
1085 needed += minheight; | |
1086 } | |
7 | 1087 else |
1088 { | |
6066 | 1089 minheight = frame_minheight(oldwin->w_frame, NOWIN) + need_status; |
1090 available = oldwin->w_frame->fr_height; | |
1091 needed += minheight; | |
7 | 1092 } |
3263 | 1093 if (available < needed && new_wp == NULL) |
7 | 1094 { |
25306
078edc1821bf
patch 8.2.3190: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
25157
diff
changeset
|
1095 emsg(_(e_not_enough_room)); |
7 | 1096 return FAIL; |
1097 } | |
1098 oldwin_height = oldwin->w_height; | |
1099 if (need_status) | |
1100 { | |
1101 oldwin->w_status_height = STATUS_HEIGHT; | |
1102 oldwin_height -= STATUS_HEIGHT; | |
1103 } | |
1104 if (new_size == 0) | |
1105 new_size = oldwin_height / 2; | |
6052 | 1106 if (new_size > available - minheight - STATUS_HEIGHT) |
1107 new_size = available - minheight - STATUS_HEIGHT; | |
6066 | 1108 if (new_size < wmh1) |
1109 new_size = wmh1; | |
7 | 1110 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1111 // if it doesn't fit in the current window, need win_equal() |
7 | 1112 if (oldwin_height - new_size - STATUS_HEIGHT < p_wmh) |
1113 do_equal = TRUE; | |
1114 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1115 // 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
|
1116 // '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
|
1117 // instead, if possible. |
7 | 1118 if (oldwin->w_p_wfh) |
1119 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1120 // 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
|
1121 // 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
|
1122 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
|
1123 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
|
1124 |
7 | 1125 win_setheight_win(oldwin->w_height + new_size + STATUS_HEIGHT, |
1126 oldwin); | |
1127 oldwin_height = oldwin->w_height; | |
1128 if (need_status) | |
1129 oldwin_height -= STATUS_HEIGHT; | |
1130 } | |
1354 | 1131 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1132 // 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
|
1133 // 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
|
1134 if (!do_equal && p_ea && size == 0 && *p_ead != 'h' |
1354 | 1135 && oldwin->w_frame->fr_parent != NULL) |
1136 { | |
1137 frp = oldwin->w_frame->fr_parent->fr_child; | |
1138 while (frp != NULL) | |
1139 { | |
1140 if (frp->fr_win != oldwin && frp->fr_win != NULL | |
1141 && (frp->fr_win->w_height > new_size | |
1142 || frp->fr_win->w_height > oldwin_height - new_size | |
1143 - STATUS_HEIGHT)) | |
1144 { | |
1145 do_equal = TRUE; | |
1146 break; | |
1147 } | |
1148 frp = frp->fr_next; | |
1149 } | |
1150 } | |
7 | 1151 } |
1152 | |
1153 /* | |
1154 * allocate new window structure and link it in the window list | |
1155 */ | |
1156 if ((flags & WSP_TOP) == 0 | |
1157 && ((flags & WSP_BOT) | |
1158 || (flags & WSP_BELOW) | |
1159 || (!(flags & WSP_ABOVE) | |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8536
diff
changeset
|
1160 && ( (flags & WSP_VERT) ? p_spr : p_sb)))) |
7 | 1161 { |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1162 // new window below/right of current one |
3263 | 1163 if (new_wp == NULL) |
1906 | 1164 wp = win_alloc(oldwin, FALSE); |
7 | 1165 else |
1166 win_append(oldwin, wp); | |
1167 } | |
1168 else | |
1169 { | |
3263 | 1170 if (new_wp == NULL) |
1906 | 1171 wp = win_alloc(oldwin->w_prev, FALSE); |
7 | 1172 else |
1173 win_append(oldwin->w_prev, wp); | |
1174 } | |
1175 | |
3263 | 1176 if (new_wp == NULL) |
7 | 1177 { |
1178 if (wp == NULL) | |
1179 return FAIL; | |
1180 | |
1906 | 1181 new_frame(wp); |
1182 if (wp->w_frame == NULL) | |
1183 { | |
1184 win_free(wp, NULL); | |
1185 return FAIL; | |
1186 } | |
1187 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1188 // make the contents of the new window the same as the current one |
1822 | 1189 win_init(wp, curwin, flags); |
7 | 1190 } |
1191 | |
1192 /* | |
1193 * Reorganise the tree of frames to insert the new window. | |
1194 */ | |
1195 if (flags & (WSP_TOP | WSP_BOT)) | |
1196 { | |
1197 if ((topframe->fr_layout == FR_COL && (flags & WSP_VERT) == 0) | |
1198 || (topframe->fr_layout == FR_ROW && (flags & WSP_VERT) != 0)) | |
1199 { | |
1200 curfrp = topframe->fr_child; | |
1201 if (flags & WSP_BOT) | |
1202 while (curfrp->fr_next != NULL) | |
1203 curfrp = curfrp->fr_next; | |
1204 } | |
1205 else | |
1206 curfrp = topframe; | |
1207 before = (flags & WSP_TOP); | |
1208 } | |
1209 else | |
1210 { | |
1211 curfrp = oldwin->w_frame; | |
1212 if (flags & WSP_BELOW) | |
1213 before = FALSE; | |
1214 else if (flags & WSP_ABOVE) | |
1215 before = TRUE; | |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8536
diff
changeset
|
1216 else if (flags & WSP_VERT) |
7 | 1217 before = !p_spr; |
1218 else | |
1219 before = !p_sb; | |
1220 } | |
1221 if (curfrp->fr_parent == NULL || curfrp->fr_parent->fr_layout != layout) | |
1222 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1223 // 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
|
1224 frp = ALLOC_CLEAR_ONE(frame_T); |
7 | 1225 *frp = *curfrp; |
1226 curfrp->fr_layout = layout; | |
1227 frp->fr_parent = curfrp; | |
1228 frp->fr_next = NULL; | |
1229 frp->fr_prev = NULL; | |
1230 curfrp->fr_child = frp; | |
1231 curfrp->fr_win = NULL; | |
1232 curfrp = frp; | |
1233 if (frp->fr_win != NULL) | |
1234 oldwin->w_frame = frp; | |
1235 else | |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
1236 FOR_ALL_FRAMES(frp, frp->fr_child) |
7 | 1237 frp->fr_parent = curfrp; |
1238 } | |
1239 | |
3263 | 1240 if (new_wp == NULL) |
1906 | 1241 frp = wp->w_frame; |
7 | 1242 else |
3263 | 1243 frp = new_wp->w_frame; |
7 | 1244 frp->fr_parent = curfrp->fr_parent; |
1245 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1246 // Insert the new frame at the right place in the frame list. |
7 | 1247 if (before) |
1248 frame_insert(curfrp, frp); | |
1249 else | |
1250 frame_append(curfrp, frp); | |
1251 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1252 // 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
|
1253 // 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
|
1254 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
|
1255 set_fraction(oldwin); |
2665 | 1256 wp->w_fraction = oldwin->w_fraction; |
1257 | |
7 | 1258 if (flags & WSP_VERT) |
1259 { | |
1260 wp->w_p_scr = curwin->w_p_scr; | |
2665 | 1261 |
7 | 1262 if (need_status) |
1263 { | |
2115
5fd44cf99b6d
updated for version 7.2.398
Bram Moolenaar <bram@zimbu.org>
parents:
2064
diff
changeset
|
1264 win_new_height(oldwin, oldwin->w_height - 1); |
7 | 1265 oldwin->w_status_height = need_status; |
1266 } | |
1267 if (flags & (WSP_TOP | WSP_BOT)) | |
1268 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1269 // set height and row of new window to full height |
685 | 1270 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
|
1271 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
|
1272 - WINBAR_HEIGHT(wp)); |
7 | 1273 wp->w_status_height = (p_ls > 0); |
1274 } | |
1275 else | |
1276 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1277 // height and row of new window is same as current window |
7 | 1278 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
|
1279 win_new_height(wp, VISIBLE_HEIGHT(oldwin)); |
7 | 1280 wp->w_status_height = oldwin->w_status_height; |
1281 } | |
1282 frp->fr_height = curfrp->fr_height; | |
1283 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1284 // "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
|
1285 // one column for the vertical separator |
2115
5fd44cf99b6d
updated for version 7.2.398
Bram Moolenaar <bram@zimbu.org>
parents:
2064
diff
changeset
|
1286 win_new_width(wp, new_size); |
7 | 1287 if (before) |
1288 wp->w_vsep_width = 1; | |
1289 else | |
1290 { | |
1291 wp->w_vsep_width = oldwin->w_vsep_width; | |
1292 oldwin->w_vsep_width = 1; | |
1293 } | |
1294 if (flags & (WSP_TOP | WSP_BOT)) | |
1295 { | |
1296 if (flags & WSP_BOT) | |
1297 frame_add_vsep(curfrp); | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1298 // Set width of neighbor frame |
7 | 1299 frame_new_width(curfrp, curfrp->fr_width |
779 | 1300 - (new_size + ((flags & WSP_TOP) != 0)), flags & WSP_TOP, |
1301 FALSE); | |
7 | 1302 } |
1303 else | |
779 | 1304 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
|
1305 if (before) // new window left of current one |
7 | 1306 { |
1307 wp->w_wincol = oldwin->w_wincol; | |
1308 oldwin->w_wincol += new_size + 1; | |
1309 } | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1310 else // new window right of current one |
7 | 1311 wp->w_wincol = oldwin->w_wincol + oldwin->w_width + 1; |
1312 frame_fix_width(oldwin); | |
1313 frame_fix_width(wp); | |
1314 } | |
1315 else | |
1316 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1317 // width and column of new window is same as current window |
7 | 1318 if (flags & (WSP_TOP | WSP_BOT)) |
1319 { | |
1320 wp->w_wincol = 0; | |
2115
5fd44cf99b6d
updated for version 7.2.398
Bram Moolenaar <bram@zimbu.org>
parents:
2064
diff
changeset
|
1321 win_new_width(wp, Columns); |
7 | 1322 wp->w_vsep_width = 0; |
1323 } | |
1324 else | |
1325 { | |
1326 wp->w_wincol = oldwin->w_wincol; | |
2115
5fd44cf99b6d
updated for version 7.2.398
Bram Moolenaar <bram@zimbu.org>
parents:
2064
diff
changeset
|
1327 win_new_width(wp, oldwin->w_width); |
7 | 1328 wp->w_vsep_width = oldwin->w_vsep_width; |
1329 } | |
1330 frp->fr_width = curfrp->fr_width; | |
1331 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1332 // "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
|
1333 // one row for the status line |
7 | 1334 win_new_height(wp, new_size); |
32319
23d44be6ec20
patch 9.0.1491: wrong scrolling with ls=0 and :botright split
Bram Moolenaar <Bram@vim.org>
parents:
32295
diff
changeset
|
1335 int old_status_height = oldwin->w_status_height; |
7 | 1336 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
|
1337 { |
12491
7ab796b041bd
patch 8.0.1125: wrong window height when splitting window with window toolbar
Christian Brabandt <cb@256bit.org>
parents:
12487
diff
changeset
|
1338 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
|
1339 + WINBAR_HEIGHT(wp) ; |
9102
0e90f3e13d88
commit https://github.com/vim/vim/commit/991dea3ab185fb35e577ab0bdfd443cd4b43ccc6
Christian Brabandt <cb@256bit.org>
parents:
8833
diff
changeset
|
1340 |
0e90f3e13d88
commit https://github.com/vim/vim/commit/991dea3ab185fb35e577ab0bdfd443cd4b43ccc6
Christian Brabandt <cb@256bit.org>
parents:
8833
diff
changeset
|
1341 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
|
1342 new_fr_height -= STATUS_HEIGHT; |
32319
23d44be6ec20
patch 9.0.1491: wrong scrolling with ls=0 and :botright split
Bram Moolenaar <Bram@vim.org>
parents:
32295
diff
changeset
|
1343 if (flags & WSP_BOT) |
23d44be6ec20
patch 9.0.1491: wrong scrolling with ls=0 and :botright split
Bram Moolenaar <Bram@vim.org>
parents:
32295
diff
changeset
|
1344 frame_add_statusline(curfrp); |
9102
0e90f3e13d88
commit https://github.com/vim/vim/commit/991dea3ab185fb35e577ab0bdfd443cd4b43ccc6
Christian Brabandt <cb@256bit.org>
parents:
8833
diff
changeset
|
1345 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
|
1346 } |
7 | 1347 else |
1348 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
|
1349 if (before) // new window above current one |
7 | 1350 { |
1351 wp->w_winrow = oldwin->w_winrow; | |
1352 wp->w_status_height = STATUS_HEIGHT; | |
1353 oldwin->w_winrow += wp->w_height + STATUS_HEIGHT; | |
1354 } | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1355 else // new window below current one |
7 | 1356 { |
12998
dd734ee3e2fe
patch 8.0.1375: window size wrong after maximizing with WinBar
Christian Brabandt <cb@256bit.org>
parents:
12916
diff
changeset
|
1357 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
|
1358 + STATUS_HEIGHT; |
32319
23d44be6ec20
patch 9.0.1491: wrong scrolling with ls=0 and :botright split
Bram Moolenaar <Bram@vim.org>
parents:
32295
diff
changeset
|
1359 wp->w_status_height = old_status_height; |
9102
0e90f3e13d88
commit https://github.com/vim/vim/commit/991dea3ab185fb35e577ab0bdfd443cd4b43ccc6
Christian Brabandt <cb@256bit.org>
parents:
8833
diff
changeset
|
1360 if (!(flags & WSP_BOT)) |
0e90f3e13d88
commit https://github.com/vim/vim/commit/991dea3ab185fb35e577ab0bdfd443cd4b43ccc6
Christian Brabandt <cb@256bit.org>
parents:
8833
diff
changeset
|
1361 oldwin->w_status_height = STATUS_HEIGHT; |
7 | 1362 } |
1363 frame_fix_height(wp); | |
1364 frame_fix_height(oldwin); | |
1365 } | |
1366 | |
1367 if (flags & (WSP_TOP | WSP_BOT)) | |
1368 (void)win_comp_pos(); | |
1369 | |
22464
b74bdd85bb26
patch 8.2.1780: statusline not updated when splitting windows
Bram Moolenaar <Bram@vim.org>
parents:
22399
diff
changeset
|
1370 // 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
|
1371 // show something related to the window count or position. |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29702
diff
changeset
|
1372 redraw_win_later(wp, UPD_NOT_VALID); |
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29702
diff
changeset
|
1373 redraw_win_later(oldwin, UPD_NOT_VALID); |
22464
b74bdd85bb26
patch 8.2.1780: statusline not updated when splitting windows
Bram Moolenaar <Bram@vim.org>
parents:
22399
diff
changeset
|
1374 status_redraw_all(); |
7 | 1375 |
1376 if (need_status) | |
1377 { | |
1378 msg_row = Rows - 1; | |
1379 msg_col = sc_col; | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1380 msg_clr_eos_force(); // Old command/ruler may still be there |
7 | 1381 comp_col(); |
1382 msg_row = Rows - 1; | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1383 msg_col = 0; // put position back at start of line |
7 | 1384 } |
1385 | |
1386 /* | |
2115
5fd44cf99b6d
updated for version 7.2.398
Bram Moolenaar <bram@zimbu.org>
parents:
2064
diff
changeset
|
1387 * equalize the window sizes. |
7 | 1388 */ |
1389 if (do_equal || dir != 0) | |
1390 win_equal(wp, TRUE, | |
1391 (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
|
1392 : dir == 'h' ? 'b' : 'v'); |
31263
d8e7d725a666
patch 9.0.0965: using one window for executing autocommands is insufficient
Bram Moolenaar <Bram@vim.org>
parents:
31261
diff
changeset
|
1393 else if (*p_spk != 'c' && !is_aucmd_win(wp)) |
30219
bc8ad1c28b51
patch 9.0.0445: when opening/closing window text moves up/down
Bram Moolenaar <Bram@vim.org>
parents:
30134
diff
changeset
|
1394 win_fix_scroll(FALSE); |
7 | 1395 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1396 // 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
|
1397 // size was given. |
7 | 1398 if (flags & WSP_VERT) |
1399 { | |
1400 i = p_wiw; | |
1401 if (size != 0) | |
1402 p_wiw = size; | |
1403 | |
1404 # ifdef FEAT_GUI | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1405 // When 'guioptions' includes 'L' or 'R' may have to add scrollbars. |
7 | 1406 if (gui.in_use) |
1407 gui_init_which_components(NULL); | |
1408 # endif | |
1409 } | |
1410 else | |
1411 { | |
1412 i = p_wh; | |
1413 if (size != 0) | |
1414 p_wh = size; | |
1415 } | |
2115
5fd44cf99b6d
updated for version 7.2.398
Bram Moolenaar <bram@zimbu.org>
parents:
2064
diff
changeset
|
1416 |
5fd44cf99b6d
updated for version 7.2.398
Bram Moolenaar <bram@zimbu.org>
parents:
2064
diff
changeset
|
1417 /* |
5fd44cf99b6d
updated for version 7.2.398
Bram Moolenaar <bram@zimbu.org>
parents:
2064
diff
changeset
|
1418 * make the new window the current window |
5fd44cf99b6d
updated for version 7.2.398
Bram Moolenaar <bram@zimbu.org>
parents:
2064
diff
changeset
|
1419 */ |
25501
a1ed55c02e80
patch 8.2.3287: channel events not handled in BufEnter autocommand
Bram Moolenaar <Bram@vim.org>
parents:
25499
diff
changeset
|
1420 (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
|
1421 | WEE_TRIGGER_ENTER_AUTOCMDS | WEE_TRIGGER_LEAVE_AUTOCMDS); |
7 | 1422 if (flags & WSP_VERT) |
1423 p_wiw = i; | |
1424 else | |
1425 p_wh = i; | |
1426 | |
1427 return OK; | |
1428 } | |
1429 | |
1906 | 1430 |
675 | 1431 /* |
1432 * Initialize window "newp" from window "oldp". | |
1433 * Used when splitting a window and when creating a new tab page. | |
1434 * The windows will both edit the same buffer. | |
1822 | 1435 * WSP_NEWLOC may be specified in flags to prevent the location list from |
1436 * being copied. | |
675 | 1437 */ |
1438 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1439 win_init(win_T *newp, win_T *oldp, int flags UNUSED) |
675 | 1440 { |
1441 int i; | |
1442 | |
1443 newp->w_buffer = oldp->w_buffer; | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2201
diff
changeset
|
1444 #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
|
1445 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
|
1446 #endif |
675 | 1447 oldp->w_buffer->b_nwindows++; |
1448 newp->w_cursor = oldp->w_cursor; | |
1449 newp->w_valid = 0; | |
1450 newp->w_curswant = oldp->w_curswant; | |
1451 newp->w_set_curswant = oldp->w_set_curswant; | |
1452 newp->w_topline = oldp->w_topline; | |
1453 #ifdef FEAT_DIFF | |
1454 newp->w_topfill = oldp->w_topfill; | |
1455 #endif | |
1456 newp->w_leftcol = oldp->w_leftcol; | |
1457 newp->w_pcmark = oldp->w_pcmark; | |
1458 newp->w_prev_pcmark = oldp->w_prev_pcmark; | |
1459 newp->w_alt_fnum = oldp->w_alt_fnum; | |
826 | 1460 newp->w_wrow = oldp->w_wrow; |
675 | 1461 newp->w_fraction = oldp->w_fraction; |
1462 newp->w_prev_fraction_row = oldp->w_prev_fraction_row; | |
1463 copy_jumplist(oldp, newp); | |
1464 #ifdef FEAT_QUICKFIX | |
1822 | 1465 if (flags & WSP_NEWLOC) |
1466 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1467 // Don't copy the location list. |
1822 | 1468 newp->w_llist = NULL; |
1469 newp->w_llist_ref = NULL; | |
1470 } | |
1471 else | |
14844
a74786d0370c
patch 8.1.0434: copy_loclist() is too long
Christian Brabandt <cb@256bit.org>
parents:
14730
diff
changeset
|
1472 copy_loclist_stack(oldp, newp); |
675 | 1473 #endif |
5584 | 1474 newp->w_localdir = (oldp->w_localdir == NULL) |
1475 ? 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
|
1476 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
|
1477 ? NULL : vim_strsave(oldp->w_prevdir); |
675 | 1478 |
30624
f2f35161d75a
patch 9.0.0647: the 'splitscroll' option is not a good name
Bram Moolenaar <Bram@vim.org>
parents:
30574
diff
changeset
|
1479 if (*p_spk != 'c') |
30219
bc8ad1c28b51
patch 9.0.0445: when opening/closing window text moves up/down
Bram Moolenaar <Bram@vim.org>
parents:
30134
diff
changeset
|
1480 { |
32363
c114eebb5268
patch 9.0.1513: text scrolls unnecessarily when splitting
Bram Moolenaar <Bram@vim.org>
parents:
32319
diff
changeset
|
1481 if (*p_spk == 't') |
c114eebb5268
patch 9.0.1513: text scrolls unnecessarily when splitting
Bram Moolenaar <Bram@vim.org>
parents:
32319
diff
changeset
|
1482 newp->w_skipcol = oldp->w_skipcol; |
30219
bc8ad1c28b51
patch 9.0.0445: when opening/closing window text moves up/down
Bram Moolenaar <Bram@vim.org>
parents:
30134
diff
changeset
|
1483 newp->w_botline = oldp->w_botline; |
bc8ad1c28b51
patch 9.0.0445: when opening/closing window text moves up/down
Bram Moolenaar <Bram@vim.org>
parents:
30134
diff
changeset
|
1484 newp->w_prev_height = oldp->w_height - WINBAR_HEIGHT(oldp); |
bc8ad1c28b51
patch 9.0.0445: when opening/closing window text moves up/down
Bram Moolenaar <Bram@vim.org>
parents:
30134
diff
changeset
|
1485 newp->w_prev_winrow = oldp->w_winrow + 2 * WINBAR_HEIGHT(oldp); |
bc8ad1c28b51
patch 9.0.0445: when opening/closing window text moves up/down
Bram Moolenaar <Bram@vim.org>
parents:
30134
diff
changeset
|
1486 } |
bc8ad1c28b51
patch 9.0.0445: when opening/closing window text moves up/down
Bram Moolenaar <Bram@vim.org>
parents:
30134
diff
changeset
|
1487 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1488 // copy tagstack and folds |
675 | 1489 for (i = 0; i < oldp->w_tagstacklen; i++) |
1490 { | |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
16427
diff
changeset
|
1491 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
|
1492 *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
|
1493 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
|
1494 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
|
1495 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
|
1496 tag->user_data = vim_strsave(tag->user_data); |
675 | 1497 } |
1498 newp->w_tagstackidx = oldp->w_tagstackidx; | |
1499 newp->w_tagstacklen = oldp->w_tagstacklen; | |
29026
5baf5e50049b
patch 8.2.5035: when splitting a window the changelist position moves
Bram Moolenaar <Bram@vim.org>
parents:
29014
diff
changeset
|
1500 |
5baf5e50049b
patch 8.2.5035: when splitting a window the changelist position moves
Bram Moolenaar <Bram@vim.org>
parents:
29014
diff
changeset
|
1501 // Keep same changelist position in new window. |
5baf5e50049b
patch 8.2.5035: when splitting a window the changelist position moves
Bram Moolenaar <Bram@vim.org>
parents:
29014
diff
changeset
|
1502 newp->w_changelistidx = oldp->w_changelistidx; |
5baf5e50049b
patch 8.2.5035: when splitting a window the changelist position moves
Bram Moolenaar <Bram@vim.org>
parents:
29014
diff
changeset
|
1503 |
3068 | 1504 #ifdef FEAT_FOLDING |
675 | 1505 copyFoldingState(oldp, newp); |
3068 | 1506 #endif |
1906 | 1507 |
1508 win_init_some(newp, oldp); | |
26193
c83460a14407
patch 8.2.3628: looking terminal colors is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26171
diff
changeset
|
1509 #ifdef FEAT_TERMINAL |
c83460a14407
patch 8.2.3628: looking terminal colors is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26171
diff
changeset
|
1510 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
|
1511 #endif |
1906 | 1512 } |
1513 | |
1514 /* | |
6222 | 1515 * Initialize window "newp" from window "old". |
1906 | 1516 * Only the essential things are copied. |
1517 */ | |
1518 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1519 win_init_some(win_T *newp, win_T *oldp) |
1906 | 1520 { |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1521 // Use the same argument list. |
1906 | 1522 newp->w_alist = oldp->w_alist; |
1523 ++newp->w_alist->al_refcount; | |
1524 newp->w_arg_idx = oldp->w_arg_idx; | |
1525 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1526 // copy options from existing window |
1906 | 1527 win_copy_options(oldp, newp); |
675 | 1528 } |
1529 | |
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
|
1530 /* |
23645f9a5ce2
patch 8.1.1452: line and col property of popup windows not properly checked
Bram Moolenaar <Bram@vim.org>
parents:
16890
diff
changeset
|
1531 * 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
|
1532 */ |
17051
221d4b82bc0b
patch 8.1.1525: cannot move a popup window with the mouse
Bram Moolenaar <Bram@vim.org>
parents:
17043
diff
changeset
|
1533 int |
16780
491c01280a5d
patch 8.1.1392: build failure in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
16778
diff
changeset
|
1534 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
|
1535 { |
18763
49b78d6465e5
patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents:
18590
diff
changeset
|
1536 #ifdef FEAT_PROP_POPUP |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
1537 win_T *wp; |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
1538 |
19888
435726a03481
patch 8.2.0500: using the same loop in many places
Bram Moolenaar <Bram@vim.org>
parents:
19291
diff
changeset
|
1539 FOR_ALL_POPUPWINS(wp) |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
1540 if (wp == win) |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
1541 return TRUE; |
19888
435726a03481
patch 8.2.0500: using the same loop in many places
Bram Moolenaar <Bram@vim.org>
parents:
19291
diff
changeset
|
1542 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
|
1543 if (wp == win) |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
1544 return TRUE; |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
1545 #endif |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
1546 return FALSE; |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
1547 } |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
1548 |
7 | 1549 /* |
9875
42adbf172ecd
commit https://github.com/vim/vim/commit/e59215c7dcae17b03daf39517560cfaa03314f5a
Christian Brabandt <cb@256bit.org>
parents:
9858
diff
changeset
|
1550 * Check if "win" is a pointer to an existing window in the current tab page. |
7 | 1551 */ |
1552 int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1553 win_valid(win_T *win) |
7 | 1554 { |
1555 win_T *wp; | |
1556 | |
1557 if (win == NULL) | |
1558 return FALSE; | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9599
diff
changeset
|
1559 FOR_ALL_WINDOWS(wp) |
7 | 1560 if (wp == win) |
1561 return TRUE; | |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
1562 return win_valid_popup(win); |
7 | 1563 } |
1564 | |
1565 /* | |
22838
80bd5de5dcab
patch 8.2.1966: popup becomes current window after closing a terminal window
Bram Moolenaar <Bram@vim.org>
parents:
22800
diff
changeset
|
1566 * 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
|
1567 * 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
|
1568 * 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
|
1569 */ |
80bd5de5dcab
patch 8.2.1966: popup becomes current window after closing a terminal window
Bram Moolenaar <Bram@vim.org>
parents:
22800
diff
changeset
|
1570 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
|
1571 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
|
1572 { |
80bd5de5dcab
patch 8.2.1966: popup becomes current window after closing a terminal window
Bram Moolenaar <Bram@vim.org>
parents:
22800
diff
changeset
|
1573 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
|
1574 |
80bd5de5dcab
patch 8.2.1966: popup becomes current window after closing a terminal window
Bram Moolenaar <Bram@vim.org>
parents:
22800
diff
changeset
|
1575 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
|
1576 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
|
1577 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
|
1578 #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
|
1579 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
|
1580 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
|
1581 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
|
1582 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
|
1583 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
|
1584 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
|
1585 #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
|
1586 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
|
1587 } |
80bd5de5dcab
patch 8.2.1966: popup becomes current window after closing a terminal window
Bram Moolenaar <Bram@vim.org>
parents:
22800
diff
changeset
|
1588 |
80bd5de5dcab
patch 8.2.1966: popup becomes current window after closing a terminal window
Bram Moolenaar <Bram@vim.org>
parents:
22800
diff
changeset
|
1589 /* |
9875
42adbf172ecd
commit https://github.com/vim/vim/commit/e59215c7dcae17b03daf39517560cfaa03314f5a
Christian Brabandt <cb@256bit.org>
parents:
9858
diff
changeset
|
1590 * 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
|
1591 */ |
42adbf172ecd
commit https://github.com/vim/vim/commit/e59215c7dcae17b03daf39517560cfaa03314f5a
Christian Brabandt <cb@256bit.org>
parents:
9858
diff
changeset
|
1592 int |
42adbf172ecd
commit https://github.com/vim/vim/commit/e59215c7dcae17b03daf39517560cfaa03314f5a
Christian Brabandt <cb@256bit.org>
parents:
9858
diff
changeset
|
1593 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
|
1594 { |
42adbf172ecd
commit https://github.com/vim/vim/commit/e59215c7dcae17b03daf39517560cfaa03314f5a
Christian Brabandt <cb@256bit.org>
parents:
9858
diff
changeset
|
1595 win_T *wp; |
42adbf172ecd
commit https://github.com/vim/vim/commit/e59215c7dcae17b03daf39517560cfaa03314f5a
Christian Brabandt <cb@256bit.org>
parents:
9858
diff
changeset
|
1596 tabpage_T *tp; |
42adbf172ecd
commit https://github.com/vim/vim/commit/e59215c7dcae17b03daf39517560cfaa03314f5a
Christian Brabandt <cb@256bit.org>
parents:
9858
diff
changeset
|
1597 |
42adbf172ecd
commit https://github.com/vim/vim/commit/e59215c7dcae17b03daf39517560cfaa03314f5a
Christian Brabandt <cb@256bit.org>
parents:
9858
diff
changeset
|
1598 if (win == NULL) |
42adbf172ecd
commit https://github.com/vim/vim/commit/e59215c7dcae17b03daf39517560cfaa03314f5a
Christian Brabandt <cb@256bit.org>
parents:
9858
diff
changeset
|
1599 return FALSE; |
42adbf172ecd
commit https://github.com/vim/vim/commit/e59215c7dcae17b03daf39517560cfaa03314f5a
Christian Brabandt <cb@256bit.org>
parents:
9858
diff
changeset
|
1600 FOR_ALL_TABPAGES(tp) |
42adbf172ecd
commit https://github.com/vim/vim/commit/e59215c7dcae17b03daf39517560cfaa03314f5a
Christian Brabandt <cb@256bit.org>
parents:
9858
diff
changeset
|
1601 { |
42adbf172ecd
commit https://github.com/vim/vim/commit/e59215c7dcae17b03daf39517560cfaa03314f5a
Christian Brabandt <cb@256bit.org>
parents:
9858
diff
changeset
|
1602 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
|
1603 { |
42adbf172ecd
commit https://github.com/vim/vim/commit/e59215c7dcae17b03daf39517560cfaa03314f5a
Christian Brabandt <cb@256bit.org>
parents:
9858
diff
changeset
|
1604 if (wp == win) |
42adbf172ecd
commit https://github.com/vim/vim/commit/e59215c7dcae17b03daf39517560cfaa03314f5a
Christian Brabandt <cb@256bit.org>
parents:
9858
diff
changeset
|
1605 return TRUE; |
42adbf172ecd
commit https://github.com/vim/vim/commit/e59215c7dcae17b03daf39517560cfaa03314f5a
Christian Brabandt <cb@256bit.org>
parents:
9858
diff
changeset
|
1606 } |
18763
49b78d6465e5
patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents:
18590
diff
changeset
|
1607 #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
|
1608 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
|
1609 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
|
1610 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
|
1611 #endif |
9875
42adbf172ecd
commit https://github.com/vim/vim/commit/e59215c7dcae17b03daf39517560cfaa03314f5a
Christian Brabandt <cb@256bit.org>
parents:
9858
diff
changeset
|
1612 } |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
1613 return win_valid_popup(win); |
9875
42adbf172ecd
commit https://github.com/vim/vim/commit/e59215c7dcae17b03daf39517560cfaa03314f5a
Christian Brabandt <cb@256bit.org>
parents:
9858
diff
changeset
|
1614 } |
42adbf172ecd
commit https://github.com/vim/vim/commit/e59215c7dcae17b03daf39517560cfaa03314f5a
Christian Brabandt <cb@256bit.org>
parents:
9858
diff
changeset
|
1615 |
42adbf172ecd
commit https://github.com/vim/vim/commit/e59215c7dcae17b03daf39517560cfaa03314f5a
Christian Brabandt <cb@256bit.org>
parents:
9858
diff
changeset
|
1616 /* |
7 | 1617 * Return the number of windows. |
1618 */ | |
1619 int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1620 win_count(void) |
7 | 1621 { |
1622 win_T *wp; | |
1623 int count = 0; | |
1624 | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9599
diff
changeset
|
1625 FOR_ALL_WINDOWS(wp) |
7 | 1626 ++count; |
1627 return count; | |
1628 } | |
1629 | |
1630 /* | |
1631 * Make "count" windows on the screen. | |
1632 * Return actual number of windows on the screen. | |
1633 * Must be called when there is just one window, filling the whole screen | |
1634 * (excluding the command line). | |
1635 */ | |
1636 int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1637 make_windows( |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1638 int count, |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1639 int vertical UNUSED) // split windows vertically if TRUE |
7 | 1640 { |
1641 int maxcount; | |
1642 int todo; | |
1643 | |
1644 if (vertical) | |
1645 { | |
26771
fc859aea8cec
patch 8.2.3914: various spelling mistakes in comments
Bram Moolenaar <Bram@vim.org>
parents:
26602
diff
changeset
|
1646 // Each window needs at least 'winminwidth' lines and a separator |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1647 // column. |
7 | 1648 maxcount = (curwin->w_width + curwin->w_vsep_width |
1649 - (p_wiw - p_wmw)) / (p_wmw + 1); | |
1650 } | |
1651 else | |
1652 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1653 // 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
|
1654 maxcount = (VISIBLE_HEIGHT(curwin) + curwin->w_status_height |
7 | 1655 - (p_wh - p_wmh)) / (p_wmh + STATUS_HEIGHT); |
1656 } | |
1657 | |
1658 if (maxcount < 2) | |
1659 maxcount = 2; | |
1660 if (count > maxcount) | |
1661 count = maxcount; | |
1662 | |
1663 /* | |
1664 * add status line now, otherwise first window will be too big | |
1665 */ | |
1666 if (count > 1) | |
1667 last_status(TRUE); | |
1668 | |
1669 /* | |
1670 * Don't execute autocommands while creating the windows. Must do that | |
1671 * when putting the buffers in the windows. | |
1672 */ | |
1410 | 1673 block_autocmds(); |
7 | 1674 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1675 // todo is number of windows left to create |
7 | 1676 for (todo = count - 1; todo > 0; --todo) |
1677 if (vertical) | |
1678 { | |
1679 if (win_split(curwin->w_width - (curwin->w_width - todo) | |
1680 / (todo + 1) - 1, WSP_VERT | WSP_ABOVE) == FAIL) | |
1681 break; | |
1682 } | |
1683 else | |
1684 { | |
1685 if (win_split(curwin->w_height - (curwin->w_height - todo | |
1686 * STATUS_HEIGHT) / (todo + 1) | |
1687 - STATUS_HEIGHT, WSP_ABOVE) == FAIL) | |
1688 break; | |
1689 } | |
1690 | |
1410 | 1691 unblock_autocmds(); |
7 | 1692 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1693 // return actual number of windows |
7 | 1694 return (count - todo); |
1695 } | |
1696 | |
1697 /* | |
1698 * Exchange current and next window | |
1699 */ | |
1700 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1701 win_exchange(long Prenum) |
7 | 1702 { |
1703 frame_T *frp; | |
1704 frame_T *frp2; | |
1705 win_T *wp; | |
1706 win_T *wp2; | |
1707 int temp; | |
1708 | |
19271
ebeeb4b4a1fa
patch 8.2.0194: some commands can cause problems in terminal popup
Bram Moolenaar <Bram@vim.org>
parents:
19265
diff
changeset
|
1709 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
|
1710 return; |
da5f5836e90c
patch 8.1.1438: some commands cause trouble in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
16863
diff
changeset
|
1711 if (ONE_WINDOW) // just one window |
7 | 1712 { |
1713 beep_flush(); | |
1714 return; | |
1715 } | |
1716 | |
1717 #ifdef FEAT_GUI | |
1718 need_mouse_correct = TRUE; | |
1719 #endif | |
1720 | |
1721 /* | |
1722 * find window to exchange with | |
1723 */ | |
1724 if (Prenum) | |
1725 { | |
1726 frp = curwin->w_frame->fr_parent->fr_child; | |
1727 while (frp != NULL && --Prenum > 0) | |
1728 frp = frp->fr_next; | |
1729 } | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1730 else if (curwin->w_frame->fr_next != NULL) // Swap with next |
7 | 1731 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
|
1732 else // Swap last window in row/col with previous |
7 | 1733 frp = curwin->w_frame->fr_prev; |
1734 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1735 // 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
|
1736 // containing windows. |
7 | 1737 if (frp == NULL || frp->fr_win == NULL || frp->fr_win == curwin) |
1738 return; | |
1739 wp = frp->fr_win; | |
1740 | |
1741 /* | |
1742 * 1. remove curwin from the list. Remember after which window it was in wp2 | |
1743 * 2. insert curwin before wp in the list | |
1744 * if wp != wp2 | |
1745 * 3. remove wp from the list | |
1746 * 4. insert wp after wp2 | |
1747 * 5. exchange the status line height and vsep width. | |
1748 */ | |
1749 wp2 = curwin->w_prev; | |
1750 frp2 = curwin->w_frame->fr_prev; | |
1751 if (wp->w_prev != curwin) | |
1752 { | |
671 | 1753 win_remove(curwin, NULL); |
7 | 1754 frame_remove(curwin->w_frame); |
1755 win_append(wp->w_prev, curwin); | |
1756 frame_insert(frp, curwin->w_frame); | |
1757 } | |
1758 if (wp != wp2) | |
1759 { | |
671 | 1760 win_remove(wp, NULL); |
7 | 1761 frame_remove(wp->w_frame); |
1762 win_append(wp2, wp); | |
1763 if (frp2 == NULL) | |
1764 frame_insert(wp->w_frame->fr_parent->fr_child, wp->w_frame); | |
1765 else | |
1766 frame_append(frp2, wp->w_frame); | |
1767 } | |
1768 temp = curwin->w_status_height; | |
1769 curwin->w_status_height = wp->w_status_height; | |
1770 wp->w_status_height = temp; | |
1771 temp = curwin->w_vsep_width; | |
1772 curwin->w_vsep_width = wp->w_vsep_width; | |
1773 wp->w_vsep_width = temp; | |
1774 | |
25553
8b5dc14345ce
patch 8.2.3313: unused code in win_exchange() and frame_remove()
Bram Moolenaar <Bram@vim.org>
parents:
25505
diff
changeset
|
1775 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
|
1776 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
|
1777 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
|
1778 frame_fix_width(wp); |
7 | 1779 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1780 (void)win_comp_pos(); // recompute window positions |
7 | 1781 |
27251
85f56e16da9b
patch 8.2.4154: ml_get error when exchanging windows in Visual mode
Bram Moolenaar <Bram@vim.org>
parents:
27032
diff
changeset
|
1782 if (wp->w_buffer != curbuf) |
85f56e16da9b
patch 8.2.4154: ml_get error when exchanging windows in Visual mode
Bram Moolenaar <Bram@vim.org>
parents:
27032
diff
changeset
|
1783 reset_VIsual_and_resel(); |
85f56e16da9b
patch 8.2.4154: ml_get error when exchanging windows in Visual mode
Bram Moolenaar <Bram@vim.org>
parents:
27032
diff
changeset
|
1784 else if (VIsual_active) |
85f56e16da9b
patch 8.2.4154: ml_get error when exchanging windows in Visual mode
Bram Moolenaar <Bram@vim.org>
parents:
27032
diff
changeset
|
1785 wp->w_cursor = curwin->w_cursor; |
85f56e16da9b
patch 8.2.4154: ml_get error when exchanging windows in Visual mode
Bram Moolenaar <Bram@vim.org>
parents:
27032
diff
changeset
|
1786 |
7 | 1787 win_enter(wp, TRUE); |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29702
diff
changeset
|
1788 redraw_all_later(UPD_NOT_VALID); |
7 | 1789 } |
1790 | |
1791 /* | |
1792 * rotate windows: if upwards TRUE the second window becomes the first one | |
1793 * if upwards FALSE the first window becomes the second one | |
1794 */ | |
1795 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1796 win_rotate(int upwards, int count) |
7 | 1797 { |
1798 win_T *wp1; | |
1799 win_T *wp2; | |
1800 frame_T *frp; | |
1801 int n; | |
1802 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1803 if (ONE_WINDOW) // nothing to do |
7 | 1804 { |
1805 beep_flush(); | |
1806 return; | |
1807 } | |
1808 | |
1809 #ifdef FEAT_GUI | |
1810 need_mouse_correct = TRUE; | |
1811 #endif | |
1812 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1813 // 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
|
1814 FOR_ALL_FRAMES(frp, curwin->w_frame->fr_parent->fr_child) |
7 | 1815 if (frp->fr_win == NULL) |
1816 { | |
26913
d4e61d61afd9
patch 8.2.3985: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26893
diff
changeset
|
1817 emsg(_(e_cannot_rotate_when_another_window_is_split)); |
7 | 1818 return; |
1819 } | |
1820 | |
1821 while (count--) | |
1822 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1823 if (upwards) // first window becomes last window |
7 | 1824 { |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1825 // remove first window/frame from the list |
7 | 1826 frp = curwin->w_frame->fr_parent->fr_child; |
1827 wp1 = frp->fr_win; | |
671 | 1828 win_remove(wp1, NULL); |
7 | 1829 frame_remove(frp); |
1830 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1831 // find last frame and append removed window/frame after it |
7 | 1832 for ( ; frp->fr_next != NULL; frp = frp->fr_next) |
1833 ; | |
1834 win_append(frp->fr_win, wp1); | |
1835 frame_append(frp, wp1->w_frame); | |
1836 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1837 wp2 = frp->fr_win; // previously last window |
7 | 1838 } |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1839 else // last window becomes first window |
7 | 1840 { |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1841 // find last window/frame in the list and remove it |
7 | 1842 for (frp = curwin->w_frame; frp->fr_next != NULL; |
1843 frp = frp->fr_next) | |
1844 ; | |
1845 wp1 = frp->fr_win; | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1846 wp2 = wp1->w_prev; // will become last window |
671 | 1847 win_remove(wp1, NULL); |
7 | 1848 frame_remove(frp); |
1849 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1850 // append the removed window/frame before the first in the list |
7 | 1851 win_append(frp->fr_parent->fr_child->fr_win->w_prev, wp1); |
1852 frame_insert(frp->fr_parent->fr_child, frp); | |
1853 } | |
1854 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1855 // exchange status height and vsep width of old and new last window |
7 | 1856 n = wp2->w_status_height; |
1857 wp2->w_status_height = wp1->w_status_height; | |
1858 wp1->w_status_height = n; | |
1859 frame_fix_height(wp1); | |
1860 frame_fix_height(wp2); | |
1861 n = wp2->w_vsep_width; | |
1862 wp2->w_vsep_width = wp1->w_vsep_width; | |
1863 wp1->w_vsep_width = n; | |
1864 frame_fix_width(wp1); | |
1865 frame_fix_width(wp2); | |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8536
diff
changeset
|
1866 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1867 // recompute w_winrow and w_wincol for all windows |
7 | 1868 (void)win_comp_pos(); |
1869 } | |
1870 | |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29702
diff
changeset
|
1871 redraw_all_later(UPD_NOT_VALID); |
7 | 1872 } |
1873 | |
1874 /* | |
1875 * Move the current window to the very top/bottom/left/right of the screen. | |
1876 */ | |
1877 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1878 win_totop(int size, int flags) |
7 | 1879 { |
1880 int dir; | |
1881 int height = curwin->w_height; | |
1882 | |
10357
59d01e335858
commit https://github.com/vim/vim/commit/459ca563128f2edb7e3bb190090bbb755a56dd55
Christian Brabandt <cb@256bit.org>
parents:
10349
diff
changeset
|
1883 if (ONE_WINDOW) |
7 | 1884 { |
1885 beep_flush(); | |
1886 return; | |
1887 } | |
17516
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
1888 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
|
1889 return; |
7 | 1890 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1891 // Remove the window and frame from the tree of frames. |
671 | 1892 (void)winframe_remove(curwin, &dir, NULL); |
1893 win_remove(curwin, NULL); | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1894 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
|
1895 (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
|
1896 |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1897 // Split a window on the desired side and put the window there. |
7 | 1898 (void)win_split_ins(size, flags, curwin, dir); |
1899 if (!(flags & WSP_VERT)) | |
1900 { | |
1901 win_setheight(height); | |
1902 if (p_ea) | |
1903 win_equal(curwin, TRUE, 'v'); | |
1904 } | |
1905 | |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8536
diff
changeset
|
1906 #if defined(FEAT_GUI) |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1907 // 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
|
1908 // scrollbars. Have to update them anyway. |
1906 | 1909 gui_may_update_scrollbars(); |
1910 #endif | |
7 | 1911 } |
1912 | |
1913 /* | |
1914 * Move window "win1" to below/right of "win2" and make "win1" the current | |
1915 * window. Only works within the same frame! | |
1916 */ | |
1917 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1918 win_move_after(win_T *win1, win_T *win2) |
7 | 1919 { |
1920 int height; | |
1921 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1922 // check if the arguments are reasonable |
7 | 1923 if (win1 == win2) |
1924 return; | |
1925 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1926 // check if there is something to do |
7 | 1927 if (win2->w_next != win1) |
1928 { | |
17516
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
1929 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
|
1930 { |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
1931 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
|
1932 return; |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
1933 } |
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
1934 |
21020
6c634e63989c
patch 8.2.1061: insufficient testing for src/window.c
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1935 // 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
|
1936 // window |
7 | 1937 if (win1 == lastwin) |
1938 { | |
1939 height = win1->w_prev->w_status_height; | |
1940 win1->w_prev->w_status_height = win1->w_status_height; | |
1941 win1->w_status_height = height; | |
1070 | 1942 if (win1->w_prev->w_vsep_width == 1) |
1943 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1944 // 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
|
1945 // add it to the last window. Adjust the frame widths. |
1070 | 1946 win1->w_prev->w_vsep_width = 0; |
1947 win1->w_prev->w_frame->fr_width -= 1; | |
1948 win1->w_vsep_width = 1; | |
1949 win1->w_frame->fr_width += 1; | |
1950 } | |
7 | 1951 } |
1952 else if (win2 == lastwin) | |
1953 { | |
1954 height = win1->w_status_height; | |
1955 win1->w_status_height = win2->w_status_height; | |
1956 win2->w_status_height = height; | |
1070 | 1957 if (win1->w_vsep_width == 1) |
1958 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1959 // 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
|
1960 // window, win2. Adjust the frame widths. |
1070 | 1961 win2->w_vsep_width = 1; |
1962 win2->w_frame->fr_width += 1; | |
1963 win1->w_vsep_width = 0; | |
1964 win1->w_frame->fr_width -= 1; | |
1965 } | |
7 | 1966 } |
671 | 1967 win_remove(win1, NULL); |
7 | 1968 frame_remove(win1->w_frame); |
1969 win_append(win2, win1); | |
1970 frame_append(win2->w_frame, win1->w_frame); | |
1971 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1972 (void)win_comp_pos(); // recompute w_winrow for all windows |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29702
diff
changeset
|
1973 redraw_later(UPD_NOT_VALID); |
7 | 1974 } |
1975 win_enter(win1, FALSE); | |
1976 } | |
1977 | |
1978 /* | |
1979 * Make all windows the same height. | |
1980 * 'next_curwin' will soon be the current window, make sure it has enough | |
1981 * rows. | |
1982 */ | |
1983 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1984 win_equal( |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1985 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
|
1986 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
|
1987 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
|
1988 // 'b' for both, 0 for using p_ead |
7 | 1989 { |
1990 if (dir == 0) | |
1991 dir = *p_ead; | |
1992 win_equal_rec(next_curwin == NULL ? curwin : next_curwin, current, | |
685 | 1993 topframe, dir, 0, tabline_height(), |
667 | 1994 (int)Columns, topframe->fr_height); |
31263
d8e7d725a666
patch 9.0.0965: using one window for executing autocommands is insufficient
Bram Moolenaar <Bram@vim.org>
parents:
31261
diff
changeset
|
1995 if (*p_spk != 'c' && !is_aucmd_win(next_curwin)) |
30219
bc8ad1c28b51
patch 9.0.0445: when opening/closing window text moves up/down
Bram Moolenaar <Bram@vim.org>
parents:
30134
diff
changeset
|
1996 win_fix_scroll(TRUE); |
7 | 1997 } |
1998 | |
1999 /* | |
2000 * Set a frame to a new position and height, spreading the available room | |
2001 * equally over contained frames. | |
2002 * The window "next_curwin" (if not NULL) should at least get the size from | |
2003 * 'winheight' and 'winwidth' if possible. | |
2004 */ | |
2005 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2006 win_equal_rec( |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2007 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
|
2008 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
|
2009 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
|
2010 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
|
2011 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
|
2012 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
|
2013 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
|
2014 int height) // new height of frame |
7 | 2015 { |
2016 int n, m; | |
2017 int extra_sep = 0; | |
2018 int wincount, totwincount = 0; | |
2019 frame_T *fr; | |
2020 int next_curwin_size = 0; | |
2021 int room = 0; | |
2022 int new_size; | |
2023 int has_next_curwin = 0; | |
2024 int hnc; | |
2025 | |
2026 if (topfr->fr_layout == FR_LEAF) | |
2027 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2028 // 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
|
2029 // Redraw when size or position changes |
7 | 2030 if (topfr->fr_height != height || topfr->fr_win->w_winrow != row |
2031 || topfr->fr_width != width || topfr->fr_win->w_wincol != col | |
2032 ) | |
2033 { | |
2034 topfr->fr_win->w_winrow = row; | |
2035 frame_new_height(topfr, height, FALSE, FALSE); | |
2036 topfr->fr_win->w_wincol = col; | |
779 | 2037 frame_new_width(topfr, width, FALSE, FALSE); |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29702
diff
changeset
|
2038 redraw_all_later(UPD_NOT_VALID); |
7 | 2039 } |
2040 } | |
2041 else if (topfr->fr_layout == FR_ROW) | |
2042 { | |
2043 topfr->fr_width = width; | |
2044 topfr->fr_height = height; | |
2045 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2046 if (dir != 'v') // equalize frame widths |
7 | 2047 { |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2048 // 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
|
2049 // frame. |
7 | 2050 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
|
2051 // add one for the rightmost window, it doesn't have a separator |
7 | 2052 if (col + width == Columns) |
2053 extra_sep = 1; | |
2054 else | |
2055 extra_sep = 0; | |
2056 totwincount = (n + extra_sep) / (p_wmw + 1); | |
779 | 2057 has_next_curwin = frame_has_win(topfr, next_curwin); |
2058 | |
2059 /* | |
2060 * Compute width for "next_curwin" window and room available for | |
2061 * other windows. | |
2062 * "m" is the minimal width when counting p_wiw for "next_curwin". | |
2063 */ | |
7 | 2064 m = frame_minwidth(topfr, next_curwin); |
2065 room = width - m; | |
2066 if (room < 0) | |
2067 { | |
2068 next_curwin_size = p_wiw + room; | |
2069 room = 0; | |
2070 } | |
2071 else | |
2072 { | |
779 | 2073 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
|
2074 FOR_ALL_FRAMES(fr, topfr->fr_child) |
779 | 2075 { |
29566
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29548
diff
changeset
|
2076 if (!frame_fixed_width(fr)) |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29548
diff
changeset
|
2077 continue; |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29548
diff
changeset
|
2078 // If 'winfixwidth' set keep the window width if possible. |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2079 // Watch out for this window being the next_curwin. |
29566
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29548
diff
changeset
|
2080 n = frame_minwidth(fr, NOWIN); |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29548
diff
changeset
|
2081 new_size = fr->fr_width; |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29548
diff
changeset
|
2082 if (frame_has_win(fr, next_curwin)) |
779 | 2083 { |
29566
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29548
diff
changeset
|
2084 room += p_wiw - p_wmw; |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29548
diff
changeset
|
2085 next_curwin_size = 0; |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29548
diff
changeset
|
2086 if (new_size < p_wiw) |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29548
diff
changeset
|
2087 new_size = p_wiw; |
779 | 2088 } |
29566
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29548
diff
changeset
|
2089 else |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29548
diff
changeset
|
2090 // These windows don't use up room. |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29548
diff
changeset
|
2091 totwincount -= (n + (fr->fr_next == NULL |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29548
diff
changeset
|
2092 ? extra_sep : 0)) / (p_wmw + 1); |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29548
diff
changeset
|
2093 room -= new_size - n; |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29548
diff
changeset
|
2094 if (room < 0) |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29548
diff
changeset
|
2095 { |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29548
diff
changeset
|
2096 new_size += room; |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29548
diff
changeset
|
2097 room = 0; |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29548
diff
changeset
|
2098 } |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29548
diff
changeset
|
2099 fr->fr_newwidth = new_size; |
779 | 2100 } |
2101 if (next_curwin_size == -1) | |
2102 { | |
2103 if (!has_next_curwin) | |
2104 next_curwin_size = 0; | |
2105 else if (totwincount > 1 | |
2106 && (room + (totwincount - 2)) | |
2107 / (totwincount - 1) > p_wiw) | |
2108 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2109 // 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
|
2110 // the room equally. |
834 | 2111 next_curwin_size = (room + p_wiw |
2112 + (totwincount - 1) * p_wmw | |
2113 + (totwincount - 1)) / totwincount; | |
779 | 2114 room -= next_curwin_size - p_wiw; |
2115 } | |
2116 else | |
2117 next_curwin_size = p_wiw; | |
2118 } | |
7 | 2119 } |
779 | 2120 |
2121 if (has_next_curwin) | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2122 --totwincount; // don't count curwin |
7 | 2123 } |
2124 | |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
2125 FOR_ALL_FRAMES(fr, topfr->fr_child) |
7 | 2126 { |
2127 wincount = 1; | |
2128 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
|
2129 // last frame gets all that remains (avoid roundoff error) |
7 | 2130 new_size = width; |
2131 else if (dir == 'v') | |
2132 new_size = fr->fr_width; | |
779 | 2133 else if (frame_fixed_width(fr)) |
2134 { | |
2135 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
|
2136 wincount = 0; // doesn't count as a sizeable window |
779 | 2137 } |
7 | 2138 else |
2139 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2140 // Compute the maximum number of windows horiz. in "fr". |
7 | 2141 n = frame_minwidth(fr, NOWIN); |
2142 wincount = (n + (fr->fr_next == NULL ? extra_sep : 0)) | |
2143 / (p_wmw + 1); | |
2144 m = frame_minwidth(fr, next_curwin); | |
779 | 2145 if (has_next_curwin) |
2146 hnc = frame_has_win(fr, next_curwin); | |
2147 else | |
2148 hnc = FALSE; | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2149 if (hnc) // don't count next_curwin |
7 | 2150 --wincount; |
779 | 2151 if (totwincount == 0) |
2152 new_size = room; | |
2153 else | |
2154 new_size = (wincount * room + ((unsigned)totwincount >> 1)) | |
7 | 2155 / totwincount; |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2156 if (hnc) // add next_curwin size |
7 | 2157 { |
2158 next_curwin_size -= p_wiw - (m - n); | |
30525
6fa498af368d
patch 9.0.0598: using negative array index with negative width window
Bram Moolenaar <Bram@vim.org>
parents:
30439
diff
changeset
|
2159 if (next_curwin_size < 0) |
6fa498af368d
patch 9.0.0598: using negative array index with negative width window
Bram Moolenaar <Bram@vim.org>
parents:
30439
diff
changeset
|
2160 next_curwin_size = 0; |
7 | 2161 new_size += next_curwin_size; |
779 | 2162 room -= new_size - next_curwin_size; |
7 | 2163 } |
779 | 2164 else |
2165 room -= new_size; | |
2166 new_size += n; | |
7 | 2167 } |
2168 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2169 // 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
|
2170 // window, unless equalizing all frames. |
7 | 2171 if (!current || dir != 'v' || topfr->fr_parent != NULL |
2172 || (new_size != fr->fr_width) | |
2173 || frame_has_win(fr, next_curwin)) | |
2174 win_equal_rec(next_curwin, current, fr, dir, col, row, | |
779 | 2175 new_size, height); |
2176 col += new_size; | |
2177 width -= new_size; | |
7 | 2178 totwincount -= wincount; |
2179 } | |
2180 } | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2181 else // topfr->fr_layout == FR_COL |
7 | 2182 { |
2183 topfr->fr_width = width; | |
2184 topfr->fr_height = height; | |
2185 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2186 if (dir != 'h') // equalize frame heights |
7 | 2187 { |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2188 // Compute maximum number of windows vertically in this frame. |
7 | 2189 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
|
2190 // add one for the bottom window if it doesn't have a statusline |
7 | 2191 if (row + height == cmdline_row && p_ls == 0) |
2192 extra_sep = 1; | |
2193 else | |
2194 extra_sep = 0; | |
2195 totwincount = (n + extra_sep) / (p_wmh + 1); | |
2196 has_next_curwin = frame_has_win(topfr, next_curwin); | |
2197 | |
2198 /* | |
2199 * Compute height for "next_curwin" window and room available for | |
2200 * other windows. | |
2201 * "m" is the minimal height when counting p_wh for "next_curwin". | |
2202 */ | |
2203 m = frame_minheight(topfr, next_curwin); | |
2204 room = height - m; | |
2205 if (room < 0) | |
2206 { | |
26771
fc859aea8cec
patch 8.2.3914: various spelling mistakes in comments
Bram Moolenaar <Bram@vim.org>
parents:
26602
diff
changeset
|
2207 // The room is less than 'winheight', use all space for the |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2208 // current window. |
7 | 2209 next_curwin_size = p_wh + room; |
2210 room = 0; | |
2211 } | |
2212 else | |
2213 { | |
2214 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
|
2215 FOR_ALL_FRAMES(fr, topfr->fr_child) |
7 | 2216 { |
29566
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29548
diff
changeset
|
2217 if (!frame_fixed_height(fr)) |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29548
diff
changeset
|
2218 continue; |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2219 // 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
|
2220 // possible. |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2221 // Watch out for this window being the next_curwin. |
29566
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29548
diff
changeset
|
2222 n = frame_minheight(fr, NOWIN); |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29548
diff
changeset
|
2223 new_size = fr->fr_height; |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29548
diff
changeset
|
2224 if (frame_has_win(fr, next_curwin)) |
7 | 2225 { |
29566
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29548
diff
changeset
|
2226 room += p_wh - p_wmh; |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29548
diff
changeset
|
2227 next_curwin_size = 0; |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29548
diff
changeset
|
2228 if (new_size < p_wh) |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29548
diff
changeset
|
2229 new_size = p_wh; |
7 | 2230 } |
29566
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29548
diff
changeset
|
2231 else |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29548
diff
changeset
|
2232 // These windows don't use up room. |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29548
diff
changeset
|
2233 totwincount -= (n + (fr->fr_next == NULL |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29548
diff
changeset
|
2234 ? extra_sep : 0)) / (p_wmh + 1); |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29548
diff
changeset
|
2235 room -= new_size - n; |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29548
diff
changeset
|
2236 if (room < 0) |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29548
diff
changeset
|
2237 { |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29548
diff
changeset
|
2238 new_size += room; |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29548
diff
changeset
|
2239 room = 0; |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29548
diff
changeset
|
2240 } |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29548
diff
changeset
|
2241 fr->fr_newheight = new_size; |
7 | 2242 } |
2243 if (next_curwin_size == -1) | |
2244 { | |
2245 if (!has_next_curwin) | |
2246 next_curwin_size = 0; | |
2247 else if (totwincount > 1 | |
2248 && (room + (totwincount - 2)) | |
2249 / (totwincount - 1) > p_wh) | |
2250 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2251 // 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
|
2252 // spread the room equally. |
834 | 2253 next_curwin_size = (room + p_wh |
2254 + (totwincount - 1) * p_wmh | |
7 | 2255 + (totwincount - 1)) / totwincount; |
2256 room -= next_curwin_size - p_wh; | |
2257 } | |
2258 else | |
2259 next_curwin_size = p_wh; | |
2260 } | |
2261 } | |
2262 | |
2263 if (has_next_curwin) | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2264 --totwincount; // don't count curwin |
7 | 2265 } |
2266 | |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
2267 FOR_ALL_FRAMES(fr, topfr->fr_child) |
7 | 2268 { |
2269 wincount = 1; | |
2270 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
|
2271 // last frame gets all that remains (avoid roundoff error) |
7 | 2272 new_size = height; |
2273 else if (dir == 'h') | |
2274 new_size = fr->fr_height; | |
2275 else if (frame_fixed_height(fr)) | |
2276 { | |
2277 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
|
2278 wincount = 0; // doesn't count as a sizeable window |
7 | 2279 } |
2280 else | |
2281 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2282 // Compute the maximum number of windows vert. in "fr". |
7 | 2283 n = frame_minheight(fr, NOWIN); |
2284 wincount = (n + (fr->fr_next == NULL ? extra_sep : 0)) | |
2285 / (p_wmh + 1); | |
2286 m = frame_minheight(fr, next_curwin); | |
2287 if (has_next_curwin) | |
2288 hnc = frame_has_win(fr, next_curwin); | |
2289 else | |
2290 hnc = FALSE; | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2291 if (hnc) // don't count next_curwin |
7 | 2292 --wincount; |
2293 if (totwincount == 0) | |
2294 new_size = room; | |
2295 else | |
2296 new_size = (wincount * room + ((unsigned)totwincount >> 1)) | |
2297 / totwincount; | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2298 if (hnc) // add next_curwin size |
7 | 2299 { |
2300 next_curwin_size -= p_wh - (m - n); | |
2301 new_size += next_curwin_size; | |
2302 room -= new_size - next_curwin_size; | |
2303 } | |
2304 else | |
2305 room -= new_size; | |
2306 new_size += n; | |
2307 } | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2308 // 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
|
2309 // window, unless equalizing all frames. |
7 | 2310 if (!current || dir != 'h' || topfr->fr_parent != NULL |
2311 || (new_size != fr->fr_height) | |
2312 || frame_has_win(fr, next_curwin)) | |
2313 win_equal_rec(next_curwin, current, fr, dir, col, row, | |
2314 width, new_size); | |
2315 row += new_size; | |
2316 height -= new_size; | |
2317 totwincount -= wincount; | |
2318 } | |
2319 } | |
2320 } | |
2321 | |
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
|
2322 #ifdef FEAT_JOB_CHANNEL |
32216
6651b86aed3b
patch 9.0.1439: start Insert mode when accessing a hidden prompt buffer
Bram Moolenaar <Bram@vim.org>
parents:
32118
diff
changeset
|
2323 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
|
2324 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
|
2325 { |
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
|
2326 // 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
|
2327 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
|
2328 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
|
2329 |
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
|
2330 // 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
|
2331 // 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
|
2332 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
|
2333 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
|
2334 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
|
2335 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
|
2336 |
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
2337 // 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
|
2338 // 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
|
2339 // mode when entering the window again. |
28773
d770568e6c98
patch 8.2.4911: the mode #defines are not clearly named
Bram Moolenaar <Bram@vim.org>
parents:
28688
diff
changeset
|
2340 if (State & MODE_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
|
2341 { |
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
|
2342 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
|
2343 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
|
2344 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
|
2345 } |
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
|
2346 } |
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
2347 |
22470
f7471450243c
patch 8.2.1783: try-catch test fails
Bram Moolenaar <Bram@vim.org>
parents:
22464
diff
changeset
|
2348 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
|
2349 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
|
2350 { |
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
|
2351 // 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
|
2352 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
|
2353 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
|
2354 |
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
|
2355 // 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
|
2356 // 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
|
2357 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
|
2358 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
|
2359 |
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
|
2360 // 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
|
2361 // mode when we left it and not already in Insert mode. |
28773
d770568e6c98
patch 8.2.4911: the mode #defines are not clearly named
Bram Moolenaar <Bram@vim.org>
parents:
28688
diff
changeset
|
2362 if ((State & MODE_INSERT) == 0) |
26280
b93e176e7998
patch 8.2.3671: restarting Insert mode in prompt buffer too often
Bram Moolenaar <Bram@vim.org>
parents:
26193
diff
changeset
|
2363 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
|
2364 } |
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13837
diff
changeset
|
2365 #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
|
2366 |
28211
522864f990ec
patch 8.2.4631: crash when switching window in BufWipeout autocommand
Bram Moolenaar <Bram@vim.org>
parents:
28169
diff
changeset
|
2367 static void |
522864f990ec
patch 8.2.4631: crash when switching window in BufWipeout autocommand
Bram Moolenaar <Bram@vim.org>
parents:
28169
diff
changeset
|
2368 win_init_empty(win_T *wp) |
522864f990ec
patch 8.2.4631: crash when switching window in BufWipeout autocommand
Bram Moolenaar <Bram@vim.org>
parents:
28169
diff
changeset
|
2369 { |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29702
diff
changeset
|
2370 redraw_win_later(wp, UPD_NOT_VALID); |
28211
522864f990ec
patch 8.2.4631: crash when switching window in BufWipeout autocommand
Bram Moolenaar <Bram@vim.org>
parents:
28169
diff
changeset
|
2371 wp->w_lines_valid = 0; |
522864f990ec
patch 8.2.4631: crash when switching window in BufWipeout autocommand
Bram Moolenaar <Bram@vim.org>
parents:
28169
diff
changeset
|
2372 wp->w_cursor.lnum = 1; |
522864f990ec
patch 8.2.4631: crash when switching window in BufWipeout autocommand
Bram Moolenaar <Bram@vim.org>
parents:
28169
diff
changeset
|
2373 wp->w_curswant = wp->w_cursor.col = 0; |
522864f990ec
patch 8.2.4631: crash when switching window in BufWipeout autocommand
Bram Moolenaar <Bram@vim.org>
parents:
28169
diff
changeset
|
2374 wp->w_cursor.coladd = 0; |
522864f990ec
patch 8.2.4631: crash when switching window in BufWipeout autocommand
Bram Moolenaar <Bram@vim.org>
parents:
28169
diff
changeset
|
2375 wp->w_pcmark.lnum = 1; // pcmark not cleared but set to line 1 |
522864f990ec
patch 8.2.4631: crash when switching window in BufWipeout autocommand
Bram Moolenaar <Bram@vim.org>
parents:
28169
diff
changeset
|
2376 wp->w_pcmark.col = 0; |
522864f990ec
patch 8.2.4631: crash when switching window in BufWipeout autocommand
Bram Moolenaar <Bram@vim.org>
parents:
28169
diff
changeset
|
2377 wp->w_prev_pcmark.lnum = 0; |
522864f990ec
patch 8.2.4631: crash when switching window in BufWipeout autocommand
Bram Moolenaar <Bram@vim.org>
parents:
28169
diff
changeset
|
2378 wp->w_prev_pcmark.col = 0; |
522864f990ec
patch 8.2.4631: crash when switching window in BufWipeout autocommand
Bram Moolenaar <Bram@vim.org>
parents:
28169
diff
changeset
|
2379 wp->w_topline = 1; |
522864f990ec
patch 8.2.4631: crash when switching window in BufWipeout autocommand
Bram Moolenaar <Bram@vim.org>
parents:
28169
diff
changeset
|
2380 #ifdef FEAT_DIFF |
522864f990ec
patch 8.2.4631: crash when switching window in BufWipeout autocommand
Bram Moolenaar <Bram@vim.org>
parents:
28169
diff
changeset
|
2381 wp->w_topfill = 0; |
522864f990ec
patch 8.2.4631: crash when switching window in BufWipeout autocommand
Bram Moolenaar <Bram@vim.org>
parents:
28169
diff
changeset
|
2382 #endif |
522864f990ec
patch 8.2.4631: crash when switching window in BufWipeout autocommand
Bram Moolenaar <Bram@vim.org>
parents:
28169
diff
changeset
|
2383 wp->w_botline = 2; |
522864f990ec
patch 8.2.4631: crash when switching window in BufWipeout autocommand
Bram Moolenaar <Bram@vim.org>
parents:
28169
diff
changeset
|
2384 #if defined(FEAT_SYN_HL) || defined(FEAT_SPELL) |
522864f990ec
patch 8.2.4631: crash when switching window in BufWipeout autocommand
Bram Moolenaar <Bram@vim.org>
parents:
28169
diff
changeset
|
2385 wp->w_s = &wp->w_buffer->b_s; |
522864f990ec
patch 8.2.4631: crash when switching window in BufWipeout autocommand
Bram Moolenaar <Bram@vim.org>
parents:
28169
diff
changeset
|
2386 #endif |
522864f990ec
patch 8.2.4631: crash when switching window in BufWipeout autocommand
Bram Moolenaar <Bram@vim.org>
parents:
28169
diff
changeset
|
2387 #ifdef FEAT_TERMINAL |
522864f990ec
patch 8.2.4631: crash when switching window in BufWipeout autocommand
Bram Moolenaar <Bram@vim.org>
parents:
28169
diff
changeset
|
2388 term_reset_wincolor(wp); |
522864f990ec
patch 8.2.4631: crash when switching window in BufWipeout autocommand
Bram Moolenaar <Bram@vim.org>
parents:
28169
diff
changeset
|
2389 #endif |
522864f990ec
patch 8.2.4631: crash when switching window in BufWipeout autocommand
Bram Moolenaar <Bram@vim.org>
parents:
28169
diff
changeset
|
2390 } |
522864f990ec
patch 8.2.4631: crash when switching window in BufWipeout autocommand
Bram Moolenaar <Bram@vim.org>
parents:
28169
diff
changeset
|
2391 |
522864f990ec
patch 8.2.4631: crash when switching window in BufWipeout autocommand
Bram Moolenaar <Bram@vim.org>
parents:
28169
diff
changeset
|
2392 /* |
522864f990ec
patch 8.2.4631: crash when switching window in BufWipeout autocommand
Bram Moolenaar <Bram@vim.org>
parents:
28169
diff
changeset
|
2393 * Init the current window "curwin". |
522864f990ec
patch 8.2.4631: crash when switching window in BufWipeout autocommand
Bram Moolenaar <Bram@vim.org>
parents:
28169
diff
changeset
|
2394 * Called when a new file is being edited. |
522864f990ec
patch 8.2.4631: crash when switching window in BufWipeout autocommand
Bram Moolenaar <Bram@vim.org>
parents:
28169
diff
changeset
|
2395 */ |
522864f990ec
patch 8.2.4631: crash when switching window in BufWipeout autocommand
Bram Moolenaar <Bram@vim.org>
parents:
28169
diff
changeset
|
2396 void |
522864f990ec
patch 8.2.4631: crash when switching window in BufWipeout autocommand
Bram Moolenaar <Bram@vim.org>
parents:
28169
diff
changeset
|
2397 curwin_init(void) |
522864f990ec
patch 8.2.4631: crash when switching window in BufWipeout autocommand
Bram Moolenaar <Bram@vim.org>
parents:
28169
diff
changeset
|
2398 { |
522864f990ec
patch 8.2.4631: crash when switching window in BufWipeout autocommand
Bram Moolenaar <Bram@vim.org>
parents:
28169
diff
changeset
|
2399 win_init_empty(curwin); |
522864f990ec
patch 8.2.4631: crash when switching window in BufWipeout autocommand
Bram Moolenaar <Bram@vim.org>
parents:
28169
diff
changeset
|
2400 } |
522864f990ec
patch 8.2.4631: crash when switching window in BufWipeout autocommand
Bram Moolenaar <Bram@vim.org>
parents:
28169
diff
changeset
|
2401 |
7 | 2402 /* |
11199
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
2403 * Close all windows for buffer "buf". |
7 | 2404 */ |
2405 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2406 close_windows( |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2407 buf_T *buf, |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2408 int keep_curwin) // don't close "curwin" |
7 | 2409 { |
671 | 2410 win_T *wp; |
2411 tabpage_T *tp, *nexttp; | |
9599
42a8a81decdf
commit https://github.com/vim/vim/commit/12c11d553053f5a9eae9eb3c518279b12fa928c2
Christian Brabandt <cb@256bit.org>
parents:
9595
diff
changeset
|
2412 int count = tabpage_index(NULL); |
7 | 2413 |
2414 ++RedrawingDisabled; | |
671 | 2415 |
10357
59d01e335858
commit https://github.com/vim/vim/commit/459ca563128f2edb7e3bb190090bbb755a56dd55
Christian Brabandt <cb@256bit.org>
parents:
10349
diff
changeset
|
2416 for (wp = firstwin; wp != NULL && !ONE_WINDOW; ) |
7 | 2417 { |
3570 | 2418 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
|
2419 && !(wp->w_closing || wp->w_buffer->b_locked > 0)) |
7 | 2420 { |
11199
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
2421 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
|
2422 // 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
|
2423 // 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
|
2424 break; |
671 | 2425 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2426 // Start all over, autocommands may change the window layout. |
671 | 2427 wp = firstwin; |
7 | 2428 } |
2429 else | |
671 | 2430 wp = wp->w_next; |
7 | 2431 } |
671 | 2432 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2433 // Also check windows in other tab pages. |
671 | 2434 for (tp = first_tabpage; tp != NULL; tp = nexttp) |
2435 { | |
2436 nexttp = tp->tp_next; | |
672 | 2437 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
|
2438 FOR_ALL_WINDOWS_IN_TAB(tp, wp) |
3570 | 2439 if (wp->w_buffer == buf |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13308
diff
changeset
|
2440 && !(wp->w_closing || wp->w_buffer->b_locked > 0)) |
671 | 2441 { |
2442 win_close_othertab(wp, FALSE, tp); | |
2443 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2444 // 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
|
2445 // autocommands may change the window layout. |
671 | 2446 nexttp = first_tabpage; |
2447 break; | |
2448 } | |
2449 } | |
2450 | |
7 | 2451 --RedrawingDisabled; |
671 | 2452 |
9599
42a8a81decdf
commit https://github.com/vim/vim/commit/12c11d553053f5a9eae9eb3c518279b12fa928c2
Christian Brabandt <cb@256bit.org>
parents:
9595
diff
changeset
|
2453 if (count != tabpage_index(NULL)) |
42a8a81decdf
commit https://github.com/vim/vim/commit/12c11d553053f5a9eae9eb3c518279b12fa928c2
Christian Brabandt <cb@256bit.org>
parents:
9595
diff
changeset
|
2454 apply_autocmds(EVENT_TABCLOSED, NULL, NULL, FALSE, curbuf); |
7 | 2455 } |
2456 | |
2457 /* | |
1906 | 2458 * Return TRUE if the current window is the only window that exists (ignoring |
31263
d8e7d725a666
patch 9.0.0965: using one window for executing autocommands is insufficient
Bram Moolenaar <Bram@vim.org>
parents:
31261
diff
changeset
|
2459 * "aucmd_win[]"). |
672 | 2460 * Returns FALSE if there is a window, possibly in another tab page. |
667 | 2461 */ |
672 | 2462 static int |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2463 last_window(void) |
667 | 2464 { |
1906 | 2465 return (one_window() && first_tabpage->tp_next == NULL); |
2466 } | |
2467 | |
2468 /* | |
31263
d8e7d725a666
patch 9.0.0965: using one window for executing autocommands is insufficient
Bram Moolenaar <Bram@vim.org>
parents:
31261
diff
changeset
|
2469 * Return TRUE if there is only one window other than "aucmd_win[]" in the |
1906 | 2470 * current tab page. |
2471 */ | |
3365 | 2472 int |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2473 one_window(void) |
1906 | 2474 { |
2475 win_T *wp; | |
2476 int seen_one = FALSE; | |
2477 | |
2478 FOR_ALL_WINDOWS(wp) | |
2479 { | |
31263
d8e7d725a666
patch 9.0.0965: using one window for executing autocommands is insufficient
Bram Moolenaar <Bram@vim.org>
parents:
31261
diff
changeset
|
2480 if (!is_aucmd_win(wp)) |
1906 | 2481 { |
2482 if (seen_one) | |
2483 return FALSE; | |
2484 seen_one = TRUE; | |
2485 } | |
2486 } | |
2487 return TRUE; | |
667 | 2488 } |
2489 | |
2490 /* | |
3535 | 2491 * Close the possibly last window in a tab page. |
2492 * Returns TRUE when the window was closed already. | |
2493 */ | |
2494 static int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2495 close_last_window_tabpage( |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2496 win_T *win, |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2497 int free_buf, |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2498 tabpage_T *prev_curtab) |
3535 | 2499 { |
31827
1009c33499e7
patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31437
diff
changeset
|
2500 if (!ONE_WINDOW) |
1009c33499e7
patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31437
diff
changeset
|
2501 return FALSE; |
1009c33499e7
patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31437
diff
changeset
|
2502 |
1009c33499e7
patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31437
diff
changeset
|
2503 buf_T *old_curbuf = curbuf; |
1009c33499e7
patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31437
diff
changeset
|
2504 |
1009c33499e7
patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31437
diff
changeset
|
2505 /* |
1009c33499e7
patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31437
diff
changeset
|
2506 * Closing the last window in a tab page. First go to another tab |
1009c33499e7
patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31437
diff
changeset
|
2507 * page and then close the window and the tab page. This avoids that |
1009c33499e7
patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31437
diff
changeset
|
2508 * curwin and curtab are invalid while we are freeing memory, they may |
1009c33499e7
patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31437
diff
changeset
|
2509 * be used in GUI events. |
1009c33499e7
patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31437
diff
changeset
|
2510 * Don't trigger autocommands yet, they may use wrong values, so do |
1009c33499e7
patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31437
diff
changeset
|
2511 * that below. |
1009c33499e7
patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31437
diff
changeset
|
2512 */ |
1009c33499e7
patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31437
diff
changeset
|
2513 goto_tabpage_tp(alt_tabpage(), FALSE, TRUE); |
1009c33499e7
patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31437
diff
changeset
|
2514 |
1009c33499e7
patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31437
diff
changeset
|
2515 // Safety check: Autocommands may have closed the window when jumping |
1009c33499e7
patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31437
diff
changeset
|
2516 // to the other tab page. |
1009c33499e7
patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31437
diff
changeset
|
2517 if (valid_tabpage(prev_curtab) && prev_curtab->tp_firstwin == win) |
1009c33499e7
patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31437
diff
changeset
|
2518 win_close_othertab(win, free_buf, prev_curtab); |
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
|
2519 #ifdef FEAT_JOB_CHANNEL |
31827
1009c33499e7
patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31437
diff
changeset
|
2520 entering_window(curwin); |
1009c33499e7
patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31437
diff
changeset
|
2521 #endif |
1009c33499e7
patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31437
diff
changeset
|
2522 // Since goto_tabpage_tp above did not trigger *Enter autocommands, do |
1009c33499e7
patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31437
diff
changeset
|
2523 // that now. |
1009c33499e7
patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31437
diff
changeset
|
2524 apply_autocmds(EVENT_TABCLOSED, NULL, NULL, FALSE, curbuf); |
1009c33499e7
patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31437
diff
changeset
|
2525 apply_autocmds(EVENT_WINENTER, NULL, NULL, FALSE, curbuf); |
1009c33499e7
patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31437
diff
changeset
|
2526 apply_autocmds(EVENT_TABENTER, NULL, NULL, FALSE, curbuf); |
1009c33499e7
patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31437
diff
changeset
|
2527 if (old_curbuf != curbuf) |
1009c33499e7
patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31437
diff
changeset
|
2528 apply_autocmds(EVENT_BUFENTER, NULL, NULL, FALSE, curbuf); |
1009c33499e7
patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31437
diff
changeset
|
2529 return TRUE; |
3535 | 2530 } |
2531 | |
2532 /* | |
17043
d99805d25b42
patch 8.1.1521: when a popup window is closed the buffer remains
Bram Moolenaar <Bram@vim.org>
parents:
16902
diff
changeset
|
2533 * 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
|
2534 * "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
|
2535 * "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
|
2536 * windows are closed. |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2537 */ |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2538 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
|
2539 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
|
2540 { |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2541 #ifdef FEAT_SYN_HL |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2542 // 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
|
2543 if (win->w_buffer != NULL) |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2544 reset_synblock(win); |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2545 #endif |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2546 |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2547 #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
|
2548 // 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
|
2549 // 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
|
2550 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
|
2551 && 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
|
2552 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
|
2553 #endif |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2554 |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2555 // Close the link to the buffer. |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2556 if (win->w_buffer != NULL) |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2557 { |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2558 bufref_T bufref; |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2559 |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2560 set_bufref(&bufref, curbuf); |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2561 win->w_closing = TRUE; |
28349
d3a1fc6b4da6
patch 8.2.4700: buffer remains active if WinClosed event throws an exception
Bram Moolenaar <Bram@vim.org>
parents:
28289
diff
changeset
|
2562 close_buffer(win, win->w_buffer, action, abort_if_last, TRUE); |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2563 if (win_valid_any_tab(win)) |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2564 win->w_closing = FALSE; |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2565 // 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
|
2566 // "wipe". |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2567 if (!bufref_valid(&bufref)) |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2568 curbuf = firstbuf; |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2569 } |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2570 } |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2571 |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2572 /* |
819 | 2573 * Close window "win". Only works for the current tab page. |
7 | 2574 * If "free_buf" is TRUE related buffer may be unloaded. |
2575 * | |
3365 | 2576 * Called by :quit, :close, :xit, :wq and findtag(). |
5302 | 2577 * Returns FAIL when the window was not closed. |
7 | 2578 */ |
5302 | 2579 int |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2580 win_close(win_T *win, int free_buf) |
7 | 2581 { |
2582 win_T *wp; | |
2583 int other_buffer = FALSE; | |
2584 int close_curwin = FALSE; | |
2585 int dir; | |
2586 int help_window = FALSE; | |
847 | 2587 tabpage_T *prev_curtab = curtab; |
11593
c4e7fe672a72
patch 8.0.0679: using freed memory
Christian Brabandt <cb@256bit.org>
parents:
11591
diff
changeset
|
2588 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
|
2589 #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
|
2590 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
|
2591 #endif |
25505
040a45d39570
patch 8.2.3289: compiler warning for unused variable with small features
Bram Moolenaar <Bram@vim.org>
parents:
25501
diff
changeset
|
2592 #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
|
2593 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
|
2594 #endif |
7 | 2595 |
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
|
2596 #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
|
2597 // 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
|
2598 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
|
2599 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
|
2600 #endif |
19271
ebeeb4b4a1fa
patch 8.2.0194: some commands can cause problems in terminal popup
Bram Moolenaar <Bram@vim.org>
parents:
19265
diff
changeset
|
2601 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
|
2602 return FAIL; |
da5f5836e90c
patch 8.1.1438: some commands cause trouble in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
16863
diff
changeset
|
2603 |
667 | 2604 if (last_window()) |
7 | 2605 { |
26913
d4e61d61afd9
patch 8.2.3985: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26893
diff
changeset
|
2606 emsg(_(e_cannot_close_last_window)); |
5302 | 2607 return FAIL; |
7 | 2608 } |
31150
bcda71c89776
patch 9.0.0909: error message for layout change does not match action
Bram Moolenaar <Bram@vim.org>
parents:
31146
diff
changeset
|
2609 if (window_layout_locked(CMD_close)) |
31146
f6d4c6a3b41c
patch 9.0.0907: restoring window after WinScrolled may fail
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
2610 return FAIL; |
7 | 2611 |
10106
58e6dd1d8be3
commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents:
10082
diff
changeset
|
2612 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
|
2613 && 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
|
2614 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
|
2615 if (win_unlisted(win)) |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
2616 { |
26883
7f150a4936f2
patch 8.2.3970: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26865
diff
changeset
|
2617 emsg(_(e_cannot_close_autocmd_or_popup_window)); |
5302 | 2618 return FAIL; |
1906 | 2619 } |
31263
d8e7d725a666
patch 9.0.0965: using one window for executing autocommands is insufficient
Bram Moolenaar <Bram@vim.org>
parents:
31261
diff
changeset
|
2620 if ((is_aucmd_win(firstwin) || is_aucmd_win(lastwin)) && one_window()) |
1906 | 2621 { |
26962
85866e069c24
patch 8.2.4010: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26913
diff
changeset
|
2622 emsg(_(e_cannot_close_window_only_autocmd_window_would_remain)); |
5302 | 2623 return FAIL; |
1906 | 2624 } |
2625 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2626 // 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
|
2627 // 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
|
2628 // curtab are invalid while we are freeing memory. |
3535 | 2629 if (close_last_window_tabpage(win, free_buf, prev_curtab)) |
5302 | 2630 return FAIL; |
856 | 2631 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2632 // 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
|
2633 // 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
|
2634 if (bt_help(win->w_buffer)) |
7 | 2635 help_window = TRUE; |
2636 else | |
1906 | 2637 clear_snapshot(curtab, SNAP_HELP_IDX); |
7 | 2638 |
2639 if (win == curwin) | |
2640 { | |
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
|
2641 #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
|
2642 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
|
2643 #endif |
7 | 2644 /* |
2645 * Guess which window is going to be the new current window. | |
2646 * This may change because of the autocommands (sigh). | |
2647 */ | |
671 | 2648 wp = frame2win(win_altframe(win, NULL)); |
7 | 2649 |
2650 /* | |
3570 | 2651 * Be careful: If autocommands delete the window or cause this window |
2652 * to be the last one left, return now. | |
7 | 2653 */ |
2654 if (wp->w_buffer != curbuf) | |
2655 { | |
29348
05ac4ab2c282
patch 9.0.0017: accessing memory beyond the end of the line
Bram Moolenaar <Bram@vim.org>
parents:
29090
diff
changeset
|
2656 reset_VIsual_and_resel(); // stop Visual mode |
05ac4ab2c282
patch 9.0.0017: accessing memory beyond the end of the line
Bram Moolenaar <Bram@vim.org>
parents:
29090
diff
changeset
|
2657 |
7 | 2658 other_buffer = TRUE; |
3570 | 2659 win->w_closing = TRUE; |
7 | 2660 apply_autocmds(EVENT_BUFLEAVE, NULL, NULL, FALSE, curbuf); |
3570 | 2661 if (!win_valid(win)) |
5302 | 2662 return FAIL; |
3570 | 2663 win->w_closing = FALSE; |
2664 if (last_window()) | |
5302 | 2665 return FAIL; |
7 | 2666 } |
3570 | 2667 win->w_closing = TRUE; |
7 | 2668 apply_autocmds(EVENT_WINLEAVE, NULL, NULL, FALSE, curbuf); |
3570 | 2669 if (!win_valid(win)) |
5302 | 2670 return FAIL; |
3570 | 2671 win->w_closing = FALSE; |
2672 if (last_window()) | |
5302 | 2673 return FAIL; |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13308
diff
changeset
|
2674 #ifdef FEAT_EVAL |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2675 // autocmds may abort script processing |
7 | 2676 if (aborting()) |
5302 | 2677 return FAIL; |
7 | 2678 #endif |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13308
diff
changeset
|
2679 } |
7 | 2680 |
1101 | 2681 #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
|
2682 // 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
|
2683 // win_free(). |
1101 | 2684 if (gui.in_use) |
2685 out_flush(); | |
2686 #endif | |
2687 | |
18763
49b78d6465e5
patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents:
18590
diff
changeset
|
2688 #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
|
2689 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
|
2690 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
|
2691 #endif |
26117
d4d9c7c55a5f
patch 8.2.3591: no event is triggered when closing a window
Bram Moolenaar <Bram@vim.org>
parents:
26077
diff
changeset
|
2692 |
d4d9c7c55a5f
patch 8.2.3591: no event is triggered when closing a window
Bram Moolenaar <Bram@vim.org>
parents:
26077
diff
changeset
|
2693 // 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
|
2694 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
|
2695 // 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
|
2696 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
|
2697 return OK; |
d4d9c7c55a5f
patch 8.2.3591: no event is triggered when closing a window
Bram Moolenaar <Bram@vim.org>
parents:
26077
diff
changeset
|
2698 |
17043
d99805d25b42
patch 8.1.1521: when a popup window is closed the buffer remains
Bram Moolenaar <Bram@vim.org>
parents:
16902
diff
changeset
|
2699 win_close_buffer(win, free_buf ? DOBUF_UNLOAD : 0, TRUE); |
847 | 2700 |
4021 | 2701 if (only_one_window() && win_valid(win) && win->w_buffer == NULL |
2702 && (last_window() || curtab != prev_curtab | |
2703 || 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
|
2704 { |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2705 // 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
|
2706 // 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
|
2707 if (curwin->w_buffer == NULL) |
1899acc5aebd
updated for version 7.4a.042
Bram Moolenaar <bram@vim.org>
parents:
5202
diff
changeset
|
2708 curwin->w_buffer = curbuf; |
4021 | 2709 getout(0); |
5233
1899acc5aebd
updated for version 7.4a.042
Bram Moolenaar <bram@vim.org>
parents:
5202
diff
changeset
|
2710 } |
4021 | 2711 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2712 // 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
|
2713 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
|
2714 && win->w_buffer == NULL) |
bc30991c3e98
commit https://github.com/vim/vim/commit/11fbc2866ccc11b4dd1726abdaf582a78ef3f743
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2715 { |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2716 // Need to close the window anyway, since the buffer is NULL. |
30429
69ff2bd737a9
patch 9.0.0550: crash when closing a tabpage and buffer is NULL
Bram Moolenaar <Bram@vim.org>
parents:
30339
diff
changeset
|
2717 // Don't trigger autocmds with a NULL buffer. |
69ff2bd737a9
patch 9.0.0550: crash when closing a tabpage and buffer is NULL
Bram Moolenaar <Bram@vim.org>
parents:
30339
diff
changeset
|
2718 block_autocmds(); |
10076
bc30991c3e98
commit https://github.com/vim/vim/commit/11fbc2866ccc11b4dd1726abdaf582a78ef3f743
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2719 win_close_othertab(win, FALSE, prev_curtab); |
30429
69ff2bd737a9
patch 9.0.0550: crash when closing a tabpage and buffer is NULL
Bram Moolenaar <Bram@vim.org>
parents:
30339
diff
changeset
|
2720 unblock_autocmds(); |
10076
bc30991c3e98
commit https://github.com/vim/vim/commit/11fbc2866ccc11b4dd1726abdaf582a78ef3f743
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2721 return FAIL; |
bc30991c3e98
commit https://github.com/vim/vim/commit/11fbc2866ccc11b4dd1726abdaf582a78ef3f743
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2722 } |
bc30991c3e98
commit https://github.com/vim/vim/commit/11fbc2866ccc11b4dd1726abdaf582a78ef3f743
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2723 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2724 // 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
|
2725 // other window. |
10076
bc30991c3e98
commit https://github.com/vim/vim/commit/11fbc2866ccc11b4dd1726abdaf582a78ef3f743
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
2726 if (!win_valid(win) || last_window() |
3535 | 2727 || close_last_window_tabpage(win, free_buf, prev_curtab)) |
5302 | 2728 return FAIL; |
7 | 2729 |
17516
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
2730 // 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
|
2731 // 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
|
2732 // 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
|
2733 // screen. |
17516
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
2734 ++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
|
2735 #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
|
2736 ++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
|
2737 #endif |
17516
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
2738 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2739 // 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
|
2740 // the screen space. |
847 | 2741 wp = win_free_mem(win, &dir, NULL); |
2742 | |
28688
264fa41e6704
patch 8.2.4868: when closing help window autocmds triggered for wrong window
Bram Moolenaar <Bram@vim.org>
parents:
28429
diff
changeset
|
2743 if (help_window) |
264fa41e6704
patch 8.2.4868: when closing help window autocmds triggered for wrong window
Bram Moolenaar <Bram@vim.org>
parents:
28429
diff
changeset
|
2744 { |
264fa41e6704
patch 8.2.4868: when closing help window autocmds triggered for wrong window
Bram Moolenaar <Bram@vim.org>
parents:
28429
diff
changeset
|
2745 // Closing the help window moves the cursor back to the current window |
264fa41e6704
patch 8.2.4868: when closing help window autocmds triggered for wrong window
Bram Moolenaar <Bram@vim.org>
parents:
28429
diff
changeset
|
2746 // of the snapshot. |
264fa41e6704
patch 8.2.4868: when closing help window autocmds triggered for wrong window
Bram Moolenaar <Bram@vim.org>
parents:
28429
diff
changeset
|
2747 win_T *prev_win = get_snapshot_curwin(SNAP_HELP_IDX); |
264fa41e6704
patch 8.2.4868: when closing help window autocmds triggered for wrong window
Bram Moolenaar <Bram@vim.org>
parents:
28429
diff
changeset
|
2748 |
264fa41e6704
patch 8.2.4868: when closing help window autocmds triggered for wrong window
Bram Moolenaar <Bram@vim.org>
parents:
28429
diff
changeset
|
2749 if (win_valid(prev_win)) |
264fa41e6704
patch 8.2.4868: when closing help window autocmds triggered for wrong window
Bram Moolenaar <Bram@vim.org>
parents:
28429
diff
changeset
|
2750 wp = prev_win; |
264fa41e6704
patch 8.2.4868: when closing help window autocmds triggered for wrong window
Bram Moolenaar <Bram@vim.org>
parents:
28429
diff
changeset
|
2751 } |
264fa41e6704
patch 8.2.4868: when closing help window autocmds triggered for wrong window
Bram Moolenaar <Bram@vim.org>
parents:
28429
diff
changeset
|
2752 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2753 // 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
|
2754 // 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
|
2755 // too. |
847 | 2756 if (win == curwin) |
7 | 2757 { |
2758 curwin = wp; | |
2759 #ifdef FEAT_QUICKFIX | |
2760 if (wp->w_p_pvw || bt_quickfix(wp->w_buffer)) | |
2761 { | |
2762 /* | |
1346 | 2763 * If the cursor goes to the preview or the quickfix window, try |
7 | 2764 * finding another window to go to. |
2765 */ | |
2766 for (;;) | |
2767 { | |
2768 if (wp->w_next == NULL) | |
2769 wp = firstwin; | |
2770 else | |
2771 wp = wp->w_next; | |
2772 if (wp == curwin) | |
2773 break; | |
2774 if (!wp->w_p_pvw && !bt_quickfix(wp->w_buffer)) | |
2775 { | |
2776 curwin = wp; | |
2777 break; | |
2778 } | |
2779 } | |
2780 } | |
2781 #endif | |
2782 curbuf = curwin->w_buffer; | |
2783 close_curwin = TRUE; | |
11193
75ccc8a15a51
patch 8.0.0483: illegal memory access when using :all
Christian Brabandt <cb@256bit.org>
parents:
11191
diff
changeset
|
2784 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2785 // 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
|
2786 // using the window. |
11193
75ccc8a15a51
patch 8.0.0483: illegal memory access when using :all
Christian Brabandt <cb@256bit.org>
parents:
11191
diff
changeset
|
2787 check_cursor(); |
7 | 2788 } |
30134
0211a930d873
patch 9.0.0403: 'equalalways' may be off when 'laststatus' is zero
Bram Moolenaar <Bram@vim.org>
parents:
30009
diff
changeset
|
2789 |
0211a930d873
patch 9.0.0403: 'equalalways' may be off when 'laststatus' is zero
Bram Moolenaar <Bram@vim.org>
parents:
30009
diff
changeset
|
2790 /* |
0211a930d873
patch 9.0.0403: 'equalalways' may be off when 'laststatus' is zero
Bram Moolenaar <Bram@vim.org>
parents:
30009
diff
changeset
|
2791 * If last window has a status line now and we don't want one, remove the |
0211a930d873
patch 9.0.0403: 'equalalways' may be off when 'laststatus' is zero
Bram Moolenaar <Bram@vim.org>
parents:
30009
diff
changeset
|
2792 * status line. Do this before win_equal(), because it may change the |
0211a930d873
patch 9.0.0403: 'equalalways' may be off when 'laststatus' is zero
Bram Moolenaar <Bram@vim.org>
parents:
30009
diff
changeset
|
2793 * height of a window |
0211a930d873
patch 9.0.0403: 'equalalways' may be off when 'laststatus' is zero
Bram Moolenaar <Bram@vim.org>
parents:
30009
diff
changeset
|
2794 */ |
0211a930d873
patch 9.0.0403: 'equalalways' may be off when 'laststatus' is zero
Bram Moolenaar <Bram@vim.org>
parents:
30009
diff
changeset
|
2795 last_status(FALSE); |
0211a930d873
patch 9.0.0403: 'equalalways' may be off when 'laststatus' is zero
Bram Moolenaar <Bram@vim.org>
parents:
30009
diff
changeset
|
2796 |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8536
diff
changeset
|
2797 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
|
2798 // 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
|
2799 // 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
|
2800 win_equal(curwin, curwin->w_frame->fr_parent == win_frame, dir); |
7 | 2801 else |
30219
bc8ad1c28b51
patch 9.0.0445: when opening/closing window text moves up/down
Bram Moolenaar <Bram@vim.org>
parents:
30134
diff
changeset
|
2802 { |
7 | 2803 win_comp_pos(); |
30624
f2f35161d75a
patch 9.0.0647: the 'splitscroll' option is not a good name
Bram Moolenaar <Bram@vim.org>
parents:
30574
diff
changeset
|
2804 if (*p_spk != 'c') |
30219
bc8ad1c28b51
patch 9.0.0445: when opening/closing window text moves up/down
Bram Moolenaar <Bram@vim.org>
parents:
30134
diff
changeset
|
2805 win_fix_scroll(FALSE); |
bc8ad1c28b51
patch 9.0.0445: when opening/closing window text moves up/down
Bram Moolenaar <Bram@vim.org>
parents:
30134
diff
changeset
|
2806 } |
7 | 2807 if (close_curwin) |
2808 { | |
25501
a1ed55c02e80
patch 8.2.3287: channel events not handled in BufEnter autocommand
Bram Moolenaar <Bram@vim.org>
parents:
25499
diff
changeset
|
2809 // 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
|
2810 // 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
|
2811 #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
|
2812 did_decrement = |
040a45d39570
patch 8.2.3289: compiler warning for unused variable with small features
Bram Moolenaar <Bram@vim.org>
parents:
25501
diff
changeset
|
2813 #else |
040a45d39570
patch 8.2.3289: compiler warning for unused variable with small features
Bram Moolenaar <Bram@vim.org>
parents:
25501
diff
changeset
|
2814 (void) |
040a45d39570
patch 8.2.3289: compiler warning for unused variable with small features
Bram Moolenaar <Bram@vim.org>
parents:
25501
diff
changeset
|
2815 #endif |
040a45d39570
patch 8.2.3289: compiler warning for unused variable with small features
Bram Moolenaar <Bram@vim.org>
parents:
25501
diff
changeset
|
2816 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
|
2817 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
|
2818 | WEE_TRIGGER_LEAVE_AUTOCMDS | WEE_ALLOW_PARSE_MESSAGES); |
7 | 2819 if (other_buffer) |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2820 // careful: after this wp and win may be invalid! |
7 | 2821 apply_autocmds(EVENT_BUFENTER, NULL, NULL, FALSE, curbuf); |
2822 } | |
2823 | |
17516
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
2824 --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
|
2825 #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
|
2826 if (!did_decrement) |
a1ed55c02e80
patch 8.2.3287: channel events not handled in BufEnter autocommand
Bram Moolenaar <Bram@vim.org>
parents:
25499
diff
changeset
|
2827 --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
|
2828 #endif |
17516
711db62c8aca
patch 8.1.1756: autocommand that splits window messes up window layout
Bram Moolenaar <Bram@vim.org>
parents:
17514
diff
changeset
|
2829 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2830 // 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
|
2831 // before it was opened. |
7 | 2832 if (help_window) |
1906 | 2833 restore_snapshot(SNAP_HELP_IDX, close_curwin); |
7 | 2834 |
18590
41484f342f80
patch 8.1.2289: after :diffsplit closing the window does not disable diff
Bram Moolenaar <Bram@vim.org>
parents:
18467
diff
changeset
|
2835 #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
|
2836 // 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
|
2837 // 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
|
2838 // 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
|
2839 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
|
2840 { |
41484f342f80
patch 8.1.2289: after :diffsplit closing the window does not disable diff
Bram Moolenaar <Bram@vim.org>
parents:
18467
diff
changeset
|
2841 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
|
2842 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
|
2843 |
41484f342f80
patch 8.1.2289: after :diffsplit closing the window does not disable diff
Bram Moolenaar <Bram@vim.org>
parents:
18467
diff
changeset
|
2844 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
|
2845 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
|
2846 ++diffcount; |
41484f342f80
patch 8.1.2289: after :diffsplit closing the window does not disable diff
Bram Moolenaar <Bram@vim.org>
parents:
18467
diff
changeset
|
2847 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
|
2848 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
|
2849 } |
41484f342f80
patch 8.1.2289: after :diffsplit closing the window does not disable diff
Bram Moolenaar <Bram@vim.org>
parents:
18467
diff
changeset
|
2850 #endif |
41484f342f80
patch 8.1.2289: after :diffsplit closing the window does not disable diff
Bram Moolenaar <Bram@vim.org>
parents:
18467
diff
changeset
|
2851 |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8536
diff
changeset
|
2852 #if defined(FEAT_GUI) |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2853 // When 'guioptions' includes 'L' or 'R' may have to remove scrollbars. |
7 | 2854 if (gui.in_use && !win_hasvertsplit()) |
2855 gui_init_which_components(NULL); | |
2856 #endif | |
2857 | |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29702
diff
changeset
|
2858 redraw_all_later(UPD_NOT_VALID); |
5302 | 2859 return OK; |
7 | 2860 } |
2861 | |
26117
d4d9c7c55a5f
patch 8.2.3591: no event is triggered when closing a window
Bram Moolenaar <Bram@vim.org>
parents:
26077
diff
changeset
|
2862 static void |
d4d9c7c55a5f
patch 8.2.3591: no event is triggered when closing a window
Bram Moolenaar <Bram@vim.org>
parents:
26077
diff
changeset
|
2863 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
|
2864 { |
d4d9c7c55a5f
patch 8.2.3591: no event is triggered when closing a window
Bram Moolenaar <Bram@vim.org>
parents:
26077
diff
changeset
|
2865 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
|
2866 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
|
2867 |
d4d9c7c55a5f
patch 8.2.3591: no event is triggered when closing a window
Bram Moolenaar <Bram@vim.org>
parents:
26077
diff
changeset
|
2868 if (recursive) |
d4d9c7c55a5f
patch 8.2.3591: no event is triggered when closing a window
Bram Moolenaar <Bram@vim.org>
parents:
26077
diff
changeset
|
2869 return; |
d4d9c7c55a5f
patch 8.2.3591: no event is triggered when closing a window
Bram Moolenaar <Bram@vim.org>
parents:
26077
diff
changeset
|
2870 recursive = TRUE; |
28375
e466fdbe0699
patch 8.2.4713: plugins cannot track text scrolling
Bram Moolenaar <Bram@vim.org>
parents:
28361
diff
changeset
|
2871 vim_snprintf((char *)winid, sizeof(winid), "%d", win->w_id); |
26117
d4d9c7c55a5f
patch 8.2.3591: no event is triggered when closing a window
Bram Moolenaar <Bram@vim.org>
parents:
26077
diff
changeset
|
2872 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
|
2873 recursive = FALSE; |
d4d9c7c55a5f
patch 8.2.3591: no event is triggered when closing a window
Bram Moolenaar <Bram@vim.org>
parents:
26077
diff
changeset
|
2874 } |
d4d9c7c55a5f
patch 8.2.3591: no event is triggered when closing a window
Bram Moolenaar <Bram@vim.org>
parents:
26077
diff
changeset
|
2875 |
28429
aa9720c76412
patch 8.2.4739: accessing freed memory after WinScrolled autocmd event
Bram Moolenaar <Bram@vim.org>
parents:
28375
diff
changeset
|
2876 /* |
31158
514ab6bdf73d
patch 9.0.0913: only change in current window triggers the WinScrolled event
Bram Moolenaar <Bram@vim.org>
parents:
31150
diff
changeset
|
2877 * Make a snapshot of all the window scroll positions and sizes of the current |
514ab6bdf73d
patch 9.0.0913: only change in current window triggers the WinScrolled event
Bram Moolenaar <Bram@vim.org>
parents:
31150
diff
changeset
|
2878 * tab page. |
514ab6bdf73d
patch 9.0.0913: only change in current window triggers the WinScrolled event
Bram Moolenaar <Bram@vim.org>
parents:
31150
diff
changeset
|
2879 */ |
31162
981f7bc781bb
patch 9.0.0915: WinScrolled may trigger immediately when defined
Bram Moolenaar <Bram@vim.org>
parents:
31158
diff
changeset
|
2880 void |
31158
514ab6bdf73d
patch 9.0.0913: only change in current window triggers the WinScrolled event
Bram Moolenaar <Bram@vim.org>
parents:
31150
diff
changeset
|
2881 snapshot_windows_scroll_size(void) |
514ab6bdf73d
patch 9.0.0913: only change in current window triggers the WinScrolled event
Bram Moolenaar <Bram@vim.org>
parents:
31150
diff
changeset
|
2882 { |
514ab6bdf73d
patch 9.0.0913: only change in current window triggers the WinScrolled event
Bram Moolenaar <Bram@vim.org>
parents:
31150
diff
changeset
|
2883 win_T *wp; |
514ab6bdf73d
patch 9.0.0913: only change in current window triggers the WinScrolled event
Bram Moolenaar <Bram@vim.org>
parents:
31150
diff
changeset
|
2884 FOR_ALL_WINDOWS(wp) |
514ab6bdf73d
patch 9.0.0913: only change in current window triggers the WinScrolled event
Bram Moolenaar <Bram@vim.org>
parents:
31150
diff
changeset
|
2885 { |
514ab6bdf73d
patch 9.0.0913: only change in current window triggers the WinScrolled event
Bram Moolenaar <Bram@vim.org>
parents:
31150
diff
changeset
|
2886 wp->w_last_topline = wp->w_topline; |
31384
992bfd3aee3f
patch 9.0.1025: WinScrolled is not triggered when filler lines change
Bram Moolenaar <Bram@vim.org>
parents:
31267
diff
changeset
|
2887 #ifdef FEAT_DIFF |
992bfd3aee3f
patch 9.0.1025: WinScrolled is not triggered when filler lines change
Bram Moolenaar <Bram@vim.org>
parents:
31267
diff
changeset
|
2888 wp->w_last_topfill = wp->w_topfill; |
992bfd3aee3f
patch 9.0.1025: WinScrolled is not triggered when filler lines change
Bram Moolenaar <Bram@vim.org>
parents:
31267
diff
changeset
|
2889 #endif |
31158
514ab6bdf73d
patch 9.0.0913: only change in current window triggers the WinScrolled event
Bram Moolenaar <Bram@vim.org>
parents:
31150
diff
changeset
|
2890 wp->w_last_leftcol = wp->w_leftcol; |
514ab6bdf73d
patch 9.0.0913: only change in current window triggers the WinScrolled event
Bram Moolenaar <Bram@vim.org>
parents:
31150
diff
changeset
|
2891 wp->w_last_skipcol = wp->w_skipcol; |
514ab6bdf73d
patch 9.0.0913: only change in current window triggers the WinScrolled event
Bram Moolenaar <Bram@vim.org>
parents:
31150
diff
changeset
|
2892 wp->w_last_width = wp->w_width; |
514ab6bdf73d
patch 9.0.0913: only change in current window triggers the WinScrolled event
Bram Moolenaar <Bram@vim.org>
parents:
31150
diff
changeset
|
2893 wp->w_last_height = wp->w_height; |
514ab6bdf73d
patch 9.0.0913: only change in current window triggers the WinScrolled event
Bram Moolenaar <Bram@vim.org>
parents:
31150
diff
changeset
|
2894 } |
514ab6bdf73d
patch 9.0.0913: only change in current window triggers the WinScrolled event
Bram Moolenaar <Bram@vim.org>
parents:
31150
diff
changeset
|
2895 } |
514ab6bdf73d
patch 9.0.0913: only change in current window triggers the WinScrolled event
Bram Moolenaar <Bram@vim.org>
parents:
31150
diff
changeset
|
2896 |
514ab6bdf73d
patch 9.0.0913: only change in current window triggers the WinScrolled event
Bram Moolenaar <Bram@vim.org>
parents:
31150
diff
changeset
|
2897 static int did_initial_scroll_size_snapshot = FALSE; |
514ab6bdf73d
patch 9.0.0913: only change in current window triggers the WinScrolled event
Bram Moolenaar <Bram@vim.org>
parents:
31150
diff
changeset
|
2898 |
514ab6bdf73d
patch 9.0.0913: only change in current window triggers the WinScrolled event
Bram Moolenaar <Bram@vim.org>
parents:
31150
diff
changeset
|
2899 void |
514ab6bdf73d
patch 9.0.0913: only change in current window triggers the WinScrolled event
Bram Moolenaar <Bram@vim.org>
parents:
31150
diff
changeset
|
2900 may_make_initial_scroll_size_snapshot(void) |
514ab6bdf73d
patch 9.0.0913: only change in current window triggers the WinScrolled event
Bram Moolenaar <Bram@vim.org>
parents:
31150
diff
changeset
|
2901 { |
514ab6bdf73d
patch 9.0.0913: only change in current window triggers the WinScrolled event
Bram Moolenaar <Bram@vim.org>
parents:
31150
diff
changeset
|
2902 if (!did_initial_scroll_size_snapshot) |
514ab6bdf73d
patch 9.0.0913: only change in current window triggers the WinScrolled event
Bram Moolenaar <Bram@vim.org>
parents:
31150
diff
changeset
|
2903 { |
514ab6bdf73d
patch 9.0.0913: only change in current window triggers the WinScrolled event
Bram Moolenaar <Bram@vim.org>
parents:
31150
diff
changeset
|
2904 did_initial_scroll_size_snapshot = TRUE; |
514ab6bdf73d
patch 9.0.0913: only change in current window triggers the WinScrolled event
Bram Moolenaar <Bram@vim.org>
parents:
31150
diff
changeset
|
2905 snapshot_windows_scroll_size(); |
514ab6bdf73d
patch 9.0.0913: only change in current window triggers the WinScrolled event
Bram Moolenaar <Bram@vim.org>
parents:
31150
diff
changeset
|
2906 } |
514ab6bdf73d
patch 9.0.0913: only change in current window triggers the WinScrolled event
Bram Moolenaar <Bram@vim.org>
parents:
31150
diff
changeset
|
2907 } |
514ab6bdf73d
patch 9.0.0913: only change in current window triggers the WinScrolled event
Bram Moolenaar <Bram@vim.org>
parents:
31150
diff
changeset
|
2908 |
31170
b7e381d7e8b8
patch 9.0.0919: build failure with tiny features
Bram Moolenaar <Bram@vim.org>
parents:
31166
diff
changeset
|
2909 #ifdef FEAT_EVAL |
31158
514ab6bdf73d
patch 9.0.0913: only change in current window triggers the WinScrolled event
Bram Moolenaar <Bram@vim.org>
parents:
31150
diff
changeset
|
2910 /* |
31166
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
2911 * Create a dictionary with information about size and scroll changes in a |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
2912 * window. |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
2913 * Returns the dictionary with refcount set to one. |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
2914 * Returns NULL when out of memory. |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
2915 */ |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
2916 static dict_T * |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
2917 make_win_info_dict( |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
2918 int width, |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
2919 int height, |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
2920 int topline, |
31384
992bfd3aee3f
patch 9.0.1025: WinScrolled is not triggered when filler lines change
Bram Moolenaar <Bram@vim.org>
parents:
31267
diff
changeset
|
2921 # ifdef FEAT_DIFF |
992bfd3aee3f
patch 9.0.1025: WinScrolled is not triggered when filler lines change
Bram Moolenaar <Bram@vim.org>
parents:
31267
diff
changeset
|
2922 int topfill, |
992bfd3aee3f
patch 9.0.1025: WinScrolled is not triggered when filler lines change
Bram Moolenaar <Bram@vim.org>
parents:
31267
diff
changeset
|
2923 # endif |
31166
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
2924 int leftcol, |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
2925 int skipcol) |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
2926 { |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
2927 dict_T *d = dict_alloc(); |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
2928 if (d == NULL) |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
2929 return NULL; |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
2930 d->dv_refcount = 1; |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
2931 |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
2932 // not actually looping, for breaking out on error |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
2933 while (1) |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
2934 { |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
2935 typval_T tv; |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
2936 tv.v_lock = 0; |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
2937 tv.v_type = VAR_NUMBER; |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
2938 |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
2939 tv.vval.v_number = width; |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
2940 if (dict_add_tv(d, "width", &tv) == FAIL) |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
2941 break; |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
2942 tv.vval.v_number = height; |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
2943 if (dict_add_tv(d, "height", &tv) == FAIL) |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
2944 break; |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
2945 tv.vval.v_number = topline; |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
2946 if (dict_add_tv(d, "topline", &tv) == FAIL) |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
2947 break; |
31384
992bfd3aee3f
patch 9.0.1025: WinScrolled is not triggered when filler lines change
Bram Moolenaar <Bram@vim.org>
parents:
31267
diff
changeset
|
2948 #ifdef FEAT_DIFF |
992bfd3aee3f
patch 9.0.1025: WinScrolled is not triggered when filler lines change
Bram Moolenaar <Bram@vim.org>
parents:
31267
diff
changeset
|
2949 tv.vval.v_number = topfill; |
992bfd3aee3f
patch 9.0.1025: WinScrolled is not triggered when filler lines change
Bram Moolenaar <Bram@vim.org>
parents:
31267
diff
changeset
|
2950 #else |
992bfd3aee3f
patch 9.0.1025: WinScrolled is not triggered when filler lines change
Bram Moolenaar <Bram@vim.org>
parents:
31267
diff
changeset
|
2951 tv.vval.v_number = 0; |
992bfd3aee3f
patch 9.0.1025: WinScrolled is not triggered when filler lines change
Bram Moolenaar <Bram@vim.org>
parents:
31267
diff
changeset
|
2952 #endif |
992bfd3aee3f
patch 9.0.1025: WinScrolled is not triggered when filler lines change
Bram Moolenaar <Bram@vim.org>
parents:
31267
diff
changeset
|
2953 if (dict_add_tv(d, "topfill", &tv) == FAIL) |
992bfd3aee3f
patch 9.0.1025: WinScrolled is not triggered when filler lines change
Bram Moolenaar <Bram@vim.org>
parents:
31267
diff
changeset
|
2954 break; |
31166
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
2955 tv.vval.v_number = leftcol; |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
2956 if (dict_add_tv(d, "leftcol", &tv) == FAIL) |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
2957 break; |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
2958 tv.vval.v_number = skipcol; |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
2959 if (dict_add_tv(d, "skipcol", &tv) == FAIL) |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
2960 break; |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
2961 return d; |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
2962 } |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
2963 dict_unref(d); |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
2964 return NULL; |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
2965 } |
31170
b7e381d7e8b8
patch 9.0.0919: build failure with tiny features
Bram Moolenaar <Bram@vim.org>
parents:
31166
diff
changeset
|
2966 #endif |
31166
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
2967 |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
2968 // Return values of check_window_scroll_resize(): |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
2969 #define CWSR_SCROLLED 1 // at least one window scrolled |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
2970 #define CWSR_RESIZED 2 // at least one window size changed |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
2971 |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
2972 /* |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
2973 * This function is used for three purposes: |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
2974 * 1. Goes over all windows in the current tab page and returns: |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
2975 * 0 no scrolling and no size changes found |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
2976 * CWSR_SCROLLED at least one window scrolled |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
2977 * CWSR_RESIZED at least one window changed size |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
2978 * CWSR_SCROLLED + CWSR_RESIZED both |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
2979 * "size_count" is set to the nr of windows with size changes. |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
2980 * "first_scroll_win" is set to the first window with any relevant changes. |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
2981 * "first_size_win" is set to the first window with size changes. |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
2982 * |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
2983 * 2. When the first three arguments are NULL and "winlist" is not NULL, |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
2984 * "winlist" is set to the list of window IDs with size changes. |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
2985 * |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
2986 * 3. When the first three arguments are NULL and "v_event" is not NULL, |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
2987 * information about changed windows is added to "v_event". |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
2988 */ |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
2989 static int |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
2990 check_window_scroll_resize( |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
2991 int *size_count, |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
2992 win_T **first_scroll_win, |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
2993 win_T **first_size_win, |
31170
b7e381d7e8b8
patch 9.0.0919: build failure with tiny features
Bram Moolenaar <Bram@vim.org>
parents:
31166
diff
changeset
|
2994 list_T *winlist UNUSED, |
b7e381d7e8b8
patch 9.0.0919: build failure with tiny features
Bram Moolenaar <Bram@vim.org>
parents:
31166
diff
changeset
|
2995 dict_T *v_event UNUSED) |
31166
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
2996 { |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
2997 int result = 0; |
31170
b7e381d7e8b8
patch 9.0.0919: build failure with tiny features
Bram Moolenaar <Bram@vim.org>
parents:
31166
diff
changeset
|
2998 #ifdef FEAT_EVAL |
31166
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
2999 int listidx = 0; |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3000 int tot_width = 0; |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3001 int tot_height = 0; |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3002 int tot_topline = 0; |
31384
992bfd3aee3f
patch 9.0.1025: WinScrolled is not triggered when filler lines change
Bram Moolenaar <Bram@vim.org>
parents:
31267
diff
changeset
|
3003 # ifdef FEAT_DIFF |
992bfd3aee3f
patch 9.0.1025: WinScrolled is not triggered when filler lines change
Bram Moolenaar <Bram@vim.org>
parents:
31267
diff
changeset
|
3004 int tot_topfill = 0; |
992bfd3aee3f
patch 9.0.1025: WinScrolled is not triggered when filler lines change
Bram Moolenaar <Bram@vim.org>
parents:
31267
diff
changeset
|
3005 # endif |
31166
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3006 int tot_leftcol = 0; |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3007 int tot_skipcol = 0; |
31170
b7e381d7e8b8
patch 9.0.0919: build failure with tiny features
Bram Moolenaar <Bram@vim.org>
parents:
31166
diff
changeset
|
3008 #endif |
28375
e466fdbe0699
patch 8.2.4713: plugins cannot track text scrolling
Bram Moolenaar <Bram@vim.org>
parents:
28361
diff
changeset
|
3009 |
31158
514ab6bdf73d
patch 9.0.0913: only change in current window triggers the WinScrolled event
Bram Moolenaar <Bram@vim.org>
parents:
31150
diff
changeset
|
3010 win_T *wp; |
514ab6bdf73d
patch 9.0.0913: only change in current window triggers the WinScrolled event
Bram Moolenaar <Bram@vim.org>
parents:
31150
diff
changeset
|
3011 FOR_ALL_WINDOWS(wp) |
31166
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3012 { |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3013 int size_changed = wp->w_last_width != wp->w_width |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3014 || wp->w_last_height != wp->w_height; |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3015 if (size_changed) |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3016 { |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3017 result |= CWSR_RESIZED; |
31170
b7e381d7e8b8
patch 9.0.0919: build failure with tiny features
Bram Moolenaar <Bram@vim.org>
parents:
31166
diff
changeset
|
3018 #ifdef FEAT_EVAL |
31166
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3019 if (winlist != NULL) |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3020 { |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3021 // Add this window to the list of changed windows. |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3022 typval_T tv; |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3023 tv.v_lock = 0; |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3024 tv.v_type = VAR_NUMBER; |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3025 tv.vval.v_number = wp->w_id; |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3026 list_set_item(winlist, listidx++, &tv); |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3027 } |
31170
b7e381d7e8b8
patch 9.0.0919: build failure with tiny features
Bram Moolenaar <Bram@vim.org>
parents:
31166
diff
changeset
|
3028 else |
b7e381d7e8b8
patch 9.0.0919: build failure with tiny features
Bram Moolenaar <Bram@vim.org>
parents:
31166
diff
changeset
|
3029 #endif |
b7e381d7e8b8
patch 9.0.0919: build failure with tiny features
Bram Moolenaar <Bram@vim.org>
parents:
31166
diff
changeset
|
3030 if (size_count != NULL) |
31166
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3031 { |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3032 ++*size_count; |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3033 if (*first_size_win == NULL) |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3034 *first_size_win = wp; |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3035 // For WinScrolled the first window with a size change is used |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3036 // even when it didn't scroll. |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3037 if (*first_scroll_win == NULL) |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3038 *first_scroll_win = wp; |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3039 } |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3040 } |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3041 |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3042 int scroll_changed = wp->w_last_topline != wp->w_topline |
31384
992bfd3aee3f
patch 9.0.1025: WinScrolled is not triggered when filler lines change
Bram Moolenaar <Bram@vim.org>
parents:
31267
diff
changeset
|
3043 #ifdef FEAT_DIFF |
992bfd3aee3f
patch 9.0.1025: WinScrolled is not triggered when filler lines change
Bram Moolenaar <Bram@vim.org>
parents:
31267
diff
changeset
|
3044 || wp->w_last_topfill != wp->w_topfill |
992bfd3aee3f
patch 9.0.1025: WinScrolled is not triggered when filler lines change
Bram Moolenaar <Bram@vim.org>
parents:
31267
diff
changeset
|
3045 #endif |
31166
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3046 || wp->w_last_leftcol != wp->w_leftcol |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3047 || wp->w_last_skipcol != wp->w_skipcol; |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3048 if (scroll_changed) |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3049 { |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3050 result |= CWSR_SCROLLED; |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3051 if (first_scroll_win != NULL && *first_scroll_win == NULL) |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3052 *first_scroll_win = wp; |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3053 } |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3054 |
31170
b7e381d7e8b8
patch 9.0.0919: build failure with tiny features
Bram Moolenaar <Bram@vim.org>
parents:
31166
diff
changeset
|
3055 #ifdef FEAT_EVAL |
31166
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3056 if ((size_changed || scroll_changed) && v_event != NULL) |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3057 { |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3058 // Add info about this window to the v:event dictionary. |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3059 int width = wp->w_width - wp->w_last_width; |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3060 int height = wp->w_height - wp->w_last_height; |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3061 int topline = wp->w_topline - wp->w_last_topline; |
31384
992bfd3aee3f
patch 9.0.1025: WinScrolled is not triggered when filler lines change
Bram Moolenaar <Bram@vim.org>
parents:
31267
diff
changeset
|
3062 #ifdef FEAT_DIFF |
992bfd3aee3f
patch 9.0.1025: WinScrolled is not triggered when filler lines change
Bram Moolenaar <Bram@vim.org>
parents:
31267
diff
changeset
|
3063 int topfill = wp->w_topfill - wp->w_last_topfill; |
992bfd3aee3f
patch 9.0.1025: WinScrolled is not triggered when filler lines change
Bram Moolenaar <Bram@vim.org>
parents:
31267
diff
changeset
|
3064 #endif |
31166
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3065 int leftcol = wp->w_leftcol - wp->w_last_leftcol; |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3066 int skipcol = wp->w_skipcol - wp->w_last_skipcol; |
31384
992bfd3aee3f
patch 9.0.1025: WinScrolled is not triggered when filler lines change
Bram Moolenaar <Bram@vim.org>
parents:
31267
diff
changeset
|
3067 dict_T *d = make_win_info_dict(width, height, topline, |
992bfd3aee3f
patch 9.0.1025: WinScrolled is not triggered when filler lines change
Bram Moolenaar <Bram@vim.org>
parents:
31267
diff
changeset
|
3068 #ifdef FEAT_DIFF |
992bfd3aee3f
patch 9.0.1025: WinScrolled is not triggered when filler lines change
Bram Moolenaar <Bram@vim.org>
parents:
31267
diff
changeset
|
3069 topfill, |
992bfd3aee3f
patch 9.0.1025: WinScrolled is not triggered when filler lines change
Bram Moolenaar <Bram@vim.org>
parents:
31267
diff
changeset
|
3070 #endif |
992bfd3aee3f
patch 9.0.1025: WinScrolled is not triggered when filler lines change
Bram Moolenaar <Bram@vim.org>
parents:
31267
diff
changeset
|
3071 leftcol, skipcol); |
31166
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3072 if (d == NULL) |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3073 break; |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3074 char winid[NUMBUFLEN]; |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3075 vim_snprintf(winid, sizeof(winid), "%d", wp->w_id); |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3076 if (dict_add_dict(v_event, winid, d) == FAIL) |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3077 { |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3078 dict_unref(d); |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3079 break; |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3080 } |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3081 --d->dv_refcount; |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3082 |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3083 tot_width += abs(width); |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3084 tot_height += abs(height); |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3085 tot_topline += abs(topline); |
31384
992bfd3aee3f
patch 9.0.1025: WinScrolled is not triggered when filler lines change
Bram Moolenaar <Bram@vim.org>
parents:
31267
diff
changeset
|
3086 #ifdef FEAT_DIFF |
992bfd3aee3f
patch 9.0.1025: WinScrolled is not triggered when filler lines change
Bram Moolenaar <Bram@vim.org>
parents:
31267
diff
changeset
|
3087 tot_topfill += abs(topfill); |
992bfd3aee3f
patch 9.0.1025: WinScrolled is not triggered when filler lines change
Bram Moolenaar <Bram@vim.org>
parents:
31267
diff
changeset
|
3088 #endif |
31166
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3089 tot_leftcol += abs(leftcol); |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3090 tot_skipcol += abs(skipcol); |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3091 } |
31170
b7e381d7e8b8
patch 9.0.0919: build failure with tiny features
Bram Moolenaar <Bram@vim.org>
parents:
31166
diff
changeset
|
3092 #endif |
b7e381d7e8b8
patch 9.0.0919: build failure with tiny features
Bram Moolenaar <Bram@vim.org>
parents:
31166
diff
changeset
|
3093 } |
b7e381d7e8b8
patch 9.0.0919: build failure with tiny features
Bram Moolenaar <Bram@vim.org>
parents:
31166
diff
changeset
|
3094 |
b7e381d7e8b8
patch 9.0.0919: build failure with tiny features
Bram Moolenaar <Bram@vim.org>
parents:
31166
diff
changeset
|
3095 #ifdef FEAT_EVAL |
31166
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3096 if (v_event != NULL) |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3097 { |
31384
992bfd3aee3f
patch 9.0.1025: WinScrolled is not triggered when filler lines change
Bram Moolenaar <Bram@vim.org>
parents:
31267
diff
changeset
|
3098 dict_T *alldict = make_win_info_dict(tot_width, tot_height, tot_topline, |
992bfd3aee3f
patch 9.0.1025: WinScrolled is not triggered when filler lines change
Bram Moolenaar <Bram@vim.org>
parents:
31267
diff
changeset
|
3099 # ifdef FEAT_DIFF |
992bfd3aee3f
patch 9.0.1025: WinScrolled is not triggered when filler lines change
Bram Moolenaar <Bram@vim.org>
parents:
31267
diff
changeset
|
3100 tot_topfill, |
992bfd3aee3f
patch 9.0.1025: WinScrolled is not triggered when filler lines change
Bram Moolenaar <Bram@vim.org>
parents:
31267
diff
changeset
|
3101 # endif |
992bfd3aee3f
patch 9.0.1025: WinScrolled is not triggered when filler lines change
Bram Moolenaar <Bram@vim.org>
parents:
31267
diff
changeset
|
3102 tot_leftcol, tot_skipcol); |
31166
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3103 if (alldict != NULL) |
28429
aa9720c76412
patch 8.2.4739: accessing freed memory after WinScrolled autocmd event
Bram Moolenaar <Bram@vim.org>
parents:
28375
diff
changeset
|
3104 { |
31166
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3105 if (dict_add_dict(v_event, "all", alldict) == FAIL) |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3106 dict_unref(alldict); |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3107 else |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3108 --alldict->dv_refcount; |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3109 } |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3110 } |
31170
b7e381d7e8b8
patch 9.0.0919: build failure with tiny features
Bram Moolenaar <Bram@vim.org>
parents:
31166
diff
changeset
|
3111 #endif |
31166
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3112 |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3113 return result; |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3114 } |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3115 |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3116 /* |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3117 * Trigger WinScrolled and/or WinResized if any window in the current tab page |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3118 * scrolled or changed size. |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3119 */ |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3120 void |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3121 may_trigger_win_scrolled_resized(void) |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3122 { |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3123 static int recursive = FALSE; |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3124 int do_resize = has_winresized(); |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3125 int do_scroll = has_winscrolled(); |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3126 |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3127 // Do not trigger WinScrolled or WinResized recursively. Do not trigger |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3128 // before the initial snapshot of the w_last_ values was made. |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3129 if (recursive |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3130 || !(do_scroll || do_resize) |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3131 || !did_initial_scroll_size_snapshot) |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3132 return; |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3133 |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3134 int size_count = 0; |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3135 win_T *first_scroll_win = NULL, *first_size_win = NULL; |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3136 int cwsr = check_window_scroll_resize(&size_count, |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3137 &first_scroll_win, &first_size_win, |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3138 NULL, NULL); |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3139 int trigger_resize = do_resize && size_count > 0; |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3140 int trigger_scroll = do_scroll && cwsr != 0; |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3141 if (!trigger_resize && !trigger_scroll) |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3142 return; // no relevant changes |
31170
b7e381d7e8b8
patch 9.0.0919: build failure with tiny features
Bram Moolenaar <Bram@vim.org>
parents:
31166
diff
changeset
|
3143 #ifdef FEAT_EVAL |
31166
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3144 list_T *windows_list = NULL; |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3145 if (trigger_resize) |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3146 { |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3147 // Create the list for v:event.windows before making the snapshot. |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3148 windows_list = list_alloc_with_items(size_count); |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3149 (void)check_window_scroll_resize(NULL, NULL, NULL, windows_list, NULL); |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3150 } |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3151 |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3152 dict_T *scroll_dict = NULL; |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3153 if (trigger_scroll) |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3154 { |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3155 // Create the dict with entries for v:event before making the snapshot. |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3156 scroll_dict = dict_alloc(); |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3157 if (scroll_dict != NULL) |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3158 { |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3159 scroll_dict->dv_refcount = 1; |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3160 (void)check_window_scroll_resize(NULL, NULL, NULL, NULL, |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3161 scroll_dict); |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3162 } |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3163 } |
31170
b7e381d7e8b8
patch 9.0.0919: build failure with tiny features
Bram Moolenaar <Bram@vim.org>
parents:
31166
diff
changeset
|
3164 #endif |
31166
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3165 |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3166 // WinScrolled/WinResized are triggered only once, even when multiple |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3167 // windows scrolled or changed size. Store the current values before |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3168 // triggering the event, if a scroll or resize happens as a side effect |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3169 // then WinScrolled/WinResized is triggered for that later. |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3170 snapshot_windows_scroll_size(); |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3171 |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3172 // "curwin" may be different from the actual current window, make |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3173 // sure it can be restored. |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3174 window_layout_lock(); |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3175 recursive = TRUE; |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3176 |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3177 // If both are to be triggered do WinResized first. |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3178 if (trigger_resize) |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3179 { |
31170
b7e381d7e8b8
patch 9.0.0919: build failure with tiny features
Bram Moolenaar <Bram@vim.org>
parents:
31166
diff
changeset
|
3180 #ifdef FEAT_EVAL |
31166
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3181 save_v_event_T save_v_event; |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3182 dict_T *v_event = get_v_event(&save_v_event); |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3183 |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3184 if (dict_add_list(v_event, "windows", windows_list) == OK) |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3185 { |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3186 dict_set_items_ro(v_event); |
31170
b7e381d7e8b8
patch 9.0.0919: build failure with tiny features
Bram Moolenaar <Bram@vim.org>
parents:
31166
diff
changeset
|
3187 #endif |
31158
514ab6bdf73d
patch 9.0.0913: only change in current window triggers the WinScrolled event
Bram Moolenaar <Bram@vim.org>
parents:
31150
diff
changeset
|
3188 char_u winid[NUMBUFLEN]; |
31166
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3189 vim_snprintf((char *)winid, sizeof(winid), "%d", |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3190 first_size_win->w_id); |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3191 apply_autocmds(EVENT_WINRESIZED, winid, winid, FALSE, |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3192 first_size_win->w_buffer); |
31170
b7e381d7e8b8
patch 9.0.0919: build failure with tiny features
Bram Moolenaar <Bram@vim.org>
parents:
31166
diff
changeset
|
3193 #ifdef FEAT_EVAL |
28429
aa9720c76412
patch 8.2.4739: accessing freed memory after WinScrolled autocmd event
Bram Moolenaar <Bram@vim.org>
parents:
28375
diff
changeset
|
3194 } |
31166
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3195 restore_v_event(v_event, &save_v_event); |
31170
b7e381d7e8b8
patch 9.0.0919: build failure with tiny features
Bram Moolenaar <Bram@vim.org>
parents:
31166
diff
changeset
|
3196 #endif |
31166
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3197 } |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3198 |
31190
02b719cd27c6
patch 9.0.0929: build failure with tiny version
Bram Moolenaar <Bram@vim.org>
parents:
31186
diff
changeset
|
3199 if (trigger_scroll |
02b719cd27c6
patch 9.0.0929: build failure with tiny version
Bram Moolenaar <Bram@vim.org>
parents:
31186
diff
changeset
|
3200 #ifdef FEAT_EVAL |
02b719cd27c6
patch 9.0.0929: build failure with tiny version
Bram Moolenaar <Bram@vim.org>
parents:
31186
diff
changeset
|
3201 && scroll_dict != NULL |
02b719cd27c6
patch 9.0.0929: build failure with tiny version
Bram Moolenaar <Bram@vim.org>
parents:
31186
diff
changeset
|
3202 #endif |
02b719cd27c6
patch 9.0.0929: build failure with tiny version
Bram Moolenaar <Bram@vim.org>
parents:
31186
diff
changeset
|
3203 ) |
31166
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3204 { |
31170
b7e381d7e8b8
patch 9.0.0919: build failure with tiny features
Bram Moolenaar <Bram@vim.org>
parents:
31166
diff
changeset
|
3205 #ifdef FEAT_EVAL |
31166
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3206 save_v_event_T save_v_event; |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3207 dict_T *v_event = get_v_event(&save_v_event); |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3208 |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3209 // Move the entries from scroll_dict to v_event. |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3210 dict_extend(v_event, scroll_dict, (char_u *)"move", NULL); |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3211 dict_set_items_ro(v_event); |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3212 dict_unref(scroll_dict); |
31170
b7e381d7e8b8
patch 9.0.0919: build failure with tiny features
Bram Moolenaar <Bram@vim.org>
parents:
31166
diff
changeset
|
3213 #endif |
31166
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3214 char_u winid[NUMBUFLEN]; |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3215 vim_snprintf((char *)winid, sizeof(winid), "%d", |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3216 first_scroll_win->w_id); |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3217 apply_autocmds(EVENT_WINSCROLLED, winid, winid, FALSE, |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3218 first_scroll_win->w_buffer); |
31170
b7e381d7e8b8
patch 9.0.0919: build failure with tiny features
Bram Moolenaar <Bram@vim.org>
parents:
31166
diff
changeset
|
3219 #ifdef FEAT_EVAL |
31166
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3220 restore_v_event(v_event, &save_v_event); |
31170
b7e381d7e8b8
patch 9.0.0919: build failure with tiny features
Bram Moolenaar <Bram@vim.org>
parents:
31166
diff
changeset
|
3221 #endif |
31166
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3222 } |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3223 |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3224 recursive = FALSE; |
a86ee6c0309e
patch 9.0.0917: the WinScrolled autocommand event is not enough
Bram Moolenaar <Bram@vim.org>
parents:
31162
diff
changeset
|
3225 window_layout_unlock(); |
28375
e466fdbe0699
patch 8.2.4713: plugins cannot track text scrolling
Bram Moolenaar <Bram@vim.org>
parents:
28361
diff
changeset
|
3226 } |
e466fdbe0699
patch 8.2.4713: plugins cannot track text scrolling
Bram Moolenaar <Bram@vim.org>
parents:
28361
diff
changeset
|
3227 |
7 | 3228 /* |
671 | 3229 * Close window "win" in tab page "tp", which is not the current tab page. |
3535 | 3230 * This may be the last window in that tab page and result in closing the tab, |
671 | 3231 * thus "tp" may become invalid! |
856 | 3232 * Caller must check if buffer is hidden and whether the tabline needs to be |
3233 * updated. | |
671 | 3234 */ |
3235 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3236 win_close_othertab(win_T *win, int free_buf, tabpage_T *tp) |
671 | 3237 { |
3238 win_T *wp; | |
3239 int dir; | |
3240 tabpage_T *ptp = NULL; | |
2191 | 3241 int free_tp = FALSE; |
671 | 3242 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3243 // 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
|
3244 // page changed. |
10106
58e6dd1d8be3
commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents:
10082
diff
changeset
|
3245 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
|
3246 && 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
|
3247 return; // window is already being closed |
3570 | 3248 |
26117
d4d9c7c55a5f
patch 8.2.3591: no event is triggered when closing a window
Bram Moolenaar <Bram@vim.org>
parents:
26077
diff
changeset
|
3249 // 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
|
3250 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
|
3251 // 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
|
3252 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
|
3253 return; |
d4d9c7c55a5f
patch 8.2.3591: no event is triggered when closing a window
Bram Moolenaar <Bram@vim.org>
parents:
26077
diff
changeset
|
3254 |
10076
bc30991c3e98
commit https://github.com/vim/vim/commit/11fbc2866ccc11b4dd1726abdaf582a78ef3f743
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
3255 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
|
3256 // 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
|
3257 close_buffer(win, win->w_buffer, free_buf ? DOBUF_UNLOAD : 0, |
28361
68c36f734b10
patch 8.2.4706: buffer remains active with WinClosed and tabpages
Bram Moolenaar <Bram@vim.org>
parents:
28349
diff
changeset
|
3258 FALSE, TRUE); |
671 | 3259 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3260 // 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
|
3261 // current tab page. |
671 | 3262 for (ptp = first_tabpage; ptp != NULL && ptp != tp; ptp = ptp->tp_next) |
3263 ; | |
672 | 3264 if (ptp == NULL || tp == curtab) |
28211
522864f990ec
patch 8.2.4631: crash when switching window in BufWipeout autocommand
Bram Moolenaar <Bram@vim.org>
parents:
28169
diff
changeset
|
3265 { |
522864f990ec
patch 8.2.4631: crash when switching window in BufWipeout autocommand
Bram Moolenaar <Bram@vim.org>
parents:
28169
diff
changeset
|
3266 // If the buffer was removed from the window we have to give it any |
522864f990ec
patch 8.2.4631: crash when switching window in BufWipeout autocommand
Bram Moolenaar <Bram@vim.org>
parents:
28169
diff
changeset
|
3267 // buffer. |
522864f990ec
patch 8.2.4631: crash when switching window in BufWipeout autocommand
Bram Moolenaar <Bram@vim.org>
parents:
28169
diff
changeset
|
3268 if (win_valid_any_tab(win) && win->w_buffer == NULL) |
522864f990ec
patch 8.2.4631: crash when switching window in BufWipeout autocommand
Bram Moolenaar <Bram@vim.org>
parents:
28169
diff
changeset
|
3269 { |
522864f990ec
patch 8.2.4631: crash when switching window in BufWipeout autocommand
Bram Moolenaar <Bram@vim.org>
parents:
28169
diff
changeset
|
3270 win->w_buffer = firstbuf; |
522864f990ec
patch 8.2.4631: crash when switching window in BufWipeout autocommand
Bram Moolenaar <Bram@vim.org>
parents:
28169
diff
changeset
|
3271 ++firstbuf->b_nwindows; |
522864f990ec
patch 8.2.4631: crash when switching window in BufWipeout autocommand
Bram Moolenaar <Bram@vim.org>
parents:
28169
diff
changeset
|
3272 win_init_empty(win); |
522864f990ec
patch 8.2.4631: crash when switching window in BufWipeout autocommand
Bram Moolenaar <Bram@vim.org>
parents:
28169
diff
changeset
|
3273 } |
671 | 3274 return; |
28211
522864f990ec
patch 8.2.4631: crash when switching window in BufWipeout autocommand
Bram Moolenaar <Bram@vim.org>
parents:
28169
diff
changeset
|
3275 } |
671 | 3276 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3277 // Autocommands may have closed the window already. |
671 | 3278 for (wp = tp->tp_firstwin; wp != NULL && wp != win; wp = wp->w_next) |
3279 ; | |
3280 if (wp == NULL) | |
3281 return; | |
3282 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3283 // When closing the last window in a tab page remove the tab page. |
7009 | 3284 if (tp->tp_firstwin == tp->tp_lastwin) |
671 | 3285 { |
30429
69ff2bd737a9
patch 9.0.0550: crash when closing a tabpage and buffer is NULL
Bram Moolenaar <Bram@vim.org>
parents:
30339
diff
changeset
|
3286 int h = tabline_height(); |
69ff2bd737a9
patch 9.0.0550: crash when closing a tabpage and buffer is NULL
Bram Moolenaar <Bram@vim.org>
parents:
30339
diff
changeset
|
3287 |
671 | 3288 if (tp == first_tabpage) |
3289 first_tabpage = tp->tp_next; | |
3290 else | |
3291 { | |
3292 for (ptp = first_tabpage; ptp != NULL && ptp->tp_next != tp; | |
3293 ptp = ptp->tp_next) | |
3294 ; | |
3295 if (ptp == NULL) | |
3296 { | |
10359
66f1b5bf3fa6
commit https://github.com/vim/vim/commit/95f096030ed1a8afea028f2ea295d6f6a70f466f
Christian Brabandt <cb@256bit.org>
parents:
10357
diff
changeset
|
3297 internal_error("win_close_othertab()"); |
671 | 3298 return; |
3299 } | |
3300 ptp->tp_next = tp->tp_next; | |
3301 } | |
2191 | 3302 free_tp = TRUE; |
30429
69ff2bd737a9
patch 9.0.0550: crash when closing a tabpage and buffer is NULL
Bram Moolenaar <Bram@vim.org>
parents:
30339
diff
changeset
|
3303 redraw_tabline = TRUE; |
69ff2bd737a9
patch 9.0.0550: crash when closing a tabpage and buffer is NULL
Bram Moolenaar <Bram@vim.org>
parents:
30339
diff
changeset
|
3304 if (h != tabline_height()) |
69ff2bd737a9
patch 9.0.0550: crash when closing a tabpage and buffer is NULL
Bram Moolenaar <Bram@vim.org>
parents:
30339
diff
changeset
|
3305 shell_new_rows(); |
2191 | 3306 } |
3307 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3308 // Free the memory used for the window. |
2191 | 3309 win_free_mem(win, &dir, tp); |
3310 | |
3311 if (free_tp) | |
847 | 3312 free_tabpage(tp); |
671 | 3313 } |
3314 | |
3315 /* | |
355 | 3316 * Free the memory used for a window. |
3317 * Returns a pointer to the window that got the freed up space. | |
3318 */ | |
3319 static win_T * | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3320 win_free_mem( |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3321 win_T *win, |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3322 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
|
3323 tabpage_T *tp) // tab page "win" is in, NULL for current |
355 | 3324 { |
3325 frame_T *frp; | |
3326 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
|
3327 tabpage_T *win_tp = tp == NULL ? curtab : tp; |
355 | 3328 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3329 // Remove the window and its frame from the tree of frames. |
355 | 3330 frp = win->w_frame; |
671 | 3331 wp = winframe_remove(win, dirp, tp); |
355 | 3332 vim_free(frp); |
671 | 3333 win_free(win, tp); |
355 | 3334 |
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
|
3335 // 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
|
3336 // 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
|
3337 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
|
3338 win_tp->tp_curwin = wp; |
819 | 3339 |
355 | 3340 return wp; |
3341 } | |
3342 | |
3343 #if defined(EXITFREE) || defined(PROTO) | |
3344 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3345 win_free_all(void) |
355 | 3346 { |
3347 int dummy; | |
3348 | |
27857
8c8fabf093bb
patch 8.2.4454: resetting cmdwin_type only for one situation
Bram Moolenaar <Bram@vim.org>
parents:
27817
diff
changeset
|
3349 // avoid an error for switching tabpage with the cmdline window open |
8c8fabf093bb
patch 8.2.4454: resetting cmdwin_type only for one situation
Bram Moolenaar <Bram@vim.org>
parents:
27817
diff
changeset
|
3350 cmdwin_type = 0; |
30645
101f08b49ed3
patch 9.0.0657: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
30624
diff
changeset
|
3351 |
671 | 3352 while (first_tabpage->tp_next != NULL) |
3353 tabpage_close(TRUE); | |
3354 | |
31263
d8e7d725a666
patch 9.0.0965: using one window for executing autocommands is insufficient
Bram Moolenaar <Bram@vim.org>
parents:
31261
diff
changeset
|
3355 for (int i = 0; i < AUCMD_WIN_COUNT; ++i) |
31267
4bc9cd62d378
patch 9.0.0967: leaking memory from autocmd windows
Bram Moolenaar <Bram@vim.org>
parents:
31263
diff
changeset
|
3356 if (aucmd_win[i].auc_win != NULL) |
31263
d8e7d725a666
patch 9.0.0965: using one window for executing autocommands is insufficient
Bram Moolenaar <Bram@vim.org>
parents:
31261
diff
changeset
|
3357 { |
d8e7d725a666
patch 9.0.0965: using one window for executing autocommands is insufficient
Bram Moolenaar <Bram@vim.org>
parents:
31261
diff
changeset
|
3358 (void)win_free_mem(aucmd_win[i].auc_win, &dummy, NULL); |
31267
4bc9cd62d378
patch 9.0.0967: leaking memory from autocmd windows
Bram Moolenaar <Bram@vim.org>
parents:
31263
diff
changeset
|
3359 aucmd_win[i].auc_win = NULL; |
31263
d8e7d725a666
patch 9.0.0965: using one window for executing autocommands is insufficient
Bram Moolenaar <Bram@vim.org>
parents:
31261
diff
changeset
|
3360 } |
1918 | 3361 |
3362 while (firstwin != NULL) | |
3363 (void)win_free_mem(firstwin, &dummy, NULL); | |
6060 | 3364 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3365 // 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
|
3366 // instead of using freed memory. |
6060 | 3367 curwin = NULL; |
355 | 3368 } |
3369 #endif | |
3370 | |
3371 /* | |
7 | 3372 * Remove a window and its frame from the tree of frames. |
3373 * Returns a pointer to the window that got the freed up space. | |
3374 */ | |
1906 | 3375 win_T * |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3376 winframe_remove( |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3377 win_T *win, |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3378 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
|
3379 tabpage_T *tp) // tab page "win" is in, NULL for current |
7 | 3380 { |
3381 frame_T *frp, *frp2, *frp3; | |
3382 frame_T *frp_close = win->w_frame; | |
3383 win_T *wp; | |
3384 | |
3385 /* | |
671 | 3386 * If there is only one window there is nothing to remove. |
3387 */ | |
10349
cf988222b150
commit https://github.com/vim/vim/commit/a1f4cb93ba50ea9e40cd4b1f5592b8a6d1398660
Christian Brabandt <cb@256bit.org>
parents:
10106
diff
changeset
|
3388 if (tp == NULL ? ONE_WINDOW : tp->tp_firstwin == tp->tp_lastwin) |
671 | 3389 return NULL; |
3390 | |
3391 /* | |
7 | 3392 * Remove the window from its frame. |
3393 */ | |
671 | 3394 frp2 = win_altframe(win, tp); |
7 | 3395 wp = frame2win(frp2); |
3396 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3397 // Remove this frame from the list of frames. |
7 | 3398 frame_remove(frp_close); |
3399 | |
3400 if (frp_close->fr_parent->fr_layout == FR_COL) | |
3401 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3402 // 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
|
3403 // (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
|
3404 // to. |
1346 | 3405 if (frp2->fr_win != NULL && frp2->fr_win->w_p_wfh) |
3406 { | |
3407 frp = frp_close->fr_prev; | |
3408 frp3 = frp_close->fr_next; | |
3409 while (frp != NULL || frp3 != NULL) | |
3410 { | |
3411 if (frp != NULL) | |
3412 { | |
16166
a3284dd27de6
patch 8.1.1088: height of quickfix window not retained with vertical split
Bram Moolenaar <Bram@vim.org>
parents:
16019
diff
changeset
|
3413 if (!frame_fixed_height(frp)) |
1346 | 3414 { |
3415 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
|
3416 wp = frame2win(frp2); |
1346 | 3417 break; |
3418 } | |
3419 frp = frp->fr_prev; | |
3420 } | |
3421 if (frp3 != NULL) | |
3422 { | |
3423 if (frp3->fr_win != NULL && !frp3->fr_win->w_p_wfh) | |
3424 { | |
3425 frp2 = frp3; | |
3426 wp = frp3->fr_win; | |
3427 break; | |
3428 } | |
3429 frp3 = frp3->fr_next; | |
3430 } | |
3431 } | |
3432 } | |
7 | 3433 frame_new_height(frp2, frp2->fr_height + frp_close->fr_height, |
3434 frp2 == frp_close->fr_next ? TRUE : FALSE, FALSE); | |
3435 *dirp = 'v'; | |
3436 } | |
3437 else | |
3438 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3439 // 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
|
3440 // (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
|
3441 // to. |
1346 | 3442 if (frp2->fr_win != NULL && frp2->fr_win->w_p_wfw) |
3443 { | |
3444 frp = frp_close->fr_prev; | |
3445 frp3 = frp_close->fr_next; | |
3446 while (frp != NULL || frp3 != NULL) | |
3447 { | |
3448 if (frp != NULL) | |
3449 { | |
16166
a3284dd27de6
patch 8.1.1088: height of quickfix window not retained with vertical split
Bram Moolenaar <Bram@vim.org>
parents:
16019
diff
changeset
|
3450 if (!frame_fixed_width(frp)) |
1346 | 3451 { |
3452 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
|
3453 wp = frame2win(frp2); |
1346 | 3454 break; |
3455 } | |
3456 frp = frp->fr_prev; | |
3457 } | |
3458 if (frp3 != NULL) | |
3459 { | |
3460 if (frp3->fr_win != NULL && !frp3->fr_win->w_p_wfw) | |
3461 { | |
3462 frp2 = frp3; | |
3463 wp = frp3->fr_win; | |
3464 break; | |
3465 } | |
3466 frp3 = frp3->fr_next; | |
3467 } | |
3468 } | |
3469 } | |
7 | 3470 frame_new_width(frp2, frp2->fr_width + frp_close->fr_width, |
779 | 3471 frp2 == frp_close->fr_next ? TRUE : FALSE, FALSE); |
7 | 3472 *dirp = 'h'; |
3473 } | |
3474 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3475 // 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
|
3476 // updated. Can only be done after the sizes have been updated. |
7 | 3477 if (frp2 == frp_close->fr_next) |
3478 { | |
3479 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
|
3480 int col = win->w_wincol; |
7 | 3481 |
3482 frame_comp_pos(frp2, &row, &col); | |
3483 } | |
3484 | |
3485 if (frp2->fr_next == NULL && frp2->fr_prev == NULL) | |
3486 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3487 // 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
|
3488 // and remove it. |
7 | 3489 frp2->fr_parent->fr_layout = frp2->fr_layout; |
3490 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
|
3491 FOR_ALL_FRAMES(frp, frp2->fr_child) |
7 | 3492 frp->fr_parent = frp2->fr_parent; |
3493 frp2->fr_parent->fr_win = frp2->fr_win; | |
3494 if (frp2->fr_win != NULL) | |
3495 frp2->fr_win->w_frame = frp2->fr_parent; | |
3496 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
|
3497 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
|
3498 topframe->fr_child = frp; |
7 | 3499 vim_free(frp2); |
3500 | |
3501 frp2 = frp->fr_parent; | |
3502 if (frp2 != NULL && frp2->fr_layout == frp->fr_layout) | |
3503 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3504 // 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
|
3505 // the frames into this list. |
7 | 3506 if (frp2->fr_child == frp) |
3507 frp2->fr_child = frp->fr_child; | |
3508 frp->fr_child->fr_prev = frp->fr_prev; | |
3509 if (frp->fr_prev != NULL) | |
3510 frp->fr_prev->fr_next = frp->fr_child; | |
3511 for (frp3 = frp->fr_child; ; frp3 = frp3->fr_next) | |
3512 { | |
3513 frp3->fr_parent = frp2; | |
3514 if (frp3->fr_next == NULL) | |
3515 { | |
3516 frp3->fr_next = frp->fr_next; | |
3517 if (frp->fr_next != NULL) | |
3518 frp->fr_next->fr_prev = frp3; | |
3519 break; | |
3520 } | |
3521 } | |
13144
20fb8c711050
patch 8.0.1446: acessing freed memory after window command in auto command
Christian Brabandt <cb@256bit.org>
parents:
13103
diff
changeset
|
3522 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
|
3523 topframe->fr_child = frp2; |
7 | 3524 vim_free(frp); |
3525 } | |
3526 } | |
3527 | |
3528 return wp; | |
3529 } | |
3530 | |
3531 /* | |
13837
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
3532 * 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
|
3533 * 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
|
3534 * |
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
3535 * 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
|
3536 * 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
|
3537 * 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
|
3538 * 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
|
3539 * respected when possible. |
7 | 3540 */ |
3541 static frame_T * | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3542 win_altframe( |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3543 win_T *win, |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3544 tabpage_T *tp) // tab page "win" is in, NULL for current |
7 | 3545 { |
3546 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
|
3547 frame_T *other_fr, *target_fr; |
7 | 3548 |
10349
cf988222b150
commit https://github.com/vim/vim/commit/a1f4cb93ba50ea9e40cd4b1f5592b8a6d1398660
Christian Brabandt <cb@256bit.org>
parents:
10106
diff
changeset
|
3549 if (tp == NULL ? ONE_WINDOW : tp->tp_firstwin == tp->tp_lastwin) |
667 | 3550 return alt_tabpage()->tp_curwin->w_frame; |
3551 | |
7 | 3552 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
|
3553 |
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
3554 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
|
3555 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
|
3556 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
|
3557 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
|
3558 |
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
|
3559 // 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
|
3560 // window |
13837
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
3561 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
|
3562 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
|
3563 |
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
|
3564 // 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
|
3565 // 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
|
3566 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
|
3567 { |
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
|
3568 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
|
3569 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
|
3570 } |
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
|
3571 |
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
|
3572 // 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
|
3573 // 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
|
3574 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
|
3575 { |
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
3576 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
|
3577 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
|
3578 } |
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
3579 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3580 // 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
|
3581 // window, reverse the selection. |
355 | 3582 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
|
3583 { |
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
3584 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
|
3585 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
|
3586 } |
7 | 3587 else |
13837
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
3588 { |
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
3589 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
|
3590 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
|
3591 } |
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
3592 |
79419af4b29c
patch 8.0.1790: 'winfixwidth' is not always respected by :close
Christian Brabandt <cb@256bit.org>
parents:
13670
diff
changeset
|
3593 return target_fr; |
7 | 3594 } |
3595 | |
3596 /* | |
667 | 3597 * Return the tabpage that will be used if the current one is closed. |
3598 */ | |
3599 static tabpage_T * | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3600 alt_tabpage(void) |
667 | 3601 { |
672 | 3602 tabpage_T *tp; |
3603 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3604 // Use the next tab page if possible. |
682 | 3605 if (curtab->tp_next != NULL) |
672 | 3606 return curtab->tp_next; |
3607 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3608 // Find the last but one tab page. |
682 | 3609 for (tp = first_tabpage; tp->tp_next != curtab; tp = tp->tp_next) |
3610 ; | |
674 | 3611 return tp; |
667 | 3612 } |
3613 | |
3614 /* | |
7 | 3615 * Find the left-upper window in frame "frp". |
3616 */ | |
3617 static win_T * | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3618 frame2win(frame_T *frp) |
7 | 3619 { |
3620 while (frp->fr_win == NULL) | |
3621 frp = frp->fr_child; | |
3622 return frp->fr_win; | |
3623 } | |
3624 | |
3625 /* | |
3626 * Return TRUE if frame "frp" contains window "wp". | |
3627 */ | |
3628 static int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3629 frame_has_win(frame_T *frp, win_T *wp) |
7 | 3630 { |
3631 frame_T *p; | |
3632 | |
3633 if (frp->fr_layout == FR_LEAF) | |
3634 return frp->fr_win == wp; | |
3635 | |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
3636 FOR_ALL_FRAMES(p, frp->fr_child) |
7 | 3637 if (frame_has_win(p, wp)) |
3638 return TRUE; | |
3639 return FALSE; | |
3640 } | |
3641 | |
3642 /* | |
3643 * Set a new height for a frame. Recursively sets the height for contained | |
3644 * frames and windows. Caller must take care of positions. | |
3645 */ | |
3646 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3647 frame_new_height( |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3648 frame_T *topfrp, |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3649 int height, |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3650 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
|
3651 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
|
3652 // may cause the height not to be set |
7 | 3653 { |
3654 frame_T *frp; | |
3655 int extra_lines; | |
3656 int h; | |
3657 | |
3658 if (topfrp->fr_win != NULL) | |
3659 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3660 // Simple case: just one window. |
7 | 3661 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
|
3662 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
|
3663 - WINBAR_HEIGHT(topfrp->fr_win)); |
7 | 3664 } |
3665 else if (topfrp->fr_layout == FR_ROW) | |
3666 { | |
3667 do | |
3668 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3669 // 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
|
3670 FOR_ALL_FRAMES(frp, topfrp->fr_child) |
7 | 3671 { |
3672 frame_new_height(frp, height, topfirst, wfh); | |
3673 if (frp->fr_height > height) | |
3674 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3675 // Could not fit the windows, make the whole row higher. |
7 | 3676 height = frp->fr_height; |
3677 break; | |
3678 } | |
3679 } | |
3680 } | |
3681 while (frp != NULL); | |
3682 } | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3683 else // fr_layout == FR_COL |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3684 { |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3685 // 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
|
3686 // frame first, frames above that when needed. |
7 | 3687 |
3688 frp = topfrp->fr_child; | |
3689 if (wfh) | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3690 // Advance past frames with one window with 'wfh' set. |
7 | 3691 while (frame_fixed_height(frp)) |
3692 { | |
3693 frp = frp->fr_next; | |
3694 if (frp == NULL) | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3695 return; // no frame without 'wfh', give up |
7 | 3696 } |
3697 if (!topfirst) | |
3698 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3699 // Find the bottom frame of this column |
7 | 3700 while (frp->fr_next != NULL) |
3701 frp = frp->fr_next; | |
3702 if (wfh) | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3703 // Advance back for frames with one window with 'wfh' set. |
7 | 3704 while (frame_fixed_height(frp)) |
3705 frp = frp->fr_prev; | |
3706 } | |
3707 | |
3708 extra_lines = height - topfrp->fr_height; | |
3709 if (extra_lines < 0) | |
3710 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3711 // reduce height of contained frames, bottom or top frame first |
7 | 3712 while (frp != NULL) |
3713 { | |
3714 h = frame_minheight(frp, NULL); | |
3715 if (frp->fr_height + extra_lines < h) | |
3716 { | |
3717 extra_lines += frp->fr_height - h; | |
3718 frame_new_height(frp, h, topfirst, wfh); | |
3719 } | |
3720 else | |
3721 { | |
3722 frame_new_height(frp, frp->fr_height + extra_lines, | |
3723 topfirst, wfh); | |
3724 break; | |
3725 } | |
3726 if (topfirst) | |
3727 { | |
3728 do | |
3729 frp = frp->fr_next; | |
3730 while (wfh && frp != NULL && frame_fixed_height(frp)); | |
3731 } | |
3732 else | |
3733 { | |
3734 do | |
3735 frp = frp->fr_prev; | |
3736 while (wfh && frp != NULL && frame_fixed_height(frp)); | |
3737 } | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3738 // Increase "height" if we could not reduce enough frames. |
7 | 3739 if (frp == NULL) |
3740 height -= extra_lines; | |
3741 } | |
3742 } | |
3743 else if (extra_lines > 0) | |
3744 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3745 // increase height of bottom or top frame |
7 | 3746 frame_new_height(frp, frp->fr_height + extra_lines, topfirst, wfh); |
3747 } | |
3748 } | |
3749 topfrp->fr_height = height; | |
3750 } | |
3751 | |
3752 /* | |
3753 * Return TRUE if height of frame "frp" should not be changed because of | |
3754 * the 'winfixheight' option. | |
3755 */ | |
3756 static int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3757 frame_fixed_height(frame_T *frp) |
7 | 3758 { |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3759 // frame with one window: fixed height if 'winfixheight' set. |
7 | 3760 if (frp->fr_win != NULL) |
3761 return frp->fr_win->w_p_wfh; | |
3762 | |
3763 if (frp->fr_layout == FR_ROW) | |
3764 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3765 // 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
|
3766 // height. |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
3767 FOR_ALL_FRAMES(frp, frp->fr_child) |
7 | 3768 if (frame_fixed_height(frp)) |
3769 return TRUE; | |
3770 return FALSE; | |
3771 } | |
3772 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3773 // 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
|
3774 // 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
|
3775 FOR_ALL_FRAMES(frp, frp->fr_child) |
7 | 3776 if (!frame_fixed_height(frp)) |
3777 return FALSE; | |
3778 return TRUE; | |
3779 } | |
3780 | |
3781 /* | |
779 | 3782 * Return TRUE if width of frame "frp" should not be changed because of |
3783 * the 'winfixwidth' option. | |
3784 */ | |
3785 static int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3786 frame_fixed_width(frame_T *frp) |
779 | 3787 { |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3788 // frame with one window: fixed width if 'winfixwidth' set. |
779 | 3789 if (frp->fr_win != NULL) |
3790 return frp->fr_win->w_p_wfw; | |
3791 | |
3792 if (frp->fr_layout == FR_COL) | |
3793 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3794 // 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
|
3795 // width. |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
3796 FOR_ALL_FRAMES(frp, frp->fr_child) |
779 | 3797 if (frame_fixed_width(frp)) |
3798 return TRUE; | |
3799 return FALSE; | |
3800 } | |
3801 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3802 // 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
|
3803 // 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
|
3804 FOR_ALL_FRAMES(frp, frp->fr_child) |
779 | 3805 if (!frame_fixed_width(frp)) |
3806 return FALSE; | |
3807 return TRUE; | |
3808 } | |
3809 | |
3810 /* | |
7 | 3811 * Add a status line to windows at the bottom of "frp". |
3812 * Note: Does not check if there is room! | |
3813 */ | |
3814 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3815 frame_add_statusline(frame_T *frp) |
7 | 3816 { |
3817 win_T *wp; | |
3818 | |
3819 if (frp->fr_layout == FR_LEAF) | |
3820 { | |
3821 wp = frp->fr_win; | |
32319
23d44be6ec20
patch 9.0.1491: wrong scrolling with ls=0 and :botright split
Bram Moolenaar <Bram@vim.org>
parents:
32295
diff
changeset
|
3822 wp->w_status_height = STATUS_HEIGHT; |
7 | 3823 } |
3824 else if (frp->fr_layout == FR_ROW) | |
3825 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3826 // 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
|
3827 FOR_ALL_FRAMES(frp, frp->fr_child) |
7 | 3828 frame_add_statusline(frp); |
3829 } | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3830 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
|
3831 { |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3832 // Only need to handle the last frame in the column. |
7 | 3833 for (frp = frp->fr_child; frp->fr_next != NULL; frp = frp->fr_next) |
3834 ; | |
3835 frame_add_statusline(frp); | |
3836 } | |
3837 } | |
3838 | |
3839 /* | |
3840 * Set width of a frame. Handles recursively going through contained frames. | |
3841 * May remove separator line for windows at the right side (for win_close()). | |
3842 */ | |
3843 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3844 frame_new_width( |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3845 frame_T *topfrp, |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3846 int width, |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3847 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
|
3848 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
|
3849 // may cause the width not to be set |
7 | 3850 { |
3851 frame_T *frp; | |
3852 int extra_cols; | |
3853 int w; | |
3854 win_T *wp; | |
3855 | |
3856 if (topfrp->fr_layout == FR_LEAF) | |
3857 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3858 // Simple case: just one window. |
7 | 3859 wp = topfrp->fr_win; |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3860 // Find out if there are any windows right of this one. |
7 | 3861 for (frp = topfrp; frp->fr_parent != NULL; frp = frp->fr_parent) |
3862 if (frp->fr_parent->fr_layout == FR_ROW && frp->fr_next != NULL) | |
3863 break; | |
3864 if (frp->fr_parent == NULL) | |
3865 wp->w_vsep_width = 0; | |
3866 win_new_width(wp, width - wp->w_vsep_width); | |
3867 } | |
3868 else if (topfrp->fr_layout == FR_COL) | |
3869 { | |
779 | 3870 do |
3871 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3872 // 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
|
3873 FOR_ALL_FRAMES(frp, topfrp->fr_child) |
779 | 3874 { |
3875 frame_new_width(frp, width, leftfirst, wfw); | |
3876 if (frp->fr_width > width) | |
3877 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3878 // Could not fit the windows, make whole column wider. |
779 | 3879 width = frp->fr_width; |
3880 break; | |
3881 } | |
3882 } | |
3883 } while (frp != NULL); | |
7 | 3884 } |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3885 else // fr_layout == FR_ROW |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3886 { |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3887 // 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
|
3888 // frame first, frames left of it when needed. |
7 | 3889 |
3890 frp = topfrp->fr_child; | |
779 | 3891 if (wfw) |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3892 // Advance past frames with one window with 'wfw' set. |
779 | 3893 while (frame_fixed_width(frp)) |
3894 { | |
3895 frp = frp->fr_next; | |
3896 if (frp == NULL) | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3897 return; // no frame without 'wfw', give up |
779 | 3898 } |
7 | 3899 if (!leftfirst) |
779 | 3900 { |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3901 // Find the rightmost frame of this row |
7 | 3902 while (frp->fr_next != NULL) |
3903 frp = frp->fr_next; | |
779 | 3904 if (wfw) |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3905 // Advance back for frames with one window with 'wfw' set. |
779 | 3906 while (frame_fixed_width(frp)) |
3907 frp = frp->fr_prev; | |
3908 } | |
7 | 3909 |
3910 extra_cols = width - topfrp->fr_width; | |
3911 if (extra_cols < 0) | |
3912 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3913 // reduce frame width, rightmost frame first |
7 | 3914 while (frp != NULL) |
3915 { | |
3916 w = frame_minwidth(frp, NULL); | |
3917 if (frp->fr_width + extra_cols < w) | |
3918 { | |
3919 extra_cols += frp->fr_width - w; | |
779 | 3920 frame_new_width(frp, w, leftfirst, wfw); |
7 | 3921 } |
3922 else | |
3923 { | |
779 | 3924 frame_new_width(frp, frp->fr_width + extra_cols, |
3925 leftfirst, wfw); | |
7 | 3926 break; |
3927 } | |
3928 if (leftfirst) | |
779 | 3929 { |
3930 do | |
3931 frp = frp->fr_next; | |
3932 while (wfw && frp != NULL && frame_fixed_width(frp)); | |
3933 } | |
7 | 3934 else |
779 | 3935 { |
3936 do | |
3937 frp = frp->fr_prev; | |
3938 while (wfw && frp != NULL && frame_fixed_width(frp)); | |
3939 } | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3940 // Increase "width" if we could not reduce enough frames. |
779 | 3941 if (frp == NULL) |
3942 width -= extra_cols; | |
7 | 3943 } |
3944 } | |
3945 else if (extra_cols > 0) | |
3946 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3947 // increase width of rightmost frame |
779 | 3948 frame_new_width(frp, frp->fr_width + extra_cols, leftfirst, wfw); |
7 | 3949 } |
3950 } | |
3951 topfrp->fr_width = width; | |
3952 } | |
3953 | |
3954 /* | |
3955 * Add the vertical separator to windows at the right side of "frp". | |
3956 * Note: Does not check if there is room! | |
3957 */ | |
3958 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3959 frame_add_vsep(frame_T *frp) |
7 | 3960 { |
3961 win_T *wp; | |
3962 | |
3963 if (frp->fr_layout == FR_LEAF) | |
3964 { | |
3965 wp = frp->fr_win; | |
3966 if (wp->w_vsep_width == 0) | |
3967 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3968 if (wp->w_width > 0) // don't make it negative |
7 | 3969 --wp->w_width; |
3970 wp->w_vsep_width = 1; | |
3971 } | |
3972 } | |
3973 else if (frp->fr_layout == FR_COL) | |
3974 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3975 // 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
|
3976 FOR_ALL_FRAMES(frp, frp->fr_child) |
7 | 3977 frame_add_vsep(frp); |
3978 } | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3979 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
|
3980 { |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3981 // Only need to handle the last frame in the row. |
7 | 3982 frp = frp->fr_child; |
3983 while (frp->fr_next != NULL) | |
3984 frp = frp->fr_next; | |
3985 frame_add_vsep(frp); | |
3986 } | |
3987 } | |
3988 | |
3989 /* | |
3990 * Set frame width from the window it contains. | |
3991 */ | |
3992 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3993 frame_fix_width(win_T *wp) |
7 | 3994 { |
3995 wp->w_frame->fr_width = wp->w_width + wp->w_vsep_width; | |
3996 } | |
3997 | |
3998 /* | |
3999 * Set frame height from the window it contains. | |
4000 */ | |
4001 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4002 frame_fix_height(win_T *wp) |
7 | 4003 { |
12998
dd734ee3e2fe
patch 8.0.1375: window size wrong after maximizing with WinBar
Christian Brabandt <cb@256bit.org>
parents:
12916
diff
changeset
|
4004 wp->w_frame->fr_height = VISIBLE_HEIGHT(wp) + wp->w_status_height; |
7 | 4005 } |
4006 | |
4007 /* | |
4008 * Compute the minimal height for frame "topfrp". | |
4009 * Uses the 'winminheight' option. | |
4010 * When "next_curwin" isn't NULL, use p_wh for this window. | |
4011 * When "next_curwin" is NOWIN, don't use at least one line for the current | |
4012 * window. | |
4013 */ | |
4014 static int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4015 frame_minheight(frame_T *topfrp, win_T *next_curwin) |
7 | 4016 { |
4017 frame_T *frp; | |
4018 int m; | |
4019 int n; | |
4020 | |
4021 if (topfrp->fr_win != NULL) | |
4022 { | |
4023 if (topfrp->fr_win == next_curwin) | |
4024 m = p_wh + topfrp->fr_win->w_status_height; | |
4025 else | |
4026 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4027 // window: minimal height of the window plus status line |
7 | 4028 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
|
4029 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
|
4030 { |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4031 // 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
|
4032 // visible. |
12998
dd734ee3e2fe
patch 8.0.1375: window size wrong after maximizing with WinBar
Christian Brabandt <cb@256bit.org>
parents:
12916
diff
changeset
|
4033 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
|
4034 ++m; |
dd734ee3e2fe
patch 8.0.1375: window size wrong after maximizing with WinBar
Christian Brabandt <cb@256bit.org>
parents:
12916
diff
changeset
|
4035 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
|
4036 } |
7 | 4037 } |
4038 } | |
4039 else if (topfrp->fr_layout == FR_ROW) | |
4040 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4041 // get the minimal height from each frame in this row |
7 | 4042 m = 0; |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
4043 FOR_ALL_FRAMES(frp, topfrp->fr_child) |
7 | 4044 { |
4045 n = frame_minheight(frp, next_curwin); | |
4046 if (n > m) | |
4047 m = n; | |
4048 } | |
4049 } | |
4050 else | |
4051 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4052 // Add up the minimal heights for all frames in this column. |
7 | 4053 m = 0; |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
4054 FOR_ALL_FRAMES(frp, topfrp->fr_child) |
7 | 4055 m += frame_minheight(frp, next_curwin); |
4056 } | |
4057 | |
4058 return m; | |
4059 } | |
4060 | |
4061 /* | |
4062 * Compute the minimal width for frame "topfrp". | |
4063 * When "next_curwin" isn't NULL, use p_wiw for this window. | |
4064 * When "next_curwin" is NOWIN, don't use at least one column for the current | |
4065 * window. | |
4066 */ | |
4067 static int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4068 frame_minwidth( |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4069 frame_T *topfrp, |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4070 win_T *next_curwin) // use p_wh and p_wiw for next_curwin |
7 | 4071 { |
4072 frame_T *frp; | |
4073 int m, n; | |
4074 | |
4075 if (topfrp->fr_win != NULL) | |
4076 { | |
4077 if (topfrp->fr_win == next_curwin) | |
4078 m = p_wiw + topfrp->fr_win->w_vsep_width; | |
4079 else | |
4080 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4081 // window: minimal width of the window plus separator column |
7 | 4082 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
|
4083 // Current window is minimal one column wide |
7 | 4084 if (p_wmw == 0 && topfrp->fr_win == curwin && next_curwin == NULL) |
4085 ++m; | |
4086 } | |
4087 } | |
4088 else if (topfrp->fr_layout == FR_COL) | |
4089 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4090 // get the minimal width from each frame in this column |
7 | 4091 m = 0; |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
4092 FOR_ALL_FRAMES(frp, topfrp->fr_child) |
7 | 4093 { |
4094 n = frame_minwidth(frp, next_curwin); | |
4095 if (n > m) | |
4096 m = n; | |
4097 } | |
4098 } | |
4099 else | |
4100 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4101 // Add up the minimal widths for all frames in this row. |
7 | 4102 m = 0; |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
4103 FOR_ALL_FRAMES(frp, topfrp->fr_child) |
7 | 4104 m += frame_minwidth(frp, next_curwin); |
4105 } | |
4106 | |
4107 return m; | |
4108 } | |
4109 | |
4110 | |
4111 /* | |
4112 * Try to close all windows except current one. | |
4113 * Buffers in the other windows become hidden if 'hidden' is set, or '!' is | |
4114 * used and the buffer was modified. | |
4115 * | |
4116 * Used by ":bdel" and ":only". | |
4117 */ | |
4118 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4119 close_others( |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4120 int message, |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4121 int forceit) // always hide all other windows |
7 | 4122 { |
4123 win_T *wp; | |
4124 win_T *nextwp; | |
4125 int r; | |
4126 | |
1906 | 4127 if (one_window()) |
7 | 4128 { |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13308
diff
changeset
|
4129 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
|
4130 msg(_(m_onlyone)); |
7 | 4131 return; |
4132 } | |
4133 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4134 // Be very careful here: autocommands may change the window layout. |
7 | 4135 for (wp = firstwin; win_valid(wp); wp = nextwp) |
4136 { | |
4137 nextwp = wp->w_next; | |
29566
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29548
diff
changeset
|
4138 if (wp == curwin) // don't close current window |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29548
diff
changeset
|
4139 continue; |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29548
diff
changeset
|
4140 |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29548
diff
changeset
|
4141 // Check if it's allowed to abandon this window |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29548
diff
changeset
|
4142 r = can_abandon(wp->w_buffer, forceit); |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29548
diff
changeset
|
4143 if (!win_valid(wp)) // autocommands messed wp up |
7 | 4144 { |
29566
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29548
diff
changeset
|
4145 nextwp = firstwin; |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29548
diff
changeset
|
4146 continue; |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29548
diff
changeset
|
4147 } |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29548
diff
changeset
|
4148 if (!r) |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29548
diff
changeset
|
4149 { |
7 | 4150 #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) |
29566
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29548
diff
changeset
|
4151 if (message && (p_confirm |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29548
diff
changeset
|
4152 || (cmdmod.cmod_flags & CMOD_CONFIRM)) && p_write) |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29548
diff
changeset
|
4153 { |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29548
diff
changeset
|
4154 dialog_changed(wp->w_buffer, FALSE); |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29548
diff
changeset
|
4155 if (!win_valid(wp)) // autocommands messed wp up |
7 | 4156 { |
29566
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29548
diff
changeset
|
4157 nextwp = firstwin; |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29548
diff
changeset
|
4158 continue; |
7 | 4159 } |
29566
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29548
diff
changeset
|
4160 } |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29548
diff
changeset
|
4161 if (bufIsChanged(wp->w_buffer)) |
7 | 4162 #endif |
29566
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29548
diff
changeset
|
4163 continue; |
7 | 4164 } |
29566
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
29548
diff
changeset
|
4165 win_close(wp, !buf_hide(wp->w_buffer) && !bufIsChanged(wp->w_buffer)); |
7 | 4166 } |
4167 | |
10357
59d01e335858
commit https://github.com/vim/vim/commit/459ca563128f2edb7e3bb190090bbb755a56dd55
Christian Brabandt <cb@256bit.org>
parents:
10349
diff
changeset
|
4168 if (message && !ONE_WINDOW) |
26913
d4e61d61afd9
patch 8.2.3985: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26893
diff
changeset
|
4169 emsg(_(e_other_window_contains_changes)); |
7 | 4170 } |
4171 | |
17789
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17670
diff
changeset
|
4172 /* |
31162
981f7bc781bb
patch 9.0.0915: WinScrolled may trigger immediately when defined
Bram Moolenaar <Bram@vim.org>
parents:
31158
diff
changeset
|
4173 * Store the relevant window pointers for tab page "tp". To be used before |
981f7bc781bb
patch 9.0.0915: WinScrolled may trigger immediately when defined
Bram Moolenaar <Bram@vim.org>
parents:
31158
diff
changeset
|
4174 * use_tabpage(). |
981f7bc781bb
patch 9.0.0915: WinScrolled may trigger immediately when defined
Bram Moolenaar <Bram@vim.org>
parents:
31158
diff
changeset
|
4175 */ |
981f7bc781bb
patch 9.0.0915: WinScrolled may trigger immediately when defined
Bram Moolenaar <Bram@vim.org>
parents:
31158
diff
changeset
|
4176 void |
981f7bc781bb
patch 9.0.0915: WinScrolled may trigger immediately when defined
Bram Moolenaar <Bram@vim.org>
parents:
31158
diff
changeset
|
4177 unuse_tabpage(tabpage_T *tp) |
981f7bc781bb
patch 9.0.0915: WinScrolled may trigger immediately when defined
Bram Moolenaar <Bram@vim.org>
parents:
31158
diff
changeset
|
4178 { |
981f7bc781bb
patch 9.0.0915: WinScrolled may trigger immediately when defined
Bram Moolenaar <Bram@vim.org>
parents:
31158
diff
changeset
|
4179 tp->tp_topframe = topframe; |
981f7bc781bb
patch 9.0.0915: WinScrolled may trigger immediately when defined
Bram Moolenaar <Bram@vim.org>
parents:
31158
diff
changeset
|
4180 tp->tp_firstwin = firstwin; |
981f7bc781bb
patch 9.0.0915: WinScrolled may trigger immediately when defined
Bram Moolenaar <Bram@vim.org>
parents:
31158
diff
changeset
|
4181 tp->tp_lastwin = lastwin; |
981f7bc781bb
patch 9.0.0915: WinScrolled may trigger immediately when defined
Bram Moolenaar <Bram@vim.org>
parents:
31158
diff
changeset
|
4182 tp->tp_curwin = curwin; |
981f7bc781bb
patch 9.0.0915: WinScrolled may trigger immediately when defined
Bram Moolenaar <Bram@vim.org>
parents:
31158
diff
changeset
|
4183 } |
981f7bc781bb
patch 9.0.0915: WinScrolled may trigger immediately when defined
Bram Moolenaar <Bram@vim.org>
parents:
31158
diff
changeset
|
4184 |
981f7bc781bb
patch 9.0.0915: WinScrolled may trigger immediately when defined
Bram Moolenaar <Bram@vim.org>
parents:
31158
diff
changeset
|
4185 /* |
981f7bc781bb
patch 9.0.0915: WinScrolled may trigger immediately when defined
Bram Moolenaar <Bram@vim.org>
parents:
31158
diff
changeset
|
4186 * Set the relevant pointers to use tab page "tp". May want to call |
981f7bc781bb
patch 9.0.0915: WinScrolled may trigger immediately when defined
Bram Moolenaar <Bram@vim.org>
parents:
31158
diff
changeset
|
4187 * unuse_tabpage() first. |
981f7bc781bb
patch 9.0.0915: WinScrolled may trigger immediately when defined
Bram Moolenaar <Bram@vim.org>
parents:
31158
diff
changeset
|
4188 */ |
981f7bc781bb
patch 9.0.0915: WinScrolled may trigger immediately when defined
Bram Moolenaar <Bram@vim.org>
parents:
31158
diff
changeset
|
4189 void |
981f7bc781bb
patch 9.0.0915: WinScrolled may trigger immediately when defined
Bram Moolenaar <Bram@vim.org>
parents:
31158
diff
changeset
|
4190 use_tabpage(tabpage_T *tp) |
981f7bc781bb
patch 9.0.0915: WinScrolled may trigger immediately when defined
Bram Moolenaar <Bram@vim.org>
parents:
31158
diff
changeset
|
4191 { |
981f7bc781bb
patch 9.0.0915: WinScrolled may trigger immediately when defined
Bram Moolenaar <Bram@vim.org>
parents:
31158
diff
changeset
|
4192 curtab = tp; |
981f7bc781bb
patch 9.0.0915: WinScrolled may trigger immediately when defined
Bram Moolenaar <Bram@vim.org>
parents:
31158
diff
changeset
|
4193 topframe = curtab->tp_topframe; |
981f7bc781bb
patch 9.0.0915: WinScrolled may trigger immediately when defined
Bram Moolenaar <Bram@vim.org>
parents:
31158
diff
changeset
|
4194 firstwin = curtab->tp_firstwin; |
981f7bc781bb
patch 9.0.0915: WinScrolled may trigger immediately when defined
Bram Moolenaar <Bram@vim.org>
parents:
31158
diff
changeset
|
4195 lastwin = curtab->tp_lastwin; |
981f7bc781bb
patch 9.0.0915: WinScrolled may trigger immediately when defined
Bram Moolenaar <Bram@vim.org>
parents:
31158
diff
changeset
|
4196 curwin = curtab->tp_curwin; |
981f7bc781bb
patch 9.0.0915: WinScrolled may trigger immediately when defined
Bram Moolenaar <Bram@vim.org>
parents:
31158
diff
changeset
|
4197 } |
981f7bc781bb
patch 9.0.0915: WinScrolled may trigger immediately when defined
Bram Moolenaar <Bram@vim.org>
parents:
31158
diff
changeset
|
4198 |
981f7bc781bb
patch 9.0.0915: WinScrolled may trigger immediately when defined
Bram Moolenaar <Bram@vim.org>
parents:
31158
diff
changeset
|
4199 /* |
7 | 4200 * Allocate the first window and put an empty buffer in it. |
4201 * Called from main(). | |
667 | 4202 * Return FAIL when something goes wrong (out of memory). |
7 | 4203 */ |
667 | 4204 int |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4205 win_alloc_first(void) |
7 | 4206 { |
675 | 4207 if (win_alloc_firstwin(NULL) == FAIL) |
667 | 4208 return FAIL; |
4209 | |
672 | 4210 first_tabpage = alloc_tabpage(); |
667 | 4211 if (first_tabpage == NULL) |
4212 return FAIL; | |
672 | 4213 curtab = first_tabpage; |
31162
981f7bc781bb
patch 9.0.0915: WinScrolled may trigger immediately when defined
Bram Moolenaar <Bram@vim.org>
parents:
31158
diff
changeset
|
4214 unuse_tabpage(first_tabpage); |
1906 | 4215 |
667 | 4216 return OK; |
4217 } | |
4218 | |
1906 | 4219 /* |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
4220 * 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
|
4221 * 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
|
4222 * 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
|
4223 */ |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
4224 win_T * |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
4225 win_alloc_popup_win(void) |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
4226 { |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
4227 win_T *wp; |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
4228 |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
4229 wp = win_alloc(NULL, TRUE); |
31827
1009c33499e7
patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31437
diff
changeset
|
4230 if (wp == NULL) |
1009c33499e7
patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31437
diff
changeset
|
4231 return NULL; |
1009c33499e7
patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31437
diff
changeset
|
4232 // We need to initialize options with something, using the current |
1009c33499e7
patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31437
diff
changeset
|
4233 // window makes most sense. |
1009c33499e7
patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31437
diff
changeset
|
4234 win_init_some(wp, curwin); |
1009c33499e7
patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31437
diff
changeset
|
4235 |
1009c33499e7
patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31437
diff
changeset
|
4236 RESET_BINDING(wp); |
1009c33499e7
patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31437
diff
changeset
|
4237 new_frame(wp); |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
4238 return wp; |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
4239 } |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
4240 |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
4241 /* |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
4242 * Initialize window "wp" to display buffer "buf". |
1906 | 4243 */ |
4244 void | |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
4245 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
|
4246 { |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
4247 wp->w_buffer = buf; |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
4248 ++buf->b_nwindows; |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
4249 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
|
4250 |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
4251 // 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
|
4252 // win_enter_ext(). |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
4253 VIM_CLEAR(wp->w_localdir); |
1906 | 4254 } |
4255 | |
667 | 4256 /* |
675 | 4257 * Allocate the first window or the first window in a new tab page. |
4258 * 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
|
4259 * When "oldwin" is not NULL copy info from it to the new window. |
667 | 4260 * Return FAIL when something goes wrong (out of memory). |
4261 */ | |
4262 static int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4263 win_alloc_firstwin(win_T *oldwin) |
667 | 4264 { |
1906 | 4265 curwin = win_alloc(NULL, FALSE); |
28289
cdaff4db7760
patch 8.2.4670: memory allocation failures for new tab page not tested
Bram Moolenaar <Bram@vim.org>
parents:
28285
diff
changeset
|
4266 if (curwin == NULL) |
cdaff4db7760
patch 8.2.4670: memory allocation failures for new tab page not tested
Bram Moolenaar <Bram@vim.org>
parents:
28285
diff
changeset
|
4267 return FAIL; |
675 | 4268 if (oldwin == NULL) |
4269 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4270 // 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
|
4271 // initialize from scratch. |
675 | 4272 curbuf = buflist_new(NULL, NULL, 1L, BLN_LISTED); |
4273 if (curwin == NULL || curbuf == NULL) | |
4274 return FAIL; | |
4275 curwin->w_buffer = curbuf; | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2201
diff
changeset
|
4276 #ifdef FEAT_SYN_HL |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2201
diff
changeset
|
4277 curwin->w_s = &(curbuf->b_s); |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2201
diff
changeset
|
4278 #endif |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4279 curbuf->b_nwindows = 1; // there is one window |
675 | 4280 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
|
4281 curwin_init(); // init current window |
675 | 4282 } |
4283 else | |
4284 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4285 // First window in new tab page, initialize it from "oldwin". |
1822 | 4286 win_init(curwin, oldwin, 0); |
675 | 4287 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4288 // We don't want cursor- and scroll-binding in the first window. |
2583 | 4289 RESET_BINDING(curwin); |
675 | 4290 } |
7 | 4291 |
1906 | 4292 new_frame(curwin); |
4293 if (curwin->w_frame == NULL) | |
667 | 4294 return FAIL; |
1906 | 4295 topframe = curwin->w_frame; |
7 | 4296 topframe->fr_width = Columns; |
4297 topframe->fr_height = Rows - p_ch; | |
667 | 4298 |
4299 return OK; | |
4300 } | |
4301 | |
4302 /* | |
1906 | 4303 * Create a frame for window "wp". |
4304 */ | |
4305 static void | |
4306 new_frame(win_T *wp) | |
4307 { | |
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
|
4308 frame_T *frp = ALLOC_CLEAR_ONE(frame_T); |
1906 | 4309 |
4310 wp->w_frame = frp; | |
31827
1009c33499e7
patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31437
diff
changeset
|
4311 if (frp == NULL) |
1009c33499e7
patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31437
diff
changeset
|
4312 return; |
1009c33499e7
patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31437
diff
changeset
|
4313 frp->fr_layout = FR_LEAF; |
1009c33499e7
patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31437
diff
changeset
|
4314 frp->fr_win = wp; |
1906 | 4315 } |
4316 | |
4317 /* | |
667 | 4318 * Initialize the window and frame size to the maximum. |
4319 */ | |
4320 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4321 win_init_size(void) |
667 | 4322 { |
4323 firstwin->w_height = ROWS_AVAIL; | |
30239
91ecee475811
patch 9.0.0455: a few problems with 'splitscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30219
diff
changeset
|
4324 firstwin->w_prev_height = ROWS_AVAIL; |
667 | 4325 topframe->fr_height = ROWS_AVAIL; |
4326 firstwin->w_width = Columns; | |
4327 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
|
4328 } |
672 | 4329 |
4330 /* | |
4331 * Allocate a new tabpage_T and init the values. | |
4332 * Returns NULL when out of memory. | |
4333 */ | |
4334 static tabpage_T * | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4335 alloc_tabpage(void) |
672 | 4336 { |
4337 tabpage_T *tp; | |
4287 | 4338 # ifdef FEAT_GUI |
4339 int i; | |
4340 # endif | |
4341 | |
672 | 4342 |
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
|
4343 tp = ALLOC_CLEAR_ONE(tabpage_T); |
4287 | 4344 if (tp == NULL) |
4345 return NULL; | |
4346 | |
4347 # ifdef FEAT_EVAL | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4348 // init t: variables |
28289
cdaff4db7760
patch 8.2.4670: memory allocation failures for new tab page not tested
Bram Moolenaar <Bram@vim.org>
parents:
28285
diff
changeset
|
4349 tp->tp_vars = dict_alloc_id(aid_newtabpage_tvars); |
4287 | 4350 if (tp->tp_vars == NULL) |
4351 { | |
4352 vim_free(tp); | |
4353 return NULL; | |
4354 } | |
4355 init_var_dict(tp->tp_vars, &tp->tp_winvar, VAR_SCOPE); | |
4356 # endif | |
4357 | |
788 | 4358 # ifdef FEAT_GUI |
4287 | 4359 for (i = 0; i < 3; i++) |
4360 tp->tp_prev_which_scrollbars[i] = -1; | |
788 | 4361 # endif |
672 | 4362 # ifdef FEAT_DIFF |
4287 | 4363 tp->tp_diff_invalid = TRUE; |
672 | 4364 # endif |
4287 | 4365 tp->tp_ch_used = p_ch; |
4366 | |
672 | 4367 return tp; |
4368 } | |
4369 | |
852 | 4370 void |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4371 free_tabpage(tabpage_T *tp) |
672 | 4372 { |
1906 | 4373 int idx; |
4374 | |
672 | 4375 # ifdef FEAT_DIFF |
4376 diff_clear(tp); | |
4377 # endif | |
18763
49b78d6465e5
patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents:
18590
diff
changeset
|
4378 # 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
|
4379 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
|
4380 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
|
4381 #endif |
1906 | 4382 for (idx = 0; idx < SNAP_COUNT; ++idx) |
4383 clear_snapshot(tp, idx); | |
819 | 4384 #ifdef FEAT_EVAL |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4385 vars_clear(&tp->tp_vars->dv_hashtab); // free all t: variables |
4287 | 4386 hash_init(&tp->tp_vars->dv_hashtab); |
4387 unref_var_dict(tp->tp_vars); | |
819 | 4388 #endif |
4401 | 4389 |
21703
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21020
diff
changeset
|
4390 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
|
4391 lastused_tabpage = NULL; |
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21020
diff
changeset
|
4392 |
16427
8c3a1bd270bb
patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents:
16405
diff
changeset
|
4393 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
|
4394 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
|
4395 |
4401 | 4396 #ifdef FEAT_PYTHON |
4397 python_tabpage_free(tp); | |
4398 #endif | |
4399 | |
4400 #ifdef FEAT_PYTHON3 | |
4401 python3_tabpage_free(tp); | |
4402 #endif | |
4403 | |
672 | 4404 vim_free(tp); |
4405 } | |
4406 | |
667 | 4407 /* |
675 | 4408 * Create a new Tab page with one window. |
4409 * It will edit the current buffer, like after ":split". | |
682 | 4410 * When "after" is 0 put it just after the current Tab page. |
4411 * Otherwise put it just before tab page "after". | |
667 | 4412 * Return FAIL or OK. |
4413 */ | |
4414 int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4415 win_new_tabpage(int after) |
667 | 4416 { |
672 | 4417 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
|
4418 tabpage_T *prev_tp = curtab; |
667 | 4419 tabpage_T *newtp; |
682 | 4420 int n; |
667 | 4421 |
27805
afbe86e8b24a
patch 8.2.4428: crash when switching tabpage while in the cmdline window
Bram Moolenaar <Bram@vim.org>
parents:
27752
diff
changeset
|
4422 if (cmdwin_type != 0) |
afbe86e8b24a
patch 8.2.4428: crash when switching tabpage while in the cmdline window
Bram Moolenaar <Bram@vim.org>
parents:
27752
diff
changeset
|
4423 { |
afbe86e8b24a
patch 8.2.4428: crash when switching tabpage while in the cmdline window
Bram Moolenaar <Bram@vim.org>
parents:
27752
diff
changeset
|
4424 emsg(_(e_invalid_in_cmdline_window)); |
afbe86e8b24a
patch 8.2.4428: crash when switching tabpage while in the cmdline window
Bram Moolenaar <Bram@vim.org>
parents:
27752
diff
changeset
|
4425 return FAIL; |
afbe86e8b24a
patch 8.2.4428: crash when switching tabpage while in the cmdline window
Bram Moolenaar <Bram@vim.org>
parents:
27752
diff
changeset
|
4426 } |
31150
bcda71c89776
patch 9.0.0909: error message for layout change does not match action
Bram Moolenaar <Bram@vim.org>
parents:
31146
diff
changeset
|
4427 if (window_layout_locked(CMD_tabnew)) |
31146
f6d4c6a3b41c
patch 9.0.0907: restoring window after WinScrolled may fail
Bram Moolenaar <Bram@vim.org>
parents:
30980
diff
changeset
|
4428 return FAIL; |
27805
afbe86e8b24a
patch 8.2.4428: crash when switching tabpage while in the cmdline window
Bram Moolenaar <Bram@vim.org>
parents:
27752
diff
changeset
|
4429 |
672 | 4430 newtp = alloc_tabpage(); |
667 | 4431 if (newtp == NULL) |
4432 return FAIL; | |
4433 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4434 // Remember the current windows in this Tab page. |
4354 | 4435 if (leave_tabpage(curbuf, TRUE) == FAIL) |
674 | 4436 { |
4437 vim_free(newtp); | |
4438 return FAIL; | |
4439 } | |
672 | 4440 curtab = newtp; |
667 | 4441 |
16427
8c3a1bd270bb
patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents:
16405
diff
changeset
|
4442 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
|
4443 ? 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
|
4444 // Create a new empty window. |
675 | 4445 if (win_alloc_firstwin(tp->tp_curwin) == OK) |
667 | 4446 { |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4447 // Make the new Tab page the new topframe. |
682 | 4448 if (after == 1) |
4449 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4450 // New tab page becomes the first one. |
682 | 4451 newtp->tp_next = first_tabpage; |
4452 first_tabpage = newtp; | |
4453 } | |
4454 else | |
4455 { | |
4456 if (after > 0) | |
4457 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4458 // Put new tab page before tab page "after". |
682 | 4459 n = 2; |
4460 for (tp = first_tabpage; tp->tp_next != NULL | |
4461 && n < after; tp = tp->tp_next) | |
4462 ++n; | |
4463 } | |
4464 newtp->tp_next = tp->tp_next; | |
4465 tp->tp_next = newtp; | |
4466 } | |
19155
013f20a3bc6b
patch 8.2.0137: crash when using win_execute() from a new tab
Bram Moolenaar <Bram@vim.org>
parents:
19143
diff
changeset
|
4467 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
|
4468 |
667 | 4469 win_init_size(); |
685 | 4470 firstwin->w_winrow = tabline_height(); |
30239
91ecee475811
patch 9.0.0455: a few problems with 'splitscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30219
diff
changeset
|
4471 firstwin->w_prev_winrow = firstwin->w_winrow; |
819 | 4472 win_comp_scroll(curwin); |
667 | 4473 |
4474 newtp->tp_topframe = topframe; | |
671 | 4475 last_status(FALSE); |
815 | 4476 |
21727
860cad58f557
patch 8.2.1413: previous tab page not usable from an Ex command
Bram Moolenaar <Bram@vim.org>
parents:
21723
diff
changeset
|
4477 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
|
4478 |
815 | 4479 #if defined(FEAT_GUI) |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4480 // 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
|
4481 // scrollbars. Have to update them anyway. |
1906 | 4482 gui_may_update_scrollbars(); |
815 | 4483 #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
|
4484 #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
|
4485 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
|
4486 #endif |
815 | 4487 |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29702
diff
changeset
|
4488 redraw_all_later(UPD_NOT_VALID); |
9595
0190d5de215f
commit https://github.com/vim/vim/commit/c917da4b3e8801a255dbefea8e4ed19c1c716dd8
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
4489 apply_autocmds(EVENT_WINNEW, NULL, NULL, FALSE, curbuf); |
4354 | 4490 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
|
4491 apply_autocmds(EVENT_TABNEW, NULL, NULL, FALSE, curbuf); |
675 | 4492 apply_autocmds(EVENT_TABENTER, NULL, NULL, FALSE, curbuf); |
667 | 4493 return OK; |
4494 } | |
4495 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4496 // Failed, get back the previous Tab page |
4354 | 4497 enter_tabpage(curtab, curbuf, TRUE, TRUE); |
667 | 4498 return FAIL; |
4499 } | |
4500 | |
4501 /* | |
682 | 4502 * Open a new tab page if ":tab cmd" was used. It will edit the same buffer, |
4503 * like with ":split". | |
4504 * Returns OK if a new tab page was created, FAIL otherwise. | |
4505 */ | |
17789
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17670
diff
changeset
|
4506 static int |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4507 may_open_tabpage(void) |
682 | 4508 { |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22470
diff
changeset
|
4509 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
|
4510 ? postponed_split_tab : cmdmod.cmod_tab; |
1090 | 4511 |
31827
1009c33499e7
patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31437
diff
changeset
|
4512 if (n == 0) |
1009c33499e7
patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31437
diff
changeset
|
4513 return FAIL; |
1009c33499e7
patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31437
diff
changeset
|
4514 |
1009c33499e7
patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31437
diff
changeset
|
4515 cmdmod.cmod_tab = 0; // reset it to avoid doing it twice |
1009c33499e7
patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31437
diff
changeset
|
4516 postponed_split_tab = 0; |
1009c33499e7
patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31437
diff
changeset
|
4517 return win_new_tabpage(n); |
682 | 4518 } |
4519 | |
4520 /* | |
672 | 4521 * Create up to "maxcount" tabpages with empty windows. |
4522 * Returns the number of resulting tab pages. | |
667 | 4523 */ |
672 | 4524 int |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4525 make_tabpages(int maxcount) |
667 | 4526 { |
672 | 4527 int count = maxcount; |
4528 int todo; | |
4529 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4530 // Limit to 'tabpagemax' tabs. |
698 | 4531 if (count > p_tpm) |
4532 count = p_tpm; | |
672 | 4533 |
4534 /* | |
4535 * Don't execute autocommands while creating the tab pages. Must do that | |
4536 * when putting the buffers in the windows. | |
4537 */ | |
1410 | 4538 block_autocmds(); |
672 | 4539 |
4540 for (todo = count - 1; todo > 0; --todo) | |
682 | 4541 if (win_new_tabpage(0) == FAIL) |
667 | 4542 break; |
672 | 4543 |
1410 | 4544 unblock_autocmds(); |
672 | 4545 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4546 // return actual number of tab pages |
672 | 4547 return (count - todo); |
667 | 4548 } |
4549 | |
4550 /* | |
671 | 4551 * Return TRUE when "tpc" points to a valid tab page. |
4552 */ | |
4553 int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4554 valid_tabpage(tabpage_T *tpc) |
671 | 4555 { |
4556 tabpage_T *tp; | |
4557 | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9599
diff
changeset
|
4558 FOR_ALL_TABPAGES(tp) |
671 | 4559 if (tp == tpc) |
4560 return TRUE; | |
4561 return FALSE; | |
4562 } | |
4563 | |
4564 /* | |
11199
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4565 * 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
|
4566 * valid. |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4567 */ |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4568 int |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4569 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
|
4570 { |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4571 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
|
4572 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
|
4573 |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4574 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
|
4575 { |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4576 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
|
4577 { |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4578 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
|
4579 { |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4580 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
|
4581 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
|
4582 } |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4583 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
|
4584 } |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4585 } |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4586 // 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
|
4587 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
|
4588 } |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4589 |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4590 /* |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4591 * 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
|
4592 * 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
|
4593 */ |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4594 void |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4595 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
|
4596 { |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4597 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
|
4598 |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4599 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
|
4600 { |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4601 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
|
4602 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
|
4603 } |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4604 else |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4605 { |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4606 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
|
4607 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
|
4608 ; |
11232
a14090a30a3f
patch 8.0.0502: Coverity complains about possible NULL pointer
Christian Brabandt <cb@256bit.org>
parents:
11207
diff
changeset
|
4609 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
|
4610 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
|
4611 } |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4612 |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4613 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
|
4614 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
|
4615 } |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4616 |
e08ead1d269f
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents:
11193
diff
changeset
|
4617 /* |
671 | 4618 * Find tab page "n" (first one is 1). Returns NULL when not found. |
4619 */ | |
4620 tabpage_T * | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4621 find_tabpage(int n) |
671 | 4622 { |
4623 tabpage_T *tp; | |
4624 int i = 1; | |
4625 | |
16427
8c3a1bd270bb
patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents:
16405
diff
changeset
|
4626 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
|
4627 return curtab; |
8c3a1bd270bb
patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents:
16405
diff
changeset
|
4628 |
671 | 4629 for (tp = first_tabpage; tp != NULL && i != n; tp = tp->tp_next) |
4630 ++i; | |
4631 return tp; | |
4632 } | |
4633 | |
4634 /* | |
685 | 4635 * Get index of tab page "tp". First one has index 1. |
686 | 4636 * When not found returns number of tab pages plus one. |
685 | 4637 */ |
4638 int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4639 tabpage_index(tabpage_T *ftp) |
685 | 4640 { |
4641 int i = 1; | |
4642 tabpage_T *tp; | |
4643 | |
4644 for (tp = first_tabpage; tp != NULL && tp != ftp; tp = tp->tp_next) | |
4645 ++i; | |
4646 return i; | |
4647 } | |
4648 | |
4649 /* | |
674 | 4650 * Prepare for leaving the current tab page. |
4352 | 4651 * When autocommands change "curtab" we don't leave the tab page and return |
674 | 4652 * FAIL. |
4653 * Careful: When OK is returned need to get a new tab page very very soon! | |
667 | 4654 */ |
674 | 4655 static int |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4656 leave_tabpage( |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4657 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
|
4658 // NULL if unknown |
32295
bea4ebf594c6
patch 9.0.1479: small source file problems; outdated list of distrib. files
Bram Moolenaar <Bram@vim.org>
parents:
32216
diff
changeset
|
4659 int trigger_leave_autocmds) |
667 | 4660 { |
674 | 4661 tabpage_T *tp = curtab; |
4662 | |
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
|
4663 #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
|
4664 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
|
4665 #endif |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4666 reset_VIsual_and_resel(); // stop Visual mode |
4354 | 4667 if (trigger_leave_autocmds) |
4668 { | |
4669 if (new_curbuf != curbuf) | |
4670 { | |
4671 apply_autocmds(EVENT_BUFLEAVE, NULL, NULL, FALSE, curbuf); | |
4672 if (curtab != tp) | |
4673 return FAIL; | |
4674 } | |
4675 apply_autocmds(EVENT_WINLEAVE, NULL, NULL, FALSE, curbuf); | |
674 | 4676 if (curtab != tp) |
4677 return FAIL; | |
4354 | 4678 apply_autocmds(EVENT_TABLEAVE, NULL, NULL, FALSE, curbuf); |
4679 if (curtab != tp) | |
4680 return FAIL; | |
4681 } | |
30976
bcda60183c77
patch 9.0.0823: mouse drag test fails
Bram Moolenaar <Bram@vim.org>
parents:
30974
diff
changeset
|
4682 |
30980
eb51299c4bfc
patch 9.0.0825: cannot drag an entry in the tabpage line
Bram Moolenaar <Bram@vim.org>
parents:
30976
diff
changeset
|
4683 reset_dragwin(); |
668 | 4684 #if defined(FEAT_GUI) |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4685 // Remove the scrollbars. They may be added back later. |
668 | 4686 if (gui.in_use) |
4687 gui_remove_scrollbars(); | |
4688 #endif | |
667 | 4689 tp->tp_curwin = curwin; |
671 | 4690 tp->tp_prevwin = prevwin; |
667 | 4691 tp->tp_firstwin = firstwin; |
4692 tp->tp_lastwin = lastwin; | |
668 | 4693 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
|
4694 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
|
4695 tp->tp_old_Columns = Columns; |
667 | 4696 firstwin = NULL; |
4697 lastwin = NULL; | |
674 | 4698 return OK; |
667 | 4699 } |
4700 | |
4701 /* | |
4702 * Start using tab page "tp". | |
675 | 4703 * Only to be used after leave_tabpage() or freeing the current tab page. |
4354 | 4704 * Only trigger *Enter autocommands when trigger_enter_autocmds is TRUE. |
4705 * Only trigger *Leave autocommands when trigger_leave_autocmds is TRUE. | |
667 | 4706 */ |
4707 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4708 enter_tabpage( |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4709 tabpage_T *tp, |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4710 buf_T *old_curbuf UNUSED, |
8368
db2a07b710ed
commit https://github.com/vim/vim/commit/f1d2501ebe33e148886c2914acd33140e20ee222
Christian Brabandt <cb@256bit.org>
parents:
8212
diff
changeset
|
4711 int trigger_enter_autocmds, |
db2a07b710ed
commit https://github.com/vim/vim/commit/f1d2501ebe33e148886c2914acd33140e20ee222
Christian Brabandt <cb@256bit.org>
parents:
8212
diff
changeset
|
4712 int trigger_leave_autocmds) |
667 | 4713 { |
19143
bfcafd1a3e37
patch 8.2.0131: command line is not cleared when switching tabs
Bram Moolenaar <Bram@vim.org>
parents:
18886
diff
changeset
|
4714 int row; |
668 | 4715 int old_off = tp->tp_firstwin->w_winrow; |
870 | 4716 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
|
4717 tabpage_T *last_tab = curtab; |
668 | 4718 |
31162
981f7bc781bb
patch 9.0.0915: WinScrolled may trigger immediately when defined
Bram Moolenaar <Bram@vim.org>
parents:
31158
diff
changeset
|
4719 use_tabpage(tp); |
870 | 4720 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4721 // 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
|
4722 // 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
|
4723 // 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
|
4724 (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
|
4725 | (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
|
4726 | (trigger_leave_autocmds ? WEE_TRIGGER_LEAVE_AUTOCMDS : 0)); |
870 | 4727 prevwin = next_prevwin; |
4728 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4729 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
|
4730 row = win_comp_pos(); // recompute w_winrow for all windows |
672 | 4731 #ifdef FEAT_DIFF |
4732 diff_need_scrollbind = TRUE; | |
4733 #endif | |
668 | 4734 |
29589
150a39f639d9
patch 9.0.0135: comment about tabpage line above the wrong code
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
4735 // Use the stored value of p_ch, so that it can be different for each tab |
150a39f639d9
patch 9.0.0135: comment about tabpage line above the wrong code
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
4736 // page. |
16477
8cc31b1b1d23
patch 8.1.1242: no cmdline redraw when tabpages have different 'cmdheight'
Bram Moolenaar <Bram@vim.org>
parents:
16475
diff
changeset
|
4737 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
|
4738 clear_cmdline = TRUE; |
824 | 4739 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
|
4740 |
bfcafd1a3e37
patch 8.2.0131: command line is not cleared when switching tabs
Bram Moolenaar <Bram@vim.org>
parents:
18886
diff
changeset
|
4741 // 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
|
4742 // 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
|
4743 // check cmdline_row. |
30671
15ac28c12c8f
patch 9.0.0670: no space for command line when there is a tabline
Bram Moolenaar <Bram@vim.org>
parents:
30665
diff
changeset
|
4744 if (row < cmdline_row && cmdline_row <= Rows - p_ch) |
19143
bfcafd1a3e37
patch 8.2.0131: command line is not cleared when switching tabs
Bram Moolenaar <Bram@vim.org>
parents:
18886
diff
changeset
|
4745 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
|
4746 |
30976
bcda60183c77
patch 9.0.0823: mouse drag test fails
Bram Moolenaar <Bram@vim.org>
parents:
30974
diff
changeset
|
4747 // If there was a click in a window, it won't be usable for a following |
bcda60183c77
patch 9.0.0823: mouse drag test fails
Bram Moolenaar <Bram@vim.org>
parents:
30974
diff
changeset
|
4748 // drag. |
30980
eb51299c4bfc
patch 9.0.0825: cannot drag an entry in the tabpage line
Bram Moolenaar <Bram@vim.org>
parents:
30976
diff
changeset
|
4749 reset_dragwin(); |
30976
bcda60183c77
patch 9.0.0823: mouse drag test fails
Bram Moolenaar <Bram@vim.org>
parents:
30974
diff
changeset
|
4750 |
29589
150a39f639d9
patch 9.0.0135: comment about tabpage line above the wrong code
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
4751 // The tabpage line may have appeared or disappeared, may need to resize |
150a39f639d9
patch 9.0.0135: comment about tabpage line above the wrong code
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
4752 // the frames for that. When the Vim window was resized need to update |
150a39f639d9
patch 9.0.0135: comment about tabpage line above the wrong code
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
4753 // frame sizes too. |
685 | 4754 if (curtab->tp_old_Rows != Rows || (old_off != firstwin->w_winrow |
4755 #ifdef FEAT_GUI_TABLINE | |
4756 && !gui_use_tabline() | |
4757 #endif | |
4758 )) | |
668 | 4759 shell_new_rows(); |
26488
06aa56b32df4
patch 8.2.3774: test for command line height fails
Bram Moolenaar <Bram@vim.org>
parents:
26486
diff
changeset
|
4760 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
|
4761 { |
06aa56b32df4
patch 8.2.3774: test for command line height fails
Bram Moolenaar <Bram@vim.org>
parents:
26486
diff
changeset
|
4762 if (starting == 0) |
06aa56b32df4
patch 8.2.3774: test for command line height fails
Bram Moolenaar <Bram@vim.org>
parents:
26486
diff
changeset
|
4763 { |
06aa56b32df4
patch 8.2.3774: test for command line height fails
Bram Moolenaar <Bram@vim.org>
parents:
26486
diff
changeset
|
4764 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
|
4765 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
|
4766 } |
06aa56b32df4
patch 8.2.3774: test for command line height fails
Bram Moolenaar <Bram@vim.org>
parents:
26486
diff
changeset
|
4767 else |
06aa56b32df4
patch 8.2.3774: test for command line height fails
Bram Moolenaar <Bram@vim.org>
parents:
26486
diff
changeset
|
4768 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
|
4769 } |
668 | 4770 |
21703
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21020
diff
changeset
|
4771 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
|
4772 |
668 | 4773 #if defined(FEAT_GUI) |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4774 // 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
|
4775 // scrollbars. Have to update them anyway. |
1906 | 4776 gui_may_update_scrollbars(); |
667 | 4777 #endif |
4778 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4779 // 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
|
4780 // 'columns' have been set correctly. |
4354 | 4781 if (trigger_enter_autocmds) |
3582 | 4782 { |
4783 apply_autocmds(EVENT_TABENTER, NULL, NULL, FALSE, curbuf); | |
4784 if (old_curbuf != curbuf) | |
4785 apply_autocmds(EVENT_BUFENTER, NULL, NULL, FALSE, curbuf); | |
4786 } | |
3413 | 4787 |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29702
diff
changeset
|
4788 redraw_all_later(UPD_NOT_VALID); |
667 | 4789 } |
4790 | |
4791 /* | |
4792 * Go to tab page "n". For ":tab N" and "Ngt". | |
685 | 4793 * When "n" is 9999 go to the last tab page. |
667 | 4794 */ |
4795 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4796 goto_tabpage(int n) |
667 | 4797 { |
16405
840fa633ad64
patch 8.1.1207: some compilers give warning messages
Bram Moolenaar <Bram@vim.org>
parents:
16401
diff
changeset
|
4798 tabpage_T *tp = NULL; // shut up compiler |
682 | 4799 tabpage_T *ttp; |
667 | 4800 int i; |
4801 | |
857 | 4802 if (text_locked()) |
4803 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4804 // 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
|
4805 text_locked_msg(); |
857 | 4806 return; |
4807 } | |
4808 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4809 // If there is only one it can't work. |
675 | 4810 if (first_tabpage->tp_next == NULL) |
4811 { | |
4812 if (n > 1) | |
4813 beep_flush(); | |
4814 return; | |
4815 } | |
4816 | |
667 | 4817 if (n == 0) |
4818 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4819 // No count, go to next tab page, wrap around end. |
674 | 4820 if (curtab->tp_next == NULL) |
667 | 4821 tp = first_tabpage; |
4822 else | |
674 | 4823 tp = curtab->tp_next; |
667 | 4824 } |
682 | 4825 else if (n < 0) |
4826 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4827 // "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
|
4828 // this N times. |
682 | 4829 ttp = curtab; |
4830 for (i = n; i < 0; ++i) | |
4831 { | |
4832 for (tp = first_tabpage; tp->tp_next != ttp && tp->tp_next != NULL; | |
4833 tp = tp->tp_next) | |
4834 ; | |
4835 ttp = tp; | |
4836 } | |
4837 } | |
685 | 4838 else if (n == 9999) |
4839 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4840 // Go to last tab page. |
685 | 4841 for (tp = first_tabpage; tp->tp_next != NULL; tp = tp->tp_next) |
4842 ; | |
4843 } | |
667 | 4844 else |
4845 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4846 // Go to tab page "n". |
685 | 4847 tp = find_tabpage(n); |
671 | 4848 if (tp == NULL) |
4849 { | |
4850 beep_flush(); | |
4851 return; | |
4852 } | |
667 | 4853 } |
4854 | |
4354 | 4855 goto_tabpage_tp(tp, TRUE, TRUE); |
685 | 4856 |
4857 #ifdef FEAT_GUI_TABLINE | |
4858 if (gui_use_tabline()) | |
690 | 4859 gui_mch_set_curtab(tabpage_index(curtab)); |
685 | 4860 #endif |
4861 } | |
4862 | |
4863 /* | |
4864 * Go to tabpage "tp". | |
4354 | 4865 * Only trigger *Enter autocommands when trigger_enter_autocmds is TRUE. |
4866 * Only trigger *Leave autocommands when trigger_leave_autocmds is TRUE. | |
685 | 4867 * Note: doesn't update the GUI tab. |
4868 */ | |
4869 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4870 goto_tabpage_tp( |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4871 tabpage_T *tp, |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4872 int trigger_enter_autocmds, |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4873 int trigger_leave_autocmds) |
685 | 4874 { |
27813
126826449b54
patch 8.2.4432: cannot use settabvar() while the cmdline window is open
Bram Moolenaar <Bram@vim.org>
parents:
27805
diff
changeset
|
4875 if (trigger_enter_autocmds || trigger_leave_autocmds) |
126826449b54
patch 8.2.4432: cannot use settabvar() while the cmdline window is open
Bram Moolenaar <Bram@vim.org>
parents:
27805
diff
changeset
|
4876 CHECK_CMDWIN; |
27805
afbe86e8b24a
patch 8.2.4428: crash when switching tabpage while in the cmdline window
Bram Moolenaar <Bram@vim.org>
parents:
27752
diff
changeset
|
4877 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4878 // 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
|
4879 set_keep_msg(NULL, 0); |
4c6b4298852f
Other solution for GTK not changing the locale.
Bram Moolenaar <bram@vim.org>
parents:
2115
diff
changeset
|
4880 |
30339
b5f67135fcb6
patch 9.0.0505: various problems with 'nosplitscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30300
diff
changeset
|
4881 skip_win_fix_scroll = TRUE; |
4354 | 4882 if (tp != curtab && leave_tabpage(tp->tp_curwin->w_buffer, |
4883 trigger_leave_autocmds) == OK) | |
674 | 4884 { |
4885 if (valid_tabpage(tp)) | |
4354 | 4886 enter_tabpage(tp, curbuf, trigger_enter_autocmds, |
4887 trigger_leave_autocmds); | |
674 | 4888 else |
4354 | 4889 enter_tabpage(curtab, curbuf, trigger_enter_autocmds, |
4890 trigger_leave_autocmds); | |
674 | 4891 } |
30339
b5f67135fcb6
patch 9.0.0505: various problems with 'nosplitscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30300
diff
changeset
|
4892 skip_win_fix_scroll = FALSE; |
667 | 4893 } |
7 | 4894 |
4895 /* | |
21703
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21020
diff
changeset
|
4896 * 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
|
4897 * 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
|
4898 */ |
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21020
diff
changeset
|
4899 int |
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21020
diff
changeset
|
4900 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
|
4901 { |
31827
1009c33499e7
patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31437
diff
changeset
|
4902 if (!valid_tabpage(lastused_tabpage)) |
1009c33499e7
patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31437
diff
changeset
|
4903 return FAIL; |
1009c33499e7
patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31437
diff
changeset
|
4904 |
1009c33499e7
patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31437
diff
changeset
|
4905 goto_tabpage_tp(lastused_tabpage, TRUE, TRUE); |
1009c33499e7
patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31437
diff
changeset
|
4906 return OK; |
21703
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21020
diff
changeset
|
4907 } |
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21020
diff
changeset
|
4908 |
22583b9d4efd
patch 8.2.1401: cannot jump to the last used tabpage
Bram Moolenaar <Bram@vim.org>
parents:
21020
diff
changeset
|
4909 /* |
825 | 4910 * Enter window "wp" in tab page "tp". |
4911 * Also updates the GUI tab. | |
4912 */ | |
4913 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4914 goto_tabpage_win(tabpage_T *tp, win_T *wp) |
825 | 4915 { |
4354 | 4916 goto_tabpage_tp(tp, TRUE, TRUE); |
825 | 4917 if (curtab == tp && win_valid(wp)) |
4918 { | |
4919 win_enter(wp, TRUE); | |
4920 # ifdef FEAT_GUI_TABLINE | |
4921 if (gui_use_tabline()) | |
4922 gui_mch_set_curtab(tabpage_index(curtab)); | |
4923 # endif | |
4924 } | |
4925 } | |
4926 | |
4927 /* | |
6775 | 4928 * Move the current tab page to after tab page "nr". |
682 | 4929 */ |
4930 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4931 tabpage_move(int nr) |
682 | 4932 { |
6775 | 4933 int n = 1; |
4934 tabpage_T *tp, *tp_dst; | |
682 | 4935 |
4936 if (first_tabpage->tp_next == NULL) | |
4937 return; | |
4938 | |
6775 | 4939 for (tp = first_tabpage; tp->tp_next != NULL && n < nr; tp = tp->tp_next) |
4940 ++n; | |
4941 | |
4942 if (tp == curtab || (nr > 0 && tp->tp_next != NULL | |
4943 && tp->tp_next == curtab)) | |
4944 return; | |
4945 | |
4946 tp_dst = tp; | |
4947 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4948 // Remove the current tab page from the list of tab pages. |
682 | 4949 if (curtab == first_tabpage) |
4950 first_tabpage = curtab->tp_next; | |
4951 else | |
4952 { | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9599
diff
changeset
|
4953 FOR_ALL_TABPAGES(tp) |
682 | 4954 if (tp->tp_next == curtab) |
4955 break; | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4956 if (tp == NULL) // "cannot happen" |
682 | 4957 return; |
4958 tp->tp_next = curtab->tp_next; | |
4959 } | |
4960 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4961 // Re-insert it at the specified position. |
6775 | 4962 if (nr <= 0) |
682 | 4963 { |
4964 curtab->tp_next = first_tabpage; | |
4965 first_tabpage = curtab; | |
4966 } | |
4967 else | |
4968 { | |
6775 | 4969 curtab->tp_next = tp_dst->tp_next; |
4970 tp_dst->tp_next = curtab; | |
682 | 4971 } |
4972 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4973 // Need to redraw the tabline. Tab page contents doesn't change. |
682 | 4974 redraw_tabline = TRUE; |
4975 } | |
4976 | |
4977 | |
4978 /* | |
7 | 4979 * Go to another window. |
4980 * When jumping to another buffer, stop Visual mode. Do this before | |
4981 * changing windows so we can yank the selection into the '*' register. | |
4982 * When jumping to another window on the same buffer, adjust its cursor | |
4983 * position to keep the same Visual area. | |
4984 */ | |
4985 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4986 win_goto(win_T *wp) |
7 | 4987 { |
2316
db0ea641e382
Fix: cursor line not properly concealed when moving between windows.
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
4988 #ifdef FEAT_CONCEAL |
db0ea641e382
Fix: cursor line not properly concealed when moving between windows.
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
4989 win_T *owp = curwin; |
db0ea641e382
Fix: cursor line not properly concealed when moving between windows.
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
4990 #endif |
db0ea641e382
Fix: cursor line not properly concealed when moving between windows.
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
4991 |
19166
215793f6b59d
patch 8.2.0142: possible to enter popup window with CTRL-W p
Bram Moolenaar <Bram@vim.org>
parents:
19155
diff
changeset
|
4992 #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
|
4993 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
|
4994 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
|
4995 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
|
4996 { |
26913
d4e61d61afd9
patch 8.2.3985: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26893
diff
changeset
|
4997 emsg(_(e_not_allowed_to_enter_popup_window)); |
19166
215793f6b59d
patch 8.2.0142: possible to enter popup window with CTRL-W p
Bram Moolenaar <Bram@vim.org>
parents:
19155
diff
changeset
|
4998 return; |
215793f6b59d
patch 8.2.0142: possible to enter popup window with CTRL-W p
Bram Moolenaar <Bram@vim.org>
parents:
19155
diff
changeset
|
4999 } |
215793f6b59d
patch 8.2.0142: possible to enter popup window with CTRL-W p
Bram Moolenaar <Bram@vim.org>
parents:
19155
diff
changeset
|
5000 #endif |
29042
e150d0e4701f
patch 8.2.5043: can open a cmdline window from a substitute expression
Bram Moolenaar <Bram@vim.org>
parents:
29026
diff
changeset
|
5001 if (text_or_buf_locked()) |
7 | 5002 { |
5003 beep_flush(); | |
5004 return; | |
5005 } | |
631 | 5006 |
7 | 5007 if (wp->w_buffer != curbuf) |
5008 reset_VIsual_and_resel(); | |
5009 else if (VIsual_active) | |
5010 wp->w_cursor = curwin->w_cursor; | |
5011 | |
5012 #ifdef FEAT_GUI | |
5013 need_mouse_correct = TRUE; | |
5014 #endif | |
5015 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
|
5016 |
db0ea641e382
Fix: cursor line not properly concealed when moving between windows.
Bram Moolenaar <bram@vim.org>
parents:
2314
diff
changeset
|
5017 #ifdef FEAT_CONCEAL |
15436
29f3d59bb6f0
patch 8.1.0726: redrawing specifically for conceal feature
Bram Moolenaar <Bram@vim.org>
parents:
15380
diff
changeset
|
5018 // Conceal cursor line in previous window, unconceal in current window. |
4094 | 5019 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
|
5020 redrawWinline(owp, owp->w_cursor.lnum); |
4094 | 5021 if (curwin->w_p_cole > 0 && !msg_scrolled) |
5022 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
|
5023 #endif |
7 | 5024 } |
5025 | |
25567
0082503ff2ff
patch 8.2.3320: some local functions are not static
Bram Moolenaar <Bram@vim.org>
parents:
25553
diff
changeset
|
5026 #if defined(FEAT_PERL) || defined(PROTO) |
7 | 5027 /* |
5028 * Find window number "winnr" (counting top to bottom). | |
5029 */ | |
5030 win_T * | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5031 win_find_nr(int winnr) |
7 | 5032 { |
5033 win_T *wp; | |
5034 | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9599
diff
changeset
|
5035 FOR_ALL_WINDOWS(wp) |
7 | 5036 if (--winnr == 0) |
5037 break; | |
5038 return wp; | |
5039 } | |
5040 #endif | |
5041 | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
5042 #if ((defined(FEAT_PYTHON) || defined(FEAT_PYTHON3))) || defined(PROTO) |
4429 | 5043 /* |
5044 * Find the tabpage for window "win". | |
5045 */ | |
5046 tabpage_T * | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5047 win_find_tabpage(win_T *win) |
4429 | 5048 { |
5049 win_T *wp; | |
5050 tabpage_T *tp; | |
5051 | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9599
diff
changeset
|
5052 FOR_ALL_TAB_WINDOWS(tp, wp) |
4429 | 5053 if (wp == win) |
5054 return tp; | |
5055 return NULL; | |
5056 } | |
5057 #endif | |
5058 | |
7 | 5059 /* |
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
|
5060 * 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
|
5061 * 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
|
5062 * 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
|
5063 * Returns the specified window if the neighbor is not found. |
7 | 5064 */ |
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
|
5065 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
|
5066 win_vert_neighbor(tabpage_T *tp, win_T *wp, int up, long count) |
7 | 5067 { |
5068 frame_T *fr; | |
5069 frame_T *nfr; | |
5070 frame_T *foundfr; | |
5071 | |
19291
1d6bc6b31c2e
patch 8.2.0204: crash when using winnr('j') in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19275
diff
changeset
|
5072 #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
|
5073 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
|
5074 // 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
|
5075 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
|
5076 #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
|
5077 foundfr = wp->w_frame; |
7 | 5078 while (count--) |
5079 { | |
5080 /* | |
5081 * First go upwards in the tree of frames until we find a upwards or | |
5082 * downwards neighbor. | |
5083 */ | |
5084 fr = foundfr; | |
5085 for (;;) | |
5086 { | |
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
|
5087 if (fr == tp->tp_topframe) |
7 | 5088 goto end; |
5089 if (up) | |
5090 nfr = fr->fr_prev; | |
5091 else | |
5092 nfr = fr->fr_next; | |
5093 if (fr->fr_parent->fr_layout == FR_COL && nfr != NULL) | |
5094 break; | |
5095 fr = fr->fr_parent; | |
5096 } | |
5097 | |
5098 /* | |
5099 * Now go downwards to find the bottom or top frame in it. | |
5100 */ | |
5101 for (;;) | |
5102 { | |
5103 if (nfr->fr_layout == FR_LEAF) | |
5104 { | |
5105 foundfr = nfr; | |
5106 break; | |
5107 } | |
5108 fr = nfr->fr_child; | |
5109 if (nfr->fr_layout == FR_ROW) | |
5110 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5111 // Find the frame at the cursor row. |
7 | 5112 while (fr->fr_next != NULL |
5113 && 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
|
5114 <= wp->w_wincol + wp->w_wcol) |
7 | 5115 fr = fr->fr_next; |
5116 } | |
5117 if (nfr->fr_layout == FR_COL && up) | |
5118 while (fr->fr_next != NULL) | |
5119 fr = fr->fr_next; | |
5120 nfr = fr; | |
5121 } | |
5122 } | |
5123 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
|
5124 return foundfr != NULL ? foundfr->fr_win : NULL; |
7 | 5125 } |
5126 | |
5127 /* | |
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
|
5128 * Move to window above or below "count" times. |
7 | 5129 */ |
5130 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
|
5131 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
|
5132 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
|
5133 long count) |
7 | 5134 { |
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
|
5135 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
|
5136 |
19265
ce8c47ed54e5
patch 8.2.0191: cannot put a terminal in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19166
diff
changeset
|
5137 #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
|
5138 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
|
5139 return; |
ce8c47ed54e5
patch 8.2.0191: cannot put a terminal in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19166
diff
changeset
|
5140 #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
|
5141 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
|
5142 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
|
5143 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
|
5144 } |
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
5145 |
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
5146 /* |
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
5147 * 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
|
5148 * 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
|
5149 * 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
|
5150 * 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
|
5151 */ |
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
5152 win_T * |
16354
b3bc3ba07bef
patch 8.1.1182: some function prototypes are outdated
Bram Moolenaar <Bram@vim.org>
parents:
16271
diff
changeset
|
5153 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
|
5154 { |
7 | 5155 frame_T *fr; |
5156 frame_T *nfr; | |
5157 frame_T *foundfr; | |
5158 | |
19291
1d6bc6b31c2e
patch 8.2.0204: crash when using winnr('j') in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19275
diff
changeset
|
5159 #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
|
5160 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
|
5161 // 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
|
5162 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
|
5163 #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
|
5164 foundfr = wp->w_frame; |
7 | 5165 while (count--) |
5166 { | |
5167 /* | |
5168 * First go upwards in the tree of frames until we find a left or | |
5169 * right neighbor. | |
5170 */ | |
5171 fr = foundfr; | |
5172 for (;;) | |
5173 { | |
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
|
5174 if (fr == tp->tp_topframe) |
7 | 5175 goto end; |
5176 if (left) | |
5177 nfr = fr->fr_prev; | |
5178 else | |
5179 nfr = fr->fr_next; | |
5180 if (fr->fr_parent->fr_layout == FR_ROW && nfr != NULL) | |
5181 break; | |
5182 fr = fr->fr_parent; | |
5183 } | |
5184 | |
5185 /* | |
5186 * Now go downwards to find the leftmost or rightmost frame in it. | |
5187 */ | |
5188 for (;;) | |
5189 { | |
5190 if (nfr->fr_layout == FR_LEAF) | |
5191 { | |
5192 foundfr = nfr; | |
5193 break; | |
5194 } | |
5195 fr = nfr->fr_child; | |
5196 if (nfr->fr_layout == FR_COL) | |
5197 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5198 // Find the frame at the cursor row. |
7 | 5199 while (fr->fr_next != NULL |
5200 && 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
|
5201 <= wp->w_winrow + wp->w_wrow) |
7 | 5202 fr = fr->fr_next; |
5203 } | |
5204 if (nfr->fr_layout == FR_ROW && left) | |
5205 while (fr->fr_next != NULL) | |
5206 fr = fr->fr_next; | |
5207 nfr = fr; | |
5208 } | |
5209 } | |
5210 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
|
5211 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
|
5212 } |
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
5213 |
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
5214 /* |
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
5215 * 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
|
5216 */ |
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
5217 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
|
5218 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
|
5219 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
|
5220 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
|
5221 { |
243cdc183ec9
patch 8.1.1140: not easy to find out what neighbors a window has
Bram Moolenaar <Bram@vim.org>
parents:
16166
diff
changeset
|
5222 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
|
5223 |
19265
ce8c47ed54e5
patch 8.2.0191: cannot put a terminal in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19166
diff
changeset
|
5224 #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
|
5225 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
|
5226 return; |
ce8c47ed54e5
patch 8.2.0191: cannot put a terminal in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19166
diff
changeset
|
5227 #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
|
5228 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
|
5229 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
|
5230 win_goto(win); |
7 | 5231 } |
5232 | |
5233 /* | |
5234 * Make window "wp" the current window. | |
5235 */ | |
5236 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5237 win_enter(win_T *wp, int undo_sync) |
7 | 5238 { |
25501
a1ed55c02e80
patch 8.2.3287: channel events not handled in BufEnter autocommand
Bram Moolenaar <Bram@vim.org>
parents:
25499
diff
changeset
|
5239 (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
|
5240 | WEE_TRIGGER_ENTER_AUTOCMDS | WEE_TRIGGER_LEAVE_AUTOCMDS); |
7 | 5241 } |
5242 | |
5243 /* | |
27032
18cafa092e8d
patch 8.2.4045: some global functions are only used in one file
Bram Moolenaar <Bram@vim.org>
parents:
27028
diff
changeset
|
5244 * Used after making another window the current one: change directory if |
18cafa092e8d
patch 8.2.4045: some global functions are only used in one file
Bram Moolenaar <Bram@vim.org>
parents:
27028
diff
changeset
|
5245 * needed. |
18cafa092e8d
patch 8.2.4045: some global functions are only used in one file
Bram Moolenaar <Bram@vim.org>
parents:
27028
diff
changeset
|
5246 */ |
18cafa092e8d
patch 8.2.4045: some global functions are only used in one file
Bram Moolenaar <Bram@vim.org>
parents:
27028
diff
changeset
|
5247 static void |
18cafa092e8d
patch 8.2.4045: some global functions are only used in one file
Bram Moolenaar <Bram@vim.org>
parents:
27028
diff
changeset
|
5248 fix_current_dir(void) |
18cafa092e8d
patch 8.2.4045: some global functions are only used in one file
Bram Moolenaar <Bram@vim.org>
parents:
27028
diff
changeset
|
5249 { |
18cafa092e8d
patch 8.2.4045: some global functions are only used in one file
Bram Moolenaar <Bram@vim.org>
parents:
27028
diff
changeset
|
5250 if (curwin->w_localdir != NULL || curtab->tp_localdir != NULL) |
18cafa092e8d
patch 8.2.4045: some global functions are only used in one file
Bram Moolenaar <Bram@vim.org>
parents:
27028
diff
changeset
|
5251 { |
18cafa092e8d
patch 8.2.4045: some global functions are only used in one file
Bram Moolenaar <Bram@vim.org>
parents:
27028
diff
changeset
|
5252 char_u *dirname; |
18cafa092e8d
patch 8.2.4045: some global functions are only used in one file
Bram Moolenaar <Bram@vim.org>
parents:
27028
diff
changeset
|
5253 |
18cafa092e8d
patch 8.2.4045: some global functions are only used in one file
Bram Moolenaar <Bram@vim.org>
parents:
27028
diff
changeset
|
5254 // Window or tab has a local directory: Save current directory as |
18cafa092e8d
patch 8.2.4045: some global functions are only used in one file
Bram Moolenaar <Bram@vim.org>
parents:
27028
diff
changeset
|
5255 // global directory (unless that was done already) and change to the |
18cafa092e8d
patch 8.2.4045: some global functions are only used in one file
Bram Moolenaar <Bram@vim.org>
parents:
27028
diff
changeset
|
5256 // local directory. |
18cafa092e8d
patch 8.2.4045: some global functions are only used in one file
Bram Moolenaar <Bram@vim.org>
parents:
27028
diff
changeset
|
5257 if (globaldir == NULL) |
18cafa092e8d
patch 8.2.4045: some global functions are only used in one file
Bram Moolenaar <Bram@vim.org>
parents:
27028
diff
changeset
|
5258 { |
18cafa092e8d
patch 8.2.4045: some global functions are only used in one file
Bram Moolenaar <Bram@vim.org>
parents:
27028
diff
changeset
|
5259 char_u cwd[MAXPATHL]; |
18cafa092e8d
patch 8.2.4045: some global functions are only used in one file
Bram Moolenaar <Bram@vim.org>
parents:
27028
diff
changeset
|
5260 |
18cafa092e8d
patch 8.2.4045: some global functions are only used in one file
Bram Moolenaar <Bram@vim.org>
parents:
27028
diff
changeset
|
5261 if (mch_dirname(cwd, MAXPATHL) == OK) |
18cafa092e8d
patch 8.2.4045: some global functions are only used in one file
Bram Moolenaar <Bram@vim.org>
parents:
27028
diff
changeset
|
5262 globaldir = vim_strsave(cwd); |
18cafa092e8d
patch 8.2.4045: some global functions are only used in one file
Bram Moolenaar <Bram@vim.org>
parents:
27028
diff
changeset
|
5263 } |
18cafa092e8d
patch 8.2.4045: some global functions are only used in one file
Bram Moolenaar <Bram@vim.org>
parents:
27028
diff
changeset
|
5264 if (curwin->w_localdir != NULL) |
18cafa092e8d
patch 8.2.4045: some global functions are only used in one file
Bram Moolenaar <Bram@vim.org>
parents:
27028
diff
changeset
|
5265 dirname = curwin->w_localdir; |
18cafa092e8d
patch 8.2.4045: some global functions are only used in one file
Bram Moolenaar <Bram@vim.org>
parents:
27028
diff
changeset
|
5266 else |
18cafa092e8d
patch 8.2.4045: some global functions are only used in one file
Bram Moolenaar <Bram@vim.org>
parents:
27028
diff
changeset
|
5267 dirname = curtab->tp_localdir; |
18cafa092e8d
patch 8.2.4045: some global functions are only used in one file
Bram Moolenaar <Bram@vim.org>
parents:
27028
diff
changeset
|
5268 |
18cafa092e8d
patch 8.2.4045: some global functions are only used in one file
Bram Moolenaar <Bram@vim.org>
parents:
27028
diff
changeset
|
5269 if (mch_chdir((char *)dirname) == 0) |
18cafa092e8d
patch 8.2.4045: some global functions are only used in one file
Bram Moolenaar <Bram@vim.org>
parents:
27028
diff
changeset
|
5270 { |
18cafa092e8d
patch 8.2.4045: some global functions are only used in one file
Bram Moolenaar <Bram@vim.org>
parents:
27028
diff
changeset
|
5271 last_chdir_reason = NULL; |
18cafa092e8d
patch 8.2.4045: some global functions are only used in one file
Bram Moolenaar <Bram@vim.org>
parents:
27028
diff
changeset
|
5272 shorten_fnames(TRUE); |
18cafa092e8d
patch 8.2.4045: some global functions are only used in one file
Bram Moolenaar <Bram@vim.org>
parents:
27028
diff
changeset
|
5273 } |
18cafa092e8d
patch 8.2.4045: some global functions are only used in one file
Bram Moolenaar <Bram@vim.org>
parents:
27028
diff
changeset
|
5274 } |
18cafa092e8d
patch 8.2.4045: some global functions are only used in one file
Bram Moolenaar <Bram@vim.org>
parents:
27028
diff
changeset
|
5275 else if (globaldir != NULL) |
18cafa092e8d
patch 8.2.4045: some global functions are only used in one file
Bram Moolenaar <Bram@vim.org>
parents:
27028
diff
changeset
|
5276 { |
18cafa092e8d
patch 8.2.4045: some global functions are only used in one file
Bram Moolenaar <Bram@vim.org>
parents:
27028
diff
changeset
|
5277 // Window doesn't have a local directory and we are not in the global |
18cafa092e8d
patch 8.2.4045: some global functions are only used in one file
Bram Moolenaar <Bram@vim.org>
parents:
27028
diff
changeset
|
5278 // directory: Change to the global directory. |
18cafa092e8d
patch 8.2.4045: some global functions are only used in one file
Bram Moolenaar <Bram@vim.org>
parents:
27028
diff
changeset
|
5279 vim_ignored = mch_chdir((char *)globaldir); |
18cafa092e8d
patch 8.2.4045: some global functions are only used in one file
Bram Moolenaar <Bram@vim.org>
parents:
27028
diff
changeset
|
5280 VIM_CLEAR(globaldir); |
18cafa092e8d
patch 8.2.4045: some global functions are only used in one file
Bram Moolenaar <Bram@vim.org>
parents:
27028
diff
changeset
|
5281 last_chdir_reason = NULL; |
18cafa092e8d
patch 8.2.4045: some global functions are only used in one file
Bram Moolenaar <Bram@vim.org>
parents:
27028
diff
changeset
|
5282 shorten_fnames(TRUE); |
18cafa092e8d
patch 8.2.4045: some global functions are only used in one file
Bram Moolenaar <Bram@vim.org>
parents:
27028
diff
changeset
|
5283 } |
18cafa092e8d
patch 8.2.4045: some global functions are only used in one file
Bram Moolenaar <Bram@vim.org>
parents:
27028
diff
changeset
|
5284 } |
18cafa092e8d
patch 8.2.4045: some global functions are only used in one file
Bram Moolenaar <Bram@vim.org>
parents:
27028
diff
changeset
|
5285 |
18cafa092e8d
patch 8.2.4045: some global functions are only used in one file
Bram Moolenaar <Bram@vim.org>
parents:
27028
diff
changeset
|
5286 /* |
25499
5ebf9bb1cbcd
patch 8.2.3286: win_enter_ext() has too many boolean arguments
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
5287 * 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
|
5288 * 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
|
5289 * 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
|
5290 * Returns TRUE when dont_parse_messages was decremented. |
7 | 5291 */ |
25501
a1ed55c02e80
patch 8.2.3287: channel events not handled in BufEnter autocommand
Bram Moolenaar <Bram@vim.org>
parents:
25499
diff
changeset
|
5292 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
|
5293 win_enter_ext(win_T *wp, int flags) |
7 | 5294 { |
5295 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
|
5296 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
|
5297 int did_decrement = FALSE; |
7 | 5298 |
32062
8c9f63a518f5
patch 9.0.1362: ml_get error when going to another tab
Bram Moolenaar <Bram@vim.org>
parents:
32009
diff
changeset
|
5299 if (wp == curwin && curwin_invalid == 0) // 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
|
5300 return FALSE; |
7 | 5301 |
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
|
5302 #ifdef FEAT_JOB_CHANNEL |
32062
8c9f63a518f5
patch 9.0.1362: ml_get error when going to another tab
Bram Moolenaar <Bram@vim.org>
parents:
32009
diff
changeset
|
5303 if (curwin_invalid == 0) |
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
|
5304 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
|
5305 #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
|
5306 |
32062
8c9f63a518f5
patch 9.0.1362: ml_get error when going to another tab
Bram Moolenaar <Bram@vim.org>
parents:
32009
diff
changeset
|
5307 if (curwin_invalid == 0 && (flags & WEE_TRIGGER_LEAVE_AUTOCMDS)) |
7 | 5308 { |
5309 /* | |
5310 * Be careful: If autocommands delete the window, return now. | |
5311 */ | |
5312 if (wp->w_buffer != curbuf) | |
5313 { | |
5314 apply_autocmds(EVENT_BUFLEAVE, NULL, NULL, FALSE, curbuf); | |
5315 other_buffer = TRUE; | |
5316 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
|
5317 return FALSE; |
7 | 5318 } |
5319 apply_autocmds(EVENT_WINLEAVE, NULL, NULL, FALSE, curbuf); | |
5320 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
|
5321 return FALSE; |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13308
diff
changeset
|
5322 #ifdef FEAT_EVAL |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5323 // autocmds may abort script processing |
7 | 5324 if (aborting()) |
25501
a1ed55c02e80
patch 8.2.3287: channel events not handled in BufEnter autocommand
Bram Moolenaar <Bram@vim.org>
parents:
25499
diff
changeset
|
5325 return FALSE; |
7 | 5326 #endif |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13308
diff
changeset
|
5327 } |
7 | 5328 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5329 // 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
|
5330 if ((flags & WEE_UNDO_SYNC) && curbuf != wp->w_buffer) |
825 | 5331 u_sync(FALSE); |
5977 | 5332 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5333 // 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
|
5334 // cursor was moved. |
32062
8c9f63a518f5
patch 9.0.1362: ml_get error when going to another tab
Bram Moolenaar <Bram@vim.org>
parents:
32009
diff
changeset
|
5335 if (*p_spk == 'c' && curwin_invalid == 0) |
30219
bc8ad1c28b51
patch 9.0.0445: when opening/closing window text moves up/down
Bram Moolenaar <Bram@vim.org>
parents:
30134
diff
changeset
|
5336 update_topline(); |
5977 | 5337 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5338 // may have to copy the buffer options when 'cpo' contains 'S' |
7 | 5339 if (wp->w_buffer != curbuf) |
5340 buf_copy_options(wp->w_buffer, BCO_ENTER | BCO_NOHELP); | |
32062
8c9f63a518f5
patch 9.0.1362: ml_get error when going to another tab
Bram Moolenaar <Bram@vim.org>
parents:
32009
diff
changeset
|
5341 if (curwin_invalid == 0) |
7 | 5342 { |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5343 prevwin = curwin; // remember for CTRL-W p |
7 | 5344 curwin->w_redr_status = TRUE; |
5345 } | |
5346 curwin = wp; | |
5347 curbuf = wp->w_buffer; | |
5348 check_cursor(); | |
5349 if (!virtual_active()) | |
5350 curwin->w_cursor.coladd = 0; | |
30624
f2f35161d75a
patch 9.0.0647: the 'splitscroll' option is not a good name
Bram Moolenaar <Bram@vim.org>
parents:
30574
diff
changeset
|
5351 if (*p_spk == 'c') // assume cursor position needs updating |
30219
bc8ad1c28b51
patch 9.0.0445: when opening/closing window text moves up/down
Bram Moolenaar <Bram@vim.org>
parents:
30134
diff
changeset
|
5352 changed_line_abv_curs(); |
bc8ad1c28b51
patch 9.0.0445: when opening/closing window text moves up/down
Bram Moolenaar <Bram@vim.org>
parents:
30134
diff
changeset
|
5353 else |
31960
9460e6b656ca
patch 9.0.1312: Cursor position wrong when splitting window in insert mode
Bram Moolenaar <Bram@vim.org>
parents:
31827
diff
changeset
|
5354 // Make sure the cursor position is valid, either by moving the cursor |
9460e6b656ca
patch 9.0.1312: Cursor position wrong when splitting window in insert mode
Bram Moolenaar <Bram@vim.org>
parents:
31827
diff
changeset
|
5355 // or by scrolling the text. |
9460e6b656ca
patch 9.0.1312: Cursor position wrong when splitting window in insert mode
Bram Moolenaar <Bram@vim.org>
parents:
31827
diff
changeset
|
5356 win_fix_cursor( |
9460e6b656ca
patch 9.0.1312: Cursor position wrong when splitting window in insert mode
Bram Moolenaar <Bram@vim.org>
parents:
31827
diff
changeset
|
5357 get_real_state() & (MODE_NORMAL|MODE_CMDLINE|MODE_TERMINAL)); |
7 | 5358 |
25501
a1ed55c02e80
patch 8.2.3287: channel events not handled in BufEnter autocommand
Bram Moolenaar <Bram@vim.org>
parents:
25499
diff
changeset
|
5359 // 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
|
5360 // autocommands. |
a1ed55c02e80
patch 8.2.3287: channel events not handled in BufEnter autocommand
Bram Moolenaar <Bram@vim.org>
parents:
25499
diff
changeset
|
5361 #ifdef MESSAGE_QUEUE |
a1ed55c02e80
patch 8.2.3287: channel events not handled in BufEnter autocommand
Bram Moolenaar <Bram@vim.org>
parents:
25499
diff
changeset
|
5362 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
|
5363 { |
a1ed55c02e80
patch 8.2.3287: channel events not handled in BufEnter autocommand
Bram Moolenaar <Bram@vim.org>
parents:
25499
diff
changeset
|
5364 --dont_parse_messages; |
a1ed55c02e80
patch 8.2.3287: channel events not handled in BufEnter autocommand
Bram Moolenaar <Bram@vim.org>
parents:
25499
diff
changeset
|
5365 did_decrement = TRUE; |
a1ed55c02e80
patch 8.2.3287: channel events not handled in BufEnter autocommand
Bram Moolenaar <Bram@vim.org>
parents:
25499
diff
changeset
|
5366 } |
a1ed55c02e80
patch 8.2.3287: channel events not handled in BufEnter autocommand
Bram Moolenaar <Bram@vim.org>
parents:
25499
diff
changeset
|
5367 #endif |
a1ed55c02e80
patch 8.2.3287: channel events not handled in BufEnter autocommand
Bram Moolenaar <Bram@vim.org>
parents:
25499
diff
changeset
|
5368 |
26121
2c64a420ce7e
patch 8.2.3593: directory is wrong after executing "lcd" with win_execute()
Bram Moolenaar <Bram@vim.org>
parents:
26117
diff
changeset
|
5369 fix_current_dir(); |
7 | 5370 |
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
|
5371 #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
|
5372 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
|
5373 #endif |
18283
0cb608fc9c60
patch 8.1.2136: using freed memory with autocmd from fuzzer
Bram Moolenaar <Bram@vim.org>
parents:
18255
diff
changeset
|
5374 // 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
|
5375 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
|
5376 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
|
5377 if (flags & WEE_TRIGGER_ENTER_AUTOCMDS) |
4354 | 5378 { |
5379 apply_autocmds(EVENT_WINENTER, NULL, NULL, FALSE, curbuf); | |
5380 if (other_buffer) | |
5381 apply_autocmds(EVENT_BUFENTER, NULL, NULL, FALSE, curbuf); | |
5382 } | |
7 | 5383 |
5384 maketitle(); | |
5385 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
|
5386 #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
|
5387 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
|
5388 // 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
|
5389 redraw_mode = TRUE; |
18255
3f51e026de28
patch 8.1.2122: cannot build without terminal feature
Bram Moolenaar <Bram@vim.org>
parents:
18253
diff
changeset
|
5390 #endif |
672 | 5391 redraw_tabline = TRUE; |
7 | 5392 if (restart_edit) |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29702
diff
changeset
|
5393 redraw_later(UPD_VALID); // causes status line redraw |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5394 |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5395 // 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
|
5396 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
|
5397 #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
|
5398 && !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
|
5399 #endif |
dfd87ef822aa
patch 8.1.1734: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
17225
diff
changeset
|
5400 ) |
7 | 5401 win_setheight((int)p_wh); |
5402 else if (curwin->w_height == 0) | |
5403 win_setheight(1); | |
5404 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5405 // set window width to desired minimal value |
779 | 5406 if (curwin->w_width < p_wiw && !curwin->w_p_wfw) |
7 | 5407 win_setwidth((int)p_wiw); |
5408 | |
18135
1868ec23360e
patch 8.1.2062: the mouse code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
18010
diff
changeset
|
5409 setmouse(); // in case jumped to/from help buffer |
7 | 5410 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5411 // 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
|
5412 DO_AUTOCHDIR; |
25501
a1ed55c02e80
patch 8.2.3287: channel events not handled in BufEnter autocommand
Bram Moolenaar <Bram@vim.org>
parents:
25499
diff
changeset
|
5413 |
a1ed55c02e80
patch 8.2.3287: channel events not handled in BufEnter autocommand
Bram Moolenaar <Bram@vim.org>
parents:
25499
diff
changeset
|
5414 return did_decrement; |
7 | 5415 } |
5416 | |
26121
2c64a420ce7e
patch 8.2.3593: directory is wrong after executing "lcd" with win_execute()
Bram Moolenaar <Bram@vim.org>
parents:
26117
diff
changeset
|
5417 /* |
825 | 5418 * Jump to the first open window that contains buffer "buf", if one exists. |
5419 * Returns a pointer to the window found, otherwise NULL. | |
7 | 5420 */ |
5421 win_T * | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5422 buf_jump_open_win(buf_T *buf) |
7 | 5423 { |
6307 | 5424 win_T *wp = NULL; |
5425 | |
5426 if (curwin->w_buffer == buf) | |
5427 wp = curwin; | |
5428 else | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9599
diff
changeset
|
5429 FOR_ALL_WINDOWS(wp) |
6307 | 5430 if (wp->w_buffer == buf) |
5431 break; | |
7 | 5432 if (wp != NULL) |
5433 win_enter(wp, FALSE); | |
5434 return wp; | |
5435 } | |
825 | 5436 |
5437 /* | |
5438 * Jump to the first open window in any tab page that contains buffer "buf", | |
27873
d1af65b322d0
patch 8.2.4462: not enough testing for quickfix code
Bram Moolenaar <Bram@vim.org>
parents:
27857
diff
changeset
|
5439 * if one exists. First search in the windows present in the current tab page. |
825 | 5440 * Returns a pointer to the window found, otherwise NULL. |
5441 */ | |
5442 win_T * | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5443 buf_jump_open_tab(buf_T *buf) |
825 | 5444 { |
6307 | 5445 win_T *wp = buf_jump_open_win(buf); |
825 | 5446 tabpage_T *tp; |
5447 | |
5448 if (wp != NULL) | |
5449 return wp; | |
5450 | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9599
diff
changeset
|
5451 FOR_ALL_TABPAGES(tp) |
825 | 5452 if (tp != curtab) |
5453 { | |
19888
435726a03481
patch 8.2.0500: using the same loop in many places
Bram Moolenaar <Bram@vim.org>
parents:
19291
diff
changeset
|
5454 FOR_ALL_WINDOWS_IN_TAB(tp, wp) |
825 | 5455 if (wp->w_buffer == buf) |
5456 break; | |
5457 if (wp != NULL) | |
5458 { | |
5459 goto_tabpage_win(tp, wp); | |
5460 if (curwin != wp) | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5461 wp = NULL; // something went wrong |
825 | 5462 break; |
5463 } | |
5464 } | |
5465 return wp; | |
5466 } | |
7 | 5467 |
9223
6c4d610fce0a
commit https://github.com/vim/vim/commit/888ccac8902cee186fbd47e971881f6d9b19c068
Christian Brabandt <cb@256bit.org>
parents:
9102
diff
changeset
|
5468 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
|
5469 |
7 | 5470 /* |
1906 | 5471 * Allocate a window structure and link it in the window list when "hidden" is |
5472 * FALSE. | |
7 | 5473 */ |
5474 static win_T * | |
30624
f2f35161d75a
patch 9.0.0647: the 'splitscroll' option is not a good name
Bram Moolenaar <Bram@vim.org>
parents:
30574
diff
changeset
|
5475 win_alloc(win_T *after, int hidden) |
7 | 5476 { |
3263 | 5477 win_T *new_wp; |
7 | 5478 |
5479 /* | |
5480 * allocate window structure and linesizes arrays | |
5481 */ | |
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
|
5482 new_wp = ALLOC_CLEAR_ONE(win_T); |
4287 | 5483 if (new_wp == NULL) |
5484 return NULL; | |
5485 | |
5486 if (win_alloc_lines(new_wp) == FAIL) | |
3263 | 5487 { |
5488 vim_free(new_wp); | |
4287 | 5489 return NULL; |
5490 } | |
5491 | |
8534
485d4d8a97f6
commit https://github.com/vim/vim/commit/86edef664efccbfe685906c854b9cdd04e56f2d5
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
5492 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
|
5493 |
4287 | 5494 #ifdef FEAT_EVAL |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5495 // init w: variables |
28289
cdaff4db7760
patch 8.2.4670: memory allocation failures for new tab page not tested
Bram Moolenaar <Bram@vim.org>
parents:
28285
diff
changeset
|
5496 new_wp->w_vars = dict_alloc_id(aid_newwin_wvars); |
4287 | 5497 if (new_wp->w_vars == NULL) |
5498 { | |
5499 win_free_lsize(new_wp); | |
5500 vim_free(new_wp); | |
5501 return NULL; | |
5502 } | |
5503 init_var_dict(new_wp->w_vars, &new_wp->w_winvar, VAR_SCOPE); | |
5504 #endif | |
5505 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5506 // 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
|
5507 // 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
|
5508 // event. |
4287 | 5509 block_autocmds(); |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13308
diff
changeset
|
5510 |
4287 | 5511 /* |
5512 * link the window in the window list | |
5513 */ | |
5514 if (!hidden) | |
5515 win_append(after, new_wp); | |
5516 new_wp->w_wincol = 0; | |
5517 new_wp->w_width = Columns; | |
5518 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5519 // position the display and the cursor at the top of the file. |
4287 | 5520 new_wp->w_topline = 1; |
7 | 5521 #ifdef FEAT_DIFF |
4287 | 5522 new_wp->w_topfill = 0; |
5523 #endif | |
5524 new_wp->w_botline = 2; | |
5525 new_wp->w_cursor.lnum = 1; | |
5526 new_wp->w_scbind_pos = 1; | |
5527 | |
15713
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15636
diff
changeset
|
5528 // 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
|
5529 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
|
5530 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
|
5531 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5532 // We won't calculate w_fraction until resizing the window |
4287 | 5533 new_wp->w_fraction = 0; |
5534 new_wp->w_prev_fraction_row = -1; | |
7 | 5535 |
5536 #ifdef FEAT_GUI | |
4287 | 5537 if (gui.in_use) |
5538 { | |
5539 gui_create_scrollbar(&new_wp->w_scrollbars[SBAR_LEFT], | |
5540 SBAR_LEFT, new_wp); | |
5541 gui_create_scrollbar(&new_wp->w_scrollbars[SBAR_RIGHT], | |
5542 SBAR_RIGHT, new_wp); | |
5543 } | |
7 | 5544 #endif |
5545 #ifdef FEAT_FOLDING | |
4287 | 5546 foldInitWin(new_wp); |
7 | 5547 #endif |
4287 | 5548 unblock_autocmds(); |
1326 | 5549 #ifdef FEAT_SEARCH_EXTRA |
30574
66de6909e102
patch 9.0.0622: matchaddpos() can get slow when adding many matches
Bram Moolenaar <Bram@vim.org>
parents:
30535
diff
changeset
|
5550 new_wp->w_next_match_id = 1000; // up to 1000 can be picked by the user |
4287 | 5551 #endif |
3263 | 5552 return new_wp; |
7 | 5553 } |
5554 | |
5555 /* | |
5237
647596ab1ae2
updated for version 7.4a.044
Bram Moolenaar <bram@vim.org>
parents:
5233
diff
changeset
|
5556 * Remove window 'wp' from the window list and free the structure. |
7 | 5557 */ |
5558 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5559 win_free( |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5560 win_T *wp, |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5561 tabpage_T *tp) // tab page "win" is in, NULL for current |
7 | 5562 { |
5563 int i; | |
5237
647596ab1ae2
updated for version 7.4a.044
Bram Moolenaar <bram@vim.org>
parents:
5233
diff
changeset
|
5564 buf_T *buf; |
647596ab1ae2
updated for version 7.4a.044
Bram Moolenaar <bram@vim.org>
parents:
5233
diff
changeset
|
5565 wininfo_T *wip; |
7 | 5566 |
1918 | 5567 #ifdef FEAT_FOLDING |
5568 clearFolding(wp); | |
5569 #endif | |
5570 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5571 // reduce the reference count to the argument list. |
1918 | 5572 alist_unlink(wp->w_alist); |
5573 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5574 // 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
|
5575 // gui_mch_destroy_scrollbar() may trigger a FocusGained event. |
1410 | 5576 block_autocmds(); |
1114 | 5577 |
2320
966a5609669e
Added Lua interfae. (Luis Carvalho)
Bram Moolenaar <bram@vim.org>
parents:
2316
diff
changeset
|
5578 #ifdef FEAT_LUA |
966a5609669e
Added Lua interfae. (Luis Carvalho)
Bram Moolenaar <bram@vim.org>
parents:
2316
diff
changeset
|
5579 lua_window_free(wp); |
966a5609669e
Added Lua interfae. (Luis Carvalho)
Bram Moolenaar <bram@vim.org>
parents:
2316
diff
changeset
|
5580 #endif |
966a5609669e
Added Lua interfae. (Luis Carvalho)
Bram Moolenaar <bram@vim.org>
parents:
2316
diff
changeset
|
5581 |
14 | 5582 #ifdef FEAT_MZSCHEME |
5583 mzscheme_window_free(wp); | |
5584 #endif | |
5585 | |
7 | 5586 #ifdef FEAT_PERL |
5587 perl_win_free(wp); | |
5588 #endif | |
5589 | |
5590 #ifdef FEAT_PYTHON | |
5591 python_window_free(wp); | |
5592 #endif | |
5593 | |
2329
ad2889f48843
Added support for Python 3. (Roland Puntaier)
Bram Moolenaar <bram@vim.org>
parents:
2320
diff
changeset
|
5594 #ifdef FEAT_PYTHON3 |
ad2889f48843
Added support for Python 3. (Roland Puntaier)
Bram Moolenaar <bram@vim.org>
parents:
2320
diff
changeset
|
5595 python3_window_free(wp); |
ad2889f48843
Added support for Python 3. (Roland Puntaier)
Bram Moolenaar <bram@vim.org>
parents:
2320
diff
changeset
|
5596 #endif |
ad2889f48843
Added support for Python 3. (Roland Puntaier)
Bram Moolenaar <bram@vim.org>
parents:
2320
diff
changeset
|
5597 |
7 | 5598 #ifdef FEAT_TCL |
5599 tcl_window_free(wp); | |
5600 #endif | |
5601 | |
5602 #ifdef FEAT_RUBY | |
5603 ruby_window_free(wp); | |
5604 #endif | |
5605 | |
5606 clear_winopt(&wp->w_onebuf_opt); | |
5607 clear_winopt(&wp->w_allbuf_opt); | |
5608 | |
26077
ad90d7eee236
patch 8.2.3572: memory leak when closing window and using "multispace"
Bram Moolenaar <Bram@vim.org>
parents:
25567
diff
changeset
|
5609 vim_free(wp->w_lcs_chars.multispace); |
29090
9b292596a332
patch 8.2.5066: timer_create is not available on every Mac system
Bram Moolenaar <Bram@vim.org>
parents:
29042
diff
changeset
|
5610 vim_free(wp->w_lcs_chars.leadmultispace); |
26077
ad90d7eee236
patch 8.2.3572: memory leak when closing window and using "multispace"
Bram Moolenaar <Bram@vim.org>
parents:
25567
diff
changeset
|
5611 |
7 | 5612 #ifdef FEAT_EVAL |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5613 vars_clear(&wp->w_vars->dv_hashtab); // free all w: variables |
4287 | 5614 hash_init(&wp->w_vars->dv_hashtab); |
5615 unref_var_dict(wp->w_vars); | |
7 | 5616 #endif |
5617 | |
8833
dc10bd23f918
commit https://github.com/vim/vim/commit/3dda7db4e1f7c4a8110a1f83001ec36b46693d27
Christian Brabandt <cb@256bit.org>
parents:
8804
diff
changeset
|
5618 { |
dc10bd23f918
commit https://github.com/vim/vim/commit/3dda7db4e1f7c4a8110a1f83001ec36b46693d27
Christian Brabandt <cb@256bit.org>
parents:
8804
diff
changeset
|
5619 tabpage_T *ttp; |
dc10bd23f918
commit https://github.com/vim/vim/commit/3dda7db4e1f7c4a8110a1f83001ec36b46693d27
Christian Brabandt <cb@256bit.org>
parents:
8804
diff
changeset
|
5620 |
dc10bd23f918
commit https://github.com/vim/vim/commit/3dda7db4e1f7c4a8110a1f83001ec36b46693d27
Christian Brabandt <cb@256bit.org>
parents:
8804
diff
changeset
|
5621 if (prevwin == wp) |
dc10bd23f918
commit https://github.com/vim/vim/commit/3dda7db4e1f7c4a8110a1f83001ec36b46693d27
Christian Brabandt <cb@256bit.org>
parents:
8804
diff
changeset
|
5622 prevwin = NULL; |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9599
diff
changeset
|
5623 FOR_ALL_TABPAGES(ttp) |
8833
dc10bd23f918
commit https://github.com/vim/vim/commit/3dda7db4e1f7c4a8110a1f83001ec36b46693d27
Christian Brabandt <cb@256bit.org>
parents:
8804
diff
changeset
|
5624 if (ttp->tp_prevwin == wp) |
dc10bd23f918
commit https://github.com/vim/vim/commit/3dda7db4e1f7c4a8110a1f83001ec36b46693d27
Christian Brabandt <cb@256bit.org>
parents:
8804
diff
changeset
|
5625 ttp->tp_prevwin = NULL; |
dc10bd23f918
commit https://github.com/vim/vim/commit/3dda7db4e1f7c4a8110a1f83001ec36b46693d27
Christian Brabandt <cb@256bit.org>
parents:
8804
diff
changeset
|
5626 } |
7 | 5627 win_free_lsize(wp); |
5628 | |
5629 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
|
5630 { |
7 | 5631 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
|
5632 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
|
5633 } |
7 | 5634 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
|
5635 vim_free(wp->w_prevdir); |
1326 | 5636 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5637 // 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
|
5638 // 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
|
5639 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
|
5640 FOR_ALL_BUF_WININFO(buf, wip) |
5237
647596ab1ae2
updated for version 7.4a.044
Bram Moolenaar <bram@vim.org>
parents:
5233
diff
changeset
|
5641 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
|
5642 { |
e871a824efc9
patch 8.2.1905: the wininfo list may contain stale entries
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
5643 wininfo_T *wip2; |
e871a824efc9
patch 8.2.1905: the wininfo list may contain stale entries
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
5644 |
e871a824efc9
patch 8.2.1905: the wininfo list may contain stale entries
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
5645 // 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
|
5646 // 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
|
5647 // Skip "wip" itself, otherwise Coverity complains. |
32118
04d9dff67d99
patch 9.0.1390: FOR_ALL_ macros are defined in an unexpected file
Bram Moolenaar <Bram@vim.org>
parents:
32062
diff
changeset
|
5648 FOR_ALL_BUF_WININFO(buf, wip2) |
25157
9a2e7184b604
patch 8.2.3115: Coverity complains about free_wininfo() use
Bram Moolenaar <Bram@vim.org>
parents:
25064
diff
changeset
|
5649 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
|
5650 { |
e871a824efc9
patch 8.2.1905: the wininfo list may contain stale entries
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
5651 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
|
5652 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
|
5653 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
|
5654 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
|
5655 else |
e871a824efc9
patch 8.2.1905: the wininfo list may contain stale entries
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
5656 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
|
5657 free_wininfo(wip2); |
e871a824efc9
patch 8.2.1905: the wininfo list may contain stale entries
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
5658 break; |
e871a824efc9
patch 8.2.1905: the wininfo list may contain stale entries
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
5659 } |
e871a824efc9
patch 8.2.1905: the wininfo list may contain stale entries
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
5660 |
5237
647596ab1ae2
updated for version 7.4a.044
Bram Moolenaar <bram@vim.org>
parents:
5233
diff
changeset
|
5661 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
|
5662 } |
5237
647596ab1ae2
updated for version 7.4a.044
Bram Moolenaar <bram@vim.org>
parents:
5233
diff
changeset
|
5663 |
7 | 5664 #ifdef FEAT_SEARCH_EXTRA |
1326 | 5665 clear_matches(wp); |
5666 #endif | |
5667 | |
7 | 5668 free_jumplist(wp); |
5669 | |
643 | 5670 #ifdef FEAT_QUICKFIX |
5671 qf_free_all(wp); | |
5672 #endif | |
5673 | |
7 | 5674 #ifdef FEAT_GUI |
5675 if (gui.in_use) | |
5676 { | |
5677 gui_mch_destroy_scrollbar(&wp->w_scrollbars[SBAR_LEFT]); | |
5678 gui_mch_destroy_scrollbar(&wp->w_scrollbars[SBAR_RIGHT]); | |
5679 } | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5680 #endif // FEAT_GUI |
7 | 5681 |
12487
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
5682 #ifdef FEAT_MENU |
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
5683 remove_winbar(wp); |
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
5684 #endif |
18763
49b78d6465e5
patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents:
18590
diff
changeset
|
5685 #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
|
5686 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
|
5687 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
|
5688 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
|
5689 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
|
5690 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
|
5691 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
|
5692 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
|
5693 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
|
5694 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
|
5695 #endif |
12487
3f16cf18386c
patch 8.0.1123: cannot define a toolbar for a window
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
5696 |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2201
diff
changeset
|
5697 #ifdef FEAT_SYN_HL |
2314
233eb4412f5d
Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents:
2306
diff
changeset
|
5698 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
|
5699 #endif |
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2201
diff
changeset
|
5700 |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
5701 if (win_valid_any_tab(wp)) |
1918 | 5702 win_remove(wp, tp); |
5958 | 5703 if (autocmd_busy) |
5704 { | |
5705 wp->w_next = au_pending_free_win; | |
5706 au_pending_free_win = wp; | |
5707 } | |
5708 else | |
5709 vim_free(wp); | |
1114 | 5710 |
1410 | 5711 unblock_autocmds(); |
7 | 5712 } |
5713 | |
5714 /* | |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
5715 * 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
|
5716 * popup window. |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
5717 */ |
28167
a52a5e3363c4
patch 8.2.4609: :unhide does not check for failing to close a window
Bram Moolenaar <Bram@vim.org>
parents:
27976
diff
changeset
|
5718 int |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
5719 win_unlisted(win_T *wp) |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
5720 { |
31263
d8e7d725a666
patch 9.0.0965: using one window for executing autocommands is insufficient
Bram Moolenaar <Bram@vim.org>
parents:
31261
diff
changeset
|
5721 return is_aucmd_win(wp) || WIN_IS_POPUP(wp); |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
5722 } |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
5723 |
18763
49b78d6465e5
patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents:
18590
diff
changeset
|
5724 #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
|
5725 /* |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
5726 * 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
|
5727 * 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
|
5728 */ |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
5729 void |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
5730 win_free_popup(win_T *win) |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
5731 { |
28285
a4aad5142959
patch 8.2.4668: buffer allocation failures insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28211
diff
changeset
|
5732 if (win->w_buffer != NULL) |
a4aad5142959
patch 8.2.4668: buffer allocation failures insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28211
diff
changeset
|
5733 { |
a4aad5142959
patch 8.2.4668: buffer allocation failures insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28211
diff
changeset
|
5734 if (bt_popup(win->w_buffer)) |
a4aad5142959
patch 8.2.4668: buffer allocation failures insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28211
diff
changeset
|
5735 win_close_buffer(win, DOBUF_WIPE_REUSE, FALSE); |
a4aad5142959
patch 8.2.4668: buffer allocation failures insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28211
diff
changeset
|
5736 else |
a4aad5142959
patch 8.2.4668: buffer allocation failures insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28211
diff
changeset
|
5737 close_buffer(win, win->w_buffer, 0, FALSE, FALSE); |
a4aad5142959
patch 8.2.4668: buffer allocation failures insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28211
diff
changeset
|
5738 } |
16802
f5487021fdad
patch 8.1.1403: cannot build without the timer feature
Bram Moolenaar <Bram@vim.org>
parents:
16800
diff
changeset
|
5739 # if defined(FEAT_TIMERS) |
30695
b9cc46461994
patch 9.0.0682: crash when popup with deleted timer is closed
Bram Moolenaar <Bram@vim.org>
parents:
30671
diff
changeset
|
5740 // the timer may have been cleared, making the pointer invalid |
b9cc46461994
patch 9.0.0682: crash when popup with deleted timer is closed
Bram Moolenaar <Bram@vim.org>
parents:
30671
diff
changeset
|
5741 if (timer_valid(win->w_popup_timer)) |
16800
12e3a3afdb6a
patch 8.1.1402: "timer" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents:
16796
diff
changeset
|
5742 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
|
5743 # endif |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
5744 vim_free(win->w_frame); |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
5745 win_free(win, NULL); |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
5746 } |
16802
f5487021fdad
patch 8.1.1403: cannot build without the timer feature
Bram Moolenaar <Bram@vim.org>
parents:
16800
diff
changeset
|
5747 #endif |
16778
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
5748 |
eda4d65f232c
patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
5749 /* |
7 | 5750 * Append window "wp" in the window list after window "after". |
5751 */ | |
17789
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17670
diff
changeset
|
5752 static void |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5753 win_append(win_T *after, win_T *wp) |
7 | 5754 { |
5755 win_T *before; | |
5756 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5757 if (after == NULL) // after NULL is in front of the first |
7 | 5758 before = firstwin; |
5759 else | |
5760 before = after->w_next; | |
5761 | |
5762 wp->w_next = before; | |
5763 wp->w_prev = after; | |
5764 if (after == NULL) | |
5765 firstwin = wp; | |
5766 else | |
5767 after->w_next = wp; | |
5768 if (before == NULL) | |
5769 lastwin = wp; | |
5770 else | |
5771 before->w_prev = wp; | |
5772 } | |
5773 | |
5774 /* | |
5775 * Remove a window from the window list. | |
5776 */ | |
1906 | 5777 void |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5778 win_remove( |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5779 win_T *wp, |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5780 tabpage_T *tp) // tab page "win" is in, NULL for current |
7 | 5781 { |
5782 if (wp->w_prev != NULL) | |
5783 wp->w_prev->w_next = wp->w_next; | |
671 | 5784 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
|
5785 firstwin = curtab->tp_firstwin = wp->w_next; |
7 | 5786 else |
671 | 5787 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
|
5788 |
7 | 5789 if (wp->w_next != NULL) |
5790 wp->w_next->w_prev = wp->w_prev; | |
671 | 5791 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
|
5792 lastwin = curtab->tp_lastwin = wp->w_prev; |
7 | 5793 else |
671 | 5794 tp->tp_lastwin = wp->w_prev; |
7 | 5795 } |
5796 | |
5797 /* | |
5798 * Append frame "frp" in a frame list after frame "after". | |
5799 */ | |
5800 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5801 frame_append(frame_T *after, frame_T *frp) |
7 | 5802 { |
5803 frp->fr_next = after->fr_next; | |
5804 after->fr_next = frp; | |
5805 if (frp->fr_next != NULL) | |
5806 frp->fr_next->fr_prev = frp; | |
5807 frp->fr_prev = after; | |
5808 } | |
5809 | |
5810 /* | |
5811 * Insert frame "frp" in a frame list before frame "before". | |
5812 */ | |
5813 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5814 frame_insert(frame_T *before, frame_T *frp) |
7 | 5815 { |
5816 frp->fr_next = before; | |
5817 frp->fr_prev = before->fr_prev; | |
5818 before->fr_prev = frp; | |
5819 if (frp->fr_prev != NULL) | |
5820 frp->fr_prev->fr_next = frp; | |
5821 else | |
5822 frp->fr_parent->fr_child = frp; | |
5823 } | |
5824 | |
5825 /* | |
5826 * Remove a frame from a frame list. | |
5827 */ | |
5828 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5829 frame_remove(frame_T *frp) |
7 | 5830 { |
5831 if (frp->fr_prev != NULL) | |
5832 frp->fr_prev->fr_next = frp->fr_next; | |
5833 else | |
5834 frp->fr_parent->fr_child = frp->fr_next; | |
5835 if (frp->fr_next != NULL) | |
5836 frp->fr_next->fr_prev = frp->fr_prev; | |
5837 } | |
5838 | |
5839 /* | |
5840 * Allocate w_lines[] for window "wp". | |
5841 * Return FAIL for failure, OK for success. | |
5842 */ | |
5843 int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5844 win_alloc_lines(win_T *wp) |
7 | 5845 { |
5846 wp->w_lines_valid = 0; | |
27251
85f56e16da9b
patch 8.2.4154: ml_get error when exchanging windows in Visual mode
Bram Moolenaar <Bram@vim.org>
parents:
27032
diff
changeset
|
5847 wp->w_lines = ALLOC_CLEAR_MULT(wline_T, Rows); |
7 | 5848 if (wp->w_lines == NULL) |
5849 return FAIL; | |
5850 return OK; | |
5851 } | |
5852 | |
5853 /* | |
5854 * free lsize arrays for a window | |
5855 */ | |
5856 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5857 win_free_lsize(win_T *wp) |
7 | 5858 { |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5859 // TODO: why would wp be NULL here? |
5952 | 5860 if (wp != NULL) |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13144
diff
changeset
|
5861 VIM_CLEAR(wp->w_lines); |
7 | 5862 } |
5863 | |
5864 /* | |
5865 * Called from win_new_shellsize() after Rows changed. | |
671 | 5866 * This only does the current tab page, others must be done when made active. |
7 | 5867 */ |
5868 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5869 shell_new_rows(void) |
7 | 5870 { |
26488
06aa56b32df4
patch 8.2.3774: test for command line height fails
Bram Moolenaar <Bram@vim.org>
parents:
26486
diff
changeset
|
5871 int h = (int)ROWS_AVAIL; |
7 | 5872 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5873 if (firstwin == NULL) // not initialized yet |
7 | 5874 return; |
26488
06aa56b32df4
patch 8.2.3774: test for command line height fails
Bram Moolenaar <Bram@vim.org>
parents:
26486
diff
changeset
|
5875 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
|
5876 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
|
5877 |
06aa56b32df4
patch 8.2.3774: test for command line height fails
Bram Moolenaar <Bram@vim.org>
parents:
26486
diff
changeset
|
5878 // 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
|
5879 // 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
|
5880 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
|
5881 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
|
5882 frame_new_height(topframe, h, FALSE, FALSE); |
7 | 5883 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5884 (void)win_comp_pos(); // recompute w_winrow and w_wincol |
7 | 5885 compute_cmdrow(); |
824 | 5886 curtab->tp_ch_used = p_ch; |
170 | 5887 |
30624
f2f35161d75a
patch 9.0.0647: the 'splitscroll' option is not a good name
Bram Moolenaar <Bram@vim.org>
parents:
30574
diff
changeset
|
5888 if (*p_spk != 'c' && !skip_win_fix_scroll) |
30219
bc8ad1c28b51
patch 9.0.0445: when opening/closing window text moves up/down
Bram Moolenaar <Bram@vim.org>
parents:
30134
diff
changeset
|
5889 win_fix_scroll(TRUE); |
bc8ad1c28b51
patch 9.0.0445: when opening/closing window text moves up/down
Bram Moolenaar <Bram@vim.org>
parents:
30134
diff
changeset
|
5890 |
7 | 5891 #if 0 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5892 // Disabled: don't want making the screen smaller make a window larger. |
7 | 5893 if (p_ea) |
5894 win_equal(curwin, FALSE, 'v'); | |
5895 #endif | |
5896 } | |
5897 | |
5898 /* | |
5899 * Called from win_new_shellsize() after Columns changed. | |
5900 */ | |
5901 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5902 shell_new_columns(void) |
7 | 5903 { |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5904 if (firstwin == NULL) // not initialized yet |
7 | 5905 return; |
779 | 5906 |
26488
06aa56b32df4
patch 8.2.3774: test for command line height fails
Bram Moolenaar <Bram@vim.org>
parents:
26486
diff
changeset
|
5907 // 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
|
5908 // 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
|
5909 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
|
5910 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
|
5911 frame_new_width(topframe, (int)Columns, FALSE, FALSE); |
779 | 5912 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5913 (void)win_comp_pos(); // recompute w_winrow and w_wincol |
7 | 5914 #if 0 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5915 // Disabled: don't want making the screen smaller make a window larger. |
7 | 5916 if (p_ea) |
5917 win_equal(curwin, FALSE, 'h'); | |
5918 #endif | |
5919 } | |
5920 | |
5921 /* | |
5922 * Save the size of all windows in "gap". | |
5923 */ | |
5924 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5925 win_size_save(garray_T *gap) |
7 | 5926 |
5927 { | |
5928 win_T *wp; | |
5929 | |
27028
c9474ae175f4
patch 8.2.4043: using int for second argument of ga_init2()
Bram Moolenaar <Bram@vim.org>
parents:
26962
diff
changeset
|
5930 ga_init2(gap, sizeof(int), 1); |
31827
1009c33499e7
patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31437
diff
changeset
|
5931 if (ga_grow(gap, win_count() * 2 + 1) == FAIL) |
1009c33499e7
patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31437
diff
changeset
|
5932 return; |
1009c33499e7
patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31437
diff
changeset
|
5933 |
1009c33499e7
patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31437
diff
changeset
|
5934 // first entry is value of 'lines' |
1009c33499e7
patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31437
diff
changeset
|
5935 ((int *)gap->ga_data)[gap->ga_len++] = Rows; |
1009c33499e7
patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31437
diff
changeset
|
5936 |
1009c33499e7
patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31437
diff
changeset
|
5937 FOR_ALL_WINDOWS(wp) |
1009c33499e7
patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31437
diff
changeset
|
5938 { |
1009c33499e7
patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31437
diff
changeset
|
5939 ((int *)gap->ga_data)[gap->ga_len++] = |
1009c33499e7
patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31437
diff
changeset
|
5940 wp->w_width + wp->w_vsep_width; |
1009c33499e7
patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31437
diff
changeset
|
5941 ((int *)gap->ga_data)[gap->ga_len++] = wp->w_height; |
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
|
5942 } |
7 | 5943 } |
5944 | |
5945 /* | |
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
|
5946 * 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
|
5947 * and 'lines' didn't change. |
7 | 5948 * Does not free the growarray. |
5949 */ | |
5950 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5951 win_size_restore(garray_T *gap) |
7 | 5952 { |
5953 win_T *wp; | |
6058 | 5954 int i, j; |
7 | 5955 |
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
|
5956 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
|
5957 && ((int *)gap->ga_data)[0] == Rows) |
7 | 5958 { |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5959 // 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
|
5960 // difficult to get right. The easy way out is to do it twice. |
6058 | 5961 for (j = 0; j < 2; ++j) |
7 | 5962 { |
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
|
5963 i = 1; |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9599
diff
changeset
|
5964 FOR_ALL_WINDOWS(wp) |
6058 | 5965 { |
5966 frame_setwidth(wp->w_frame, ((int *)gap->ga_data)[i++]); | |
5967 win_setheight_win(((int *)gap->ga_data)[i++], wp); | |
5968 } | |
7 | 5969 } |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5970 // recompute the window positions |
7 | 5971 (void)win_comp_pos(); |
5972 } | |
5973 } | |
5974 | |
5975 /* | |
5976 * Update the position for all windows, using the width and height of the | |
5977 * frames. | |
5978 * Returns the row just after the last window. | |
5979 */ | |
668 | 5980 int |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5981 win_comp_pos(void) |
7 | 5982 { |
685 | 5983 int row = tabline_height(); |
7 | 5984 int col = 0; |
5985 | |
5986 frame_comp_pos(topframe, &row, &col); | |
5987 return row; | |
5988 } | |
5989 | |
5990 /* | |
5991 * Update the position of the windows in frame "topfrp", using the width and | |
5992 * height of the frames. | |
5993 * "*row" and "*col" are the top-left position of the frame. They are updated | |
5994 * to the bottom-right position plus one. | |
5995 */ | |
5996 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5997 frame_comp_pos(frame_T *topfrp, int *row, int *col) |
7 | 5998 { |
5999 win_T *wp; | |
6000 frame_T *frp; | |
6001 int startcol; | |
6002 int startrow; | |
12998
dd734ee3e2fe
patch 8.0.1375: window size wrong after maximizing with WinBar
Christian Brabandt <cb@256bit.org>
parents:
12916
diff
changeset
|
6003 int h; |
7 | 6004 |
6005 wp = topfrp->fr_win; | |
6006 if (wp != NULL) | |
6007 { | |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8536
diff
changeset
|
6008 if (wp->w_winrow != *row || wp->w_wincol != *col) |
7 | 6009 { |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6010 // position changed, redraw |
7 | 6011 wp->w_winrow = *row; |
6012 wp->w_wincol = *col; | |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29702
diff
changeset
|
6013 redraw_win_later(wp, UPD_NOT_VALID); |
7 | 6014 wp->w_redr_status = TRUE; |
6015 } | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6016 // 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
|
6017 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
|
6018 *row += h > topfrp->fr_height ? topfrp->fr_height : h; |
7 | 6019 *col += wp->w_width + wp->w_vsep_width; |
6020 } | |
6021 else | |
6022 { | |
6023 startrow = *row; | |
6024 startcol = *col; | |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
6025 FOR_ALL_FRAMES(frp, topfrp->fr_child) |
7 | 6026 { |
6027 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
|
6028 *row = startrow; // all frames are at the same row |
7 | 6029 else |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6030 *col = startcol; // all frames are at the same col |
7 | 6031 frame_comp_pos(frp, row, col); |
6032 } | |
6033 } | |
6034 } | |
6035 | |
6036 /* | |
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
|
6037 * 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
|
6038 */ |
2fc13817b100
patch 8.2.3764: cannot see any text when window was made zero lines
Bram Moolenaar <Bram@vim.org>
parents:
26458
diff
changeset
|
6039 void |
32009
4545f58c8490
patch 9.0.1336: functions without arguments are not always declared properly
Bram Moolenaar <Bram@vim.org>
parents:
31960
diff
changeset
|
6040 win_ensure_size(void) |
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
|
6041 { |
2fc13817b100
patch 8.2.3764: cannot see any text when window was made zero lines
Bram Moolenaar <Bram@vim.org>
parents:
26458
diff
changeset
|
6042 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
|
6043 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
|
6044 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
|
6045 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
|
6046 } |
2fc13817b100
patch 8.2.3764: cannot see any text when window was made zero lines
Bram Moolenaar <Bram@vim.org>
parents:
26458
diff
changeset
|
6047 |
2fc13817b100
patch 8.2.3764: cannot see any text when window was made zero lines
Bram Moolenaar <Bram@vim.org>
parents:
26458
diff
changeset
|
6048 /* |
7 | 6049 * Set current window height and take care of repositioning other windows to |
6050 * fit around it. | |
6051 */ | |
6052 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6053 win_setheight(int height) |
7 | 6054 { |
6055 win_setheight_win(height, curwin); | |
6056 } | |
6057 | |
6058 /* | |
6059 * Set the window height of window "win" and take care of repositioning other | |
6060 * windows to fit around it. | |
6061 */ | |
6062 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6063 win_setheight_win(int height, win_T *win) |
7 | 6064 { |
6065 int row; | |
6066 | |
6067 if (win == curwin) | |
6068 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6069 // 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
|
6070 // 'winminheight' is zero. |
7 | 6071 if (height < p_wmh) |
6072 height = p_wmh; | |
6073 if (height == 0) | |
6074 height = 1; | |
12998
dd734ee3e2fe
patch 8.0.1375: window size wrong after maximizing with WinBar
Christian Brabandt <cb@256bit.org>
parents:
12916
diff
changeset
|
6075 height += WINBAR_HEIGHT(curwin); |
7 | 6076 } |
6077 | |
6078 frame_setheight(win->w_frame, height + win->w_status_height); | |
6079 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6080 // recompute the window positions |
7 | 6081 row = win_comp_pos(); |
6082 | |
6083 /* | |
6084 * If there is extra space created between the last window and the command | |
6085 * line, clear it. | |
6086 */ | |
6087 if (full_screen && msg_scrolled == 0 && row < cmdline_row) | |
6088 screen_fill(row, cmdline_row, 0, (int)Columns, ' ', ' ', 0); | |
6089 cmdline_row = row; | |
6090 msg_row = row; | |
6091 msg_col = 0; | |
6092 | |
30624
f2f35161d75a
patch 9.0.0647: the 'splitscroll' option is not a good name
Bram Moolenaar <Bram@vim.org>
parents:
30574
diff
changeset
|
6093 if (*p_spk != 'c') |
30219
bc8ad1c28b51
patch 9.0.0445: when opening/closing window text moves up/down
Bram Moolenaar <Bram@vim.org>
parents:
30134
diff
changeset
|
6094 win_fix_scroll(TRUE); |
bc8ad1c28b51
patch 9.0.0445: when opening/closing window text moves up/down
Bram Moolenaar <Bram@vim.org>
parents:
30134
diff
changeset
|
6095 |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29702
diff
changeset
|
6096 redraw_all_later(UPD_NOT_VALID); |
7 | 6097 } |
6098 | |
6099 /* | |
6100 * Set the height of a frame to "height" and take care that all frames and | |
6101 * windows inside it are resized. Also resize frames on the left and right if | |
6102 * the are in the same FR_ROW frame. | |
6103 * | |
6104 * Strategy: | |
6105 * If the frame is part of a FR_COL frame, try fitting the frame in that | |
6106 * frame. If that doesn't work (the FR_COL frame is too small), recursively | |
6107 * go to containing frames to resize them and make room. | |
6108 * If the frame is part of a FR_ROW frame, all frames must be resized as well. | |
6109 * Check for the minimal height of the FR_ROW frame. | |
6110 * At the top level we can also use change the command line height. | |
6111 */ | |
6112 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6113 frame_setheight(frame_T *curfrp, int height) |
7 | 6114 { |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6115 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
|
6116 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
|
6117 int room_cmdline; // lines available from cmdline |
7 | 6118 int run; |
6119 frame_T *frp; | |
6120 int h; | |
6121 int room_reserved; | |
6122 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6123 // If the height already is the desired value, nothing to do. |
7 | 6124 if (curfrp->fr_height == height) |
6125 return; | |
6126 | |
6127 if (curfrp->fr_parent == NULL) | |
6128 { | |
29700
cc0f638f5f6b
patch 9.0.0190: the way 'cmdheight' can be made zero is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
29694
diff
changeset
|
6129 // topframe: can only change the command line height |
667 | 6130 if (height > ROWS_AVAIL) |
29976
b6b71499d9af
patch 9.0.0326: some changes for cmdheight=0 are not needed
Bram Moolenaar <Bram@vim.org>
parents:
29932
diff
changeset
|
6131 height = ROWS_AVAIL; |
7 | 6132 if (height > 0) |
6133 frame_new_height(curfrp, height, FALSE, FALSE); | |
6134 } | |
6135 else if (curfrp->fr_parent->fr_layout == FR_ROW) | |
6136 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6137 // 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
|
6138 // one. First check for the minimal height of these. |
7 | 6139 h = frame_minheight(curfrp->fr_parent, NULL); |
6140 if (height < h) | |
6141 height = h; | |
6142 frame_setheight(curfrp->fr_parent, height); | |
6143 } | |
6144 else | |
6145 { | |
6146 /* | |
6147 * Column of frames: try to change only frames in this column. | |
6148 */ | |
6149 /* | |
6150 * Do this twice: | |
6151 * 1: compute room available, if it's not enough try resizing the | |
6152 * containing frame. | |
6153 * 2: compute the room available and adjust the height to it. | |
6154 * Try not to reduce the height of a window with 'winfixheight' set. | |
6155 */ | |
6156 for (run = 1; run <= 2; ++run) | |
6157 { | |
6158 room = 0; | |
6159 room_reserved = 0; | |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
6160 FOR_ALL_FRAMES(frp, curfrp->fr_parent->fr_child) |
7 | 6161 { |
6162 if (frp != curfrp | |
6163 && frp->fr_win != NULL | |
6164 && frp->fr_win->w_p_wfh) | |
6165 room_reserved += frp->fr_height; | |
6166 room += frp->fr_height; | |
6167 if (frp != curfrp) | |
6168 room -= frame_minheight(frp, NULL); | |
6169 } | |
6170 if (curfrp->fr_width != Columns) | |
6171 room_cmdline = 0; | |
6172 else | |
6173 { | |
6174 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
|
6175 + VISIBLE_HEIGHT(lastwin) |
dd734ee3e2fe
patch 8.0.1375: window size wrong after maximizing with WinBar
Christian Brabandt <cb@256bit.org>
parents:
12916
diff
changeset
|
6176 + lastwin->w_status_height); |
7 | 6177 if (room_cmdline < 0) |
6178 room_cmdline = 0; | |
6179 } | |
6180 | |
6181 if (height <= room + room_cmdline) | |
6182 break; | |
6183 if (run == 2 || curfrp->fr_width == Columns) | |
6184 { | |
28169
bef82285dda0
patch 8.2.4610: some conditions are always true
Bram Moolenaar <Bram@vim.org>
parents:
28167
diff
changeset
|
6185 height = room + room_cmdline; |
7 | 6186 break; |
6187 } | |
6188 frame_setheight(curfrp->fr_parent, height | |
6189 + frame_minheight(curfrp->fr_parent, NOWIN) - (int)p_wmh - 1); | |
6190 } | |
6191 | |
6192 /* | |
6193 * Compute the number of lines we will take from others frames (can be | |
6194 * negative!). | |
6195 */ | |
6196 take = height - curfrp->fr_height; | |
6197 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6198 // 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
|
6199 // with 'winfixheight' set. |
7 | 6200 if (height > room + room_cmdline - room_reserved) |
6201 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
|
6202 // 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
|
6203 // window smaller, need to make the other window taller. |
7 | 6204 if (take < 0 && room - curfrp->fr_height < room_reserved) |
6205 room_reserved = 0; | |
6206 | |
6207 if (take > 0 && room_cmdline > 0) | |
6208 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6209 // use lines from cmdline first |
7 | 6210 if (take < room_cmdline) |
6211 room_cmdline = take; | |
6212 take -= room_cmdline; | |
6213 topframe->fr_height += room_cmdline; | |
6214 } | |
6215 | |
6216 /* | |
6217 * set the current frame to the new height | |
6218 */ | |
6219 frame_new_height(curfrp, height, FALSE, FALSE); | |
6220 | |
6221 /* | |
6222 * First take lines from the frames after the current frame. If | |
6223 * that is not enough, takes lines from frames above the current | |
6224 * frame. | |
6225 */ | |
6226 for (run = 0; run < 2; ++run) | |
6227 { | |
6228 if (run == 0) | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6229 frp = curfrp->fr_next; // 1st run: start with next window |
7 | 6230 else |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6231 frp = curfrp->fr_prev; // 2nd run: start with prev window |
7 | 6232 while (frp != NULL && take != 0) |
6233 { | |
6234 h = frame_minheight(frp, NULL); | |
6235 if (room_reserved > 0 | |
6236 && frp->fr_win != NULL | |
6237 && frp->fr_win->w_p_wfh) | |
6238 { | |
6239 if (room_reserved >= frp->fr_height) | |
6240 room_reserved -= frp->fr_height; | |
6241 else | |
6242 { | |
6243 if (frp->fr_height - room_reserved > take) | |
6244 room_reserved = frp->fr_height - take; | |
6245 take -= frp->fr_height - room_reserved; | |
6246 frame_new_height(frp, room_reserved, FALSE, FALSE); | |
6247 room_reserved = 0; | |
6248 } | |
6249 } | |
6250 else | |
6251 { | |
6252 if (frp->fr_height - take < h) | |
6253 { | |
6254 take -= frp->fr_height - h; | |
6255 frame_new_height(frp, h, FALSE, FALSE); | |
6256 } | |
6257 else | |
6258 { | |
6259 frame_new_height(frp, frp->fr_height - take, | |
6260 FALSE, FALSE); | |
6261 take = 0; | |
6262 } | |
6263 } | |
6264 if (run == 0) | |
6265 frp = frp->fr_next; | |
6266 else | |
6267 frp = frp->fr_prev; | |
6268 } | |
6269 } | |
6270 } | |
6271 } | |
6272 | |
6273 /* | |
6274 * Set current window width and take care of repositioning other windows to | |
6275 * fit around it. | |
6276 */ | |
6277 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6278 win_setwidth(int width) |
7 | 6279 { |
6280 win_setwidth_win(width, curwin); | |
6281 } | |
6282 | |
6283 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6284 win_setwidth_win(int width, win_T *wp) |
7 | 6285 { |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6286 // 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
|
6287 // 'winminwidth' is zero. |
7 | 6288 if (wp == curwin) |
6289 { | |
6290 if (width < p_wmw) | |
6291 width = p_wmw; | |
6292 if (width == 0) | |
6293 width = 1; | |
6294 } | |
23402
65718283239b
patch 8.2.2244: crash when making the window width negative
Bram Moolenaar <Bram@vim.org>
parents:
23386
diff
changeset
|
6295 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
|
6296 width = 0; |
7 | 6297 |
6298 frame_setwidth(wp->w_frame, width + wp->w_vsep_width); | |
6299 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6300 // recompute the window positions |
7 | 6301 (void)win_comp_pos(); |
6302 | |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29702
diff
changeset
|
6303 redraw_all_later(UPD_NOT_VALID); |
7 | 6304 } |
6305 | |
6306 /* | |
6307 * Set the width of a frame to "width" and take care that all frames and | |
6308 * windows inside it are resized. Also resize frames above and below if the | |
6309 * are in the same FR_ROW frame. | |
6310 * | |
6311 * Strategy is similar to frame_setheight(). | |
6312 */ | |
6313 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6314 frame_setwidth(frame_T *curfrp, int width) |
7 | 6315 { |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6316 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
|
6317 int take; // number of lines taken from other windows |
7 | 6318 int run; |
6319 frame_T *frp; | |
6320 int w; | |
779 | 6321 int room_reserved; |
7 | 6322 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6323 // If the width already is the desired value, nothing to do. |
7 | 6324 if (curfrp->fr_width == width) |
6325 return; | |
6326 | |
6327 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
|
6328 // topframe: can't change width |
7 | 6329 return; |
6330 | |
6331 if (curfrp->fr_parent->fr_layout == FR_COL) | |
6332 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6333 // 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
|
6334 // this one. First check for the minimal width of these. |
7 | 6335 w = frame_minwidth(curfrp->fr_parent, NULL); |
6336 if (width < w) | |
6337 width = w; | |
6338 frame_setwidth(curfrp->fr_parent, width); | |
6339 } | |
6340 else | |
6341 { | |
6342 /* | |
6343 * Row of frames: try to change only frames in this row. | |
6344 * | |
6345 * Do this twice: | |
6346 * 1: compute room available, if it's not enough try resizing the | |
6347 * containing frame. | |
6348 * 2: compute the room available and adjust the width to it. | |
6349 */ | |
6350 for (run = 1; run <= 2; ++run) | |
6351 { | |
6352 room = 0; | |
779 | 6353 room_reserved = 0; |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
6354 FOR_ALL_FRAMES(frp, curfrp->fr_parent->fr_child) |
7 | 6355 { |
779 | 6356 if (frp != curfrp |
6357 && frp->fr_win != NULL | |
6358 && frp->fr_win->w_p_wfw) | |
6359 room_reserved += frp->fr_width; | |
7 | 6360 room += frp->fr_width; |
6361 if (frp != curfrp) | |
6362 room -= frame_minwidth(frp, NULL); | |
6363 } | |
6364 | |
6365 if (width <= room) | |
6366 break; | |
667 | 6367 if (run == 2 || curfrp->fr_height >= ROWS_AVAIL) |
7 | 6368 { |
28169
bef82285dda0
patch 8.2.4610: some conditions are always true
Bram Moolenaar <Bram@vim.org>
parents:
28167
diff
changeset
|
6369 width = room; |
7 | 6370 break; |
6371 } | |
6372 frame_setwidth(curfrp->fr_parent, width | |
6373 + frame_minwidth(curfrp->fr_parent, NOWIN) - (int)p_wmw - 1); | |
6374 } | |
6375 | |
6376 /* | |
6377 * Compute the number of lines we will take from others frames (can be | |
6378 * negative!). | |
6379 */ | |
6380 take = width - curfrp->fr_width; | |
6381 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6382 // 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
|
6383 // with 'winfixwidth' set. |
779 | 6384 if (width > room - room_reserved) |
6385 room_reserved = room - width; | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6386 // 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
|
6387 // window smaller, need to make the other window narrower. |
779 | 6388 if (take < 0 && room - curfrp->fr_width < room_reserved) |
6389 room_reserved = 0; | |
6390 | |
7 | 6391 /* |
6392 * set the current frame to the new width | |
6393 */ | |
779 | 6394 frame_new_width(curfrp, width, FALSE, FALSE); |
7 | 6395 |
6396 /* | |
6397 * First take lines from the frames right of the current frame. If | |
6398 * that is not enough, takes lines from frames left of the current | |
6399 * frame. | |
6400 */ | |
6401 for (run = 0; run < 2; ++run) | |
6402 { | |
6403 if (run == 0) | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6404 frp = curfrp->fr_next; // 1st run: start with next window |
7 | 6405 else |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6406 frp = curfrp->fr_prev; // 2nd run: start with prev window |
7 | 6407 while (frp != NULL && take != 0) |
6408 { | |
6409 w = frame_minwidth(frp, NULL); | |
779 | 6410 if (room_reserved > 0 |
6411 && frp->fr_win != NULL | |
6412 && frp->fr_win->w_p_wfw) | |
7 | 6413 { |
779 | 6414 if (room_reserved >= frp->fr_width) |
6415 room_reserved -= frp->fr_width; | |
6416 else | |
6417 { | |
6418 if (frp->fr_width - room_reserved > take) | |
6419 room_reserved = frp->fr_width - take; | |
6420 take -= frp->fr_width - room_reserved; | |
6421 frame_new_width(frp, room_reserved, FALSE, FALSE); | |
6422 room_reserved = 0; | |
6423 } | |
7 | 6424 } |
6425 else | |
6426 { | |
779 | 6427 if (frp->fr_width - take < w) |
6428 { | |
6429 take -= frp->fr_width - w; | |
6430 frame_new_width(frp, w, FALSE, FALSE); | |
6431 } | |
6432 else | |
6433 { | |
6434 frame_new_width(frp, frp->fr_width - take, | |
6435 FALSE, FALSE); | |
6436 take = 0; | |
6437 } | |
7 | 6438 } |
6439 if (run == 0) | |
6440 frp = frp->fr_next; | |
6441 else | |
6442 frp = frp->fr_prev; | |
6443 } | |
6444 } | |
6445 } | |
6446 } | |
6447 | |
6448 /* | |
14057
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
6449 * Check 'winminheight' for a valid value and reduce it if needed. |
7 | 6450 */ |
6451 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6452 win_setminheight(void) |
7 | 6453 { |
6454 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
|
6455 int needed; |
7 | 6456 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
|
6457 |
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
6458 // loop until there is a 'winminheight' that is possible |
7 | 6459 while (p_wmh > 0) |
6460 { | |
24108
0a5eba7e6660
patch 8.2.2595: setting 'winminheight' may cause 'lines' to change
Bram Moolenaar <Bram@vim.org>
parents:
24037
diff
changeset
|
6461 room = Rows - p_ch; |
30005
bb0e525e1393
patch 9.0.0340: the 'cmdheight' zero support causes too much trouble
Bram Moolenaar <Bram@vim.org>
parents:
29976
diff
changeset
|
6462 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
|
6463 if (room >= needed) |
7 | 6464 break; |
6465 --p_wmh; | |
6466 if (first) | |
6467 { | |
25306
078edc1821bf
patch 8.2.3190: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
25157
diff
changeset
|
6468 emsg(_(e_not_enough_room)); |
7 | 6469 first = FALSE; |
6470 } | |
6471 } | |
6472 } | |
6473 | |
14057
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
6474 /* |
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
6475 * 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
|
6476 */ |
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
6477 void |
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
6478 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
|
6479 { |
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
6480 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
|
6481 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
|
6482 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
|
6483 |
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
6484 // 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
|
6485 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
|
6486 { |
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
6487 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
|
6488 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
|
6489 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
|
6490 break; |
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
6491 --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
|
6492 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
|
6493 { |
25306
078edc1821bf
patch 8.2.3190: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
25157
diff
changeset
|
6494 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
|
6495 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
|
6496 } |
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
6497 } |
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
6498 } |
be8fb2fd51fc
patch 8.1.0046: loading a session file fails if 'winheight' is big
Christian Brabandt <cb@256bit.org>
parents:
14049
diff
changeset
|
6499 |
7 | 6500 /* |
6501 * Status line of dragwin is dragged "offset" lines down (negative is up). | |
6502 */ | |
6503 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6504 win_drag_status_line(win_T *dragwin, int offset) |
7 | 6505 { |
6506 frame_T *curfr; | |
6507 frame_T *fr; | |
6508 int room; | |
6509 int row; | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6510 int up; // if TRUE, drag status line up, otherwise down |
7 | 6511 int n; |
6512 | |
6513 fr = dragwin->w_frame; | |
6514 curfr = fr; | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6515 if (fr != topframe) // more than one window |
7 | 6516 { |
6517 fr = fr->fr_parent; | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6518 // 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
|
6519 // be. |
7 | 6520 if (fr->fr_layout != FR_COL) |
6521 { | |
6522 curfr = fr; | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6523 if (fr != topframe) // only a row of windows, may drag statusline |
7 | 6524 fr = fr->fr_parent; |
6525 } | |
6526 } | |
6527 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6528 // 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
|
6529 // frame instead (go two up to skip a row of frames). |
7 | 6530 while (curfr != topframe && curfr->fr_next == NULL) |
6531 { | |
6532 if (fr != topframe) | |
6533 fr = fr->fr_parent; | |
6534 curfr = fr; | |
6535 if (fr != topframe) | |
6536 fr = fr->fr_parent; | |
6537 } | |
6538 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6539 if (offset < 0) // drag up |
7 | 6540 { |
6541 up = TRUE; | |
6542 offset = -offset; | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6543 // sum up the room of the current frame and above it |
7 | 6544 if (fr == curfr) |
6545 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6546 // only one window |
7 | 6547 room = fr->fr_height - frame_minheight(fr, NULL); |
6548 } | |
6549 else | |
6550 { | |
6551 room = 0; | |
6552 for (fr = fr->fr_child; ; fr = fr->fr_next) | |
6553 { | |
6554 room += fr->fr_height - frame_minheight(fr, NULL); | |
6555 if (fr == curfr) | |
6556 break; | |
6557 } | |
6558 } | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6559 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
|
6560 } |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6561 else // drag down |
7 | 6562 { |
6563 up = FALSE; | |
6564 /* | |
6565 * Only dragging the last status line can reduce p_ch. | |
6566 */ | |
6567 room = Rows - cmdline_row; | |
30005
bb0e525e1393
patch 9.0.0340: the 'cmdheight' zero support causes too much trouble
Bram Moolenaar <Bram@vim.org>
parents:
29976
diff
changeset
|
6568 if (curfr->fr_next == NULL) |
bb0e525e1393
patch 9.0.0340: the 'cmdheight' zero support causes too much trouble
Bram Moolenaar <Bram@vim.org>
parents:
29976
diff
changeset
|
6569 --room; |
bb0e525e1393
patch 9.0.0340: the 'cmdheight' zero support causes too much trouble
Bram Moolenaar <Bram@vim.org>
parents:
29976
diff
changeset
|
6570 else |
7 | 6571 room -= p_ch; |
6572 if (room < 0) | |
6573 room = 0; | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6574 // 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
|
6575 FOR_ALL_FRAMES(fr, curfr->fr_next) |
7 | 6576 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
|
6577 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
|
6578 } |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6579 |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6580 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
|
6581 offset = room; // Move as far as we can |
7 | 6582 if (offset <= 0) |
6583 return; | |
6584 | |
6585 /* | |
6586 * Grow frame fr by "offset" lines. | |
6587 * Doesn't happen when dragging the last status line up. | |
6588 */ | |
6589 if (fr != NULL) | |
6590 frame_new_height(fr, fr->fr_height + offset, up, FALSE); | |
6591 | |
6592 if (up) | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6593 fr = curfr; // current frame gets smaller |
7 | 6594 else |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6595 fr = curfr->fr_next; // next frame gets smaller |
7 | 6596 |
6597 /* | |
6598 * Now make the other frames smaller. | |
6599 */ | |
6600 while (fr != NULL && offset > 0) | |
6601 { | |
6602 n = frame_minheight(fr, NULL); | |
6603 if (fr->fr_height - offset <= n) | |
6604 { | |
6605 offset -= fr->fr_height - n; | |
6606 frame_new_height(fr, n, !up, FALSE); | |
6607 } | |
6608 else | |
6609 { | |
6610 frame_new_height(fr, fr->fr_height - offset, !up, FALSE); | |
6611 break; | |
6612 } | |
6613 if (up) | |
6614 fr = fr->fr_prev; | |
6615 else | |
6616 fr = fr->fr_next; | |
6617 } | |
6618 row = win_comp_pos(); | |
6619 screen_fill(row, cmdline_row, 0, (int)Columns, ' ', ' ', 0); | |
6620 cmdline_row = row; | |
30005
bb0e525e1393
patch 9.0.0340: the 'cmdheight' zero support causes too much trouble
Bram Moolenaar <Bram@vim.org>
parents:
29976
diff
changeset
|
6621 p_ch = MAX(Rows - cmdline_row, 1); |
824 | 6622 curtab->tp_ch_used = p_ch; |
30005
bb0e525e1393
patch 9.0.0340: the 'cmdheight' zero support causes too much trouble
Bram Moolenaar <Bram@vim.org>
parents:
29976
diff
changeset
|
6623 |
30624
f2f35161d75a
patch 9.0.0647: the 'splitscroll' option is not a good name
Bram Moolenaar <Bram@vim.org>
parents:
30574
diff
changeset
|
6624 if (*p_spk != 'c') |
30219
bc8ad1c28b51
patch 9.0.0445: when opening/closing window text moves up/down
Bram Moolenaar <Bram@vim.org>
parents:
30134
diff
changeset
|
6625 win_fix_scroll(TRUE); |
bc8ad1c28b51
patch 9.0.0445: when opening/closing window text moves up/down
Bram Moolenaar <Bram@vim.org>
parents:
30134
diff
changeset
|
6626 |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29702
diff
changeset
|
6627 redraw_all_later(UPD_SOME_VALID); |
7 | 6628 showmode(); |
6629 } | |
6630 | |
6631 /* | |
6632 * Separator line of dragwin is dragged "offset" lines right (negative is left). | |
6633 */ | |
6634 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6635 win_drag_vsep_line(win_T *dragwin, int offset) |
7 | 6636 { |
6637 frame_T *curfr; | |
6638 frame_T *fr; | |
6639 int room; | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6640 int left; // if TRUE, drag separator line left, otherwise right |
7 | 6641 int n; |
6642 | |
6643 fr = dragwin->w_frame; | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6644 if (fr == topframe) // only one window (cannot happen?) |
7 | 6645 return; |
6646 curfr = fr; | |
6647 fr = fr->fr_parent; | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6648 // When the parent frame is not a row of frames, its parent should be. |
7 | 6649 if (fr->fr_layout != FR_ROW) |
6650 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6651 if (fr == topframe) // only a column of windows (cannot happen?) |
7 | 6652 return; |
6653 curfr = fr; | |
6654 fr = fr->fr_parent; | |
6655 } | |
6656 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6657 // 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
|
6658 // frame instead. |
7 | 6659 while (curfr->fr_next == NULL) |
6660 { | |
6661 if (fr == topframe) | |
6662 break; | |
6663 curfr = fr; | |
6664 fr = fr->fr_parent; | |
6665 if (fr != topframe) | |
6666 { | |
6667 curfr = fr; | |
6668 fr = fr->fr_parent; | |
6669 } | |
6670 } | |
6671 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6672 if (offset < 0) // drag left |
7 | 6673 { |
6674 left = TRUE; | |
6675 offset = -offset; | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6676 // sum up the room of the current frame and left of it |
7 | 6677 room = 0; |
6678 for (fr = fr->fr_child; ; fr = fr->fr_next) | |
6679 { | |
6680 room += fr->fr_width - frame_minwidth(fr, NULL); | |
6681 if (fr == curfr) | |
6682 break; | |
6683 } | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6684 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
|
6685 } |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6686 else // drag right |
7 | 6687 { |
6688 left = FALSE; | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6689 // sum up the room of frames right of the current one |
7 | 6690 room = 0; |
15227
95678f27a704
patch 8.1.0623: iterating through window frames is repeated
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
6691 FOR_ALL_FRAMES(fr, curfr->fr_next) |
7 | 6692 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
|
6693 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
|
6694 } |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6695 |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6696 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
|
6697 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
|
6698 if (offset <= 0) // No room at all, quit. |
7 | 6699 return; |
7256
79270eaac6de
commit https://github.com/vim/vim/commit/294a7e55b01149154807a23323038784549b8946
Christian Brabandt <cb@256bit.org>
parents:
7229
diff
changeset
|
6700 if (fr == NULL) |
27440
1118a65c9bc7
patch 8.2.4248: no proper test for moving the window separator
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
6701 // This can happen when calling win_move_separator() on the rightmost |
1118a65c9bc7
patch 8.2.4248: no proper test for moving the window separator
Bram Moolenaar <Bram@vim.org>
parents:
27426
diff
changeset
|
6702 // window. Just don't do anything. |
30825
c7983f593fa7
patch 9.0.0747: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
30695
diff
changeset
|
6703 return; |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6704 |
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6705 // grow frame fr by offset lines |
779 | 6706 frame_new_width(fr, fr->fr_width + offset, left, FALSE); |
7 | 6707 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6708 // shrink other frames: current and at the left or at the right |
7 | 6709 if (left) |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6710 fr = curfr; // current frame gets smaller |
7 | 6711 else |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6712 fr = curfr->fr_next; // next frame gets smaller |
7 | 6713 |
6714 while (fr != NULL && offset > 0) | |
6715 { | |
6716 n = frame_minwidth(fr, NULL); | |
6717 if (fr->fr_width - offset <= n) | |
6718 { | |
6719 offset -= fr->fr_width - n; | |
779 | 6720 frame_new_width(fr, n, !left, FALSE); |
7 | 6721 } |
6722 else | |
6723 { | |
779 | 6724 frame_new_width(fr, fr->fr_width - offset, !left, FALSE); |
7 | 6725 break; |
6726 } | |
6727 if (left) | |
6728 fr = fr->fr_prev; | |
6729 else | |
6730 fr = fr->fr_next; | |
6731 } | |
6732 (void)win_comp_pos(); | |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29702
diff
changeset
|
6733 redraw_all_later(UPD_NOT_VALID); |
7 | 6734 } |
6735 | |
2665 | 6736 #define FRACTION_MULT 16384L |
6737 | |
6738 /* | |
6739 * 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
|
6740 * Has no effect when the window is less than two lines. |
2665 | 6741 */ |
7311
743c258ca3ab
commit https://github.com/vim/vim/commit/9dc2ce398bb3456cc8f590ef0260459798b34d2a
Christian Brabandt <cb@256bit.org>
parents:
7256
diff
changeset
|
6742 void |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6743 set_fraction(win_T *wp) |
2665 | 6744 { |
12910
d21adefd4a50
patch 8.0.1331: possible crash when window can be zero lines high
Christian Brabandt <cb@256bit.org>
parents:
12716
diff
changeset
|
6745 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
|
6746 // 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
|
6747 // 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
|
6748 // 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
|
6749 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
|
6750 + FRACTION_MULT / 2) / (long)wp->w_height; |
2665 | 6751 } |
6752 | |
7 | 6753 /* |
30624
f2f35161d75a
patch 9.0.0647: the 'splitscroll' option is not a good name
Bram Moolenaar <Bram@vim.org>
parents:
30574
diff
changeset
|
6754 * Handle scroll position for 'splitkeep'. Replaces scroll_to_fraction() |
30219
bc8ad1c28b51
patch 9.0.0445: when opening/closing window text moves up/down
Bram Moolenaar <Bram@vim.org>
parents:
30134
diff
changeset
|
6755 * call from win_new_height(). Instead we iterate over all windows in a |
30535
04df44c52d65
patch 9.0.0603: with 'nosplitscroll' folds are not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
30525
diff
changeset
|
6756 * tabpage and calculate the new scroll position. |
30219
bc8ad1c28b51
patch 9.0.0445: when opening/closing window text moves up/down
Bram Moolenaar <Bram@vim.org>
parents:
30134
diff
changeset
|
6757 * TODO: Ensure this also works with wrapped lines. |
bc8ad1c28b51
patch 9.0.0445: when opening/closing window text moves up/down
Bram Moolenaar <Bram@vim.org>
parents:
30134
diff
changeset
|
6758 * Requires topline to be able to be set to a bufferline with some |
bc8ad1c28b51
patch 9.0.0445: when opening/closing window text moves up/down
Bram Moolenaar <Bram@vim.org>
parents:
30134
diff
changeset
|
6759 * offset(row-wise scrolling/smoothscroll). |
bc8ad1c28b51
patch 9.0.0445: when opening/closing window text moves up/down
Bram Moolenaar <Bram@vim.org>
parents:
30134
diff
changeset
|
6760 */ |
bc8ad1c28b51
patch 9.0.0445: when opening/closing window text moves up/down
Bram Moolenaar <Bram@vim.org>
parents:
30134
diff
changeset
|
6761 static void |
bc8ad1c28b51
patch 9.0.0445: when opening/closing window text moves up/down
Bram Moolenaar <Bram@vim.org>
parents:
30134
diff
changeset
|
6762 win_fix_scroll(int resize) |
bc8ad1c28b51
patch 9.0.0445: when opening/closing window text moves up/down
Bram Moolenaar <Bram@vim.org>
parents:
30134
diff
changeset
|
6763 { |
30535
04df44c52d65
patch 9.0.0603: with 'nosplitscroll' folds are not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
30525
diff
changeset
|
6764 int diff; |
04df44c52d65
patch 9.0.0603: with 'nosplitscroll' folds are not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
30525
diff
changeset
|
6765 win_T *wp; |
04df44c52d65
patch 9.0.0603: with 'nosplitscroll' folds are not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
30525
diff
changeset
|
6766 linenr_T lnum; |
30219
bc8ad1c28b51
patch 9.0.0445: when opening/closing window text moves up/down
Bram Moolenaar <Bram@vim.org>
parents:
30134
diff
changeset
|
6767 |
30624
f2f35161d75a
patch 9.0.0647: the 'splitscroll' option is not a good name
Bram Moolenaar <Bram@vim.org>
parents:
30574
diff
changeset
|
6768 skip_update_topline = TRUE; |
30219
bc8ad1c28b51
patch 9.0.0445: when opening/closing window text moves up/down
Bram Moolenaar <Bram@vim.org>
parents:
30134
diff
changeset
|
6769 FOR_ALL_WINDOWS(wp) |
bc8ad1c28b51
patch 9.0.0445: when opening/closing window text moves up/down
Bram Moolenaar <Bram@vim.org>
parents:
30134
diff
changeset
|
6770 { |
30339
b5f67135fcb6
patch 9.0.0505: various problems with 'nosplitscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30300
diff
changeset
|
6771 // Skip when window height has not changed. |
30300
b9d07900b0b8
patch 9.0.0486: text scrolled with 'nosplitscroll', autocmd win and help
Bram Moolenaar <Bram@vim.org>
parents:
30285
diff
changeset
|
6772 if (wp->w_height != wp->w_prev_height) |
30219
bc8ad1c28b51
patch 9.0.0445: when opening/closing window text moves up/down
Bram Moolenaar <Bram@vim.org>
parents:
30134
diff
changeset
|
6773 { |
30535
04df44c52d65
patch 9.0.0603: with 'nosplitscroll' folds are not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
30525
diff
changeset
|
6774 // If window has moved update botline to keep the same screenlines. |
30665
fe0a18141c3c
patch 9.0.0667: ml_get error when 'splitkeep' is "screen"
Bram Moolenaar <Bram@vim.org>
parents:
30661
diff
changeset
|
6775 if (*p_spk == 's' && wp->w_winrow != wp->w_prev_winrow |
fe0a18141c3c
patch 9.0.0667: ml_get error when 'splitkeep' is "screen"
Bram Moolenaar <Bram@vim.org>
parents:
30661
diff
changeset
|
6776 && wp->w_botline - 1 <= wp->w_buffer->b_ml.ml_line_count) |
30219
bc8ad1c28b51
patch 9.0.0445: when opening/closing window text moves up/down
Bram Moolenaar <Bram@vim.org>
parents:
30134
diff
changeset
|
6777 { |
bc8ad1c28b51
patch 9.0.0445: when opening/closing window text moves up/down
Bram Moolenaar <Bram@vim.org>
parents:
30134
diff
changeset
|
6778 lnum = wp->w_cursor.lnum; |
30535
04df44c52d65
patch 9.0.0603: with 'nosplitscroll' folds are not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
30525
diff
changeset
|
6779 diff = (wp->w_winrow - wp->w_prev_winrow) |
04df44c52d65
patch 9.0.0603: with 'nosplitscroll' folds are not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
30525
diff
changeset
|
6780 + (wp->w_height - wp->w_prev_height); |
04df44c52d65
patch 9.0.0603: with 'nosplitscroll' folds are not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
30525
diff
changeset
|
6781 wp->w_cursor.lnum = wp->w_botline - 1; |
04df44c52d65
patch 9.0.0603: with 'nosplitscroll' folds are not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
30525
diff
changeset
|
6782 // Add difference in height and row to botline. |
04df44c52d65
patch 9.0.0603: with 'nosplitscroll' folds are not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
30525
diff
changeset
|
6783 if (diff > 0) |
04df44c52d65
patch 9.0.0603: with 'nosplitscroll' folds are not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
30525
diff
changeset
|
6784 cursor_down_inner(wp, diff); |
04df44c52d65
patch 9.0.0603: with 'nosplitscroll' folds are not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
30525
diff
changeset
|
6785 else |
04df44c52d65
patch 9.0.0603: with 'nosplitscroll' folds are not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
30525
diff
changeset
|
6786 cursor_up_inner(wp, -diff); |
30219
bc8ad1c28b51
patch 9.0.0445: when opening/closing window text moves up/down
Bram Moolenaar <Bram@vim.org>
parents:
30134
diff
changeset
|
6787 // Bring the new cursor position to the bottom of the screen. |
bc8ad1c28b51
patch 9.0.0445: when opening/closing window text moves up/down
Bram Moolenaar <Bram@vim.org>
parents:
30134
diff
changeset
|
6788 wp->w_fraction = FRACTION_MULT; |
bc8ad1c28b51
patch 9.0.0445: when opening/closing window text moves up/down
Bram Moolenaar <Bram@vim.org>
parents:
30134
diff
changeset
|
6789 scroll_to_fraction(wp, wp->w_prev_height); |
bc8ad1c28b51
patch 9.0.0445: when opening/closing window text moves up/down
Bram Moolenaar <Bram@vim.org>
parents:
30134
diff
changeset
|
6790 wp->w_cursor.lnum = lnum; |
bc8ad1c28b51
patch 9.0.0445: when opening/closing window text moves up/down
Bram Moolenaar <Bram@vim.org>
parents:
30134
diff
changeset
|
6791 } |
30439
e3091fc473a1
patch 9.0.0555: scrolling with 'nosplitscroll' in callback changing curwin
Bram Moolenaar <Bram@vim.org>
parents:
30429
diff
changeset
|
6792 else if (wp == curwin) |
e3091fc473a1
patch 9.0.0555: scrolling with 'nosplitscroll' in callback changing curwin
Bram Moolenaar <Bram@vim.org>
parents:
30429
diff
changeset
|
6793 wp->w_valid &= ~VALID_CROW; |
30219
bc8ad1c28b51
patch 9.0.0445: when opening/closing window text moves up/down
Bram Moolenaar <Bram@vim.org>
parents:
30134
diff
changeset
|
6794 invalidate_botline_win(wp); |
bc8ad1c28b51
patch 9.0.0445: when opening/closing window text moves up/down
Bram Moolenaar <Bram@vim.org>
parents:
30134
diff
changeset
|
6795 validate_botline_win(wp); |
bc8ad1c28b51
patch 9.0.0445: when opening/closing window text moves up/down
Bram Moolenaar <Bram@vim.org>
parents:
30134
diff
changeset
|
6796 } |
bc8ad1c28b51
patch 9.0.0445: when opening/closing window text moves up/down
Bram Moolenaar <Bram@vim.org>
parents:
30134
diff
changeset
|
6797 wp->w_prev_height = wp->w_height; |
bc8ad1c28b51
patch 9.0.0445: when opening/closing window text moves up/down
Bram Moolenaar <Bram@vim.org>
parents:
30134
diff
changeset
|
6798 wp->w_prev_winrow = wp->w_winrow; |
bc8ad1c28b51
patch 9.0.0445: when opening/closing window text moves up/down
Bram Moolenaar <Bram@vim.org>
parents:
30134
diff
changeset
|
6799 } |
30339
b5f67135fcb6
patch 9.0.0505: various problems with 'nosplitscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30300
diff
changeset
|
6800 skip_update_topline = FALSE; |
30219
bc8ad1c28b51
patch 9.0.0445: when opening/closing window text moves up/down
Bram Moolenaar <Bram@vim.org>
parents:
30134
diff
changeset
|
6801 // Ensure cursor is valid when not in normal mode or when resized. |
30339
b5f67135fcb6
patch 9.0.0505: various problems with 'nosplitscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30300
diff
changeset
|
6802 if (!(get_real_state() & (MODE_NORMAL|MODE_CMDLINE|MODE_TERMINAL))) |
30219
bc8ad1c28b51
patch 9.0.0445: when opening/closing window text moves up/down
Bram Moolenaar <Bram@vim.org>
parents:
30134
diff
changeset
|
6803 win_fix_cursor(FALSE); |
bc8ad1c28b51
patch 9.0.0445: when opening/closing window text moves up/down
Bram Moolenaar <Bram@vim.org>
parents:
30134
diff
changeset
|
6804 else if (resize) |
bc8ad1c28b51
patch 9.0.0445: when opening/closing window text moves up/down
Bram Moolenaar <Bram@vim.org>
parents:
30134
diff
changeset
|
6805 win_fix_cursor(TRUE); |
bc8ad1c28b51
patch 9.0.0445: when opening/closing window text moves up/down
Bram Moolenaar <Bram@vim.org>
parents:
30134
diff
changeset
|
6806 } |
bc8ad1c28b51
patch 9.0.0445: when opening/closing window text moves up/down
Bram Moolenaar <Bram@vim.org>
parents:
30134
diff
changeset
|
6807 |
bc8ad1c28b51
patch 9.0.0445: when opening/closing window text moves up/down
Bram Moolenaar <Bram@vim.org>
parents:
30134
diff
changeset
|
6808 /* |
30624
f2f35161d75a
patch 9.0.0647: the 'splitscroll' option is not a good name
Bram Moolenaar <Bram@vim.org>
parents:
30574
diff
changeset
|
6809 * Make sure the cursor position is valid for 'splitkeep'. |
30219
bc8ad1c28b51
patch 9.0.0445: when opening/closing window text moves up/down
Bram Moolenaar <Bram@vim.org>
parents:
30134
diff
changeset
|
6810 * If it is not, put the cursor position in the jumplist and move it. |
31960
9460e6b656ca
patch 9.0.1312: Cursor position wrong when splitting window in insert mode
Bram Moolenaar <Bram@vim.org>
parents:
31827
diff
changeset
|
6811 * If we are not in normal mode ("normal" is zero), make it valid by scrolling |
9460e6b656ca
patch 9.0.1312: Cursor position wrong when splitting window in insert mode
Bram Moolenaar <Bram@vim.org>
parents:
31827
diff
changeset
|
6812 * instead. |
30219
bc8ad1c28b51
patch 9.0.0445: when opening/closing window text moves up/down
Bram Moolenaar <Bram@vim.org>
parents:
30134
diff
changeset
|
6813 */ |
bc8ad1c28b51
patch 9.0.0445: when opening/closing window text moves up/down
Bram Moolenaar <Bram@vim.org>
parents:
30134
diff
changeset
|
6814 static void |
bc8ad1c28b51
patch 9.0.0445: when opening/closing window text moves up/down
Bram Moolenaar <Bram@vim.org>
parents:
30134
diff
changeset
|
6815 win_fix_cursor(int normal) |
bc8ad1c28b51
patch 9.0.0445: when opening/closing window text moves up/down
Bram Moolenaar <Bram@vim.org>
parents:
30134
diff
changeset
|
6816 { |
30535
04df44c52d65
patch 9.0.0603: with 'nosplitscroll' folds are not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
30525
diff
changeset
|
6817 long so = get_scrolloff_value(); |
04df44c52d65
patch 9.0.0603: with 'nosplitscroll' folds are not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
30525
diff
changeset
|
6818 win_T *wp = curwin; |
04df44c52d65
patch 9.0.0603: with 'nosplitscroll' folds are not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
30525
diff
changeset
|
6819 linenr_T nlnum = 0; |
30624
f2f35161d75a
patch 9.0.0647: the 'splitscroll' option is not a good name
Bram Moolenaar <Bram@vim.org>
parents:
30574
diff
changeset
|
6820 linenr_T lnum = wp->w_cursor.lnum; |
f2f35161d75a
patch 9.0.0647: the 'splitscroll' option is not a good name
Bram Moolenaar <Bram@vim.org>
parents:
30574
diff
changeset
|
6821 linenr_T bot; |
f2f35161d75a
patch 9.0.0647: the 'splitscroll' option is not a good name
Bram Moolenaar <Bram@vim.org>
parents:
30574
diff
changeset
|
6822 linenr_T top; |
30219
bc8ad1c28b51
patch 9.0.0445: when opening/closing window text moves up/down
Bram Moolenaar <Bram@vim.org>
parents:
30134
diff
changeset
|
6823 |
bc8ad1c28b51
patch 9.0.0445: when opening/closing window text moves up/down
Bram Moolenaar <Bram@vim.org>
parents:
30134
diff
changeset
|
6824 if (wp->w_buffer->b_ml.ml_line_count < wp->w_height) |
bc8ad1c28b51
patch 9.0.0445: when opening/closing window text moves up/down
Bram Moolenaar <Bram@vim.org>
parents:
30134
diff
changeset
|
6825 return; |
30267
be97adfeac3a
patch 9.0.0469: cursor moves if cmdwin is closed when 'splitscroll' is off
Bram Moolenaar <Bram@vim.org>
parents:
30251
diff
changeset
|
6826 if (skip_win_fix_cursor) |
be97adfeac3a
patch 9.0.0469: cursor moves if cmdwin is closed when 'splitscroll' is off
Bram Moolenaar <Bram@vim.org>
parents:
30251
diff
changeset
|
6827 return; |
30645
101f08b49ed3
patch 9.0.0657: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
30624
diff
changeset
|
6828 |
30535
04df44c52d65
patch 9.0.0603: with 'nosplitscroll' folds are not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
30525
diff
changeset
|
6829 // Determine valid cursor range. |
30219
bc8ad1c28b51
patch 9.0.0445: when opening/closing window text moves up/down
Bram Moolenaar <Bram@vim.org>
parents:
30134
diff
changeset
|
6830 so = MIN(wp->w_height / 2, so); |
30535
04df44c52d65
patch 9.0.0603: with 'nosplitscroll' folds are not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
30525
diff
changeset
|
6831 wp->w_cursor.lnum = wp->w_topline; |
04df44c52d65
patch 9.0.0603: with 'nosplitscroll' folds are not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
30525
diff
changeset
|
6832 top = cursor_down_inner(wp, so); |
04df44c52d65
patch 9.0.0603: with 'nosplitscroll' folds are not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
30525
diff
changeset
|
6833 wp->w_cursor.lnum = wp->w_botline - 1; |
04df44c52d65
patch 9.0.0603: with 'nosplitscroll' folds are not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
30525
diff
changeset
|
6834 bot = cursor_up_inner(wp, so); |
30624
f2f35161d75a
patch 9.0.0647: the 'splitscroll' option is not a good name
Bram Moolenaar <Bram@vim.org>
parents:
30574
diff
changeset
|
6835 wp->w_cursor.lnum = lnum; |
30535
04df44c52d65
patch 9.0.0603: with 'nosplitscroll' folds are not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
30525
diff
changeset
|
6836 // Check if cursor position is above or below valid cursor range. |
04df44c52d65
patch 9.0.0603: with 'nosplitscroll' folds are not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
30525
diff
changeset
|
6837 if (lnum > bot && (wp->w_botline - wp->w_buffer->b_ml.ml_line_count) != 1) |
04df44c52d65
patch 9.0.0603: with 'nosplitscroll' folds are not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
30525
diff
changeset
|
6838 nlnum = bot; |
04df44c52d65
patch 9.0.0603: with 'nosplitscroll' folds are not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
30525
diff
changeset
|
6839 else if (lnum < top && wp->w_topline != 1) |
04df44c52d65
patch 9.0.0603: with 'nosplitscroll' folds are not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
30525
diff
changeset
|
6840 nlnum = (so == wp->w_height / 2) ? bot : top; |
04df44c52d65
patch 9.0.0603: with 'nosplitscroll' folds are not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
30525
diff
changeset
|
6841 |
04df44c52d65
patch 9.0.0603: with 'nosplitscroll' folds are not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
30525
diff
changeset
|
6842 if (nlnum) // Cursor is invalid for current scroll position. |
04df44c52d65
patch 9.0.0603: with 'nosplitscroll' folds are not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
30525
diff
changeset
|
6843 { |
04df44c52d65
patch 9.0.0603: with 'nosplitscroll' folds are not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
30525
diff
changeset
|
6844 if (normal) // Save to jumplist and set cursor to avoid scrolling. |
04df44c52d65
patch 9.0.0603: with 'nosplitscroll' folds are not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
30525
diff
changeset
|
6845 { |
04df44c52d65
patch 9.0.0603: with 'nosplitscroll' folds are not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
30525
diff
changeset
|
6846 setmark('\''); |
04df44c52d65
patch 9.0.0603: with 'nosplitscroll' folds are not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
30525
diff
changeset
|
6847 wp->w_cursor.lnum = nlnum; |
30219
bc8ad1c28b51
patch 9.0.0445: when opening/closing window text moves up/down
Bram Moolenaar <Bram@vim.org>
parents:
30134
diff
changeset
|
6848 } |
30535
04df44c52d65
patch 9.0.0603: with 'nosplitscroll' folds are not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
30525
diff
changeset
|
6849 else // Scroll instead when not in normal mode. |
04df44c52d65
patch 9.0.0603: with 'nosplitscroll' folds are not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
30525
diff
changeset
|
6850 { |
30624
f2f35161d75a
patch 9.0.0647: the 'splitscroll' option is not a good name
Bram Moolenaar <Bram@vim.org>
parents:
30574
diff
changeset
|
6851 wp->w_fraction = (nlnum == bot) ? FRACTION_MULT : 0; |
30219
bc8ad1c28b51
patch 9.0.0445: when opening/closing window text moves up/down
Bram Moolenaar <Bram@vim.org>
parents:
30134
diff
changeset
|
6852 scroll_to_fraction(wp, wp->w_prev_height); |
30339
b5f67135fcb6
patch 9.0.0505: various problems with 'nosplitscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30300
diff
changeset
|
6853 validate_botline_win(curwin); |
30219
bc8ad1c28b51
patch 9.0.0445: when opening/closing window text moves up/down
Bram Moolenaar <Bram@vim.org>
parents:
30134
diff
changeset
|
6854 } |
bc8ad1c28b51
patch 9.0.0445: when opening/closing window text moves up/down
Bram Moolenaar <Bram@vim.org>
parents:
30134
diff
changeset
|
6855 } |
bc8ad1c28b51
patch 9.0.0445: when opening/closing window text moves up/down
Bram Moolenaar <Bram@vim.org>
parents:
30134
diff
changeset
|
6856 } |
bc8ad1c28b51
patch 9.0.0445: when opening/closing window text moves up/down
Bram Moolenaar <Bram@vim.org>
parents:
30134
diff
changeset
|
6857 |
bc8ad1c28b51
patch 9.0.0445: when opening/closing window text moves up/down
Bram Moolenaar <Bram@vim.org>
parents:
30134
diff
changeset
|
6858 /* |
7 | 6859 * 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
|
6860 * "height" excludes any window toolbar. |
7 | 6861 * This takes care of the things inside the window, not what happens to the |
6862 * window position, the frame or to other windows. | |
6863 */ | |
3697 | 6864 void |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6865 win_new_height(win_T *wp, int height) |
7 | 6866 { |
5875 | 6867 int prev_height = wp->w_height; |
7 | 6868 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6869 // 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
|
6870 // Will equalize heights soon to fix it. |
7 | 6871 if (height < 0) |
6872 height = 0; | |
826 | 6873 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
|
6874 return; // nothing to do |
7 | 6875 |
5875 | 6876 if (wp->w_height > 0) |
6877 { | |
30624
f2f35161d75a
patch 9.0.0647: the 'splitscroll' option is not a good name
Bram Moolenaar <Bram@vim.org>
parents:
30574
diff
changeset
|
6878 if (wp == curwin && *p_spk == 'c') |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6879 // 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
|
6880 // call win_new_height() recursively. |
5969 | 6881 validate_cursor(); |
6882 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
|
6883 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
|
6884 // to avoid the following to mess things up. |
5875 | 6885 if (wp->w_wrow != wp->w_prev_fraction_row) |
6886 set_fraction(wp); | |
6887 } | |
7 | 6888 |
6889 wp->w_height = height; | |
31261
a9040128bc3b
patch 9.0.0964: status line not redrawn when 'splitkeep' is "screen"
Bram Moolenaar <Bram@vim.org>
parents:
31227
diff
changeset
|
6890 wp->w_redr_status = TRUE; |
30892
d5ad2e07a18f
patch 9.0.0780: 'scroll' value computed in unexpected location
Bram Moolenaar <Bram@vim.org>
parents:
30825
diff
changeset
|
6891 win_comp_scroll(wp); |
7 | 6892 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6893 // 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
|
6894 // values might be invalid. |
30624
f2f35161d75a
patch 9.0.0647: the 'splitscroll' option is not a good name
Bram Moolenaar <Bram@vim.org>
parents:
30574
diff
changeset
|
6895 if (!exiting && *p_spk == 'c') |
32363
c114eebb5268
patch 9.0.1513: text scrolls unnecessarily when splitting
Bram Moolenaar <Bram@vim.org>
parents:
32319
diff
changeset
|
6896 { |
c114eebb5268
patch 9.0.1513: text scrolls unnecessarily when splitting
Bram Moolenaar <Bram@vim.org>
parents:
32319
diff
changeset
|
6897 wp->w_skipcol = 0; |
10835
c9da7f9137af
patch 8.0.0307: asan detects a memory error when EXITFREE is defined
Christian Brabandt <cb@256bit.org>
parents:
10377
diff
changeset
|
6898 scroll_to_fraction(wp, prev_height); |
32363
c114eebb5268
patch 9.0.1513: text scrolls unnecessarily when splitting
Bram Moolenaar <Bram@vim.org>
parents:
32319
diff
changeset
|
6899 } |
10013
942d40a92be6
commit https://github.com/vim/vim/commit/46328f9a1cc8047d1e05095bc9f531038c5a4028
Christian Brabandt <cb@256bit.org>
parents:
9953
diff
changeset
|
6900 } |
942d40a92be6
commit https://github.com/vim/vim/commit/46328f9a1cc8047d1e05095bc9f531038c5a4028
Christian Brabandt <cb@256bit.org>
parents:
9953
diff
changeset
|
6901 |
942d40a92be6
commit https://github.com/vim/vim/commit/46328f9a1cc8047d1e05095bc9f531038c5a4028
Christian Brabandt <cb@256bit.org>
parents:
9953
diff
changeset
|
6902 void |
942d40a92be6
commit https://github.com/vim/vim/commit/46328f9a1cc8047d1e05095bc9f531038c5a4028
Christian Brabandt <cb@256bit.org>
parents:
9953
diff
changeset
|
6903 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
|
6904 { |
942d40a92be6
commit https://github.com/vim/vim/commit/46328f9a1cc8047d1e05095bc9f531038c5a4028
Christian Brabandt <cb@256bit.org>
parents:
9953
diff
changeset
|
6905 linenr_T lnum; |
942d40a92be6
commit https://github.com/vim/vim/commit/46328f9a1cc8047d1e05095bc9f531038c5a4028
Christian Brabandt <cb@256bit.org>
parents:
9953
diff
changeset
|
6906 int sline, line_size; |
942d40a92be6
commit https://github.com/vim/vim/commit/46328f9a1cc8047d1e05095bc9f531038c5a4028
Christian Brabandt <cb@256bit.org>
parents:
9953
diff
changeset
|
6907 int height = wp->w_height; |
942d40a92be6
commit https://github.com/vim/vim/commit/46328f9a1cc8047d1e05095bc9f531038c5a4028
Christian Brabandt <cb@256bit.org>
parents:
9953
diff
changeset
|
6908 |
16650
06fd0eaada01
patch 8.1.1327: unnecessary scroll after horizontal split
Bram Moolenaar <Bram@vim.org>
parents:
16477
diff
changeset
|
6909 // 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
|
6910 // - window height is 0 |
06fd0eaada01
patch 8.1.1327: unnecessary scroll after horizontal split
Bram Moolenaar <Bram@vim.org>
parents:
16477
diff
changeset
|
6911 // - '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
|
6912 // - 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
|
6913 // is visible. |
16650
06fd0eaada01
patch 8.1.1327: unnecessary scroll after horizontal split
Bram Moolenaar <Bram@vim.org>
parents:
16477
diff
changeset
|
6914 if (height > 0 |
28809
d0241e74bfdb
patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
6915 && (!wp->w_p_scb || wp == curwin) |
d0241e74bfdb
patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents:
28773
diff
changeset
|
6916 && (height < wp->w_buffer->b_ml.ml_line_count || wp->w_topline > 1)) |
7 | 6917 { |
47 | 6918 /* |
6919 * Find a value for w_topline that shows the cursor at the same | |
6920 * relative position in the window as before (more or less). | |
6921 */ | |
7 | 6922 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
|
6923 if (lnum < 1) // can happen when starting up |
7 | 6924 lnum = 1; |
15977
7fbdceabad64
patch 8.1.0994: relative cursor position is not calculated correctly
Bram Moolenaar <Bram@vim.org>
parents:
15937
diff
changeset
|
6925 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
|
6926 / FRACTION_MULT; |
7 | 6927 line_size = plines_win_col(wp, lnum, (long)(wp->w_cursor.col)) - 1; |
6928 sline = wp->w_wrow - line_size; | |
1023 | 6929 |
6930 if (sline >= 0) | |
6931 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6932 // Make sure the whole cursor line is visible, if possible. |
1023 | 6933 int rows = plines_win(wp, lnum, FALSE); |
6934 | |
6935 if (sline > wp->w_height - rows) | |
6936 { | |
6937 sline = wp->w_height - rows; | |
6938 wp->w_wrow -= rows - line_size; | |
6939 } | |
6940 } | |
6941 | |
7 | 6942 if (sline < 0) |
6943 { | |
6944 /* | |
6945 * Cursor line would go off top of screen if w_wrow was this high. | |
1023 | 6946 * Make cursor line the first line in the window. If not enough |
6947 * room use w_skipcol; | |
7 | 6948 */ |
6949 wp->w_wrow = line_size; | |
1023 | 6950 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
|
6951 && (wp->w_width - win_col_off(wp)) > 0) |
1023 | 6952 { |
12515
972ea22c946f
patch 8.0.1136: W_WIDTH() is always the same
Christian Brabandt <cb@256bit.org>
parents:
12513
diff
changeset
|
6953 wp->w_skipcol += wp->w_width - win_col_off(wp); |
1023 | 6954 --wp->w_wrow; |
6955 while (wp->w_wrow >= wp->w_height) | |
6956 { | |
12515
972ea22c946f
patch 8.0.1136: W_WIDTH() is always the same
Christian Brabandt <cb@256bit.org>
parents:
12513
diff
changeset
|
6957 wp->w_skipcol += wp->w_width - win_col_off(wp) |
1023 | 6958 + win_col_off2(wp); |
6959 --wp->w_wrow; | |
6960 } | |
6961 } | |
7 | 6962 } |
5936 | 6963 else if (sline > 0) |
7 | 6964 { |
1023 | 6965 while (sline > 0 && lnum > 1) |
7 | 6966 { |
6967 #ifdef FEAT_FOLDING | |
6968 hasFoldingWin(wp, lnum, &lnum, NULL, TRUE, NULL); | |
6969 if (lnum == 1) | |
6970 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6971 // first line in buffer is folded |
7 | 6972 line_size = 1; |
6973 --sline; | |
6974 break; | |
6975 } | |
6976 #endif | |
6977 --lnum; | |
6978 #ifdef FEAT_DIFF | |
6979 if (lnum == wp->w_topline) | |
6980 line_size = plines_win_nofill(wp, lnum, TRUE) | |
6981 + wp->w_topfill; | |
6982 else | |
6983 #endif | |
6984 line_size = plines_win(wp, lnum, TRUE); | |
6985 sline -= line_size; | |
6986 } | |
47 | 6987 |
7 | 6988 if (sline < 0) |
6989 { | |
6990 /* | |
6991 * Line we want at top would go off top of screen. Use next | |
6992 * line instead. | |
6993 */ | |
6994 #ifdef FEAT_FOLDING | |
6995 hasFoldingWin(wp, lnum, NULL, &lnum, TRUE, NULL); | |
6996 #endif | |
6997 lnum++; | |
6998 wp->w_wrow -= line_size + sline; | |
6999 } | |
5936 | 7000 else if (sline > 0) |
7 | 7001 { |
15977
7fbdceabad64
patch 8.1.0994: relative cursor position is not calculated correctly
Bram Moolenaar <Bram@vim.org>
parents:
15937
diff
changeset
|
7002 // First line of file reached, use that as topline. |
7 | 7003 lnum = 1; |
7004 wp->w_wrow -= sline; | |
7005 } | |
7006 } | |
15977
7fbdceabad64
patch 8.1.0994: relative cursor position is not calculated correctly
Bram Moolenaar <Bram@vim.org>
parents:
15937
diff
changeset
|
7007 set_topline(wp, lnum); |
7 | 7008 } |
7009 | |
7010 if (wp == curwin) | |
7011 { | |
30624
f2f35161d75a
patch 9.0.0647: the 'splitscroll' option is not a good name
Bram Moolenaar <Bram@vim.org>
parents:
30574
diff
changeset
|
7012 if (get_scrolloff_value()) |
7 | 7013 update_topline(); |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7014 curs_columns(FALSE); // validate w_wrow |
7 | 7015 } |
5875 | 7016 if (prev_height > 0) |
7017 wp->w_prev_fraction_row = wp->w_wrow; | |
7 | 7018 |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29702
diff
changeset
|
7019 redraw_win_later(wp, UPD_SOME_VALID); |
7 | 7020 invalidate_botline_win(wp); |
7021 } | |
7022 | |
7023 /* | |
7024 * Set the width of a window. | |
7025 */ | |
3697 | 7026 void |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7027 win_new_width(win_T *wp, int width) |
7 | 7028 { |
30525
6fa498af368d
patch 9.0.0598: using negative array index with negative width window
Bram Moolenaar <Bram@vim.org>
parents:
30439
diff
changeset
|
7029 // Should we give an error if width < 0? |
6fa498af368d
patch 9.0.0598: using negative array index with negative width window
Bram Moolenaar <Bram@vim.org>
parents:
30439
diff
changeset
|
7030 wp->w_width = width < 0 ? 0 : width; |
7 | 7031 wp->w_lines_valid = 0; |
7032 changed_line_abv_curs_win(wp); | |
30624
f2f35161d75a
patch 9.0.0647: the 'splitscroll' option is not a good name
Bram Moolenaar <Bram@vim.org>
parents:
30574
diff
changeset
|
7033 invalidate_botline_win(wp); |
f2f35161d75a
patch 9.0.0647: the 'splitscroll' option is not a good name
Bram Moolenaar <Bram@vim.org>
parents:
30574
diff
changeset
|
7034 if (wp == curwin) |
f2f35161d75a
patch 9.0.0647: the 'splitscroll' option is not a good name
Bram Moolenaar <Bram@vim.org>
parents:
30574
diff
changeset
|
7035 { |
f2f35161d75a
patch 9.0.0647: the 'splitscroll' option is not a good name
Bram Moolenaar <Bram@vim.org>
parents:
30574
diff
changeset
|
7036 skip_update_topline = (*p_spk != 'c'); |
f2f35161d75a
patch 9.0.0647: the 'splitscroll' option is not a good name
Bram Moolenaar <Bram@vim.org>
parents:
30574
diff
changeset
|
7037 update_topline(); |
f2f35161d75a
patch 9.0.0647: the 'splitscroll' option is not a good name
Bram Moolenaar <Bram@vim.org>
parents:
30574
diff
changeset
|
7038 curs_columns(TRUE); // validate w_wrow |
f2f35161d75a
patch 9.0.0647: the 'splitscroll' option is not a good name
Bram Moolenaar <Bram@vim.org>
parents:
30574
diff
changeset
|
7039 skip_update_topline = FALSE; |
7 | 7040 } |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29702
diff
changeset
|
7041 redraw_win_later(wp, UPD_NOT_VALID); |
7 | 7042 wp->w_redr_status = TRUE; |
7043 } | |
7044 | |
7045 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7046 win_comp_scroll(win_T *wp) |
7 | 7047 { |
23386
3105546b941f
patch 8.2.2236: 'scroll' option can change when setting the statusline
Bram Moolenaar <Bram@vim.org>
parents:
22900
diff
changeset
|
7048 #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
|
7049 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
|
7050 #endif |
3105546b941f
patch 8.2.2236: 'scroll' option can change when setting the statusline
Bram Moolenaar <Bram@vim.org>
parents:
22900
diff
changeset
|
7051 |
7 | 7052 wp->w_p_scr = ((unsigned)wp->w_height >> 1); |
7053 if (wp->w_p_scr == 0) | |
7054 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
|
7055 #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
|
7056 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
|
7057 { |
3105546b941f
patch 8.2.2236: 'scroll' option can change when setting the statusline
Bram Moolenaar <Bram@vim.org>
parents:
22900
diff
changeset
|
7058 // 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
|
7059 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
|
7060 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
|
7061 } |
3105546b941f
patch 8.2.2236: 'scroll' option can change when setting the statusline
Bram Moolenaar <Bram@vim.org>
parents:
22900
diff
changeset
|
7062 #endif |
7 | 7063 } |
7064 | |
7065 /* | |
30661
57ebc2a4d2ca
patch 9.0.0665: setting 'cmdheight' has no effect if last window was resized
Bram Moolenaar <Bram@vim.org>
parents:
30645
diff
changeset
|
7066 * Command_height: called whenever p_ch has been changed. |
7 | 7067 */ |
7068 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7069 command_height(void) |
7 | 7070 { |
7071 int h; | |
7072 frame_T *frp; | |
824 | 7073 int old_p_ch = curtab->tp_ch_used; |
7074 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7075 // 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
|
7076 // 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
|
7077 // p_ch was changed in another tab page. |
824 | 7078 curtab->tp_ch_used = p_ch; |
170 | 7079 |
29700
cc0f638f5f6b
patch 9.0.0190: the way 'cmdheight' can be made zero is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
29694
diff
changeset
|
7080 // If the space for the command line is already more than 'cmdheight' there |
cc0f638f5f6b
patch 9.0.0190: the way 'cmdheight' can be made zero is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
29694
diff
changeset
|
7081 // is nothing to do (window size must have decreased). |
cc0f638f5f6b
patch 9.0.0190: the way 'cmdheight' can be made zero is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
29694
diff
changeset
|
7082 if (p_ch > old_p_ch && cmdline_row <= Rows - p_ch) |
cc0f638f5f6b
patch 9.0.0190: the way 'cmdheight' can be made zero is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
29694
diff
changeset
|
7083 return; |
cc0f638f5f6b
patch 9.0.0190: the way 'cmdheight' can be made zero is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
29694
diff
changeset
|
7084 |
30661
57ebc2a4d2ca
patch 9.0.0665: setting 'cmdheight' has no effect if last window was resized
Bram Moolenaar <Bram@vim.org>
parents:
30645
diff
changeset
|
7085 // Update cmdline_row to what it should be: just below the last window. |
30671
15ac28c12c8f
patch 9.0.0670: no space for command line when there is a tabline
Bram Moolenaar <Bram@vim.org>
parents:
30665
diff
changeset
|
7086 cmdline_row = topframe->fr_height + tabline_height(); |
30661
57ebc2a4d2ca
patch 9.0.0665: setting 'cmdheight' has no effect if last window was resized
Bram Moolenaar <Bram@vim.org>
parents:
30645
diff
changeset
|
7087 |
29702
c43738957bee
patch 9.0.0191: messages test fails; window size incorrect
Bram Moolenaar <Bram@vim.org>
parents:
29700
diff
changeset
|
7088 // If cmdline_row is smaller than what it is supposed to be for 'cmdheight' |
c43738957bee
patch 9.0.0191: messages test fails; window size incorrect
Bram Moolenaar <Bram@vim.org>
parents:
29700
diff
changeset
|
7089 // then set old_p_ch to what it would be, so that the windows get resized |
c43738957bee
patch 9.0.0191: messages test fails; window size incorrect
Bram Moolenaar <Bram@vim.org>
parents:
29700
diff
changeset
|
7090 // properly for the new value. |
c43738957bee
patch 9.0.0191: messages test fails; window size incorrect
Bram Moolenaar <Bram@vim.org>
parents:
29700
diff
changeset
|
7091 if (cmdline_row < Rows - p_ch) |
c43738957bee
patch 9.0.0191: messages test fails; window size incorrect
Bram Moolenaar <Bram@vim.org>
parents:
29700
diff
changeset
|
7092 old_p_ch = Rows - cmdline_row; |
c43738957bee
patch 9.0.0191: messages test fails; window size incorrect
Bram Moolenaar <Bram@vim.org>
parents:
29700
diff
changeset
|
7093 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7094 // Find bottom frame with width of screen. |
7 | 7095 frp = lastwin->w_frame; |
7096 while (frp->fr_width != Columns && frp->fr_parent != NULL) | |
7097 frp = frp->fr_parent; | |
7098 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7099 // Avoid changing the height of a window with 'winfixheight' set. |
7 | 7100 while (frp->fr_prev != NULL && frp->fr_layout == FR_LEAF |
7101 && frp->fr_win->w_p_wfh) | |
7102 frp = frp->fr_prev; | |
7103 | |
7104 if (starting != NO_SCREEN) | |
7105 { | |
7106 cmdline_row = Rows - p_ch; | |
7107 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7108 if (p_ch > old_p_ch) // p_ch got bigger |
7 | 7109 { |
7110 while (p_ch > old_p_ch) | |
7111 { | |
7112 if (frp == NULL) | |
7113 { | |
25306
078edc1821bf
patch 8.2.3190: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
25157
diff
changeset
|
7114 emsg(_(e_not_enough_room)); |
7 | 7115 p_ch = old_p_ch; |
1404 | 7116 curtab->tp_ch_used = p_ch; |
7 | 7117 cmdline_row = Rows - p_ch; |
7118 break; | |
7119 } | |
7120 h = frp->fr_height - frame_minheight(frp, NULL); | |
7121 if (h > p_ch - old_p_ch) | |
7122 h = p_ch - old_p_ch; | |
7123 old_p_ch += h; | |
7124 frame_add_height(frp, -h); | |
7125 frp = frp->fr_prev; | |
7126 } | |
7127 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7128 // Recompute window positions. |
7 | 7129 (void)win_comp_pos(); |
7130 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7131 // clear the lines added to cmdline |
7 | 7132 if (full_screen) |
27426
41e0dcf38521
patch 8.2.4241: some type casts are redundant
Bram Moolenaar <Bram@vim.org>
parents:
27251
diff
changeset
|
7133 screen_fill(cmdline_row, (int)Rows, 0, |
7 | 7134 (int)Columns, ' ', ' ', 0); |
7135 msg_row = cmdline_row; | |
7136 redraw_cmdline = TRUE; | |
7137 return; | |
7138 } | |
7139 | |
7140 if (msg_row < cmdline_row) | |
7141 msg_row = cmdline_row; | |
7142 redraw_cmdline = TRUE; | |
7143 } | |
7144 frame_add_height(frp, (int)(old_p_ch - p_ch)); | |
7145 | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7146 // Recompute window positions. |
7 | 7147 if (frp != lastwin->w_frame) |
7148 (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
|
7149 } |
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
7150 |
7 | 7151 /* |
7152 * Resize frame "frp" to be "n" lines higher (negative for less high). | |
7153 * Also resize the frames it is contained in. | |
7154 */ | |
7155 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7156 frame_add_height(frame_T *frp, int n) |
7 | 7157 { |
7158 frame_new_height(frp, frp->fr_height + n, FALSE, FALSE); | |
7159 for (;;) | |
7160 { | |
7161 frp = frp->fr_parent; | |
7162 if (frp == NULL) | |
7163 break; | |
7164 frp->fr_height += n; | |
7165 } | |
7166 } | |
7167 | |
7168 /* | |
7169 * Add or remove a status line for the bottom window(s), according to the | |
7170 * value of 'laststatus'. | |
7171 */ | |
7172 void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7173 last_status( |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7174 int morewin) // pretend there are two or more windows |
7 | 7175 { |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7176 // Don't make a difference between horizontal or vertical split. |
7 | 7177 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
|
7178 || (p_ls == 1 && (morewin || !ONE_WINDOW)))); |
7 | 7179 } |
7180 | |
7181 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7182 last_status_rec(frame_T *fr, int statusline) |
7 | 7183 { |
7184 frame_T *fp; | |
7185 win_T *wp; | |
7186 | |
7187 if (fr->fr_layout == FR_LEAF) | |
7188 { | |
7189 wp = fr->fr_win; | |
7190 if (wp->w_status_height != 0 && !statusline) | |
7191 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7192 // remove status line |
7 | 7193 win_new_height(wp, wp->w_height + 1); |
7194 wp->w_status_height = 0; | |
7195 comp_col(); | |
7196 } | |
7197 else if (wp->w_status_height == 0 && statusline) | |
7198 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7199 // Find a frame to take a line from. |
7 | 7200 fp = fr; |
7201 while (fp->fr_height <= frame_minheight(fp, NULL)) | |
7202 { | |
7203 if (fp == topframe) | |
7204 { | |
25306
078edc1821bf
patch 8.2.3190: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
25157
diff
changeset
|
7205 emsg(_(e_not_enough_room)); |
7 | 7206 return; |
7207 } | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7208 // 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
|
7209 // the top or in a row of frames: go to parent. |
7 | 7210 if (fp->fr_parent->fr_layout == FR_COL && fp->fr_prev != NULL) |
7211 fp = fp->fr_prev; | |
7212 else | |
7213 fp = fp->fr_parent; | |
7214 } | |
7215 wp->w_status_height = 1; | |
7216 if (fp != fr) | |
7217 { | |
7218 frame_new_height(fp, fp->fr_height - 1, FALSE, FALSE); | |
7219 frame_fix_height(wp); | |
7220 (void)win_comp_pos(); | |
7221 } | |
7222 else | |
7223 win_new_height(wp, wp->w_height - 1); | |
7224 comp_col(); | |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29702
diff
changeset
|
7225 redraw_all_later(UPD_SOME_VALID); |
7 | 7226 } |
30239
91ecee475811
patch 9.0.0455: a few problems with 'splitscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30219
diff
changeset
|
7227 // Set prev_height when difference is due to 'laststatus'. |
91ecee475811
patch 9.0.0455: a few problems with 'splitscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30219
diff
changeset
|
7228 if (abs(wp->w_height - wp->w_prev_height) == 1) |
91ecee475811
patch 9.0.0455: a few problems with 'splitscroll'
Bram Moolenaar <Bram@vim.org>
parents:
30219
diff
changeset
|
7229 wp->w_prev_height = wp->w_height; |
7 | 7230 } |
7231 else if (fr->fr_layout == FR_ROW) | |
7232 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7233 // 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
|
7234 FOR_ALL_FRAMES(fp, fr->fr_child) |
7 | 7235 last_status_rec(fp, statusline); |
7236 } | |
7237 else | |
7238 { | |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7239 // horizontally split window, set status line for last one |
7 | 7240 for (fp = fr->fr_child; fp->fr_next != NULL; fp = fp->fr_next) |
7241 ; | |
7242 last_status_rec(fp, statusline); | |
7243 } | |
7244 } | |
7245 | |
667 | 7246 /* |
668 | 7247 * Return the number of lines used by the tab page line. |
667 | 7248 */ |
7249 int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7250 tabline_height(void) |
667 | 7251 { |
685 | 7252 #ifdef FEAT_GUI_TABLINE |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7253 // When the GUI has the tabline then this always returns zero. |
685 | 7254 if (gui_use_tabline()) |
7255 return 0; | |
7256 #endif | |
675 | 7257 switch (p_stal) |
668 | 7258 { |
7259 case 0: return 0; | |
7260 case 1: return (first_tabpage->tp_next == NULL) ? 0 : 1; | |
7261 } | |
667 | 7262 return 1; |
7263 } | |
7264 | |
7 | 7265 /* |
7266 * Return the minimal number of rows that is needed on the screen to display | |
7267 * the current number of windows. | |
7268 */ | |
7269 int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7270 min_rows(void) |
7 | 7271 { |
7272 int total; | |
671 | 7273 tabpage_T *tp; |
7274 int n; | |
7 | 7275 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7276 if (firstwin == NULL) // not initialized yet |
7 | 7277 return MIN_LINES; |
7278 | |
671 | 7279 total = 0; |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9599
diff
changeset
|
7280 FOR_ALL_TABPAGES(tp) |
671 | 7281 { |
7282 n = frame_minheight(tp->tp_topframe, NULL); | |
7283 if (total < n) | |
7284 total = n; | |
7285 } | |
685 | 7286 total += tabline_height(); |
30005
bb0e525e1393
patch 9.0.0340: the 'cmdheight' zero support causes too much trouble
Bram Moolenaar <Bram@vim.org>
parents:
29976
diff
changeset
|
7287 total += 1; // count the room for the command line |
7 | 7288 return total; |
7289 } | |
7290 | |
7291 /* | |
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
|
7292 * Return TRUE if there is only one window and only one tab page, not |
672 | 7293 * 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
|
7294 * Does not count unlisted windows. |
7 | 7295 */ |
7296 int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7297 only_one_window(void) |
7 | 7298 { |
7299 int count = 0; | |
7300 win_T *wp; | |
7301 | |
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
|
7302 #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
|
7303 // 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
|
7304 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
|
7305 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
|
7306 #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
|
7307 |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7308 // If there is another tab page there always is another window. |
667 | 7309 if (first_tabpage->tp_next != NULL) |
7310 return FALSE; | |
7311 | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9599
diff
changeset
|
7312 FOR_ALL_WINDOWS(wp) |
4021 | 7313 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
|
7314 && (!((bt_help(wp->w_buffer) && !bt_help(curbuf)) |
7 | 7315 # ifdef FEAT_QUICKFIX |
7316 || wp->w_p_pvw | |
7317 # endif | |
31263
d8e7d725a666
patch 9.0.0965: using one window for executing autocommands is insufficient
Bram Moolenaar <Bram@vim.org>
parents:
31261
diff
changeset
|
7318 ) || wp == curwin) && !is_aucmd_win(wp)) |
7 | 7319 ++count; |
7320 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
|
7321 } |
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
7322 |
7 | 7323 /* |
29438
87da4bab5aaa
patch 9.0.0061: ml_get error with nested autocommand
Bram Moolenaar <Bram@vim.org>
parents:
29348
diff
changeset
|
7324 * Implementation of check_lnums() and check_lnums_nested(). |
7 | 7325 */ |
29438
87da4bab5aaa
patch 9.0.0061: ml_get error with nested autocommand
Bram Moolenaar <Bram@vim.org>
parents:
29348
diff
changeset
|
7326 static void |
87da4bab5aaa
patch 9.0.0061: ml_get error with nested autocommand
Bram Moolenaar <Bram@vim.org>
parents:
29348
diff
changeset
|
7327 check_lnums_both(int do_curwin, int nested) |
7 | 7328 { |
7329 win_T *wp; | |
671 | 7330 tabpage_T *tp; |
7331 | |
7332 FOR_ALL_TAB_WINDOWS(tp, wp) | |
7 | 7333 if ((do_curwin || wp != curwin) && wp->w_buffer == curbuf) |
7334 { | |
29505
33983b2f030f
patch 9.0.0094: cursor restored unexpected with nested autocommand
Bram Moolenaar <Bram@vim.org>
parents:
29471
diff
changeset
|
7335 int need_adjust; |
33983b2f030f
patch 9.0.0094: cursor restored unexpected with nested autocommand
Bram Moolenaar <Bram@vim.org>
parents:
29471
diff
changeset
|
7336 |
29438
87da4bab5aaa
patch 9.0.0061: ml_get error with nested autocommand
Bram Moolenaar <Bram@vim.org>
parents:
29348
diff
changeset
|
7337 if (!nested) |
87da4bab5aaa
patch 9.0.0061: ml_get error with nested autocommand
Bram Moolenaar <Bram@vim.org>
parents:
29348
diff
changeset
|
7338 { |
87da4bab5aaa
patch 9.0.0061: ml_get error with nested autocommand
Bram Moolenaar <Bram@vim.org>
parents:
29348
diff
changeset
|
7339 // save the original cursor position and topline |
87da4bab5aaa
patch 9.0.0061: ml_get error with nested autocommand
Bram Moolenaar <Bram@vim.org>
parents:
29348
diff
changeset
|
7340 wp->w_save_cursor.w_cursor_save = wp->w_cursor; |
87da4bab5aaa
patch 9.0.0061: ml_get error with nested autocommand
Bram Moolenaar <Bram@vim.org>
parents:
29348
diff
changeset
|
7341 wp->w_save_cursor.w_topline_save = wp->w_topline; |
87da4bab5aaa
patch 9.0.0061: ml_get error with nested autocommand
Bram Moolenaar <Bram@vim.org>
parents:
29348
diff
changeset
|
7342 } |
16401
3b2db762a509
patch 8.1.1205: a BufReadPre autocommand may cause the cursor to move
Bram Moolenaar <Bram@vim.org>
parents:
16354
diff
changeset
|
7343 |
29505
33983b2f030f
patch 9.0.0094: cursor restored unexpected with nested autocommand
Bram Moolenaar <Bram@vim.org>
parents:
29471
diff
changeset
|
7344 need_adjust = wp->w_cursor.lnum > curbuf->b_ml.ml_line_count; |
33983b2f030f
patch 9.0.0094: cursor restored unexpected with nested autocommand
Bram Moolenaar <Bram@vim.org>
parents:
29471
diff
changeset
|
7345 if (need_adjust) |
7 | 7346 wp->w_cursor.lnum = curbuf->b_ml.ml_line_count; |
29505
33983b2f030f
patch 9.0.0094: cursor restored unexpected with nested autocommand
Bram Moolenaar <Bram@vim.org>
parents:
29471
diff
changeset
|
7347 if (need_adjust || !nested) |
33983b2f030f
patch 9.0.0094: cursor restored unexpected with nested autocommand
Bram Moolenaar <Bram@vim.org>
parents:
29471
diff
changeset
|
7348 // save the (corrected) cursor position |
33983b2f030f
patch 9.0.0094: cursor restored unexpected with nested autocommand
Bram Moolenaar <Bram@vim.org>
parents:
29471
diff
changeset
|
7349 wp->w_save_cursor.w_cursor_corr = wp->w_cursor; |
33983b2f030f
patch 9.0.0094: cursor restored unexpected with nested autocommand
Bram Moolenaar <Bram@vim.org>
parents:
29471
diff
changeset
|
7350 |
33983b2f030f
patch 9.0.0094: cursor restored unexpected with nested autocommand
Bram Moolenaar <Bram@vim.org>
parents:
29471
diff
changeset
|
7351 need_adjust = wp->w_topline > curbuf->b_ml.ml_line_count; |
33983b2f030f
patch 9.0.0094: cursor restored unexpected with nested autocommand
Bram Moolenaar <Bram@vim.org>
parents:
29471
diff
changeset
|
7352 if (need_adjust) |
7 | 7353 wp->w_topline = curbuf->b_ml.ml_line_count; |
29505
33983b2f030f
patch 9.0.0094: cursor restored unexpected with nested autocommand
Bram Moolenaar <Bram@vim.org>
parents:
29471
diff
changeset
|
7354 if (need_adjust || !nested) |
33983b2f030f
patch 9.0.0094: cursor restored unexpected with nested autocommand
Bram Moolenaar <Bram@vim.org>
parents:
29471
diff
changeset
|
7355 // save the (corrected) topline |
33983b2f030f
patch 9.0.0094: cursor restored unexpected with nested autocommand
Bram Moolenaar <Bram@vim.org>
parents:
29471
diff
changeset
|
7356 wp->w_save_cursor.w_topline_corr = wp->w_topline; |
16401
3b2db762a509
patch 8.1.1205: a BufReadPre autocommand may cause the cursor to move
Bram Moolenaar <Bram@vim.org>
parents:
16354
diff
changeset
|
7357 } |
3b2db762a509
patch 8.1.1205: a BufReadPre autocommand may cause the cursor to move
Bram Moolenaar <Bram@vim.org>
parents:
16354
diff
changeset
|
7358 } |
3b2db762a509
patch 8.1.1205: a BufReadPre autocommand may cause the cursor to move
Bram Moolenaar <Bram@vim.org>
parents:
16354
diff
changeset
|
7359 |
3b2db762a509
patch 8.1.1205: a BufReadPre autocommand may cause the cursor to move
Bram Moolenaar <Bram@vim.org>
parents:
16354
diff
changeset
|
7360 /* |
29438
87da4bab5aaa
patch 9.0.0061: ml_get error with nested autocommand
Bram Moolenaar <Bram@vim.org>
parents:
29348
diff
changeset
|
7361 * Correct the cursor line number in other windows. Used after changing the |
87da4bab5aaa
patch 9.0.0061: ml_get error with nested autocommand
Bram Moolenaar <Bram@vim.org>
parents:
29348
diff
changeset
|
7362 * current buffer, and before applying autocommands. |
87da4bab5aaa
patch 9.0.0061: ml_get error with nested autocommand
Bram Moolenaar <Bram@vim.org>
parents:
29348
diff
changeset
|
7363 * When "do_curwin" is TRUE, also check current window. |
87da4bab5aaa
patch 9.0.0061: ml_get error with nested autocommand
Bram Moolenaar <Bram@vim.org>
parents:
29348
diff
changeset
|
7364 */ |
87da4bab5aaa
patch 9.0.0061: ml_get error with nested autocommand
Bram Moolenaar <Bram@vim.org>
parents:
29348
diff
changeset
|
7365 void |
87da4bab5aaa
patch 9.0.0061: ml_get error with nested autocommand
Bram Moolenaar <Bram@vim.org>
parents:
29348
diff
changeset
|
7366 check_lnums(int do_curwin) |
87da4bab5aaa
patch 9.0.0061: ml_get error with nested autocommand
Bram Moolenaar <Bram@vim.org>
parents:
29348
diff
changeset
|
7367 { |
87da4bab5aaa
patch 9.0.0061: ml_get error with nested autocommand
Bram Moolenaar <Bram@vim.org>
parents:
29348
diff
changeset
|
7368 check_lnums_both(do_curwin, FALSE); |
87da4bab5aaa
patch 9.0.0061: ml_get error with nested autocommand
Bram Moolenaar <Bram@vim.org>
parents:
29348
diff
changeset
|
7369 } |
87da4bab5aaa
patch 9.0.0061: ml_get error with nested autocommand
Bram Moolenaar <Bram@vim.org>
parents:
29348
diff
changeset
|
7370 |
87da4bab5aaa
patch 9.0.0061: ml_get error with nested autocommand
Bram Moolenaar <Bram@vim.org>
parents:
29348
diff
changeset
|
7371 /* |
87da4bab5aaa
patch 9.0.0061: ml_get error with nested autocommand
Bram Moolenaar <Bram@vim.org>
parents:
29348
diff
changeset
|
7372 * Like check_lnums() but for when check_lnums() was already called. |
87da4bab5aaa
patch 9.0.0061: ml_get error with nested autocommand
Bram Moolenaar <Bram@vim.org>
parents:
29348
diff
changeset
|
7373 */ |
87da4bab5aaa
patch 9.0.0061: ml_get error with nested autocommand
Bram Moolenaar <Bram@vim.org>
parents:
29348
diff
changeset
|
7374 void |
87da4bab5aaa
patch 9.0.0061: ml_get error with nested autocommand
Bram Moolenaar <Bram@vim.org>
parents:
29348
diff
changeset
|
7375 check_lnums_nested(int do_curwin) |
87da4bab5aaa
patch 9.0.0061: ml_get error with nested autocommand
Bram Moolenaar <Bram@vim.org>
parents:
29348
diff
changeset
|
7376 { |
87da4bab5aaa
patch 9.0.0061: ml_get error with nested autocommand
Bram Moolenaar <Bram@vim.org>
parents:
29348
diff
changeset
|
7377 check_lnums_both(do_curwin, TRUE); |
87da4bab5aaa
patch 9.0.0061: ml_get error with nested autocommand
Bram Moolenaar <Bram@vim.org>
parents:
29348
diff
changeset
|
7378 } |
87da4bab5aaa
patch 9.0.0061: ml_get error with nested autocommand
Bram Moolenaar <Bram@vim.org>
parents:
29348
diff
changeset
|
7379 |
87da4bab5aaa
patch 9.0.0061: ml_get error with nested autocommand
Bram Moolenaar <Bram@vim.org>
parents:
29348
diff
changeset
|
7380 /* |
16401
3b2db762a509
patch 8.1.1205: a BufReadPre autocommand may cause the cursor to move
Bram Moolenaar <Bram@vim.org>
parents:
16354
diff
changeset
|
7381 * 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
|
7382 * 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
|
7383 */ |
3b2db762a509
patch 8.1.1205: a BufReadPre autocommand may cause the cursor to move
Bram Moolenaar <Bram@vim.org>
parents:
16354
diff
changeset
|
7384 void |
32009
4545f58c8490
patch 9.0.1336: functions without arguments are not always declared properly
Bram Moolenaar <Bram@vim.org>
parents:
31960
diff
changeset
|
7385 reset_lnums(void) |
16401
3b2db762a509
patch 8.1.1205: a BufReadPre autocommand may cause the cursor to move
Bram Moolenaar <Bram@vim.org>
parents:
16354
diff
changeset
|
7386 { |
3b2db762a509
patch 8.1.1205: a BufReadPre autocommand may cause the cursor to move
Bram Moolenaar <Bram@vim.org>
parents:
16354
diff
changeset
|
7387 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
|
7388 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
|
7389 |
3b2db762a509
patch 8.1.1205: a BufReadPre autocommand may cause the cursor to move
Bram Moolenaar <Bram@vim.org>
parents:
16354
diff
changeset
|
7390 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
|
7391 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
|
7392 { |
29471
9ada26920941
patch 9.0.0077: wrong restored cursor position when switching window in autocmd
Bram Moolenaar <Bram@vim.org>
parents:
29438
diff
changeset
|
7393 // Restore the value if the autocommand didn't change it and it was |
9ada26920941
patch 9.0.0077: wrong restored cursor position when switching window in autocmd
Bram Moolenaar <Bram@vim.org>
parents:
29438
diff
changeset
|
7394 // set. |
9ada26920941
patch 9.0.0077: wrong restored cursor position when switching window in autocmd
Bram Moolenaar <Bram@vim.org>
parents:
29438
diff
changeset
|
7395 if (EQUAL_POS(wp->w_save_cursor.w_cursor_corr, wp->w_cursor) |
9ada26920941
patch 9.0.0077: wrong restored cursor position when switching window in autocmd
Bram Moolenaar <Bram@vim.org>
parents:
29438
diff
changeset
|
7396 && wp->w_save_cursor.w_cursor_save.lnum != 0) |
16401
3b2db762a509
patch 8.1.1205: a BufReadPre autocommand may cause the cursor to move
Bram Moolenaar <Bram@vim.org>
parents:
16354
diff
changeset
|
7397 wp->w_cursor = wp->w_save_cursor.w_cursor_save; |
29471
9ada26920941
patch 9.0.0077: wrong restored cursor position when switching window in autocmd
Bram Moolenaar <Bram@vim.org>
parents:
29438
diff
changeset
|
7398 if (wp->w_save_cursor.w_topline_corr == wp->w_topline |
9ada26920941
patch 9.0.0077: wrong restored cursor position when switching window in autocmd
Bram Moolenaar <Bram@vim.org>
parents:
29438
diff
changeset
|
7399 && wp->w_save_cursor.w_topline_save != 0) |
16401
3b2db762a509
patch 8.1.1205: a BufReadPre autocommand may cause the cursor to move
Bram Moolenaar <Bram@vim.org>
parents:
16354
diff
changeset
|
7400 wp->w_topline = wp->w_save_cursor.w_topline_save; |
7 | 7401 } |
7402 } | |
7403 | |
7404 /* | |
7405 * A snapshot of the window sizes, to restore them after closing the help | |
32118
04d9dff67d99
patch 9.0.1390: FOR_ALL_ macros are defined in an unexpected file
Bram Moolenaar <Bram@vim.org>
parents:
32062
diff
changeset
|
7406 * or other window. |
7 | 7407 * Only these fields are used: |
7408 * fr_layout | |
7409 * fr_width | |
7410 * fr_height | |
7411 * fr_next | |
7412 * fr_child | |
7413 * fr_win (only valid for the old curwin, NULL otherwise) | |
7414 */ | |
7415 | |
7416 /* | |
7417 * Create a snapshot of the current frame sizes. | |
32118
04d9dff67d99
patch 9.0.1390: FOR_ALL_ macros are defined in an unexpected file
Bram Moolenaar <Bram@vim.org>
parents:
32062
diff
changeset
|
7418 * "idx" is SNAP_HELP_IDX or SNAP_AUCMD_IDX. |
7 | 7419 */ |
1906 | 7420 void |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7421 make_snapshot(int idx) |
7 | 7422 { |
1906 | 7423 clear_snapshot(curtab, idx); |
7424 make_snapshot_rec(topframe, &curtab->tp_snapshot[idx]); | |
7 | 7425 } |
7426 | |
7427 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7428 make_snapshot_rec(frame_T *fr, frame_T **frp) |
7 | 7429 { |
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
|
7430 *frp = ALLOC_CLEAR_ONE(frame_T); |
7 | 7431 if (*frp == NULL) |
7432 return; | |
7433 (*frp)->fr_layout = fr->fr_layout; | |
7434 (*frp)->fr_width = fr->fr_width; | |
7435 (*frp)->fr_height = fr->fr_height; | |
7436 if (fr->fr_next != NULL) | |
7437 make_snapshot_rec(fr->fr_next, &((*frp)->fr_next)); | |
7438 if (fr->fr_child != NULL) | |
7439 make_snapshot_rec(fr->fr_child, &((*frp)->fr_child)); | |
7440 if (fr->fr_layout == FR_LEAF && fr->fr_win == curwin) | |
7441 (*frp)->fr_win = curwin; | |
7442 } | |
7443 | |
7444 /* | |
7445 * Remove any existing snapshot. | |
7446 */ | |
7447 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7448 clear_snapshot(tabpage_T *tp, int idx) |
7 | 7449 { |
1906 | 7450 clear_snapshot_rec(tp->tp_snapshot[idx]); |
7451 tp->tp_snapshot[idx] = NULL; | |
7 | 7452 } |
7453 | |
7454 static void | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7455 clear_snapshot_rec(frame_T *fr) |
7 | 7456 { |
31827
1009c33499e7
patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31437
diff
changeset
|
7457 if (fr == NULL) |
1009c33499e7
patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31437
diff
changeset
|
7458 return; |
1009c33499e7
patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31437
diff
changeset
|
7459 clear_snapshot_rec(fr->fr_next); |
1009c33499e7
patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31437
diff
changeset
|
7460 clear_snapshot_rec(fr->fr_child); |
1009c33499e7
patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents:
31437
diff
changeset
|
7461 vim_free(fr); |
7 | 7462 } |
7463 | |
7464 /* | |
28688
264fa41e6704
patch 8.2.4868: when closing help window autocmds triggered for wrong window
Bram Moolenaar <Bram@vim.org>
parents:
28429
diff
changeset
|
7465 * Traverse a snapshot to find the previous curwin. |
264fa41e6704
patch 8.2.4868: when closing help window autocmds triggered for wrong window
Bram Moolenaar <Bram@vim.org>
parents:
28429
diff
changeset
|
7466 */ |
264fa41e6704
patch 8.2.4868: when closing help window autocmds triggered for wrong window
Bram Moolenaar <Bram@vim.org>
parents:
28429
diff
changeset
|
7467 static win_T * |
264fa41e6704
patch 8.2.4868: when closing help window autocmds triggered for wrong window
Bram Moolenaar <Bram@vim.org>
parents:
28429
diff
changeset
|
7468 get_snapshot_curwin_rec(frame_T *ft) |
264fa41e6704
patch 8.2.4868: when closing help window autocmds triggered for wrong window
Bram Moolenaar <Bram@vim.org>
parents:
28429
diff
changeset
|
7469 { |
264fa41e6704
patch 8.2.4868: when closing help window autocmds triggered for wrong window
Bram Moolenaar <Bram@vim.org>
parents:
28429
diff
changeset
|
7470 win_T *wp; |
264fa41e6704
patch 8.2.4868: when closing help window autocmds triggered for wrong window
Bram Moolenaar <Bram@vim.org>
parents:
28429
diff
changeset
|
7471 |
264fa41e6704
patch 8.2.4868: when closing help window autocmds triggered for wrong window
Bram Moolenaar <Bram@vim.org>
parents:
28429
diff
changeset
|
7472 if (ft->fr_next != NULL) |
264fa41e6704
patch 8.2.4868: when closing help window autocmds triggered for wrong window
Bram Moolenaar <Bram@vim.org>
parents:
28429
diff
changeset
|
7473 { |
264fa41e6704
patch 8.2.4868: when closing help window autocmds triggered for wrong window
Bram Moolenaar <Bram@vim.org>
parents:
28429
diff
changeset
|
7474 if ((wp = get_snapshot_curwin_rec(ft->fr_next)) != NULL) |
264fa41e6704
patch 8.2.4868: when closing help window autocmds triggered for wrong window
Bram Moolenaar <Bram@vim.org>
parents:
28429
diff
changeset
|
7475 return wp; |
264fa41e6704
patch 8.2.4868: when closing help window autocmds triggered for wrong window
Bram Moolenaar <Bram@vim.org>
parents:
28429
diff
changeset
|
7476 } |
264fa41e6704
patch 8.2.4868: when closing help window autocmds triggered for wrong window
Bram Moolenaar <Bram@vim.org>
parents:
28429
diff
changeset
|
7477 if (ft->fr_child != NULL) |
264fa41e6704
patch 8.2.4868: when closing help window autocmds triggered for wrong window
Bram Moolenaar <Bram@vim.org>
parents:
28429
diff
changeset
|
7478 { |
264fa41e6704
patch 8.2.4868: when closing help window autocmds triggered for wrong window
Bram Moolenaar <Bram@vim.org>
parents:
28429
diff
changeset
|
7479 if ((wp = get_snapshot_curwin_rec(ft->fr_child)) != NULL) |
264fa41e6704
patch 8.2.4868: when closing help window autocmds triggered for wrong window
Bram Moolenaar <Bram@vim.org>
parents:
28429
diff
changeset
|
7480 return wp; |
264fa41e6704
patch 8.2.4868: when closing help window autocmds triggered for wrong window
Bram Moolenaar <Bram@vim.org>
parents:
28429
diff
changeset
|
7481 } |
264fa41e6704
patch 8.2.4868: when closing help window autocmds triggered for wrong window
Bram Moolenaar <Bram@vim.org>
parents:
28429
diff
changeset
|
7482 |
264fa41e6704
patch 8.2.4868: when closing help window autocmds triggered for wrong window
Bram Moolenaar <Bram@vim.org>
parents:
28429
diff
changeset
|
7483 return ft->fr_win; |
264fa41e6704
patch 8.2.4868: when closing help window autocmds triggered for wrong window
Bram Moolenaar <Bram@vim.org>
parents:
28429
diff
changeset
|
7484 } |
264fa41e6704
patch 8.2.4868: when closing help window autocmds triggered for wrong window
Bram Moolenaar <Bram@vim.org>
parents:
28429
diff
changeset
|
7485 |
264fa41e6704
patch 8.2.4868: when closing help window autocmds triggered for wrong window
Bram Moolenaar <Bram@vim.org>
parents:
28429
diff
changeset
|
7486 /* |
264fa41e6704
patch 8.2.4868: when closing help window autocmds triggered for wrong window
Bram Moolenaar <Bram@vim.org>
parents:
28429
diff
changeset
|
7487 * Return the current window stored in the snapshot or NULL. |
264fa41e6704
patch 8.2.4868: when closing help window autocmds triggered for wrong window
Bram Moolenaar <Bram@vim.org>
parents:
28429
diff
changeset
|
7488 */ |
264fa41e6704
patch 8.2.4868: when closing help window autocmds triggered for wrong window
Bram Moolenaar <Bram@vim.org>
parents:
28429
diff
changeset
|
7489 static win_T * |
264fa41e6704
patch 8.2.4868: when closing help window autocmds triggered for wrong window
Bram Moolenaar <Bram@vim.org>
parents:
28429
diff
changeset
|
7490 get_snapshot_curwin(int idx) |
264fa41e6704
patch 8.2.4868: when closing help window autocmds triggered for wrong window
Bram Moolenaar <Bram@vim.org>
parents:
28429
diff
changeset
|
7491 { |
264fa41e6704
patch 8.2.4868: when closing help window autocmds triggered for wrong window
Bram Moolenaar <Bram@vim.org>
parents:
28429
diff
changeset
|
7492 if (curtab->tp_snapshot[idx] == NULL) |
264fa41e6704
patch 8.2.4868: when closing help window autocmds triggered for wrong window
Bram Moolenaar <Bram@vim.org>
parents:
28429
diff
changeset
|
7493 return NULL; |
264fa41e6704
patch 8.2.4868: when closing help window autocmds triggered for wrong window
Bram Moolenaar <Bram@vim.org>
parents:
28429
diff
changeset
|
7494 |
264fa41e6704
patch 8.2.4868: when closing help window autocmds triggered for wrong window
Bram Moolenaar <Bram@vim.org>
parents:
28429
diff
changeset
|
7495 return get_snapshot_curwin_rec(curtab->tp_snapshot[idx]); |
264fa41e6704
patch 8.2.4868: when closing help window autocmds triggered for wrong window
Bram Moolenaar <Bram@vim.org>
parents:
28429
diff
changeset
|
7496 } |
264fa41e6704
patch 8.2.4868: when closing help window autocmds triggered for wrong window
Bram Moolenaar <Bram@vim.org>
parents:
28429
diff
changeset
|
7497 |
264fa41e6704
patch 8.2.4868: when closing help window autocmds triggered for wrong window
Bram Moolenaar <Bram@vim.org>
parents:
28429
diff
changeset
|
7498 /* |
7 | 7499 * Restore a previously created snapshot, if there is any. |
7500 * This is only done if the screen size didn't change and the window layout is | |
7501 * still the same. | |
32118
04d9dff67d99
patch 9.0.1390: FOR_ALL_ macros are defined in an unexpected file
Bram Moolenaar <Bram@vim.org>
parents:
32062
diff
changeset
|
7502 * "idx" is SNAP_HELP_IDX or SNAP_AUCMD_IDX. |
7 | 7503 */ |
1906 | 7504 void |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7505 restore_snapshot( |
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7506 int idx, |
18816
15539899a112
patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7507 int close_curwin) // closing current window |
7 | 7508 { |
7509 win_T *wp; | |
7510 | |
1906 | 7511 if (curtab->tp_snapshot[idx] != NULL |
7512 && curtab->tp_snapshot[idx]->fr_width == topframe->fr_width | |
7513 && curtab->tp_snapshot[idx]->fr_height == topframe->fr_height | |
7514 && check_snapshot_rec(curtab->tp_snapshot[idx], topframe) == OK) | |
7515 { | |
7516 wp = restore_snapshot_rec(curtab->tp_snapshot[idx], topframe); | |
7 | 7517 win_comp_pos(); |
7518 if (wp != NULL && close_curwin) | |
7519 win_goto(wp); | |
29732
89e1d67814a9
patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents:
29702
diff
changeset
|
7520 redraw_all_later(UPD_NOT_VALID); |
7 | 7521 } |
1906 | 7522 clear_snapshot(curtab, idx); |
7 | 7523 } |
7524 | |
7525 /* | |
7526 * 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
|
7527 * and same children. And the window pointer is valid. |
7 | 7528 */ |
7529 static int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7530 check_snapshot_rec(frame_T *sn, frame_T *fr) |
7 | 7531 { |
7532 if (sn->fr_layout != fr->fr_layout | |
7533 || (sn->fr_next == NULL) != (fr->fr_next == NULL) | |
7534 || (sn->fr_child == NULL) != (fr->fr_child == NULL) | |
7535 || (sn->fr_next != NULL | |
7536 && check_snapshot_rec(sn->fr_next, fr->fr_next) == FAIL) | |
7537 || (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
|
7538 && 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
|
7539 || (sn->fr_win != NULL && !win_valid(sn->fr_win))) |
7 | 7540 return FAIL; |
7541 return OK; | |
7542 } | |
7543 | |
7544 /* | |
7545 * Copy the size of snapshot frame "sn" to frame "fr". Do the same for all | |
7546 * following frames and children. | |
7547 * Returns a pointer to the old current window, or NULL. | |
7548 */ | |
7549 static win_T * | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7550 restore_snapshot_rec(frame_T *sn, frame_T *fr) |
7 | 7551 { |
7552 win_T *wp = NULL; | |
7553 win_T *wp2; | |
7554 | |
7555 fr->fr_height = sn->fr_height; | |
7556 fr->fr_width = sn->fr_width; | |
7557 if (fr->fr_layout == FR_LEAF) | |
7558 { | |
7559 frame_new_height(fr, fr->fr_height, FALSE, FALSE); | |
779 | 7560 frame_new_width(fr, fr->fr_width, FALSE, FALSE); |
7 | 7561 wp = sn->fr_win; |
7562 } | |
7563 if (sn->fr_next != NULL) | |
7564 { | |
7565 wp2 = restore_snapshot_rec(sn->fr_next, fr->fr_next); | |
7566 if (wp2 != NULL) | |
7567 wp = wp2; | |
7568 } | |
7569 if (sn->fr_child != NULL) | |
7570 { | |
7571 wp2 = restore_snapshot_rec(sn->fr_child, fr->fr_child); | |
7572 if (wp2 != NULL) | |
7573 wp = wp2; | |
7574 } | |
7575 return wp; | |
7576 } | |
7577 | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
7578 #if defined(FEAT_GUI) || defined(PROTO) |
7 | 7579 /* |
7580 * Return TRUE if there is any vertically split window. | |
7581 */ | |
7582 int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7583 win_hasvertsplit(void) |
7 | 7584 { |
7585 frame_T *fr; | |
7586 | |
7587 if (topframe->fr_layout == FR_ROW) | |
7588 return TRUE; | |
7589 | |
7590 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
|
7591 FOR_ALL_FRAMES(fr, topframe->fr_child) |
7 | 7592 if (fr->fr_layout == FR_ROW) |
7593 return TRUE; | |
7594 | |
7595 return FALSE; | |
7596 } | |
7597 #endif | |
1326 | 7598 |
4379 | 7599 #if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) || defined(PROTO) |
7600 int | |
4401 | 7601 get_win_number(win_T *wp, win_T *first_win) |
4379 | 7602 { |
7603 int i = 1; | |
7604 win_T *w; | |
7605 | |
4401 | 7606 for (w = first_win; w != NULL && w != wp; w = W_NEXT(w)) |
4379 | 7607 ++i; |
7608 | |
7609 if (w == NULL) | |
7610 return 0; | |
7611 else | |
7612 return i; | |
7613 } | |
4401 | 7614 |
7615 int | |
4936
ae05437a744a
updated for version 7.3.1213
Bram Moolenaar <bram@vim.org>
parents:
4918
diff
changeset
|
7616 get_tab_number(tabpage_T *tp UNUSED) |
4401 | 7617 { |
7618 int i = 1; | |
7619 tabpage_T *t; | |
7620 | |
7621 for (t = first_tabpage; t != NULL && t != tp; t = t->tp_next) | |
7622 ++i; | |
7623 | |
7624 if (t == NULL) | |
7625 return 0; | |
7626 else | |
7627 return i; | |
7628 } | |
7629 #endif | |
5004
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
7630 |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
7631 /* |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
7632 * 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
|
7633 */ |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
7634 static int |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7635 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
|
7636 { |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
7637 frame_T *frp; |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
7638 |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
7639 if (topfrp->fr_height != height) |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
7640 return FALSE; |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
7641 |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
7642 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
|
7643 FOR_ALL_FRAMES(frp, topfrp->fr_child) |
5004
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
7644 if (frp->fr_height != height) |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
7645 return FALSE; |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
7646 |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
7647 return TRUE; |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
7648 } |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
7649 |
5004
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
7650 /* |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
7651 * 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
|
7652 */ |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
7653 static int |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7654 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
|
7655 { |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
7656 frame_T *frp; |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
7657 |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
7658 if (topfrp->fr_width != width) |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
7659 return FALSE; |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
7660 |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
7661 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
|
7662 FOR_ALL_FRAMES(frp, topfrp->fr_child) |
5004
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
7663 if (frp->fr_width != width) |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
7664 return FALSE; |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
7665 |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
7666 return TRUE; |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
7667 } |
a1b41dabc682
updated for version 7.3.1246
Bram Moolenaar <bram@vim.org>
parents:
4936
diff
changeset
|
7668 |
17940
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
7669 #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
|
7670 /* |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
7671 * 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
|
7672 */ |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
7673 static int |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
7674 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
|
7675 { |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
7676 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
|
7677 } |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
7678 |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
7679 /* |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
7680 * 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
|
7681 * 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
|
7682 */ |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
7683 char * |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
7684 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
|
7685 { |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
7686 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
|
7687 int col; |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
7688 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
|
7689 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
|
7690 int i; |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
7691 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
|
7692 |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
7693 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
|
7694 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
|
7695 |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
7696 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
|
7697 { |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
7698 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
|
7699 { |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
7700 // -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
|
7701 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
|
7702 ++s; |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
7703 if (!VIM_ISDIGIT(*s)) |
26865
bce848ec8b1b
patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
7704 return e_invalid_argument; |
17940
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
7705 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
|
7706 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
|
7707 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
|
7708 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
|
7709 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
|
7710 goto skip; |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
7711 } |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
7712 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
|
7713 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
|
7714 else |
26865
bce848ec8b1b
patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
7715 return e_invalid_argument; |
17940
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
7716 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
|
7717 skip: |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
7718 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
|
7719 break; |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
7720 if (*s != ',') |
26865
bce848ec8b1b
patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
7721 return e_invalid_argument; |
17940
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
7722 if (*++s == NUL) |
26865
bce848ec8b1b
patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
7723 return e_invalid_argument; // illegal trailing comma as in "set cc=80," |
17940
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
7724 } |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
7725 |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
7726 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
|
7727 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
|
7728 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
|
7729 else |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
7730 { |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
7731 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
|
7732 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
|
7733 { |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
7734 // 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
|
7735 // win_line() |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
7736 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
|
7737 |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
7738 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
|
7739 // skip duplicates |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
7740 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
|
7741 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
|
7742 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
|
7743 } |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
7744 } |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
7745 |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
7746 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
|
7747 } |
079e10a49ea1
patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents:
17932
diff
changeset
|
7748 #endif |