comparison src/window.c @ 25499:5ebf9bb1cbcd v8.2.3286

patch 8.2.3286: win_enter_ext() has too many boolean arguments Commit: https://github.com/vim/vim/commit/d61f2f772a59617850e9aa2f5fa069c1aad8e074 Author: Bram Moolenaar <Bram@vim.org> Date: Wed Aug 4 20:26:19 2021 +0200 patch 8.2.3286: win_enter_ext() has too many boolean arguments Problem: win_enter_ext() has too many boolean arguments. Solution: use one flags argument with defined values.
author Bram Moolenaar <Bram@vim.org>
date Wed, 04 Aug 2021 20:30:04 +0200
parents 078edc1821bf
children a1ed55c02e80
comparison
equal deleted inserted replaced
25498:d8b600855be4 25499:5ebf9bb1cbcd
38 static int leave_tabpage(buf_T *new_curbuf, int trigger_leave_autocmds); 38 static int leave_tabpage(buf_T *new_curbuf, int trigger_leave_autocmds);
39 static void enter_tabpage(tabpage_T *tp, buf_T *old_curbuf, int trigger_enter_autocmds, int trigger_leave_autocmds); 39 static void enter_tabpage(tabpage_T *tp, buf_T *old_curbuf, int trigger_enter_autocmds, int trigger_leave_autocmds);
40 static void frame_fix_height(win_T *wp); 40 static void frame_fix_height(win_T *wp);
41 static int frame_minheight(frame_T *topfrp, win_T *next_curwin); 41 static int frame_minheight(frame_T *topfrp, win_T *next_curwin);
42 static int may_open_tabpage(void); 42 static int may_open_tabpage(void);
43 static void win_enter_ext(win_T *wp, int undo_sync, int no_curwin, int trigger_new_autocmds, int trigger_enter_autocmds, int trigger_leave_autocmds); 43 static void win_enter_ext(win_T *wp, int flags);
44 static void win_free(win_T *wp, tabpage_T *tp); 44 static void win_free(win_T *wp, tabpage_T *tp);
45 static int win_unlisted(win_T *wp); 45 static int win_unlisted(win_T *wp);
46 static void win_append(win_T *after, win_T *wp); 46 static void win_append(win_T *after, win_T *wp);
47 static void frame_append(frame_T *after, frame_T *frp); 47 static void frame_append(frame_T *after, frame_T *frp);
48 static void frame_insert(frame_T *before, frame_T *frp); 48 static void frame_insert(frame_T *before, frame_T *frp);
64 static win_T *win_alloc(win_T *after, int hidden); 64 static win_T *win_alloc(win_T *after, int hidden);
65 65
66 #define NOWIN (win_T *)-1 // non-existing window 66 #define NOWIN (win_T *)-1 // non-existing window
67 67
68 #define ROWS_AVAIL (Rows - p_ch - tabline_height()) 68 #define ROWS_AVAIL (Rows - p_ch - tabline_height())
69
70 // flags for win_enter_ext()
71 #define WEE_UNDO_SYNC 0x01
72 #define WEE_CURWIN_INVALID 0x02
73 #define WEE_TRIGGER_NEW_AUTOCMDS 0x04
74 #define WEE_TRIGGER_ENTER_AUTOCMDS 0x08
75 #define WEE_TRIGGER_LEAVE_AUTOCMDS 0x10
69 76
70 static char *m_onlyone = N_("Already only one window"); 77 static char *m_onlyone = N_("Already only one window");
71 78
72 // When non-zero splitting a window is forbidden. Used to avoid that nasty 79 // When non-zero splitting a window is forbidden. Used to avoid that nasty
73 // autocommands mess up the window structure. 80 // autocommands mess up the window structure.
1329 #endif 1336 #endif
1330 1337
1331 /* 1338 /*
1332 * make the new window the current window 1339 * make the new window the current window
1333 */ 1340 */
1334 win_enter_ext(wp, FALSE, FALSE, TRUE, TRUE, TRUE); 1341 win_enter_ext(wp, WEE_TRIGGER_NEW_AUTOCMDS | WEE_TRIGGER_ENTER_AUTOCMDS
1342 | WEE_TRIGGER_LEAVE_AUTOCMDS);
1335 if (flags & WSP_VERT) 1343 if (flags & WSP_VERT)
1336 p_wiw = i; 1344 p_wiw = i;
1337 else 1345 else
1338 p_wh = i; 1346 p_wh = i;
1339 1347
2651 win_equal(curwin, curwin->w_frame->fr_parent == win_frame, dir); 2659 win_equal(curwin, curwin->w_frame->fr_parent == win_frame, dir);
2652 else 2660 else
2653 win_comp_pos(); 2661 win_comp_pos();
2654 if (close_curwin) 2662 if (close_curwin)
2655 { 2663 {
2656 win_enter_ext(wp, FALSE, TRUE, FALSE, TRUE, TRUE); 2664 win_enter_ext(wp, WEE_CURWIN_INVALID | WEE_TRIGGER_ENTER_AUTOCMDS
2665 | WEE_TRIGGER_LEAVE_AUTOCMDS);
2657 if (other_buffer) 2666 if (other_buffer)
2658 // careful: after this wp and win may be invalid! 2667 // careful: after this wp and win may be invalid!
2659 apply_autocmds(EVENT_BUFENTER, NULL, NULL, FALSE, curbuf); 2668 apply_autocmds(EVENT_BUFENTER, NULL, NULL, FALSE, curbuf);
2660 } 2669 }
2661 2670
4177 topframe = tp->tp_topframe; 4186 topframe = tp->tp_topframe;
4178 4187
4179 // We would like doing the TabEnter event first, but we don't have a 4188 // We would like doing the TabEnter event first, but we don't have a
4180 // valid current window yet, which may break some commands. 4189 // valid current window yet, which may break some commands.
4181 // This triggers autocommands, thus may make "tp" invalid. 4190 // This triggers autocommands, thus may make "tp" invalid.
4182 win_enter_ext(tp->tp_curwin, FALSE, TRUE, FALSE, 4191 win_enter_ext(tp->tp_curwin, WEE_CURWIN_INVALID
4183 trigger_enter_autocmds, trigger_leave_autocmds); 4192 | (trigger_enter_autocmds ? WEE_TRIGGER_ENTER_AUTOCMDS : 0)
4193 | (trigger_leave_autocmds ? WEE_TRIGGER_LEAVE_AUTOCMDS : 0));
4184 prevwin = next_prevwin; 4194 prevwin = next_prevwin;
4185 4195
4186 last_status(FALSE); // status line may appear or disappear 4196 last_status(FALSE); // status line may appear or disappear
4187 row = win_comp_pos(); // recompute w_winrow for all windows 4197 row = win_comp_pos(); // recompute w_winrow for all windows
4188 #ifdef FEAT_DIFF 4198 #ifdef FEAT_DIFF
4677 * Make window "wp" the current window. 4687 * Make window "wp" the current window.
4678 */ 4688 */
4679 void 4689 void
4680 win_enter(win_T *wp, int undo_sync) 4690 win_enter(win_T *wp, int undo_sync)
4681 { 4691 {
4682 win_enter_ext(wp, undo_sync, FALSE, FALSE, TRUE, TRUE); 4692 win_enter_ext(wp, (undo_sync ? WEE_UNDO_SYNC : 0)
4683 } 4693 | WEE_TRIGGER_ENTER_AUTOCMDS | WEE_TRIGGER_LEAVE_AUTOCMDS);
4684 4694 }
4685 /* 4695
4686 * Make window wp the current window. 4696 /*
4687 * Can be called with "curwin_invalid" TRUE, which means that curwin has just 4697 * Make window "wp" the current window.
4688 * been closed and isn't valid. 4698 * Can be called with "flags" containing WEE_CURWIN_INVALID, which means that
4699 * curwin has just been closed and isn't valid.
4689 */ 4700 */
4690 static void 4701 static void
4691 win_enter_ext( 4702 win_enter_ext(win_T *wp, int flags)
4692 win_T *wp,
4693 int undo_sync,
4694 int curwin_invalid,
4695 int trigger_new_autocmds,
4696 int trigger_enter_autocmds,
4697 int trigger_leave_autocmds)
4698 { 4703 {
4699 int other_buffer = FALSE; 4704 int other_buffer = FALSE;
4705 int curwin_invalid = (flags & WEE_CURWIN_INVALID);
4700 4706
4701 if (wp == curwin && !curwin_invalid) // nothing to do 4707 if (wp == curwin && !curwin_invalid) // nothing to do
4702 return; 4708 return;
4703 4709
4704 #ifdef FEAT_JOB_CHANNEL 4710 #ifdef FEAT_JOB_CHANNEL
4705 if (!curwin_invalid) 4711 if (!curwin_invalid)
4706 leaving_window(curwin); 4712 leaving_window(curwin);
4707 #endif 4713 #endif
4708 4714
4709 if (!curwin_invalid && trigger_leave_autocmds) 4715 if (!curwin_invalid && (flags & WEE_TRIGGER_LEAVE_AUTOCMDS))
4710 { 4716 {
4711 /* 4717 /*
4712 * Be careful: If autocommands delete the window, return now. 4718 * Be careful: If autocommands delete the window, return now.
4713 */ 4719 */
4714 if (wp->w_buffer != curbuf) 4720 if (wp->w_buffer != curbuf)
4727 return; 4733 return;
4728 #endif 4734 #endif
4729 } 4735 }
4730 4736
4731 // sync undo before leaving the current buffer 4737 // sync undo before leaving the current buffer
4732 if (undo_sync && curbuf != wp->w_buffer) 4738 if ((flags & WEE_UNDO_SYNC) && curbuf != wp->w_buffer)
4733 u_sync(FALSE); 4739 u_sync(FALSE);
4734 4740
4735 // Might need to scroll the old window before switching, e.g., when the 4741 // Might need to scroll the old window before switching, e.g., when the
4736 // cursor was moved. 4742 // cursor was moved.
4737 update_topline(); 4743 update_topline();
4784 4790
4785 #ifdef FEAT_JOB_CHANNEL 4791 #ifdef FEAT_JOB_CHANNEL
4786 entering_window(curwin); 4792 entering_window(curwin);
4787 #endif 4793 #endif
4788 // Careful: autocommands may close the window and make "wp" invalid 4794 // Careful: autocommands may close the window and make "wp" invalid
4789 if (trigger_new_autocmds) 4795 if (flags & WEE_TRIGGER_NEW_AUTOCMDS)
4790 apply_autocmds(EVENT_WINNEW, NULL, NULL, FALSE, curbuf); 4796 apply_autocmds(EVENT_WINNEW, NULL, NULL, FALSE, curbuf);
4791 if (trigger_enter_autocmds) 4797 if (flags & WEE_TRIGGER_ENTER_AUTOCMDS)
4792 { 4798 {
4793 apply_autocmds(EVENT_WINENTER, NULL, NULL, FALSE, curbuf); 4799 apply_autocmds(EVENT_WINENTER, NULL, NULL, FALSE, curbuf);
4794 if (other_buffer) 4800 if (other_buffer)
4795 apply_autocmds(EVENT_BUFENTER, NULL, NULL, FALSE, curbuf); 4801 apply_autocmds(EVENT_BUFENTER, NULL, NULL, FALSE, curbuf);
4796 } 4802 }