comparison src/window.c @ 12477:68d7bc045dbe v8.0.1118

patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs commit https://github.com/vim/vim/commit/4033c55eca575777718c0701e26635a0cc47d907 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Sep 16 20:54:51 2017 +0200 patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs Problem: FEAT_WINDOWS adds a lot of #ifdefs while it is nearly always enabled and only adds 7% to the binary size of the tiny build. Solution: Graduate FEAT_WINDOWS.
author Christian Brabandt <cb@256bit.org>
date Sat, 16 Sep 2017 21:00:06 +0200
parents bc0fee081e1e
children 3f16cf18386c
comparison
equal deleted inserted replaced
12476:2516383741e6 12477:68d7bc045dbe
8 */ 8 */
9 9
10 #include "vim.h" 10 #include "vim.h"
11 11
12 static int path_is_url(char_u *p); 12 static int path_is_url(char_u *p);
13 #if defined(FEAT_WINDOWS) || defined(PROTO)
14 static void cmd_with_count(char *cmd, char_u *bufp, size_t bufsize, long Prenum); 13 static void cmd_with_count(char *cmd, char_u *bufp, size_t bufsize, long Prenum);
15 static void win_init(win_T *newp, win_T *oldp, int flags); 14 static void win_init(win_T *newp, win_T *oldp, int flags);
16 static void win_init_some(win_T *newp, win_T *oldp); 15 static void win_init_some(win_T *newp, win_T *oldp);
17 static void frame_comp_pos(frame_T *topfrp, int *row, int *col); 16 static void frame_comp_pos(frame_T *topfrp, int *row, int *col);
18 static void frame_setheight(frame_T *curfrp, int height); 17 static void frame_setheight(frame_T *curfrp, int height);
34 static void frame_add_statusline(frame_T *frp); 33 static void frame_add_statusline(frame_T *frp);
35 static void frame_new_width(frame_T *topfrp, int width, int leftfirst, int wfw); 34 static void frame_new_width(frame_T *topfrp, int width, int leftfirst, int wfw);
36 static void frame_add_vsep(frame_T *frp); 35 static void frame_add_vsep(frame_T *frp);
37 static int frame_minwidth(frame_T *topfrp, win_T *next_curwin); 36 static int frame_minwidth(frame_T *topfrp, win_T *next_curwin);
38 static void frame_fix_width(win_T *wp); 37 static void frame_fix_width(win_T *wp);
39 #endif
40 static int win_alloc_firstwin(win_T *oldwin); 38 static int win_alloc_firstwin(win_T *oldwin);
41 static void new_frame(win_T *wp); 39 static void new_frame(win_T *wp);
42 #if defined(FEAT_WINDOWS) || defined(PROTO)
43 static tabpage_T *alloc_tabpage(void); 40 static tabpage_T *alloc_tabpage(void);
44 static int leave_tabpage(buf_T *new_curbuf, int trigger_leave_autocmds); 41 static int leave_tabpage(buf_T *new_curbuf, int trigger_leave_autocmds);
45 static void enter_tabpage(tabpage_T *tp, buf_T *old_curbuf, int trigger_enter_autocmds, int trigger_leave_autocmds); 42 static void enter_tabpage(tabpage_T *tp, buf_T *old_curbuf, int trigger_enter_autocmds, int trigger_leave_autocmds);
46 static void frame_fix_height(win_T *wp); 43 static void frame_fix_height(win_T *wp);
47 static int frame_minheight(frame_T *topfrp, win_T *next_curwin); 44 static int frame_minheight(frame_T *topfrp, win_T *next_curwin);
62 static win_T *restore_snapshot_rec(frame_T *sn, frame_T *fr); 59 static win_T *restore_snapshot_rec(frame_T *sn, frame_T *fr);
63 60
64 static int frame_check_height(frame_T *topfrp, int height); 61 static int frame_check_height(frame_T *topfrp, int height);
65 static int frame_check_width(frame_T *topfrp, int width); 62 static int frame_check_width(frame_T *topfrp, int width);
66 63
67 #endif /* FEAT_WINDOWS */
68
69 static win_T *win_alloc(win_T *after, int hidden); 64 static win_T *win_alloc(win_T *after, int hidden);
70 65
71 #define URL_SLASH 1 /* path_is_url() has found "://" */ 66 #define URL_SLASH 1 /* path_is_url() has found "://" */
72 #define URL_BACKSLASH 2 /* path_is_url() has found ":\\" */ 67 #define URL_BACKSLASH 2 /* path_is_url() has found ":\\" */
73 68
74 #define NOWIN (win_T *)-1 /* non-existing window */ 69 #define NOWIN (win_T *)-1 /* non-existing window */
75 70
76 #ifdef FEAT_WINDOWS 71 #define ROWS_AVAIL (Rows - p_ch - tabline_height())
77 # define ROWS_AVAIL (Rows - p_ch - tabline_height())
78 #else
79 # define ROWS_AVAIL (Rows - p_ch)
80 #endif
81
82 #if defined(FEAT_WINDOWS) || defined(PROTO)
83 72
84 static char *m_onlyone = N_("Already only one window"); 73 static char *m_onlyone = N_("Already only one window");
85 74
86 /* 75 /*
87 * all CTRL-W window commands are handled here, called from normal_cmd(). 76 * all CTRL-W window commands are handled here, called from normal_cmd().
196 reset_VIsual_and_resel(); /* stop Visual mode */ 185 reset_VIsual_and_resel(); /* stop Visual mode */
197 cmd_with_count("close", cbuf, sizeof(cbuf), Prenum); 186 cmd_with_count("close", cbuf, sizeof(cbuf), Prenum);
198 do_cmdline_cmd(cbuf); 187 do_cmdline_cmd(cbuf);
199 break; 188 break;
200 189
201 #if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX) 190 #if defined(FEAT_QUICKFIX)
202 /* close preview window */ 191 /* close preview window */
203 case Ctrl_Z: 192 case Ctrl_Z:
204 case 'z': 193 case 'z':
205 CHECK_CMDWIN 194 CHECK_CMDWIN
206 reset_VIsual_and_resel(); /* stop Visual mode */ 195 reset_VIsual_and_resel(); /* stop Visual mode */
1352 1341
1353 /* copy options from existing window */ 1342 /* copy options from existing window */
1354 win_copy_options(oldp, newp); 1343 win_copy_options(oldp, newp);
1355 } 1344 }
1356 1345
1357 #endif /* FEAT_WINDOWS */ 1346
1358
1359 #if defined(FEAT_WINDOWS) || defined(PROTO)
1360 /* 1347 /*
1361 * Check if "win" is a pointer to an existing window in the current tab page. 1348 * Check if "win" is a pointer to an existing window in the current tab page.
1362 */ 1349 */
1363 int 1350 int
1364 win_valid(win_T *win) 1351 win_valid(win_T *win)
2594 void 2581 void
2595 win_free_all(void) 2582 win_free_all(void)
2596 { 2583 {
2597 int dummy; 2584 int dummy;
2598 2585
2599 # ifdef FEAT_WINDOWS
2600 while (first_tabpage->tp_next != NULL) 2586 while (first_tabpage->tp_next != NULL)
2601 tabpage_close(TRUE); 2587 tabpage_close(TRUE);
2602 # endif
2603 2588
2604 # ifdef FEAT_AUTOCMD 2589 # ifdef FEAT_AUTOCMD
2605 if (aucmd_win != NULL) 2590 if (aucmd_win != NULL)
2606 { 2591 {
2607 (void)win_free_mem(aucmd_win, &dummy, NULL); 2592 (void)win_free_mem(aucmd_win, &dummy, NULL);
3386 3371
3387 if (message && !ONE_WINDOW) 3372 if (message && !ONE_WINDOW)
3388 EMSG(_("E445: Other window contains changes")); 3373 EMSG(_("E445: Other window contains changes"));
3389 } 3374 }
3390 3375
3391 #endif /* FEAT_WINDOWS */
3392
3393 /* 3376 /*
3394 * Init the current window "curwin". 3377 * Init the current window "curwin".
3395 * Called when a new file is being edited. 3378 * Called when a new file is being edited.
3396 */ 3379 */
3397 void 3380 void
3439 win_alloc_first(void) 3422 win_alloc_first(void)
3440 { 3423 {
3441 if (win_alloc_firstwin(NULL) == FAIL) 3424 if (win_alloc_firstwin(NULL) == FAIL)
3442 return FAIL; 3425 return FAIL;
3443 3426
3444 #ifdef FEAT_WINDOWS
3445 first_tabpage = alloc_tabpage(); 3427 first_tabpage = alloc_tabpage();
3446 if (first_tabpage == NULL) 3428 if (first_tabpage == NULL)
3447 return FAIL; 3429 return FAIL;
3448 first_tabpage->tp_topframe = topframe; 3430 first_tabpage->tp_topframe = topframe;
3449 curtab = first_tabpage; 3431 curtab = first_tabpage;
3450 #endif
3451 3432
3452 return OK; 3433 return OK;
3453 } 3434 }
3454 3435
3455 #if defined(FEAT_AUTOCMD) || defined(PROTO) 3436 #if defined(FEAT_AUTOCMD) || defined(PROTO)
3471 #endif 3452 #endif
3472 3453
3473 /* 3454 /*
3474 * Allocate the first window or the first window in a new tab page. 3455 * Allocate the first window or the first window in a new tab page.
3475 * When "oldwin" is NULL create an empty buffer for it. 3456 * When "oldwin" is NULL create an empty buffer for it.
3476 * When "oldwin" is not NULL copy info from it to the new window (only with 3457 * When "oldwin" is not NULL copy info from it to the new window.
3477 * FEAT_WINDOWS).
3478 * Return FAIL when something goes wrong (out of memory). 3458 * Return FAIL when something goes wrong (out of memory).
3479 */ 3459 */
3480 static int 3460 static int
3481 win_alloc_firstwin(win_T *oldwin) 3461 win_alloc_firstwin(win_T *oldwin)
3482 { 3462 {
3491 curwin->w_buffer = curbuf; 3471 curwin->w_buffer = curbuf;
3492 #ifdef FEAT_SYN_HL 3472 #ifdef FEAT_SYN_HL
3493 curwin->w_s = &(curbuf->b_s); 3473 curwin->w_s = &(curbuf->b_s);
3494 #endif 3474 #endif
3495 curbuf->b_nwindows = 1; /* there is one window */ 3475 curbuf->b_nwindows = 1; /* there is one window */
3496 #ifdef FEAT_WINDOWS
3497 curwin->w_alist = &global_alist; 3476 curwin->w_alist = &global_alist;
3498 #endif
3499 curwin_init(); /* init current window */ 3477 curwin_init(); /* init current window */
3500 } 3478 }
3501 #ifdef FEAT_WINDOWS
3502 else 3479 else
3503 { 3480 {
3504 /* First window in new tab page, initialize it from "oldwin". */ 3481 /* First window in new tab page, initialize it from "oldwin". */
3505 win_init(curwin, oldwin, 0); 3482 win_init(curwin, oldwin, 0);
3506 3483
3507 /* We don't want cursor- and scroll-binding in the first window. */ 3484 /* We don't want cursor- and scroll-binding in the first window. */
3508 RESET_BINDING(curwin); 3485 RESET_BINDING(curwin);
3509 } 3486 }
3510 #endif
3511 3487
3512 new_frame(curwin); 3488 new_frame(curwin);
3513 if (curwin->w_frame == NULL) 3489 if (curwin->w_frame == NULL)
3514 return FAIL; 3490 return FAIL;
3515 topframe = curwin->w_frame; 3491 topframe = curwin->w_frame;
3516 #ifdef FEAT_WINDOWS
3517 topframe->fr_width = Columns; 3492 topframe->fr_width = Columns;
3518 #endif
3519 topframe->fr_height = Rows - p_ch; 3493 topframe->fr_height = Rows - p_ch;
3520 topframe->fr_win = curwin; 3494 topframe->fr_win = curwin;
3521 3495
3522 return OK; 3496 return OK;
3523 } 3497 }
3544 void 3518 void
3545 win_init_size(void) 3519 win_init_size(void)
3546 { 3520 {
3547 firstwin->w_height = ROWS_AVAIL; 3521 firstwin->w_height = ROWS_AVAIL;
3548 topframe->fr_height = ROWS_AVAIL; 3522 topframe->fr_height = ROWS_AVAIL;
3549 #ifdef FEAT_WINDOWS
3550 firstwin->w_width = Columns; 3523 firstwin->w_width = Columns;
3551 topframe->fr_width = Columns; 3524 topframe->fr_width = Columns;
3552 #endif 3525 }
3553 }
3554
3555 #if defined(FEAT_WINDOWS) || defined(PROTO)
3556 3526
3557 /* 3527 /*
3558 * Allocate a new tabpage_T and init the values. 3528 * Allocate a new tabpage_T and init the values.
3559 * Returns NULL when out of memory. 3529 * Returns NULL when out of memory.
3560 */ 3530 */
4183 win_T * 4153 win_T *
4184 win_find_nr(int winnr) 4154 win_find_nr(int winnr)
4185 { 4155 {
4186 win_T *wp; 4156 win_T *wp;
4187 4157
4188 # ifdef FEAT_WINDOWS
4189 FOR_ALL_WINDOWS(wp) 4158 FOR_ALL_WINDOWS(wp)
4190 if (--winnr == 0) 4159 if (--winnr == 0)
4191 break; 4160 break;
4192 return wp; 4161 return wp;
4193 # else 4162 }
4194 return curwin; 4163 #endif
4195 # endif 4164
4196 } 4165 #if ((defined(FEAT_PYTHON) || defined(FEAT_PYTHON3))) || defined(PROTO)
4197 #endif
4198
4199 #if (defined(FEAT_WINDOWS) && (defined(FEAT_PYTHON) || defined(FEAT_PYTHON3))) \
4200 || defined(PROTO)
4201 /* 4166 /*
4202 * Find the tabpage for window "win". 4167 * Find the tabpage for window "win".
4203 */ 4168 */
4204 tabpage_T * 4169 tabpage_T *
4205 win_find_tabpage(win_T *win) 4170 win_find_tabpage(win_T *win)
4479 4444
4480 /* Change directories when the 'acd' option is set. */ 4445 /* Change directories when the 'acd' option is set. */
4481 DO_AUTOCHDIR 4446 DO_AUTOCHDIR
4482 } 4447 }
4483 4448
4484 #endif /* FEAT_WINDOWS */ 4449
4485
4486 #if defined(FEAT_WINDOWS) || defined(FEAT_SIGNS) || defined(PROTO)
4487 /* 4450 /*
4488 * Jump to the first open window that contains buffer "buf", if one exists. 4451 * Jump to the first open window that contains buffer "buf", if one exists.
4489 * Returns a pointer to the window found, otherwise NULL. 4452 * Returns a pointer to the window found, otherwise NULL.
4490 */ 4453 */
4491 win_T * 4454 win_T *
4493 { 4456 {
4494 win_T *wp = NULL; 4457 win_T *wp = NULL;
4495 4458
4496 if (curwin->w_buffer == buf) 4459 if (curwin->w_buffer == buf)
4497 wp = curwin; 4460 wp = curwin;
4498 # ifdef FEAT_WINDOWS
4499 else 4461 else
4500 FOR_ALL_WINDOWS(wp) 4462 FOR_ALL_WINDOWS(wp)
4501 if (wp->w_buffer == buf) 4463 if (wp->w_buffer == buf)
4502 break; 4464 break;
4503 if (wp != NULL) 4465 if (wp != NULL)
4504 win_enter(wp, FALSE); 4466 win_enter(wp, FALSE);
4505 # endif
4506 return wp; 4467 return wp;
4507 } 4468 }
4508 4469
4509 /* 4470 /*
4510 * Jump to the first open window in any tab page that contains buffer "buf", 4471 * Jump to the first open window in any tab page that contains buffer "buf",
4513 */ 4474 */
4514 win_T * 4475 win_T *
4515 buf_jump_open_tab(buf_T *buf) 4476 buf_jump_open_tab(buf_T *buf)
4516 { 4477 {
4517 win_T *wp = buf_jump_open_win(buf); 4478 win_T *wp = buf_jump_open_win(buf);
4518 # ifdef FEAT_WINDOWS
4519 tabpage_T *tp; 4479 tabpage_T *tp;
4520 4480
4521 if (wp != NULL) 4481 if (wp != NULL)
4522 return wp; 4482 return wp;
4523 4483
4533 if (curwin != wp) 4493 if (curwin != wp)
4534 wp = NULL; /* something went wrong */ 4494 wp = NULL; /* something went wrong */
4535 break; 4495 break;
4536 } 4496 }
4537 } 4497 }
4538 # endif
4539 return wp; 4498 return wp;
4540 } 4499 }
4541 #endif
4542 4500
4543 static int last_win_id = LOWEST_WIN_ID - 1; 4501 static int last_win_id = LOWEST_WIN_ID - 1;
4544 4502
4545 /* 4503 /*
4546 * Allocate a window structure and link it in the window list when "hidden" is 4504 * Allocate a window structure and link it in the window list when "hidden" is
4585 block_autocmds(); 4543 block_autocmds();
4586 #endif 4544 #endif
4587 /* 4545 /*
4588 * link the window in the window list 4546 * link the window in the window list
4589 */ 4547 */
4590 #ifdef FEAT_WINDOWS
4591 if (!hidden) 4548 if (!hidden)
4592 win_append(after, new_wp); 4549 win_append(after, new_wp);
4593 new_wp->w_wincol = 0; 4550 new_wp->w_wincol = 0;
4594 new_wp->w_width = Columns; 4551 new_wp->w_width = Columns;
4595 #endif
4596 4552
4597 /* position the display and the cursor at the top of the file. */ 4553 /* position the display and the cursor at the top of the file. */
4598 new_wp->w_topline = 1; 4554 new_wp->w_topline = 1;
4599 #ifdef FEAT_DIFF 4555 #ifdef FEAT_DIFF
4600 new_wp->w_topfill = 0; 4556 new_wp->w_topfill = 0;
4628 new_wp->w_match_head = NULL; 4584 new_wp->w_match_head = NULL;
4629 new_wp->w_next_match_id = 4; 4585 new_wp->w_next_match_id = 4;
4630 #endif 4586 #endif
4631 return new_wp; 4587 return new_wp;
4632 } 4588 }
4633
4634 #if defined(FEAT_WINDOWS) || defined(PROTO)
4635 4589
4636 /* 4590 /*
4637 * Remove window 'wp' from the window list and free the structure. 4591 * Remove window 'wp' from the window list and free the structure.
4638 */ 4592 */
4639 static void 4593 static void
4848 frp->fr_parent->fr_child = frp->fr_next; 4802 frp->fr_parent->fr_child = frp->fr_next;
4849 if (frp->fr_next != NULL) 4803 if (frp->fr_next != NULL)
4850 frp->fr_next->fr_prev = frp->fr_prev; 4804 frp->fr_next->fr_prev = frp->fr_prev;
4851 } 4805 }
4852 4806
4853 #endif /* FEAT_WINDOWS */
4854
4855 /* 4807 /*
4856 * Allocate w_lines[] for window "wp". 4808 * Allocate w_lines[] for window "wp".
4857 * Return FAIL for failure, OK for success. 4809 * Return FAIL for failure, OK for success.
4858 */ 4810 */
4859 int 4811 int
4889 { 4841 {
4890 int h = (int)ROWS_AVAIL; 4842 int h = (int)ROWS_AVAIL;
4891 4843
4892 if (firstwin == NULL) /* not initialized yet */ 4844 if (firstwin == NULL) /* not initialized yet */
4893 return; 4845 return;
4894 #ifdef FEAT_WINDOWS
4895 if (h < frame_minheight(topframe, NULL)) 4846 if (h < frame_minheight(topframe, NULL))
4896 h = frame_minheight(topframe, NULL); 4847 h = frame_minheight(topframe, NULL);
4897 4848
4898 /* First try setting the heights of windows with 'winfixheight'. If 4849 /* First try setting the heights of windows with 'winfixheight'. If
4899 * that doesn't result in the right height, forget about that option. */ 4850 * that doesn't result in the right height, forget about that option. */
4900 frame_new_height(topframe, h, FALSE, TRUE); 4851 frame_new_height(topframe, h, FALSE, TRUE);
4901 if (!frame_check_height(topframe, h)) 4852 if (!frame_check_height(topframe, h))
4902 frame_new_height(topframe, h, FALSE, FALSE); 4853 frame_new_height(topframe, h, FALSE, FALSE);
4903 4854
4904 (void)win_comp_pos(); /* recompute w_winrow and w_wincol */ 4855 (void)win_comp_pos(); /* recompute w_winrow and w_wincol */
4905 #else
4906 if (h < 1)
4907 h = 1;
4908 win_new_height(firstwin, h);
4909 #endif
4910 compute_cmdrow(); 4856 compute_cmdrow();
4911 #ifdef FEAT_WINDOWS
4912 curtab->tp_ch_used = p_ch; 4857 curtab->tp_ch_used = p_ch;
4913 #endif
4914 4858
4915 #if 0 4859 #if 0
4916 /* Disabled: don't want making the screen smaller make a window larger. */ 4860 /* Disabled: don't want making the screen smaller make a window larger. */
4917 if (p_ea) 4861 if (p_ea)
4918 win_equal(curwin, FALSE, 'v'); 4862 win_equal(curwin, FALSE, 'v');
4919 #endif 4863 #endif
4920 } 4864 }
4921 4865
4922 #if defined(FEAT_WINDOWS) || defined(PROTO)
4923 /* 4866 /*
4924 * Called from win_new_shellsize() after Columns changed. 4867 * Called from win_new_shellsize() after Columns changed.
4925 */ 4868 */
4926 void 4869 void
4927 shell_new_columns(void) 4870 shell_new_columns(void)
4940 /* Disabled: don't want making the screen smaller make a window larger. */ 4883 /* Disabled: don't want making the screen smaller make a window larger. */
4941 if (p_ea) 4884 if (p_ea)
4942 win_equal(curwin, FALSE, 'h'); 4885 win_equal(curwin, FALSE, 'h');
4943 #endif 4886 #endif
4944 } 4887 }
4945 #endif
4946 4888
4947 #if defined(FEAT_CMDWIN) || defined(PROTO) 4889 #if defined(FEAT_CMDWIN) || defined(PROTO)
4948 /* 4890 /*
4949 * Save the size of all windows in "gap". 4891 * Save the size of all windows in "gap".
4950 */ 4892 */
4991 (void)win_comp_pos(); 4933 (void)win_comp_pos();
4992 } 4934 }
4993 } 4935 }
4994 #endif /* FEAT_CMDWIN */ 4936 #endif /* FEAT_CMDWIN */
4995 4937
4996 #if defined(FEAT_WINDOWS) || defined(PROTO)
4997 /* 4938 /*
4998 * Update the position for all windows, using the width and height of the 4939 * Update the position for all windows, using the width and height of the
4999 * frames. 4940 * frames.
5000 * Returns the row just after the last window. 4941 * Returns the row just after the last window.
5001 */ 4942 */
5050 frame_comp_pos(frp, row, col); 4991 frame_comp_pos(frp, row, col);
5051 } 4992 }
5052 } 4993 }
5053 } 4994 }
5054 4995
5055 #endif /* FEAT_WINDOWS */
5056
5057 /* 4996 /*
5058 * Set current window height and take care of repositioning other windows to 4997 * Set current window height and take care of repositioning other windows to
5059 * fit around it. 4998 * fit around it.
5060 */ 4999 */
5061 void 5000 void
5075 5014
5076 if (win == curwin) 5015 if (win == curwin)
5077 { 5016 {
5078 /* Always keep current window at least one line high, even when 5017 /* Always keep current window at least one line high, even when
5079 * 'winminheight' is zero. */ 5018 * 'winminheight' is zero. */
5080 #ifdef FEAT_WINDOWS
5081 if (height < p_wmh) 5019 if (height < p_wmh)
5082 height = p_wmh; 5020 height = p_wmh;
5083 #endif
5084 if (height == 0) 5021 if (height == 0)
5085 height = 1; 5022 height = 1;
5086 } 5023 }
5087 5024
5088 #ifdef FEAT_WINDOWS
5089 frame_setheight(win->w_frame, height + win->w_status_height); 5025 frame_setheight(win->w_frame, height + win->w_status_height);
5090 5026
5091 /* recompute the window positions */ 5027 /* recompute the window positions */
5092 row = win_comp_pos(); 5028 row = win_comp_pos();
5093 #else
5094 if (height > topframe->fr_height)
5095 height = topframe->fr_height;
5096 win->w_height = height;
5097 row = height;
5098 #endif
5099 5029
5100 /* 5030 /*
5101 * If there is extra space created between the last window and the command 5031 * If there is extra space created between the last window and the command
5102 * line, clear it. 5032 * line, clear it.
5103 */ 5033 */
5107 msg_row = row; 5037 msg_row = row;
5108 msg_col = 0; 5038 msg_col = 0;
5109 5039
5110 redraw_all_later(NOT_VALID); 5040 redraw_all_later(NOT_VALID);
5111 } 5041 }
5112
5113 #if defined(FEAT_WINDOWS) || defined(PROTO)
5114 5042
5115 /* 5043 /*
5116 * Set the height of a frame to "height" and take care that all frames and 5044 * Set the height of a frame to "height" and take care that all frames and
5117 * windows inside it are resized. Also resize frames on the left and right if 5045 * windows inside it are resized. Also resize frames on the left and right if
5118 * the are in the same FR_ROW frame. 5046 * the are in the same FR_ROW frame.
5723 (void)win_comp_pos(); 5651 (void)win_comp_pos();
5724 redraw_all_later(NOT_VALID); 5652 redraw_all_later(NOT_VALID);
5725 } 5653 }
5726 #endif /* FEAT_MOUSE */ 5654 #endif /* FEAT_MOUSE */
5727 5655
5728 #endif /* FEAT_WINDOWS */
5729
5730 #define FRACTION_MULT 16384L 5656 #define FRACTION_MULT 16384L
5731 5657
5732 /* 5658 /*
5733 * Set wp->w_fraction for the current w_wrow and w_height. 5659 * Set wp->w_fraction for the current w_wrow and w_height.
5734 */ 5660 */
5896 if (prev_height > 0) 5822 if (prev_height > 0)
5897 wp->w_prev_fraction_row = wp->w_wrow; 5823 wp->w_prev_fraction_row = wp->w_wrow;
5898 5824
5899 win_comp_scroll(wp); 5825 win_comp_scroll(wp);
5900 redraw_win_later(wp, SOME_VALID); 5826 redraw_win_later(wp, SOME_VALID);
5901 #ifdef FEAT_WINDOWS
5902 wp->w_redr_status = TRUE; 5827 wp->w_redr_status = TRUE;
5903 #endif
5904 invalidate_botline_win(wp); 5828 invalidate_botline_win(wp);
5905 } 5829 }
5906 5830
5907 #ifdef FEAT_WINDOWS
5908 /* 5831 /*
5909 * Set the width of a window. 5832 * Set the width of a window.
5910 */ 5833 */
5911 void 5834 void
5912 win_new_width(win_T *wp, int width) 5835 win_new_width(win_T *wp, int width)
5921 curs_columns(TRUE); /* validate w_wrow */ 5844 curs_columns(TRUE); /* validate w_wrow */
5922 } 5845 }
5923 redraw_win_later(wp, NOT_VALID); 5846 redraw_win_later(wp, NOT_VALID);
5924 wp->w_redr_status = TRUE; 5847 wp->w_redr_status = TRUE;
5925 } 5848 }
5926 #endif
5927 5849
5928 void 5850 void
5929 win_comp_scroll(win_T *wp) 5851 win_comp_scroll(win_T *wp)
5930 { 5852 {
5931 wp->w_p_scr = ((unsigned)wp->w_height >> 1); 5853 wp->w_p_scr = ((unsigned)wp->w_height >> 1);
5937 * command_height: called whenever p_ch has been changed 5859 * command_height: called whenever p_ch has been changed
5938 */ 5860 */
5939 void 5861 void
5940 command_height(void) 5862 command_height(void)
5941 { 5863 {
5942 #ifdef FEAT_WINDOWS
5943 int h; 5864 int h;
5944 frame_T *frp; 5865 frame_T *frp;
5945 int old_p_ch = curtab->tp_ch_used; 5866 int old_p_ch = curtab->tp_ch_used;
5946 5867
5947 /* Use the value of p_ch that we remembered. This is needed for when the 5868 /* Use the value of p_ch that we remembered. This is needed for when the
6002 frame_add_height(frp, (int)(old_p_ch - p_ch)); 5923 frame_add_height(frp, (int)(old_p_ch - p_ch));
6003 5924
6004 /* Recompute window positions. */ 5925 /* Recompute window positions. */
6005 if (frp != lastwin->w_frame) 5926 if (frp != lastwin->w_frame)
6006 (void)win_comp_pos(); 5927 (void)win_comp_pos();
6007 #else 5928 }
6008 cmdline_row = Rows - p_ch; 5929
6009 win_setheight(cmdline_row);
6010 #endif
6011 }
6012
6013 #if defined(FEAT_WINDOWS) || defined(PROTO)
6014 /* 5930 /*
6015 * Resize frame "frp" to be "n" lines higher (negative for less high). 5931 * Resize frame "frp" to be "n" lines higher (negative for less high).
6016 * Also resize the frames it is contained in. 5932 * Also resize the frames it is contained in.
6017 */ 5933 */
6018 static void 5934 static void
6120 case 1: return (first_tabpage->tp_next == NULL) ? 0 : 1; 6036 case 1: return (first_tabpage->tp_next == NULL) ? 0 : 1;
6121 } 6037 }
6122 return 1; 6038 return 1;
6123 } 6039 }
6124 6040
6125 #endif /* FEAT_WINDOWS */
6126
6127 #if defined(FEAT_SEARCHPATH) || defined(PROTO) 6041 #if defined(FEAT_SEARCHPATH) || defined(PROTO)
6128 /* 6042 /*
6129 * Get the file name at the cursor. 6043 * Get the file name at the cursor.
6130 * If Visual mode is active, use the selected text if it's in one line. 6044 * If Visual mode is active, use the selected text if it's in one line.
6131 * Returns the name in allocated memory, NULL for failure. 6045 * Returns the name in allocated memory, NULL for failure.
6436 */ 6350 */
6437 int 6351 int
6438 min_rows(void) 6352 min_rows(void)
6439 { 6353 {
6440 int total; 6354 int total;
6441 #ifdef FEAT_WINDOWS
6442 tabpage_T *tp; 6355 tabpage_T *tp;
6443 int n; 6356 int n;
6444 #endif
6445 6357
6446 if (firstwin == NULL) /* not initialized yet */ 6358 if (firstwin == NULL) /* not initialized yet */
6447 return MIN_LINES; 6359 return MIN_LINES;
6448 6360
6449 #ifdef FEAT_WINDOWS
6450 total = 0; 6361 total = 0;
6451 FOR_ALL_TABPAGES(tp) 6362 FOR_ALL_TABPAGES(tp)
6452 { 6363 {
6453 n = frame_minheight(tp->tp_topframe, NULL); 6364 n = frame_minheight(tp->tp_topframe, NULL);
6454 if (total < n) 6365 if (total < n)
6455 total = n; 6366 total = n;
6456 } 6367 }
6457 total += tabline_height(); 6368 total += tabline_height();
6458 #else
6459 total = 1; /* at least one window should have a line! */
6460 #endif
6461 total += 1; /* count the room for the command line */ 6369 total += 1; /* count the room for the command line */
6462 return total; 6370 return total;
6463 } 6371 }
6464 6372
6465 /* 6373 /*
6468 * Does not count "aucmd_win". 6376 * Does not count "aucmd_win".
6469 */ 6377 */
6470 int 6378 int
6471 only_one_window(void) 6379 only_one_window(void)
6472 { 6380 {
6473 #ifdef FEAT_WINDOWS
6474 int count = 0; 6381 int count = 0;
6475 win_T *wp; 6382 win_T *wp;
6476 6383
6477 /* If there is another tab page there always is another window. */ 6384 /* If there is another tab page there always is another window. */
6478 if (first_tabpage->tp_next != NULL) 6385 if (first_tabpage->tp_next != NULL)
6489 && wp != aucmd_win 6396 && wp != aucmd_win
6490 # endif 6397 # endif
6491 ) 6398 )
6492 ++count; 6399 ++count;
6493 return (count <= 1); 6400 return (count <= 1);
6494 #else 6401 }
6495 return TRUE; 6402
6496 #endif
6497 }
6498
6499 #if defined(FEAT_WINDOWS) || defined(FEAT_AUTOCMD) || defined(PROTO)
6500 /* 6403 /*
6501 * Correct the cursor line number in other windows. Used after changing the 6404 * Correct the cursor line number in other windows. Used after changing the
6502 * current buffer, and before applying autocommands. 6405 * current buffer, and before applying autocommands.
6503 * When "do_curwin" is TRUE, also check current window. 6406 * When "do_curwin" is TRUE, also check current window.
6504 */ 6407 */
6505 void 6408 void
6506 check_lnums(int do_curwin) 6409 check_lnums(int do_curwin)
6507 { 6410 {
6508 win_T *wp; 6411 win_T *wp;
6509
6510 #ifdef FEAT_WINDOWS
6511 tabpage_T *tp; 6412 tabpage_T *tp;
6512 6413
6513 FOR_ALL_TAB_WINDOWS(tp, wp) 6414 FOR_ALL_TAB_WINDOWS(tp, wp)
6514 if ((do_curwin || wp != curwin) && wp->w_buffer == curbuf) 6415 if ((do_curwin || wp != curwin) && wp->w_buffer == curbuf)
6515 #else
6516 wp = curwin;
6517 if (do_curwin)
6518 #endif
6519 { 6416 {
6520 if (wp->w_cursor.lnum > curbuf->b_ml.ml_line_count) 6417 if (wp->w_cursor.lnum > curbuf->b_ml.ml_line_count)
6521 wp->w_cursor.lnum = curbuf->b_ml.ml_line_count; 6418 wp->w_cursor.lnum = curbuf->b_ml.ml_line_count;
6522 if (wp->w_topline > curbuf->b_ml.ml_line_count) 6419 if (wp->w_topline > curbuf->b_ml.ml_line_count)
6523 wp->w_topline = curbuf->b_ml.ml_line_count; 6420 wp->w_topline = curbuf->b_ml.ml_line_count;
6524 } 6421 }
6525 } 6422 }
6526 #endif
6527
6528 #if defined(FEAT_WINDOWS) || defined(PROTO)
6529 6423
6530 /* 6424 /*
6531 * A snapshot of the window sizes, to restore them after closing the help 6425 * A snapshot of the window sizes, to restore them after closing the help
6532 * window. 6426 * window.
6533 * Only these fields are used: 6427 * Only these fields are used:
6664 wp = wp2; 6558 wp = wp2;
6665 } 6559 }
6666 return wp; 6560 return wp;
6667 } 6561 }
6668 6562
6669 #endif
6670
6671 #if defined(FEAT_EVAL) || defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) \ 6563 #if defined(FEAT_EVAL) || defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) \
6672 || defined(PROTO) 6564 || defined(PROTO)
6673 /* 6565 /*
6674 * Set "win" to be the curwin and "tp" to be the current tab page. 6566 * Set "win" to be the curwin and "tp" to be the current tab page.
6675 * restore_win() MUST be called to undo, also when FAIL is returned. 6567 * restore_win() MUST be called to undo, also when FAIL is returned.
6687 int no_display UNUSED) 6579 int no_display UNUSED)
6688 { 6580 {
6689 # ifdef FEAT_AUTOCMD 6581 # ifdef FEAT_AUTOCMD
6690 block_autocmds(); 6582 block_autocmds();
6691 # endif 6583 # endif
6692 # ifdef FEAT_WINDOWS
6693 *save_curwin = curwin; 6584 *save_curwin = curwin;
6694 if (tp != NULL) 6585 if (tp != NULL)
6695 { 6586 {
6696 *save_curtab = curtab; 6587 *save_curtab = curtab;
6697 if (no_display) 6588 if (no_display)
6707 } 6598 }
6708 if (!win_valid(win)) 6599 if (!win_valid(win))
6709 return FAIL; 6600 return FAIL;
6710 curwin = win; 6601 curwin = win;
6711 curbuf = curwin->w_buffer; 6602 curbuf = curwin->w_buffer;
6712 # endif
6713 return OK; 6603 return OK;
6714 } 6604 }
6715 6605
6716 /* 6606 /*
6717 * Restore current tabpage and window saved by switch_win(), if still valid. 6607 * Restore current tabpage and window saved by switch_win(), if still valid.
6722 restore_win( 6612 restore_win(
6723 win_T *save_curwin UNUSED, 6613 win_T *save_curwin UNUSED,
6724 tabpage_T *save_curtab UNUSED, 6614 tabpage_T *save_curtab UNUSED,
6725 int no_display UNUSED) 6615 int no_display UNUSED)
6726 { 6616 {
6727 # ifdef FEAT_WINDOWS
6728 if (save_curtab != NULL && valid_tabpage(save_curtab)) 6617 if (save_curtab != NULL && valid_tabpage(save_curtab))
6729 { 6618 {
6730 if (no_display) 6619 if (no_display)
6731 { 6620 {
6732 curtab->tp_firstwin = firstwin; 6621 curtab->tp_firstwin = firstwin;
6741 if (win_valid(save_curwin)) 6630 if (win_valid(save_curwin))
6742 { 6631 {
6743 curwin = save_curwin; 6632 curwin = save_curwin;
6744 curbuf = curwin->w_buffer; 6633 curbuf = curwin->w_buffer;
6745 } 6634 }
6746 # endif
6747 # ifdef FEAT_AUTOCMD 6635 # ifdef FEAT_AUTOCMD
6748 unblock_autocmds(); 6636 unblock_autocmds();
6749 # endif 6637 # endif
6750 } 6638 }
6751 6639
6784 ++curbuf->b_nwindows; 6672 ++curbuf->b_nwindows;
6785 } 6673 }
6786 } 6674 }
6787 #endif 6675 #endif
6788 6676
6789 #if (defined(FEAT_GUI) && defined(FEAT_WINDOWS)) || defined(PROTO) 6677 #if defined(FEAT_GUI) || defined(PROTO)
6790 /* 6678 /*
6791 * Return TRUE if there is any vertically split window. 6679 * Return TRUE if there is any vertically split window.
6792 */ 6680 */
6793 int 6681 int
6794 win_hasvertsplit(void) 6682 win_hasvertsplit(void)
7119 7007
7120 int 7008 int
7121 get_tab_number(tabpage_T *tp UNUSED) 7009 get_tab_number(tabpage_T *tp UNUSED)
7122 { 7010 {
7123 int i = 1; 7011 int i = 1;
7124 # ifdef FEAT_WINDOWS
7125 tabpage_T *t; 7012 tabpage_T *t;
7126 7013
7127 for (t = first_tabpage; t != NULL && t != tp; t = t->tp_next) 7014 for (t = first_tabpage; t != NULL && t != tp; t = t->tp_next)
7128 ++i; 7015 ++i;
7129 7016
7130 if (t == NULL) 7017 if (t == NULL)
7131 return 0; 7018 return 0;
7132 else 7019 else
7133 # endif
7134 return i; 7020 return i;
7135 } 7021 }
7136 #endif 7022 #endif
7137 7023
7138 #if defined(FEAT_WINDOWS) || defined(PROTO)
7139 /* 7024 /*
7140 * Return TRUE if "topfrp" and its children are at the right height. 7025 * Return TRUE if "topfrp" and its children are at the right height.
7141 */ 7026 */
7142 static int 7027 static int
7143 frame_check_height(frame_T *topfrp, int height) 7028 frame_check_height(frame_T *topfrp, int height)
7152 if (frp->fr_height != height) 7037 if (frp->fr_height != height)
7153 return FALSE; 7038 return FALSE;
7154 7039
7155 return TRUE; 7040 return TRUE;
7156 } 7041 }
7157 #endif 7042
7158
7159 #if defined(FEAT_WINDOWS) || defined(PROTO)
7160 /* 7043 /*
7161 * Return TRUE if "topfrp" and its children are at the right width. 7044 * Return TRUE if "topfrp" and its children are at the right width.
7162 */ 7045 */
7163 static int 7046 static int
7164 frame_check_width(frame_T *topfrp, int width) 7047 frame_check_width(frame_T *topfrp, int width)
7173 if (frp->fr_width != width) 7056 if (frp->fr_width != width)
7174 return FALSE; 7057 return FALSE;
7175 7058
7176 return TRUE; 7059 return TRUE;
7177 } 7060 }
7178 #endif
7179 7061
7180 #if defined(FEAT_EVAL) || defined(PROTO) 7062 #if defined(FEAT_EVAL) || defined(PROTO)
7181 int 7063 int
7182 win_getid(typval_T *argvars) 7064 win_getid(typval_T *argvars)
7183 { 7065 {