comparison src/window.c @ 7837:33ba2adb6065

commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b Author: Bram Moolenaar <Bram@vim.org> Date: Sat Jan 30 21:29:58 2016 +0100 patch 7.4.1215 Problem: Using old style function declarations. Solution: Change to new style function declarations. (script by Hirohito Higashi)
author Christian Brabandt <cb@256bit.org>
date Sat, 30 Jan 2016 21:30:04 +0100
parents 0b6c37dd858d
children 05b88224cea1
comparison
equal deleted inserted replaced
7836:4f052afd5b05 7837:33ba2adb6065
93 93
94 /* 94 /*
95 * all CTRL-W window commands are handled here, called from normal_cmd(). 95 * all CTRL-W window commands are handled here, called from normal_cmd().
96 */ 96 */
97 void 97 void
98 do_window(nchar, Prenum, xchar) 98 do_window(
99 int nchar; 99 int nchar,
100 long Prenum; 100 long Prenum,
101 int xchar; /* extra char from ":wincmd gx" or NUL */ 101 int xchar) /* extra char from ":wincmd gx" or NUL */
102 { 102 {
103 long Prenum1; 103 long Prenum1;
104 win_T *wp; 104 win_T *wp;
105 #if defined(FEAT_SEARCHPATH) || defined(FEAT_FIND_ID) 105 #if defined(FEAT_SEARCHPATH) || defined(FEAT_FIND_ID)
106 char_u *ptr; 106 char_u *ptr;
625 625
626 /* 626 /*
627 * Figure out the address type for ":wnncmd". 627 * Figure out the address type for ":wnncmd".
628 */ 628 */
629 void 629 void
630 get_wincmd_addr_type(arg, eap) 630 get_wincmd_addr_type(char_u *arg, exarg_T *eap)
631 char_u *arg;
632 exarg_T *eap;
633 { 631 {
634 switch (*arg) 632 switch (*arg)
635 { 633 {
636 case 'S': 634 case 'S':
637 case Ctrl_S: 635 case Ctrl_S:
726 break; 724 break;
727 } 725 }
728 } 726 }
729 727
730 static void 728 static void
731 cmd_with_count(cmd, bufp, bufsize, Prenum) 729 cmd_with_count(
732 char *cmd; 730 char *cmd,
733 char_u *bufp; 731 char_u *bufp,
734 size_t bufsize; 732 size_t bufsize,
735 long Prenum; 733 long Prenum)
736 { 734 {
737 size_t len = STRLEN(cmd); 735 size_t len = STRLEN(cmd);
738 736
739 STRCPY(bufp, cmd); 737 STRCPY(bufp, cmd);
740 if (Prenum > 0) 738 if (Prenum > 0)
755 * WSP_HELP: creating the help window, keep layout snapshot 753 * WSP_HELP: creating the help window, keep layout snapshot
756 * 754 *
757 * return FAIL for failure, OK otherwise 755 * return FAIL for failure, OK otherwise
758 */ 756 */
759 int 757 int
760 win_split(size, flags) 758 win_split(int size, int flags)
761 int size;
762 int flags;
763 { 759 {
764 /* When the ":tab" modifier was used open a new tab page instead. */ 760 /* When the ":tab" modifier was used open a new tab page instead. */
765 if (may_open_tabpage() == OK) 761 if (may_open_tabpage() == OK)
766 return OK; 762 return OK;
767 763
788 * When "new_wp" is not NULL: insert this window at the far 784 * When "new_wp" is not NULL: insert this window at the far
789 * top/left/right/bottom. 785 * top/left/right/bottom.
790 * return FAIL for failure, OK otherwise 786 * return FAIL for failure, OK otherwise
791 */ 787 */
792 int 788 int
793 win_split_ins(size, flags, new_wp, dir) 789 win_split_ins(
794 int size; 790 int size,
795 int flags; 791 int flags,
796 win_T *new_wp; 792 win_T *new_wp,
797 int dir; 793 int dir)
798 { 794 {
799 win_T *wp = new_wp; 795 win_T *wp = new_wp;
800 win_T *oldwin; 796 win_T *oldwin;
801 int new_size = size; 797 int new_size = size;
802 int i; 798 int i;
1332 * The windows will both edit the same buffer. 1328 * The windows will both edit the same buffer.
1333 * WSP_NEWLOC may be specified in flags to prevent the location list from 1329 * WSP_NEWLOC may be specified in flags to prevent the location list from
1334 * being copied. 1330 * being copied.
1335 */ 1331 */
1336 static void 1332 static void
1337 win_init(newp, oldp, flags) 1333 win_init(win_T *newp, win_T *oldp, int flags UNUSED)
1338 win_T *newp;
1339 win_T *oldp;
1340 int flags UNUSED;
1341 { 1334 {
1342 int i; 1335 int i;
1343 1336
1344 newp->w_buffer = oldp->w_buffer; 1337 newp->w_buffer = oldp->w_buffer;
1345 #ifdef FEAT_SYN_HL 1338 #ifdef FEAT_SYN_HL
1401 /* 1394 /*
1402 * Initialize window "newp" from window "old". 1395 * Initialize window "newp" from window "old".
1403 * Only the essential things are copied. 1396 * Only the essential things are copied.
1404 */ 1397 */
1405 static void 1398 static void
1406 win_init_some(newp, oldp) 1399 win_init_some(win_T *newp, win_T *oldp)
1407 win_T *newp;
1408 win_T *oldp;
1409 { 1400 {
1410 /* Use the same argument list. */ 1401 /* Use the same argument list. */
1411 newp->w_alist = oldp->w_alist; 1402 newp->w_alist = oldp->w_alist;
1412 ++newp->w_alist->al_refcount; 1403 ++newp->w_alist->al_refcount;
1413 newp->w_arg_idx = oldp->w_arg_idx; 1404 newp->w_arg_idx = oldp->w_arg_idx;
1421 #if defined(FEAT_WINDOWS) || defined(PROTO) 1412 #if defined(FEAT_WINDOWS) || defined(PROTO)
1422 /* 1413 /*
1423 * Check if "win" is a pointer to an existing window. 1414 * Check if "win" is a pointer to an existing window.
1424 */ 1415 */
1425 int 1416 int
1426 win_valid(win) 1417 win_valid(win_T *win)
1427 win_T *win;
1428 { 1418 {
1429 win_T *wp; 1419 win_T *wp;
1430 1420
1431 if (win == NULL) 1421 if (win == NULL)
1432 return FALSE; 1422 return FALSE;
1438 1428
1439 /* 1429 /*
1440 * Return the number of windows. 1430 * Return the number of windows.
1441 */ 1431 */
1442 int 1432 int
1443 win_count() 1433 win_count(void)
1444 { 1434 {
1445 win_T *wp; 1435 win_T *wp;
1446 int count = 0; 1436 int count = 0;
1447 1437
1448 for (wp = firstwin; wp != NULL; wp = wp->w_next) 1438 for (wp = firstwin; wp != NULL; wp = wp->w_next)
1455 * Return actual number of windows on the screen. 1445 * Return actual number of windows on the screen.
1456 * Must be called when there is just one window, filling the whole screen 1446 * Must be called when there is just one window, filling the whole screen
1457 * (excluding the command line). 1447 * (excluding the command line).
1458 */ 1448 */
1459 int 1449 int
1460 make_windows(count, vertical) 1450 make_windows(
1461 int count; 1451 int count,
1462 int vertical UNUSED; /* split windows vertically if TRUE */ 1452 int vertical UNUSED) /* split windows vertically if TRUE */
1463 { 1453 {
1464 int maxcount; 1454 int maxcount;
1465 int todo; 1455 int todo;
1466 1456
1467 #ifdef FEAT_VERTSPLIT 1457 #ifdef FEAT_VERTSPLIT
1527 1517
1528 /* 1518 /*
1529 * Exchange current and next window 1519 * Exchange current and next window
1530 */ 1520 */
1531 static void 1521 static void
1532 win_exchange(Prenum) 1522 win_exchange(long Prenum)
1533 long Prenum;
1534 { 1523 {
1535 frame_T *frp; 1524 frame_T *frp;
1536 frame_T *frp2; 1525 frame_T *frp2;
1537 win_T *wp; 1526 win_T *wp;
1538 win_T *wp2; 1527 win_T *wp2;
1632 /* 1621 /*
1633 * rotate windows: if upwards TRUE the second window becomes the first one 1622 * rotate windows: if upwards TRUE the second window becomes the first one
1634 * if upwards FALSE the first window becomes the second one 1623 * if upwards FALSE the first window becomes the second one
1635 */ 1624 */
1636 static void 1625 static void
1637 win_rotate(upwards, count) 1626 win_rotate(int upwards, int count)
1638 int upwards;
1639 int count;
1640 { 1627 {
1641 win_T *wp1; 1628 win_T *wp1;
1642 win_T *wp2; 1629 win_T *wp2;
1643 frame_T *frp; 1630 frame_T *frp;
1644 int n; 1631 int n;
1721 1708
1722 /* 1709 /*
1723 * Move the current window to the very top/bottom/left/right of the screen. 1710 * Move the current window to the very top/bottom/left/right of the screen.
1724 */ 1711 */
1725 static void 1712 static void
1726 win_totop(size, flags) 1713 win_totop(int size, int flags)
1727 int size;
1728 int flags;
1729 { 1714 {
1730 int dir; 1715 int dir;
1731 int height = curwin->w_height; 1716 int height = curwin->w_height;
1732 1717
1733 if (lastwin == firstwin) 1718 if (lastwin == firstwin)
1761 /* 1746 /*
1762 * Move window "win1" to below/right of "win2" and make "win1" the current 1747 * Move window "win1" to below/right of "win2" and make "win1" the current
1763 * window. Only works within the same frame! 1748 * window. Only works within the same frame!
1764 */ 1749 */
1765 void 1750 void
1766 win_move_after(win1, win2) 1751 win_move_after(win_T *win1, win_T *win2)
1767 win_T *win1, *win2;
1768 { 1752 {
1769 int height; 1753 int height;
1770 1754
1771 /* check if the arguments are reasonable */ 1755 /* check if the arguments are reasonable */
1772 if (win1 == win2) 1756 if (win1 == win2)
1826 * Make all windows the same height. 1810 * Make all windows the same height.
1827 * 'next_curwin' will soon be the current window, make sure it has enough 1811 * 'next_curwin' will soon be the current window, make sure it has enough
1828 * rows. 1812 * rows.
1829 */ 1813 */
1830 void 1814 void
1831 win_equal(next_curwin, current, dir) 1815 win_equal(
1832 win_T *next_curwin; /* pointer to current window to be or NULL */ 1816 win_T *next_curwin, /* pointer to current window to be or NULL */
1833 int current; /* do only frame with current window */ 1817 int current, /* do only frame with current window */
1834 int dir; /* 'v' for vertically, 'h' for horizontally, 1818 int dir) /* 'v' for vertically, 'h' for horizontally,
1835 'b' for both, 0 for using p_ead */ 1819 'b' for both, 0 for using p_ead */
1836 { 1820 {
1837 if (dir == 0) 1821 if (dir == 0)
1838 #ifdef FEAT_VERTSPLIT 1822 #ifdef FEAT_VERTSPLIT
1839 dir = *p_ead; 1823 dir = *p_ead;
1850 * equally over contained frames. 1834 * equally over contained frames.
1851 * The window "next_curwin" (if not NULL) should at least get the size from 1835 * The window "next_curwin" (if not NULL) should at least get the size from
1852 * 'winheight' and 'winwidth' if possible. 1836 * 'winheight' and 'winwidth' if possible.
1853 */ 1837 */
1854 static void 1838 static void
1855 win_equal_rec(next_curwin, current, topfr, dir, col, row, width, height) 1839 win_equal_rec(
1856 win_T *next_curwin; /* pointer to current window to be or NULL */ 1840 win_T *next_curwin, /* pointer to current window to be or NULL */
1857 int current; /* do only frame with current window */ 1841 int current, /* do only frame with current window */
1858 frame_T *topfr; /* frame to set size off */ 1842 frame_T *topfr, /* frame to set size off */
1859 int dir; /* 'v', 'h' or 'b', see win_equal() */ 1843 int dir, /* 'v', 'h' or 'b', see win_equal() */
1860 int col; /* horizontal position for frame */ 1844 int col, /* horizontal position for frame */
1861 int row; /* vertical position for frame */ 1845 int row, /* vertical position for frame */
1862 int width; /* new width of frame */ 1846 int width, /* new width of frame */
1863 int height; /* new height of frame */ 1847 int height) /* new height of frame */
1864 { 1848 {
1865 int n, m; 1849 int n, m;
1866 int extra_sep = 0; 1850 int extra_sep = 0;
1867 int wincount, totwincount = 0; 1851 int wincount, totwincount = 0;
1868 frame_T *fr; 1852 frame_T *fr;
2181 2165
2182 /* 2166 /*
2183 * close all windows for buffer 'buf' 2167 * close all windows for buffer 'buf'
2184 */ 2168 */
2185 void 2169 void
2186 close_windows(buf, keep_curwin) 2170 close_windows(
2187 buf_T *buf; 2171 buf_T *buf,
2188 int keep_curwin; /* don't close "curwin" */ 2172 int keep_curwin) /* don't close "curwin" */
2189 { 2173 {
2190 win_T *wp; 2174 win_T *wp;
2191 tabpage_T *tp, *nexttp; 2175 tabpage_T *tp, *nexttp;
2192 int h = tabline_height(); 2176 int h = tabline_height();
2193 2177
2242 * Return TRUE if the current window is the only window that exists (ignoring 2226 * Return TRUE if the current window is the only window that exists (ignoring
2243 * "aucmd_win"). 2227 * "aucmd_win").
2244 * Returns FALSE if there is a window, possibly in another tab page. 2228 * Returns FALSE if there is a window, possibly in another tab page.
2245 */ 2229 */
2246 static int 2230 static int
2247 last_window() 2231 last_window(void)
2248 { 2232 {
2249 return (one_window() && first_tabpage->tp_next == NULL); 2233 return (one_window() && first_tabpage->tp_next == NULL);
2250 } 2234 }
2251 2235
2252 /* 2236 /*
2253 * Return TRUE if there is only one window other than "aucmd_win" in the 2237 * Return TRUE if there is only one window other than "aucmd_win" in the
2254 * current tab page. 2238 * current tab page.
2255 */ 2239 */
2256 int 2240 int
2257 one_window() 2241 one_window(void)
2258 { 2242 {
2259 #ifdef FEAT_AUTOCMD 2243 #ifdef FEAT_AUTOCMD
2260 win_T *wp; 2244 win_T *wp;
2261 int seen_one = FALSE; 2245 int seen_one = FALSE;
2262 2246
2278 /* 2262 /*
2279 * Close the possibly last window in a tab page. 2263 * Close the possibly last window in a tab page.
2280 * Returns TRUE when the window was closed already. 2264 * Returns TRUE when the window was closed already.
2281 */ 2265 */
2282 static int 2266 static int
2283 close_last_window_tabpage(win, free_buf, prev_curtab) 2267 close_last_window_tabpage(
2284 win_T *win; 2268 win_T *win,
2285 int free_buf; 2269 int free_buf,
2286 tabpage_T *prev_curtab; 2270 tabpage_T *prev_curtab)
2287 { 2271 {
2288 if (firstwin == lastwin) 2272 if (firstwin == lastwin)
2289 { 2273 {
2290 #ifdef FEAT_AUTOCMD 2274 #ifdef FEAT_AUTOCMD
2291 buf_T *old_curbuf = curbuf; 2275 buf_T *old_curbuf = curbuf;
2331 * 2315 *
2332 * Called by :quit, :close, :xit, :wq and findtag(). 2316 * Called by :quit, :close, :xit, :wq and findtag().
2333 * Returns FAIL when the window was not closed. 2317 * Returns FAIL when the window was not closed.
2334 */ 2318 */
2335 int 2319 int
2336 win_close(win, free_buf) 2320 win_close(win_T *win, int free_buf)
2337 win_T *win;
2338 int free_buf;
2339 { 2321 {
2340 win_T *wp; 2322 win_T *wp;
2341 #ifdef FEAT_AUTOCMD 2323 #ifdef FEAT_AUTOCMD
2342 int other_buffer = FALSE; 2324 int other_buffer = FALSE;
2343 #endif 2325 #endif
2555 * thus "tp" may become invalid! 2537 * thus "tp" may become invalid!
2556 * Caller must check if buffer is hidden and whether the tabline needs to be 2538 * Caller must check if buffer is hidden and whether the tabline needs to be
2557 * updated. 2539 * updated.
2558 */ 2540 */
2559 void 2541 void
2560 win_close_othertab(win, free_buf, tp) 2542 win_close_othertab(win_T *win, int free_buf, tabpage_T *tp)
2561 win_T *win;
2562 int free_buf;
2563 tabpage_T *tp;
2564 { 2543 {
2565 win_T *wp; 2544 win_T *wp;
2566 int dir; 2545 int dir;
2567 tabpage_T *ptp = NULL; 2546 tabpage_T *ptp = NULL;
2568 int free_tp = FALSE; 2547 int free_tp = FALSE;
2618 /* 2597 /*
2619 * Free the memory used for a window. 2598 * Free the memory used for a window.
2620 * Returns a pointer to the window that got the freed up space. 2599 * Returns a pointer to the window that got the freed up space.
2621 */ 2600 */
2622 static win_T * 2601 static win_T *
2623 win_free_mem(win, dirp, tp) 2602 win_free_mem(
2624 win_T *win; 2603 win_T *win,
2625 int *dirp; /* set to 'v' or 'h' for direction if 'ea' */ 2604 int *dirp, /* set to 'v' or 'h' for direction if 'ea' */
2626 tabpage_T *tp; /* tab page "win" is in, NULL for current */ 2605 tabpage_T *tp) /* tab page "win" is in, NULL for current */
2627 { 2606 {
2628 frame_T *frp; 2607 frame_T *frp;
2629 win_T *wp; 2608 win_T *wp;
2630 2609
2631 /* Remove the window and its frame from the tree of frames. */ 2610 /* Remove the window and its frame from the tree of frames. */
2642 return wp; 2621 return wp;
2643 } 2622 }
2644 2623
2645 #if defined(EXITFREE) || defined(PROTO) 2624 #if defined(EXITFREE) || defined(PROTO)
2646 void 2625 void
2647 win_free_all() 2626 win_free_all(void)
2648 { 2627 {
2649 int dummy; 2628 int dummy;
2650 2629
2651 # ifdef FEAT_WINDOWS 2630 # ifdef FEAT_WINDOWS
2652 while (first_tabpage->tp_next != NULL) 2631 while (first_tabpage->tp_next != NULL)
2673 /* 2652 /*
2674 * Remove a window and its frame from the tree of frames. 2653 * Remove a window and its frame from the tree of frames.
2675 * Returns a pointer to the window that got the freed up space. 2654 * Returns a pointer to the window that got the freed up space.
2676 */ 2655 */
2677 win_T * 2656 win_T *
2678 winframe_remove(win, dirp, tp) 2657 winframe_remove(
2679 win_T *win; 2658 win_T *win,
2680 int *dirp UNUSED; /* set to 'v' or 'h' for direction if 'ea' */ 2659 int *dirp UNUSED, /* set to 'v' or 'h' for direction if 'ea' */
2681 tabpage_T *tp; /* tab page "win" is in, NULL for current */ 2660 tabpage_T *tp) /* tab page "win" is in, NULL for current */
2682 { 2661 {
2683 frame_T *frp, *frp2, *frp3; 2662 frame_T *frp, *frp2, *frp3;
2684 frame_T *frp_close = win->w_frame; 2663 frame_T *frp_close = win->w_frame;
2685 win_T *wp; 2664 win_T *wp;
2686 2665
2837 * if 'nosplitbelow'/'nosplitleft' the space goes to the window below/right. 2816 * if 'nosplitbelow'/'nosplitleft' the space goes to the window below/right.
2838 * This makes opening a window and closing it immediately keep the same window 2817 * This makes opening a window and closing it immediately keep the same window
2839 * layout. 2818 * layout.
2840 */ 2819 */
2841 static frame_T * 2820 static frame_T *
2842 win_altframe(win, tp) 2821 win_altframe(
2843 win_T *win; 2822 win_T *win,
2844 tabpage_T *tp; /* tab page "win" is in, NULL for current */ 2823 tabpage_T *tp) /* tab page "win" is in, NULL for current */
2845 { 2824 {
2846 frame_T *frp; 2825 frame_T *frp;
2847 int b; 2826 int b;
2848 2827
2849 if (tp == NULL ? firstwin == lastwin : tp->tp_firstwin == tp->tp_lastwin) 2828 if (tp == NULL ? firstwin == lastwin : tp->tp_firstwin == tp->tp_lastwin)
2864 2843
2865 /* 2844 /*
2866 * Return the tabpage that will be used if the current one is closed. 2845 * Return the tabpage that will be used if the current one is closed.
2867 */ 2846 */
2868 static tabpage_T * 2847 static tabpage_T *
2869 alt_tabpage() 2848 alt_tabpage(void)
2870 { 2849 {
2871 tabpage_T *tp; 2850 tabpage_T *tp;
2872 2851
2873 /* Use the next tab page if possible. */ 2852 /* Use the next tab page if possible. */
2874 if (curtab->tp_next != NULL) 2853 if (curtab->tp_next != NULL)
2882 2861
2883 /* 2862 /*
2884 * Find the left-upper window in frame "frp". 2863 * Find the left-upper window in frame "frp".
2885 */ 2864 */
2886 static win_T * 2865 static win_T *
2887 frame2win(frp) 2866 frame2win(frame_T *frp)
2888 frame_T *frp;
2889 { 2867 {
2890 while (frp->fr_win == NULL) 2868 while (frp->fr_win == NULL)
2891 frp = frp->fr_child; 2869 frp = frp->fr_child;
2892 return frp->fr_win; 2870 return frp->fr_win;
2893 } 2871 }
2894 2872
2895 /* 2873 /*
2896 * Return TRUE if frame "frp" contains window "wp". 2874 * Return TRUE if frame "frp" contains window "wp".
2897 */ 2875 */
2898 static int 2876 static int
2899 frame_has_win(frp, wp) 2877 frame_has_win(frame_T *frp, win_T *wp)
2900 frame_T *frp;
2901 win_T *wp;
2902 { 2878 {
2903 frame_T *p; 2879 frame_T *p;
2904 2880
2905 if (frp->fr_layout == FR_LEAF) 2881 if (frp->fr_layout == FR_LEAF)
2906 return frp->fr_win == wp; 2882 return frp->fr_win == wp;
2914 /* 2890 /*
2915 * Set a new height for a frame. Recursively sets the height for contained 2891 * Set a new height for a frame. Recursively sets the height for contained
2916 * frames and windows. Caller must take care of positions. 2892 * frames and windows. Caller must take care of positions.
2917 */ 2893 */
2918 static void 2894 static void
2919 frame_new_height(topfrp, height, topfirst, wfh) 2895 frame_new_height(
2920 frame_T *topfrp; 2896 frame_T *topfrp,
2921 int height; 2897 int height,
2922 int topfirst; /* resize topmost contained frame first */ 2898 int topfirst, /* resize topmost contained frame first */
2923 int wfh; /* obey 'winfixheight' when there is a choice; 2899 int wfh) /* obey 'winfixheight' when there is a choice;
2924 may cause the height not to be set */ 2900 may cause the height not to be set */
2925 { 2901 {
2926 frame_T *frp; 2902 frame_T *frp;
2927 int extra_lines; 2903 int extra_lines;
2928 int h; 2904 int h;
3025 /* 3001 /*
3026 * Return TRUE if height of frame "frp" should not be changed because of 3002 * Return TRUE if height of frame "frp" should not be changed because of
3027 * the 'winfixheight' option. 3003 * the 'winfixheight' option.
3028 */ 3004 */
3029 static int 3005 static int
3030 frame_fixed_height(frp) 3006 frame_fixed_height(frame_T *frp)
3031 frame_T *frp;
3032 { 3007 {
3033 /* frame with one window: fixed height if 'winfixheight' set. */ 3008 /* frame with one window: fixed height if 'winfixheight' set. */
3034 if (frp->fr_win != NULL) 3009 if (frp->fr_win != NULL)
3035 return frp->fr_win->w_p_wfh; 3010 return frp->fr_win->w_p_wfh;
3036 3011
3056 /* 3031 /*
3057 * Return TRUE if width of frame "frp" should not be changed because of 3032 * Return TRUE if width of frame "frp" should not be changed because of
3058 * the 'winfixwidth' option. 3033 * the 'winfixwidth' option.
3059 */ 3034 */
3060 static int 3035 static int
3061 frame_fixed_width(frp) 3036 frame_fixed_width(frame_T *frp)
3062 frame_T *frp;
3063 { 3037 {
3064 /* frame with one window: fixed width if 'winfixwidth' set. */ 3038 /* frame with one window: fixed width if 'winfixwidth' set. */
3065 if (frp->fr_win != NULL) 3039 if (frp->fr_win != NULL)
3066 return frp->fr_win->w_p_wfw; 3040 return frp->fr_win->w_p_wfw;
3067 3041
3086 /* 3060 /*
3087 * Add a status line to windows at the bottom of "frp". 3061 * Add a status line to windows at the bottom of "frp".
3088 * Note: Does not check if there is room! 3062 * Note: Does not check if there is room!
3089 */ 3063 */
3090 static void 3064 static void
3091 frame_add_statusline(frp) 3065 frame_add_statusline(frame_T *frp)
3092 frame_T *frp;
3093 { 3066 {
3094 win_T *wp; 3067 win_T *wp;
3095 3068
3096 if (frp->fr_layout == FR_LEAF) 3069 if (frp->fr_layout == FR_LEAF)
3097 { 3070 {
3121 /* 3094 /*
3122 * Set width of a frame. Handles recursively going through contained frames. 3095 * Set width of a frame. Handles recursively going through contained frames.
3123 * May remove separator line for windows at the right side (for win_close()). 3096 * May remove separator line for windows at the right side (for win_close()).
3124 */ 3097 */
3125 static void 3098 static void
3126 frame_new_width(topfrp, width, leftfirst, wfw) 3099 frame_new_width(
3127 frame_T *topfrp; 3100 frame_T *topfrp,
3128 int width; 3101 int width,
3129 int leftfirst; /* resize leftmost contained frame first */ 3102 int leftfirst, /* resize leftmost contained frame first */
3130 int wfw; /* obey 'winfixwidth' when there is a choice; 3103 int wfw) /* obey 'winfixwidth' when there is a choice;
3131 may cause the width not to be set */ 3104 may cause the width not to be set */
3132 { 3105 {
3133 frame_T *frp; 3106 frame_T *frp;
3134 int extra_cols; 3107 int extra_cols;
3135 int w; 3108 int w;
3236 /* 3209 /*
3237 * Add the vertical separator to windows at the right side of "frp". 3210 * Add the vertical separator to windows at the right side of "frp".
3238 * Note: Does not check if there is room! 3211 * Note: Does not check if there is room!
3239 */ 3212 */
3240 static void 3213 static void
3241 frame_add_vsep(frp) 3214 frame_add_vsep(frame_T *frp)
3242 frame_T *frp;
3243 { 3215 {
3244 win_T *wp; 3216 win_T *wp;
3245 3217
3246 if (frp->fr_layout == FR_LEAF) 3218 if (frp->fr_layout == FR_LEAF)
3247 { 3219 {
3271 3243
3272 /* 3244 /*
3273 * Set frame width from the window it contains. 3245 * Set frame width from the window it contains.
3274 */ 3246 */
3275 static void 3247 static void
3276 frame_fix_width(wp) 3248 frame_fix_width(win_T *wp)
3277 win_T *wp;
3278 { 3249 {
3279 wp->w_frame->fr_width = wp->w_width + wp->w_vsep_width; 3250 wp->w_frame->fr_width = wp->w_width + wp->w_vsep_width;
3280 } 3251 }
3281 #endif 3252 #endif
3282 3253
3283 /* 3254 /*
3284 * Set frame height from the window it contains. 3255 * Set frame height from the window it contains.
3285 */ 3256 */
3286 static void 3257 static void
3287 frame_fix_height(wp) 3258 frame_fix_height(win_T *wp)
3288 win_T *wp;
3289 { 3259 {
3290 wp->w_frame->fr_height = wp->w_height + wp->w_status_height; 3260 wp->w_frame->fr_height = wp->w_height + wp->w_status_height;
3291 } 3261 }
3292 3262
3293 /* 3263 /*
3296 * When "next_curwin" isn't NULL, use p_wh for this window. 3266 * When "next_curwin" isn't NULL, use p_wh for this window.
3297 * When "next_curwin" is NOWIN, don't use at least one line for the current 3267 * When "next_curwin" is NOWIN, don't use at least one line for the current
3298 * window. 3268 * window.
3299 */ 3269 */
3300 static int 3270 static int
3301 frame_minheight(topfrp, next_curwin) 3271 frame_minheight(frame_T *topfrp, win_T *next_curwin)
3302 frame_T *topfrp;
3303 win_T *next_curwin;
3304 { 3272 {
3305 frame_T *frp; 3273 frame_T *frp;
3306 int m; 3274 int m;
3307 #ifdef FEAT_VERTSPLIT 3275 #ifdef FEAT_VERTSPLIT
3308 int n; 3276 int n;
3351 * When "next_curwin" isn't NULL, use p_wiw for this window. 3319 * When "next_curwin" isn't NULL, use p_wiw for this window.
3352 * When "next_curwin" is NOWIN, don't use at least one column for the current 3320 * When "next_curwin" is NOWIN, don't use at least one column for the current
3353 * window. 3321 * window.
3354 */ 3322 */
3355 static int 3323 static int
3356 frame_minwidth(topfrp, next_curwin) 3324 frame_minwidth(
3357 frame_T *topfrp; 3325 frame_T *topfrp,
3358 win_T *next_curwin; /* use p_wh and p_wiw for next_curwin */ 3326 win_T *next_curwin) /* use p_wh and p_wiw for next_curwin */
3359 { 3327 {
3360 frame_T *frp; 3328 frame_T *frp;
3361 int m, n; 3329 int m, n;
3362 3330
3363 if (topfrp->fr_win != NULL) 3331 if (topfrp->fr_win != NULL)
3403 * used and the buffer was modified. 3371 * used and the buffer was modified.
3404 * 3372 *
3405 * Used by ":bdel" and ":only". 3373 * Used by ":bdel" and ":only".
3406 */ 3374 */
3407 void 3375 void
3408 close_others(message, forceit) 3376 close_others(
3409 int message; 3377 int message,
3410 int forceit; /* always hide all other windows */ 3378 int forceit) /* always hide all other windows */
3411 { 3379 {
3412 win_T *wp; 3380 win_T *wp;
3413 win_T *nextwp; 3381 win_T *nextwp;
3414 int r; 3382 int r;
3415 3383
3471 /* 3439 /*
3472 * Init the current window "curwin". 3440 * Init the current window "curwin".
3473 * Called when a new file is being edited. 3441 * Called when a new file is being edited.
3474 */ 3442 */
3475 void 3443 void
3476 curwin_init() 3444 curwin_init(void)
3477 { 3445 {
3478 win_init_empty(curwin); 3446 win_init_empty(curwin);
3479 } 3447 }
3480 3448
3481 void 3449 void
3482 win_init_empty(wp) 3450 win_init_empty(win_T *wp)
3483 win_T *wp;
3484 { 3451 {
3485 redraw_win_later(wp, NOT_VALID); 3452 redraw_win_later(wp, NOT_VALID);
3486 wp->w_lines_valid = 0; 3453 wp->w_lines_valid = 0;
3487 wp->w_cursor.lnum = 1; 3454 wp->w_cursor.lnum = 1;
3488 wp->w_curswant = wp->w_cursor.col = 0; 3455 wp->w_curswant = wp->w_cursor.col = 0;
3513 * Allocate the first window and put an empty buffer in it. 3480 * Allocate the first window and put an empty buffer in it.
3514 * Called from main(). 3481 * Called from main().
3515 * Return FAIL when something goes wrong (out of memory). 3482 * Return FAIL when something goes wrong (out of memory).
3516 */ 3483 */
3517 int 3484 int
3518 win_alloc_first() 3485 win_alloc_first(void)
3519 { 3486 {
3520 if (win_alloc_firstwin(NULL) == FAIL) 3487 if (win_alloc_firstwin(NULL) == FAIL)
3521 return FAIL; 3488 return FAIL;
3522 3489
3523 #ifdef FEAT_WINDOWS 3490 #ifdef FEAT_WINDOWS
3535 /* 3502 /*
3536 * Init "aucmd_win". This can only be done after the first 3503 * Init "aucmd_win". This can only be done after the first
3537 * window is fully initialized, thus it can't be in win_alloc_first(). 3504 * window is fully initialized, thus it can't be in win_alloc_first().
3538 */ 3505 */
3539 void 3506 void
3540 win_alloc_aucmd_win() 3507 win_alloc_aucmd_win(void)
3541 { 3508 {
3542 aucmd_win = win_alloc(NULL, TRUE); 3509 aucmd_win = win_alloc(NULL, TRUE);
3543 if (aucmd_win != NULL) 3510 if (aucmd_win != NULL)
3544 { 3511 {
3545 win_init_some(aucmd_win, curwin); 3512 win_init_some(aucmd_win, curwin);
3555 * When "oldwin" is not NULL copy info from it to the new window (only with 3522 * When "oldwin" is not NULL copy info from it to the new window (only with
3556 * FEAT_WINDOWS). 3523 * FEAT_WINDOWS).
3557 * Return FAIL when something goes wrong (out of memory). 3524 * Return FAIL when something goes wrong (out of memory).
3558 */ 3525 */
3559 static int 3526 static int
3560 win_alloc_firstwin(oldwin) 3527 win_alloc_firstwin(win_T *oldwin)
3561 win_T *oldwin;
3562 { 3528 {
3563 curwin = win_alloc(NULL, FALSE); 3529 curwin = win_alloc(NULL, FALSE);
3564 if (oldwin == NULL) 3530 if (oldwin == NULL)
3565 { 3531 {
3566 /* Very first window, need to create an empty buffer for it and 3532 /* Very first window, need to create an empty buffer for it and
3620 3586
3621 /* 3587 /*
3622 * Initialize the window and frame size to the maximum. 3588 * Initialize the window and frame size to the maximum.
3623 */ 3589 */
3624 void 3590 void
3625 win_init_size() 3591 win_init_size(void)
3626 { 3592 {
3627 firstwin->w_height = ROWS_AVAIL; 3593 firstwin->w_height = ROWS_AVAIL;
3628 topframe->fr_height = ROWS_AVAIL; 3594 topframe->fr_height = ROWS_AVAIL;
3629 #ifdef FEAT_VERTSPLIT 3595 #ifdef FEAT_VERTSPLIT
3630 firstwin->w_width = Columns; 3596 firstwin->w_width = Columns;
3637 /* 3603 /*
3638 * Allocate a new tabpage_T and init the values. 3604 * Allocate a new tabpage_T and init the values.
3639 * Returns NULL when out of memory. 3605 * Returns NULL when out of memory.
3640 */ 3606 */
3641 static tabpage_T * 3607 static tabpage_T *
3642 alloc_tabpage() 3608 alloc_tabpage(void)
3643 { 3609 {
3644 tabpage_T *tp; 3610 tabpage_T *tp;
3645 # ifdef FEAT_GUI 3611 # ifdef FEAT_GUI
3646 int i; 3612 int i;
3647 # endif 3613 # endif
3673 3639
3674 return tp; 3640 return tp;
3675 } 3641 }
3676 3642
3677 void 3643 void
3678 free_tabpage(tp) 3644 free_tabpage(tabpage_T *tp)
3679 tabpage_T *tp;
3680 { 3645 {
3681 int idx; 3646 int idx;
3682 3647
3683 # ifdef FEAT_DIFF 3648 # ifdef FEAT_DIFF
3684 diff_clear(tp); 3649 diff_clear(tp);
3708 * When "after" is 0 put it just after the current Tab page. 3673 * When "after" is 0 put it just after the current Tab page.
3709 * Otherwise put it just before tab page "after". 3674 * Otherwise put it just before tab page "after".
3710 * Return FAIL or OK. 3675 * Return FAIL or OK.
3711 */ 3676 */
3712 int 3677 int
3713 win_new_tabpage(after) 3678 win_new_tabpage(int after)
3714 int after;
3715 { 3679 {
3716 tabpage_T *tp = curtab; 3680 tabpage_T *tp = curtab;
3717 tabpage_T *newtp; 3681 tabpage_T *newtp;
3718 int n; 3682 int n;
3719 3683
3782 * Open a new tab page if ":tab cmd" was used. It will edit the same buffer, 3746 * Open a new tab page if ":tab cmd" was used. It will edit the same buffer,
3783 * like with ":split". 3747 * like with ":split".
3784 * Returns OK if a new tab page was created, FAIL otherwise. 3748 * Returns OK if a new tab page was created, FAIL otherwise.
3785 */ 3749 */
3786 int 3750 int
3787 may_open_tabpage() 3751 may_open_tabpage(void)
3788 { 3752 {
3789 int n = (cmdmod.tab == 0) ? postponed_split_tab : cmdmod.tab; 3753 int n = (cmdmod.tab == 0) ? postponed_split_tab : cmdmod.tab;
3790 3754
3791 if (n != 0) 3755 if (n != 0)
3792 { 3756 {
3800 /* 3764 /*
3801 * Create up to "maxcount" tabpages with empty windows. 3765 * Create up to "maxcount" tabpages with empty windows.
3802 * Returns the number of resulting tab pages. 3766 * Returns the number of resulting tab pages.
3803 */ 3767 */
3804 int 3768 int
3805 make_tabpages(maxcount) 3769 make_tabpages(int maxcount)
3806 int maxcount;
3807 { 3770 {
3808 int count = maxcount; 3771 int count = maxcount;
3809 int todo; 3772 int todo;
3810 3773
3811 /* Limit to 'tabpagemax' tabs. */ 3774 /* Limit to 'tabpagemax' tabs. */
3834 3797
3835 /* 3798 /*
3836 * Return TRUE when "tpc" points to a valid tab page. 3799 * Return TRUE when "tpc" points to a valid tab page.
3837 */ 3800 */
3838 int 3801 int
3839 valid_tabpage(tpc) 3802 valid_tabpage(tabpage_T *tpc)
3840 tabpage_T *tpc;
3841 { 3803 {
3842 tabpage_T *tp; 3804 tabpage_T *tp;
3843 3805
3844 for (tp = first_tabpage; tp != NULL; tp = tp->tp_next) 3806 for (tp = first_tabpage; tp != NULL; tp = tp->tp_next)
3845 if (tp == tpc) 3807 if (tp == tpc)
3849 3811
3850 /* 3812 /*
3851 * Find tab page "n" (first one is 1). Returns NULL when not found. 3813 * Find tab page "n" (first one is 1). Returns NULL when not found.
3852 */ 3814 */
3853 tabpage_T * 3815 tabpage_T *
3854 find_tabpage(n) 3816 find_tabpage(int n)
3855 int n;
3856 { 3817 {
3857 tabpage_T *tp; 3818 tabpage_T *tp;
3858 int i = 1; 3819 int i = 1;
3859 3820
3860 for (tp = first_tabpage; tp != NULL && i != n; tp = tp->tp_next) 3821 for (tp = first_tabpage; tp != NULL && i != n; tp = tp->tp_next)
3865 /* 3826 /*
3866 * Get index of tab page "tp". First one has index 1. 3827 * Get index of tab page "tp". First one has index 1.
3867 * When not found returns number of tab pages plus one. 3828 * When not found returns number of tab pages plus one.
3868 */ 3829 */
3869 int 3830 int
3870 tabpage_index(ftp) 3831 tabpage_index(tabpage_T *ftp)
3871 tabpage_T *ftp;
3872 { 3832 {
3873 int i = 1; 3833 int i = 1;
3874 tabpage_T *tp; 3834 tabpage_T *tp;
3875 3835
3876 for (tp = first_tabpage; tp != NULL && tp != ftp; tp = tp->tp_next) 3836 for (tp = first_tabpage; tp != NULL && tp != ftp; tp = tp->tp_next)
3883 * When autocommands change "curtab" we don't leave the tab page and return 3843 * When autocommands change "curtab" we don't leave the tab page and return
3884 * FAIL. 3844 * FAIL.
3885 * Careful: When OK is returned need to get a new tab page very very soon! 3845 * Careful: When OK is returned need to get a new tab page very very soon!
3886 */ 3846 */
3887 static int 3847 static int
3888 leave_tabpage(new_curbuf, trigger_leave_autocmds) 3848 leave_tabpage(
3889 buf_T *new_curbuf UNUSED; /* what is going to be the new curbuf, 3849 buf_T *new_curbuf UNUSED, /* what is going to be the new curbuf,
3890 NULL if unknown */ 3850 NULL if unknown */
3891 int trigger_leave_autocmds UNUSED; 3851 int trigger_leave_autocmds UNUSED)
3892 { 3852 {
3893 tabpage_T *tp = curtab; 3853 tabpage_T *tp = curtab;
3894 3854
3895 reset_VIsual_and_resel(); /* stop Visual mode */ 3855 reset_VIsual_and_resel(); /* stop Visual mode */
3896 #ifdef FEAT_AUTOCMD 3856 #ifdef FEAT_AUTOCMD
3931 * Only to be used after leave_tabpage() or freeing the current tab page. 3891 * Only to be used after leave_tabpage() or freeing the current tab page.
3932 * Only trigger *Enter autocommands when trigger_enter_autocmds is TRUE. 3892 * Only trigger *Enter autocommands when trigger_enter_autocmds is TRUE.
3933 * Only trigger *Leave autocommands when trigger_leave_autocmds is TRUE. 3893 * Only trigger *Leave autocommands when trigger_leave_autocmds is TRUE.
3934 */ 3894 */
3935 static void 3895 static void
3936 enter_tabpage(tp, old_curbuf, trigger_enter_autocmds, trigger_leave_autocmds) 3896 enter_tabpage(
3937 tabpage_T *tp; 3897 tabpage_T *tp,
3938 buf_T *old_curbuf UNUSED; 3898 buf_T *old_curbuf UNUSED,
3939 int trigger_enter_autocmds UNUSED; 3899 int trigger_enter_autocmds UNUSED,
3940 int trigger_leave_autocmds UNUSED; 3900 int trigger_leave_autocmds UNUSED)
3941 { 3901 {
3942 int old_off = tp->tp_firstwin->w_winrow; 3902 int old_off = tp->tp_firstwin->w_winrow;
3943 win_T *next_prevwin = tp->tp_prevwin; 3903 win_T *next_prevwin = tp->tp_prevwin;
3944 3904
3945 curtab = tp; 3905 curtab = tp;
4000 /* 3960 /*
4001 * Go to tab page "n". For ":tab N" and "Ngt". 3961 * Go to tab page "n". For ":tab N" and "Ngt".
4002 * When "n" is 9999 go to the last tab page. 3962 * When "n" is 9999 go to the last tab page.
4003 */ 3963 */
4004 void 3964 void
4005 goto_tabpage(n) 3965 goto_tabpage(int n)
4006 int n;
4007 { 3966 {
4008 tabpage_T *tp; 3967 tabpage_T *tp;
4009 tabpage_T *ttp; 3968 tabpage_T *ttp;
4010 int i; 3969 int i;
4011 3970
4080 * Only trigger *Enter autocommands when trigger_enter_autocmds is TRUE. 4039 * Only trigger *Enter autocommands when trigger_enter_autocmds is TRUE.
4081 * Only trigger *Leave autocommands when trigger_leave_autocmds is TRUE. 4040 * Only trigger *Leave autocommands when trigger_leave_autocmds is TRUE.
4082 * Note: doesn't update the GUI tab. 4041 * Note: doesn't update the GUI tab.
4083 */ 4042 */
4084 void 4043 void
4085 goto_tabpage_tp(tp, trigger_enter_autocmds, trigger_leave_autocmds) 4044 goto_tabpage_tp(
4086 tabpage_T *tp; 4045 tabpage_T *tp,
4087 int trigger_enter_autocmds; 4046 int trigger_enter_autocmds,
4088 int trigger_leave_autocmds; 4047 int trigger_leave_autocmds)
4089 { 4048 {
4090 /* Don't repeat a message in another tab page. */ 4049 /* Don't repeat a message in another tab page. */
4091 set_keep_msg(NULL, 0); 4050 set_keep_msg(NULL, 0);
4092 4051
4093 if (tp != curtab && leave_tabpage(tp->tp_curwin->w_buffer, 4052 if (tp != curtab && leave_tabpage(tp->tp_curwin->w_buffer,
4105 /* 4064 /*
4106 * Enter window "wp" in tab page "tp". 4065 * Enter window "wp" in tab page "tp".
4107 * Also updates the GUI tab. 4066 * Also updates the GUI tab.
4108 */ 4067 */
4109 void 4068 void
4110 goto_tabpage_win(tp, wp) 4069 goto_tabpage_win(tabpage_T *tp, win_T *wp)
4111 tabpage_T *tp;
4112 win_T *wp;
4113 { 4070 {
4114 goto_tabpage_tp(tp, TRUE, TRUE); 4071 goto_tabpage_tp(tp, TRUE, TRUE);
4115 if (curtab == tp && win_valid(wp)) 4072 if (curtab == tp && win_valid(wp))
4116 { 4073 {
4117 win_enter(wp, TRUE); 4074 win_enter(wp, TRUE);
4124 4081
4125 /* 4082 /*
4126 * Move the current tab page to after tab page "nr". 4083 * Move the current tab page to after tab page "nr".
4127 */ 4084 */
4128 void 4085 void
4129 tabpage_move(nr) 4086 tabpage_move(int nr)
4130 int nr;
4131 { 4087 {
4132 int n = 1; 4088 int n = 1;
4133 tabpage_T *tp, *tp_dst; 4089 tabpage_T *tp, *tp_dst;
4134 4090
4135 if (first_tabpage->tp_next == NULL) 4091 if (first_tabpage->tp_next == NULL)
4180 * changing windows so we can yank the selection into the '*' register. 4136 * changing windows so we can yank the selection into the '*' register.
4181 * When jumping to another window on the same buffer, adjust its cursor 4137 * When jumping to another window on the same buffer, adjust its cursor
4182 * position to keep the same Visual area. 4138 * position to keep the same Visual area.
4183 */ 4139 */
4184 void 4140 void
4185 win_goto(wp) 4141 win_goto(win_T *wp)
4186 win_T *wp;
4187 { 4142 {
4188 #ifdef FEAT_CONCEAL 4143 #ifdef FEAT_CONCEAL
4189 win_T *owp = curwin; 4144 win_T *owp = curwin;
4190 #endif 4145 #endif
4191 4146
4222 #if defined(FEAT_PERL) || defined(PROTO) 4177 #if defined(FEAT_PERL) || defined(PROTO)
4223 /* 4178 /*
4224 * Find window number "winnr" (counting top to bottom). 4179 * Find window number "winnr" (counting top to bottom).
4225 */ 4180 */
4226 win_T * 4181 win_T *
4227 win_find_nr(winnr) 4182 win_find_nr(int winnr)
4228 int winnr;
4229 { 4183 {
4230 win_T *wp; 4184 win_T *wp;
4231 4185
4232 # ifdef FEAT_WINDOWS 4186 # ifdef FEAT_WINDOWS
4233 for (wp = firstwin; wp != NULL; wp = wp->w_next) 4187 for (wp = firstwin; wp != NULL; wp = wp->w_next)
4244 || defined(PROTO) 4198 || defined(PROTO)
4245 /* 4199 /*
4246 * Find the tabpage for window "win". 4200 * Find the tabpage for window "win".
4247 */ 4201 */
4248 tabpage_T * 4202 tabpage_T *
4249 win_find_tabpage(win) 4203 win_find_tabpage(win_T *win)
4250 win_T *win;
4251 { 4204 {
4252 win_T *wp; 4205 win_T *wp;
4253 tabpage_T *tp; 4206 tabpage_T *tp;
4254 4207
4255 for (tp = first_tabpage; tp != NULL; tp = tp->tp_next) 4208 for (tp = first_tabpage; tp != NULL; tp = tp->tp_next)
4264 #ifdef FEAT_VERTSPLIT 4217 #ifdef FEAT_VERTSPLIT
4265 /* 4218 /*
4266 * Move to window above or below "count" times. 4219 * Move to window above or below "count" times.
4267 */ 4220 */
4268 static void 4221 static void
4269 win_goto_ver(up, count) 4222 win_goto_ver(
4270 int up; /* TRUE to go to win above */ 4223 int up, /* TRUE to go to win above */
4271 long count; 4224 long count)
4272 { 4225 {
4273 frame_T *fr; 4226 frame_T *fr;
4274 frame_T *nfr; 4227 frame_T *nfr;
4275 frame_T *foundfr; 4228 frame_T *foundfr;
4276 4229
4327 4280
4328 /* 4281 /*
4329 * Move to left or right window. 4282 * Move to left or right window.
4330 */ 4283 */
4331 static void 4284 static void
4332 win_goto_hor(left, count) 4285 win_goto_hor(
4333 int left; /* TRUE to go to left win */ 4286 int left, /* TRUE to go to left win */
4334 long count; 4287 long count)
4335 { 4288 {
4336 frame_T *fr; 4289 frame_T *fr;
4337 frame_T *nfr; 4290 frame_T *nfr;
4338 frame_T *foundfr; 4291 frame_T *foundfr;
4339 4292
4391 4344
4392 /* 4345 /*
4393 * Make window "wp" the current window. 4346 * Make window "wp" the current window.
4394 */ 4347 */
4395 void 4348 void
4396 win_enter(wp, undo_sync) 4349 win_enter(win_T *wp, int undo_sync)
4397 win_T *wp;
4398 int undo_sync;
4399 { 4350 {
4400 win_enter_ext(wp, undo_sync, FALSE, TRUE, TRUE); 4351 win_enter_ext(wp, undo_sync, FALSE, TRUE, TRUE);
4401 } 4352 }
4402 4353
4403 /* 4354 /*
4404 * Make window wp the current window. 4355 * Make window wp the current window.
4405 * Can be called with "curwin_invalid" TRUE, which means that curwin has just 4356 * Can be called with "curwin_invalid" TRUE, which means that curwin has just
4406 * been closed and isn't valid. 4357 * been closed and isn't valid.
4407 */ 4358 */
4408 static void 4359 static void
4409 win_enter_ext(wp, undo_sync, curwin_invalid, trigger_enter_autocmds, trigger_leave_autocmds) 4360 win_enter_ext(
4410 win_T *wp; 4361 win_T *wp,
4411 int undo_sync; 4362 int undo_sync,
4412 int curwin_invalid; 4363 int curwin_invalid,
4413 int trigger_enter_autocmds UNUSED; 4364 int trigger_enter_autocmds UNUSED,
4414 int trigger_leave_autocmds UNUSED; 4365 int trigger_leave_autocmds UNUSED)
4415 { 4366 {
4416 #ifdef FEAT_AUTOCMD 4367 #ifdef FEAT_AUTOCMD
4417 int other_buffer = FALSE; 4368 int other_buffer = FALSE;
4418 #endif 4369 #endif
4419 4370
4537 /* 4488 /*
4538 * Jump to the first open window that contains buffer "buf", if one exists. 4489 * Jump to the first open window that contains buffer "buf", if one exists.
4539 * Returns a pointer to the window found, otherwise NULL. 4490 * Returns a pointer to the window found, otherwise NULL.
4540 */ 4491 */
4541 win_T * 4492 win_T *
4542 buf_jump_open_win(buf) 4493 buf_jump_open_win(buf_T *buf)
4543 buf_T *buf;
4544 { 4494 {
4545 win_T *wp = NULL; 4495 win_T *wp = NULL;
4546 4496
4547 if (curwin->w_buffer == buf) 4497 if (curwin->w_buffer == buf)
4548 wp = curwin; 4498 wp = curwin;
4561 * Jump to the first open window in any tab page that contains buffer "buf", 4511 * Jump to the first open window in any tab page that contains buffer "buf",
4562 * if one exists. 4512 * if one exists.
4563 * Returns a pointer to the window found, otherwise NULL. 4513 * Returns a pointer to the window found, otherwise NULL.
4564 */ 4514 */
4565 win_T * 4515 win_T *
4566 buf_jump_open_tab(buf) 4516 buf_jump_open_tab(buf_T *buf)
4567 buf_T *buf;
4568 { 4517 {
4569 win_T *wp = buf_jump_open_win(buf); 4518 win_T *wp = buf_jump_open_win(buf);
4570 # ifdef FEAT_WINDOWS 4519 # ifdef FEAT_WINDOWS
4571 tabpage_T *tp; 4520 tabpage_T *tp;
4572 4521
4595 /* 4544 /*
4596 * Allocate a window structure and link it in the window list when "hidden" is 4545 * Allocate a window structure and link it in the window list when "hidden" is
4597 * FALSE. 4546 * FALSE.
4598 */ 4547 */
4599 static win_T * 4548 static win_T *
4600 win_alloc(after, hidden) 4549 win_alloc(win_T *after UNUSED, int hidden UNUSED)
4601 win_T *after UNUSED;
4602 int hidden UNUSED;
4603 { 4550 {
4604 win_T *new_wp; 4551 win_T *new_wp;
4605 4552
4606 /* 4553 /*
4607 * allocate window structure and linesizes arrays 4554 * allocate window structure and linesizes arrays
4687 4634
4688 /* 4635 /*
4689 * Remove window 'wp' from the window list and free the structure. 4636 * Remove window 'wp' from the window list and free the structure.
4690 */ 4637 */
4691 static void 4638 static void
4692 win_free(wp, tp) 4639 win_free(
4693 win_T *wp; 4640 win_T *wp,
4694 tabpage_T *tp; /* tab page "win" is in, NULL for current */ 4641 tabpage_T *tp) /* tab page "win" is in, NULL for current */
4695 { 4642 {
4696 int i; 4643 int i;
4697 buf_T *buf; 4644 buf_T *buf;
4698 wininfo_T *wip; 4645 wininfo_T *wip;
4699 4646
4808 4755
4809 /* 4756 /*
4810 * Append window "wp" in the window list after window "after". 4757 * Append window "wp" in the window list after window "after".
4811 */ 4758 */
4812 void 4759 void
4813 win_append(after, wp) 4760 win_append(win_T *after, win_T *wp)
4814 win_T *after, *wp;
4815 { 4761 {
4816 win_T *before; 4762 win_T *before;
4817 4763
4818 if (after == NULL) /* after NULL is in front of the first */ 4764 if (after == NULL) /* after NULL is in front of the first */
4819 before = firstwin; 4765 before = firstwin;
4834 4780
4835 /* 4781 /*
4836 * Remove a window from the window list. 4782 * Remove a window from the window list.
4837 */ 4783 */
4838 void 4784 void
4839 win_remove(wp, tp) 4785 win_remove(
4840 win_T *wp; 4786 win_T *wp,
4841 tabpage_T *tp; /* tab page "win" is in, NULL for current */ 4787 tabpage_T *tp) /* tab page "win" is in, NULL for current */
4842 { 4788 {
4843 if (wp->w_prev != NULL) 4789 if (wp->w_prev != NULL)
4844 wp->w_prev->w_next = wp->w_next; 4790 wp->w_prev->w_next = wp->w_next;
4845 else if (tp == NULL) 4791 else if (tp == NULL)
4846 firstwin = wp->w_next; 4792 firstwin = wp->w_next;
4856 4802
4857 /* 4803 /*
4858 * Append frame "frp" in a frame list after frame "after". 4804 * Append frame "frp" in a frame list after frame "after".
4859 */ 4805 */
4860 static void 4806 static void
4861 frame_append(after, frp) 4807 frame_append(frame_T *after, frame_T *frp)
4862 frame_T *after, *frp;
4863 { 4808 {
4864 frp->fr_next = after->fr_next; 4809 frp->fr_next = after->fr_next;
4865 after->fr_next = frp; 4810 after->fr_next = frp;
4866 if (frp->fr_next != NULL) 4811 if (frp->fr_next != NULL)
4867 frp->fr_next->fr_prev = frp; 4812 frp->fr_next->fr_prev = frp;
4870 4815
4871 /* 4816 /*
4872 * Insert frame "frp" in a frame list before frame "before". 4817 * Insert frame "frp" in a frame list before frame "before".
4873 */ 4818 */
4874 static void 4819 static void
4875 frame_insert(before, frp) 4820 frame_insert(frame_T *before, frame_T *frp)
4876 frame_T *before, *frp;
4877 { 4821 {
4878 frp->fr_next = before; 4822 frp->fr_next = before;
4879 frp->fr_prev = before->fr_prev; 4823 frp->fr_prev = before->fr_prev;
4880 before->fr_prev = frp; 4824 before->fr_prev = frp;
4881 if (frp->fr_prev != NULL) 4825 if (frp->fr_prev != NULL)
4886 4830
4887 /* 4831 /*
4888 * Remove a frame from a frame list. 4832 * Remove a frame from a frame list.
4889 */ 4833 */
4890 static void 4834 static void
4891 frame_remove(frp) 4835 frame_remove(frame_T *frp)
4892 frame_T *frp;
4893 { 4836 {
4894 if (frp->fr_prev != NULL) 4837 if (frp->fr_prev != NULL)
4895 frp->fr_prev->fr_next = frp->fr_next; 4838 frp->fr_prev->fr_next = frp->fr_next;
4896 else 4839 else
4897 frp->fr_parent->fr_child = frp->fr_next; 4840 frp->fr_parent->fr_child = frp->fr_next;
4904 /* 4847 /*
4905 * Allocate w_lines[] for window "wp". 4848 * Allocate w_lines[] for window "wp".
4906 * Return FAIL for failure, OK for success. 4849 * Return FAIL for failure, OK for success.
4907 */ 4850 */
4908 int 4851 int
4909 win_alloc_lines(wp) 4852 win_alloc_lines(win_T *wp)
4910 win_T *wp;
4911 { 4853 {
4912 wp->w_lines_valid = 0; 4854 wp->w_lines_valid = 0;
4913 wp->w_lines = (wline_T *)alloc_clear((unsigned)(Rows * sizeof(wline_T))); 4855 wp->w_lines = (wline_T *)alloc_clear((unsigned)(Rows * sizeof(wline_T)));
4914 if (wp->w_lines == NULL) 4856 if (wp->w_lines == NULL)
4915 return FAIL; 4857 return FAIL;
4918 4860
4919 /* 4861 /*
4920 * free lsize arrays for a window 4862 * free lsize arrays for a window
4921 */ 4863 */
4922 void 4864 void
4923 win_free_lsize(wp) 4865 win_free_lsize(win_T *wp)
4924 win_T *wp;
4925 { 4866 {
4926 /* TODO: why would wp be NULL here? */ 4867 /* TODO: why would wp be NULL here? */
4927 if (wp != NULL) 4868 if (wp != NULL)
4928 { 4869 {
4929 vim_free(wp->w_lines); 4870 vim_free(wp->w_lines);
4934 /* 4875 /*
4935 * Called from win_new_shellsize() after Rows changed. 4876 * Called from win_new_shellsize() after Rows changed.
4936 * This only does the current tab page, others must be done when made active. 4877 * This only does the current tab page, others must be done when made active.
4937 */ 4878 */
4938 void 4879 void
4939 shell_new_rows() 4880 shell_new_rows(void)
4940 { 4881 {
4941 int h = (int)ROWS_AVAIL; 4882 int h = (int)ROWS_AVAIL;
4942 4883
4943 if (firstwin == NULL) /* not initialized yet */ 4884 if (firstwin == NULL) /* not initialized yet */
4944 return; 4885 return;
4973 #if defined(FEAT_VERTSPLIT) || defined(PROTO) 4914 #if defined(FEAT_VERTSPLIT) || defined(PROTO)
4974 /* 4915 /*
4975 * Called from win_new_shellsize() after Columns changed. 4916 * Called from win_new_shellsize() after Columns changed.
4976 */ 4917 */
4977 void 4918 void
4978 shell_new_columns() 4919 shell_new_columns(void)
4979 { 4920 {
4980 if (firstwin == NULL) /* not initialized yet */ 4921 if (firstwin == NULL) /* not initialized yet */
4981 return; 4922 return;
4982 4923
4983 /* First try setting the widths of windows with 'winfixwidth'. If that 4924 /* First try setting the widths of windows with 'winfixwidth'. If that
4998 #if defined(FEAT_CMDWIN) || defined(PROTO) 4939 #if defined(FEAT_CMDWIN) || defined(PROTO)
4999 /* 4940 /*
5000 * Save the size of all windows in "gap". 4941 * Save the size of all windows in "gap".
5001 */ 4942 */
5002 void 4943 void
5003 win_size_save(gap) 4944 win_size_save(garray_T *gap)
5004 garray_T *gap;
5005 4945
5006 { 4946 {
5007 win_T *wp; 4947 win_T *wp;
5008 4948
5009 ga_init2(gap, (int)sizeof(int), 1); 4949 ga_init2(gap, (int)sizeof(int), 1);
5019 /* 4959 /*
5020 * Restore window sizes, but only if the number of windows is still the same. 4960 * Restore window sizes, but only if the number of windows is still the same.
5021 * Does not free the growarray. 4961 * Does not free the growarray.
5022 */ 4962 */
5023 void 4963 void
5024 win_size_restore(gap) 4964 win_size_restore(garray_T *gap)
5025 garray_T *gap;
5026 { 4965 {
5027 win_T *wp; 4966 win_T *wp;
5028 int i, j; 4967 int i, j;
5029 4968
5030 if (win_count() * 2 == gap->ga_len) 4969 if (win_count() * 2 == gap->ga_len)
5051 * Update the position for all windows, using the width and height of the 4990 * Update the position for all windows, using the width and height of the
5052 * frames. 4991 * frames.
5053 * Returns the row just after the last window. 4992 * Returns the row just after the last window.
5054 */ 4993 */
5055 int 4994 int
5056 win_comp_pos() 4995 win_comp_pos(void)
5057 { 4996 {
5058 int row = tabline_height(); 4997 int row = tabline_height();
5059 int col = 0; 4998 int col = 0;
5060 4999
5061 frame_comp_pos(topframe, &row, &col); 5000 frame_comp_pos(topframe, &row, &col);
5067 * height of the frames. 5006 * height of the frames.
5068 * "*row" and "*col" are the top-left position of the frame. They are updated 5007 * "*row" and "*col" are the top-left position of the frame. They are updated
5069 * to the bottom-right position plus one. 5008 * to the bottom-right position plus one.
5070 */ 5009 */
5071 static void 5010 static void
5072 frame_comp_pos(topfrp, row, col) 5011 frame_comp_pos(frame_T *topfrp, int *row, int *col)
5073 frame_T *topfrp;
5074 int *row;
5075 int *col;
5076 { 5012 {
5077 win_T *wp; 5013 win_T *wp;
5078 frame_T *frp; 5014 frame_T *frp;
5079 #ifdef FEAT_VERTSPLIT 5015 #ifdef FEAT_VERTSPLIT
5080 int startcol; 5016 int startcol;
5127 /* 5063 /*
5128 * Set current window height and take care of repositioning other windows to 5064 * Set current window height and take care of repositioning other windows to
5129 * fit around it. 5065 * fit around it.
5130 */ 5066 */
5131 void 5067 void
5132 win_setheight(height) 5068 win_setheight(int height)
5133 int height;
5134 { 5069 {
5135 win_setheight_win(height, curwin); 5070 win_setheight_win(height, curwin);
5136 } 5071 }
5137 5072
5138 /* 5073 /*
5139 * Set the window height of window "win" and take care of repositioning other 5074 * Set the window height of window "win" and take care of repositioning other
5140 * windows to fit around it. 5075 * windows to fit around it.
5141 */ 5076 */
5142 void 5077 void
5143 win_setheight_win(height, win) 5078 win_setheight_win(int height, win_T *win)
5144 int height;
5145 win_T *win;
5146 { 5079 {
5147 int row; 5080 int row;
5148 5081
5149 if (win == curwin) 5082 if (win == curwin)
5150 { 5083 {
5197 * If the frame is part of a FR_ROW frame, all frames must be resized as well. 5130 * If the frame is part of a FR_ROW frame, all frames must be resized as well.
5198 * Check for the minimal height of the FR_ROW frame. 5131 * Check for the minimal height of the FR_ROW frame.
5199 * At the top level we can also use change the command line height. 5132 * At the top level we can also use change the command line height.
5200 */ 5133 */
5201 static void 5134 static void
5202 frame_setheight(curfrp, height) 5135 frame_setheight(frame_T *curfrp, int height)
5203 frame_T *curfrp;
5204 int height;
5205 { 5136 {
5206 int room; /* total number of lines available */ 5137 int room; /* total number of lines available */
5207 int take; /* number of lines taken from other windows */ 5138 int take; /* number of lines taken from other windows */
5208 int room_cmdline; /* lines available from cmdline */ 5139 int room_cmdline; /* lines available from cmdline */
5209 int run; 5140 int run;
5377 /* 5308 /*
5378 * Set current window width and take care of repositioning other windows to 5309 * Set current window width and take care of repositioning other windows to
5379 * fit around it. 5310 * fit around it.
5380 */ 5311 */
5381 void 5312 void
5382 win_setwidth(width) 5313 win_setwidth(int width)
5383 int width;
5384 { 5314 {
5385 win_setwidth_win(width, curwin); 5315 win_setwidth_win(width, curwin);
5386 } 5316 }
5387 5317
5388 void 5318 void
5389 win_setwidth_win(width, wp) 5319 win_setwidth_win(int width, win_T *wp)
5390 int width;
5391 win_T *wp;
5392 { 5320 {
5393 /* Always keep current window at least one column wide, even when 5321 /* Always keep current window at least one column wide, even when
5394 * 'winminwidth' is zero. */ 5322 * 'winminwidth' is zero. */
5395 if (wp == curwin) 5323 if (wp == curwin)
5396 { 5324 {
5414 * are in the same FR_ROW frame. 5342 * are in the same FR_ROW frame.
5415 * 5343 *
5416 * Strategy is similar to frame_setheight(). 5344 * Strategy is similar to frame_setheight().
5417 */ 5345 */
5418 static void 5346 static void
5419 frame_setwidth(curfrp, width) 5347 frame_setwidth(frame_T *curfrp, int width)
5420 frame_T *curfrp;
5421 int width;
5422 { 5348 {
5423 int room; /* total number of lines available */ 5349 int room; /* total number of lines available */
5424 int take; /* number of lines taken from other windows */ 5350 int take; /* number of lines taken from other windows */
5425 int run; 5351 int run;
5426 frame_T *frp; 5352 frame_T *frp;
5557 5483
5558 /* 5484 /*
5559 * Check 'winminheight' for a valid value. 5485 * Check 'winminheight' for a valid value.
5560 */ 5486 */
5561 void 5487 void
5562 win_setminheight() 5488 win_setminheight(void)
5563 { 5489 {
5564 int room; 5490 int room;
5565 int first = TRUE; 5491 int first = TRUE;
5566 win_T *wp; 5492 win_T *wp;
5567 5493
5587 5513
5588 /* 5514 /*
5589 * Status line of dragwin is dragged "offset" lines down (negative is up). 5515 * Status line of dragwin is dragged "offset" lines down (negative is up).
5590 */ 5516 */
5591 void 5517 void
5592 win_drag_status_line(dragwin, offset) 5518 win_drag_status_line(win_T *dragwin, int offset)
5593 win_T *dragwin;
5594 int offset;
5595 { 5519 {
5596 frame_T *curfr; 5520 frame_T *curfr;
5597 frame_T *fr; 5521 frame_T *fr;
5598 int room; 5522 int room;
5599 int row; 5523 int row;
5719 # if defined(FEAT_VERTSPLIT) || defined(PROTO) 5643 # if defined(FEAT_VERTSPLIT) || defined(PROTO)
5720 /* 5644 /*
5721 * Separator line of dragwin is dragged "offset" lines right (negative is left). 5645 * Separator line of dragwin is dragged "offset" lines right (negative is left).
5722 */ 5646 */
5723 void 5647 void
5724 win_drag_vsep_line(dragwin, offset) 5648 win_drag_vsep_line(win_T *dragwin, int offset)
5725 win_T *dragwin;
5726 int offset;
5727 { 5649 {
5728 frame_T *curfr; 5650 frame_T *curfr;
5729 frame_T *fr; 5651 frame_T *fr;
5730 int room; 5652 int room;
5731 int left; /* if TRUE, drag separator line left, otherwise right */ 5653 int left; /* if TRUE, drag separator line left, otherwise right */
5830 5752
5831 /* 5753 /*
5832 * Set wp->w_fraction for the current w_wrow and w_height. 5754 * Set wp->w_fraction for the current w_wrow and w_height.
5833 */ 5755 */
5834 void 5756 void
5835 set_fraction(wp) 5757 set_fraction(win_T *wp)
5836 win_T *wp;
5837 { 5758 {
5838 wp->w_fraction = ((long)wp->w_wrow * FRACTION_MULT 5759 wp->w_fraction = ((long)wp->w_wrow * FRACTION_MULT
5839 + wp->w_height / 2) / (long)wp->w_height; 5760 + wp->w_height / 2) / (long)wp->w_height;
5840 } 5761 }
5841 5762
5843 * Set the height of a window. 5764 * Set the height of a window.
5844 * This takes care of the things inside the window, not what happens to the 5765 * This takes care of the things inside the window, not what happens to the
5845 * window position, the frame or to other windows. 5766 * window position, the frame or to other windows.
5846 */ 5767 */
5847 void 5768 void
5848 win_new_height(wp, height) 5769 win_new_height(win_T *wp, int height)
5849 win_T *wp;
5850 int height;
5851 { 5770 {
5852 linenr_T lnum; 5771 linenr_T lnum;
5853 int sline, line_size; 5772 int sline, line_size;
5854 int prev_height = wp->w_height; 5773 int prev_height = wp->w_height;
5855 5774
5998 #ifdef FEAT_VERTSPLIT 5917 #ifdef FEAT_VERTSPLIT
5999 /* 5918 /*
6000 * Set the width of a window. 5919 * Set the width of a window.
6001 */ 5920 */
6002 void 5921 void
6003 win_new_width(wp, width) 5922 win_new_width(win_T *wp, int width)
6004 win_T *wp;
6005 int width;
6006 { 5923 {
6007 wp->w_width = width; 5924 wp->w_width = width;
6008 wp->w_lines_valid = 0; 5925 wp->w_lines_valid = 0;
6009 changed_line_abv_curs_win(wp); 5926 changed_line_abv_curs_win(wp);
6010 invalidate_botline_win(wp); 5927 invalidate_botline_win(wp);
6017 wp->w_redr_status = TRUE; 5934 wp->w_redr_status = TRUE;
6018 } 5935 }
6019 #endif 5936 #endif
6020 5937
6021 void 5938 void
6022 win_comp_scroll(wp) 5939 win_comp_scroll(win_T *wp)
6023 win_T *wp;
6024 { 5940 {
6025 wp->w_p_scr = ((unsigned)wp->w_height >> 1); 5941 wp->w_p_scr = ((unsigned)wp->w_height >> 1);
6026 if (wp->w_p_scr == 0) 5942 if (wp->w_p_scr == 0)
6027 wp->w_p_scr = 1; 5943 wp->w_p_scr = 1;
6028 } 5944 }
6029 5945
6030 /* 5946 /*
6031 * command_height: called whenever p_ch has been changed 5947 * command_height: called whenever p_ch has been changed
6032 */ 5948 */
6033 void 5949 void
6034 command_height() 5950 command_height(void)
6035 { 5951 {
6036 #ifdef FEAT_WINDOWS 5952 #ifdef FEAT_WINDOWS
6037 int h; 5953 int h;
6038 frame_T *frp; 5954 frame_T *frp;
6039 int old_p_ch = curtab->tp_ch_used; 5955 int old_p_ch = curtab->tp_ch_used;
6110 /* 6026 /*
6111 * Resize frame "frp" to be "n" lines higher (negative for less high). 6027 * Resize frame "frp" to be "n" lines higher (negative for less high).
6112 * Also resize the frames it is contained in. 6028 * Also resize the frames it is contained in.
6113 */ 6029 */
6114 static void 6030 static void
6115 frame_add_height(frp, n) 6031 frame_add_height(frame_T *frp, int n)
6116 frame_T *frp;
6117 int n;
6118 { 6032 {
6119 frame_new_height(frp, frp->fr_height + n, FALSE, FALSE); 6033 frame_new_height(frp, frp->fr_height + n, FALSE, FALSE);
6120 for (;;) 6034 for (;;)
6121 { 6035 {
6122 frp = frp->fr_parent; 6036 frp = frp->fr_parent;
6129 /* 6043 /*
6130 * Add or remove a status line for the bottom window(s), according to the 6044 * Add or remove a status line for the bottom window(s), according to the
6131 * value of 'laststatus'. 6045 * value of 'laststatus'.
6132 */ 6046 */
6133 void 6047 void
6134 last_status(morewin) 6048 last_status(
6135 int morewin; /* pretend there are two or more windows */ 6049 int morewin) /* pretend there are two or more windows */
6136 { 6050 {
6137 /* Don't make a difference between horizontal or vertical split. */ 6051 /* Don't make a difference between horizontal or vertical split. */
6138 last_status_rec(topframe, (p_ls == 2 6052 last_status_rec(topframe, (p_ls == 2
6139 || (p_ls == 1 && (morewin || lastwin != firstwin)))); 6053 || (p_ls == 1 && (morewin || lastwin != firstwin))));
6140 } 6054 }
6141 6055
6142 static void 6056 static void
6143 last_status_rec(fr, statusline) 6057 last_status_rec(frame_T *fr, int statusline)
6144 frame_T *fr;
6145 int statusline;
6146 { 6058 {
6147 frame_T *fp; 6059 frame_T *fp;
6148 win_T *wp; 6060 win_T *wp;
6149 6061
6150 if (fr->fr_layout == FR_LEAF) 6062 if (fr->fr_layout == FR_LEAF)
6207 6119
6208 /* 6120 /*
6209 * Return the number of lines used by the tab page line. 6121 * Return the number of lines used by the tab page line.
6210 */ 6122 */
6211 int 6123 int
6212 tabline_height() 6124 tabline_height(void)
6213 { 6125 {
6214 #ifdef FEAT_GUI_TABLINE 6126 #ifdef FEAT_GUI_TABLINE
6215 /* When the GUI has the tabline then this always returns zero. */ 6127 /* When the GUI has the tabline then this always returns zero. */
6216 if (gui_use_tabline()) 6128 if (gui_use_tabline())
6217 return 0; 6129 return 0;
6231 * Get the file name at the cursor. 6143 * Get the file name at the cursor.
6232 * If Visual mode is active, use the selected text if it's in one line. 6144 * If Visual mode is active, use the selected text if it's in one line.
6233 * Returns the name in allocated memory, NULL for failure. 6145 * Returns the name in allocated memory, NULL for failure.
6234 */ 6146 */
6235 char_u * 6147 char_u *
6236 grab_file_name(count, file_lnum) 6148 grab_file_name(long count, linenr_T *file_lnum)
6237 long count;
6238 linenr_T *file_lnum;
6239 { 6149 {
6240 int options = FNAME_MESS|FNAME_EXP|FNAME_REL|FNAME_UNESC; 6150 int options = FNAME_MESS|FNAME_EXP|FNAME_REL|FNAME_UNESC;
6241 6151
6242 if (VIsual_active) 6152 if (VIsual_active)
6243 { 6153 {
6265 * FNAME_EXP expand to path 6175 * FNAME_EXP expand to path
6266 * FNAME_HYP check for hypertext link 6176 * FNAME_HYP check for hypertext link
6267 * FNAME_INCL apply "includeexpr" 6177 * FNAME_INCL apply "includeexpr"
6268 */ 6178 */
6269 char_u * 6179 char_u *
6270 file_name_at_cursor(options, count, file_lnum) 6180 file_name_at_cursor(int options, long count, linenr_T *file_lnum)
6271 int options;
6272 long count;
6273 linenr_T *file_lnum;
6274 { 6181 {
6275 return file_name_in_line(ml_get_curline(), 6182 return file_name_in_line(ml_get_curline(),
6276 curwin->w_cursor.col, options, count, curbuf->b_ffname, 6183 curwin->w_cursor.col, options, count, curbuf->b_ffname,
6277 file_lnum); 6184 file_lnum);
6278 } 6185 }
6280 /* 6187 /*
6281 * Return the name of the file under or after ptr[col]. 6188 * Return the name of the file under or after ptr[col].
6282 * Otherwise like file_name_at_cursor(). 6189 * Otherwise like file_name_at_cursor().
6283 */ 6190 */
6284 char_u * 6191 char_u *
6285 file_name_in_line(line, col, options, count, rel_fname, file_lnum) 6192 file_name_in_line(
6286 char_u *line; 6193 char_u *line,
6287 int col; 6194 int col,
6288 int options; 6195 int options,
6289 long count; 6196 long count,
6290 char_u *rel_fname; /* file we are searching relative to */ 6197 char_u *rel_fname, /* file we are searching relative to */
6291 linenr_T *file_lnum; /* line number after the file name */ 6198 linenr_T *file_lnum) /* line number after the file name */
6292 { 6199 {
6293 char_u *ptr; 6200 char_u *ptr;
6294 int len; 6201 int len;
6295 6202
6296 /* 6203 /*
6373 6280
6374 # if defined(FEAT_FIND_ID) && defined(FEAT_EVAL) 6281 # if defined(FEAT_FIND_ID) && defined(FEAT_EVAL)
6375 static char_u *eval_includeexpr(char_u *ptr, int len); 6282 static char_u *eval_includeexpr(char_u *ptr, int len);
6376 6283
6377 static char_u * 6284 static char_u *
6378 eval_includeexpr(ptr, len) 6285 eval_includeexpr(char_u *ptr, int len)
6379 char_u *ptr;
6380 int len;
6381 { 6286 {
6382 char_u *res; 6287 char_u *res;
6383 6288
6384 set_vim_var_string(VV_FNAME, ptr, len); 6289 set_vim_var_string(VV_FNAME, ptr, len);
6385 res = eval_to_string_safe(curbuf->b_p_inex, NULL, 6290 res = eval_to_string_safe(curbuf->b_p_inex, NULL,
6392 /* 6297 /*
6393 * Return the name of the file ptr[len] in 'path'. 6298 * Return the name of the file ptr[len] in 'path'.
6394 * Otherwise like file_name_at_cursor(). 6299 * Otherwise like file_name_at_cursor().
6395 */ 6300 */
6396 char_u * 6301 char_u *
6397 find_file_name_in_path(ptr, len, options, count, rel_fname) 6302 find_file_name_in_path(
6398 char_u *ptr; 6303 char_u *ptr,
6399 int len; 6304 int len,
6400 int options; 6305 int options,
6401 long count; 6306 long count,
6402 char_u *rel_fname; /* file we are searching relative to */ 6307 char_u *rel_fname) /* file we are searching relative to */
6403 { 6308 {
6404 char_u *file_name; 6309 char_u *file_name;
6405 int c; 6310 int c;
6406 # if defined(FEAT_FIND_ID) && defined(FEAT_EVAL) 6311 # if defined(FEAT_FIND_ID) && defined(FEAT_EVAL)
6407 char_u *tofree = NULL; 6312 char_u *tofree = NULL;
6471 * Check if the "://" of a URL is at the pointer, return URL_SLASH. 6376 * Check if the "://" of a URL is at the pointer, return URL_SLASH.
6472 * Also check for ":\\", which MS Internet Explorer accepts, return 6377 * Also check for ":\\", which MS Internet Explorer accepts, return
6473 * URL_BACKSLASH. 6378 * URL_BACKSLASH.
6474 */ 6379 */
6475 static int 6380 static int
6476 path_is_url(p) 6381 path_is_url(char_u *p)
6477 char_u *p;
6478 { 6382 {
6479 if (STRNCMP(p, "://", (size_t)3) == 0) 6383 if (STRNCMP(p, "://", (size_t)3) == 0)
6480 return URL_SLASH; 6384 return URL_SLASH;
6481 else if (STRNCMP(p, ":\\\\", (size_t)3) == 0) 6385 else if (STRNCMP(p, ":\\\\", (size_t)3) == 0)
6482 return URL_BACKSLASH; 6386 return URL_BACKSLASH;
6487 * Check if "fname" starts with "name://". Return URL_SLASH if it does. 6391 * Check if "fname" starts with "name://". Return URL_SLASH if it does.
6488 * Return URL_BACKSLASH for "name:\\". 6392 * Return URL_BACKSLASH for "name:\\".
6489 * Return zero otherwise. 6393 * Return zero otherwise.
6490 */ 6394 */
6491 int 6395 int
6492 path_with_url(fname) 6396 path_with_url(char_u *fname)
6493 char_u *fname;
6494 { 6397 {
6495 char_u *p; 6398 char_u *p;
6496 6399
6497 for (p = fname; isalpha(*p); ++p) 6400 for (p = fname; isalpha(*p); ++p)
6498 ; 6401 ;
6501 6404
6502 /* 6405 /*
6503 * Return TRUE if "name" is a full (absolute) path name or URL. 6406 * Return TRUE if "name" is a full (absolute) path name or URL.
6504 */ 6407 */
6505 int 6408 int
6506 vim_isAbsName(name) 6409 vim_isAbsName(char_u *name)
6507 char_u *name;
6508 { 6410 {
6509 return (path_with_url(name) != 0 || mch_isFullName(name)); 6411 return (path_with_url(name) != 0 || mch_isFullName(name));
6510 } 6412 }
6511 6413
6512 /* 6414 /*
6513 * Get absolute file name into buffer "buf[len]". 6415 * Get absolute file name into buffer "buf[len]".
6514 * 6416 *
6515 * return FAIL for failure, OK otherwise 6417 * return FAIL for failure, OK otherwise
6516 */ 6418 */
6517 int 6419 int
6518 vim_FullName(fname, buf, len, force) 6420 vim_FullName(
6519 char_u *fname, *buf; 6421 char_u *fname,
6520 int len; 6422 char_u *buf,
6521 int force; /* force expansion even when already absolute */ 6423 int len,
6424 int force) /* force expansion even when already absolute */
6522 { 6425 {
6523 int retval = OK; 6426 int retval = OK;
6524 int url; 6427 int url;
6525 6428
6526 *buf = NUL; 6429 *buf = NUL;
6544 /* 6447 /*
6545 * Return the minimal number of rows that is needed on the screen to display 6448 * Return the minimal number of rows that is needed on the screen to display
6546 * the current number of windows. 6449 * the current number of windows.
6547 */ 6450 */
6548 int 6451 int
6549 min_rows() 6452 min_rows(void)
6550 { 6453 {
6551 int total; 6454 int total;
6552 #ifdef FEAT_WINDOWS 6455 #ifdef FEAT_WINDOWS
6553 tabpage_T *tp; 6456 tabpage_T *tp;
6554 int n; 6457 int n;
6577 * Return TRUE if there is only one window (in the current tab page), not 6480 * Return TRUE if there is only one window (in the current tab page), not
6578 * counting a help or preview window, unless it is the current window. 6481 * counting a help or preview window, unless it is the current window.
6579 * Does not count "aucmd_win". 6482 * Does not count "aucmd_win".
6580 */ 6483 */
6581 int 6484 int
6582 only_one_window() 6485 only_one_window(void)
6583 { 6486 {
6584 #ifdef FEAT_WINDOWS 6487 #ifdef FEAT_WINDOWS
6585 int count = 0; 6488 int count = 0;
6586 win_T *wp; 6489 win_T *wp;
6587 6490
6612 * Correct the cursor line number in other windows. Used after changing the 6515 * Correct the cursor line number in other windows. Used after changing the
6613 * current buffer, and before applying autocommands. 6516 * current buffer, and before applying autocommands.
6614 * When "do_curwin" is TRUE, also check current window. 6517 * When "do_curwin" is TRUE, also check current window.
6615 */ 6518 */
6616 void 6519 void
6617 check_lnums(do_curwin) 6520 check_lnums(int do_curwin)
6618 int do_curwin;
6619 { 6521 {
6620 win_T *wp; 6522 win_T *wp;
6621 6523
6622 #ifdef FEAT_WINDOWS 6524 #ifdef FEAT_WINDOWS
6623 tabpage_T *tp; 6525 tabpage_T *tp;
6653 6555
6654 /* 6556 /*
6655 * Create a snapshot of the current frame sizes. 6557 * Create a snapshot of the current frame sizes.
6656 */ 6558 */
6657 void 6559 void
6658 make_snapshot(idx) 6560 make_snapshot(int idx)
6659 int idx;
6660 { 6561 {
6661 clear_snapshot(curtab, idx); 6562 clear_snapshot(curtab, idx);
6662 make_snapshot_rec(topframe, &curtab->tp_snapshot[idx]); 6563 make_snapshot_rec(topframe, &curtab->tp_snapshot[idx]);
6663 } 6564 }
6664 6565
6665 static void 6566 static void
6666 make_snapshot_rec(fr, frp) 6567 make_snapshot_rec(frame_T *fr, frame_T **frp)
6667 frame_T *fr;
6668 frame_T **frp;
6669 { 6568 {
6670 *frp = (frame_T *)alloc_clear((unsigned)sizeof(frame_T)); 6569 *frp = (frame_T *)alloc_clear((unsigned)sizeof(frame_T));
6671 if (*frp == NULL) 6570 if (*frp == NULL)
6672 return; 6571 return;
6673 (*frp)->fr_layout = fr->fr_layout; 6572 (*frp)->fr_layout = fr->fr_layout;
6685 6584
6686 /* 6585 /*
6687 * Remove any existing snapshot. 6586 * Remove any existing snapshot.
6688 */ 6587 */
6689 static void 6588 static void
6690 clear_snapshot(tp, idx) 6589 clear_snapshot(tabpage_T *tp, int idx)
6691 tabpage_T *tp;
6692 int idx;
6693 { 6590 {
6694 clear_snapshot_rec(tp->tp_snapshot[idx]); 6591 clear_snapshot_rec(tp->tp_snapshot[idx]);
6695 tp->tp_snapshot[idx] = NULL; 6592 tp->tp_snapshot[idx] = NULL;
6696 } 6593 }
6697 6594
6698 static void 6595 static void
6699 clear_snapshot_rec(fr) 6596 clear_snapshot_rec(frame_T *fr)
6700 frame_T *fr;
6701 { 6597 {
6702 if (fr != NULL) 6598 if (fr != NULL)
6703 { 6599 {
6704 clear_snapshot_rec(fr->fr_next); 6600 clear_snapshot_rec(fr->fr_next);
6705 clear_snapshot_rec(fr->fr_child); 6601 clear_snapshot_rec(fr->fr_child);
6711 * Restore a previously created snapshot, if there is any. 6607 * Restore a previously created snapshot, if there is any.
6712 * This is only done if the screen size didn't change and the window layout is 6608 * This is only done if the screen size didn't change and the window layout is
6713 * still the same. 6609 * still the same.
6714 */ 6610 */
6715 void 6611 void
6716 restore_snapshot(idx, close_curwin) 6612 restore_snapshot(
6717 int idx; 6613 int idx,
6718 int close_curwin; /* closing current window */ 6614 int close_curwin) /* closing current window */
6719 { 6615 {
6720 win_T *wp; 6616 win_T *wp;
6721 6617
6722 if (curtab->tp_snapshot[idx] != NULL 6618 if (curtab->tp_snapshot[idx] != NULL
6723 # ifdef FEAT_VERTSPLIT 6619 # ifdef FEAT_VERTSPLIT
6738 /* 6634 /*
6739 * Check if frames "sn" and "fr" have the same layout, same following frames 6635 * Check if frames "sn" and "fr" have the same layout, same following frames
6740 * and same children. 6636 * and same children.
6741 */ 6637 */
6742 static int 6638 static int
6743 check_snapshot_rec(sn, fr) 6639 check_snapshot_rec(frame_T *sn, frame_T *fr)
6744 frame_T *sn;
6745 frame_T *fr;
6746 { 6640 {
6747 if (sn->fr_layout != fr->fr_layout 6641 if (sn->fr_layout != fr->fr_layout
6748 || (sn->fr_next == NULL) != (fr->fr_next == NULL) 6642 || (sn->fr_next == NULL) != (fr->fr_next == NULL)
6749 || (sn->fr_child == NULL) != (fr->fr_child == NULL) 6643 || (sn->fr_child == NULL) != (fr->fr_child == NULL)
6750 || (sn->fr_next != NULL 6644 || (sn->fr_next != NULL
6759 * Copy the size of snapshot frame "sn" to frame "fr". Do the same for all 6653 * Copy the size of snapshot frame "sn" to frame "fr". Do the same for all
6760 * following frames and children. 6654 * following frames and children.
6761 * Returns a pointer to the old current window, or NULL. 6655 * Returns a pointer to the old current window, or NULL.
6762 */ 6656 */
6763 static win_T * 6657 static win_T *
6764 restore_snapshot_rec(sn, fr) 6658 restore_snapshot_rec(frame_T *sn, frame_T *fr)
6765 frame_T *sn;
6766 frame_T *fr;
6767 { 6659 {
6768 win_T *wp = NULL; 6660 win_T *wp = NULL;
6769 win_T *wp2; 6661 win_T *wp2;
6770 6662
6771 fr->fr_height = sn->fr_height; 6663 fr->fr_height = sn->fr_height;
6806 * When "no_display" is TRUE the display won't be affected, no redraw is 6698 * When "no_display" is TRUE the display won't be affected, no redraw is
6807 * triggered, another tabpage access is limited. 6699 * triggered, another tabpage access is limited.
6808 * Returns FAIL if switching to "win" failed. 6700 * Returns FAIL if switching to "win" failed.
6809 */ 6701 */
6810 int 6702 int
6811 switch_win(save_curwin, save_curtab, win, tp, no_display) 6703 switch_win(
6812 win_T **save_curwin UNUSED; 6704 win_T **save_curwin UNUSED,
6813 tabpage_T **save_curtab UNUSED; 6705 tabpage_T **save_curtab UNUSED,
6814 win_T *win UNUSED; 6706 win_T *win UNUSED,
6815 tabpage_T *tp UNUSED; 6707 tabpage_T *tp UNUSED,
6816 int no_display UNUSED; 6708 int no_display UNUSED)
6817 { 6709 {
6818 # ifdef FEAT_AUTOCMD 6710 # ifdef FEAT_AUTOCMD
6819 block_autocmds(); 6711 block_autocmds();
6820 # endif 6712 # endif
6821 # ifdef FEAT_WINDOWS 6713 # ifdef FEAT_WINDOWS
6846 * Restore current tabpage and window saved by switch_win(), if still valid. 6738 * Restore current tabpage and window saved by switch_win(), if still valid.
6847 * When "no_display" is TRUE the display won't be affected, no redraw is 6739 * When "no_display" is TRUE the display won't be affected, no redraw is
6848 * triggered. 6740 * triggered.
6849 */ 6741 */
6850 void 6742 void
6851 restore_win(save_curwin, save_curtab, no_display) 6743 restore_win(
6852 win_T *save_curwin UNUSED; 6744 win_T *save_curwin UNUSED,
6853 tabpage_T *save_curtab UNUSED; 6745 tabpage_T *save_curtab UNUSED,
6854 int no_display UNUSED; 6746 int no_display UNUSED)
6855 { 6747 {
6856 # ifdef FEAT_WINDOWS 6748 # ifdef FEAT_WINDOWS
6857 if (save_curtab != NULL && valid_tabpage(save_curtab)) 6749 if (save_curtab != NULL && valid_tabpage(save_curtab))
6858 { 6750 {
6859 if (no_display) 6751 if (no_display)
6881 /* 6773 /*
6882 * Make "buf" the current buffer. restore_buffer() MUST be called to undo. 6774 * Make "buf" the current buffer. restore_buffer() MUST be called to undo.
6883 * No autocommands will be executed. Use aucmd_prepbuf() if there are any. 6775 * No autocommands will be executed. Use aucmd_prepbuf() if there are any.
6884 */ 6776 */
6885 void 6777 void
6886 switch_buffer(save_curbuf, buf) 6778 switch_buffer(buf_T **save_curbuf, buf_T *buf)
6887 buf_T *buf;
6888 buf_T **save_curbuf;
6889 { 6779 {
6890 # ifdef FEAT_AUTOCMD 6780 # ifdef FEAT_AUTOCMD
6891 block_autocmds(); 6781 block_autocmds();
6892 # endif 6782 # endif
6893 *save_curbuf = curbuf; 6783 *save_curbuf = curbuf;
6899 6789
6900 /* 6790 /*
6901 * Restore the current buffer after using switch_buffer(). 6791 * Restore the current buffer after using switch_buffer().
6902 */ 6792 */
6903 void 6793 void
6904 restore_buffer(save_curbuf) 6794 restore_buffer(buf_T *save_curbuf)
6905 buf_T *save_curbuf;
6906 { 6795 {
6907 # ifdef FEAT_AUTOCMD 6796 # ifdef FEAT_AUTOCMD
6908 unblock_autocmds(); 6797 unblock_autocmds();
6909 # endif 6798 # endif
6910 /* Check for valid buffer, just in case. */ 6799 /* Check for valid buffer, just in case. */
6921 #if (defined(FEAT_GUI) && defined(FEAT_VERTSPLIT)) || defined(PROTO) 6810 #if (defined(FEAT_GUI) && defined(FEAT_VERTSPLIT)) || defined(PROTO)
6922 /* 6811 /*
6923 * Return TRUE if there is any vertically split window. 6812 * Return TRUE if there is any vertically split window.
6924 */ 6813 */
6925 int 6814 int
6926 win_hasvertsplit() 6815 win_hasvertsplit(void)
6927 { 6816 {
6928 frame_T *fr; 6817 frame_T *fr;
6929 6818
6930 if (topframe->fr_layout == FR_ROW) 6819 if (topframe->fr_layout == FR_ROW)
6931 return TRUE; 6820 return TRUE;
6946 * Optionally, a desired ID 'id' can be specified (greater than or equal to 1). 6835 * Optionally, a desired ID 'id' can be specified (greater than or equal to 1).
6947 * If no particular ID is desired, -1 must be specified for 'id'. 6836 * If no particular ID is desired, -1 must be specified for 'id'.
6948 * Return ID of added match, -1 on failure. 6837 * Return ID of added match, -1 on failure.
6949 */ 6838 */
6950 int 6839 int
6951 match_add(wp, grp, pat, prio, id, pos_list, conceal_char) 6840 match_add(
6952 win_T *wp; 6841 win_T *wp,
6953 char_u *grp; 6842 char_u *grp,
6954 char_u *pat; 6843 char_u *pat,
6955 int prio; 6844 int prio,
6956 int id; 6845 int id,
6957 list_T *pos_list; 6846 list_T *pos_list,
6958 char_u *conceal_char UNUSED; /* pointer to conceal replacement char */ 6847 char_u *conceal_char UNUSED) /* pointer to conceal replacement char */
6959 { 6848 {
6960 matchitem_T *cur; 6849 matchitem_T *cur;
6961 matchitem_T *prev; 6850 matchitem_T *prev;
6962 matchitem_T *m; 6851 matchitem_T *m;
6963 int hlg_id; 6852 int hlg_id;
7144 /* 7033 /*
7145 * Delete match with ID 'id' in the match list of window 'wp'. 7034 * Delete match with ID 'id' in the match list of window 'wp'.
7146 * Print error messages if 'perr' is TRUE. 7035 * Print error messages if 'perr' is TRUE.
7147 */ 7036 */
7148 int 7037 int
7149 match_delete(wp, id, perr) 7038 match_delete(win_T *wp, int id, int perr)
7150 win_T *wp;
7151 int id;
7152 int perr;
7153 { 7039 {
7154 matchitem_T *cur = wp->w_match_head; 7040 matchitem_T *cur = wp->w_match_head;
7155 matchitem_T *prev = cur; 7041 matchitem_T *prev = cur;
7156 int rtype = SOME_VALID; 7042 int rtype = SOME_VALID;
7157 7043
7204 7090
7205 /* 7091 /*
7206 * Delete all matches in the match list of window 'wp'. 7092 * Delete all matches in the match list of window 'wp'.
7207 */ 7093 */
7208 void 7094 void
7209 clear_matches(wp) 7095 clear_matches(win_T *wp)
7210 win_T *wp;
7211 { 7096 {
7212 matchitem_T *m; 7097 matchitem_T *m;
7213 7098
7214 while (wp->w_match_head != NULL) 7099 while (wp->w_match_head != NULL)
7215 { 7100 {
7225 /* 7110 /*
7226 * Get match from ID 'id' in window 'wp'. 7111 * Get match from ID 'id' in window 'wp'.
7227 * Return NULL if match not found. 7112 * Return NULL if match not found.
7228 */ 7113 */
7229 matchitem_T * 7114 matchitem_T *
7230 get_match(wp, id) 7115 get_match(win_T *wp, int id)
7231 win_T *wp;
7232 int id;
7233 { 7116 {
7234 matchitem_T *cur = wp->w_match_head; 7117 matchitem_T *cur = wp->w_match_head;
7235 7118
7236 while (cur != NULL && cur->id != id) 7119 while (cur != NULL && cur->id != id)
7237 cur = cur->next; 7120 cur = cur->next;
7276 #if defined(FEAT_WINDOWS) || defined(PROTO) 7159 #if defined(FEAT_WINDOWS) || defined(PROTO)
7277 /* 7160 /*
7278 * Return TRUE if "topfrp" and its children are at the right height. 7161 * Return TRUE if "topfrp" and its children are at the right height.
7279 */ 7162 */
7280 static int 7163 static int
7281 frame_check_height(topfrp, height) 7164 frame_check_height(frame_T *topfrp, int height)
7282 frame_T *topfrp;
7283 int height;
7284 { 7165 {
7285 frame_T *frp; 7166 frame_T *frp;
7286 7167
7287 if (topfrp->fr_height != height) 7168 if (topfrp->fr_height != height)
7288 return FALSE; 7169 return FALSE;
7299 #if defined(FEAT_VERTSPLIT) || defined(PROTO) 7180 #if defined(FEAT_VERTSPLIT) || defined(PROTO)
7300 /* 7181 /*
7301 * Return TRUE if "topfrp" and its children are at the right width. 7182 * Return TRUE if "topfrp" and its children are at the right width.
7302 */ 7183 */
7303 static int 7184 static int
7304 frame_check_width(topfrp, width) 7185 frame_check_width(frame_T *topfrp, int width)
7305 frame_T *topfrp;
7306 int width;
7307 { 7186 {
7308 frame_T *frp; 7187 frame_T *frp;
7309 7188
7310 if (topfrp->fr_width != width) 7189 if (topfrp->fr_width != width)
7311 return FALSE; 7190 return FALSE;