Mercurial > vim
comparison src/ex_docmd.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 | 937356f8f8d6 |
children | 3ca08bf99396 |
comparison
equal
deleted
inserted
replaced
12476:2516383741e6 | 12477:68d7bc045dbe |
---|---|
106 # define ex_brewind ex_ni | 106 # define ex_brewind ex_ni |
107 # define ex_blast ex_ni | 107 # define ex_blast ex_ni |
108 # define buflist_list ex_ni | 108 # define buflist_list ex_ni |
109 # define ex_checktime ex_ni | 109 # define ex_checktime ex_ni |
110 #endif | 110 #endif |
111 #if !defined(FEAT_LISTCMDS) || !defined(FEAT_WINDOWS) | 111 #if !defined(FEAT_LISTCMDS) |
112 # define ex_buffer_all ex_ni | 112 # define ex_buffer_all ex_ni |
113 #endif | 113 #endif |
114 static char_u *getargcmd(char_u **); | 114 static char_u *getargcmd(char_u **); |
115 static char_u *skip_cmd_arg(char_u *p, int rembs); | 115 static char_u *skip_cmd_arg(char_u *p, int rembs); |
116 static int getargopt(exarg_T *eap); | 116 static int getargopt(exarg_T *eap); |
124 # define qf_age ex_ni | 124 # define qf_age ex_ni |
125 # define qf_history ex_ni | 125 # define qf_history ex_ni |
126 # define ex_helpgrep ex_ni | 126 # define ex_helpgrep ex_ni |
127 # define ex_vimgrep ex_ni | 127 # define ex_vimgrep ex_ni |
128 #endif | 128 #endif |
129 #if !defined(FEAT_QUICKFIX) || !defined(FEAT_WINDOWS) | 129 #if !defined(FEAT_QUICKFIX) |
130 # define ex_cclose ex_ni | 130 # define ex_cclose ex_ni |
131 # define ex_copen ex_ni | 131 # define ex_copen ex_ni |
132 # define ex_cwindow ex_ni | 132 # define ex_cwindow ex_ni |
133 # define ex_cbottom ex_ni | 133 # define ex_cbottom ex_ni |
134 #endif | 134 #endif |
157 static void ex_highlight(exarg_T *eap); | 157 static void ex_highlight(exarg_T *eap); |
158 static void ex_colorscheme(exarg_T *eap); | 158 static void ex_colorscheme(exarg_T *eap); |
159 static void ex_quit(exarg_T *eap); | 159 static void ex_quit(exarg_T *eap); |
160 static void ex_cquit(exarg_T *eap); | 160 static void ex_cquit(exarg_T *eap); |
161 static void ex_quit_all(exarg_T *eap); | 161 static void ex_quit_all(exarg_T *eap); |
162 #ifdef FEAT_WINDOWS | |
163 static void ex_close(exarg_T *eap); | 162 static void ex_close(exarg_T *eap); |
164 static void ex_win_close(int forceit, win_T *win, tabpage_T *tp); | 163 static void ex_win_close(int forceit, win_T *win, tabpage_T *tp); |
165 static void ex_only(exarg_T *eap); | 164 static void ex_only(exarg_T *eap); |
166 static void ex_resize(exarg_T *eap); | 165 static void ex_resize(exarg_T *eap); |
167 static void ex_stag(exarg_T *eap); | 166 static void ex_stag(exarg_T *eap); |
168 static void ex_tabclose(exarg_T *eap); | 167 static void ex_tabclose(exarg_T *eap); |
169 static void ex_tabonly(exarg_T *eap); | 168 static void ex_tabonly(exarg_T *eap); |
170 static void ex_tabnext(exarg_T *eap); | 169 static void ex_tabnext(exarg_T *eap); |
171 static void ex_tabmove(exarg_T *eap); | 170 static void ex_tabmove(exarg_T *eap); |
172 static void ex_tabs(exarg_T *eap); | 171 static void ex_tabs(exarg_T *eap); |
173 #else | 172 #if defined(FEAT_QUICKFIX) |
174 # define ex_close ex_ni | |
175 # define ex_only ex_ni | |
176 # define ex_all ex_ni | |
177 # define ex_resize ex_ni | |
178 # define ex_splitview ex_ni | |
179 # define ex_stag ex_ni | |
180 # define ex_tabnext ex_ni | |
181 # define ex_tabmove ex_ni | |
182 # define ex_tabs ex_ni | |
183 # define ex_tabclose ex_ni | |
184 # define ex_tabonly ex_ni | |
185 #endif | |
186 #if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX) | |
187 static void ex_pclose(exarg_T *eap); | 173 static void ex_pclose(exarg_T *eap); |
188 static void ex_ptag(exarg_T *eap); | 174 static void ex_ptag(exarg_T *eap); |
189 static void ex_pedit(exarg_T *eap); | 175 static void ex_pedit(exarg_T *eap); |
190 #else | 176 #else |
191 # define ex_pclose ex_ni | 177 # define ex_pclose ex_ni |
312 static void ex_pwd(exarg_T *eap); | 298 static void ex_pwd(exarg_T *eap); |
313 static void ex_equal(exarg_T *eap); | 299 static void ex_equal(exarg_T *eap); |
314 static void ex_sleep(exarg_T *eap); | 300 static void ex_sleep(exarg_T *eap); |
315 static void do_exmap(exarg_T *eap, int isabbrev); | 301 static void do_exmap(exarg_T *eap, int isabbrev); |
316 static void ex_winsize(exarg_T *eap); | 302 static void ex_winsize(exarg_T *eap); |
317 #ifdef FEAT_WINDOWS | |
318 static void ex_wincmd(exarg_T *eap); | 303 static void ex_wincmd(exarg_T *eap); |
319 #else | |
320 # define ex_wincmd ex_ni | |
321 #endif | |
322 #if defined(FEAT_GUI) || defined(UNIX) || defined(VMS) || defined(MSWIN) | 304 #if defined(FEAT_GUI) || defined(UNIX) || defined(VMS) || defined(MSWIN) |
323 static void ex_winpos(exarg_T *eap); | 305 static void ex_winpos(exarg_T *eap); |
324 #else | 306 #else |
325 # define ex_winpos ex_ni | 307 # define ex_winpos ex_ni |
326 #endif | 308 #endif |
354 static void ex_findpat(exarg_T *eap); | 336 static void ex_findpat(exarg_T *eap); |
355 #else | 337 #else |
356 # define ex_findpat ex_ni | 338 # define ex_findpat ex_ni |
357 # define ex_checkpath ex_ni | 339 # define ex_checkpath ex_ni |
358 #endif | 340 #endif |
359 #if defined(FEAT_FIND_ID) && defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX) | 341 #if defined(FEAT_FIND_ID) && defined(FEAT_QUICKFIX) |
360 static void ex_psearch(exarg_T *eap); | 342 static void ex_psearch(exarg_T *eap); |
361 #else | 343 #else |
362 # define ex_psearch ex_ni | 344 # define ex_psearch ex_ni |
363 #endif | 345 #endif |
364 static void ex_tag(exarg_T *eap); | 346 static void ex_tag(exarg_T *eap); |
1673 buf = nextbuf; | 1655 buf = nextbuf; |
1674 } | 1656 } |
1675 return buf->b_fnum; | 1657 return buf->b_fnum; |
1676 } | 1658 } |
1677 | 1659 |
1678 #ifdef FEAT_WINDOWS | |
1679 static int current_win_nr(win_T *win); | 1660 static int current_win_nr(win_T *win); |
1680 static int current_tab_nr(tabpage_T *tab); | 1661 static int current_tab_nr(tabpage_T *tab); |
1681 | 1662 |
1682 static int | 1663 static int |
1683 current_win_nr(win_T *win) | 1664 current_win_nr(win_T *win) |
1711 | 1692 |
1712 # define CURRENT_WIN_NR current_win_nr(curwin) | 1693 # define CURRENT_WIN_NR current_win_nr(curwin) |
1713 # define LAST_WIN_NR current_win_nr(NULL) | 1694 # define LAST_WIN_NR current_win_nr(NULL) |
1714 # define CURRENT_TAB_NR current_tab_nr(curtab) | 1695 # define CURRENT_TAB_NR current_tab_nr(curtab) |
1715 # define LAST_TAB_NR current_tab_nr(NULL) | 1696 # define LAST_TAB_NR current_tab_nr(NULL) |
1716 #else | |
1717 # define CURRENT_WIN_NR 1 | |
1718 # define LAST_WIN_NR 1 | |
1719 # define CURRENT_TAB_NR 1 | |
1720 # define LAST_TAB_NR 1 | |
1721 #endif | |
1722 | |
1723 | 1697 |
1724 /* | 1698 /* |
1725 * Execute one Ex command. | 1699 * Execute one Ex command. |
1726 * | 1700 * |
1727 * If 'sourcing' is TRUE, the command will be included in the error message. | 1701 * If 'sourcing' is TRUE, the command will be included in the error message. |
1841 switch (*p) | 1815 switch (*p) |
1842 { | 1816 { |
1843 /* When adding an entry, also modify cmd_exists(). */ | 1817 /* When adding an entry, also modify cmd_exists(). */ |
1844 case 'a': if (!checkforcmd(&ea.cmd, "aboveleft", 3)) | 1818 case 'a': if (!checkforcmd(&ea.cmd, "aboveleft", 3)) |
1845 break; | 1819 break; |
1846 #ifdef FEAT_WINDOWS | |
1847 cmdmod.split |= WSP_ABOVE; | 1820 cmdmod.split |= WSP_ABOVE; |
1848 #endif | |
1849 continue; | 1821 continue; |
1850 | 1822 |
1851 case 'b': if (checkforcmd(&ea.cmd, "belowright", 3)) | 1823 case 'b': if (checkforcmd(&ea.cmd, "belowright", 3)) |
1852 { | 1824 { |
1853 #ifdef FEAT_WINDOWS | |
1854 cmdmod.split |= WSP_BELOW; | 1825 cmdmod.split |= WSP_BELOW; |
1855 #endif | |
1856 continue; | 1826 continue; |
1857 } | 1827 } |
1858 if (checkforcmd(&ea.cmd, "browse", 3)) | 1828 if (checkforcmd(&ea.cmd, "browse", 3)) |
1859 { | 1829 { |
1860 #ifdef FEAT_BROWSE_CMD | 1830 #ifdef FEAT_BROWSE_CMD |
1862 #endif | 1832 #endif |
1863 continue; | 1833 continue; |
1864 } | 1834 } |
1865 if (!checkforcmd(&ea.cmd, "botright", 2)) | 1835 if (!checkforcmd(&ea.cmd, "botright", 2)) |
1866 break; | 1836 break; |
1867 #ifdef FEAT_WINDOWS | |
1868 cmdmod.split |= WSP_BOT; | 1837 cmdmod.split |= WSP_BOT; |
1869 #endif | |
1870 continue; | 1838 continue; |
1871 | 1839 |
1872 case 'c': if (!checkforcmd(&ea.cmd, "confirm", 4)) | 1840 case 'c': if (!checkforcmd(&ea.cmd, "confirm", 4)) |
1873 break; | 1841 break; |
1874 #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) | 1842 #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) |
1935 continue; | 1903 continue; |
1936 } | 1904 } |
1937 | 1905 |
1938 if (!checkforcmd(&ea.cmd, "leftabove", 5)) | 1906 if (!checkforcmd(&ea.cmd, "leftabove", 5)) |
1939 break; | 1907 break; |
1940 #ifdef FEAT_WINDOWS | |
1941 cmdmod.split |= WSP_ABOVE; | 1908 cmdmod.split |= WSP_ABOVE; |
1942 #endif | |
1943 continue; | 1909 continue; |
1944 | 1910 |
1945 case 'n': if (checkforcmd(&ea.cmd, "noautocmd", 3)) | 1911 case 'n': if (checkforcmd(&ea.cmd, "noautocmd", 3)) |
1946 { | 1912 { |
1947 #ifdef FEAT_AUTOCMD | 1913 #ifdef FEAT_AUTOCMD |
1961 cmdmod.noswapfile = TRUE; | 1927 cmdmod.noswapfile = TRUE; |
1962 continue; | 1928 continue; |
1963 | 1929 |
1964 case 'r': if (!checkforcmd(&ea.cmd, "rightbelow", 6)) | 1930 case 'r': if (!checkforcmd(&ea.cmd, "rightbelow", 6)) |
1965 break; | 1931 break; |
1966 #ifdef FEAT_WINDOWS | |
1967 cmdmod.split |= WSP_BELOW; | 1932 cmdmod.split |= WSP_BELOW; |
1968 #endif | |
1969 continue; | 1933 continue; |
1970 | 1934 |
1971 case 's': if (checkforcmd(&ea.cmd, "sandbox", 3)) | 1935 case 's': if (checkforcmd(&ea.cmd, "sandbox", 3)) |
1972 { | 1936 { |
1973 #ifdef HAVE_SANDBOX | 1937 #ifdef HAVE_SANDBOX |
1991 } | 1955 } |
1992 continue; | 1956 continue; |
1993 | 1957 |
1994 case 't': if (checkforcmd(&p, "tab", 3)) | 1958 case 't': if (checkforcmd(&p, "tab", 3)) |
1995 { | 1959 { |
1996 #ifdef FEAT_WINDOWS | |
1997 long tabnr = get_address(&ea, &ea.cmd, ADDR_TABS, | 1960 long tabnr = get_address(&ea, &ea.cmd, ADDR_TABS, |
1998 ea.skip, FALSE, 1); | 1961 ea.skip, FALSE, 1); |
1999 if (tabnr == MAXLNUM) | 1962 if (tabnr == MAXLNUM) |
2000 cmdmod.tab = tabpage_index(curtab) + 1; | 1963 cmdmod.tab = tabpage_index(curtab) + 1; |
2001 else | 1964 else |
2006 goto doend; | 1969 goto doend; |
2007 } | 1970 } |
2008 cmdmod.tab = tabnr + 1; | 1971 cmdmod.tab = tabnr + 1; |
2009 } | 1972 } |
2010 ea.cmd = p; | 1973 ea.cmd = p; |
2011 #endif | |
2012 continue; | 1974 continue; |
2013 } | 1975 } |
2014 if (!checkforcmd(&ea.cmd, "topleft", 2)) | 1976 if (!checkforcmd(&ea.cmd, "topleft", 2)) |
2015 break; | 1977 break; |
2016 #ifdef FEAT_WINDOWS | |
2017 cmdmod.split |= WSP_TOP; | 1978 cmdmod.split |= WSP_TOP; |
2018 #endif | |
2019 continue; | 1979 continue; |
2020 | 1980 |
2021 case 'u': if (!checkforcmd(&ea.cmd, "unsilent", 3)) | 1981 case 'u': if (!checkforcmd(&ea.cmd, "unsilent", 3)) |
2022 break; | 1982 break; |
2023 if (save_msg_silent == -1) | 1983 if (save_msg_silent == -1) |
2025 msg_silent = 0; | 1985 msg_silent = 0; |
2026 continue; | 1986 continue; |
2027 | 1987 |
2028 case 'v': if (checkforcmd(&ea.cmd, "vertical", 4)) | 1988 case 'v': if (checkforcmd(&ea.cmd, "vertical", 4)) |
2029 { | 1989 { |
2030 #ifdef FEAT_WINDOWS | |
2031 cmdmod.split |= WSP_VERT; | 1990 cmdmod.split |= WSP_VERT; |
2032 #endif | |
2033 continue; | 1991 continue; |
2034 } | 1992 } |
2035 if (!checkforcmd(&p, "verbose", 4)) | 1993 if (!checkforcmd(&p, "verbose", 4)) |
2036 break; | 1994 break; |
2037 if (verbose_save < 0) | 1995 if (verbose_save < 0) |
2110 if (ea.cmdidx != CMD_SIZE) | 2068 if (ea.cmdidx != CMD_SIZE) |
2111 ea.addr_type = cmdnames[(int)ea.cmdidx].cmd_addr_type; | 2069 ea.addr_type = cmdnames[(int)ea.cmdidx].cmd_addr_type; |
2112 else | 2070 else |
2113 ea.addr_type = ADDR_LINES; | 2071 ea.addr_type = ADDR_LINES; |
2114 | 2072 |
2115 #ifdef FEAT_WINDOWS | |
2116 /* :wincmd range depends on the argument. */ | 2073 /* :wincmd range depends on the argument. */ |
2117 if (ea.cmdidx == CMD_wincmd && p != NULL) | 2074 if (ea.cmdidx == CMD_wincmd && p != NULL) |
2118 get_wincmd_addr_type(skipwhite(p), &ea); | 2075 get_wincmd_addr_type(skipwhite(p), &ea); |
2119 #endif | |
2120 } | 2076 } |
2121 | 2077 |
2122 /* repeat for all ',' or ';' separated addresses */ | 2078 /* repeat for all ',' or ';' separated addresses */ |
2123 ea.cmd = cmd; | 2079 ea.cmd = cmd; |
2124 for (;;) | 2080 for (;;) |
6793 if (quote) | 6749 if (quote) |
6794 *buf++ = '"'; | 6750 *buf++ = '"'; |
6795 *buf = '\0'; | 6751 *buf = '\0'; |
6796 } | 6752 } |
6797 | 6753 |
6798 #ifdef FEAT_WINDOWS | |
6799 /* :aboveleft and :leftabove */ | 6754 /* :aboveleft and :leftabove */ |
6800 if (cmdmod.split & WSP_ABOVE) | 6755 if (cmdmod.split & WSP_ABOVE) |
6801 result += add_cmd_modifier(buf, "aboveleft", &multi_mods); | 6756 result += add_cmd_modifier(buf, "aboveleft", &multi_mods); |
6802 /* :belowright and :rightbelow */ | 6757 /* :belowright and :rightbelow */ |
6803 if (cmdmod.split & WSP_BELOW) | 6758 if (cmdmod.split & WSP_BELOW) |
6804 result += add_cmd_modifier(buf, "belowright", &multi_mods); | 6759 result += add_cmd_modifier(buf, "belowright", &multi_mods); |
6805 /* :botright */ | 6760 /* :botright */ |
6806 if (cmdmod.split & WSP_BOT) | 6761 if (cmdmod.split & WSP_BOT) |
6807 result += add_cmd_modifier(buf, "botright", &multi_mods); | 6762 result += add_cmd_modifier(buf, "botright", &multi_mods); |
6808 #endif | |
6809 | 6763 |
6810 /* the modifiers that are simple flags */ | 6764 /* the modifiers that are simple flags */ |
6811 for (i = 0; mod_entries[i].varp != NULL; ++i) | 6765 for (i = 0; mod_entries[i].varp != NULL; ++i) |
6812 if (*mod_entries[i].varp) | 6766 if (*mod_entries[i].varp) |
6813 result += add_cmd_modifier(buf, mod_entries[i].name, | 6767 result += add_cmd_modifier(buf, mod_entries[i].name, |
6819 #endif | 6773 #endif |
6820 /* :silent */ | 6774 /* :silent */ |
6821 if (msg_silent > 0) | 6775 if (msg_silent > 0) |
6822 result += add_cmd_modifier(buf, | 6776 result += add_cmd_modifier(buf, |
6823 emsg_silent > 0 ? "silent!" : "silent", &multi_mods); | 6777 emsg_silent > 0 ? "silent!" : "silent", &multi_mods); |
6824 #ifdef FEAT_WINDOWS | |
6825 /* :tab */ | 6778 /* :tab */ |
6826 if (cmdmod.tab > 0) | 6779 if (cmdmod.tab > 0) |
6827 result += add_cmd_modifier(buf, "tab", &multi_mods); | 6780 result += add_cmd_modifier(buf, "tab", &multi_mods); |
6828 /* :topleft */ | 6781 /* :topleft */ |
6829 if (cmdmod.split & WSP_TOP) | 6782 if (cmdmod.split & WSP_TOP) |
6830 result += add_cmd_modifier(buf, "topleft", &multi_mods); | 6783 result += add_cmd_modifier(buf, "topleft", &multi_mods); |
6831 #endif | |
6832 /* TODO: How to support :unsilent?*/ | 6784 /* TODO: How to support :unsilent?*/ |
6833 /* :verbose */ | 6785 /* :verbose */ |
6834 if (p_verbose > 0) | 6786 if (p_verbose > 0) |
6835 result += add_cmd_modifier(buf, "verbose", &multi_mods); | 6787 result += add_cmd_modifier(buf, "verbose", &multi_mods); |
6836 #ifdef FEAT_WINDOWS | |
6837 /* :vertical */ | 6788 /* :vertical */ |
6838 if (cmdmod.split & WSP_VERT) | 6789 if (cmdmod.split & WSP_VERT) |
6839 result += add_cmd_modifier(buf, "vertical", &multi_mods); | 6790 result += add_cmd_modifier(buf, "vertical", &multi_mods); |
6840 #endif | |
6841 if (quote && buf != NULL) | 6791 if (quote && buf != NULL) |
6842 { | 6792 { |
6843 buf += result - 2; | 6793 buf += result - 2; |
6844 *buf = '"'; | 6794 *buf = '"'; |
6845 } | 6795 } |
7268 * ":quit": quit current window, quit Vim if the last window is closed. | 7218 * ":quit": quit current window, quit Vim if the last window is closed. |
7269 */ | 7219 */ |
7270 static void | 7220 static void |
7271 ex_quit(exarg_T *eap) | 7221 ex_quit(exarg_T *eap) |
7272 { | 7222 { |
7273 #if defined(FEAT_WINDOWS) || defined(FEAT_AUTOCMD) | |
7274 win_T *wp; | 7223 win_T *wp; |
7275 #endif | |
7276 | 7224 |
7277 #ifdef FEAT_CMDWIN | 7225 #ifdef FEAT_CMDWIN |
7278 if (cmdwin_type != 0) | 7226 if (cmdwin_type != 0) |
7279 { | 7227 { |
7280 cmdwin_result = Ctrl_C; | 7228 cmdwin_result = Ctrl_C; |
7285 if (text_locked()) | 7233 if (text_locked()) |
7286 { | 7234 { |
7287 text_locked_msg(); | 7235 text_locked_msg(); |
7288 return; | 7236 return; |
7289 } | 7237 } |
7290 #ifdef FEAT_WINDOWS | |
7291 if (eap->addr_count > 0) | 7238 if (eap->addr_count > 0) |
7292 { | 7239 { |
7293 int wnr = eap->line2; | 7240 int wnr = eap->line2; |
7294 | 7241 |
7295 for (wp = firstwin; wp->w_next != NULL; wp = wp->w_next) | 7242 for (wp = firstwin; wp->w_next != NULL; wp = wp->w_next) |
7296 if (--wnr <= 0) | 7243 if (--wnr <= 0) |
7297 break; | 7244 break; |
7298 } | 7245 } |
7299 else | 7246 else |
7300 #endif | |
7301 #if defined(FEAT_WINDOWS) || defined(FEAT_AUTOCMD) | |
7302 wp = curwin; | 7247 wp = curwin; |
7303 #endif | |
7304 | 7248 |
7305 #ifdef FEAT_AUTOCMD | 7249 #ifdef FEAT_AUTOCMD |
7306 apply_autocmds(EVENT_QUITPRE, NULL, NULL, FALSE, curbuf); | 7250 apply_autocmds(EVENT_QUITPRE, NULL, NULL, FALSE, curbuf); |
7307 /* Refuse to quit when locked or when the buffer in the last window is | 7251 /* Refuse to quit when locked or when the buffer in the last window is |
7308 * being closed (can only happen in autocommands). */ | 7252 * being closed (can only happen in autocommands). */ |
7309 if (curbuf_locked() | 7253 if (curbuf_locked() || !win_valid(wp) |
7310 # ifdef FEAT_WINDOWS | |
7311 || !win_valid(wp) | |
7312 # endif | |
7313 || (wp->w_buffer->b_nwindows == 1 && wp->w_buffer->b_locked > 0)) | 7254 || (wp->w_buffer->b_nwindows == 1 && wp->w_buffer->b_locked > 0)) |
7314 return; | 7255 return; |
7315 #endif | 7256 #endif |
7316 | 7257 |
7317 #ifdef FEAT_NETBEANS_INTG | 7258 #ifdef FEAT_NETBEANS_INTG |
7332 { | 7273 { |
7333 not_exiting(); | 7274 not_exiting(); |
7334 } | 7275 } |
7335 else | 7276 else |
7336 { | 7277 { |
7337 #ifdef FEAT_WINDOWS | |
7338 /* quit last window | 7278 /* quit last window |
7339 * Note: only_one_window() returns true, even so a help window is | 7279 * Note: only_one_window() returns true, even so a help window is |
7340 * still open. In that case only quit, if no address has been | 7280 * still open. In that case only quit, if no address has been |
7341 * specified. Example: | 7281 * specified. Example: |
7342 * :h|wincmd w|1q - don't quit | 7282 * :h|wincmd w|1q - don't quit |
7343 * :h|wincmd w|q - quit | 7283 * :h|wincmd w|q - quit |
7344 */ | 7284 */ |
7345 if (only_one_window() && (ONE_WINDOW || eap->addr_count == 0)) | 7285 if (only_one_window() && (ONE_WINDOW || eap->addr_count == 0)) |
7346 #endif | |
7347 getout(0); | 7286 getout(0); |
7348 #ifdef FEAT_WINDOWS | 7287 #ifdef FEAT_GUI |
7349 # ifdef FEAT_GUI | |
7350 need_mouse_correct = TRUE; | 7288 need_mouse_correct = TRUE; |
7351 # endif | 7289 #endif |
7352 /* close window; may free buffer */ | 7290 /* close window; may free buffer */ |
7353 win_close(wp, !buf_hide(wp->w_buffer) || eap->forceit); | 7291 win_close(wp, !buf_hide(wp->w_buffer) || eap->forceit); |
7354 #endif | |
7355 } | 7292 } |
7356 } | 7293 } |
7357 | 7294 |
7358 /* | 7295 /* |
7359 * ":cquit". | 7296 * ":cquit". |
7400 if (eap->forceit || !check_changed_any(FALSE, FALSE)) | 7337 if (eap->forceit || !check_changed_any(FALSE, FALSE)) |
7401 getout(0); | 7338 getout(0); |
7402 not_exiting(); | 7339 not_exiting(); |
7403 } | 7340 } |
7404 | 7341 |
7405 #if defined(FEAT_WINDOWS) || defined(PROTO) | |
7406 /* | 7342 /* |
7407 * ":close": close current window, unless it is the last one | 7343 * ":close": close current window, unless it is the last one |
7408 */ | 7344 */ |
7409 static void | 7345 static void |
7410 ex_close(exarg_T *eap) | 7346 ex_close(exarg_T *eap) |
7411 { | 7347 { |
7412 win_T *win; | 7348 win_T *win; |
7413 int winnr = 0; | 7349 int winnr = 0; |
7414 # ifdef FEAT_CMDWIN | 7350 #ifdef FEAT_CMDWIN |
7415 if (cmdwin_type != 0) | 7351 if (cmdwin_type != 0) |
7416 cmdwin_result = Ctrl_C; | 7352 cmdwin_result = Ctrl_C; |
7417 else | 7353 else |
7418 # endif | 7354 #endif |
7419 if (!text_locked() | 7355 if (!text_locked() |
7420 #ifdef FEAT_AUTOCMD | 7356 #ifdef FEAT_AUTOCMD |
7421 && !curbuf_locked() | 7357 && !curbuf_locked() |
7422 #endif | 7358 #endif |
7423 ) | 7359 ) |
7436 ex_win_close(eap->forceit, win, NULL); | 7372 ex_win_close(eap->forceit, win, NULL); |
7437 } | 7373 } |
7438 } | 7374 } |
7439 } | 7375 } |
7440 | 7376 |
7441 # ifdef FEAT_QUICKFIX | 7377 #ifdef FEAT_QUICKFIX |
7442 /* | 7378 /* |
7443 * ":pclose": Close any preview window. | 7379 * ":pclose": Close any preview window. |
7444 */ | 7380 */ |
7445 static void | 7381 static void |
7446 ex_pclose(exarg_T *eap) | 7382 ex_pclose(exarg_T *eap) |
7452 { | 7388 { |
7453 ex_win_close(eap->forceit, win, NULL); | 7389 ex_win_close(eap->forceit, win, NULL); |
7454 break; | 7390 break; |
7455 } | 7391 } |
7456 } | 7392 } |
7457 # endif | 7393 #endif |
7458 | 7394 |
7459 /* | 7395 /* |
7460 * Close window "win" and take care of handling closing the last window for a | 7396 * Close window "win" and take care of handling closing the last window for a |
7461 * modified buffer. | 7397 * modified buffer. |
7462 */ | 7398 */ |
7470 buf_T *buf = win->w_buffer; | 7406 buf_T *buf = win->w_buffer; |
7471 | 7407 |
7472 need_hide = (bufIsChanged(buf) && buf->b_nwindows <= 1); | 7408 need_hide = (bufIsChanged(buf) && buf->b_nwindows <= 1); |
7473 if (need_hide && !buf_hide(buf) && !forceit) | 7409 if (need_hide && !buf_hide(buf) && !forceit) |
7474 { | 7410 { |
7475 # if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) | 7411 #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) |
7476 if ((p_confirm || cmdmod.confirm) && p_write) | 7412 if ((p_confirm || cmdmod.confirm) && p_write) |
7477 { | 7413 { |
7478 bufref_T bufref; | 7414 bufref_T bufref; |
7479 | 7415 |
7480 set_bufref(&bufref, buf); | 7416 set_bufref(&bufref, buf); |
7482 if (bufref_valid(&bufref) && bufIsChanged(buf)) | 7418 if (bufref_valid(&bufref) && bufIsChanged(buf)) |
7483 return; | 7419 return; |
7484 need_hide = FALSE; | 7420 need_hide = FALSE; |
7485 } | 7421 } |
7486 else | 7422 else |
7487 # endif | 7423 #endif |
7488 { | 7424 { |
7489 no_write_message(); | 7425 no_write_message(); |
7490 return; | 7426 return; |
7491 } | 7427 } |
7492 } | 7428 } |
7493 | 7429 |
7494 # ifdef FEAT_GUI | 7430 #ifdef FEAT_GUI |
7495 need_mouse_correct = TRUE; | 7431 need_mouse_correct = TRUE; |
7496 # endif | 7432 #endif |
7497 | 7433 |
7498 /* free buffer when not hiding it or when it's a scratch buffer */ | 7434 /* free buffer when not hiding it or when it's a scratch buffer */ |
7499 if (tp == NULL) | 7435 if (tp == NULL) |
7500 win_close(win, !need_hide && !buf_hide(buf)); | 7436 win_close(win, !need_hide && !buf_hide(buf)); |
7501 else | 7437 else |
7777 { | 7713 { |
7778 if (eap->addr_count == 0) | 7714 if (eap->addr_count == 0) |
7779 eap->line2 = 9999; | 7715 eap->line2 = 9999; |
7780 do_arg_all((int)eap->line2, eap->forceit, eap->cmdidx == CMD_drop); | 7716 do_arg_all((int)eap->line2, eap->forceit, eap->cmdidx == CMD_drop); |
7781 } | 7717 } |
7782 #endif /* FEAT_WINDOWS */ | |
7783 | 7718 |
7784 static void | 7719 static void |
7785 ex_hide(exarg_T *eap UNUSED) | 7720 ex_hide(exarg_T *eap UNUSED) |
7786 { | 7721 { |
7787 /* ":hide" or ":hide | cmd": hide current window */ | 7722 /* ":hide" or ":hide | cmd": hide current window */ |
7788 #ifdef FEAT_WINDOWS | |
7789 if (!eap->skip) | 7723 if (!eap->skip) |
7790 { | 7724 { |
7791 # ifdef FEAT_GUI | 7725 #ifdef FEAT_GUI |
7792 need_mouse_correct = TRUE; | 7726 need_mouse_correct = TRUE; |
7793 # endif | 7727 #endif |
7794 if (eap->addr_count == 0) | 7728 if (eap->addr_count == 0) |
7795 win_close(curwin, FALSE); /* don't free buffer */ | 7729 win_close(curwin, FALSE); /* don't free buffer */ |
7796 else | 7730 else |
7797 { | 7731 { |
7798 int winnr = 0; | 7732 int winnr = 0; |
7807 if (win == NULL) | 7741 if (win == NULL) |
7808 win = lastwin; | 7742 win = lastwin; |
7809 win_close(win, FALSE); | 7743 win_close(win, FALSE); |
7810 } | 7744 } |
7811 } | 7745 } |
7812 #endif | |
7813 } | 7746 } |
7814 | 7747 |
7815 /* | 7748 /* |
7816 * ":stop" and ":suspend": Suspend Vim. | 7749 * ":stop" and ":suspend": Suspend Vim. |
7817 */ | 7750 */ |
7885 { | 7818 { |
7886 not_exiting(); | 7819 not_exiting(); |
7887 } | 7820 } |
7888 else | 7821 else |
7889 { | 7822 { |
7890 #ifdef FEAT_WINDOWS | |
7891 if (only_one_window()) /* quit last window, exit Vim */ | 7823 if (only_one_window()) /* quit last window, exit Vim */ |
7892 #endif | |
7893 getout(0); | 7824 getout(0); |
7894 #ifdef FEAT_WINDOWS | |
7895 # ifdef FEAT_GUI | 7825 # ifdef FEAT_GUI |
7896 need_mouse_correct = TRUE; | 7826 need_mouse_correct = TRUE; |
7897 # endif | 7827 # endif |
7898 /* Quit current window, may free the buffer. */ | 7828 /* Quit current window, may free the buffer. */ |
7899 win_close(curwin, !buf_hide(curwin->w_buffer)); | 7829 win_close(curwin, !buf_hide(curwin->w_buffer)); |
7900 #endif | |
7901 } | 7830 } |
7902 } | 7831 } |
7903 | 7832 |
7904 /* | 7833 /* |
7905 * ":print", ":list", ":number". | 7834 * ":print", ":list", ":number". |
7945 ex_shell(exarg_T *eap UNUSED) | 7874 ex_shell(exarg_T *eap UNUSED) |
7946 { | 7875 { |
7947 do_shell(NULL, 0); | 7876 do_shell(NULL, 0); |
7948 } | 7877 } |
7949 | 7878 |
7950 #if (defined(FEAT_WINDOWS) && defined(HAVE_DROP_FILE)) \ | 7879 #if defined(HAVE_DROP_FILE) \ |
7951 || (defined(FEAT_GUI_GTK) && defined(FEAT_DND)) \ | 7880 || (defined(FEAT_GUI_GTK) && defined(FEAT_DND)) \ |
7952 || defined(FEAT_GUI_MSWIN) \ | 7881 || defined(FEAT_GUI_MSWIN) \ |
7953 || defined(FEAT_GUI_MAC) \ | 7882 || defined(FEAT_GUI_MAC) \ |
7954 || defined(PROTO) | 7883 || defined(PROTO) |
7955 | 7884 |
7998 split = check_changed(curbuf, CCGD_AW); | 7927 split = check_changed(curbuf, CCGD_AW); |
7999 --emsg_off; | 7928 --emsg_off; |
8000 } | 7929 } |
8001 if (split) | 7930 if (split) |
8002 { | 7931 { |
8003 # ifdef FEAT_WINDOWS | |
8004 if (win_split(0, 0) == FAIL) | 7932 if (win_split(0, 0) == FAIL) |
8005 return; | 7933 return; |
8006 RESET_BINDING(curwin); | 7934 RESET_BINDING(curwin); |
8007 | 7935 |
8008 /* When splitting the window, create a new alist. Otherwise the | 7936 /* When splitting the window, create a new alist. Otherwise the |
8009 * existing one is overwritten. */ | 7937 * existing one is overwritten. */ |
8010 alist_unlink(curwin->w_alist); | 7938 alist_unlink(curwin->w_alist); |
8011 alist_new(); | 7939 alist_new(); |
8012 # else | |
8013 return; /* can't split, always fail */ | |
8014 # endif | |
8015 } | 7940 } |
8016 | 7941 |
8017 /* | 7942 /* |
8018 * Set up the new argument list. | 7943 * Set up the new argument list. |
8019 */ | 7944 */ |
8056 alist_init(alist_T *al) | 7981 alist_init(alist_T *al) |
8057 { | 7982 { |
8058 ga_init2(&al->al_ga, (int)sizeof(aentry_T), 5); | 7983 ga_init2(&al->al_ga, (int)sizeof(aentry_T), 5); |
8059 } | 7984 } |
8060 | 7985 |
8061 #if defined(FEAT_WINDOWS) || defined(PROTO) | |
8062 | |
8063 /* | 7986 /* |
8064 * Remove a reference from an argument list. | 7987 * Remove a reference from an argument list. |
8065 * Ignored when the argument list is the global one. | 7988 * Ignored when the argument list is the global one. |
8066 * If the argument list is no longer used by any window, free it. | 7989 * If the argument list is no longer used by any window, free it. |
8067 */ | 7990 */ |
8073 alist_clear(al); | 7996 alist_clear(al); |
8074 vim_free(al); | 7997 vim_free(al); |
8075 } | 7998 } |
8076 } | 7999 } |
8077 | 8000 |
8078 # if defined(FEAT_LISTCMDS) || defined(HAVE_DROP_FILE) || defined(PROTO) | 8001 #if defined(FEAT_LISTCMDS) || defined(HAVE_DROP_FILE) || defined(PROTO) |
8079 /* | 8002 /* |
8080 * Create a new argument list and use it for the current window. | 8003 * Create a new argument list and use it for the current window. |
8081 */ | 8004 */ |
8082 void | 8005 void |
8083 alist_new(void) | 8006 alist_new(void) |
8093 curwin->w_alist->al_refcount = 1; | 8016 curwin->w_alist->al_refcount = 1; |
8094 curwin->w_alist->id = ++max_alist_id; | 8017 curwin->w_alist->id = ++max_alist_id; |
8095 alist_init(curwin->w_alist); | 8018 alist_init(curwin->w_alist); |
8096 } | 8019 } |
8097 } | 8020 } |
8098 # endif | |
8099 #endif | 8021 #endif |
8100 | 8022 |
8101 #if !defined(UNIX) || defined(PROTO) | 8023 #if !defined(UNIX) || defined(PROTO) |
8102 /* | 8024 /* |
8103 * Expand the file names in the global argument list. | 8025 * Expand the file names in the global argument list. |
8177 } | 8099 } |
8178 vim_free(files); | 8100 vim_free(files); |
8179 } | 8101 } |
8180 else | 8102 else |
8181 FreeWild(count, files); | 8103 FreeWild(count, files); |
8182 #ifdef FEAT_WINDOWS | |
8183 if (al == &global_alist) | 8104 if (al == &global_alist) |
8184 #endif | |
8185 arg_had_last = FALSE; | 8105 arg_had_last = FALSE; |
8186 } | 8106 } |
8187 | 8107 |
8188 /* | 8108 /* |
8189 * Add file "fname" to argument list "al". | 8109 * Add file "fname" to argument list "al". |
8213 */ | 8133 */ |
8214 void | 8134 void |
8215 alist_slash_adjust(void) | 8135 alist_slash_adjust(void) |
8216 { | 8136 { |
8217 int i; | 8137 int i; |
8218 # ifdef FEAT_WINDOWS | |
8219 win_T *wp; | 8138 win_T *wp; |
8220 tabpage_T *tp; | 8139 tabpage_T *tp; |
8221 # endif | |
8222 | 8140 |
8223 for (i = 0; i < GARGCOUNT; ++i) | 8141 for (i = 0; i < GARGCOUNT; ++i) |
8224 if (GARGLIST[i].ae_fname != NULL) | 8142 if (GARGLIST[i].ae_fname != NULL) |
8225 slash_adjust(GARGLIST[i].ae_fname); | 8143 slash_adjust(GARGLIST[i].ae_fname); |
8226 # ifdef FEAT_WINDOWS | |
8227 FOR_ALL_TAB_WINDOWS(tp, wp) | 8144 FOR_ALL_TAB_WINDOWS(tp, wp) |
8228 if (wp->w_alist != &global_alist) | 8145 if (wp->w_alist != &global_alist) |
8229 for (i = 0; i < WARGCOUNT(wp); ++i) | 8146 for (i = 0; i < WARGCOUNT(wp); ++i) |
8230 if (WARGLIST(wp)[i].ae_fname != NULL) | 8147 if (WARGLIST(wp)[i].ae_fname != NULL) |
8231 slash_adjust(WARGLIST(wp)[i].ae_fname); | 8148 slash_adjust(WARGLIST(wp)[i].ae_fname); |
8232 # endif | |
8233 } | 8149 } |
8234 #endif | 8150 #endif |
8235 | 8151 |
8236 /* | 8152 /* |
8237 * ":preserve". | 8153 * ":preserve". |
8269 ex_wrongmodifier(exarg_T *eap) | 8185 ex_wrongmodifier(exarg_T *eap) |
8270 { | 8186 { |
8271 eap->errmsg = e_invcmd; | 8187 eap->errmsg = e_invcmd; |
8272 } | 8188 } |
8273 | 8189 |
8274 #ifdef FEAT_WINDOWS | |
8275 /* | 8190 /* |
8276 * :sview [+command] file split window with new file, read-only | 8191 * :sview [+command] file split window with new file, read-only |
8277 * :split [[+command] file] split window with current or new file | 8192 * :split [[+command] file] split window with current or new file |
8278 * :vsplit [[+command] file] split window vertically with current or new file | 8193 * :vsplit [[+command] file] split window vertically with current or new file |
8279 * :new [[+command] file] split window with no or new file | 8194 * :new [[+command] file] split window with no or new file |
8287 */ | 8202 */ |
8288 void | 8203 void |
8289 ex_splitview(exarg_T *eap) | 8204 ex_splitview(exarg_T *eap) |
8290 { | 8205 { |
8291 win_T *old_curwin = curwin; | 8206 win_T *old_curwin = curwin; |
8292 # if defined(FEAT_SEARCHPATH) || defined(FEAT_BROWSE) | 8207 #if defined(FEAT_SEARCHPATH) || defined(FEAT_BROWSE) |
8293 char_u *fname = NULL; | 8208 char_u *fname = NULL; |
8294 # endif | 8209 #endif |
8295 # ifdef FEAT_BROWSE | 8210 #ifdef FEAT_BROWSE |
8296 int browse_flag = cmdmod.browse; | 8211 int browse_flag = cmdmod.browse; |
8297 # endif | 8212 #endif |
8298 | 8213 |
8299 # ifdef FEAT_GUI | 8214 #ifdef FEAT_GUI |
8300 need_mouse_correct = TRUE; | 8215 need_mouse_correct = TRUE; |
8301 # endif | 8216 #endif |
8302 | 8217 |
8303 # ifdef FEAT_QUICKFIX | 8218 #ifdef FEAT_QUICKFIX |
8304 /* A ":split" in the quickfix window works like ":new". Don't want two | 8219 /* A ":split" in the quickfix window works like ":new". Don't want two |
8305 * quickfix windows. But it's OK when doing ":tab split". */ | 8220 * quickfix windows. But it's OK when doing ":tab split". */ |
8306 if (bt_quickfix(curbuf) && cmdmod.tab == 0) | 8221 if (bt_quickfix(curbuf) && cmdmod.tab == 0) |
8307 { | 8222 { |
8308 if (eap->cmdidx == CMD_split) | 8223 if (eap->cmdidx == CMD_split) |
8309 eap->cmdidx = CMD_new; | 8224 eap->cmdidx = CMD_new; |
8310 if (eap->cmdidx == CMD_vsplit) | 8225 if (eap->cmdidx == CMD_vsplit) |
8311 eap->cmdidx = CMD_vnew; | 8226 eap->cmdidx = CMD_vnew; |
8312 } | 8227 } |
8313 # endif | 8228 #endif |
8314 | 8229 |
8315 # ifdef FEAT_SEARCHPATH | 8230 #ifdef FEAT_SEARCHPATH |
8316 if (eap->cmdidx == CMD_sfind || eap->cmdidx == CMD_tabfind) | 8231 if (eap->cmdidx == CMD_sfind || eap->cmdidx == CMD_tabfind) |
8317 { | 8232 { |
8318 fname = find_file_in_path(eap->arg, (int)STRLEN(eap->arg), | 8233 fname = find_file_in_path(eap->arg, (int)STRLEN(eap->arg), |
8319 FNAME_MESS, TRUE, curbuf->b_ffname); | 8234 FNAME_MESS, TRUE, curbuf->b_ffname); |
8320 if (fname == NULL) | 8235 if (fname == NULL) |
8321 goto theend; | 8236 goto theend; |
8322 eap->arg = fname; | 8237 eap->arg = fname; |
8323 } | 8238 } |
8324 # ifdef FEAT_BROWSE | 8239 # ifdef FEAT_BROWSE |
8325 else | 8240 else |
8326 # endif | |
8327 # endif | 8241 # endif |
8328 # ifdef FEAT_BROWSE | 8242 #endif |
8243 #ifdef FEAT_BROWSE | |
8329 if (cmdmod.browse | 8244 if (cmdmod.browse |
8330 && eap->cmdidx != CMD_vnew | 8245 && eap->cmdidx != CMD_vnew |
8331 && eap->cmdidx != CMD_new) | 8246 && eap->cmdidx != CMD_new) |
8332 { | 8247 { |
8333 # ifdef FEAT_AUTOCMD | 8248 # ifdef FEAT_AUTOCMD |
8351 goto theend; | 8266 goto theend; |
8352 eap->arg = fname; | 8267 eap->arg = fname; |
8353 } | 8268 } |
8354 } | 8269 } |
8355 cmdmod.browse = FALSE; /* Don't browse again in do_ecmd(). */ | 8270 cmdmod.browse = FALSE; /* Don't browse again in do_ecmd(). */ |
8356 # endif | 8271 #endif |
8357 | 8272 |
8358 /* | 8273 /* |
8359 * Either open new tab page or split the window. | 8274 * Either open new tab page or split the window. |
8360 */ | 8275 */ |
8361 if (eap->cmdidx == CMD_tabedit | 8276 if (eap->cmdidx == CMD_tabedit |
8532 ui_breakcheck(); | 8447 ui_breakcheck(); |
8533 } | 8448 } |
8534 } | 8449 } |
8535 } | 8450 } |
8536 | 8451 |
8537 #endif /* FEAT_WINDOWS */ | |
8538 | |
8539 /* | 8452 /* |
8540 * ":mode": Set screen mode. | 8453 * ":mode": Set screen mode. |
8541 * If no argument given, just get the screen size and redraw. | 8454 * If no argument given, just get the screen size and redraw. |
8542 */ | 8455 */ |
8543 static void | 8456 static void |
8547 shell_resized(); | 8460 shell_resized(); |
8548 else | 8461 else |
8549 mch_screenmode(eap->arg); | 8462 mch_screenmode(eap->arg); |
8550 } | 8463 } |
8551 | 8464 |
8552 #ifdef FEAT_WINDOWS | |
8553 /* | 8465 /* |
8554 * ":resize". | 8466 * ":resize". |
8555 * set, increment or decrement current window height | 8467 * set, increment or decrement current window height |
8556 */ | 8468 */ |
8557 static void | 8469 static void |
8586 else if (n == 0 && eap->arg[0] == NUL) /* default is very high */ | 8498 else if (n == 0 && eap->arg[0] == NUL) /* default is very high */ |
8587 n = 9999; | 8499 n = 9999; |
8588 win_setheight_win((int)n, wp); | 8500 win_setheight_win((int)n, wp); |
8589 } | 8501 } |
8590 } | 8502 } |
8591 #endif | |
8592 | 8503 |
8593 /* | 8504 /* |
8594 * ":find [+command] <file>" command. | 8505 * ":find [+command] <file>" command. |
8595 */ | 8506 */ |
8596 static void | 8507 static void |
8679 do_exedit( | 8590 do_exedit( |
8680 exarg_T *eap, | 8591 exarg_T *eap, |
8681 win_T *old_curwin) /* curwin before doing a split or NULL */ | 8592 win_T *old_curwin) /* curwin before doing a split or NULL */ |
8682 { | 8593 { |
8683 int n; | 8594 int n; |
8684 #ifdef FEAT_WINDOWS | |
8685 int need_hide; | 8595 int need_hide; |
8686 #endif | |
8687 int exmode_was = exmode_active; | 8596 int exmode_was = exmode_active; |
8688 | 8597 |
8689 /* | 8598 /* |
8690 * ":vi" command ends Ex mode. | 8599 * ":vi" command ends Ex mode. |
8691 */ | 8600 */ |
8736 } | 8645 } |
8737 | 8646 |
8738 if ((eap->cmdidx == CMD_new | 8647 if ((eap->cmdidx == CMD_new |
8739 || eap->cmdidx == CMD_tabnew | 8648 || eap->cmdidx == CMD_tabnew |
8740 || eap->cmdidx == CMD_tabedit | 8649 || eap->cmdidx == CMD_tabedit |
8741 #ifdef FEAT_WINDOWS | 8650 || eap->cmdidx == CMD_vnew) && *eap->arg == NUL) |
8742 || eap->cmdidx == CMD_vnew | |
8743 #endif | |
8744 ) && *eap->arg == NUL) | |
8745 { | 8651 { |
8746 /* ":new" or ":tabnew" without argument: edit an new empty buffer */ | 8652 /* ":new" or ":tabnew" without argument: edit an new empty buffer */ |
8747 setpcmark(); | 8653 setpcmark(); |
8748 (void)do_ecmd(0, NULL, NULL, eap, ECMD_ONE, | 8654 (void)do_ecmd(0, NULL, NULL, eap, ECMD_ONE, |
8749 ECMD_HIDE + (eap->forceit ? ECMD_FORCEIT : 0), | 8655 ECMD_HIDE + (eap->forceit ? ECMD_FORCEIT : 0), |
8750 old_curwin == NULL ? curwin : NULL); | 8656 old_curwin == NULL ? curwin : NULL); |
8751 } | 8657 } |
8752 else if ((eap->cmdidx != CMD_split | 8658 else if ((eap->cmdidx != CMD_split && eap->cmdidx != CMD_vsplit) |
8753 #ifdef FEAT_WINDOWS | |
8754 && eap->cmdidx != CMD_vsplit | |
8755 #endif | |
8756 ) | |
8757 || *eap->arg != NUL | 8659 || *eap->arg != NUL |
8758 #ifdef FEAT_BROWSE | 8660 #ifdef FEAT_BROWSE |
8759 || cmdmod.browse | 8661 || cmdmod.browse |
8760 #endif | 8662 #endif |
8761 ) | 8663 ) |
8787 + (eap->cmdidx == CMD_badd ? ECMD_ADDBUF : 0 ) | 8689 + (eap->cmdidx == CMD_badd ? ECMD_ADDBUF : 0 ) |
8788 #endif | 8690 #endif |
8789 , old_curwin == NULL ? curwin : NULL) == FAIL) | 8691 , old_curwin == NULL ? curwin : NULL) == FAIL) |
8790 { | 8692 { |
8791 /* Editing the file failed. If the window was split, close it. */ | 8693 /* Editing the file failed. If the window was split, close it. */ |
8792 #ifdef FEAT_WINDOWS | |
8793 if (old_curwin != NULL) | 8694 if (old_curwin != NULL) |
8794 { | 8695 { |
8795 need_hide = (curbufIsChanged() && curbuf->b_nwindows <= 1); | 8696 need_hide = (curbufIsChanged() && curbuf->b_nwindows <= 1); |
8796 if (!need_hide || buf_hide(curbuf)) | 8697 if (!need_hide || buf_hide(curbuf)) |
8797 { | 8698 { |
8798 # if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL) | 8699 #if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL) |
8799 cleanup_T cs; | 8700 cleanup_T cs; |
8800 | 8701 |
8801 /* Reset the error/interrupt/exception state here so that | 8702 /* Reset the error/interrupt/exception state here so that |
8802 * aborting() returns FALSE when closing a window. */ | 8703 * aborting() returns FALSE when closing a window. */ |
8803 enter_cleanup(&cs); | 8704 enter_cleanup(&cs); |
8804 # endif | 8705 #endif |
8805 # ifdef FEAT_GUI | 8706 #ifdef FEAT_GUI |
8806 need_mouse_correct = TRUE; | 8707 need_mouse_correct = TRUE; |
8807 # endif | 8708 #endif |
8808 win_close(curwin, !need_hide && !buf_hide(curbuf)); | 8709 win_close(curwin, !need_hide && !buf_hide(curbuf)); |
8809 | 8710 |
8810 # if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL) | 8711 #if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL) |
8811 /* Restore the error/interrupt/exception state if not | 8712 /* Restore the error/interrupt/exception state if not |
8812 * discarded by a new aborting error, interrupt, or | 8713 * discarded by a new aborting error, interrupt, or |
8813 * uncaught exception. */ | 8714 * uncaught exception. */ |
8814 leave_cleanup(&cs); | 8715 leave_cleanup(&cs); |
8815 # endif | 8716 #endif |
8816 } | 8717 } |
8817 } | 8718 } |
8818 #endif | |
8819 } | 8719 } |
8820 else if (readonlymode && curbuf->b_nwindows == 1) | 8720 else if (readonlymode && curbuf->b_nwindows == 1) |
8821 { | 8721 { |
8822 /* When editing an already visited buffer, 'readonly' won't be set | 8722 /* When editing an already visited buffer, 'readonly' won't be set |
8823 * but the previous value is kept. With ":view" and ":sview" we | 8723 * but the previous value is kept. With ":view" and ":sview" we |
8839 if (n != curwin->w_arg_idx_invalid) | 8739 if (n != curwin->w_arg_idx_invalid) |
8840 maketitle(); | 8740 maketitle(); |
8841 #endif | 8741 #endif |
8842 } | 8742 } |
8843 | 8743 |
8844 #ifdef FEAT_WINDOWS | |
8845 /* | 8744 /* |
8846 * if ":split file" worked, set alternate file name in old window to new | 8745 * if ":split file" worked, set alternate file name in old window to new |
8847 * file | 8746 * file |
8848 */ | 8747 */ |
8849 if (old_curwin != NULL | 8748 if (old_curwin != NULL |
8851 && curwin != old_curwin | 8750 && curwin != old_curwin |
8852 && win_valid(old_curwin) | 8751 && win_valid(old_curwin) |
8853 && old_curwin->w_buffer != curbuf | 8752 && old_curwin->w_buffer != curbuf |
8854 && !cmdmod.keepalt) | 8753 && !cmdmod.keepalt) |
8855 old_curwin->w_alt_fnum = curbuf->b_fnum; | 8754 old_curwin->w_alt_fnum = curbuf->b_fnum; |
8856 #endif | |
8857 | 8755 |
8858 ex_no_reprint = TRUE; | 8756 ex_no_reprint = TRUE; |
8859 } | 8757 } |
8860 | 8758 |
8861 #ifndef FEAT_GUI | 8759 #ifndef FEAT_GUI |
8950 else | 8848 else |
8951 scrolldown(-y, TRUE); | 8849 scrolldown(-y, TRUE); |
8952 curwin->w_scbind_pos = topline; | 8850 curwin->w_scbind_pos = topline; |
8953 redraw_later(VALID); | 8851 redraw_later(VALID); |
8954 cursor_correct(); | 8852 cursor_correct(); |
8955 #ifdef FEAT_WINDOWS | |
8956 curwin->w_redr_status = TRUE; | 8853 curwin->w_redr_status = TRUE; |
8957 #endif | |
8958 } | 8854 } |
8959 } | 8855 } |
8960 curwin = save_curwin; | 8856 curwin = save_curwin; |
8961 curbuf = save_curbuf; | 8857 curbuf = save_curbuf; |
8962 if (curwin->w_p_scb) | 8858 if (curwin->w_p_scb) |
9307 set_shellsize(w, h, TRUE); | 9203 set_shellsize(w, h, TRUE); |
9308 else | 9204 else |
9309 EMSG(_("E465: :winsize requires two number arguments")); | 9205 EMSG(_("E465: :winsize requires two number arguments")); |
9310 } | 9206 } |
9311 | 9207 |
9312 #ifdef FEAT_WINDOWS | |
9313 static void | 9208 static void |
9314 ex_wincmd(exarg_T *eap) | 9209 ex_wincmd(exarg_T *eap) |
9315 { | 9210 { |
9316 int xchar = NUL; | 9211 int xchar = NUL; |
9317 char_u *p; | 9212 char_u *p; |
9342 do_window(*eap->arg, eap->addr_count > 0 ? eap->line2 : 0L, xchar); | 9237 do_window(*eap->arg, eap->addr_count > 0 ? eap->line2 : 0L, xchar); |
9343 postponed_split_flags = 0; | 9238 postponed_split_flags = 0; |
9344 postponed_split_tab = 0; | 9239 postponed_split_tab = 0; |
9345 } | 9240 } |
9346 } | 9241 } |
9347 #endif | |
9348 | 9242 |
9349 #if defined(FEAT_GUI) || defined(UNIX) || defined(VMS) || defined(MSWIN) | 9243 #if defined(FEAT_GUI) || defined(UNIX) || defined(VMS) || defined(MSWIN) |
9350 /* | 9244 /* |
9351 * ":winpos". | 9245 * ":winpos". |
9352 */ | 9246 */ |
9863 * ":redrawstatus": force redraw of status line(s) | 9757 * ":redrawstatus": force redraw of status line(s) |
9864 */ | 9758 */ |
9865 static void | 9759 static void |
9866 ex_redrawstatus(exarg_T *eap UNUSED) | 9760 ex_redrawstatus(exarg_T *eap UNUSED) |
9867 { | 9761 { |
9868 #if defined(FEAT_WINDOWS) | |
9869 int r = RedrawingDisabled; | 9762 int r = RedrawingDisabled; |
9870 int p = p_lz; | 9763 int p = p_lz; |
9871 | 9764 |
9872 RedrawingDisabled = 0; | 9765 RedrawingDisabled = 0; |
9873 p_lz = FALSE; | 9766 p_lz = FALSE; |
9877 status_redraw_curbuf(); | 9770 status_redraw_curbuf(); |
9878 update_screen(VIsual_active ? INVERTED : 0); | 9771 update_screen(VIsual_active ? INVERTED : 0); |
9879 RedrawingDisabled = r; | 9772 RedrawingDisabled = r; |
9880 p_lz = p; | 9773 p_lz = p; |
9881 out_flush(); | 9774 out_flush(); |
9882 #endif | |
9883 } | 9775 } |
9884 | 9776 |
9885 static void | 9777 static void |
9886 close_redir(void) | 9778 close_redir(void) |
9887 { | 9779 { |
10455 find_pattern_in_path(NULL, 0, 0, FALSE, FALSE, CHECK_PATH, 1L, | 10347 find_pattern_in_path(NULL, 0, 0, FALSE, FALSE, CHECK_PATH, 1L, |
10456 eap->forceit ? ACTION_SHOW_ALL : ACTION_SHOW, | 10348 eap->forceit ? ACTION_SHOW_ALL : ACTION_SHOW, |
10457 (linenr_T)1, (linenr_T)MAXLNUM); | 10349 (linenr_T)1, (linenr_T)MAXLNUM); |
10458 } | 10350 } |
10459 | 10351 |
10460 #if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX) | 10352 #if defined(FEAT_QUICKFIX) |
10461 /* | 10353 /* |
10462 * ":psearch" | 10354 * ":psearch" |
10463 */ | 10355 */ |
10464 static void | 10356 static void |
10465 ex_psearch(exarg_T *eap) | 10357 ex_psearch(exarg_T *eap) |
10526 *eap->cmd == 'd' ? FIND_DEFINE : FIND_ANY, | 10418 *eap->cmd == 'd' ? FIND_DEFINE : FIND_ANY, |
10527 n, action, eap->line1, eap->line2); | 10419 n, action, eap->line1, eap->line2); |
10528 } | 10420 } |
10529 #endif | 10421 #endif |
10530 | 10422 |
10531 #ifdef FEAT_WINDOWS | 10423 |
10532 | 10424 #ifdef FEAT_QUICKFIX |
10533 # ifdef FEAT_QUICKFIX | |
10534 /* | 10425 /* |
10535 * ":ptag", ":ptselect", ":ptjump", ":ptnext", etc. | 10426 * ":ptag", ":ptselect", ":ptjump", ":ptnext", etc. |
10536 */ | 10427 */ |
10537 static void | 10428 static void |
10538 ex_ptag(exarg_T *eap) | 10429 ex_ptag(exarg_T *eap) |
10561 redraw_later(VALID); | 10452 redraw_later(VALID); |
10562 win_enter(curwin_save, TRUE); | 10453 win_enter(curwin_save, TRUE); |
10563 } | 10454 } |
10564 g_do_tagpreview = 0; | 10455 g_do_tagpreview = 0; |
10565 } | 10456 } |
10566 # endif | 10457 #endif |
10567 | 10458 |
10568 /* | 10459 /* |
10569 * ":stag", ":stselect" and ":stjump". | 10460 * ":stag", ":stselect" and ":stjump". |
10570 */ | 10461 */ |
10571 static void | 10462 static void |
10576 postponed_split_tab = cmdmod.tab; | 10467 postponed_split_tab = cmdmod.tab; |
10577 ex_tag_cmd(eap, cmdnames[eap->cmdidx].cmd_name + 1); | 10468 ex_tag_cmd(eap, cmdnames[eap->cmdidx].cmd_name + 1); |
10578 postponed_split_flags = 0; | 10469 postponed_split_flags = 0; |
10579 postponed_split_tab = 0; | 10470 postponed_split_tab = 0; |
10580 } | 10471 } |
10581 #endif | |
10582 | 10472 |
10583 /* | 10473 /* |
10584 * ":tag", ":tselect", ":tjump", ":tnext", etc. | 10474 * ":tag", ":tselect", ":tjump", ":tnext", etc. |
10585 */ | 10475 */ |
10586 static void | 10476 static void |