Mercurial > vim
annotate src/ex_docmd.c @ 18713:baf890fa1621 v8.1.2348
patch 8.1.2348: :const cannot be followed by "| endif"
Commit: https://github.com/vim/vim/commit/8f76e6b12b958f2779444a92234bbaf3f49eeb99
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Nov 26 16:50:30 2019 +0100
patch 8.1.2348: :const cannot be followed by "| endif"
Problem: :const cannot be followed by "| endif".
Solution: Check following command for :const. (closes https://github.com/vim/vim/issues/5269)
Also fix completion after :const.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 26 Nov 2019 17:00:04 +0100 |
parents | fa6efc49d71f |
children | bd4c34db84ab |
rev | line source |
---|---|
10042
4aead6a9b7a9
commit https://github.com/vim/vim/commit/edf3f97ae2af024708ebb4ac614227327033ca47
Christian Brabandt <cb@256bit.org>
parents:
9980
diff
changeset
|
1 /* vi:set ts=8 sts=4 sw=4 noet: |
7 | 2 * |
3 * VIM - Vi IMproved by Bram Moolenaar | |
4 * | |
5 * Do ":help uganda" in Vim to read copying and usage conditions. | |
6 * Do ":help credits" in Vim to see a list of people who contributed. | |
7 * See README.txt for an overview of the Vim source code. | |
8 */ | |
9 | |
10 /* | |
11 * ex_docmd.c: functions for executing an Ex command line. | |
12 */ | |
13 | |
14 #include "vim.h" | |
15 | |
16 static int quitmore = 0; | |
17 static int ex_pressedreturn = FALSE; | |
18 #ifndef FEAT_PRINTER | |
19 # define ex_hardcopy ex_ni | |
20 #endif | |
21 | |
22 #ifdef FEAT_EVAL | |
17178
40c4cb095d53
patch 8.1.1588: in :let-heredoc line continuation is recognized
Bram Moolenaar <Bram@vim.org>
parents:
17111
diff
changeset
|
23 static char_u *do_one_cmd(char_u **, int, struct condstack *, char_u *(*fgetline)(int, void *, int, int), void *cookie); |
7 | 24 #else |
17178
40c4cb095d53
patch 8.1.1588: in :let-heredoc line continuation is recognized
Bram Moolenaar <Bram@vim.org>
parents:
17111
diff
changeset
|
25 static char_u *do_one_cmd(char_u **, int, char_u *(*fgetline)(int, void *, int, int), void *cookie); |
7 | 26 static int if_level = 0; /* depth in :if */ |
27 #endif | |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
28 static void free_cmdmod(void); |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
29 static void append_command(char_u *cmd); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
30 static char_u *find_command(exarg_T *eap, int *full); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
31 |
7 | 32 #ifndef FEAT_MENU |
33 # define ex_emenu ex_ni | |
34 # define ex_menu ex_ni | |
35 # define ex_menutranslate ex_ni | |
36 #endif | |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
37 static void ex_autocmd(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
38 static void ex_doautocmd(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
39 static void ex_bunload(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
40 static void ex_buffer(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
41 static void ex_bmodified(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
42 static void ex_bnext(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
43 static void ex_bprevious(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
44 static void ex_brewind(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
45 static void ex_blast(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
46 static char_u *getargcmd(char_u **); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
47 static int getargopt(exarg_T *eap); |
7 | 48 #ifndef FEAT_QUICKFIX |
49 # define ex_make ex_ni | |
41 | 50 # define ex_cbuffer ex_ni |
7 | 51 # define ex_cc ex_ni |
52 # define ex_cnext ex_ni | |
16505
28e3ba82d8c8
patch 8.1.1256: cannot navigate through errors relative to the cursor
Bram Moolenaar <Bram@vim.org>
parents:
16479
diff
changeset
|
53 # define ex_cbelow ex_ni |
7 | 54 # define ex_cfile ex_ni |
55 # define qf_list ex_ni | |
56 # define qf_age ex_ni | |
9538
26da1efa9e46
commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
57 # define qf_history ex_ni |
7 | 58 # define ex_helpgrep ex_ni |
41 | 59 # define ex_vimgrep ex_ni |
7 | 60 #endif |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
61 #if !defined(FEAT_QUICKFIX) |
7 | 62 # define ex_cclose ex_ni |
63 # define ex_copen ex_ni | |
64 # define ex_cwindow ex_ni | |
9432
abb72f0b9e06
commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents:
9284
diff
changeset
|
65 # define ex_cbottom ex_ni |
7 | 66 #endif |
532 | 67 #if !defined(FEAT_QUICKFIX) || !defined(FEAT_EVAL) |
68 # define ex_cexpr ex_ni | |
69 #endif | |
7 | 70 |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
71 static linenr_T get_address(exarg_T *, char_u **, cmd_addr_T addr_type, int skip, int silent, int to_other_file, int address_count); |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
72 static void get_flags(exarg_T *eap); |
2333
aee7e1e5e0ce
Build problem when using all interfaces except Lua.
Bram Moolenaar <bram@vim.org>
parents:
2330
diff
changeset
|
73 #if !defined(FEAT_PERL) \ |
aee7e1e5e0ce
Build problem when using all interfaces except Lua.
Bram Moolenaar <bram@vim.org>
parents:
2330
diff
changeset
|
74 || !defined(FEAT_PYTHON) || !defined(FEAT_PYTHON3) \ |
aee7e1e5e0ce
Build problem when using all interfaces except Lua.
Bram Moolenaar <bram@vim.org>
parents:
2330
diff
changeset
|
75 || !defined(FEAT_TCL) \ |
aee7e1e5e0ce
Build problem when using all interfaces except Lua.
Bram Moolenaar <bram@vim.org>
parents:
2330
diff
changeset
|
76 || !defined(FEAT_RUBY) \ |
aee7e1e5e0ce
Build problem when using all interfaces except Lua.
Bram Moolenaar <bram@vim.org>
parents:
2330
diff
changeset
|
77 || !defined(FEAT_LUA) \ |
aee7e1e5e0ce
Build problem when using all interfaces except Lua.
Bram Moolenaar <bram@vim.org>
parents:
2330
diff
changeset
|
78 || !defined(FEAT_MZSCHEME) |
1315 | 79 # define HAVE_EX_SCRIPT_NI |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
80 static void ex_script_ni(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
81 #endif |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
82 static char *invalid_range(exarg_T *eap); |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
83 static void correct_range(exarg_T *eap); |
344 | 84 #ifdef FEAT_QUICKFIX |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
85 static char_u *replace_makeprg(exarg_T *eap, char_u *p, char_u **cmdlinep); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
86 #endif |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
87 static char_u *repl_cmdline(exarg_T *eap, char_u *src, int srclen, char_u *repl, char_u **cmdlinep); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
88 static void ex_highlight(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
89 static void ex_colorscheme(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
90 static void ex_cquit(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
91 static void ex_quit_all(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
92 static void ex_close(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
93 static void ex_win_close(int forceit, win_T *win, tabpage_T *tp); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
94 static void ex_only(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
95 static void ex_resize(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
96 static void ex_stag(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
97 static void ex_tabclose(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
98 static void ex_tabonly(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
99 static void ex_tabnext(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
100 static void ex_tabmove(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
101 static void ex_tabs(exarg_T *eap); |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
102 #if defined(FEAT_QUICKFIX) |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
103 static void ex_pclose(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
104 static void ex_ptag(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
105 static void ex_pedit(exarg_T *eap); |
7 | 106 #else |
107 # define ex_pclose ex_ni | |
108 # define ex_ptag ex_ni | |
109 # define ex_pedit ex_ni | |
110 #endif | |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
111 static void ex_hide(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
112 static void ex_stop(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
113 static void ex_exit(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
114 static void ex_print(exarg_T *eap); |
7 | 115 #ifdef FEAT_BYTEOFF |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
116 static void ex_goto(exarg_T *eap); |
7 | 117 #else |
118 # define ex_goto ex_ni | |
119 #endif | |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
120 static void ex_shell(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
121 static void ex_preserve(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
122 static void ex_recover(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
123 static void ex_mode(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
124 static void ex_wrongmodifier(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
125 static void ex_find(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
126 static void ex_open(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
127 static void ex_edit(exarg_T *eap); |
7 | 128 #ifndef FEAT_GUI |
129 # define ex_gui ex_nogui | |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
130 static void ex_nogui(exarg_T *eap); |
7 | 131 #endif |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15866
diff
changeset
|
132 #if defined(FEAT_GUI_MSWIN) && defined(FEAT_MENU) && defined(FEAT_TEAROFF) |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
133 static void ex_tearoff(exarg_T *eap); |
7 | 134 #else |
135 # define ex_tearoff ex_ni | |
136 #endif | |
13392
d5347779fb20
patch 8.0.1570: can't use :popup for a menu in the terminal
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
137 #if (defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_GTK) \ |
d5347779fb20
patch 8.0.1570: can't use :popup for a menu in the terminal
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
138 || defined(FEAT_TERM_POPUP_MENU)) && defined(FEAT_MENU) |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
139 static void ex_popup(exarg_T *eap); |
7 | 140 #else |
141 # define ex_popup ex_ni | |
142 #endif | |
143 #ifndef FEAT_GUI_MSWIN | |
144 # define ex_simalt ex_ni | |
145 #endif | |
573 | 146 #if !defined(FEAT_GUI_MSWIN) && !defined(FEAT_GUI_GTK) && !defined(FEAT_GUI_MOTIF) |
7 | 147 # define gui_mch_find_dialog ex_ni |
148 # define gui_mch_replace_dialog ex_ni | |
149 #endif | |
573 | 150 #if !defined(FEAT_GUI_GTK) |
7 | 151 # define ex_helpfind ex_ni |
152 #endif | |
153 #ifndef FEAT_CSCOPE | |
10373
bd674706408a
commit https://github.com/vim/vim/commit/d4db7719bdfbc54df396eac08d8cbb2389feacf4
Christian Brabandt <cb@256bit.org>
parents:
10361
diff
changeset
|
154 # define ex_cscope ex_ni |
bd674706408a
commit https://github.com/vim/vim/commit/d4db7719bdfbc54df396eac08d8cbb2389feacf4
Christian Brabandt <cb@256bit.org>
parents:
10361
diff
changeset
|
155 # define ex_scscope ex_ni |
bd674706408a
commit https://github.com/vim/vim/commit/d4db7719bdfbc54df396eac08d8cbb2389feacf4
Christian Brabandt <cb@256bit.org>
parents:
10361
diff
changeset
|
156 # define ex_cstag ex_ni |
7 | 157 #endif |
158 #ifndef FEAT_SYN_HL | |
159 # define ex_syntax ex_ni | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2238
diff
changeset
|
160 # define ex_ownsyntax ex_ni |
737 | 161 #endif |
4766
ec24ff78a79c
updated for version 7.3.1130
Bram Moolenaar <bram@vim.org>
parents:
4764
diff
changeset
|
162 #if !defined(FEAT_SYN_HL) || !defined(FEAT_PROFILE) |
4764
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4710
diff
changeset
|
163 # define ex_syntime ex_ni |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4710
diff
changeset
|
164 #endif |
737 | 165 #ifndef FEAT_SPELL |
310 | 166 # define ex_spell ex_ni |
236 | 167 # define ex_mkspell ex_ni |
351 | 168 # define ex_spelldump ex_ni |
714 | 169 # define ex_spellinfo ex_ni |
372 | 170 # define ex_spellrepall ex_ni |
236 | 171 #endif |
2214
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
172 #ifndef FEAT_PERSISTENT_UNDO |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
173 # define ex_rundo ex_ni |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
174 # define ex_wundo ex_ni |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
175 #endif |
2320
966a5609669e
Added Lua interfae. (Luis Carvalho)
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
176 #ifndef FEAT_LUA |
966a5609669e
Added Lua interfae. (Luis Carvalho)
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
177 # define ex_lua ex_script_ni |
966a5609669e
Added Lua interfae. (Luis Carvalho)
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
178 # define ex_luado ex_ni |
966a5609669e
Added Lua interfae. (Luis Carvalho)
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
179 # define ex_luafile ex_ni |
966a5609669e
Added Lua interfae. (Luis Carvalho)
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
180 #endif |
14 | 181 #ifndef FEAT_MZSCHEME |
182 # define ex_mzscheme ex_script_ni | |
183 # define ex_mzfile ex_ni | |
184 #endif | |
7 | 185 #ifndef FEAT_PERL |
186 # define ex_perl ex_script_ni | |
187 # define ex_perldo ex_ni | |
188 #endif | |
189 #ifndef FEAT_PYTHON | |
190 # define ex_python ex_script_ni | |
4435 | 191 # define ex_pydo ex_ni |
7 | 192 # define ex_pyfile ex_ni |
193 #endif | |
2329
ad2889f48843
Added support for Python 3. (Roland Puntaier)
Bram Moolenaar <bram@vim.org>
parents:
2320
diff
changeset
|
194 #ifndef FEAT_PYTHON3 |
2350
06feaf4fe36a
Rename some "python3" symbols to "py3", as the command name.
Bram Moolenaar <bram@vim.org>
parents:
2340
diff
changeset
|
195 # define ex_py3 ex_script_ni |
4417 | 196 # define ex_py3do ex_ni |
2329
ad2889f48843
Added support for Python 3. (Roland Puntaier)
Bram Moolenaar <bram@vim.org>
parents:
2320
diff
changeset
|
197 # define ex_py3file ex_ni |
ad2889f48843
Added support for Python 3. (Roland Puntaier)
Bram Moolenaar <bram@vim.org>
parents:
2320
diff
changeset
|
198 #endif |
10722
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10656
diff
changeset
|
199 #if !defined(FEAT_PYTHON) && !defined(FEAT_PYTHON3) |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10656
diff
changeset
|
200 # define ex_pyx ex_script_ni |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10656
diff
changeset
|
201 # define ex_pyxdo ex_ni |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10656
diff
changeset
|
202 # define ex_pyxfile ex_ni |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10656
diff
changeset
|
203 #endif |
7 | 204 #ifndef FEAT_TCL |
205 # define ex_tcl ex_script_ni | |
206 # define ex_tcldo ex_ni | |
207 # define ex_tclfile ex_ni | |
208 #endif | |
209 #ifndef FEAT_RUBY | |
210 # define ex_ruby ex_script_ni | |
211 # define ex_rubydo ex_ni | |
212 # define ex_rubyfile ex_ni | |
213 #endif | |
214 #ifndef FEAT_KEYMAP | |
215 # define ex_loadkeymap ex_ni | |
216 #endif | |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
217 static void ex_swapname(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
218 static void ex_syncbind(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
219 static void ex_read(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
220 static void ex_pwd(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
221 static void ex_equal(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
222 static void ex_sleep(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
223 static void ex_winsize(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
224 static void ex_wincmd(exarg_T *eap); |
11 | 225 #if defined(FEAT_GUI) || defined(UNIX) || defined(VMS) || defined(MSWIN) |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
226 static void ex_winpos(exarg_T *eap); |
7 | 227 #else |
228 # define ex_winpos ex_ni | |
229 #endif | |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
230 static void ex_operators(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
231 static void ex_put(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
232 static void ex_copymove(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
233 static void ex_submagic(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
234 static void ex_join(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
235 static void ex_at(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
236 static void ex_bang(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
237 static void ex_undo(exarg_T *eap); |
2214
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
238 #ifdef FEAT_PERSISTENT_UNDO |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
239 static void ex_wundo(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
240 static void ex_rundo(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
241 #endif |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
242 static void ex_redo(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
243 static void ex_later(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
244 static void ex_redir(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
245 static void ex_redrawstatus(exarg_T *eap); |
15396
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
246 static void ex_redrawtabline(exarg_T *eap); |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
247 static void close_redir(void); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
248 static void ex_mark(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
249 static void ex_startinsert(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
250 static void ex_stopinsert(exarg_T *eap); |
7 | 251 #ifdef FEAT_FIND_ID |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
252 static void ex_checkpath(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
253 static void ex_findpat(exarg_T *eap); |
7 | 254 #else |
255 # define ex_findpat ex_ni | |
256 # define ex_checkpath ex_ni | |
257 #endif | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
258 #if defined(FEAT_FIND_ID) && defined(FEAT_QUICKFIX) |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
259 static void ex_psearch(exarg_T *eap); |
7 | 260 #else |
261 # define ex_psearch ex_ni | |
262 #endif | |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
263 static void ex_tag(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
264 static void ex_tag_cmd(exarg_T *eap, char_u *name); |
7 | 265 #ifndef FEAT_EVAL |
17622
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
266 # define ex_break ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
267 # define ex_breakadd ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
268 # define ex_breakdel ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
269 # define ex_breaklist ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
270 # define ex_call ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
271 # define ex_catch ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
272 # define ex_compiler ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
273 # define ex_const ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
274 # define ex_continue ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
275 # define ex_debug ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
276 # define ex_debuggreedy ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
277 # define ex_delfunction ex_ni |
7 | 278 # define ex_echo ex_ni |
279 # define ex_echohl ex_ni | |
17622
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
280 # define ex_else ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
281 # define ex_endfunction ex_ni |
7 | 282 # define ex_endif ex_ni |
17622
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
283 # define ex_endtry ex_ni |
7 | 284 # define ex_endwhile ex_ni |
17622
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
285 # define ex_eval ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
286 # define ex_execute ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
287 # define ex_finally ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
288 # define ex_finish ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
289 # define ex_function ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
290 # define ex_if ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
291 # define ex_let ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
292 # define ex_lockvar ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
293 # define ex_oldfiles ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
294 # define ex_options ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
295 # define ex_packadd ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
296 # define ex_packloadall ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
297 # define ex_return ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
298 # define ex_scriptnames ex_ni |
7 | 299 # define ex_throw ex_ni |
300 # define ex_try ex_ni | |
301 # define ex_unlet ex_ni | |
146 | 302 # define ex_unlockvar ex_ni |
17622
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
303 # define ex_while ex_ni |
7 | 304 #endif |
17536
e00d12c085a5
patch 8.1.1766: code for writing session file is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17496
diff
changeset
|
305 #ifndef FEAT_SESSION |
7 | 306 # define ex_loadview ex_ni |
307 #endif | |
17458
cfdef48743ed
patch 8.1.1727: code for viminfo support is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17431
diff
changeset
|
308 #ifndef FEAT_VIMINFO |
7 | 309 # define ex_viminfo ex_ni |
310 #endif | |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
311 static void ex_behave(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
312 static void ex_filetype(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
313 static void ex_setfiletype(exarg_T *eap); |
7 | 314 #ifndef FEAT_DIFF |
16 | 315 # define ex_diffoff ex_ni |
7 | 316 # define ex_diffpatch ex_ni |
317 # define ex_diffgetput ex_ni | |
318 # define ex_diffsplit ex_ni | |
319 # define ex_diffthis ex_ni | |
320 # define ex_diffupdate ex_ni | |
321 #endif | |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
322 static void ex_digraphs(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
323 static void ex_set(exarg_T *eap); |
7 | 324 #ifdef FEAT_SEARCH_EXTRA |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
325 static void ex_nohlsearch(exarg_T *eap); |
7 | 326 #else |
327 # define ex_nohlsearch ex_ni | |
328 # define ex_match ex_ni | |
329 #endif | |
330 #ifdef FEAT_CRYPT | |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
331 static void ex_X(exarg_T *eap); |
7 | 332 #else |
333 # define ex_X ex_ni | |
334 #endif | |
335 #ifdef FEAT_FOLDING | |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
336 static void ex_fold(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
337 static void ex_foldopen(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
338 static void ex_folddo(exarg_T *eap); |
7 | 339 #else |
340 # define ex_fold ex_ni | |
341 # define ex_foldopen ex_ni | |
342 # define ex_folddo ex_ni | |
343 #endif | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
344 #if !(defined(HAVE_LOCALE_H) || defined(X_LOCALE)) |
7 | 345 # define ex_language ex_ni |
346 #endif | |
347 #ifndef FEAT_SIGNS | |
348 # define ex_sign ex_ni | |
349 #endif | |
33 | 350 #ifndef FEAT_NETBEANS_INTG |
2210 | 351 # define ex_nbclose ex_ni |
33 | 352 # define ex_nbkey ex_ni |
2210 | 353 # define ex_nbstart ex_ni |
33 | 354 #endif |
7 | 355 |
356 #ifndef FEAT_JUMPLIST | |
357 # define ex_jumps ex_ni | |
9284
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
9260
diff
changeset
|
358 # define ex_clearjumps ex_ni |
7 | 359 # define ex_changes ex_ni |
360 #endif | |
361 | |
170 | 362 #ifndef FEAT_PROFILE |
363 # define ex_profile ex_ni | |
364 #endif | |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
11547
diff
changeset
|
365 #ifndef FEAT_TERMINAL |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
11547
diff
changeset
|
366 # define ex_terminal ex_ni |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
11547
diff
changeset
|
367 #endif |
16608
0422b14bce58
patch 8.1.1307: cannot reconnect to the X server after it restarted
Bram Moolenaar <Bram@vim.org>
parents:
16576
diff
changeset
|
368 #if !defined(FEAT_X11) || !defined(FEAT_XCLIPBOARD) |
0422b14bce58
patch 8.1.1307: cannot reconnect to the X server after it restarted
Bram Moolenaar <Bram@vim.org>
parents:
16576
diff
changeset
|
369 # define ex_xrestore ex_ni |
0422b14bce58
patch 8.1.1307: cannot reconnect to the X server after it restarted
Bram Moolenaar <Bram@vim.org>
parents:
16576
diff
changeset
|
370 #endif |
16780
491c01280a5d
patch 8.1.1392: build failure in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
371 #if !defined(FEAT_TEXT_PROP) |
491c01280a5d
patch 8.1.1392: build failure in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
372 # define ex_popupclear ex_ni |
491c01280a5d
patch 8.1.1392: build failure in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
373 #endif |
170 | 374 |
7 | 375 /* |
376 * Declare cmdnames[]. | |
377 */ | |
378 #define DO_DECLARE_EXCMD | |
379 #include "ex_cmds.h" | |
11374
889da8649221
patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents:
11258
diff
changeset
|
380 #include "ex_cmdidxs.h" |
11236
62c96fee518e
patch 8.0.0504: looking up an Ex command is a bit slow
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
381 |
7 | 382 static char_u dollar_command[2] = {'$', 0}; |
383 | |
384 | |
385 #ifdef FEAT_EVAL | |
72 | 386 /* Struct for storing a line inside a while/for loop */ |
7 | 387 typedef struct |
388 { | |
389 char_u *line; /* command line */ | |
390 linenr_T lnum; /* sourcing_lnum of the line */ | |
391 } wcmd_T; | |
392 | |
393 /* | |
72 | 394 * Structure used to store info for line position in a while or for loop. |
7 | 395 * This is required, because do_one_cmd() may invoke ex_function(), which |
72 | 396 * reads more lines that may come from the while/for loop. |
397 */ | |
398 struct loop_cookie | |
7 | 399 { |
400 garray_T *lines_gap; /* growarray with line info */ | |
401 int current_line; /* last read line from growarray */ | |
402 int repeating; /* TRUE when looping a second time */ | |
403 /* When "repeating" is FALSE use "getline" and "cookie" to get lines */ | |
17178
40c4cb095d53
patch 8.1.1588: in :let-heredoc line continuation is recognized
Bram Moolenaar <Bram@vim.org>
parents:
17111
diff
changeset
|
404 char_u *(*getline)(int, void *, int, int); |
7 | 405 void *cookie; |
406 }; | |
407 | |
17178
40c4cb095d53
patch 8.1.1588: in :let-heredoc line continuation is recognized
Bram Moolenaar <Bram@vim.org>
parents:
17111
diff
changeset
|
408 static char_u *get_loop_line(int c, void *cookie, int indent, int do_concat); |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
409 static int store_loop_line(garray_T *gap, char_u *line); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
410 static void free_cmdlines(garray_T *gap); |
8 | 411 |
412 /* Struct to save a few things while debugging. Used in do_cmdline() only. */ | |
413 struct dbg_stuff | |
414 { | |
415 int trylevel; | |
416 int force_abort; | |
417 except_T *caught_stack; | |
418 char_u *vv_exception; | |
419 char_u *vv_throwpoint; | |
420 int did_emsg; | |
421 int got_int; | |
422 int did_throw; | |
423 int need_rethrow; | |
424 int check_cstack; | |
425 except_T *current_exception; | |
426 }; | |
427 | |
428 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
429 save_dbg_stuff(struct dbg_stuff *dsp) |
8 | 430 { |
431 dsp->trylevel = trylevel; trylevel = 0; | |
432 dsp->force_abort = force_abort; force_abort = FALSE; | |
433 dsp->caught_stack = caught_stack; caught_stack = NULL; | |
434 dsp->vv_exception = v_exception(NULL); | |
435 dsp->vv_throwpoint = v_throwpoint(NULL); | |
436 | |
437 /* Necessary for debugging an inactive ":catch", ":finally", ":endtry" */ | |
438 dsp->did_emsg = did_emsg; did_emsg = FALSE; | |
439 dsp->got_int = got_int; got_int = FALSE; | |
440 dsp->did_throw = did_throw; did_throw = FALSE; | |
441 dsp->need_rethrow = need_rethrow; need_rethrow = FALSE; | |
442 dsp->check_cstack = check_cstack; check_cstack = FALSE; | |
443 dsp->current_exception = current_exception; current_exception = NULL; | |
444 } | |
445 | |
446 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
447 restore_dbg_stuff(struct dbg_stuff *dsp) |
8 | 448 { |
449 suppress_errthrow = FALSE; | |
450 trylevel = dsp->trylevel; | |
451 force_abort = dsp->force_abort; | |
452 caught_stack = dsp->caught_stack; | |
453 (void)v_exception(dsp->vv_exception); | |
454 (void)v_throwpoint(dsp->vv_throwpoint); | |
455 did_emsg = dsp->did_emsg; | |
456 got_int = dsp->got_int; | |
457 did_throw = dsp->did_throw; | |
458 need_rethrow = dsp->need_rethrow; | |
459 check_cstack = dsp->check_cstack; | |
460 current_exception = dsp->current_exception; | |
461 } | |
7 | 462 #endif |
463 | |
464 /* | |
465 * do_exmode(): Repeatedly get commands for the "Ex" mode, until the ":vi" | |
466 * command is given. | |
467 */ | |
468 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
469 do_exmode( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
470 int improved) /* TRUE for "improved Ex" mode */ |
7 | 471 { |
472 int save_msg_scroll; | |
473 int prev_msg_row; | |
474 linenr_T prev_line; | |
10889
5780bd3a5a7e
patch 8.0.0334: can't access b:changedtick from a dict reference
Christian Brabandt <cb@256bit.org>
parents:
10875
diff
changeset
|
475 varnumber_T changedtick; |
167 | 476 |
477 if (improved) | |
478 exmode_active = EXMODE_VIM; | |
479 else | |
480 exmode_active = EXMODE_NORMAL; | |
481 State = NORMAL; | |
482 | |
483 /* When using ":global /pat/ visual" and then "Q" we return to continue | |
484 * the :global command. */ | |
485 if (global_busy) | |
486 return; | |
7 | 487 |
488 save_msg_scroll = msg_scroll; | |
489 ++RedrawingDisabled; /* don't redisplay the window */ | |
490 ++no_wait_return; /* don't wait for return */ | |
491 #ifdef FEAT_GUI | |
492 /* Ignore scrollbar and mouse events in Ex mode */ | |
493 ++hold_gui_events; | |
494 #endif | |
495 | |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15510
diff
changeset
|
496 msg(_("Entering Ex mode. Type \"visual\" to go to Normal mode.")); |
7 | 497 while (exmode_active) |
498 { | |
161 | 499 /* Check for a ":normal" command and no more characters left. */ |
500 if (ex_normal_busy > 0 && typebuf.tb_len == 0) | |
501 { | |
502 exmode_active = FALSE; | |
503 break; | |
504 } | |
7 | 505 msg_scroll = TRUE; |
506 need_wait_return = FALSE; | |
507 ex_pressedreturn = FALSE; | |
508 ex_no_reprint = FALSE; | |
10952
835604f3c37a
patch 8.0.0365: might free a dict item that wasn't allocated
Christian Brabandt <cb@256bit.org>
parents:
10889
diff
changeset
|
509 changedtick = CHANGEDTICK(curbuf); |
7 | 510 prev_msg_row = msg_row; |
511 prev_line = curwin->w_cursor.lnum; | |
512 if (improved) | |
513 { | |
514 cmdline_row = msg_row; | |
515 do_cmdline(NULL, getexline, NULL, 0); | |
516 } | |
517 else | |
518 do_cmdline(NULL, getexmodeline, NULL, DOCMD_NOWAIT); | |
519 lines_left = Rows - 1; | |
520 | |
167 | 521 if ((prev_line != curwin->w_cursor.lnum |
10952
835604f3c37a
patch 8.0.0365: might free a dict item that wasn't allocated
Christian Brabandt <cb@256bit.org>
parents:
10889
diff
changeset
|
522 || changedtick != CHANGEDTICK(curbuf)) && !ex_no_reprint) |
167 | 523 { |
524 if (curbuf->b_ml.ml_flags & ML_EMPTY) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
525 emsg(_(e_emptybuf)); |
167 | 526 else |
527 { | |
528 if (ex_pressedreturn) | |
529 { | |
530 /* go up one line, to overwrite the ":<CR>" line, so the | |
1441 | 531 * output doesn't contain empty lines. */ |
167 | 532 msg_row = prev_msg_row; |
533 if (prev_msg_row == Rows - 1) | |
534 msg_row--; | |
535 } | |
536 msg_col = 0; | |
537 print_line_no_prefix(curwin->w_cursor.lnum, FALSE, FALSE); | |
538 msg_clr_eos(); | |
539 } | |
540 } | |
541 else if (ex_pressedreturn && !ex_no_reprint) /* must be at EOF */ | |
542 { | |
543 if (curbuf->b_ml.ml_flags & ML_EMPTY) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
544 emsg(_(e_emptybuf)); |
167 | 545 else |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
546 emsg(_("E501: At end-of-file")); |
167 | 547 } |
7 | 548 } |
549 | |
550 #ifdef FEAT_GUI | |
551 --hold_gui_events; | |
552 #endif | |
553 --RedrawingDisabled; | |
554 --no_wait_return; | |
555 update_screen(CLEAR); | |
556 need_wait_return = FALSE; | |
557 msg_scroll = save_msg_scroll; | |
558 } | |
559 | |
560 /* | |
18297
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
561 * Print the executed command for when 'verbose' is set. |
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
562 * When "lnum" is 0 only print the command. |
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
563 */ |
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
564 static void |
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
565 msg_verbose_cmd(linenr_T lnum, char_u *cmd) |
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
566 { |
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
567 ++no_wait_return; |
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
568 verbose_enter_scroll(); |
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
569 |
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
570 if (lnum == 0) |
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
571 smsg(_("Executing: %s"), cmd); |
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
572 else |
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
573 smsg(_("line %ld: %s"), (long)lnum, cmd); |
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
574 if (msg_silent == 0) |
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
575 msg_puts("\n"); // don't overwrite this |
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
576 |
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
577 verbose_leave_scroll(); |
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
578 --no_wait_return; |
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
579 } |
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
580 |
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
581 /* |
7 | 582 * Execute a simple command line. Used for translated commands like "*". |
583 */ | |
584 int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
585 do_cmdline_cmd(char_u *cmd) |
7 | 586 { |
587 return do_cmdline(cmd, NULL, NULL, | |
588 DOCMD_VERBOSE|DOCMD_NOWAIT|DOCMD_KEYTYPED); | |
589 } | |
590 | |
591 /* | |
592 * do_cmdline(): execute one Ex command line | |
593 * | |
594 * 1. Execute "cmdline" when it is not NULL. | |
2635 | 595 * If "cmdline" is NULL, or more lines are needed, fgetline() is used. |
7 | 596 * 2. Split up in parts separated with '|'. |
597 * | |
598 * This function can be called recursively! | |
599 * | |
600 * flags: | |
601 * DOCMD_VERBOSE - The command will be included in the error message. | |
602 * DOCMD_NOWAIT - Don't call wait_return() and friends. | |
2635 | 603 * DOCMD_REPEAT - Repeat execution until fgetline() returns NULL. |
7 | 604 * DOCMD_KEYTYPED - Don't reset KeyTyped. |
605 * DOCMD_EXCRESET - Reset the exception environment (used for debugging). | |
606 * DOCMD_KEEPLINE - Store first typed line (for repeating with "."). | |
607 * | |
608 * return FAIL if cmdline could not be executed, OK otherwise | |
609 */ | |
610 int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
611 do_cmdline( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
612 char_u *cmdline, |
17178
40c4cb095d53
patch 8.1.1588: in :let-heredoc line continuation is recognized
Bram Moolenaar <Bram@vim.org>
parents:
17111
diff
changeset
|
613 char_u *(*fgetline)(int, void *, int, int), |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
614 void *cookie, /* argument for fgetline() */ |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
615 int flags) |
7 | 616 { |
617 char_u *next_cmdline; /* next cmd to execute */ | |
618 char_u *cmdline_copy = NULL; /* copy of cmd line */ | |
2635 | 619 int used_getline = FALSE; /* used "fgetline" to obtain command */ |
7 | 620 static int recursive = 0; /* recursive depth */ |
621 int msg_didout_before_start = 0; | |
622 int count = 0; /* line number count */ | |
623 int did_inc = FALSE; /* incremented RedrawingDisabled */ | |
624 int retval = OK; | |
625 #ifdef FEAT_EVAL | |
626 struct condstack cstack; /* conditional stack */ | |
72 | 627 garray_T lines_ga; /* keep lines for ":while"/":for" */ |
7 | 628 int current_line = 0; /* active line in lines_ga */ |
629 char_u *fname = NULL; /* function or script name */ | |
630 linenr_T *breakpoint = NULL; /* ptr to breakpoint field in cookie */ | |
631 int *dbg_tick = NULL; /* ptr to dbg_tick field in cookie */ | |
8 | 632 struct dbg_stuff debug_saved; /* saved things for debug mode */ |
7 | 633 int initial_trylevel; |
634 struct msglist **saved_msg_list = NULL; | |
635 struct msglist *private_msg_list; | |
636 | |
2635 | 637 /* "fgetline" and "cookie" passed to do_one_cmd() */ |
17178
40c4cb095d53
patch 8.1.1588: in :let-heredoc line continuation is recognized
Bram Moolenaar <Bram@vim.org>
parents:
17111
diff
changeset
|
638 char_u *(*cmd_getline)(int, void *, int, int); |
7 | 639 void *cmd_cookie; |
72 | 640 struct loop_cookie cmd_loop_cookie; |
7 | 641 void *real_cookie; |
170 | 642 int getline_is_func; |
7 | 643 #else |
2635 | 644 # define cmd_getline fgetline |
7 | 645 # define cmd_cookie cookie |
646 #endif | |
647 static int call_depth = 0; /* recursiveness */ | |
648 | |
649 #ifdef FEAT_EVAL | |
650 /* For every pair of do_cmdline()/do_one_cmd() calls, use an extra memory | |
651 * location for storing error messages to be converted to an exception. | |
84 | 652 * This ensures that the do_errthrow() call in do_one_cmd() does not |
653 * combine the messages stored by an earlier invocation of do_one_cmd() | |
654 * with the command name of the later one. This would happen when | |
655 * BufWritePost autocommands are executed after a write error. */ | |
7 | 656 saved_msg_list = msg_list; |
657 msg_list = &private_msg_list; | |
658 private_msg_list = NULL; | |
659 #endif | |
660 | |
661 /* It's possible to create an endless loop with ":execute", catch that | |
10488
89200fa1d174
commit https://github.com/vim/vim/commit/777b30f827bcbe10a40640b1bf0361cb93a16be1
Christian Brabandt <cb@256bit.org>
parents:
10484
diff
changeset
|
662 * here. The value of 200 allows nested function calls, ":source", etc. |
89200fa1d174
commit https://github.com/vim/vim/commit/777b30f827bcbe10a40640b1bf0361cb93a16be1
Christian Brabandt <cb@256bit.org>
parents:
10484
diff
changeset
|
663 * Allow 200 or 'maxfuncdepth', whatever is larger. */ |
10490
8f2191b56d52
commit https://github.com/vim/vim/commit/b094ff4b2be4d8b7364c566a1cc7e27aa4452a50
Christian Brabandt <cb@256bit.org>
parents:
10488
diff
changeset
|
664 if (call_depth >= 200 |
8f2191b56d52
commit https://github.com/vim/vim/commit/b094ff4b2be4d8b7364c566a1cc7e27aa4452a50
Christian Brabandt <cb@256bit.org>
parents:
10488
diff
changeset
|
665 #ifdef FEAT_EVAL |
8f2191b56d52
commit https://github.com/vim/vim/commit/b094ff4b2be4d8b7364c566a1cc7e27aa4452a50
Christian Brabandt <cb@256bit.org>
parents:
10488
diff
changeset
|
666 && call_depth >= p_mfd |
8f2191b56d52
commit https://github.com/vim/vim/commit/b094ff4b2be4d8b7364c566a1cc7e27aa4452a50
Christian Brabandt <cb@256bit.org>
parents:
10488
diff
changeset
|
667 #endif |
8f2191b56d52
commit https://github.com/vim/vim/commit/b094ff4b2be4d8b7364c566a1cc7e27aa4452a50
Christian Brabandt <cb@256bit.org>
parents:
10488
diff
changeset
|
668 ) |
7 | 669 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
670 emsg(_("E169: Command too recursive")); |
7 | 671 #ifdef FEAT_EVAL |
672 /* When converting to an exception, we do not include the command name | |
673 * since this is not an error of the specific command. */ | |
674 do_errthrow((struct condstack *)NULL, (char_u *)NULL); | |
675 msg_list = saved_msg_list; | |
676 #endif | |
677 return FAIL; | |
678 } | |
679 ++call_depth; | |
680 | |
681 #ifdef FEAT_EVAL | |
682 cstack.cs_idx = -1; | |
72 | 683 cstack.cs_looplevel = 0; |
7 | 684 cstack.cs_trylevel = 0; |
685 cstack.cs_emsg_silent_list = NULL; | |
72 | 686 cstack.cs_lflags = 0; |
7 | 687 ga_init2(&lines_ga, (int)sizeof(wcmd_T), 10); |
688 | |
2635 | 689 real_cookie = getline_cookie(fgetline, cookie); |
7 | 690 |
691 /* Inside a function use a higher nesting level. */ | |
2635 | 692 getline_is_func = getline_equal(fgetline, cookie, get_func_line); |
170 | 693 if (getline_is_func && ex_nesting_level == func_level(real_cookie)) |
7 | 694 ++ex_nesting_level; |
695 | |
696 /* Get the function or script name and the address where the next breakpoint | |
697 * line and the debug tick for a function or script are stored. */ | |
170 | 698 if (getline_is_func) |
7 | 699 { |
700 fname = func_name(real_cookie); | |
701 breakpoint = func_breakpoint(real_cookie); | |
702 dbg_tick = func_dbg_tick(real_cookie); | |
703 } | |
2635 | 704 else if (getline_equal(fgetline, cookie, getsourceline)) |
7 | 705 { |
706 fname = sourcing_name; | |
707 breakpoint = source_breakpoint(real_cookie); | |
708 dbg_tick = source_dbg_tick(real_cookie); | |
709 } | |
710 | |
711 /* | |
712 * Initialize "force_abort" and "suppress_errthrow" at the top level. | |
713 */ | |
714 if (!recursive) | |
715 { | |
716 force_abort = FALSE; | |
717 suppress_errthrow = FALSE; | |
718 } | |
719 | |
720 /* | |
721 * If requested, store and reset the global values controlling the | |
944 | 722 * exception handling (used when debugging). Otherwise clear it to avoid |
723 * a bogus compiler warning when the optimizer uses inline functions... | |
7 | 724 */ |
878 | 725 if (flags & DOCMD_EXCRESET) |
8 | 726 save_dbg_stuff(&debug_saved); |
944 | 727 else |
7133
48ce650e8a27
commit https://github.com/vim/vim/commit/69b67f7e774dc212e8c97495ee81c601b8a89ac2
Christian Brabandt <cb@256bit.org>
parents:
7109
diff
changeset
|
728 vim_memset(&debug_saved, 0, sizeof(debug_saved)); |
7 | 729 |
730 initial_trylevel = trylevel; | |
731 | |
732 /* | |
733 * "did_throw" will be set to TRUE when an exception is being thrown. | |
734 */ | |
735 did_throw = FALSE; | |
736 #endif | |
737 /* | |
738 * "did_emsg" will be set to TRUE when emsg() is used, in which case we | |
72 | 739 * cancel the whole command line, and any if/endif or loop. |
7 | 740 * If force_abort is set, we cancel everything. |
741 */ | |
742 did_emsg = FALSE; | |
743 | |
744 /* | |
745 * KeyTyped is only set when calling vgetc(). Reset it here when not | |
746 * calling vgetc() (sourced command lines). | |
747 */ | |
2635 | 748 if (!(flags & DOCMD_KEYTYPED) |
749 && !getline_equal(fgetline, cookie, getexline)) | |
7 | 750 KeyTyped = FALSE; |
751 | |
752 /* | |
753 * Continue executing command lines: | |
72 | 754 * - when inside an ":if", ":while" or ":for" |
7 | 755 * - for multiple commands on one line, separated with '|' |
756 * - when repeating until there are no more lines (for ":source") | |
757 */ | |
758 next_cmdline = cmdline; | |
759 do | |
760 { | |
170 | 761 #ifdef FEAT_EVAL |
2635 | 762 getline_is_func = getline_equal(fgetline, cookie, get_func_line); |
170 | 763 #endif |
764 | |
72 | 765 /* stop skipping cmds for an error msg after all endif/while/for */ |
7 | 766 if (next_cmdline == NULL |
767 #ifdef FEAT_EVAL | |
768 && !force_abort | |
769 && cstack.cs_idx < 0 | |
170 | 770 && !(getline_is_func && func_has_abort(real_cookie)) |
7 | 771 #endif |
772 ) | |
773 did_emsg = FALSE; | |
774 | |
775 /* | |
72 | 776 * 1. If repeating a line in a loop, get a line from lines_ga. |
2635 | 777 * 2. If no line given: Get an allocated line with fgetline(). |
7 | 778 * 3. If a line is given: Make a copy, so we can mess with it. |
779 */ | |
780 | |
781 #ifdef FEAT_EVAL | |
782 /* 1. If repeating, get a previous line from lines_ga. */ | |
72 | 783 if (cstack.cs_looplevel > 0 && current_line < lines_ga.ga_len) |
7 | 784 { |
785 /* Each '|' separated command is stored separately in lines_ga, to | |
786 * be able to jump to it. Don't use next_cmdline now. */ | |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13221
diff
changeset
|
787 VIM_CLEAR(cmdline_copy); |
7 | 788 |
789 /* Check if a function has returned or, unless it has an unclosed | |
790 * try conditional, aborted. */ | |
170 | 791 if (getline_is_func) |
792 { | |
793 # ifdef FEAT_PROFILE | |
788 | 794 if (do_profiling == PROF_YES) |
170 | 795 func_line_end(real_cookie); |
796 # endif | |
797 if (func_has_ended(real_cookie)) | |
798 { | |
799 retval = FAIL; | |
800 break; | |
801 } | |
802 } | |
803 #ifdef FEAT_PROFILE | |
788 | 804 else if (do_profiling == PROF_YES |
2635 | 805 && getline_equal(fgetline, cookie, getsourceline)) |
170 | 806 script_line_end(); |
807 #endif | |
7 | 808 |
809 /* Check if a sourced file hit a ":finish" command. */ | |
2635 | 810 if (source_finished(fgetline, cookie)) |
7 | 811 { |
812 retval = FAIL; | |
813 break; | |
814 } | |
815 | |
816 /* If breakpoints have been added/deleted need to check for it. */ | |
817 if (breakpoint != NULL && dbg_tick != NULL | |
818 && *dbg_tick != debug_tick) | |
819 { | |
820 *breakpoint = dbg_find_breakpoint( | |
2635 | 821 getline_equal(fgetline, cookie, getsourceline), |
7 | 822 fname, sourcing_lnum); |
823 *dbg_tick = debug_tick; | |
824 } | |
825 | |
826 next_cmdline = ((wcmd_T *)(lines_ga.ga_data))[current_line].line; | |
827 sourcing_lnum = ((wcmd_T *)(lines_ga.ga_data))[current_line].lnum; | |
828 | |
829 /* Did we encounter a breakpoint? */ | |
830 if (breakpoint != NULL && *breakpoint != 0 | |
831 && *breakpoint <= sourcing_lnum) | |
832 { | |
833 dbg_breakpoint(fname, sourcing_lnum); | |
834 /* Find next breakpoint. */ | |
835 *breakpoint = dbg_find_breakpoint( | |
2635 | 836 getline_equal(fgetline, cookie, getsourceline), |
7 | 837 fname, sourcing_lnum); |
838 *dbg_tick = debug_tick; | |
839 } | |
170 | 840 # ifdef FEAT_PROFILE |
788 | 841 if (do_profiling == PROF_YES) |
170 | 842 { |
843 if (getline_is_func) | |
844 func_line_start(real_cookie); | |
2635 | 845 else if (getline_equal(fgetline, cookie, getsourceline)) |
170 | 846 script_line_start(); |
847 } | |
848 # endif | |
7 | 849 } |
850 | |
72 | 851 if (cstack.cs_looplevel > 0) |
852 { | |
853 /* Inside a while/for loop we need to store the lines and use them | |
2635 | 854 * again. Pass a different "fgetline" function to do_one_cmd() |
7 | 855 * below, so that it stores lines in or reads them from |
856 * "lines_ga". Makes it possible to define a function inside a | |
72 | 857 * while/for loop. */ |
858 cmd_getline = get_loop_line; | |
859 cmd_cookie = (void *)&cmd_loop_cookie; | |
860 cmd_loop_cookie.lines_gap = &lines_ga; | |
861 cmd_loop_cookie.current_line = current_line; | |
2635 | 862 cmd_loop_cookie.getline = fgetline; |
72 | 863 cmd_loop_cookie.cookie = cookie; |
864 cmd_loop_cookie.repeating = (current_line < lines_ga.ga_len); | |
7 | 865 } |
866 else | |
867 { | |
2635 | 868 cmd_getline = fgetline; |
7 | 869 cmd_cookie = cookie; |
870 } | |
871 #endif | |
872 | |
2635 | 873 /* 2. If no line given, get an allocated line with fgetline(). */ |
7 | 874 if (next_cmdline == NULL) |
875 { | |
876 /* | |
877 * Need to set msg_didout for the first line after an ":if", | |
878 * otherwise the ":if" will be overwritten. | |
879 */ | |
2635 | 880 if (count == 1 && getline_equal(fgetline, cookie, getexline)) |
7 | 881 msg_didout = TRUE; |
2635 | 882 if (fgetline == NULL || (next_cmdline = fgetline(':', cookie, |
7 | 883 #ifdef FEAT_EVAL |
884 cstack.cs_idx < 0 ? 0 : (cstack.cs_idx + 1) * 2 | |
885 #else | |
886 0 | |
887 #endif | |
17178
40c4cb095d53
patch 8.1.1588: in :let-heredoc line continuation is recognized
Bram Moolenaar <Bram@vim.org>
parents:
17111
diff
changeset
|
888 , TRUE)) == NULL) |
7 | 889 { |
890 /* Don't call wait_return for aborted command line. The NULL | |
891 * returned for the end of a sourced file or executed function | |
892 * doesn't do this. */ | |
893 if (KeyTyped && !(flags & DOCMD_REPEAT)) | |
894 need_wait_return = FALSE; | |
895 retval = FAIL; | |
896 break; | |
897 } | |
898 used_getline = TRUE; | |
899 | |
900 /* | |
901 * Keep the first typed line. Clear it when more lines are typed. | |
902 */ | |
903 if (flags & DOCMD_KEEPLINE) | |
904 { | |
905 vim_free(repeat_cmdline); | |
906 if (count == 0) | |
907 repeat_cmdline = vim_strsave(next_cmdline); | |
908 else | |
909 repeat_cmdline = NULL; | |
910 } | |
911 } | |
912 | |
913 /* 3. Make a copy of the command so we can mess with it. */ | |
914 else if (cmdline_copy == NULL) | |
915 { | |
916 next_cmdline = vim_strsave(next_cmdline); | |
917 if (next_cmdline == NULL) | |
918 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
919 emsg(_(e_outofmem)); |
7 | 920 retval = FAIL; |
921 break; | |
922 } | |
923 } | |
924 cmdline_copy = next_cmdline; | |
925 | |
926 #ifdef FEAT_EVAL | |
927 /* | |
72 | 928 * Save the current line when inside a ":while" or ":for", and when |
929 * the command looks like a ":while" or ":for", because we may need it | |
930 * later. When there is a '|' and another command, it is stored | |
931 * separately, because we need to be able to jump back to it from an | |
932 * :endwhile/:endfor. | |
7 | 933 */ |
72 | 934 if (current_line == lines_ga.ga_len |
935 && (cstack.cs_looplevel || has_loop_cmd(next_cmdline))) | |
936 { | |
937 if (store_loop_line(&lines_ga, next_cmdline) == FAIL) | |
7 | 938 { |
939 retval = FAIL; | |
940 break; | |
941 } | |
942 } | |
943 did_endif = FALSE; | |
944 #endif | |
945 | |
946 if (count++ == 0) | |
947 { | |
948 /* | |
949 * All output from the commands is put below each other, without | |
950 * waiting for a return. Don't do this when executing commands | |
951 * from a script or when being called recursive (e.g. for ":e | |
952 * +command file"). | |
953 */ | |
954 if (!(flags & DOCMD_NOWAIT) && !recursive) | |
955 { | |
956 msg_didout_before_start = msg_didout; | |
957 msg_didany = FALSE; /* no output yet */ | |
958 msg_start(); | |
959 msg_scroll = TRUE; /* put messages below each other */ | |
4352 | 960 ++no_wait_return; /* don't wait for return until finished */ |
7 | 961 ++RedrawingDisabled; |
962 did_inc = TRUE; | |
963 } | |
964 } | |
965 | |
966 if (p_verbose >= 15 && sourcing_name != NULL) | |
18297
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
967 msg_verbose_cmd(sourcing_lnum, cmdline_copy); |
7 | 968 |
969 /* | |
970 * 2. Execute one '|' separated command. | |
971 * do_one_cmd() will return NULL if there is no trailing '|'. | |
972 * "cmdline_copy" can change, e.g. for '%' and '#' expansion. | |
973 */ | |
974 ++recursive; | |
975 next_cmdline = do_one_cmd(&cmdline_copy, flags & DOCMD_VERBOSE, | |
976 #ifdef FEAT_EVAL | |
977 &cstack, | |
978 #endif | |
979 cmd_getline, cmd_cookie); | |
980 --recursive; | |
981 | |
982 #ifdef FEAT_EVAL | |
72 | 983 if (cmd_cookie == (void *)&cmd_loop_cookie) |
984 /* Use "current_line" from "cmd_loop_cookie", it may have been | |
7 | 985 * incremented when defining a function. */ |
72 | 986 current_line = cmd_loop_cookie.current_line; |
7 | 987 #endif |
988 | |
989 if (next_cmdline == NULL) | |
990 { | |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13221
diff
changeset
|
991 VIM_CLEAR(cmdline_copy); |
17652
9efb4dda9720
patch 8.1.1823: command line history code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17650
diff
changeset
|
992 |
7 | 993 /* |
994 * If the command was typed, remember it for the ':' register. | |
995 * Do this AFTER executing the command to make :@: work. | |
996 */ | |
2635 | 997 if (getline_equal(fgetline, cookie, getexline) |
7 | 998 && new_last_cmdline != NULL) |
999 { | |
1000 vim_free(last_cmdline); | |
1001 last_cmdline = new_last_cmdline; | |
1002 new_last_cmdline = NULL; | |
1003 } | |
1004 } | |
1005 else | |
1006 { | |
1007 /* need to copy the command after the '|' to cmdline_copy, for the | |
1008 * next do_one_cmd() */ | |
1619 | 1009 STRMOVE(cmdline_copy, next_cmdline); |
7 | 1010 next_cmdline = cmdline_copy; |
1011 } | |
1012 | |
1013 | |
1014 #ifdef FEAT_EVAL | |
1015 /* reset did_emsg for a function that is not aborted by an error */ | |
1016 if (did_emsg && !force_abort | |
2635 | 1017 && getline_equal(fgetline, cookie, get_func_line) |
7 | 1018 && !func_has_abort(real_cookie)) |
1019 did_emsg = FALSE; | |
1020 | |
72 | 1021 if (cstack.cs_looplevel > 0) |
7 | 1022 { |
1023 ++current_line; | |
1024 | |
1025 /* | |
72 | 1026 * An ":endwhile", ":endfor" and ":continue" is handled here. |
1027 * If we were executing commands, jump back to the ":while" or | |
1028 * ":for". | |
1029 * If we were not executing commands, decrement cs_looplevel. | |
7 | 1030 */ |
72 | 1031 if (cstack.cs_lflags & (CSL_HAD_CONT | CSL_HAD_ENDLOOP)) |
1032 { | |
1033 cstack.cs_lflags &= ~(CSL_HAD_CONT | CSL_HAD_ENDLOOP); | |
1034 | |
1035 /* Jump back to the matching ":while" or ":for". Be careful | |
1036 * not to use a cs_line[] from an entry that isn't a ":while" | |
1037 * or ":for": It would make "current_line" invalid and can | |
1038 * cause a crash. */ | |
7 | 1039 if (!did_emsg && !got_int && !did_throw |
1040 && cstack.cs_idx >= 0 | |
72 | 1041 && (cstack.cs_flags[cstack.cs_idx] |
1042 & (CSF_WHILE | CSF_FOR)) | |
7 | 1043 && cstack.cs_line[cstack.cs_idx] >= 0 |
1044 && (cstack.cs_flags[cstack.cs_idx] & CSF_ACTIVE)) | |
1045 { | |
1046 current_line = cstack.cs_line[cstack.cs_idx]; | |
72 | 1047 /* remember we jumped there */ |
1048 cstack.cs_lflags |= CSL_HAD_LOOP; | |
7 | 1049 line_breakcheck(); /* check if CTRL-C typed */ |
1050 | |
72 | 1051 /* Check for the next breakpoint at or after the ":while" |
1052 * or ":for". */ | |
7 | 1053 if (breakpoint != NULL) |
1054 { | |
1055 *breakpoint = dbg_find_breakpoint( | |
2635 | 1056 getline_equal(fgetline, cookie, getsourceline), |
7 | 1057 fname, |
1058 ((wcmd_T *)lines_ga.ga_data)[current_line].lnum-1); | |
1059 *dbg_tick = debug_tick; | |
1060 } | |
1061 } | |
72 | 1062 else |
7 | 1063 { |
72 | 1064 /* can only get here with ":endwhile" or ":endfor" */ |
7 | 1065 if (cstack.cs_idx >= 0) |
77 | 1066 rewind_conditionals(&cstack, cstack.cs_idx - 1, |
1067 CSF_WHILE | CSF_FOR, &cstack.cs_looplevel); | |
7 | 1068 } |
1069 } | |
1070 | |
1071 /* | |
72 | 1072 * For a ":while" or ":for" we need to remember the line number. |
7 | 1073 */ |
72 | 1074 else if (cstack.cs_lflags & CSL_HAD_LOOP) |
1075 { | |
1076 cstack.cs_lflags &= ~CSL_HAD_LOOP; | |
7 | 1077 cstack.cs_line[cstack.cs_idx] = current_line - 1; |
1078 } | |
1079 } | |
1080 | |
13262
69278c25429d
patch 8.0.1505: debugger can't break on a condition
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
1081 /* Check for the next breakpoint after a watchexpression */ |
69278c25429d
patch 8.0.1505: debugger can't break on a condition
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
1082 if (breakpoint != NULL && has_watchexpr()) |
69278c25429d
patch 8.0.1505: debugger can't break on a condition
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
1083 { |
69278c25429d
patch 8.0.1505: debugger can't break on a condition
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
1084 *breakpoint = dbg_find_breakpoint(FALSE, fname, sourcing_lnum); |
69278c25429d
patch 8.0.1505: debugger can't break on a condition
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
1085 *dbg_tick = debug_tick; |
69278c25429d
patch 8.0.1505: debugger can't break on a condition
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
1086 } |
69278c25429d
patch 8.0.1505: debugger can't break on a condition
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
1087 |
7 | 1088 /* |
1089 * When not inside any ":while" loop, clear remembered lines. | |
1090 */ | |
72 | 1091 if (cstack.cs_looplevel == 0) |
7 | 1092 { |
1093 if (lines_ga.ga_len > 0) | |
1094 { | |
1095 sourcing_lnum = | |
1096 ((wcmd_T *)lines_ga.ga_data)[lines_ga.ga_len - 1].lnum; | |
1097 free_cmdlines(&lines_ga); | |
1098 } | |
1099 current_line = 0; | |
1100 } | |
1101 | |
1102 /* | |
72 | 1103 * A ":finally" makes did_emsg, got_int, and did_throw pending for |
1104 * being restored at the ":endtry". Reset them here and set the | |
1105 * ACTIVE and FINALLY flags, so that the finally clause gets executed. | |
1106 * This includes the case where a missing ":endif", ":endwhile" or | |
1107 * ":endfor" was detected by the ":finally" itself. | |
7 | 1108 */ |
72 | 1109 if (cstack.cs_lflags & CSL_HAD_FINA) |
1110 { | |
1111 cstack.cs_lflags &= ~CSL_HAD_FINA; | |
1112 report_make_pending(cstack.cs_pending[cstack.cs_idx] | |
1113 & (CSTP_ERROR | CSTP_INTERRUPT | CSTP_THROW), | |
7 | 1114 did_throw ? (void *)current_exception : NULL); |
1115 did_emsg = got_int = did_throw = FALSE; | |
1116 cstack.cs_flags[cstack.cs_idx] |= CSF_ACTIVE | CSF_FINALLY; | |
1117 } | |
1118 | |
1119 /* Update global "trylevel" for recursive calls to do_cmdline() from | |
1120 * within this loop. */ | |
1121 trylevel = initial_trylevel + cstack.cs_trylevel; | |
1122 | |
1123 /* | |
1190 | 1124 * If the outermost try conditional (across function calls and sourced |
7 | 1125 * files) is aborted because of an error, an interrupt, or an uncaught |
1126 * exception, cancel everything. If it is left normally, reset | |
1127 * force_abort to get the non-EH compatible abortion behavior for | |
1128 * the rest of the script. | |
1129 */ | |
1130 if (trylevel == 0 && !did_emsg && !got_int && !did_throw) | |
1131 force_abort = FALSE; | |
1132 | |
1133 /* Convert an interrupt to an exception if appropriate. */ | |
1134 (void)do_intthrow(&cstack); | |
1135 #endif /* FEAT_EVAL */ | |
1136 | |
1137 } | |
1138 /* | |
1139 * Continue executing command lines when: | |
1140 * - no CTRL-C typed, no aborting error, no exception thrown or try | |
1141 * conditionals need to be checked for executing finally clauses or | |
1142 * catching an interrupt exception | |
1143 * - didn't get an error message or lines are not typed | |
72 | 1144 * - there is a command after '|', inside a :if, :while, :for or :try, or |
7 | 1145 * looping for ":source" command or function call. |
1146 */ | |
1147 while (!((got_int | |
1148 #ifdef FEAT_EVAL | |
1149 || (did_emsg && force_abort) || did_throw | |
1150 #endif | |
1151 ) | |
1152 #ifdef FEAT_EVAL | |
1153 && cstack.cs_trylevel == 0 | |
1154 #endif | |
1155 ) | |
3757 | 1156 && !(did_emsg |
1157 #ifdef FEAT_EVAL | |
1158 /* Keep going when inside try/catch, so that the error can be | |
4352 | 1159 * deal with, except when it is a syntax error, it may cause |
3757 | 1160 * the :endtry to be missed. */ |
1161 && (cstack.cs_trylevel == 0 || did_emsg_syntax) | |
1162 #endif | |
1163 && used_getline | |
2635 | 1164 && (getline_equal(fgetline, cookie, getexmodeline) |
1165 || getline_equal(fgetline, cookie, getexline))) | |
7 | 1166 && (next_cmdline != NULL |
1167 #ifdef FEAT_EVAL | |
1168 || cstack.cs_idx >= 0 | |
1169 #endif | |
1170 || (flags & DOCMD_REPEAT))); | |
1171 | |
1172 vim_free(cmdline_copy); | |
3757 | 1173 did_emsg_syntax = FALSE; |
7 | 1174 #ifdef FEAT_EVAL |
1175 free_cmdlines(&lines_ga); | |
1176 ga_clear(&lines_ga); | |
1177 | |
1178 if (cstack.cs_idx >= 0) | |
1179 { | |
1180 /* | |
1181 * If a sourced file or executed function ran to its end, report the | |
1182 * unclosed conditional. | |
1183 */ | |
1184 if (!got_int && !did_throw | |
2635 | 1185 && ((getline_equal(fgetline, cookie, getsourceline) |
1186 && !source_finished(fgetline, cookie)) | |
1187 || (getline_equal(fgetline, cookie, get_func_line) | |
7 | 1188 && !func_has_ended(real_cookie)))) |
1189 { | |
1190 if (cstack.cs_flags[cstack.cs_idx] & CSF_TRY) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
1191 emsg(_(e_endtry)); |
7 | 1192 else if (cstack.cs_flags[cstack.cs_idx] & CSF_WHILE) |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
1193 emsg(_(e_endwhile)); |
72 | 1194 else if (cstack.cs_flags[cstack.cs_idx] & CSF_FOR) |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
1195 emsg(_(e_endfor)); |
7 | 1196 else |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
1197 emsg(_(e_endif)); |
7 | 1198 } |
1199 | |
1200 /* | |
1201 * Reset "trylevel" in case of a ":finish" or ":return" or a missing | |
1202 * ":endtry" in a sourced file or executed function. If the try | |
1203 * conditional is in its finally clause, ignore anything pending. | |
1204 * If it is in a catch clause, finish the caught exception. | |
77 | 1205 * Also cleanup any "cs_forinfo" structures. |
7 | 1206 */ |
1207 do | |
77 | 1208 { |
1209 int idx = cleanup_conditionals(&cstack, 0, TRUE); | |
1210 | |
111 | 1211 if (idx >= 0) |
1212 --idx; /* remove try block not in its finally clause */ | |
77 | 1213 rewind_conditionals(&cstack, idx, CSF_WHILE | CSF_FOR, |
1214 &cstack.cs_looplevel); | |
1215 } | |
1216 while (cstack.cs_idx >= 0); | |
7 | 1217 trylevel = initial_trylevel; |
1218 } | |
1219 | |
72 | 1220 /* If a missing ":endtry", ":endwhile", ":endfor", or ":endif" or a memory |
1221 * lack was reported above and the error message is to be converted to an | |
7 | 1222 * exception, do this now after rewinding the cstack. */ |
2635 | 1223 do_errthrow(&cstack, getline_equal(fgetline, cookie, get_func_line) |
7 | 1224 ? (char_u *)"endfunction" : (char_u *)NULL); |
1225 | |
1226 if (trylevel == 0) | |
1227 { | |
1228 /* | |
1229 * When an exception is being thrown out of the outermost try | |
1230 * conditional, discard the uncaught exception, disable the conversion | |
1231 * of interrupts or errors to exceptions, and ensure that no more | |
1232 * commands are executed. | |
1233 */ | |
1234 if (did_throw) | |
1235 { | |
1236 void *p = NULL; | |
1237 char_u *saved_sourcing_name; | |
1238 int saved_sourcing_lnum; | |
1239 struct msglist *messages = NULL, *next; | |
1240 | |
1241 /* | |
1242 * If the uncaught exception is a user exception, report it as an | |
1243 * error. If it is an error exception, display the saved error | |
1244 * message now. For an interrupt exception, do nothing; the | |
1245 * interrupt message is given elsewhere. | |
1246 */ | |
1247 switch (current_exception->type) | |
1248 { | |
1249 case ET_USER: | |
272 | 1250 vim_snprintf((char *)IObuff, IOSIZE, |
1251 _("E605: Exception not caught: %s"), | |
7 | 1252 current_exception->value); |
1253 p = vim_strsave(IObuff); | |
1254 break; | |
1255 case ET_ERROR: | |
1256 messages = current_exception->messages; | |
1257 current_exception->messages = NULL; | |
1258 break; | |
1259 case ET_INTERRUPT: | |
1260 break; | |
1261 } | |
1262 | |
1263 saved_sourcing_name = sourcing_name; | |
1264 saved_sourcing_lnum = sourcing_lnum; | |
1265 sourcing_name = current_exception->throw_name; | |
1266 sourcing_lnum = current_exception->throw_lnum; | |
1267 current_exception->throw_name = NULL; | |
1268 | |
1269 discard_current_exception(); /* uses IObuff if 'verbose' */ | |
1270 suppress_errthrow = TRUE; | |
1271 force_abort = TRUE; | |
1272 | |
1273 if (messages != NULL) | |
1274 { | |
1275 do | |
1276 { | |
1277 next = messages->next; | |
1278 emsg(messages->msg); | |
1279 vim_free(messages->msg); | |
1280 vim_free(messages); | |
1281 messages = next; | |
1282 } | |
1283 while (messages != NULL); | |
1284 } | |
1285 else if (p != NULL) | |
1286 { | |
15490
98c35d312987
patch 8.1.0753: printf format not checked for semsg()
Bram Moolenaar <Bram@vim.org>
parents:
15488
diff
changeset
|
1287 emsg(p); |
7 | 1288 vim_free(p); |
1289 } | |
1290 vim_free(sourcing_name); | |
1291 sourcing_name = saved_sourcing_name; | |
1292 sourcing_lnum = saved_sourcing_lnum; | |
1293 } | |
1294 | |
1295 /* | |
1296 * On an interrupt or an aborting error not converted to an exception, | |
1297 * disable the conversion of errors to exceptions. (Interrupts are not | |
1298 * converted any more, here.) This enables also the interrupt message | |
1299 * when force_abort is set and did_emsg unset in case of an interrupt | |
1300 * from a finally clause after an error. | |
1301 */ | |
1302 else if (got_int || (did_emsg && force_abort)) | |
1303 suppress_errthrow = TRUE; | |
1304 } | |
1305 | |
1306 /* | |
1307 * The current cstack will be freed when do_cmdline() returns. An uncaught | |
1308 * exception will have to be rethrown in the previous cstack. If a function | |
1309 * has just returned or a script file was just finished and the previous | |
1310 * cstack belongs to the same function or, respectively, script file, it | |
1311 * will have to be checked for finally clauses to be executed due to the | |
1312 * ":return" or ":finish". This is done in do_one_cmd(). | |
1313 */ | |
1314 if (did_throw) | |
1315 need_rethrow = TRUE; | |
2635 | 1316 if ((getline_equal(fgetline, cookie, getsourceline) |
7 | 1317 && ex_nesting_level > source_level(real_cookie)) |
2635 | 1318 || (getline_equal(fgetline, cookie, get_func_line) |
7 | 1319 && ex_nesting_level > func_level(real_cookie) + 1)) |
1320 { | |
1321 if (!did_throw) | |
1322 check_cstack = TRUE; | |
1323 } | |
1324 else | |
1325 { | |
1326 /* When leaving a function, reduce nesting level. */ | |
2635 | 1327 if (getline_equal(fgetline, cookie, get_func_line)) |
7 | 1328 --ex_nesting_level; |
1329 /* | |
1330 * Go to debug mode when returning from a function in which we are | |
1331 * single-stepping. | |
1332 */ | |
2635 | 1333 if ((getline_equal(fgetline, cookie, getsourceline) |
1334 || getline_equal(fgetline, cookie, get_func_line)) | |
7 | 1335 && ex_nesting_level + 1 <= debug_break_level) |
2635 | 1336 do_debug(getline_equal(fgetline, cookie, getsourceline) |
7 | 1337 ? (char_u *)_("End of sourced file") |
1338 : (char_u *)_("End of function")); | |
1339 } | |
1340 | |
1341 /* | |
1342 * Restore the exception environment (done after returning from the | |
1343 * debugger). | |
1344 */ | |
1345 if (flags & DOCMD_EXCRESET) | |
8 | 1346 restore_dbg_stuff(&debug_saved); |
7 | 1347 |
1348 msg_list = saved_msg_list; | |
1349 #endif /* FEAT_EVAL */ | |
1350 | |
1351 /* | |
1352 * If there was too much output to fit on the command line, ask the user to | |
1353 * hit return before redrawing the screen. With the ":global" command we do | |
1354 * this only once after the command is finished. | |
1355 */ | |
1356 if (did_inc) | |
1357 { | |
1358 --RedrawingDisabled; | |
1359 --no_wait_return; | |
1360 msg_scroll = FALSE; | |
1361 | |
1362 /* | |
1363 * When just finished an ":if"-":else" which was typed, no need to | |
1364 * wait for hit-return. Also for an error situation. | |
1365 */ | |
1366 if (retval == FAIL | |
1367 #ifdef FEAT_EVAL | |
1368 || (did_endif && KeyTyped && !did_emsg) | |
1369 #endif | |
1370 ) | |
1371 { | |
1372 need_wait_return = FALSE; | |
1373 msg_didany = FALSE; /* don't wait when restarting edit */ | |
1374 } | |
1375 else if (need_wait_return) | |
1376 { | |
1377 /* | |
1378 * The msg_start() above clears msg_didout. The wait_return we do | |
1379 * here should not overwrite the command that may be shown before | |
1380 * doing that. | |
1381 */ | |
1382 msg_didout |= msg_didout_before_start; | |
1383 wait_return(FALSE); | |
1384 } | |
1385 } | |
1386 | |
3976 | 1387 #ifdef FEAT_EVAL |
1388 did_endif = FALSE; /* in case do_cmdline used recursively */ | |
1389 #else | |
7 | 1390 /* |
1391 * Reset if_level, in case a sourced script file contains more ":if" than | |
1392 * ":endif" (could be ":if x | foo | endif"). | |
1393 */ | |
1394 if_level = 0; | |
3972 | 1395 #endif |
3963 | 1396 |
7 | 1397 --call_depth; |
1398 return retval; | |
1399 } | |
1400 | |
1401 #ifdef FEAT_EVAL | |
1402 /* | |
72 | 1403 * Obtain a line when inside a ":while" or ":for" loop. |
7 | 1404 */ |
1405 static char_u * | |
17178
40c4cb095d53
patch 8.1.1588: in :let-heredoc line continuation is recognized
Bram Moolenaar <Bram@vim.org>
parents:
17111
diff
changeset
|
1406 get_loop_line(int c, void *cookie, int indent, int do_concat) |
7 | 1407 { |
72 | 1408 struct loop_cookie *cp = (struct loop_cookie *)cookie; |
7 | 1409 wcmd_T *wp; |
1410 char_u *line; | |
1411 | |
1412 if (cp->current_line + 1 >= cp->lines_gap->ga_len) | |
1413 { | |
1414 if (cp->repeating) | |
72 | 1415 return NULL; /* trying to read past ":endwhile"/":endfor" */ |
1416 | |
1417 /* First time inside the ":while"/":for": get line normally. */ | |
7 | 1418 if (cp->getline == NULL) |
17178
40c4cb095d53
patch 8.1.1588: in :let-heredoc line continuation is recognized
Bram Moolenaar <Bram@vim.org>
parents:
17111
diff
changeset
|
1419 line = getcmdline(c, 0L, indent, do_concat); |
7 | 1420 else |
17178
40c4cb095d53
patch 8.1.1588: in :let-heredoc line continuation is recognized
Bram Moolenaar <Bram@vim.org>
parents:
17111
diff
changeset
|
1421 line = cp->getline(c, cp->cookie, indent, do_concat); |
857 | 1422 if (line != NULL && store_loop_line(cp->lines_gap, line) == OK) |
7 | 1423 ++cp->current_line; |
1424 | |
1425 return line; | |
1426 } | |
1427 | |
1428 KeyTyped = FALSE; | |
1429 ++cp->current_line; | |
1430 wp = (wcmd_T *)(cp->lines_gap->ga_data) + cp->current_line; | |
1431 sourcing_lnum = wp->lnum; | |
1432 return vim_strsave(wp->line); | |
1433 } | |
1434 | |
1435 /* | |
1436 * Store a line in "gap" so that a ":while" loop can execute it again. | |
1437 */ | |
1438 static int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
1439 store_loop_line(garray_T *gap, char_u *line) |
7 | 1440 { |
1441 if (ga_grow(gap, 1) == FAIL) | |
1442 return FAIL; | |
1443 ((wcmd_T *)(gap->ga_data))[gap->ga_len].line = vim_strsave(line); | |
1444 ((wcmd_T *)(gap->ga_data))[gap->ga_len].lnum = sourcing_lnum; | |
1445 ++gap->ga_len; | |
1446 return OK; | |
1447 } | |
1448 | |
1449 /* | |
72 | 1450 * Free the lines stored for a ":while" or ":for" loop. |
7 | 1451 */ |
1452 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
1453 free_cmdlines(garray_T *gap) |
7 | 1454 { |
1455 while (gap->ga_len > 0) | |
1456 { | |
1457 vim_free(((wcmd_T *)(gap->ga_data))[gap->ga_len - 1].line); | |
1458 --gap->ga_len; | |
1459 } | |
1460 } | |
1461 #endif | |
1462 | |
1463 /* | |
944 | 1464 * If "fgetline" is get_loop_line(), return TRUE if the getline it uses equals |
1465 * "func". * Otherwise return TRUE when "fgetline" equals "func". | |
7 | 1466 */ |
1467 int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
1468 getline_equal( |
17178
40c4cb095d53
patch 8.1.1588: in :let-heredoc line continuation is recognized
Bram Moolenaar <Bram@vim.org>
parents:
17111
diff
changeset
|
1469 char_u *(*fgetline)(int, void *, int, int), |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
1470 void *cookie UNUSED, /* argument for fgetline() */ |
17178
40c4cb095d53
patch 8.1.1588: in :let-heredoc line continuation is recognized
Bram Moolenaar <Bram@vim.org>
parents:
17111
diff
changeset
|
1471 char_u *(*func)(int, void *, int, int)) |
7 | 1472 { |
1473 #ifdef FEAT_EVAL | |
17178
40c4cb095d53
patch 8.1.1588: in :let-heredoc line continuation is recognized
Bram Moolenaar <Bram@vim.org>
parents:
17111
diff
changeset
|
1474 char_u *(*gp)(int, void *, int, int); |
72 | 1475 struct loop_cookie *cp; |
1476 | |
944 | 1477 /* When "fgetline" is "get_loop_line()" use the "cookie" to find the |
1190 | 1478 * function that's originally used to obtain the lines. This may be |
1479 * nested several levels. */ | |
944 | 1480 gp = fgetline; |
72 | 1481 cp = (struct loop_cookie *)cookie; |
1482 while (gp == get_loop_line) | |
7 | 1483 { |
1484 gp = cp->getline; | |
1485 cp = cp->cookie; | |
1486 } | |
1487 return gp == func; | |
1488 #else | |
944 | 1489 return fgetline == func; |
7 | 1490 #endif |
1491 } | |
1492 | |
1493 /* | |
944 | 1494 * If "fgetline" is get_loop_line(), return the cookie used by the original |
7 | 1495 * getline function. Otherwise return "cookie". |
1496 */ | |
1497 void * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
1498 getline_cookie( |
17178
40c4cb095d53
patch 8.1.1588: in :let-heredoc line continuation is recognized
Bram Moolenaar <Bram@vim.org>
parents:
17111
diff
changeset
|
1499 char_u *(*fgetline)(int, void *, int, int) UNUSED, |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
1500 void *cookie) /* argument for fgetline() */ |
7 | 1501 { |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
1502 #ifdef FEAT_EVAL |
17178
40c4cb095d53
patch 8.1.1588: in :let-heredoc line continuation is recognized
Bram Moolenaar <Bram@vim.org>
parents:
17111
diff
changeset
|
1503 char_u *(*gp)(int, void *, int, int); |
72 | 1504 struct loop_cookie *cp; |
1505 | |
944 | 1506 /* When "fgetline" is "get_loop_line()" use the "cookie" to find the |
1190 | 1507 * cookie that's originally used to obtain the lines. This may be nested |
7 | 1508 * several levels. */ |
944 | 1509 gp = fgetline; |
72 | 1510 cp = (struct loop_cookie *)cookie; |
1511 while (gp == get_loop_line) | |
7 | 1512 { |
1513 gp = cp->getline; | |
1514 cp = cp->cookie; | |
1515 } | |
1516 return cp; | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
1517 #else |
7 | 1518 return cookie; |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
1519 #endif |
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
1520 } |
7 | 1521 |
6398 | 1522 |
1523 /* | |
1524 * Helper function to apply an offset for buffer commands, i.e. ":bdelete", | |
1525 * ":bwipeout", etc. | |
1526 * Returns the buffer number. | |
1527 */ | |
1528 static int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
1529 compute_buffer_local_count(int addr_type, int lnum, int offset) |
6398 | 1530 { |
1531 buf_T *buf; | |
6417 | 1532 buf_T *nextbuf; |
6398 | 1533 int count = offset; |
1534 | |
1535 buf = firstbuf; | |
1536 while (buf->b_next != NULL && buf->b_fnum < lnum) | |
1537 buf = buf->b_next; | |
1538 while (count != 0) | |
1539 { | |
6417 | 1540 count += (offset < 0) ? 1 : -1; |
1541 nextbuf = (offset < 0) ? buf->b_prev : buf->b_next; | |
1542 if (nextbuf == NULL) | |
6398 | 1543 break; |
6417 | 1544 buf = nextbuf; |
6398 | 1545 if (addr_type == ADDR_LOADED_BUFFERS) |
1546 /* skip over unloaded buffers */ | |
6417 | 1547 while (buf->b_ml.ml_mfp == NULL) |
1548 { | |
1549 nextbuf = (offset < 0) ? buf->b_prev : buf->b_next; | |
1550 if (nextbuf == NULL) | |
1551 break; | |
1552 buf = nextbuf; | |
1553 } | |
1554 } | |
1555 /* we might have gone too far, last buffer is not loadedd */ | |
1556 if (addr_type == ADDR_LOADED_BUFFERS) | |
1557 while (buf->b_ml.ml_mfp == NULL) | |
1558 { | |
1559 nextbuf = (offset >= 0) ? buf->b_prev : buf->b_next; | |
1560 if (nextbuf == NULL) | |
1561 break; | |
1562 buf = nextbuf; | |
1563 } | |
6398 | 1564 return buf->b_fnum; |
1565 } | |
1566 | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
1567 /* |
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
1568 * Return the window number of "win". |
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
1569 * When "win" is NULL return the number of windows. |
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
1570 */ |
6409 | 1571 static int |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
1572 current_win_nr(win_T *win) |
6409 | 1573 { |
1574 win_T *wp; | |
1575 int nr = 0; | |
1576 | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9538
diff
changeset
|
1577 FOR_ALL_WINDOWS(wp) |
6409 | 1578 { |
1579 ++nr; | |
1580 if (wp == win) | |
1581 break; | |
1582 } | |
1583 return nr; | |
1584 } | |
1585 | |
1586 static int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
1587 current_tab_nr(tabpage_T *tab) |
6409 | 1588 { |
1589 tabpage_T *tp; | |
1590 int nr = 0; | |
1591 | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9538
diff
changeset
|
1592 FOR_ALL_TABPAGES(tp) |
6409 | 1593 { |
1594 ++nr; | |
1595 if (tp == tab) | |
1596 break; | |
1597 } | |
1598 return nr; | |
1599 } | |
1600 | |
1601 # define CURRENT_WIN_NR current_win_nr(curwin) | |
1602 # define LAST_WIN_NR current_win_nr(NULL) | |
1603 # define CURRENT_TAB_NR current_tab_nr(curtab) | |
1604 # define LAST_TAB_NR current_tab_nr(NULL) | |
6398 | 1605 |
7 | 1606 /* |
1607 * Execute one Ex command. | |
1608 * | |
1609 * If 'sourcing' is TRUE, the command will be included in the error message. | |
1610 * | |
1611 * 1. skip comment lines and leading space | |
1612 * 2. handle command modifiers | |
6400 | 1613 * 3. find the command |
6398 | 1614 * 4. parse range |
6400 | 1615 * 5. Parse the command. |
6398 | 1616 * 6. parse arguments |
1617 * 7. switch on command name | |
7 | 1618 * |
944 | 1619 * Note: "fgetline" can be NULL. |
7 | 1620 * |
1621 * This function may be called recursively! | |
1622 */ | |
1623 #if (_MSC_VER == 1200) | |
1624 /* | |
8 | 1625 * Avoid optimisation bug in VC++ version 6.0 |
7 | 1626 */ |
128 | 1627 #pragma optimize( "g", off ) |
7 | 1628 #endif |
1629 static char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
1630 do_one_cmd( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
1631 char_u **cmdlinep, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
1632 int sourcing, |
7 | 1633 #ifdef FEAT_EVAL |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
1634 struct condstack *cstack, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
1635 #endif |
17178
40c4cb095d53
patch 8.1.1588: in :let-heredoc line continuation is recognized
Bram Moolenaar <Bram@vim.org>
parents:
17111
diff
changeset
|
1636 char_u *(*fgetline)(int, void *, int, int), |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
1637 void *cookie) /* argument for fgetline() */ |
7 | 1638 { |
1639 char_u *p; | |
1640 linenr_T lnum; | |
1641 long n; | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
1642 char *errormsg = NULL; /* error message */ |
9941
e975914c17e9
commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
9927
diff
changeset
|
1643 char_u *after_modifier = NULL; |
7 | 1644 exarg_T ea; /* Ex command arguments */ |
1926 | 1645 int save_msg_scroll = msg_scroll; |
7 | 1646 cmdmod_T save_cmdmod; |
16144
4850744dc181
patch 8.1.1077: reg_executing() is reset by calling input()
Bram Moolenaar <Bram@vim.org>
parents:
15973
diff
changeset
|
1647 int save_reg_executing = reg_executing; |
7 | 1648 int ni; /* set when Not Implemented */ |
6398 | 1649 char_u *cmd; |
7 | 1650 |
1651 vim_memset(&ea, 0, sizeof(ea)); | |
1652 ea.line1 = 1; | |
1653 ea.line2 = 1; | |
1654 #ifdef FEAT_EVAL | |
1655 ++ex_nesting_level; | |
1656 #endif | |
1657 | |
3997 | 1658 /* When the last file has not been edited :q has to be typed twice. */ |
7 | 1659 if (quitmore |
1660 #ifdef FEAT_EVAL | |
1661 /* avoid that a function call in 'statusline' does this */ | |
944 | 1662 && !getline_equal(fgetline, cookie, get_func_line) |
4133 | 1663 #endif |
3997 | 1664 /* avoid that an autocommand, e.g. QuitPre, does this */ |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
1665 && !getline_equal(fgetline, cookie, getnextac)) |
7 | 1666 --quitmore; |
1667 | |
1668 /* | |
1669 * Reset browse, confirm, etc.. They are restored when returning, for | |
1670 * recursive calls. | |
1671 */ | |
1672 save_cmdmod = cmdmod; | |
1673 | |
930 | 1674 /* "#!anything" is handled like a comment. */ |
1675 if ((*cmdlinep)[0] == '#' && (*cmdlinep)[1] == '!') | |
1676 goto doend; | |
1677 | |
18297
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
1678 if (p_verbose >= 16) |
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
1679 msg_verbose_cmd(0, *cmdlinep); |
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
1680 |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
1681 /* |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
1682 * 1. Skip comment lines and leading white space and colons. |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
1683 * 2. Handle command modifiers. |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
1684 */ |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
1685 // The "ea" structure holds the arguments that can be used. |
7 | 1686 ea.cmd = *cmdlinep; |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
1687 ea.cmdlinep = cmdlinep; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
1688 ea.getline = fgetline; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
1689 ea.cookie = cookie; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
1690 #ifdef FEAT_EVAL |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
1691 ea.cstack = cstack; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
1692 #endif |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
1693 if (parse_command_modifiers(&ea, &errormsg, FALSE) == FAIL) |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
1694 goto doend; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
1695 |
9941
e975914c17e9
commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
9927
diff
changeset
|
1696 after_modifier = ea.cmd; |
7 | 1697 |
1698 #ifdef FEAT_EVAL | |
1699 ea.skip = did_emsg || got_int || did_throw || (cstack->cs_idx >= 0 | |
1700 && !(cstack->cs_flags[cstack->cs_idx] & CSF_ACTIVE)); | |
1701 #else | |
1702 ea.skip = (if_level > 0); | |
1703 #endif | |
1704 | |
1705 /* | |
6398 | 1706 * 3. Skip over the range to find the command. Let "p" point to after it. |
1707 * | |
1708 * We need the command to know what kind of range it uses. | |
1709 */ | |
1710 cmd = ea.cmd; | |
1711 ea.cmd = skip_range(ea.cmd, NULL); | |
1712 if (*ea.cmd == '*' && vim_strchr(p_cpo, CPO_STAR) == NULL) | |
1713 ea.cmd = skipwhite(ea.cmd + 1); | |
1714 p = find_command(&ea, NULL); | |
1715 | |
14591
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1716 #ifdef FEAT_EVAL |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1717 # ifdef FEAT_PROFILE |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1718 // Count this line for profiling if skip is TRUE. |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1719 if (do_profiling == PROF_YES |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1720 && (!ea.skip || cstack->cs_idx == 0 || (cstack->cs_idx > 0 |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1721 && (cstack->cs_flags[cstack->cs_idx - 1] & CSF_ACTIVE)))) |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1722 { |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1723 int skip = did_emsg || got_int || did_throw; |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1724 |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1725 if (ea.cmdidx == CMD_catch) |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1726 skip = !skip && !(cstack->cs_idx >= 0 |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1727 && (cstack->cs_flags[cstack->cs_idx] & CSF_THROWN) |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1728 && !(cstack->cs_flags[cstack->cs_idx] & CSF_CAUGHT)); |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1729 else if (ea.cmdidx == CMD_else || ea.cmdidx == CMD_elseif) |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1730 skip = skip || !(cstack->cs_idx >= 0 |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1731 && !(cstack->cs_flags[cstack->cs_idx] |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1732 & (CSF_ACTIVE | CSF_TRUE))); |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1733 else if (ea.cmdidx == CMD_finally) |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1734 skip = FALSE; |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1735 else if (ea.cmdidx != CMD_endif |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1736 && ea.cmdidx != CMD_endfor |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1737 && ea.cmdidx != CMD_endtry |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1738 && ea.cmdidx != CMD_endwhile) |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1739 skip = ea.skip; |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1740 |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1741 if (!skip) |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1742 { |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1743 if (getline_equal(fgetline, cookie, get_func_line)) |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1744 func_line_exec(getline_cookie(fgetline, cookie)); |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1745 else if (getline_equal(fgetline, cookie, getsourceline)) |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1746 script_line_exec(); |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1747 } |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1748 } |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1749 # endif |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1750 |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1751 /* May go to debug mode. If this happens and the ">quit" debug command is |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1752 * used, throw an interrupt exception and skip the next command. */ |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1753 dbg_check_breakpoint(&ea); |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1754 if (!ea.skip && got_int) |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1755 { |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1756 ea.skip = TRUE; |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1757 (void)do_intthrow(cstack); |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1758 } |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1759 #endif |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1760 |
6398 | 1761 /* |
1762 * 4. parse a range specifier of the form: addr [,addr] [;addr] .. | |
7 | 1763 * |
1764 * where 'addr' is: | |
1765 * | |
1766 * % (entire file) | |
1767 * $ [+-NUM] | |
1768 * 'x [+-NUM] (where x denotes a currently defined mark) | |
1769 * . [+-NUM] | |
1770 * [+-NUM].. | |
1771 * NUM | |
1772 * | |
1773 * The ea.cmd pointer is updated to point to the first character following the | |
1774 * range spec. If an initial address is found, but no second, the upper bound | |
1775 * is equal to the lower. | |
1776 */ | |
1777 | |
16515
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
1778 // ea.addr_type for user commands is set by find_ucmd |
6489 | 1779 if (!IS_USER_CMDIDX(ea.cmdidx)) |
1780 { | |
1781 if (ea.cmdidx != CMD_SIZE) | |
1782 ea.addr_type = cmdnames[(int)ea.cmdidx].cmd_addr_type; | |
1783 else | |
1784 ea.addr_type = ADDR_LINES; | |
1785 | |
16515
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
1786 // :wincmd range depends on the argument. |
6506 | 1787 if (ea.cmdidx == CMD_wincmd && p != NULL) |
1788 get_wincmd_addr_type(skipwhite(p), &ea); | |
16515
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
1789 #ifdef FEAT_QUICKFIX |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
1790 // :.cc in quickfix window uses line number |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
1791 if ((ea.cmdidx == CMD_cc || ea.cmdidx == CMD_ll) && bt_quickfix(curbuf)) |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
1792 ea.addr_type = ADDR_OTHER; |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
1793 #endif |
6489 | 1794 } |
6398 | 1795 |
6489 | 1796 ea.cmd = cmd; |
14760
fd69edd2c67e
patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents:
14700
diff
changeset
|
1797 if (parse_cmd_address(&ea, &errormsg, FALSE) == FAIL) |
14505
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
1798 goto doend; |
7 | 1799 |
1800 /* | |
6398 | 1801 * 5. Parse the command. |
7 | 1802 */ |
1803 | |
1804 /* | |
1805 * Skip ':' and any white space | |
1806 */ | |
1807 ea.cmd = skipwhite(ea.cmd); | |
1808 while (*ea.cmd == ':') | |
1809 ea.cmd = skipwhite(ea.cmd + 1); | |
1810 | |
1811 /* | |
1812 * If we got a line, but no command, then go to the line. | |
1813 * If we find a '|' or '\n' we set ea.nextcmd. | |
1814 */ | |
6398 | 1815 if (*ea.cmd == NUL || *ea.cmd == '"' |
1816 || (ea.nextcmd = check_nextcmd(ea.cmd)) != NULL) | |
7 | 1817 { |
1818 /* | |
1819 * strange vi behaviour: | |
1820 * ":3" jumps to line 3 | |
1821 * ":3|..." prints line 3 | |
1822 * ":|" prints current line | |
1823 */ | |
1824 if (ea.skip) /* skip this if inside :if */ | |
1825 goto doend; | |
167 | 1826 if (*ea.cmd == '|' || (exmode_active && ea.line1 != ea.line2)) |
7 | 1827 { |
1828 ea.cmdidx = CMD_print; | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
1829 ea.argt = EX_RANGE+EX_COUNT+EX_TRLBAR; |
7 | 1830 if ((errormsg = invalid_range(&ea)) == NULL) |
1831 { | |
1832 correct_range(&ea); | |
1833 ex_print(&ea); | |
1834 } | |
1835 } | |
1836 else if (ea.addr_count != 0) | |
1837 { | |
631 | 1838 if (ea.line2 > curbuf->b_ml.ml_line_count) |
1839 { | |
1840 /* With '-' in 'cpoptions' a line number past the file is an | |
1841 * error, otherwise put it at the end of the file. */ | |
1842 if (vim_strchr(p_cpo, CPO_MINUS) != NULL) | |
1843 ea.line2 = -1; | |
1844 else | |
1845 ea.line2 = curbuf->b_ml.ml_line_count; | |
1846 } | |
1847 | |
1848 if (ea.line2 < 0) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
1849 errormsg = _(e_invrange); |
7 | 1850 else |
1851 { | |
1852 if (ea.line2 == 0) | |
1853 curwin->w_cursor.lnum = 1; | |
1854 else | |
1855 curwin->w_cursor.lnum = ea.line2; | |
1856 beginline(BL_SOL | BL_FIX); | |
1857 } | |
1858 } | |
1859 goto doend; | |
1860 } | |
1861 | |
6154 | 1862 /* If this looks like an undefined user command and there are CmdUndefined |
1863 * autocommands defined, trigger the matching autocommands. */ | |
1864 if (p != NULL && ea.cmdidx == CMD_SIZE && !ea.skip | |
1865 && ASCII_ISUPPER(*ea.cmd) | |
1866 && has_cmdundefined()) | |
1867 { | |
1868 int ret; | |
1869 | |
6156 | 1870 p = ea.cmd; |
6154 | 1871 while (ASCII_ISALNUM(*p)) |
1872 ++p; | |
6191 | 1873 p = vim_strnsave(ea.cmd, (int)(p - ea.cmd)); |
6154 | 1874 ret = apply_autocmds(EVENT_CMDUNDEFINED, p, p, TRUE, NULL); |
1875 vim_free(p); | |
6965 | 1876 /* If the autocommands did something and didn't cause an error, try |
1877 * finding the command again. */ | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
1878 p = (ret |
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
1879 #ifdef FEAT_EVAL |
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
1880 && !aborting() |
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
1881 #endif |
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
1882 ) ? find_command(&ea, NULL) : ea.cmd; |
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
1883 } |
6154 | 1884 |
7 | 1885 if (p == NULL) |
1886 { | |
1887 if (!ea.skip) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
1888 errormsg = _("E464: Ambiguous use of user-defined command"); |
7 | 1889 goto doend; |
1890 } | |
16411
5b5c5daf57de
patch 8.1.1210: support for user commands is spread out
Bram Moolenaar <Bram@vim.org>
parents:
16399
diff
changeset
|
1891 // Check for wrong commands. |
11547
3d03ed329a54
patch 8.0.0656: cannot use ! after some user commands
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
1892 if (*p == '!' && ea.cmd[1] == 0151 && ea.cmd[0] == 78 |
3d03ed329a54
patch 8.0.0656: cannot use ! after some user commands
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
1893 && !IS_USER_CMDIDX(ea.cmdidx)) |
7 | 1894 { |
1895 errormsg = uc_fun_cmd(); | |
1896 goto doend; | |
1897 } | |
16411
5b5c5daf57de
patch 8.1.1210: support for user commands is spread out
Bram Moolenaar <Bram@vim.org>
parents:
16399
diff
changeset
|
1898 |
7 | 1899 if (ea.cmdidx == CMD_SIZE) |
1900 { | |
1901 if (!ea.skip) | |
1902 { | |
1903 STRCPY(IObuff, _("E492: Not an editor command")); | |
1904 if (!sourcing) | |
9941
e975914c17e9
commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
9927
diff
changeset
|
1905 { |
e975914c17e9
commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
9927
diff
changeset
|
1906 /* If the modifier was parsed OK the error must be in the |
e975914c17e9
commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
9927
diff
changeset
|
1907 * following command */ |
e975914c17e9
commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
9927
diff
changeset
|
1908 if (after_modifier != NULL) |
e975914c17e9
commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
9927
diff
changeset
|
1909 append_command(after_modifier); |
e975914c17e9
commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
9927
diff
changeset
|
1910 else |
e975914c17e9
commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
9927
diff
changeset
|
1911 append_command(*cmdlinep); |
e975914c17e9
commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
9927
diff
changeset
|
1912 } |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
1913 errormsg = (char *)IObuff; |
3757 | 1914 did_emsg_syntax = TRUE; |
7 | 1915 } |
1916 goto doend; | |
1917 } | |
1918 | |
6305 | 1919 ni = (!IS_USER_CMDIDX(ea.cmdidx) |
1920 && (cmdnames[ea.cmdidx].cmd_func == ex_ni | |
1315 | 1921 #ifdef HAVE_EX_SCRIPT_NI |
1922 || cmdnames[ea.cmdidx].cmd_func == ex_script_ni | |
1923 #endif | |
1924 )); | |
7 | 1925 |
1926 #ifndef FEAT_EVAL | |
1927 /* | |
1928 * When the expression evaluation is disabled, recognize the ":if" and | |
1929 * ":endif" commands and ignore everything in between it. | |
1930 */ | |
1931 if (ea.cmdidx == CMD_if) | |
1932 ++if_level; | |
1933 if (if_level) | |
1934 { | |
1935 if (ea.cmdidx == CMD_endif) | |
1936 --if_level; | |
1937 goto doend; | |
1938 } | |
1939 | |
1940 #endif | |
1941 | |
1613 | 1942 /* forced commands */ |
1943 if (*p == '!' && ea.cmdidx != CMD_substitute | |
1944 && ea.cmdidx != CMD_smagic && ea.cmdidx != CMD_snomagic) | |
7 | 1945 { |
1946 ++p; | |
1947 ea.forceit = TRUE; | |
1948 } | |
1949 else | |
1950 ea.forceit = FALSE; | |
1951 | |
1952 /* | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
1953 * 6. Parse arguments. Then check for errors. |
7 | 1954 */ |
6305 | 1955 if (!IS_USER_CMDIDX(ea.cmdidx)) |
835 | 1956 ea.argt = (long)cmdnames[(int)ea.cmdidx].cmd_argt; |
7 | 1957 |
1958 if (!ea.skip) | |
1959 { | |
1960 #ifdef HAVE_SANDBOX | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
1961 if (sandbox != 0 && !(ea.argt & EX_SBOXOK)) |
7 | 1962 { |
15748
93b78c4a7cd5
patch 8.1.0881: can execute shell commands in rvim through interfaces
Bram Moolenaar <Bram@vim.org>
parents:
15713
diff
changeset
|
1963 // Command not allowed in sandbox. |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
1964 errormsg = _(e_sandbox); |
7 | 1965 goto doend; |
1966 } | |
1967 #endif | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
1968 if (restricted != 0 && (ea.argt & EX_RESTRICT)) |
15748
93b78c4a7cd5
patch 8.1.0881: can execute shell commands in rvim through interfaces
Bram Moolenaar <Bram@vim.org>
parents:
15713
diff
changeset
|
1969 { |
93b78c4a7cd5
patch 8.1.0881: can execute shell commands in rvim through interfaces
Bram Moolenaar <Bram@vim.org>
parents:
15713
diff
changeset
|
1970 errormsg = _("E981: Command not allowed in rvim"); |
93b78c4a7cd5
patch 8.1.0881: can execute shell commands in rvim through interfaces
Bram Moolenaar <Bram@vim.org>
parents:
15713
diff
changeset
|
1971 goto doend; |
93b78c4a7cd5
patch 8.1.0881: can execute shell commands in rvim through interfaces
Bram Moolenaar <Bram@vim.org>
parents:
15713
diff
changeset
|
1972 } |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
1973 if (!curbuf->b_p_ma && (ea.argt & EX_MODIFY)) |
7 | 1974 { |
1975 /* Command not allowed in non-'modifiable' buffer */ | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
1976 errormsg = _(e_modifiable); |
7 | 1977 goto doend; |
1978 } | |
631 | 1979 |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
1980 if (text_locked() && !(ea.argt & EX_CMDWIN) |
6305 | 1981 && !IS_USER_CMDIDX(ea.cmdidx)) |
7 | 1982 { |
631 | 1983 /* Command not allowed when editing the command line. */ |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
1984 errormsg = _(get_text_locked_msg()); |
7 | 1985 goto doend; |
1986 } | |
14648
c3222a7342ab
patch 8.1.0337: :file fails in quickfix command
Christian Brabandt <cb@256bit.org>
parents:
14640
diff
changeset
|
1987 |
822 | 1988 /* Disallow editing another buffer when "curbuf_lock" is set. |
14648
c3222a7342ab
patch 8.1.0337: :file fails in quickfix command
Christian Brabandt <cb@256bit.org>
parents:
14640
diff
changeset
|
1989 * Do allow ":checktime" (it is postponed). |
c3222a7342ab
patch 8.1.0337: :file fails in quickfix command
Christian Brabandt <cb@256bit.org>
parents:
14640
diff
changeset
|
1990 * Do allow ":edit" (check for an argument later). |
c3222a7342ab
patch 8.1.0337: :file fails in quickfix command
Christian Brabandt <cb@256bit.org>
parents:
14640
diff
changeset
|
1991 * Do allow ":file" with no arguments (check for an argument later). */ |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
1992 if (!(ea.argt & EX_CMDWIN) |
14648
c3222a7342ab
patch 8.1.0337: :file fails in quickfix command
Christian Brabandt <cb@256bit.org>
parents:
14640
diff
changeset
|
1993 && ea.cmdidx != CMD_checktime |
822 | 1994 && ea.cmdidx != CMD_edit |
14648
c3222a7342ab
patch 8.1.0337: :file fails in quickfix command
Christian Brabandt <cb@256bit.org>
parents:
14640
diff
changeset
|
1995 && ea.cmdidx != CMD_file |
6305 | 1996 && !IS_USER_CMDIDX(ea.cmdidx) |
819 | 1997 && curbuf_locked()) |
1998 goto doend; | |
7 | 1999 |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2000 if (!ni && !(ea.argt & EX_RANGE) && ea.addr_count > 0) |
7 | 2001 { |
2002 /* no range allowed */ | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2003 errormsg = _(e_norange); |
7 | 2004 goto doend; |
2005 } | |
2006 } | |
2007 | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2008 if (!ni && !(ea.argt & EX_BANG) && ea.forceit) // no <!> allowed |
7 | 2009 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2010 errormsg = _(e_nobang); |
7 | 2011 goto doend; |
2012 } | |
2013 | |
2014 /* | |
2015 * Don't complain about the range if it is not used | |
2016 * (could happen if line_count is accidentally set to 0). | |
2017 */ | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2018 if (!ea.skip && !ni && (ea.argt & EX_RANGE)) |
7 | 2019 { |
2020 /* | |
2021 * If the range is backwards, ask for confirmation and, if given, swap | |
2022 * ea.line1 & ea.line2 so it's forwards again. | |
2023 * When global command is busy, don't ask, will fail below. | |
2024 */ | |
2025 if (!global_busy && ea.line1 > ea.line2) | |
2026 { | |
557 | 2027 if (msg_silent == 0) |
2028 { | |
2029 if (sourcing || exmode_active) | |
2030 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2031 errormsg = _("E493: Backwards range given"); |
557 | 2032 goto doend; |
2033 } | |
7 | 2034 if (ask_yesno((char_u *) |
2035 _("Backwards range given, OK to swap"), FALSE) != 'y') | |
557 | 2036 goto doend; |
7 | 2037 } |
2038 lnum = ea.line1; | |
2039 ea.line1 = ea.line2; | |
2040 ea.line2 = lnum; | |
2041 } | |
2042 if ((errormsg = invalid_range(&ea)) != NULL) | |
2043 goto doend; | |
2044 } | |
2045 | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
2046 if ((ea.addr_type == ADDR_OTHER) && ea.addr_count == 0) |
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
2047 // default is 1, not cursor |
7 | 2048 ea.line2 = 1; |
2049 | |
2050 correct_range(&ea); | |
2051 | |
2052 #ifdef FEAT_FOLDING | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2053 if (((ea.argt & EX_WHOLEFOLD) || ea.addr_count >= 2) && !global_busy |
7465
71e2aca45b81
commit https://github.com/vim/vim/commit/a3306958dcb9aadff1e1e8521d908d86b10ac99a
Christian Brabandt <cb@256bit.org>
parents:
7410
diff
changeset
|
2054 && ea.addr_type == ADDR_LINES) |
7 | 2055 { |
2056 /* Put the first line at the start of a closed fold, put the last line | |
2057 * at the end of a closed fold. */ | |
2058 (void)hasFolding(ea.line1, &ea.line1, NULL); | |
2059 (void)hasFolding(ea.line2, NULL, &ea.line2); | |
2060 } | |
2061 #endif | |
2062 | |
2063 #ifdef FEAT_QUICKFIX | |
2064 /* | |
41 | 2065 * For the ":make" and ":grep" commands we insert the 'makeprg'/'grepprg' |
7 | 2066 * option here, so things like % get expanded. |
2067 */ | |
344 | 2068 p = replace_makeprg(&ea, p, cmdlinep); |
2069 if (p == NULL) | |
2070 goto doend; | |
7 | 2071 #endif |
2072 | |
2073 /* | |
2074 * Skip to start of argument. | |
2075 * Don't do this for the ":!" command, because ":!! -l" needs the space. | |
2076 */ | |
2077 if (ea.cmdidx == CMD_bang) | |
2078 ea.arg = p; | |
2079 else | |
2080 ea.arg = skipwhite(p); | |
2081 | |
14648
c3222a7342ab
patch 8.1.0337: :file fails in quickfix command
Christian Brabandt <cb@256bit.org>
parents:
14640
diff
changeset
|
2082 // ":file" cannot be run with an argument when "curbuf_lock" is set |
c3222a7342ab
patch 8.1.0337: :file fails in quickfix command
Christian Brabandt <cb@256bit.org>
parents:
14640
diff
changeset
|
2083 if (ea.cmdidx == CMD_file && *ea.arg != NUL && curbuf_locked()) |
c3222a7342ab
patch 8.1.0337: :file fails in quickfix command
Christian Brabandt <cb@256bit.org>
parents:
14640
diff
changeset
|
2084 goto doend; |
c3222a7342ab
patch 8.1.0337: :file fails in quickfix command
Christian Brabandt <cb@256bit.org>
parents:
14640
diff
changeset
|
2085 |
7 | 2086 /* |
2087 * Check for "++opt=val" argument. | |
2088 * Must be first, allow ":w ++enc=utf8 !cmd" | |
2089 */ | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2090 if (ea.argt & EX_ARGOPT) |
7 | 2091 while (ea.arg[0] == '+' && ea.arg[1] == '+') |
2092 if (getargopt(&ea) == FAIL && !ni) | |
2093 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2094 errormsg = _(e_invarg); |
7 | 2095 goto doend; |
2096 } | |
2097 | |
2098 if (ea.cmdidx == CMD_write || ea.cmdidx == CMD_update) | |
2099 { | |
2100 if (*ea.arg == '>') /* append */ | |
2101 { | |
2102 if (*++ea.arg != '>') /* typed wrong */ | |
2103 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2104 errormsg = _("E494: Use w or w>>"); |
7 | 2105 goto doend; |
2106 } | |
2107 ea.arg = skipwhite(ea.arg + 1); | |
2108 ea.append = TRUE; | |
2109 } | |
2110 else if (*ea.arg == '!' && ea.cmdidx == CMD_write) /* :w !filter */ | |
2111 { | |
2112 ++ea.arg; | |
2113 ea.usefilter = TRUE; | |
2114 } | |
2115 } | |
2116 | |
2117 if (ea.cmdidx == CMD_read) | |
2118 { | |
2119 if (ea.forceit) | |
2120 { | |
2121 ea.usefilter = TRUE; /* :r! filter if ea.forceit */ | |
2122 ea.forceit = FALSE; | |
2123 } | |
2124 else if (*ea.arg == '!') /* :r !filter */ | |
2125 { | |
2126 ++ea.arg; | |
2127 ea.usefilter = TRUE; | |
2128 } | |
2129 } | |
2130 | |
2131 if (ea.cmdidx == CMD_lshift || ea.cmdidx == CMD_rshift) | |
2132 { | |
2133 ea.amount = 1; | |
2134 while (*ea.arg == *ea.cmd) /* count number of '>' or '<' */ | |
2135 { | |
2136 ++ea.arg; | |
2137 ++ea.amount; | |
2138 } | |
2139 ea.arg = skipwhite(ea.arg); | |
2140 } | |
2141 | |
2142 /* | |
2143 * Check for "+command" argument, before checking for next command. | |
2144 * Don't do this for ":read !cmd" and ":write !cmd". | |
2145 */ | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2146 if ((ea.argt & EX_CMDARG) && !ea.usefilter) |
7 | 2147 ea.do_ecmd_cmd = getargcmd(&ea.arg); |
2148 | |
2149 /* | |
2150 * Check for '|' to separate commands and '"' to start comments. | |
2151 * Don't do this for ":read !cmd" and ":write !cmd". | |
2152 */ | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2153 if ((ea.argt & EX_TRLBAR) && !ea.usefilter) |
7 | 2154 separate_nextcmd(&ea); |
2155 | |
2156 /* | |
2157 * Check for <newline> to end a shell command. | |
167 | 2158 * Also do this for ":read !cmd", ":write !cmd" and ":global". |
2159 * Any others? | |
7 | 2160 */ |
167 | 2161 else if (ea.cmdidx == CMD_bang |
11806
1c1cb1e9b7b3
patch 8.0.0785: wildcards are not expanded for :terminal
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
2162 || ea.cmdidx == CMD_terminal |
167 | 2163 || ea.cmdidx == CMD_global |
2164 || ea.cmdidx == CMD_vglobal | |
2165 || ea.usefilter) | |
7 | 2166 { |
2167 for (p = ea.arg; *p; ++p) | |
2168 { | |
2169 /* Remove one backslash before a newline, so that it's possible to | |
2170 * pass a newline to the shell and also a newline that is preceded | |
2171 * with a backslash. This makes it impossible to end a shell | |
2172 * command in a backslash, but that doesn't appear useful. | |
2173 * Halving the number of backslashes is incompatible with previous | |
2174 * versions. */ | |
2175 if (*p == '\\' && p[1] == '\n') | |
1619 | 2176 STRMOVE(p, p + 1); |
7 | 2177 else if (*p == '\n') |
2178 { | |
2179 ea.nextcmd = p + 1; | |
2180 *p = NUL; | |
2181 break; | |
2182 } | |
2183 } | |
2184 } | |
2185 | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2186 if ((ea.argt & EX_DFLALL) && ea.addr_count == 0) |
7 | 2187 { |
6424 | 2188 buf_T *buf; |
2189 | |
7 | 2190 ea.line1 = 1; |
6424 | 2191 switch (ea.addr_type) |
2192 { | |
2193 case ADDR_LINES: | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
2194 case ADDR_OTHER: |
6424 | 2195 ea.line2 = curbuf->b_ml.ml_line_count; |
2196 break; | |
2197 case ADDR_LOADED_BUFFERS: | |
2198 buf = firstbuf; | |
2199 while (buf->b_next != NULL && buf->b_ml.ml_mfp == NULL) | |
2200 buf = buf->b_next; | |
2201 ea.line1 = buf->b_fnum; | |
2202 buf = lastbuf; | |
2203 while (buf->b_prev != NULL && buf->b_ml.ml_mfp == NULL) | |
2204 buf = buf->b_prev; | |
2205 ea.line2 = buf->b_fnum; | |
2206 break; | |
2207 case ADDR_BUFFERS: | |
2208 ea.line1 = firstbuf->b_fnum; | |
2209 ea.line2 = lastbuf->b_fnum; | |
2210 break; | |
2211 case ADDR_WINDOWS: | |
2212 ea.line2 = LAST_WIN_NR; | |
2213 break; | |
2214 case ADDR_TABS: | |
2215 ea.line2 = LAST_TAB_NR; | |
2216 break; | |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
2217 case ADDR_TABS_RELATIVE: |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
2218 ea.line2 = 1; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
2219 break; |
6424 | 2220 case ADDR_ARGUMENTS: |
2221 if (ARGCOUNT == 0) | |
2222 ea.line1 = ea.line2 = 0; | |
2223 else | |
2224 ea.line2 = ARGCOUNT; | |
2225 break; | |
16515
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
2226 case ADDR_QUICKFIX_VALID: |
7105
f4456e686406
commit https://github.com/vim/vim/commit/e906c502079770ae0e0071c74cefb802689ff193
Christian Brabandt <cb@256bit.org>
parents:
7092
diff
changeset
|
2227 #ifdef FEAT_QUICKFIX |
16515
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
2228 ea.line2 = qf_get_valid_size(&ea); |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
2229 if (ea.line2 == 0) |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
2230 ea.line2 = 1; |
16479
7dcf301d1432
patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents:
16475
diff
changeset
|
2231 #endif |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
2232 break; |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
2233 case ADDR_NONE: |
16515
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
2234 case ADDR_UNSIGNED: |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
2235 case ADDR_QUICKFIX: |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2236 iemsg(_("INTERNAL: Cannot use EX_DFLALL with ADDR_NONE, ADDR_UNSIGNED or ADDR_QUICKFIX")); |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
2237 break; |
6424 | 2238 } |
7 | 2239 } |
2240 | |
2241 /* accept numbered register only when no count allowed (:put) */ | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2242 if ( (ea.argt & EX_REGSTR) |
7 | 2243 && *ea.arg != NUL |
6305 | 2244 /* Do not allow register = for user commands */ |
2245 && (!IS_USER_CMDIDX(ea.cmdidx) || *ea.arg != '=') | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2246 && !((ea.argt & EX_COUNT) && VIM_ISDIGIT(*ea.arg))) |
7 | 2247 { |
2791 | 2248 #ifndef FEAT_CLIPBOARD |
2249 /* check these explicitly for a more specific error message */ | |
2250 if (*ea.arg == '*' || *ea.arg == '+') | |
2251 { | |
15474
79e3dcc5aa50
patch 8.1.0745: compiler warnings for signed/unsigned string
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
2252 errormsg = _(e_invalidreg); |
2791 | 2253 goto doend; |
2254 } | |
2255 #endif | |
6305 | 2256 if (valid_yank_reg(*ea.arg, (ea.cmdidx != CMD_put |
2257 && !IS_USER_CMDIDX(ea.cmdidx)))) | |
2791 | 2258 { |
2259 ea.regname = *ea.arg++; | |
7 | 2260 #ifdef FEAT_EVAL |
2791 | 2261 /* for '=' register: accept the rest of the line as an expression */ |
2262 if (ea.arg[-1] == '=' && ea.arg[0] != NUL) | |
2263 { | |
2264 set_expr_line(vim_strsave(ea.arg)); | |
2265 ea.arg += STRLEN(ea.arg); | |
2266 } | |
2267 #endif | |
2268 ea.arg = skipwhite(ea.arg); | |
2269 } | |
7 | 2270 } |
2271 | |
2272 /* | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2273 * Check for a count. When accepting a EX_BUFNAME, don't use "123foo" as a |
7 | 2274 * count, it's a buffer name. |
2275 */ | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2276 if ((ea.argt & EX_COUNT) && VIM_ISDIGIT(*ea.arg) |
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2277 && (!(ea.argt & EX_BUFNAME) || *(p = skipdigits(ea.arg)) == NUL |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
2278 || VIM_ISWHITE(*p))) |
7 | 2279 { |
2280 n = getdigits(&ea.arg); | |
2281 ea.arg = skipwhite(ea.arg); | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2282 if (n <= 0 && !ni && (ea.argt & EX_ZEROR) == 0) |
7 | 2283 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2284 errormsg = _(e_zerocount); |
7 | 2285 goto doend; |
2286 } | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
2287 if (ea.addr_type != ADDR_LINES) // e.g. :buffer 2, :sleep 3 |
7 | 2288 { |
2289 ea.line2 = n; | |
2290 if (ea.addr_count == 0) | |
2291 ea.addr_count = 1; | |
2292 } | |
2293 else | |
2294 { | |
2295 ea.line1 = ea.line2; | |
2296 ea.line2 += n - 1; | |
2297 ++ea.addr_count; | |
2298 /* | |
2299 * Be vi compatible: no error message for out of range. | |
2300 */ | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
2301 if (ea.line2 > curbuf->b_ml.ml_line_count) |
7 | 2302 ea.line2 = curbuf->b_ml.ml_line_count; |
2303 } | |
2304 } | |
167 | 2305 |
2306 /* | |
2307 * Check for flags: 'l', 'p' and '#'. | |
2308 */ | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2309 if (ea.argt & EX_FLAGS) |
167 | 2310 get_flags(&ea); |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2311 if (!ni && !(ea.argt & EX_EXTRA) && *ea.arg != NUL |
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2312 && *ea.arg != '"' && (*ea.arg != '|' || (ea.argt & EX_TRLBAR) == 0)) |
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2313 { |
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2314 // no arguments allowed but there is something |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2315 errormsg = _(e_trailing); |
7 | 2316 goto doend; |
2317 } | |
2318 | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2319 if (!ni && (ea.argt & EX_NEEDARG) && *ea.arg == NUL) |
7 | 2320 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2321 errormsg = _(e_argreq); |
7 | 2322 goto doend; |
2323 } | |
2324 | |
2325 #ifdef FEAT_EVAL | |
2326 /* | |
2327 * Skip the command when it's not going to be executed. | |
2328 * The commands like :if, :endif, etc. always need to be executed. | |
2329 * Also make an exception for commands that handle a trailing command | |
2330 * themselves. | |
2331 */ | |
2332 if (ea.skip) | |
2333 { | |
2334 switch (ea.cmdidx) | |
2335 { | |
2336 /* commands that need evaluation */ | |
2337 case CMD_while: | |
2338 case CMD_endwhile: | |
72 | 2339 case CMD_for: |
2340 case CMD_endfor: | |
7 | 2341 case CMD_if: |
2342 case CMD_elseif: | |
2343 case CMD_else: | |
2344 case CMD_endif: | |
2345 case CMD_try: | |
2346 case CMD_catch: | |
2347 case CMD_finally: | |
2348 case CMD_endtry: | |
2349 case CMD_function: | |
2350 break; | |
2351 | |
2352 /* Commands that handle '|' themselves. Check: A command should | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2353 * either have the EX_TRLBAR flag, appear in this list or appear in |
7 | 2354 * the list at ":help :bar". */ |
2355 case CMD_aboveleft: | |
2356 case CMD_and: | |
2357 case CMD_belowright: | |
2358 case CMD_botright: | |
2359 case CMD_browse: | |
2360 case CMD_call: | |
2361 case CMD_confirm: | |
18713
baf890fa1621
patch 8.1.2348: :const cannot be followed by "| endif"
Bram Moolenaar <Bram@vim.org>
parents:
18406
diff
changeset
|
2362 case CMD_const: |
7 | 2363 case CMD_delfunction: |
2364 case CMD_djump: | |
2365 case CMD_dlist: | |
2366 case CMD_dsearch: | |
2367 case CMD_dsplit: | |
2368 case CMD_echo: | |
2369 case CMD_echoerr: | |
2370 case CMD_echomsg: | |
2371 case CMD_echon: | |
2372 case CMD_execute: | |
9941
e975914c17e9
commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
9927
diff
changeset
|
2373 case CMD_filter: |
7 | 2374 case CMD_help: |
2375 case CMD_hide: | |
2376 case CMD_ijump: | |
2377 case CMD_ilist: | |
2378 case CMD_isearch: | |
2379 case CMD_isplit: | |
22 | 2380 case CMD_keepalt: |
7 | 2381 case CMD_keepjumps: |
2382 case CMD_keepmarks: | |
5467 | 2383 case CMD_keeppatterns: |
7 | 2384 case CMD_leftabove: |
2385 case CMD_let: | |
2386 case CMD_lockmarks: | |
2320
966a5609669e
Added Lua interfae. (Luis Carvalho)
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
2387 case CMD_lua: |
7 | 2388 case CMD_match: |
14 | 2389 case CMD_mzscheme: |
5737 | 2390 case CMD_noautocmd: |
2391 case CMD_noswapfile: | |
7 | 2392 case CMD_perl: |
2393 case CMD_psearch: | |
2394 case CMD_python: | |
2350
06feaf4fe36a
Rename some "python3" symbols to "py3", as the command name.
Bram Moolenaar <bram@vim.org>
parents:
2340
diff
changeset
|
2395 case CMD_py3: |
2366
7a57fe6a5157
Fix that :py3file was not working.
Bram Moolenaar <bram@vim.org>
parents:
2360
diff
changeset
|
2396 case CMD_python3: |
7 | 2397 case CMD_return: |
2398 case CMD_rightbelow: | |
2399 case CMD_ruby: | |
2400 case CMD_silent: | |
2401 case CMD_smagic: | |
2402 case CMD_snomagic: | |
2403 case CMD_substitute: | |
2404 case CMD_syntax: | |
690 | 2405 case CMD_tab: |
7 | 2406 case CMD_tcl: |
2407 case CMD_throw: | |
2408 case CMD_tilde: | |
2409 case CMD_topleft: | |
2410 case CMD_unlet: | |
2411 case CMD_verbose: | |
2412 case CMD_vertical: | |
2887 | 2413 case CMD_wincmd: |
7 | 2414 break; |
2415 | |
2416 default: goto doend; | |
2417 } | |
2418 } | |
2419 #endif | |
2420 | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2421 if (ea.argt & EX_XFILE) |
7 | 2422 { |
2423 if (expand_filename(&ea, cmdlinep, &errormsg) == FAIL) | |
2424 goto doend; | |
2425 } | |
2426 | |
2427 /* | |
2428 * Accept buffer name. Cannot be used at the same time with a buffer | |
2429 * number. Don't do this for a user command. | |
2430 */ | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2431 if ((ea.argt & EX_BUFNAME) && *ea.arg != NUL && ea.addr_count == 0 |
6305 | 2432 && !IS_USER_CMDIDX(ea.cmdidx)) |
7 | 2433 { |
2434 /* | |
2435 * :bdelete, :bwipeout and :bunload take several arguments, separated | |
2436 * by spaces: find next space (skipping over escaped characters). | |
2437 * The others take one argument: ignore trailing spaces. | |
2438 */ | |
2439 if (ea.cmdidx == CMD_bdelete || ea.cmdidx == CMD_bwipeout | |
2440 || ea.cmdidx == CMD_bunload) | |
2441 p = skiptowhite_esc(ea.arg); | |
2442 else | |
2443 { | |
2444 p = ea.arg + STRLEN(ea.arg); | |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
2445 while (p > ea.arg && VIM_ISWHITE(p[-1])) |
7 | 2446 --p; |
2447 } | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2448 ea.line2 = buflist_findpat(ea.arg, p, (ea.argt & EX_BUFUNL) != 0, |
4236 | 2449 FALSE, FALSE); |
7 | 2450 if (ea.line2 < 0) /* failed */ |
2451 goto doend; | |
2452 ea.addr_count = 1; | |
2453 ea.arg = skipwhite(p); | |
2454 } | |
2455 | |
13288
530943a23d3f
patch 8.0.1518: error messages suppressed after ":silent! try"
Christian Brabandt <cb@256bit.org>
parents:
13268
diff
changeset
|
2456 /* The :try command saves the emsg_silent flag, reset it here when |
530943a23d3f
patch 8.0.1518: error messages suppressed after ":silent! try"
Christian Brabandt <cb@256bit.org>
parents:
13268
diff
changeset
|
2457 * ":silent! try" was used, it should only apply to :try itself. */ |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2458 if (ea.cmdidx == CMD_try && ea.did_esilent > 0) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2459 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2460 emsg_silent -= ea.did_esilent; |
13288
530943a23d3f
patch 8.0.1518: error messages suppressed after ":silent! try"
Christian Brabandt <cb@256bit.org>
parents:
13268
diff
changeset
|
2461 if (emsg_silent < 0) |
530943a23d3f
patch 8.0.1518: error messages suppressed after ":silent! try"
Christian Brabandt <cb@256bit.org>
parents:
13268
diff
changeset
|
2462 emsg_silent = 0; |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2463 ea.did_esilent = 0; |
13288
530943a23d3f
patch 8.0.1518: error messages suppressed after ":silent! try"
Christian Brabandt <cb@256bit.org>
parents:
13268
diff
changeset
|
2464 } |
530943a23d3f
patch 8.0.1518: error messages suppressed after ":silent! try"
Christian Brabandt <cb@256bit.org>
parents:
13268
diff
changeset
|
2465 |
530943a23d3f
patch 8.0.1518: error messages suppressed after ":silent! try"
Christian Brabandt <cb@256bit.org>
parents:
13268
diff
changeset
|
2466 /* |
530943a23d3f
patch 8.0.1518: error messages suppressed after ":silent! try"
Christian Brabandt <cb@256bit.org>
parents:
13268
diff
changeset
|
2467 * 7. Execute the command. |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2468 */ |
7 | 2469 |
6305 | 2470 if (IS_USER_CMDIDX(ea.cmdidx)) |
7 | 2471 { |
2472 /* | |
2473 * Execute a user-defined command. | |
2474 */ | |
2475 do_ucmd(&ea); | |
2476 } | |
2477 else | |
2478 { | |
2479 /* | |
16411
5b5c5daf57de
patch 8.1.1210: support for user commands is spread out
Bram Moolenaar <Bram@vim.org>
parents:
16399
diff
changeset
|
2480 * Call the function to execute the builtin command. |
7 | 2481 */ |
2482 ea.errmsg = NULL; | |
2483 (cmdnames[ea.cmdidx].cmd_func)(&ea); | |
2484 if (ea.errmsg != NULL) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2485 errormsg = _(ea.errmsg); |
7 | 2486 } |
2487 | |
2488 #ifdef FEAT_EVAL | |
2489 /* | |
2490 * If the command just executed called do_cmdline(), any throw or ":return" | |
2491 * or ":finish" encountered there must also check the cstack of the still | |
2492 * active do_cmdline() that called this do_one_cmd(). Rethrow an uncaught | |
2493 * exception, or reanimate a returned function or finished script file and | |
2494 * return or finish it again. | |
2495 */ | |
2496 if (need_rethrow) | |
2497 do_throw(cstack); | |
2498 else if (check_cstack) | |
2499 { | |
944 | 2500 if (source_finished(fgetline, cookie)) |
7 | 2501 do_finish(&ea, TRUE); |
944 | 2502 else if (getline_equal(fgetline, cookie, get_func_line) |
7 | 2503 && current_func_returned()) |
2504 do_return(&ea, TRUE, FALSE, NULL); | |
2505 } | |
2506 need_rethrow = check_cstack = FALSE; | |
2507 #endif | |
2508 | |
2509 doend: | |
2510 if (curwin->w_cursor.lnum == 0) /* can happen with zero line number */ | |
11374
889da8649221
patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents:
11258
diff
changeset
|
2511 { |
7 | 2512 curwin->w_cursor.lnum = 1; |
11374
889da8649221
patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents:
11258
diff
changeset
|
2513 curwin->w_cursor.col = 0; |
889da8649221
patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents:
11258
diff
changeset
|
2514 } |
7 | 2515 |
2516 if (errormsg != NULL && *errormsg != NUL && !did_emsg) | |
2517 { | |
2518 if (sourcing) | |
2519 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2520 if (errormsg != (char *)IObuff) |
7 | 2521 { |
2522 STRCPY(IObuff, errormsg); | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2523 errormsg = (char *)IObuff; |
7 | 2524 } |
3097 | 2525 append_command(*cmdlinep); |
7 | 2526 } |
2527 emsg(errormsg); | |
2528 } | |
2529 #ifdef FEAT_EVAL | |
2530 do_errthrow(cstack, | |
6305 | 2531 (ea.cmdidx != CMD_SIZE && !IS_USER_CMDIDX(ea.cmdidx)) |
2532 ? cmdnames[(int)ea.cmdidx].cmd_name : (char_u *)NULL); | |
7 | 2533 #endif |
2534 | |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2535 if (ea.verbose_save >= 0) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2536 p_verbose = ea.verbose_save; |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
2537 |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2538 free_cmdmod(); |
7 | 2539 cmdmod = save_cmdmod; |
16144
4850744dc181
patch 8.1.1077: reg_executing() is reset by calling input()
Bram Moolenaar <Bram@vim.org>
parents:
15973
diff
changeset
|
2540 reg_executing = save_reg_executing; |
7 | 2541 |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2542 if (ea.save_msg_silent != -1) |
7 | 2543 { |
2544 /* messages could be enabled for a serious error, need to check if the | |
2545 * counters don't become negative */ | |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2546 if (!did_emsg || msg_silent > ea.save_msg_silent) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2547 msg_silent = ea.save_msg_silent; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2548 emsg_silent -= ea.did_esilent; |
7 | 2549 if (emsg_silent < 0) |
2550 emsg_silent = 0; | |
2551 /* Restore msg_scroll, it's set by file I/O commands, even when no | |
2552 * message is actually displayed. */ | |
2553 msg_scroll = save_msg_scroll; | |
1854 | 2554 |
2555 /* "silent reg" or "silent echo x" inside "redir" leaves msg_col | |
2556 * somewhere in the line. Put it back in the first column. */ | |
2557 if (redirecting()) | |
2558 msg_col = 0; | |
7 | 2559 } |
2560 | |
28 | 2561 #ifdef HAVE_SANDBOX |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2562 if (ea.did_sandbox) |
28 | 2563 --sandbox; |
2564 #endif | |
2565 | |
7 | 2566 if (ea.nextcmd && *ea.nextcmd == NUL) /* not really a next command */ |
2567 ea.nextcmd = NULL; | |
2568 | |
2569 #ifdef FEAT_EVAL | |
2570 --ex_nesting_level; | |
2571 #endif | |
2572 | |
2573 return ea.nextcmd; | |
2574 } | |
2575 #if (_MSC_VER == 1200) | |
128 | 2576 #pragma optimize( "", on ) |
7 | 2577 #endif |
2578 | |
2579 /* | |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2580 * Parse and skip over command modifiers: |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2581 * - update eap->cmd |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2582 * - store flags in "cmdmod". |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2583 * - Set ex_pressedreturn for an empty command line. |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2584 * - set msg_silent for ":silent" |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2585 * - set 'eventignore' to "all" for ":noautocmd" |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2586 * - set p_verbose for ":verbose" |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2587 * - Increment "sandbox" for ":sandbox" |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2588 * When "skip_only" is TRUE the global variables are not changed, except for |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2589 * "cmdmod". |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2590 * Return FAIL when the command is not to be executed. |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2591 * May set "errormsg" to an error message. |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2592 */ |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2593 int |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2594 parse_command_modifiers(exarg_T *eap, char **errormsg, int skip_only) |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2595 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2596 char_u *p; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2597 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2598 vim_memset(&cmdmod, 0, sizeof(cmdmod)); |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2599 eap->verbose_save = -1; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2600 eap->save_msg_silent = -1; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2601 |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2602 // Repeat until no more command modifiers are found. |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2603 for (;;) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2604 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2605 while (*eap->cmd == ' ' || *eap->cmd == '\t' || *eap->cmd == ':') |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2606 ++eap->cmd; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2607 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2608 /* in ex mode, an empty line works like :+ */ |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2609 if (*eap->cmd == NUL && exmode_active |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2610 && (getline_equal(eap->getline, eap->cookie, getexmodeline) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2611 || getline_equal(eap->getline, eap->cookie, getexline)) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2612 && curwin->w_cursor.lnum < curbuf->b_ml.ml_line_count) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2613 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2614 eap->cmd = (char_u *)"+"; |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2615 if (!skip_only) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2616 ex_pressedreturn = TRUE; |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2617 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2618 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2619 /* ignore comment and empty lines */ |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2620 if (*eap->cmd == '"') |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2621 return FAIL; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2622 if (*eap->cmd == NUL) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2623 { |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2624 if (!skip_only) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2625 ex_pressedreturn = TRUE; |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2626 return FAIL; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2627 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2628 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2629 p = skip_range(eap->cmd, NULL); |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2630 switch (*p) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2631 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2632 /* When adding an entry, also modify cmd_exists(). */ |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2633 case 'a': if (!checkforcmd(&eap->cmd, "aboveleft", 3)) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2634 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2635 cmdmod.split |= WSP_ABOVE; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2636 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2637 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2638 case 'b': if (checkforcmd(&eap->cmd, "belowright", 3)) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2639 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2640 cmdmod.split |= WSP_BELOW; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2641 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2642 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2643 if (checkforcmd(&eap->cmd, "browse", 3)) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2644 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2645 #ifdef FEAT_BROWSE_CMD |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2646 cmdmod.browse = TRUE; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2647 #endif |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2648 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2649 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2650 if (!checkforcmd(&eap->cmd, "botright", 2)) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2651 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2652 cmdmod.split |= WSP_BOT; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2653 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2654 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2655 case 'c': if (!checkforcmd(&eap->cmd, "confirm", 4)) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2656 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2657 #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2658 cmdmod.confirm = TRUE; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2659 #endif |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2660 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2661 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2662 case 'k': if (checkforcmd(&eap->cmd, "keepmarks", 3)) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2663 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2664 cmdmod.keepmarks = TRUE; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2665 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2666 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2667 if (checkforcmd(&eap->cmd, "keepalt", 5)) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2668 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2669 cmdmod.keepalt = TRUE; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2670 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2671 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2672 if (checkforcmd(&eap->cmd, "keeppatterns", 5)) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2673 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2674 cmdmod.keeppatterns = TRUE; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2675 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2676 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2677 if (!checkforcmd(&eap->cmd, "keepjumps", 5)) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2678 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2679 cmdmod.keepjumps = TRUE; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2680 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2681 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2682 case 'f': /* only accept ":filter {pat} cmd" */ |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2683 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2684 char_u *reg_pat; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2685 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2686 if (!checkforcmd(&p, "filter", 4) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2687 || *p == NUL || ends_excmd(*p)) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2688 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2689 if (*p == '!') |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2690 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2691 cmdmod.filter_force = TRUE; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2692 p = skipwhite(p + 1); |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2693 if (*p == NUL || ends_excmd(*p)) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2694 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2695 } |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2696 if (skip_only) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2697 p = skip_vimgrep_pat(p, NULL, NULL); |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2698 else |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2699 // NOTE: This puts a NUL after the pattern. |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2700 p = skip_vimgrep_pat(p, ®_pat, NULL); |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2701 if (p == NULL || *p == NUL) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2702 break; |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2703 if (!skip_only) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2704 { |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2705 cmdmod.filter_regmatch.regprog = |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2706 vim_regcomp(reg_pat, RE_MAGIC); |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2707 if (cmdmod.filter_regmatch.regprog == NULL) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2708 break; |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2709 } |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2710 eap->cmd = p; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2711 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2712 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2713 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2714 /* ":hide" and ":hide | cmd" are not modifiers */ |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2715 case 'h': if (p != eap->cmd || !checkforcmd(&p, "hide", 3) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2716 || *p == NUL || ends_excmd(*p)) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2717 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2718 eap->cmd = p; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2719 cmdmod.hide = TRUE; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2720 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2721 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2722 case 'l': if (checkforcmd(&eap->cmd, "lockmarks", 3)) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2723 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2724 cmdmod.lockmarks = TRUE; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2725 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2726 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2727 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2728 if (!checkforcmd(&eap->cmd, "leftabove", 5)) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2729 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2730 cmdmod.split |= WSP_ABOVE; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2731 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2732 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2733 case 'n': if (checkforcmd(&eap->cmd, "noautocmd", 3)) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2734 { |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2735 if (cmdmod.save_ei == NULL && !skip_only) |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2736 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2737 /* Set 'eventignore' to "all". Restore the |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2738 * existing option value later. */ |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2739 cmdmod.save_ei = vim_strsave(p_ei); |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2740 set_string_option_direct((char_u *)"ei", -1, |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2741 (char_u *)"all", OPT_FREE, SID_NONE); |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2742 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2743 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2744 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2745 if (!checkforcmd(&eap->cmd, "noswapfile", 3)) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2746 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2747 cmdmod.noswapfile = TRUE; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2748 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2749 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2750 case 'r': if (!checkforcmd(&eap->cmd, "rightbelow", 6)) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2751 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2752 cmdmod.split |= WSP_BELOW; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2753 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2754 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2755 case 's': if (checkforcmd(&eap->cmd, "sandbox", 3)) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2756 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2757 #ifdef HAVE_SANDBOX |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2758 if (!skip_only) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2759 { |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2760 if (!eap->did_sandbox) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2761 ++sandbox; |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2762 eap->did_sandbox = TRUE; |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2763 } |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2764 #endif |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2765 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2766 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2767 if (!checkforcmd(&eap->cmd, "silent", 3)) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2768 break; |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2769 if (!skip_only) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2770 { |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2771 if (eap->save_msg_silent == -1) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2772 eap->save_msg_silent = msg_silent; |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2773 ++msg_silent; |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2774 } |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2775 if (*eap->cmd == '!' && !VIM_ISWHITE(eap->cmd[-1])) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2776 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2777 /* ":silent!", but not "silent !cmd" */ |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2778 eap->cmd = skipwhite(eap->cmd + 1); |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2779 if (!skip_only) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2780 { |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2781 ++emsg_silent; |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2782 ++eap->did_esilent; |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2783 } |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2784 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2785 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2786 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2787 case 't': if (checkforcmd(&p, "tab", 3)) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2788 { |
15263
ad065b8123e8
patch 8.1.0640: get E14 while typing command :tab with 'incsearch' set
Bram Moolenaar <Bram@vim.org>
parents:
15239
diff
changeset
|
2789 if (!skip_only) |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2790 { |
15263
ad065b8123e8
patch 8.1.0640: get E14 while typing command :tab with 'incsearch' set
Bram Moolenaar <Bram@vim.org>
parents:
15239
diff
changeset
|
2791 long tabnr = get_address(eap, &eap->cmd, |
ad065b8123e8
patch 8.1.0640: get E14 while typing command :tab with 'incsearch' set
Bram Moolenaar <Bram@vim.org>
parents:
15239
diff
changeset
|
2792 ADDR_TABS, eap->skip, |
ad065b8123e8
patch 8.1.0640: get E14 while typing command :tab with 'incsearch' set
Bram Moolenaar <Bram@vim.org>
parents:
15239
diff
changeset
|
2793 skip_only, FALSE, 1); |
ad065b8123e8
patch 8.1.0640: get E14 while typing command :tab with 'incsearch' set
Bram Moolenaar <Bram@vim.org>
parents:
15239
diff
changeset
|
2794 if (tabnr == MAXLNUM) |
ad065b8123e8
patch 8.1.0640: get E14 while typing command :tab with 'incsearch' set
Bram Moolenaar <Bram@vim.org>
parents:
15239
diff
changeset
|
2795 cmdmod.tab = tabpage_index(curtab) + 1; |
ad065b8123e8
patch 8.1.0640: get E14 while typing command :tab with 'incsearch' set
Bram Moolenaar <Bram@vim.org>
parents:
15239
diff
changeset
|
2796 else |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2797 { |
15263
ad065b8123e8
patch 8.1.0640: get E14 while typing command :tab with 'incsearch' set
Bram Moolenaar <Bram@vim.org>
parents:
15239
diff
changeset
|
2798 if (tabnr < 0 || tabnr > LAST_TAB_NR) |
ad065b8123e8
patch 8.1.0640: get E14 while typing command :tab with 'incsearch' set
Bram Moolenaar <Bram@vim.org>
parents:
15239
diff
changeset
|
2799 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2800 *errormsg = _(e_invrange); |
15263
ad065b8123e8
patch 8.1.0640: get E14 while typing command :tab with 'incsearch' set
Bram Moolenaar <Bram@vim.org>
parents:
15239
diff
changeset
|
2801 return FAIL; |
ad065b8123e8
patch 8.1.0640: get E14 while typing command :tab with 'incsearch' set
Bram Moolenaar <Bram@vim.org>
parents:
15239
diff
changeset
|
2802 } |
ad065b8123e8
patch 8.1.0640: get E14 while typing command :tab with 'incsearch' set
Bram Moolenaar <Bram@vim.org>
parents:
15239
diff
changeset
|
2803 cmdmod.tab = tabnr + 1; |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2804 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2805 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2806 eap->cmd = p; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2807 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2808 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2809 if (!checkforcmd(&eap->cmd, "topleft", 2)) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2810 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2811 cmdmod.split |= WSP_TOP; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2812 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2813 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2814 case 'u': if (!checkforcmd(&eap->cmd, "unsilent", 3)) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2815 break; |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2816 if (!skip_only) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2817 { |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2818 if (eap->save_msg_silent == -1) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2819 eap->save_msg_silent = msg_silent; |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2820 msg_silent = 0; |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2821 } |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2822 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2823 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2824 case 'v': if (checkforcmd(&eap->cmd, "vertical", 4)) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2825 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2826 cmdmod.split |= WSP_VERT; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2827 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2828 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2829 if (!checkforcmd(&p, "verbose", 4)) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2830 break; |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2831 if (!skip_only) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2832 { |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2833 if (eap->verbose_save < 0) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2834 eap->verbose_save = p_verbose; |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2835 if (vim_isdigit(*eap->cmd)) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2836 p_verbose = atoi((char *)eap->cmd); |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2837 else |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2838 p_verbose = 1; |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2839 } |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2840 eap->cmd = p; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2841 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2842 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2843 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2844 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2845 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2846 return OK; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2847 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2848 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2849 /* |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2850 * Free contents of "cmdmod". |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2851 */ |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2852 static void |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2853 free_cmdmod(void) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2854 { |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2855 if (cmdmod.save_ei != NULL) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2856 { |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2857 /* Restore 'eventignore' to the value before ":noautocmd". */ |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2858 set_string_option_direct((char_u *)"ei", -1, cmdmod.save_ei, |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2859 OPT_FREE, SID_NONE); |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2860 free_string_option(cmdmod.save_ei); |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2861 } |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2862 |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2863 if (cmdmod.filter_regmatch.regprog != NULL) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2864 vim_regfree(cmdmod.filter_regmatch.regprog); |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2865 } |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2866 |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2867 /* |
14505
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2868 * Parse the address range, if any, in "eap". |
14760
fd69edd2c67e
patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents:
14700
diff
changeset
|
2869 * May set the last search pattern, unless "silent" is TRUE. |
14505
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2870 * Return FAIL and set "errormsg" or return OK. |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2871 */ |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2872 int |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2873 parse_cmd_address(exarg_T *eap, char **errormsg, int silent) |
14505
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2874 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2875 int address_count = 1; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2876 linenr_T lnum; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2877 |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2878 // Repeat for all ',' or ';' separated addresses. |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2879 for (;;) |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2880 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2881 eap->line1 = eap->line2; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2882 switch (eap->addr_type) |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2883 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2884 case ADDR_LINES: |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
2885 case ADDR_OTHER: |
14505
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2886 // default is current line number |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2887 eap->line2 = curwin->w_cursor.lnum; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2888 break; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2889 case ADDR_WINDOWS: |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2890 eap->line2 = CURRENT_WIN_NR; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2891 break; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2892 case ADDR_ARGUMENTS: |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2893 eap->line2 = curwin->w_arg_idx + 1; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2894 if (eap->line2 > ARGCOUNT) |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2895 eap->line2 = ARGCOUNT; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2896 break; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2897 case ADDR_LOADED_BUFFERS: |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2898 case ADDR_BUFFERS: |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2899 eap->line2 = curbuf->b_fnum; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2900 break; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2901 case ADDR_TABS: |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2902 eap->line2 = CURRENT_TAB_NR; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2903 break; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2904 case ADDR_TABS_RELATIVE: |
16515
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
2905 case ADDR_UNSIGNED: |
14505
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2906 eap->line2 = 1; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2907 break; |
16479
7dcf301d1432
patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents:
16475
diff
changeset
|
2908 case ADDR_QUICKFIX: |
14505
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2909 #ifdef FEAT_QUICKFIX |
16515
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
2910 eap->line2 = qf_get_cur_idx(eap); |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
2911 #endif |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
2912 break; |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
2913 case ADDR_QUICKFIX_VALID: |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
2914 #ifdef FEAT_QUICKFIX |
14505
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2915 eap->line2 = qf_get_cur_valid_idx(eap); |
16479
7dcf301d1432
patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents:
16475
diff
changeset
|
2916 #endif |
14505
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2917 break; |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
2918 case ADDR_NONE: |
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
2919 // Will give an error later if a range is found. |
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
2920 break; |
14505
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2921 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2922 eap->cmd = skipwhite(eap->cmd); |
14760
fd69edd2c67e
patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents:
14700
diff
changeset
|
2923 lnum = get_address(eap, &eap->cmd, eap->addr_type, eap->skip, silent, |
14505
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2924 eap->addr_count == 0, address_count++); |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2925 if (eap->cmd == NULL) // error detected |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2926 return FAIL; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2927 if (lnum == MAXLNUM) |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2928 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2929 if (*eap->cmd == '%') // '%' - all lines |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2930 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2931 ++eap->cmd; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2932 switch (eap->addr_type) |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2933 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2934 case ADDR_LINES: |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
2935 case ADDR_OTHER: |
14505
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2936 eap->line1 = 1; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2937 eap->line2 = curbuf->b_ml.ml_line_count; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2938 break; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2939 case ADDR_LOADED_BUFFERS: |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2940 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2941 buf_T *buf = firstbuf; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2942 |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2943 while (buf->b_next != NULL |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2944 && buf->b_ml.ml_mfp == NULL) |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2945 buf = buf->b_next; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2946 eap->line1 = buf->b_fnum; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2947 buf = lastbuf; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2948 while (buf->b_prev != NULL |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2949 && buf->b_ml.ml_mfp == NULL) |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2950 buf = buf->b_prev; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2951 eap->line2 = buf->b_fnum; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2952 break; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2953 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2954 case ADDR_BUFFERS: |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2955 eap->line1 = firstbuf->b_fnum; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2956 eap->line2 = lastbuf->b_fnum; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2957 break; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2958 case ADDR_WINDOWS: |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2959 case ADDR_TABS: |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2960 if (IS_USER_CMDIDX(eap->cmdidx)) |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2961 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2962 eap->line1 = 1; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2963 eap->line2 = eap->addr_type == ADDR_WINDOWS |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2964 ? LAST_WIN_NR : LAST_TAB_NR; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2965 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2966 else |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2967 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2968 // there is no Vim command which uses '%' and |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2969 // ADDR_WINDOWS or ADDR_TABS |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2970 *errormsg = _(e_invrange); |
14505
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2971 return FAIL; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2972 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2973 break; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2974 case ADDR_TABS_RELATIVE: |
16515
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
2975 case ADDR_UNSIGNED: |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
2976 case ADDR_QUICKFIX: |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2977 *errormsg = _(e_invrange); |
14505
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2978 return FAIL; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2979 case ADDR_ARGUMENTS: |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2980 if (ARGCOUNT == 0) |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2981 eap->line1 = eap->line2 = 0; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2982 else |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2983 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2984 eap->line1 = 1; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2985 eap->line2 = ARGCOUNT; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2986 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2987 break; |
16515
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
2988 case ADDR_QUICKFIX_VALID: |
14505
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2989 #ifdef FEAT_QUICKFIX |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2990 eap->line1 = 1; |
16515
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
2991 eap->line2 = qf_get_valid_size(eap); |
14505
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2992 if (eap->line2 == 0) |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2993 eap->line2 = 1; |
16479
7dcf301d1432
patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents:
16475
diff
changeset
|
2994 #endif |
14505
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2995 break; |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
2996 case ADDR_NONE: |
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
2997 // Will give an error later if a range is found. |
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
2998 break; |
14505
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2999 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3000 ++eap->addr_count; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3001 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3002 else if (*eap->cmd == '*' && vim_strchr(p_cpo, CPO_STAR) == NULL) |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3003 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3004 pos_T *fp; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3005 |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3006 // '*' - visual area |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3007 if (eap->addr_type != ADDR_LINES) |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3008 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
3009 *errormsg = _(e_invrange); |
14505
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3010 return FAIL; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3011 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3012 |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3013 ++eap->cmd; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3014 if (!eap->skip) |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3015 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3016 fp = getmark('<', FALSE); |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3017 if (check_mark(fp) == FAIL) |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3018 return FAIL; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3019 eap->line1 = fp->lnum; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3020 fp = getmark('>', FALSE); |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3021 if (check_mark(fp) == FAIL) |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3022 return FAIL; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3023 eap->line2 = fp->lnum; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3024 ++eap->addr_count; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3025 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3026 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3027 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3028 else |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3029 eap->line2 = lnum; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3030 eap->addr_count++; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3031 |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3032 if (*eap->cmd == ';') |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3033 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3034 if (!eap->skip) |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3035 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3036 curwin->w_cursor.lnum = eap->line2; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3037 // don't leave the cursor on an illegal line or column |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3038 check_cursor(); |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3039 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3040 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3041 else if (*eap->cmd != ',') |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3042 break; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3043 ++eap->cmd; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3044 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3045 |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3046 // One address given: set start and end lines. |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3047 if (eap->addr_count == 1) |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3048 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3049 eap->line1 = eap->line2; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3050 // ... but only implicit: really no address given |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3051 if (lnum == MAXLNUM) |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3052 eap->addr_count = 0; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3053 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3054 return OK; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3055 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3056 |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3057 /* |
93 | 3058 * Check for an Ex command with optional tail. |
7 | 3059 * If there is a match advance "pp" to the argument and return TRUE. |
3060 */ | |
93 | 3061 int |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3062 checkforcmd( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3063 char_u **pp, /* start of command */ |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3064 char *cmd, /* name of command */ |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3065 int len) /* required length */ |
7 | 3066 { |
3067 int i; | |
3068 | |
3069 for (i = 0; cmd[i] != NUL; ++i) | |
1872 | 3070 if (((char_u *)cmd)[i] != (*pp)[i]) |
7 | 3071 break; |
3072 if (i >= len && !isalpha((*pp)[i])) | |
3073 { | |
3074 *pp = skipwhite(*pp + i); | |
3075 return TRUE; | |
3076 } | |
3077 return FALSE; | |
3078 } | |
3079 | |
3080 /* | |
3097 | 3081 * Append "cmd" to the error message in IObuff. |
3082 * Takes care of limiting the length and handling 0xa0, which would be | |
3083 * invisible otherwise. | |
3084 */ | |
3085 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3086 append_command(char_u *cmd) |
3097 | 3087 { |
3088 char_u *s = cmd; | |
3089 char_u *d; | |
3090 | |
3091 STRCAT(IObuff, ": "); | |
3092 d = IObuff + STRLEN(IObuff); | |
3093 while (*s != NUL && d - IObuff < IOSIZE - 7) | |
3094 { | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
3095 if (enc_utf8 ? (s[0] == 0xc2 && s[1] == 0xa0) : *s == 0xa0) |
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
3096 { |
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
3097 s += enc_utf8 ? 2 : 1; |
3097 | 3098 STRCPY(d, "<a0>"); |
3099 d += 4; | |
3100 } | |
3101 else | |
3102 MB_COPY_CHAR(s, d); | |
3103 } | |
3104 *d = NUL; | |
3105 } | |
3106 | |
3107 /* | |
7 | 3108 * Find an Ex command by its name, either built-in or user. |
184 | 3109 * Start of the name can be found at eap->cmd. |
16515
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
3110 * Sets eap->cmdidx and returns a pointer to char after the command name. |
184 | 3111 * "full" is set to TRUE if the whole command name matched. |
7 | 3112 * Returns NULL for an ambiguous user command. |
3113 */ | |
3114 static char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3115 find_command(exarg_T *eap, int *full UNUSED) |
7 | 3116 { |
3117 int len; | |
3118 char_u *p; | |
167 | 3119 int i; |
7 | 3120 |
3121 /* | |
3122 * Isolate the command and search for it in the command table. | |
1441 | 3123 * Exceptions: |
7 | 3124 * - the 'k' command can directly be followed by any character. |
3125 * - the 's' command can be followed directly by 'c', 'g', 'i', 'I' or 'r' | |
6472 | 3126 * but :sre[wind] is another command, as are :scr[iptnames], |
7 | 3127 * :scs[cope], :sim[alt], :sig[ns] and :sil[ent]. |
167 | 3128 * - the "d" command can directly be followed by 'l' or 'p' flag. |
7 | 3129 */ |
3130 p = eap->cmd; | |
3131 if (*p == 'k') | |
3132 { | |
3133 eap->cmdidx = CMD_k; | |
3134 ++p; | |
3135 } | |
3136 else if (p[0] == 's' | |
6987 | 3137 && ((p[1] == 'c' && (p[2] == NUL || (p[2] != 's' && p[2] != 'r' |
3138 && (p[3] == NUL || (p[3] != 'i' && p[4] != 'p'))))) | |
7 | 3139 || p[1] == 'g' |
3140 || (p[1] == 'i' && p[2] != 'm' && p[2] != 'l' && p[2] != 'g') | |
3141 || p[1] == 'I' | |
3142 || (p[1] == 'r' && p[2] != 'e'))) | |
3143 { | |
3144 eap->cmdidx = CMD_substitute; | |
3145 ++p; | |
3146 } | |
3147 else | |
3148 { | |
3149 while (ASCII_ISALPHA(*p)) | |
3150 ++p; | |
2366
7a57fe6a5157
Fix that :py3file was not working.
Bram Moolenaar <bram@vim.org>
parents:
2360
diff
changeset
|
3151 /* for python 3.x support ":py3", ":python3", ":py3file", etc. */ |
2330 | 3152 if (eap->cmd[0] == 'p' && eap->cmd[1] == 'y') |
2366
7a57fe6a5157
Fix that :py3file was not working.
Bram Moolenaar <bram@vim.org>
parents:
2360
diff
changeset
|
3153 while (ASCII_ISALNUM(*p)) |
7a57fe6a5157
Fix that :py3file was not working.
Bram Moolenaar <bram@vim.org>
parents:
2360
diff
changeset
|
3154 ++p; |
2329
ad2889f48843
Added support for Python 3. (Roland Puntaier)
Bram Moolenaar <bram@vim.org>
parents:
2320
diff
changeset
|
3155 |
7 | 3156 /* check for non-alpha command */ |
3157 if (p == eap->cmd && vim_strchr((char_u *)"@*!=><&~#", *p) != NULL) | |
3158 ++p; | |
3159 len = (int)(p - eap->cmd); | |
167 | 3160 if (*eap->cmd == 'd' && (p[-1] == 'l' || p[-1] == 'p')) |
3161 { | |
3162 /* Check for ":dl", ":dell", etc. to ":deletel": that's | |
3163 * :delete with the 'l' flag. Same for 'p'. */ | |
3164 for (i = 0; i < len; ++i) | |
1872 | 3165 if (eap->cmd[i] != ((char_u *)"delete")[i]) |
167 | 3166 break; |
3167 if (i == len - 1) | |
3168 { | |
3169 --len; | |
3170 if (p[-1] == 'l') | |
3171 eap->flags |= EXFLAG_LIST; | |
3172 else | |
3173 eap->flags |= EXFLAG_PRINT; | |
3174 } | |
3175 } | |
7 | 3176 |
11236
62c96fee518e
patch 8.0.0504: looking up an Ex command is a bit slow
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
3177 if (ASCII_ISLOWER(eap->cmd[0])) |
62c96fee518e
patch 8.0.0504: looking up an Ex command is a bit slow
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
3178 { |
11240
06307d812ca7
patch 8.0.0506: can't build with ANSI C
Christian Brabandt <cb@256bit.org>
parents:
11236
diff
changeset
|
3179 int c1 = eap->cmd[0]; |
17496
c8152af9fa33
patch 8.1.1746: ":dl" is seen as ":dlist" instead of ":delete"
Bram Moolenaar <Bram@vim.org>
parents:
17488
diff
changeset
|
3180 int c2 = len == 1 ? NUL : eap->cmd[1]; |
11240
06307d812ca7
patch 8.0.0506: can't build with ANSI C
Christian Brabandt <cb@256bit.org>
parents:
11236
diff
changeset
|
3181 |
11236
62c96fee518e
patch 8.0.0504: looking up an Ex command is a bit slow
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
3182 if (command_count != (int)CMD_SIZE) |
62c96fee518e
patch 8.0.0504: looking up an Ex command is a bit slow
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
3183 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
3184 iemsg(_("E943: Command table needs to be updated, run 'make cmdidxs'")); |
11236
62c96fee518e
patch 8.0.0504: looking up an Ex command is a bit slow
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
3185 getout(1); |
62c96fee518e
patch 8.0.0504: looking up an Ex command is a bit slow
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
3186 } |
62c96fee518e
patch 8.0.0504: looking up an Ex command is a bit slow
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
3187 |
62c96fee518e
patch 8.0.0504: looking up an Ex command is a bit slow
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
3188 /* Use a precomputed index for fast look-up in cmdnames[] |
62c96fee518e
patch 8.0.0504: looking up an Ex command is a bit slow
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
3189 * taking into account the first 2 letters of eap->cmd. */ |
62c96fee518e
patch 8.0.0504: looking up an Ex command is a bit slow
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
3190 eap->cmdidx = cmdidxs1[CharOrdLow(c1)]; |
62c96fee518e
patch 8.0.0504: looking up an Ex command is a bit slow
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
3191 if (ASCII_ISLOWER(c2)) |
62c96fee518e
patch 8.0.0504: looking up an Ex command is a bit slow
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
3192 eap->cmdidx += cmdidxs2[CharOrdLow(c1)][CharOrdLow(c2)]; |
62c96fee518e
patch 8.0.0504: looking up an Ex command is a bit slow
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
3193 } |
7 | 3194 else |
11236
62c96fee518e
patch 8.0.0504: looking up an Ex command is a bit slow
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
3195 eap->cmdidx = CMD_bang; |
7 | 3196 |
3197 for ( ; (int)eap->cmdidx < (int)CMD_SIZE; | |
3198 eap->cmdidx = (cmdidx_T)((int)eap->cmdidx + 1)) | |
3199 if (STRNCMP(cmdnames[(int)eap->cmdidx].cmd_name, (char *)eap->cmd, | |
3200 (size_t)len) == 0) | |
3201 { | |
3202 #ifdef FEAT_EVAL | |
3203 if (full != NULL | |
3204 && cmdnames[(int)eap->cmdidx].cmd_name[len] == NUL) | |
3205 *full = TRUE; | |
3206 #endif | |
3207 break; | |
3208 } | |
3209 | |
16411
5b5c5daf57de
patch 8.1.1210: support for user commands is spread out
Bram Moolenaar <Bram@vim.org>
parents:
16399
diff
changeset
|
3210 // Look for a user defined command as a last resort. Let ":Print" be |
5b5c5daf57de
patch 8.1.1210: support for user commands is spread out
Bram Moolenaar <Bram@vim.org>
parents:
16399
diff
changeset
|
3211 // overruled by a user defined command. |
2633 | 3212 if ((eap->cmdidx == CMD_SIZE || eap->cmdidx == CMD_Print) |
3213 && *eap->cmd >= 'A' && *eap->cmd <= 'Z') | |
7 | 3214 { |
16411
5b5c5daf57de
patch 8.1.1210: support for user commands is spread out
Bram Moolenaar <Bram@vim.org>
parents:
16399
diff
changeset
|
3215 // User defined commands may contain digits. |
7 | 3216 while (ASCII_ISALNUM(*p)) |
3217 ++p; | |
184 | 3218 p = find_ucmd(eap, p, full, NULL, NULL); |
3219 } | |
3220 if (p == eap->cmd) | |
7 | 3221 eap->cmdidx = CMD_SIZE; |
3222 } | |
3223 | |
3224 return p; | |
3225 } | |
3226 | |
3227 #if defined(FEAT_EVAL) || defined(PROTO) | |
1447 | 3228 static struct cmdmod |
3229 { | |
3230 char *name; | |
3231 int minlen; | |
3232 int has_count; /* :123verbose :3tab */ | |
3233 } cmdmods[] = { | |
3234 {"aboveleft", 3, FALSE}, | |
3235 {"belowright", 3, FALSE}, | |
3236 {"botright", 2, FALSE}, | |
3237 {"browse", 3, FALSE}, | |
3238 {"confirm", 4, FALSE}, | |
9941
e975914c17e9
commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
9927
diff
changeset
|
3239 {"filter", 4, FALSE}, |
1447 | 3240 {"hide", 3, FALSE}, |
3241 {"keepalt", 5, FALSE}, | |
3242 {"keepjumps", 5, FALSE}, | |
3243 {"keepmarks", 3, FALSE}, | |
5467 | 3244 {"keeppatterns", 5, FALSE}, |
1447 | 3245 {"leftabove", 5, FALSE}, |
3246 {"lockmarks", 3, FALSE}, | |
1721 | 3247 {"noautocmd", 3, FALSE}, |
5737 | 3248 {"noswapfile", 3, FALSE}, |
1447 | 3249 {"rightbelow", 6, FALSE}, |
3250 {"sandbox", 3, FALSE}, | |
3251 {"silent", 3, FALSE}, | |
3252 {"tab", 3, TRUE}, | |
3253 {"topleft", 2, FALSE}, | |
1926 | 3254 {"unsilent", 3, FALSE}, |
1447 | 3255 {"verbose", 4, TRUE}, |
3256 {"vertical", 4, FALSE}, | |
3257 }; | |
3258 | |
3259 /* | |
3260 * Return length of a command modifier (including optional count). | |
3261 * Return zero when it's not a modifier. | |
3262 */ | |
3263 int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3264 modifier_len(char_u *cmd) |
1447 | 3265 { |
3266 int i, j; | |
3267 char_u *p = cmd; | |
3268 | |
3269 if (VIM_ISDIGIT(*cmd)) | |
3270 p = skipwhite(skipdigits(cmd)); | |
1880 | 3271 for (i = 0; i < (int)(sizeof(cmdmods) / sizeof(struct cmdmod)); ++i) |
1447 | 3272 { |
3273 for (j = 0; p[j] != NUL; ++j) | |
3274 if (p[j] != cmdmods[i].name[j]) | |
3275 break; | |
4857
84a8d1ba81c3
updated for version 7.3.1175
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3276 if (!ASCII_ISALPHA(p[j]) && j >= cmdmods[i].minlen |
1447 | 3277 && (p == cmd || cmdmods[i].has_count)) |
1570 | 3278 return j + (int)(p - cmd); |
1447 | 3279 } |
3280 return 0; | |
3281 } | |
3282 | |
7 | 3283 /* |
3284 * Return > 0 if an Ex command "name" exists. | |
3285 * Return 2 if there is an exact match. | |
3286 * Return 3 if there is an ambiguous match. | |
3287 */ | |
3288 int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3289 cmd_exists(char_u *name) |
7 | 3290 { |
3291 exarg_T ea; | |
3292 int full = FALSE; | |
3293 int i; | |
3294 int j; | |
866 | 3295 char_u *p; |
7 | 3296 |
3297 /* Check command modifiers. */ | |
1880 | 3298 for (i = 0; i < (int)(sizeof(cmdmods) / sizeof(struct cmdmod)); ++i) |
7 | 3299 { |
3300 for (j = 0; name[j] != NUL; ++j) | |
3301 if (name[j] != cmdmods[i].name[j]) | |
3302 break; | |
3303 if (name[j] == NUL && j >= cmdmods[i].minlen) | |
3304 return (cmdmods[i].name[j] == NUL ? 2 : 1); | |
3305 } | |
3306 | |
862 | 3307 /* Check built-in commands and user defined commands. |
3308 * For ":2match" and ":3match" we need to skip the number. */ | |
3309 ea.cmd = (*name == '2' || *name == '3') ? name + 1 : name; | |
7 | 3310 ea.cmdidx = (cmdidx_T)0; |
866 | 3311 p = find_command(&ea, &full); |
3312 if (p == NULL) | |
7 | 3313 return 3; |
862 | 3314 if (vim_isdigit(*name) && ea.cmdidx != CMD_match) |
3315 return 0; | |
866 | 3316 if (*skipwhite(p) != NUL) |
3317 return 0; /* trailing garbage */ | |
7 | 3318 return (ea.cmdidx == CMD_SIZE ? 0 : (full ? 2 : 1)); |
3319 } | |
3320 #endif | |
3321 | |
17835
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17823
diff
changeset
|
3322 cmdidx_T |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17823
diff
changeset
|
3323 excmd_get_cmdidx(char_u *cmd, int len) |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17823
diff
changeset
|
3324 { |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17823
diff
changeset
|
3325 cmdidx_T idx; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17823
diff
changeset
|
3326 |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17823
diff
changeset
|
3327 for (idx = (cmdidx_T)0; (int)idx < (int)CMD_SIZE; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17823
diff
changeset
|
3328 idx = (cmdidx_T)((int)idx + 1)) |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17823
diff
changeset
|
3329 if (STRNCMP(cmdnames[(int)idx].cmd_name, cmd, (size_t)len) == 0) |
7 | 3330 break; |
3331 | |
17835
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17823
diff
changeset
|
3332 return idx; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17823
diff
changeset
|
3333 } |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17823
diff
changeset
|
3334 |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17823
diff
changeset
|
3335 long |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17823
diff
changeset
|
3336 excmd_get_argt(cmdidx_T idx) |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17823
diff
changeset
|
3337 { |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17823
diff
changeset
|
3338 return (long)cmdnames[(int)idx].cmd_argt; |
7 | 3339 } |
3340 | |
3341 /* | |
14505
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3342 * Skip a range specifier of the form: addr [,addr] [;addr] .. |
7 | 3343 * |
3344 * Backslashed delimiters after / or ? will be skipped, and commands will | |
3345 * not be expanded between /'s and ?'s or after "'". | |
3346 * | |
167 | 3347 * Also skip white space and ":" characters. |
7 | 3348 * Returns the "cmd" pointer advanced to beyond the range. |
3349 */ | |
3350 char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3351 skip_range( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3352 char_u *cmd, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3353 int *ctx) /* pointer to xp_context or NULL */ |
7 | 3354 { |
1872 | 3355 unsigned delim; |
7 | 3356 |
10817
cc8079703414
patch 8.0.0298: Ex command range with repeated search does not work
Christian Brabandt <cb@256bit.org>
parents:
10809
diff
changeset
|
3357 while (vim_strchr((char_u *)" \t0123456789.$%'/?-+,;\\", *cmd) != NULL) |
cc8079703414
patch 8.0.0298: Ex command range with repeated search does not work
Christian Brabandt <cb@256bit.org>
parents:
10809
diff
changeset
|
3358 { |
cc8079703414
patch 8.0.0298: Ex command range with repeated search does not work
Christian Brabandt <cb@256bit.org>
parents:
10809
diff
changeset
|
3359 if (*cmd == '\\') |
cc8079703414
patch 8.0.0298: Ex command range with repeated search does not work
Christian Brabandt <cb@256bit.org>
parents:
10809
diff
changeset
|
3360 { |
cc8079703414
patch 8.0.0298: Ex command range with repeated search does not work
Christian Brabandt <cb@256bit.org>
parents:
10809
diff
changeset
|
3361 if (cmd[1] == '?' || cmd[1] == '/' || cmd[1] == '&') |
cc8079703414
patch 8.0.0298: Ex command range with repeated search does not work
Christian Brabandt <cb@256bit.org>
parents:
10809
diff
changeset
|
3362 ++cmd; |
cc8079703414
patch 8.0.0298: Ex command range with repeated search does not work
Christian Brabandt <cb@256bit.org>
parents:
10809
diff
changeset
|
3363 else |
cc8079703414
patch 8.0.0298: Ex command range with repeated search does not work
Christian Brabandt <cb@256bit.org>
parents:
10809
diff
changeset
|
3364 break; |
cc8079703414
patch 8.0.0298: Ex command range with repeated search does not work
Christian Brabandt <cb@256bit.org>
parents:
10809
diff
changeset
|
3365 } |
cc8079703414
patch 8.0.0298: Ex command range with repeated search does not work
Christian Brabandt <cb@256bit.org>
parents:
10809
diff
changeset
|
3366 else if (*cmd == '\'') |
7 | 3367 { |
3368 if (*++cmd == NUL && ctx != NULL) | |
3369 *ctx = EXPAND_NOTHING; | |
3370 } | |
3371 else if (*cmd == '/' || *cmd == '?') | |
3372 { | |
3373 delim = *cmd++; | |
3374 while (*cmd != NUL && *cmd != delim) | |
3375 if (*cmd++ == '\\' && *cmd != NUL) | |
3376 ++cmd; | |
3377 if (*cmd == NUL && ctx != NULL) | |
3378 *ctx = EXPAND_NOTHING; | |
3379 } | |
3380 if (*cmd != NUL) | |
3381 ++cmd; | |
3382 } | |
167 | 3383 |
3384 /* Skip ":" and white space. */ | |
3385 while (*cmd == ':') | |
3386 cmd = skipwhite(cmd + 1); | |
3387 | |
7 | 3388 return cmd; |
3389 } | |
3390 | |
17650
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
3391 static void |
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
3392 addr_error(cmd_addr_T addr_type) |
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
3393 { |
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
3394 if (addr_type == ADDR_NONE) |
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
3395 emsg(_(e_norange)); |
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
3396 else |
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
3397 emsg(_(e_invrange)); |
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
3398 } |
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
3399 |
7 | 3400 /* |
14677
7771a1ff8b99
patch 8.1.0351: 'incsearch' for :/foo/s//<Esc> changes last search pattern
Christian Brabandt <cb@256bit.org>
parents:
14648
diff
changeset
|
3401 * Get a single EX address. |
7 | 3402 * |
3403 * Set ptr to the next character after the part that was interpreted. | |
3404 * Set ptr to NULL when an error is encountered. | |
14677
7771a1ff8b99
patch 8.1.0351: 'incsearch' for :/foo/s//<Esc> changes last search pattern
Christian Brabandt <cb@256bit.org>
parents:
14648
diff
changeset
|
3405 * This may set the last used search pattern. |
7 | 3406 * |
3407 * Return MAXLNUM when no Ex address was found. | |
3408 */ | |
3409 static linenr_T | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3410 get_address( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3411 exarg_T *eap UNUSED, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3412 char_u **ptr, |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
3413 cmd_addr_T addr_type_arg, |
14760
fd69edd2c67e
patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents:
14700
diff
changeset
|
3414 int skip, // only skip the address, don't use it |
fd69edd2c67e
patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents:
14700
diff
changeset
|
3415 int silent, // no errors or side effects |
fd69edd2c67e
patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents:
14700
diff
changeset
|
3416 int to_other_file, // flag: may jump to other file |
fd69edd2c67e
patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents:
14700
diff
changeset
|
3417 int address_count UNUSED) // 1 for first address, >1 after comma |
7 | 3418 { |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
3419 cmd_addr_T addr_type = addr_type_arg; |
7 | 3420 int c; |
3421 int i; | |
3422 long n; | |
3423 char_u *cmd; | |
3424 pos_T pos; | |
3425 pos_T *fp; | |
3426 linenr_T lnum; | |
6424 | 3427 buf_T *buf; |
7 | 3428 |
3429 cmd = skipwhite(*ptr); | |
3430 lnum = MAXLNUM; | |
3431 do | |
3432 { | |
3433 switch (*cmd) | |
3434 { | |
3435 case '.': /* '.' - Cursor position */ | |
6398 | 3436 ++cmd; |
3437 switch (addr_type) | |
3438 { | |
3439 case ADDR_LINES: | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
3440 case ADDR_OTHER: |
7 | 3441 lnum = curwin->w_cursor.lnum; |
3442 break; | |
6398 | 3443 case ADDR_WINDOWS: |
6409 | 3444 lnum = CURRENT_WIN_NR; |
6398 | 3445 break; |
3446 case ADDR_ARGUMENTS: | |
3447 lnum = curwin->w_arg_idx + 1; | |
3448 break; | |
3449 case ADDR_LOADED_BUFFERS: | |
6424 | 3450 case ADDR_BUFFERS: |
6398 | 3451 lnum = curbuf->b_fnum; |
3452 break; | |
3453 case ADDR_TABS: | |
6409 | 3454 lnum = CURRENT_TAB_NR; |
6398 | 3455 break; |
17650
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
3456 case ADDR_NONE: |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
3457 case ADDR_TABS_RELATIVE: |
16515
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
3458 case ADDR_UNSIGNED: |
17650
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
3459 addr_error(addr_type); |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
3460 cmd = NULL; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
3461 goto error; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
3462 break; |
16479
7dcf301d1432
patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents:
16475
diff
changeset
|
3463 case ADDR_QUICKFIX: |
7105
f4456e686406
commit https://github.com/vim/vim/commit/e906c502079770ae0e0071c74cefb802689ff193
Christian Brabandt <cb@256bit.org>
parents:
7092
diff
changeset
|
3464 #ifdef FEAT_QUICKFIX |
16515
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
3465 lnum = qf_get_cur_idx(eap); |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
3466 #endif |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
3467 break; |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
3468 case ADDR_QUICKFIX_VALID: |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
3469 #ifdef FEAT_QUICKFIX |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
3470 lnum = qf_get_cur_valid_idx(eap); |
16479
7dcf301d1432
patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents:
16475
diff
changeset
|
3471 #endif |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
3472 break; |
6398 | 3473 } |
3474 break; | |
7 | 3475 |
3476 case '$': /* '$' - last line */ | |
6398 | 3477 ++cmd; |
3478 switch (addr_type) | |
3479 { | |
3480 case ADDR_LINES: | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
3481 case ADDR_OTHER: |
7 | 3482 lnum = curbuf->b_ml.ml_line_count; |
3483 break; | |
6398 | 3484 case ADDR_WINDOWS: |
6409 | 3485 lnum = LAST_WIN_NR; |
6398 | 3486 break; |
3487 case ADDR_ARGUMENTS: | |
3488 lnum = ARGCOUNT; | |
3489 break; | |
3490 case ADDR_LOADED_BUFFERS: | |
6424 | 3491 buf = lastbuf; |
3492 while (buf->b_ml.ml_mfp == NULL) | |
3493 { | |
3494 if (buf->b_prev == NULL) | |
3495 break; | |
3496 buf = buf->b_prev; | |
3497 } | |
3498 lnum = buf->b_fnum; | |
3499 break; | |
3500 case ADDR_BUFFERS: | |
6398 | 3501 lnum = lastbuf->b_fnum; |
3502 break; | |
3503 case ADDR_TABS: | |
6409 | 3504 lnum = LAST_TAB_NR; |
6398 | 3505 break; |
17650
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
3506 case ADDR_NONE: |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
3507 case ADDR_TABS_RELATIVE: |
16515
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
3508 case ADDR_UNSIGNED: |
17650
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
3509 addr_error(addr_type); |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
3510 cmd = NULL; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
3511 goto error; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
3512 break; |
16479
7dcf301d1432
patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents:
16475
diff
changeset
|
3513 case ADDR_QUICKFIX: |
7105
f4456e686406
commit https://github.com/vim/vim/commit/e906c502079770ae0e0071c74cefb802689ff193
Christian Brabandt <cb@256bit.org>
parents:
7092
diff
changeset
|
3514 #ifdef FEAT_QUICKFIX |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
3515 lnum = qf_get_size(eap); |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
3516 if (lnum == 0) |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
3517 lnum = 1; |
16479
7dcf301d1432
patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents:
16475
diff
changeset
|
3518 #endif |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
3519 break; |
16515
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
3520 case ADDR_QUICKFIX_VALID: |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
3521 #ifdef FEAT_QUICKFIX |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
3522 lnum = qf_get_valid_size(eap); |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
3523 if (lnum == 0) |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
3524 lnum = 1; |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
3525 #endif |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
3526 break; |
6398 | 3527 } |
3528 break; | |
7 | 3529 |
3530 case '\'': /* ''' - mark */ | |
6398 | 3531 if (*++cmd == NUL) |
3532 { | |
3533 cmd = NULL; | |
3534 goto error; | |
3535 } | |
3536 if (addr_type != ADDR_LINES) | |
3537 { | |
17650
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
3538 addr_error(addr_type); |
6581 | 3539 cmd = NULL; |
6398 | 3540 goto error; |
3541 } | |
3542 if (skip) | |
3543 ++cmd; | |
3544 else | |
3545 { | |
3546 /* Only accept a mark in another file when it is | |
3547 * used by itself: ":'M". */ | |
3548 fp = getmark(*cmd, to_other_file && cmd[1] == NUL); | |
3549 ++cmd; | |
3550 if (fp == (pos_T *)-1) | |
3551 /* Jumped to another file. */ | |
3552 lnum = curwin->w_cursor.lnum; | |
3553 else | |
3554 { | |
3555 if (check_mark(fp) == FAIL) | |
7 | 3556 { |
3557 cmd = NULL; | |
3558 goto error; | |
3559 } | |
6398 | 3560 lnum = fp->lnum; |
3561 } | |
3562 } | |
3563 break; | |
7 | 3564 |
3565 case '/': | |
3566 case '?': /* '/' or '?' - search */ | |
6398 | 3567 c = *cmd++; |
3568 if (addr_type != ADDR_LINES) | |
3569 { | |
17650
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
3570 addr_error(addr_type); |
6581 | 3571 cmd = NULL; |
6398 | 3572 goto error; |
3573 } | |
3574 if (skip) /* skip "/pat/" */ | |
3575 { | |
3576 cmd = skip_regexp(cmd, c, (int)p_magic, NULL); | |
3577 if (*cmd == c) | |
3578 ++cmd; | |
3579 } | |
3580 else | |
3581 { | |
14760
fd69edd2c67e
patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents:
14700
diff
changeset
|
3582 int flags; |
fd69edd2c67e
patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents:
14700
diff
changeset
|
3583 |
fd69edd2c67e
patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents:
14700
diff
changeset
|
3584 pos = curwin->w_cursor; // save curwin->w_cursor |
fd69edd2c67e
patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents:
14700
diff
changeset
|
3585 |
fd69edd2c67e
patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents:
14700
diff
changeset
|
3586 // When '/' or '?' follows another address, start from |
fd69edd2c67e
patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents:
14700
diff
changeset
|
3587 // there. |
6398 | 3588 if (lnum != MAXLNUM) |
3589 curwin->w_cursor.lnum = lnum; | |
14760
fd69edd2c67e
patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents:
14700
diff
changeset
|
3590 |
fd69edd2c67e
patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents:
14700
diff
changeset
|
3591 // Start a forward search at the end of the line (unless |
fd69edd2c67e
patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents:
14700
diff
changeset
|
3592 // before the first line). |
fd69edd2c67e
patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents:
14700
diff
changeset
|
3593 // Start a backward search at the start of the line. |
fd69edd2c67e
patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents:
14700
diff
changeset
|
3594 // This makes sure we never match in the current |
fd69edd2c67e
patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents:
14700
diff
changeset
|
3595 // line, and can match anywhere in the |
fd69edd2c67e
patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents:
14700
diff
changeset
|
3596 // next/previous line. |
13082
a80082fd1a1d
patch 8.0.1416: crash when searching for a sentence
Christian Brabandt <cb@256bit.org>
parents:
12824
diff
changeset
|
3597 if (c == '/' && curwin->w_cursor.lnum > 0) |
6398 | 3598 curwin->w_cursor.col = MAXCOL; |
3599 else | |
3600 curwin->w_cursor.col = 0; | |
3601 searchcmdlen = 0; | |
14760
fd69edd2c67e
patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents:
14700
diff
changeset
|
3602 flags = silent ? 0 : SEARCH_HIS | SEARCH_MSG; |
18358
34d5cd432cac
patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents:
18297
diff
changeset
|
3603 if (!do_search(NULL, c, cmd, 1L, flags, NULL)) |
6398 | 3604 { |
3605 curwin->w_cursor = pos; | |
3606 cmd = NULL; | |
3607 goto error; | |
3608 } | |
3609 lnum = curwin->w_cursor.lnum; | |
3610 curwin->w_cursor = pos; | |
3611 /* adjust command string pointer */ | |
3612 cmd += searchcmdlen; | |
3613 } | |
3614 break; | |
7 | 3615 |
3616 case '\\': /* "\?", "\/" or "\&", repeat search */ | |
6398 | 3617 ++cmd; |
3618 if (addr_type != ADDR_LINES) | |
3619 { | |
17650
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
3620 addr_error(addr_type); |
6581 | 3621 cmd = NULL; |
6398 | 3622 goto error; |
3623 } | |
3624 if (*cmd == '&') | |
3625 i = RE_SUBST; | |
3626 else if (*cmd == '?' || *cmd == '/') | |
3627 i = RE_SEARCH; | |
3628 else | |
3629 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
3630 emsg(_(e_backslash)); |
6398 | 3631 cmd = NULL; |
3632 goto error; | |
3633 } | |
3634 | |
3635 if (!skip) | |
3636 { | |
3637 /* | |
3638 * When search follows another address, start from | |
3639 * there. | |
3640 */ | |
3641 if (lnum != MAXLNUM) | |
3642 pos.lnum = lnum; | |
3643 else | |
3644 pos.lnum = curwin->w_cursor.lnum; | |
3645 | |
3646 /* | |
3647 * Start the search just like for the above | |
3648 * do_search(). | |
3649 */ | |
3650 if (*cmd != '?') | |
3651 pos.col = MAXCOL; | |
3652 else | |
3653 pos.col = 0; | |
7007 | 3654 pos.coladd = 0; |
15239
db5d2429bda3
patch 8.1.0629: "gn" selects the wrong text with a multi-line match
Bram Moolenaar <Bram@vim.org>
parents:
15227
diff
changeset
|
3655 if (searchit(curwin, curbuf, &pos, NULL, |
6398 | 3656 *cmd == '?' ? BACKWARD : FORWARD, |
18358
34d5cd432cac
patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents:
18297
diff
changeset
|
3657 (char_u *)"", 1L, SEARCH_MSG, i, NULL) != FAIL) |
6398 | 3658 lnum = pos.lnum; |
3659 else | |
3660 { | |
3661 cmd = NULL; | |
3662 goto error; | |
3663 } | |
3664 } | |
3665 ++cmd; | |
3666 break; | |
7 | 3667 |
3668 default: | |
6398 | 3669 if (VIM_ISDIGIT(*cmd)) /* absolute line number */ |
3670 lnum = getdigits(&cmd); | |
7 | 3671 } |
3672 | |
3673 for (;;) | |
3674 { | |
3675 cmd = skipwhite(cmd); | |
3676 if (*cmd != '-' && *cmd != '+' && !VIM_ISDIGIT(*cmd)) | |
3677 break; | |
3678 | |
3679 if (lnum == MAXLNUM) | |
6398 | 3680 { |
3681 switch (addr_type) | |
3682 { | |
3683 case ADDR_LINES: | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
3684 case ADDR_OTHER: |
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
3685 // "+1" is same as ".+1" |
6409 | 3686 lnum = curwin->w_cursor.lnum; |
6398 | 3687 break; |
3688 case ADDR_WINDOWS: | |
6409 | 3689 lnum = CURRENT_WIN_NR; |
6398 | 3690 break; |
3691 case ADDR_ARGUMENTS: | |
3692 lnum = curwin->w_arg_idx + 1; | |
3693 break; | |
3694 case ADDR_LOADED_BUFFERS: | |
6424 | 3695 case ADDR_BUFFERS: |
6398 | 3696 lnum = curbuf->b_fnum; |
3697 break; | |
3698 case ADDR_TABS: | |
6409 | 3699 lnum = CURRENT_TAB_NR; |
6398 | 3700 break; |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
3701 case ADDR_TABS_RELATIVE: |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
3702 lnum = 1; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
3703 break; |
16479
7dcf301d1432
patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents:
16475
diff
changeset
|
3704 case ADDR_QUICKFIX: |
7105
f4456e686406
commit https://github.com/vim/vim/commit/e906c502079770ae0e0071c74cefb802689ff193
Christian Brabandt <cb@256bit.org>
parents:
7092
diff
changeset
|
3705 #ifdef FEAT_QUICKFIX |
16515
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
3706 lnum = qf_get_cur_idx(eap); |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
3707 #endif |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
3708 break; |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
3709 case ADDR_QUICKFIX_VALID: |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
3710 #ifdef FEAT_QUICKFIX |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
3711 lnum = qf_get_cur_valid_idx(eap); |
16479
7dcf301d1432
patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents:
16475
diff
changeset
|
3712 #endif |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
3713 break; |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
3714 case ADDR_NONE: |
16515
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
3715 case ADDR_UNSIGNED: |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
3716 lnum = 0; |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
3717 break; |
6398 | 3718 } |
3719 } | |
3720 | |
7 | 3721 if (VIM_ISDIGIT(*cmd)) |
3722 i = '+'; /* "number" is same as "+number" */ | |
3723 else | |
3724 i = *cmd++; | |
3725 if (!VIM_ISDIGIT(*cmd)) /* '+' is '+1', but '+0' is not '+1' */ | |
3726 n = 1; | |
3727 else | |
3728 n = getdigits(&cmd); | |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
3729 |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
3730 if (addr_type == ADDR_TABS_RELATIVE) |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
3731 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
3732 emsg(_(e_invrange)); |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
3733 cmd = NULL; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
3734 goto error; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
3735 } |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
3736 else if (addr_type == ADDR_LOADED_BUFFERS |
6424 | 3737 || addr_type == ADDR_BUFFERS) |
6581 | 3738 lnum = compute_buffer_local_count( |
3739 addr_type, lnum, (i == '-') ? -1 * n : n); | |
7 | 3740 else |
10484
c7de1536780a
commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
10480
diff
changeset
|
3741 { |
c7de1536780a
commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
10480
diff
changeset
|
3742 #ifdef FEAT_FOLDING |
c7de1536780a
commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
10480
diff
changeset
|
3743 /* Relative line addressing, need to adjust for folded lines |
c7de1536780a
commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
10480
diff
changeset
|
3744 * now, but only do it after the first address. */ |
c7de1536780a
commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
10480
diff
changeset
|
3745 if (addr_type == ADDR_LINES && (i == '-' || i == '+') |
c7de1536780a
commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
10480
diff
changeset
|
3746 && address_count >= 2) |
c7de1536780a
commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
10480
diff
changeset
|
3747 (void)hasFolding(lnum, NULL, &lnum); |
c7de1536780a
commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
10480
diff
changeset
|
3748 #endif |
c7de1536780a
commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
10480
diff
changeset
|
3749 if (i == '-') |
c7de1536780a
commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
10480
diff
changeset
|
3750 lnum -= n; |
c7de1536780a
commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
10480
diff
changeset
|
3751 else |
c7de1536780a
commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
10480
diff
changeset
|
3752 lnum += n; |
c7de1536780a
commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
10480
diff
changeset
|
3753 } |
7 | 3754 } |
3755 } while (*cmd == '/' || *cmd == '?'); | |
3756 | |
3757 error: | |
3758 *ptr = cmd; | |
3759 return lnum; | |
3760 } | |
3761 | |
3762 /* | |
167 | 3763 * Get flags from an Ex command argument. |
3764 */ | |
3765 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3766 get_flags(exarg_T *eap) |
167 | 3767 { |
3768 while (vim_strchr((char_u *)"lp#", *eap->arg) != NULL) | |
3769 { | |
3770 if (*eap->arg == 'l') | |
3771 eap->flags |= EXFLAG_LIST; | |
3772 else if (*eap->arg == 'p') | |
3773 eap->flags |= EXFLAG_PRINT; | |
3774 else | |
3775 eap->flags |= EXFLAG_NR; | |
3776 eap->arg = skipwhite(eap->arg + 1); | |
3777 } | |
3778 } | |
3779 | |
3780 /* | |
7 | 3781 * Function called for command which is Not Implemented. NI! |
3782 */ | |
3783 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3784 ex_ni(exarg_T *eap) |
7 | 3785 { |
3786 if (!eap->skip) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
3787 eap->errmsg = N_("E319: Sorry, the command is not available in this version"); |
7 | 3788 } |
3789 | |
1315 | 3790 #ifdef HAVE_EX_SCRIPT_NI |
7 | 3791 /* |
3792 * Function called for script command which is Not Implemented. NI! | |
3793 * Skips over ":perl <<EOF" constructs. | |
3794 */ | |
3795 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3796 ex_script_ni(exarg_T *eap) |
7 | 3797 { |
3798 if (!eap->skip) | |
3799 ex_ni(eap); | |
3800 else | |
3801 vim_free(script_get(eap, eap->arg)); | |
3802 } | |
3803 #endif | |
3804 | |
3805 /* | |
3806 * Check range in Ex command for validity. | |
3807 * Return NULL when valid, error message when invalid. | |
3808 */ | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
3809 static char * |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3810 invalid_range(exarg_T *eap) |
7 | 3811 { |
6472 | 3812 buf_T *buf; |
16515
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
3813 |
7 | 3814 if ( eap->line1 < 0 |
3815 || eap->line2 < 0 | |
6472 | 3816 || eap->line1 > eap->line2) |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
3817 return _(e_invrange); |
6472 | 3818 |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
3819 if (eap->argt & EX_RANGE) |
6472 | 3820 { |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
3821 switch (eap->addr_type) |
6472 | 3822 { |
3823 case ADDR_LINES: | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
3824 if (eap->line2 > curbuf->b_ml.ml_line_count |
7 | 3825 #ifdef FEAT_DIFF |
6472 | 3826 + (eap->cmdidx == CMD_diffget) |
3827 #endif | |
3828 ) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
3829 return _(e_invrange); |
6472 | 3830 break; |
3831 case ADDR_ARGUMENTS: | |
6581 | 3832 /* add 1 if ARGCOUNT is 0 */ |
3833 if (eap->line2 > ARGCOUNT + (!ARGCOUNT)) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
3834 return _(e_invrange); |
6472 | 3835 break; |
3836 case ADDR_BUFFERS: | |
17823
7e6b7a4f13bc
patch 8.1.1908: every popup window consumes a buffer number
Bram Moolenaar <Bram@vim.org>
parents:
17817
diff
changeset
|
3837 // Only a boundary check, not whether the buffers actually |
7e6b7a4f13bc
patch 8.1.1908: every popup window consumes a buffer number
Bram Moolenaar <Bram@vim.org>
parents:
17817
diff
changeset
|
3838 // exist. |
7e6b7a4f13bc
patch 8.1.1908: every popup window consumes a buffer number
Bram Moolenaar <Bram@vim.org>
parents:
17817
diff
changeset
|
3839 if (eap->line1 < 1 || eap->line2 > get_highest_fnum()) |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
3840 return _(e_invrange); |
6472 | 3841 break; |
3842 case ADDR_LOADED_BUFFERS: | |
3843 buf = firstbuf; | |
3844 while (buf->b_ml.ml_mfp == NULL) | |
3845 { | |
3846 if (buf->b_next == NULL) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
3847 return _(e_invrange); |
6472 | 3848 buf = buf->b_next; |
3849 } | |
3850 if (eap->line1 < buf->b_fnum) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
3851 return _(e_invrange); |
6472 | 3852 buf = lastbuf; |
3853 while (buf->b_ml.ml_mfp == NULL) | |
3854 { | |
3855 if (buf->b_prev == NULL) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
3856 return _(e_invrange); |
6472 | 3857 buf = buf->b_prev; |
3858 } | |
3859 if (eap->line2 > buf->b_fnum) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
3860 return _(e_invrange); |
6472 | 3861 break; |
3862 case ADDR_WINDOWS: | |
6480 | 3863 if (eap->line2 > LAST_WIN_NR) |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
3864 return _(e_invrange); |
6472 | 3865 break; |
3866 case ADDR_TABS: | |
3867 if (eap->line2 > LAST_TAB_NR) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
3868 return _(e_invrange); |
6472 | 3869 break; |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
3870 case ADDR_TABS_RELATIVE: |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
3871 case ADDR_OTHER: |
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
3872 // Any range is OK. |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
3873 break; |
16479
7dcf301d1432
patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents:
16475
diff
changeset
|
3874 case ADDR_QUICKFIX: |
7105
f4456e686406
commit https://github.com/vim/vim/commit/e906c502079770ae0e0071c74cefb802689ff193
Christian Brabandt <cb@256bit.org>
parents:
7092
diff
changeset
|
3875 #ifdef FEAT_QUICKFIX |
16515
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
3876 // No error for value that is too big, will use the last entry. |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
3877 if (eap->line2 <= 0) |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
3878 return _(e_invrange); |
16479
7dcf301d1432
patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents:
16475
diff
changeset
|
3879 #endif |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
3880 break; |
16515
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
3881 case ADDR_QUICKFIX_VALID: |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
3882 #ifdef FEAT_QUICKFIX |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
3883 if ((eap->line2 != 1 && eap->line2 > qf_get_valid_size(eap)) |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
3884 || eap->line2 < 0) |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
3885 return _(e_invrange); |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
3886 #endif |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
3887 break; |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
3888 case ADDR_UNSIGNED: |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
3889 if (eap->line2 < 0) |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
3890 return _(e_invrange); |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
3891 break; |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
3892 case ADDR_NONE: |
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
3893 // Will give an error elsewhere. |
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
3894 break; |
6472 | 3895 } |
3896 } | |
7 | 3897 return NULL; |
3898 } | |
3899 | |
3900 /* | |
3901 * Correct the range for zero line number, if required. | |
3902 */ | |
3903 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3904 correct_range(exarg_T *eap) |
7 | 3905 { |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
3906 if (!(eap->argt & EX_ZEROR)) // zero in range not allowed |
7 | 3907 { |
3908 if (eap->line1 == 0) | |
3909 eap->line1 = 1; | |
3910 if (eap->line2 == 0) | |
3911 eap->line2 = 1; | |
3912 } | |
3913 } | |
3914 | |
153 | 3915 #ifdef FEAT_QUICKFIX |
3916 /* | |
3917 * For a ":vimgrep" or ":vimgrepadd" command return a pointer past the | |
3918 * pattern. Otherwise return eap->arg. | |
3919 */ | |
3920 static char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3921 skip_grep_pat(exarg_T *eap) |
153 | 3922 { |
3923 char_u *p = eap->arg; | |
3924 | |
655 | 3925 if (*p != NUL && (eap->cmdidx == CMD_vimgrep || eap->cmdidx == CMD_lvimgrep |
3926 || eap->cmdidx == CMD_vimgrepadd | |
3927 || eap->cmdidx == CMD_lvimgrepadd | |
3928 || grep_internal(eap->cmdidx))) | |
153 | 3929 { |
170 | 3930 p = skip_vimgrep_pat(p, NULL, NULL); |
153 | 3931 if (p == NULL) |
3932 p = eap->arg; | |
3933 } | |
3934 return p; | |
3935 } | |
344 | 3936 |
3937 /* | |
3938 * For the ":make" and ":grep" commands insert the 'makeprg'/'grepprg' option | |
3939 * in the command line, so that things like % get expanded. | |
3940 */ | |
3941 static char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3942 replace_makeprg(exarg_T *eap, char_u *p, char_u **cmdlinep) |
344 | 3943 { |
3944 char_u *new_cmdline; | |
3945 char_u *program; | |
3946 char_u *pos; | |
3947 char_u *ptr; | |
3948 int len; | |
3949 int i; | |
3950 | |
3951 /* | |
3952 * Don't do it when ":vimgrep" is used for ":grep". | |
3953 */ | |
655 | 3954 if ((eap->cmdidx == CMD_make || eap->cmdidx == CMD_lmake |
3955 || eap->cmdidx == CMD_grep || eap->cmdidx == CMD_lgrep | |
3956 || eap->cmdidx == CMD_grepadd | |
3957 || eap->cmdidx == CMD_lgrepadd) | |
344 | 3958 && !grep_internal(eap->cmdidx)) |
3959 { | |
655 | 3960 if (eap->cmdidx == CMD_grep || eap->cmdidx == CMD_lgrep |
3961 || eap->cmdidx == CMD_grepadd || eap->cmdidx == CMD_lgrepadd) | |
344 | 3962 { |
3963 if (*curbuf->b_p_gp == NUL) | |
3964 program = p_gp; | |
3965 else | |
3966 program = curbuf->b_p_gp; | |
3967 } | |
3968 else | |
3969 { | |
3970 if (*curbuf->b_p_mp == NUL) | |
3971 program = p_mp; | |
3972 else | |
3973 program = curbuf->b_p_mp; | |
3974 } | |
3975 | |
3976 p = skipwhite(p); | |
3977 | |
3978 if ((pos = (char_u *)strstr((char *)program, "$*")) != NULL) | |
3979 { | |
3980 /* replace $* by given arguments */ | |
3981 i = 1; | |
3982 while ((pos = (char_u *)strstr((char *)pos + 2, "$*")) != NULL) | |
3983 ++i; | |
3984 len = (int)STRLEN(p); | |
16782
fc58fee685e2
patch 8.1.1393: unnecessary type casts
Bram Moolenaar <Bram@vim.org>
parents:
16780
diff
changeset
|
3985 new_cmdline = alloc(STRLEN(program) + i * (len - 2) + 1); |
344 | 3986 if (new_cmdline == NULL) |
3987 return NULL; /* out of memory */ | |
3988 ptr = new_cmdline; | |
3989 while ((pos = (char_u *)strstr((char *)program, "$*")) != NULL) | |
3990 { | |
3991 i = (int)(pos - program); | |
3992 STRNCPY(ptr, program, i); | |
3993 STRCPY(ptr += i, p); | |
3994 ptr += len; | |
3995 program = pos + 2; | |
3996 } | |
3997 STRCPY(ptr, program); | |
3998 } | |
3999 else | |
4000 { | |
16782
fc58fee685e2
patch 8.1.1393: unnecessary type casts
Bram Moolenaar <Bram@vim.org>
parents:
16780
diff
changeset
|
4001 new_cmdline = alloc(STRLEN(program) + STRLEN(p) + 2); |
344 | 4002 if (new_cmdline == NULL) |
4003 return NULL; /* out of memory */ | |
4004 STRCPY(new_cmdline, program); | |
4005 STRCAT(new_cmdline, " "); | |
4006 STRCAT(new_cmdline, p); | |
4007 } | |
4008 msg_make(p); | |
4009 | |
4010 /* 'eap->cmd' is not set here, because it is not used at CMD_make */ | |
4011 vim_free(*cmdlinep); | |
4012 *cmdlinep = new_cmdline; | |
4013 p = new_cmdline; | |
4014 } | |
4015 return p; | |
4016 } | |
153 | 4017 #endif |
4018 | |
7 | 4019 /* |
4020 * Expand file name in Ex command argument. | |
17081
81b791a843bc
patch 8.1.1540: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
16874
diff
changeset
|
4021 * When an error is detected, "errormsgp" is set to a non-NULL pointer. |
7 | 4022 * Return FAIL for failure, OK otherwise. |
4023 */ | |
4024 int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4025 expand_filename( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4026 exarg_T *eap, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4027 char_u **cmdlinep, |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
4028 char **errormsgp) |
7 | 4029 { |
4030 int has_wildcards; /* need to expand wildcards */ | |
4031 char_u *repl; | |
4032 int srclen; | |
4033 char_u *p; | |
4034 int n; | |
1098 | 4035 int escaped; |
7 | 4036 |
153 | 4037 #ifdef FEAT_QUICKFIX |
4038 /* Skip a regexp pattern for ":vimgrep[add] pat file..." */ | |
4039 p = skip_grep_pat(eap); | |
4040 #else | |
4041 p = eap->arg; | |
4042 #endif | |
4043 | |
7 | 4044 /* |
4045 * Decide to expand wildcards *before* replacing '%', '#', etc. If | |
4046 * the file name contains a wildcard it should not cause expanding. | |
4047 * (it will be expanded anyway if there is a wildcard before replacing). | |
4048 */ | |
153 | 4049 has_wildcards = mch_has_wildcard(p); |
4050 while (*p != NUL) | |
7 | 4051 { |
9 | 4052 #ifdef FEAT_EVAL |
4053 /* Skip over `=expr`, wildcards in it are not expanded. */ | |
4054 if (p[0] == '`' && p[1] == '=') | |
4055 { | |
4056 p += 2; | |
4057 (void)skip_expr(&p); | |
4058 if (*p == '`') | |
4059 ++p; | |
4060 continue; | |
4061 } | |
4062 #endif | |
7 | 4063 /* |
4064 * Quick check if this cannot be the start of a special string. | |
4065 * Also removes backslash before '%', '#' and '<'. | |
4066 */ | |
4067 if (vim_strchr((char_u *)"%#<", *p) == NULL) | |
4068 { | |
4069 ++p; | |
4070 continue; | |
4071 } | |
4072 | |
4073 /* | |
4074 * Try to find a match at this position. | |
4075 */ | |
1098 | 4076 repl = eval_vars(p, eap->arg, &srclen, &(eap->do_ecmd_lnum), |
4077 errormsgp, &escaped); | |
7 | 4078 if (*errormsgp != NULL) /* error detected */ |
4079 return FAIL; | |
4080 if (repl == NULL) /* no match found */ | |
4081 { | |
4082 p += srclen; | |
4083 continue; | |
4084 } | |
4085 | |
37 | 4086 /* Wildcards won't be expanded below, the replacement is taken |
4087 * literally. But do expand "~/file", "~user/file" and "$HOME/file". */ | |
4088 if (vim_strchr(repl, '$') != NULL || vim_strchr(repl, '~') != NULL) | |
4089 { | |
4090 char_u *l = repl; | |
4091 | |
4092 repl = expand_env_save(repl); | |
4093 vim_free(l); | |
4094 } | |
4095 | |
1098 | 4096 /* Need to escape white space et al. with a backslash. |
4097 * Don't do this for: | |
4098 * - replacement that already has been escaped: "##" | |
4099 * - shell commands (may have to use quotes instead). | |
4100 * - non-unix systems when there is a single argument (spaces don't | |
4101 * separate arguments then). | |
4102 */ | |
7 | 4103 if (!eap->usefilter |
1098 | 4104 && !escaped |
7 | 4105 && eap->cmdidx != CMD_bang |
4106 && eap->cmdidx != CMD_grep | |
11806
1c1cb1e9b7b3
patch 8.0.0785: wildcards are not expanded for :terminal
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
4107 && eap->cmdidx != CMD_grepadd |
1c1cb1e9b7b3
patch 8.0.0785: wildcards are not expanded for :terminal
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
4108 && eap->cmdidx != CMD_hardcopy |
655 | 4109 && eap->cmdidx != CMD_lgrep |
4110 && eap->cmdidx != CMD_lgrepadd | |
11806
1c1cb1e9b7b3
patch 8.0.0785: wildcards are not expanded for :terminal
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
4111 && eap->cmdidx != CMD_lmake |
1c1cb1e9b7b3
patch 8.0.0785: wildcards are not expanded for :terminal
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
4112 && eap->cmdidx != CMD_make |
1c1cb1e9b7b3
patch 8.0.0785: wildcards are not expanded for :terminal
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
4113 && eap->cmdidx != CMD_terminal |
7 | 4114 #ifndef UNIX |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
4115 && !(eap->argt & EX_NOSPC) |
7 | 4116 #endif |
4117 ) | |
4118 { | |
4119 char_u *l; | |
4120 #ifdef BACKSLASH_IN_FILENAME | |
4121 /* Don't escape a backslash here, because rem_backslash() doesn't | |
4122 * remove it later. */ | |
4123 static char_u *nobslash = (char_u *)" \t\"|"; | |
4124 # define ESCAPE_CHARS nobslash | |
4125 #else | |
4126 # define ESCAPE_CHARS escape_chars | |
4127 #endif | |
4128 | |
4129 for (l = repl; *l; ++l) | |
4130 if (vim_strchr(ESCAPE_CHARS, *l) != NULL) | |
4131 { | |
4132 l = vim_strsave_escaped(repl, ESCAPE_CHARS); | |
4133 if (l != NULL) | |
4134 { | |
4135 vim_free(repl); | |
4136 repl = l; | |
4137 } | |
4138 break; | |
4139 } | |
4140 } | |
4141 | |
4142 /* For a shell command a '!' must be escaped. */ | |
11806
1c1cb1e9b7b3
patch 8.0.0785: wildcards are not expanded for :terminal
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
4143 if ((eap->usefilter || eap->cmdidx == CMD_bang |
1c1cb1e9b7b3
patch 8.0.0785: wildcards are not expanded for :terminal
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
4144 || eap->cmdidx == CMD_terminal) |
5778 | 4145 && vim_strpbrk(repl, (char_u *)"!") != NULL) |
7 | 4146 { |
4147 char_u *l; | |
4148 | |
5778 | 4149 l = vim_strsave_escaped(repl, (char_u *)"!"); |
7 | 4150 if (l != NULL) |
4151 { | |
4152 vim_free(repl); | |
4153 repl = l; | |
4154 } | |
4155 } | |
4156 | |
4157 p = repl_cmdline(eap, p, srclen, repl, cmdlinep); | |
4158 vim_free(repl); | |
4159 if (p == NULL) | |
4160 return FAIL; | |
4161 } | |
4162 | |
4163 /* | |
4164 * One file argument: Expand wildcards. | |
4165 * Don't do this with ":r !command" or ":w !command". | |
4166 */ | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
4167 if ((eap->argt & EX_NOSPC) && !eap->usefilter) |
7 | 4168 { |
4169 /* | |
4170 * May do this twice: | |
4171 * 1. Replace environment variables. | |
4172 * 2. Replace any other wildcards, remove backslashes. | |
4173 */ | |
4174 for (n = 1; n <= 2; ++n) | |
4175 { | |
4176 if (n == 2) | |
4177 { | |
4178 /* | |
4179 * Halve the number of backslashes (this is Vi compatible). | |
4180 * For Unix and OS/2, when wildcards are expanded, this is | |
4181 * done by ExpandOne() below. | |
4182 */ | |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7262
diff
changeset
|
4183 #if defined(UNIX) |
7 | 4184 if (!has_wildcards) |
4185 #endif | |
4186 backslash_halve(eap->arg); | |
4187 } | |
4188 | |
4189 if (has_wildcards) | |
4190 { | |
4191 if (n == 1) | |
4192 { | |
4193 /* | |
4194 * First loop: May expand environment variables. This | |
4195 * can be done much faster with expand_env() than with | |
4196 * something else (e.g., calling a shell). | |
4197 * After expanding environment variables, check again | |
4198 * if there are still wildcards present. | |
4199 */ | |
4200 if (vim_strchr(eap->arg, '$') != NULL | |
4201 || vim_strchr(eap->arg, '~') != NULL) | |
4202 { | |
372 | 4203 expand_env_esc(eap->arg, NameBuff, MAXPATHL, |
1408 | 4204 TRUE, TRUE, NULL); |
7 | 4205 has_wildcards = mch_has_wildcard(NameBuff); |
4206 p = NameBuff; | |
4207 } | |
4208 else | |
4209 p = NULL; | |
4210 } | |
4211 else /* n == 2 */ | |
4212 { | |
4213 expand_T xpc; | |
18386
105c6cf8b266
patch 8.1.2187: error for bad regexp even though regexp is not used
Bram Moolenaar <Bram@vim.org>
parents:
18358
diff
changeset
|
4214 int options = WILD_LIST_NOTFOUND |
105c6cf8b266
patch 8.1.2187: error for bad regexp even though regexp is not used
Bram Moolenaar <Bram@vim.org>
parents:
18358
diff
changeset
|
4215 | WILD_NOERROR | WILD_ADD_SLASH; |
7 | 4216 |
4217 ExpandInit(&xpc); | |
4218 xpc.xp_context = EXPAND_FILES; | |
2652 | 4219 if (p_wic) |
4220 options += WILD_ICASE; | |
7 | 4221 p = ExpandOne(&xpc, eap->arg, NULL, |
2652 | 4222 options, WILD_EXPAND_FREE); |
7 | 4223 if (p == NULL) |
4224 return FAIL; | |
4225 } | |
4226 if (p != NULL) | |
4227 { | |
4228 (void)repl_cmdline(eap, eap->arg, (int)STRLEN(eap->arg), | |
4229 p, cmdlinep); | |
4230 if (n == 2) /* p came from ExpandOne() */ | |
4231 vim_free(p); | |
4232 } | |
4233 } | |
4234 } | |
4235 } | |
4236 return OK; | |
4237 } | |
4238 | |
4239 /* | |
4240 * Replace part of the command line, keeping eap->cmd, eap->arg and | |
4241 * eap->nextcmd correct. | |
4242 * "src" points to the part that is to be replaced, of length "srclen". | |
4243 * "repl" is the replacement string. | |
4244 * Returns a pointer to the character after the replaced string. | |
4245 * Returns NULL for failure. | |
4246 */ | |
4247 static char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4248 repl_cmdline( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4249 exarg_T *eap, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4250 char_u *src, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4251 int srclen, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4252 char_u *repl, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4253 char_u **cmdlinep) |
7 | 4254 { |
4255 int len; | |
4256 int i; | |
4257 char_u *new_cmdline; | |
4258 | |
4259 /* | |
4260 * The new command line is build in new_cmdline[]. | |
4261 * First allocate it. | |
4262 * Careful: a "+cmd" argument may have been NUL terminated. | |
4263 */ | |
4264 len = (int)STRLEN(repl); | |
4265 i = (int)(src - *cmdlinep) + (int)STRLEN(src + srclen) + len + 3; | |
698 | 4266 if (eap->nextcmd != NULL) |
7 | 4267 i += (int)STRLEN(eap->nextcmd);/* add space for next command */ |
16764
ef00b6bc186b
patch 8.1.1384: using "int" for alloc() often results in compiler warnings
Bram Moolenaar <Bram@vim.org>
parents:
16738
diff
changeset
|
4268 if ((new_cmdline = alloc(i)) == NULL) |
7 | 4269 return NULL; /* out of memory! */ |
4270 | |
4271 /* | |
4272 * Copy the stuff before the expanded part. | |
4273 * Copy the expanded stuff. | |
4274 * Copy what came after the expanded part. | |
4275 * Copy the next commands, if there are any. | |
4276 */ | |
4277 i = (int)(src - *cmdlinep); /* length of part before match */ | |
4278 mch_memmove(new_cmdline, *cmdlinep, (size_t)i); | |
434 | 4279 |
7 | 4280 mch_memmove(new_cmdline + i, repl, (size_t)len); |
4281 i += len; /* remember the end of the string */ | |
4282 STRCPY(new_cmdline + i, src + srclen); | |
4283 src = new_cmdline + i; /* remember where to continue */ | |
4284 | |
698 | 4285 if (eap->nextcmd != NULL) /* append next command */ |
7 | 4286 { |
4287 i = (int)STRLEN(new_cmdline) + 1; | |
4288 STRCPY(new_cmdline + i, eap->nextcmd); | |
4289 eap->nextcmd = new_cmdline + i; | |
4290 } | |
4291 eap->cmd = new_cmdline + (eap->cmd - *cmdlinep); | |
4292 eap->arg = new_cmdline + (eap->arg - *cmdlinep); | |
4293 if (eap->do_ecmd_cmd != NULL && eap->do_ecmd_cmd != dollar_command) | |
4294 eap->do_ecmd_cmd = new_cmdline + (eap->do_ecmd_cmd - *cmdlinep); | |
4295 vim_free(*cmdlinep); | |
4296 *cmdlinep = new_cmdline; | |
4297 | |
4298 return src; | |
4299 } | |
4300 | |
4301 /* | |
4302 * Check for '|' to separate commands and '"' to start comments. | |
4303 */ | |
4304 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4305 separate_nextcmd(exarg_T *eap) |
7 | 4306 { |
4307 char_u *p; | |
4308 | |
153 | 4309 #ifdef FEAT_QUICKFIX |
4310 p = skip_grep_pat(eap); | |
4311 #else | |
41 | 4312 p = eap->arg; |
4313 #endif | |
4314 | |
11127
506f5d8b7d8b
patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11010
diff
changeset
|
4315 for ( ; *p; MB_PTR_ADV(p)) |
7 | 4316 { |
4317 if (*p == Ctrl_V) | |
4318 { | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
4319 if (eap->argt & (EX_CTRLV | EX_XFILE)) |
7 | 4320 ++p; /* skip CTRL-V and next char */ |
4321 else | |
1362 | 4322 /* remove CTRL-V and skip next char */ |
1619 | 4323 STRMOVE(p, p + 1); |
7 | 4324 if (*p == NUL) /* stop at NUL after CTRL-V */ |
4325 break; | |
4326 } | |
9 | 4327 |
4328 #ifdef FEAT_EVAL | |
4329 /* Skip over `=expr` when wildcards are expanded. */ | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
4330 else if (p[0] == '`' && p[1] == '=' && (eap->argt & EX_XFILE)) |
9 | 4331 { |
4332 p += 2; | |
4333 (void)skip_expr(&p); | |
4334 } | |
4335 #endif | |
4336 | |
7 | 4337 /* Check for '"': start of comment or '|': next command */ |
4338 /* :@" and :*" do not start a comment! | |
4339 * :redir @" doesn't either. */ | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
4340 else if ((*p == '"' && !(eap->argt & EX_NOTRLCOM) |
7 | 4341 && ((eap->cmdidx != CMD_at && eap->cmdidx != CMD_star) |
4342 || p != eap->arg) | |
4343 && (eap->cmdidx != CMD_redir | |
4344 || p != eap->arg + 1 || p[-1] != '@')) | |
4345 || *p == '|' || *p == '\n') | |
4346 { | |
4347 /* | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
4348 * We remove the '\' before the '|', unless EX_CTRLV is used |
7 | 4349 * AND 'b' is present in 'cpoptions'. |
4350 */ | |
4351 if ((vim_strchr(p_cpo, CPO_BAR) == NULL | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
4352 || !(eap->argt & EX_CTRLV)) && *(p - 1) == '\\') |
7 | 4353 { |
1619 | 4354 STRMOVE(p - 1, p); /* remove the '\' */ |
7 | 4355 --p; |
4356 } | |
4357 else | |
4358 { | |
4359 eap->nextcmd = check_nextcmd(p); | |
4360 *p = NUL; | |
4361 break; | |
4362 } | |
4363 } | |
41 | 4364 } |
4365 | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
4366 if (!(eap->argt & EX_NOTRLCOM)) /* remove trailing spaces */ |
7 | 4367 del_trailing_spaces(eap->arg); |
4368 } | |
4369 | |
4370 /* | |
4371 * get + command from ex argument | |
4372 */ | |
4373 static char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4374 getargcmd(char_u **argp) |
7 | 4375 { |
4376 char_u *arg = *argp; | |
4377 char_u *command = NULL; | |
4378 | |
4379 if (*arg == '+') /* +[command] */ | |
4380 { | |
4381 ++arg; | |
5790 | 4382 if (vim_isspace(*arg) || *arg == NUL) |
7 | 4383 command = dollar_command; |
4384 else | |
4385 { | |
4386 command = arg; | |
4387 arg = skip_cmd_arg(command, TRUE); | |
4388 if (*arg != NUL) | |
4389 *arg++ = NUL; /* terminate command with NUL */ | |
4390 } | |
4391 | |
4392 arg = skipwhite(arg); /* skip over spaces */ | |
4393 *argp = arg; | |
4394 } | |
4395 return command; | |
4396 } | |
4397 | |
4398 /* | |
4399 * Find end of "+command" argument. Skip over "\ " and "\\". | |
4400 */ | |
17835
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17823
diff
changeset
|
4401 char_u * |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4402 skip_cmd_arg( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4403 char_u *p, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4404 int rembs) /* TRUE to halve the number of backslashes */ |
7 | 4405 { |
4406 while (*p && !vim_isspace(*p)) | |
4407 { | |
4408 if (*p == '\\' && p[1] != NUL) | |
4409 { | |
4410 if (rembs) | |
1619 | 4411 STRMOVE(p, p + 1); |
7 | 4412 else |
4413 ++p; | |
4414 } | |
11127
506f5d8b7d8b
patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11010
diff
changeset
|
4415 MB_PTR_ADV(p); |
7 | 4416 } |
4417 return p; | |
4418 } | |
4419 | |
13575
4df23d9bad47
patch 8.0.1660: the terminal API "drop" command doesn't support options
Christian Brabandt <cb@256bit.org>
parents:
13553
diff
changeset
|
4420 int |
4df23d9bad47
patch 8.0.1660: the terminal API "drop" command doesn't support options
Christian Brabandt <cb@256bit.org>
parents:
13553
diff
changeset
|
4421 get_bad_opt(char_u *p, exarg_T *eap) |
4df23d9bad47
patch 8.0.1660: the terminal API "drop" command doesn't support options
Christian Brabandt <cb@256bit.org>
parents:
13553
diff
changeset
|
4422 { |
4df23d9bad47
patch 8.0.1660: the terminal API "drop" command doesn't support options
Christian Brabandt <cb@256bit.org>
parents:
13553
diff
changeset
|
4423 if (STRICMP(p, "keep") == 0) |
4df23d9bad47
patch 8.0.1660: the terminal API "drop" command doesn't support options
Christian Brabandt <cb@256bit.org>
parents:
13553
diff
changeset
|
4424 eap->bad_char = BAD_KEEP; |
4df23d9bad47
patch 8.0.1660: the terminal API "drop" command doesn't support options
Christian Brabandt <cb@256bit.org>
parents:
13553
diff
changeset
|
4425 else if (STRICMP(p, "drop") == 0) |
4df23d9bad47
patch 8.0.1660: the terminal API "drop" command doesn't support options
Christian Brabandt <cb@256bit.org>
parents:
13553
diff
changeset
|
4426 eap->bad_char = BAD_DROP; |
4df23d9bad47
patch 8.0.1660: the terminal API "drop" command doesn't support options
Christian Brabandt <cb@256bit.org>
parents:
13553
diff
changeset
|
4427 else if (MB_BYTE2LEN(*p) == 1 && p[1] == NUL) |
4df23d9bad47
patch 8.0.1660: the terminal API "drop" command doesn't support options
Christian Brabandt <cb@256bit.org>
parents:
13553
diff
changeset
|
4428 eap->bad_char = *p; |
14051
c1ead25ed819
patch 8.1.0043: ++bad argument of :edit does not work properly
Christian Brabandt <cb@256bit.org>
parents:
14035
diff
changeset
|
4429 else |
c1ead25ed819
patch 8.1.0043: ++bad argument of :edit does not work properly
Christian Brabandt <cb@256bit.org>
parents:
14035
diff
changeset
|
4430 return FAIL; |
c1ead25ed819
patch 8.1.0043: ++bad argument of :edit does not work properly
Christian Brabandt <cb@256bit.org>
parents:
14035
diff
changeset
|
4431 return OK; |
13575
4df23d9bad47
patch 8.0.1660: the terminal API "drop" command doesn't support options
Christian Brabandt <cb@256bit.org>
parents:
13553
diff
changeset
|
4432 } |
4df23d9bad47
patch 8.0.1660: the terminal API "drop" command doesn't support options
Christian Brabandt <cb@256bit.org>
parents:
13553
diff
changeset
|
4433 |
7 | 4434 /* |
4435 * Get "++opt=arg" argument. | |
4436 * Return FAIL or OK. | |
4437 */ | |
4438 static int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4439 getargopt(exarg_T *eap) |
7 | 4440 { |
4441 char_u *arg = eap->arg + 2; | |
4442 int *pp = NULL; | |
2168 | 4443 int bad_char_idx; |
7 | 4444 char_u *p; |
4445 | |
4446 /* ":edit ++[no]bin[ary] file" */ | |
4447 if (STRNCMP(arg, "bin", 3) == 0 || STRNCMP(arg, "nobin", 5) == 0) | |
4448 { | |
4449 if (*arg == 'n') | |
4450 { | |
4451 arg += 2; | |
4452 eap->force_bin = FORCE_NOBIN; | |
4453 } | |
4454 else | |
4455 eap->force_bin = FORCE_BIN; | |
4456 if (!checkforcmd(&arg, "binary", 3)) | |
4457 return FAIL; | |
4458 eap->arg = skipwhite(arg); | |
4459 return OK; | |
4460 } | |
4461 | |
819 | 4462 /* ":read ++edit file" */ |
4463 if (STRNCMP(arg, "edit", 4) == 0) | |
4464 { | |
4465 eap->read_edit = TRUE; | |
4466 eap->arg = skipwhite(arg + 4); | |
4467 return OK; | |
4468 } | |
4469 | |
7 | 4470 if (STRNCMP(arg, "ff", 2) == 0) |
4471 { | |
4472 arg += 2; | |
4473 pp = &eap->force_ff; | |
4474 } | |
4475 else if (STRNCMP(arg, "fileformat", 10) == 0) | |
4476 { | |
4477 arg += 10; | |
4478 pp = &eap->force_ff; | |
4479 } | |
4480 else if (STRNCMP(arg, "enc", 3) == 0) | |
4481 { | |
3208 | 4482 if (STRNCMP(arg, "encoding", 8) == 0) |
4483 arg += 8; | |
4484 else | |
4485 arg += 3; | |
7 | 4486 pp = &eap->force_enc; |
4487 } | |
595 | 4488 else if (STRNCMP(arg, "bad", 3) == 0) |
4489 { | |
4490 arg += 3; | |
2168 | 4491 pp = &bad_char_idx; |
595 | 4492 } |
7 | 4493 |
4494 if (pp == NULL || *arg != '=') | |
4495 return FAIL; | |
4496 | |
4497 ++arg; | |
4498 *pp = (int)(arg - eap->cmd); | |
4499 arg = skip_cmd_arg(arg, FALSE); | |
4500 eap->arg = skipwhite(arg); | |
4501 *arg = NUL; | |
4502 | |
4503 if (pp == &eap->force_ff) | |
4504 { | |
4505 if (check_ff_value(eap->cmd + eap->force_ff) == FAIL) | |
4506 return FAIL; | |
13575
4df23d9bad47
patch 8.0.1660: the terminal API "drop" command doesn't support options
Christian Brabandt <cb@256bit.org>
parents:
13553
diff
changeset
|
4507 eap->force_ff = eap->cmd[eap->force_ff]; |
7 | 4508 } |
595 | 4509 else if (pp == &eap->force_enc) |
7 | 4510 { |
4511 /* Make 'fileencoding' lower case. */ | |
4512 for (p = eap->cmd + eap->force_enc; *p != NUL; ++p) | |
4513 *p = TOLOWER_ASC(*p); | |
4514 } | |
595 | 4515 else |
4516 { | |
4517 /* Check ++bad= argument. Must be a single-byte character, "keep" or | |
4518 * "drop". */ | |
13575
4df23d9bad47
patch 8.0.1660: the terminal API "drop" command doesn't support options
Christian Brabandt <cb@256bit.org>
parents:
13553
diff
changeset
|
4519 if (get_bad_opt(eap->cmd + bad_char_idx, eap) == FAIL) |
595 | 4520 return FAIL; |
4521 } | |
7 | 4522 |
4523 return OK; | |
4524 } | |
4525 | |
4526 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4527 ex_autocmd(exarg_T *eap) |
7 | 4528 { |
4529 /* | |
14266
7346b2ea80d8
patch 8.1.0149: session is wrong with multiple tabs when :lcd was used
Christian Brabandt <cb@256bit.org>
parents:
14155
diff
changeset
|
4530 * Disallow autocommands from .exrc and .vimrc in current |
7 | 4531 * directory for security reasons. |
4532 */ | |
4533 if (secure) | |
4534 { | |
4535 secure = 2; | |
4536 eap->errmsg = e_curdir; | |
4537 } | |
4538 else if (eap->cmdidx == CMD_autocmd) | |
4539 do_autocmd(eap->arg, eap->forceit); | |
4540 else | |
4541 do_augroup(eap->arg, eap->forceit); | |
4542 } | |
4543 | |
4544 /* | |
4545 * ":doautocmd": Apply the automatic commands to the current buffer. | |
4546 */ | |
4547 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4548 ex_doautocmd(exarg_T *eap) |
7 | 4549 { |
3350 | 4550 char_u *arg = eap->arg; |
4551 int call_do_modelines = check_nomodeline(&arg); | |
9260
ac8180818504
commit https://github.com/vim/vim/commit/1610d052413e0ed664498853a47acc2d677a22d1
Christian Brabandt <cb@256bit.org>
parents:
9230
diff
changeset
|
4552 int did_aucmd; |
ac8180818504
commit https://github.com/vim/vim/commit/1610d052413e0ed664498853a47acc2d677a22d1
Christian Brabandt <cb@256bit.org>
parents:
9230
diff
changeset
|
4553 |
ac8180818504
commit https://github.com/vim/vim/commit/1610d052413e0ed664498853a47acc2d677a22d1
Christian Brabandt <cb@256bit.org>
parents:
9230
diff
changeset
|
4554 (void)do_doautocmd(arg, TRUE, &did_aucmd); |
ac8180818504
commit https://github.com/vim/vim/commit/1610d052413e0ed664498853a47acc2d677a22d1
Christian Brabandt <cb@256bit.org>
parents:
9230
diff
changeset
|
4555 /* Only when there is no <nomodeline>. */ |
ac8180818504
commit https://github.com/vim/vim/commit/1610d052413e0ed664498853a47acc2d677a22d1
Christian Brabandt <cb@256bit.org>
parents:
9230
diff
changeset
|
4556 if (call_do_modelines && did_aucmd) |
3350 | 4557 do_modelines(0); |
7 | 4558 } |
4559 | |
4560 /* | |
4561 * :[N]bunload[!] [N] [bufname] unload buffer | |
4562 * :[N]bdelete[!] [N] [bufname] delete buffer from buffer list | |
4563 * :[N]bwipeout[!] [N] [bufname] delete buffer really | |
4564 */ | |
4565 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4566 ex_bunload(exarg_T *eap) |
7 | 4567 { |
17111
af861fccc309
patch 8.1.1555: NOT_IN_POPUP_WINDOW is confusing
Bram Moolenaar <Bram@vim.org>
parents:
17095
diff
changeset
|
4568 if (ERROR_IF_POPUP_WINDOW) |
16874
da5f5836e90c
patch 8.1.1438: some commands cause trouble in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
4569 return; |
7 | 4570 eap->errmsg = do_bufdel( |
4571 eap->cmdidx == CMD_bdelete ? DOBUF_DEL | |
4572 : eap->cmdidx == CMD_bwipeout ? DOBUF_WIPE | |
4573 : DOBUF_UNLOAD, eap->arg, | |
4574 eap->addr_count, (int)eap->line1, (int)eap->line2, eap->forceit); | |
4575 } | |
4576 | |
4577 /* | |
4578 * :[N]buffer [N] to buffer N | |
4579 * :[N]sbuffer [N] to buffer N | |
4580 */ | |
4581 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4582 ex_buffer(exarg_T *eap) |
7 | 4583 { |
17111
af861fccc309
patch 8.1.1555: NOT_IN_POPUP_WINDOW is confusing
Bram Moolenaar <Bram@vim.org>
parents:
17095
diff
changeset
|
4584 if (ERROR_IF_POPUP_WINDOW) |
16874
da5f5836e90c
patch 8.1.1438: some commands cause trouble in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
4585 return; |
7 | 4586 if (*eap->arg) |
4587 eap->errmsg = e_trailing; | |
4588 else | |
4589 { | |
4590 if (eap->addr_count == 0) /* default is current buffer */ | |
4591 goto_buffer(eap, DOBUF_CURRENT, FORWARD, 0); | |
4592 else | |
4593 goto_buffer(eap, DOBUF_FIRST, FORWARD, (int)eap->line2); | |
6230 | 4594 if (eap->do_ecmd_cmd != NULL) |
4595 do_cmdline_cmd(eap->do_ecmd_cmd); | |
7 | 4596 } |
4597 } | |
4598 | |
4599 /* | |
4600 * :[N]bmodified [N] to next mod. buffer | |
4601 * :[N]sbmodified [N] to next mod. buffer | |
4602 */ | |
4603 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4604 ex_bmodified(exarg_T *eap) |
7 | 4605 { |
4606 goto_buffer(eap, DOBUF_MOD, FORWARD, (int)eap->line2); | |
6230 | 4607 if (eap->do_ecmd_cmd != NULL) |
4608 do_cmdline_cmd(eap->do_ecmd_cmd); | |
7 | 4609 } |
4610 | |
4611 /* | |
4612 * :[N]bnext [N] to next buffer | |
4613 * :[N]sbnext [N] split and to next buffer | |
4614 */ | |
4615 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4616 ex_bnext(exarg_T *eap) |
7 | 4617 { |
4618 goto_buffer(eap, DOBUF_CURRENT, FORWARD, (int)eap->line2); | |
6230 | 4619 if (eap->do_ecmd_cmd != NULL) |
4620 do_cmdline_cmd(eap->do_ecmd_cmd); | |
7 | 4621 } |
4622 | |
4623 /* | |
4624 * :[N]bNext [N] to previous buffer | |
4625 * :[N]bprevious [N] to previous buffer | |
4626 * :[N]sbNext [N] split and to previous buffer | |
4627 * :[N]sbprevious [N] split and to previous buffer | |
4628 */ | |
4629 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4630 ex_bprevious(exarg_T *eap) |
7 | 4631 { |
4632 goto_buffer(eap, DOBUF_CURRENT, BACKWARD, (int)eap->line2); | |
6230 | 4633 if (eap->do_ecmd_cmd != NULL) |
4634 do_cmdline_cmd(eap->do_ecmd_cmd); | |
7 | 4635 } |
4636 | |
4637 /* | |
4638 * :brewind to first buffer | |
4639 * :bfirst to first buffer | |
4640 * :sbrewind split and to first buffer | |
4641 * :sbfirst split and to first buffer | |
4642 */ | |
4643 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4644 ex_brewind(exarg_T *eap) |
7 | 4645 { |
4646 goto_buffer(eap, DOBUF_FIRST, FORWARD, 0); | |
6230 | 4647 if (eap->do_ecmd_cmd != NULL) |
4648 do_cmdline_cmd(eap->do_ecmd_cmd); | |
7 | 4649 } |
4650 | |
4651 /* | |
4652 * :blast to last buffer | |
4653 * :sblast split and to last buffer | |
4654 */ | |
4655 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4656 ex_blast(exarg_T *eap) |
7 | 4657 { |
4658 goto_buffer(eap, DOBUF_LAST, BACKWARD, 0); | |
6230 | 4659 if (eap->do_ecmd_cmd != NULL) |
4660 do_cmdline_cmd(eap->do_ecmd_cmd); | |
7 | 4661 } |
4662 | |
4663 int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4664 ends_excmd(int c) |
7 | 4665 { |
4666 return (c == NUL || c == '|' || c == '"' || c == '\n'); | |
4667 } | |
4668 | |
4669 #if defined(FEAT_SYN_HL) || defined(FEAT_SEARCH_EXTRA) || defined(FEAT_EVAL) \ | |
4670 || defined(PROTO) | |
4671 /* | |
4672 * Return the next command, after the first '|' or '\n'. | |
4673 * Return NULL if not found. | |
4674 */ | |
4675 char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4676 find_nextcmd(char_u *p) |
7 | 4677 { |
4678 while (*p != '|' && *p != '\n') | |
4679 { | |
4680 if (*p == NUL) | |
4681 return NULL; | |
4682 ++p; | |
4683 } | |
4684 return (p + 1); | |
4685 } | |
4686 #endif | |
4687 | |
4688 /* | |
10383
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
4689 * Check if *p is a separator between Ex commands, skipping over white space. |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
4690 * Return NULL if it isn't, the following character if it is. |
7 | 4691 */ |
4692 char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4693 check_nextcmd(char_u *p) |
7 | 4694 { |
10383
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
4695 char_u *s = skipwhite(p); |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
4696 |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
4697 if (*s == '|' || *s == '\n') |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
4698 return (s + 1); |
7 | 4699 else |
4700 return NULL; | |
4701 } | |
4702 | |
4703 /* | |
4704 * - if there are more files to edit | |
4705 * - and this is the last window | |
4706 * - and forceit not used | |
4707 * - and not repeated twice on a row | |
4708 * return FAIL and give error message if 'message' TRUE | |
4709 * return OK otherwise | |
4710 */ | |
4711 static int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4712 check_more( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4713 int message, /* when FALSE check only, no messages */ |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4714 int forceit) |
7 | 4715 { |
4716 int n = ARGCOUNT - curwin->w_arg_idx - 1; | |
4717 | |
672 | 4718 if (!forceit && only_one_window() |
4719 && ARGCOUNT > 1 && !arg_had_last && n >= 0 && quitmore == 0) | |
7 | 4720 { |
4721 if (message) | |
4722 { | |
4723 #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) | |
4724 if ((p_confirm || cmdmod.confirm) && curbuf->b_fname != NULL) | |
4725 { | |
2770 | 4726 char_u buff[DIALOG_MSG_SIZE]; |
7 | 4727 |
14585
c8f07e8b273e
patch 8.1.0306: plural messages are not translated properly
Christian Brabandt <cb@256bit.org>
parents:
14550
diff
changeset
|
4728 vim_snprintf((char *)buff, DIALOG_MSG_SIZE, |
c8f07e8b273e
patch 8.1.0306: plural messages are not translated properly
Christian Brabandt <cb@256bit.org>
parents:
14550
diff
changeset
|
4729 NGETTEXT("%d more file to edit. Quit anyway?", |
c8f07e8b273e
patch 8.1.0306: plural messages are not translated properly
Christian Brabandt <cb@256bit.org>
parents:
14550
diff
changeset
|
4730 "%d more files to edit. Quit anyway?", n), n); |
7 | 4731 if (vim_dialog_yesno(VIM_QUESTION, NULL, buff, 1) == VIM_YES) |
4732 return OK; | |
4733 return FAIL; | |
4734 } | |
4735 #endif | |
15490
98c35d312987
patch 8.1.0753: printf format not checked for semsg()
Bram Moolenaar <Bram@vim.org>
parents:
15488
diff
changeset
|
4736 semsg(NGETTEXT("E173: %d more file to edit", |
98c35d312987
patch 8.1.0753: printf format not checked for semsg()
Bram Moolenaar <Bram@vim.org>
parents:
15488
diff
changeset
|
4737 "E173: %d more files to edit", n), n); |
7 | 4738 quitmore = 2; /* next try to quit is allowed */ |
4739 } | |
4740 return FAIL; | |
4741 } | |
4742 return OK; | |
4743 } | |
4744 | |
4745 /* | |
4746 * Function given to ExpandGeneric() to obtain the list of command names. | |
4747 */ | |
4748 char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4749 get_command_name(expand_T *xp UNUSED, int idx) |
7 | 4750 { |
4751 if (idx >= (int)CMD_SIZE) | |
4752 return get_user_command_name(idx); | |
4753 return cmdnames[idx].cmd_name; | |
4754 } | |
4755 | |
4756 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4757 ex_colorscheme(exarg_T *eap) |
7 | 4758 { |
2142
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4759 if (*eap->arg == NUL) |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4760 { |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4761 #ifdef FEAT_EVAL |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4762 char_u *expr = vim_strsave((char_u *)"g:colors_name"); |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4763 char_u *p = NULL; |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4764 |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4765 if (expr != NULL) |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4766 { |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4767 ++emsg_off; |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4768 p = eval_to_string(expr, NULL, FALSE); |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4769 --emsg_off; |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4770 vim_free(expr); |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4771 } |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4772 if (p != NULL) |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4773 { |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15510
diff
changeset
|
4774 msg((char *)p); |
2142
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4775 vim_free(p); |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4776 } |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4777 else |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15510
diff
changeset
|
4778 msg("default"); |
2142
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4779 #else |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15510
diff
changeset
|
4780 msg(_("unknown")); |
2142
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4781 #endif |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4782 } |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4783 else if (load_colors(eap->arg) == FAIL) |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
4784 semsg(_("E185: Cannot find color scheme '%s'"), eap->arg); |
15663
61448894376e
patch 8.1.0839: when using VTP wrong colors after a color scheme change
Bram Moolenaar <Bram@vim.org>
parents:
15643
diff
changeset
|
4785 |
61448894376e
patch 8.1.0839: when using VTP wrong colors after a color scheme change
Bram Moolenaar <Bram@vim.org>
parents:
15643
diff
changeset
|
4786 #ifdef FEAT_VTP |
61448894376e
patch 8.1.0839: when using VTP wrong colors after a color scheme change
Bram Moolenaar <Bram@vim.org>
parents:
15643
diff
changeset
|
4787 else if (has_vtp_working()) |
61448894376e
patch 8.1.0839: when using VTP wrong colors after a color scheme change
Bram Moolenaar <Bram@vim.org>
parents:
15643
diff
changeset
|
4788 { |
61448894376e
patch 8.1.0839: when using VTP wrong colors after a color scheme change
Bram Moolenaar <Bram@vim.org>
parents:
15643
diff
changeset
|
4789 // background color change requires clear + redraw |
61448894376e
patch 8.1.0839: when using VTP wrong colors after a color scheme change
Bram Moolenaar <Bram@vim.org>
parents:
15643
diff
changeset
|
4790 update_screen(CLEAR); |
61448894376e
patch 8.1.0839: when using VTP wrong colors after a color scheme change
Bram Moolenaar <Bram@vim.org>
parents:
15643
diff
changeset
|
4791 redrawcmd(); |
61448894376e
patch 8.1.0839: when using VTP wrong colors after a color scheme change
Bram Moolenaar <Bram@vim.org>
parents:
15643
diff
changeset
|
4792 } |
61448894376e
patch 8.1.0839: when using VTP wrong colors after a color scheme change
Bram Moolenaar <Bram@vim.org>
parents:
15643
diff
changeset
|
4793 #endif |
7 | 4794 } |
4795 | |
4796 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4797 ex_highlight(exarg_T *eap) |
7 | 4798 { |
4799 if (*eap->arg == NUL && eap->cmd[2] == '!') | |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15510
diff
changeset
|
4800 msg(_("Greetings, Vim user!")); |
7 | 4801 do_highlight(eap->arg, eap->forceit, FALSE); |
4802 } | |
4803 | |
4804 | |
4805 /* | |
4806 * Call this function if we thought we were going to exit, but we won't | |
4807 * (because of an error). May need to restore the terminal mode. | |
4808 */ | |
4809 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4810 not_exiting(void) |
7 | 4811 { |
4812 exiting = FALSE; | |
4813 settmode(TMODE_RAW); | |
4814 } | |
4815 | |
13442
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
4816 static int |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
4817 before_quit_autocmds(win_T *wp, int quit_all, int forceit) |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
4818 { |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
4819 apply_autocmds(EVENT_QUITPRE, NULL, NULL, FALSE, wp->w_buffer); |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
4820 |
18406
fa6efc49d71f
patch 8.1.2197: ExitPre autocommand may cause accessing freed memory
Bram Moolenaar <Bram@vim.org>
parents:
18402
diff
changeset
|
4821 // Bail out when autocommands closed the window. |
fa6efc49d71f
patch 8.1.2197: ExitPre autocommand may cause accessing freed memory
Bram Moolenaar <Bram@vim.org>
parents:
18402
diff
changeset
|
4822 // Refuse to quit when the buffer in the last window is being closed (can |
fa6efc49d71f
patch 8.1.2197: ExitPre autocommand may cause accessing freed memory
Bram Moolenaar <Bram@vim.org>
parents:
18402
diff
changeset
|
4823 // only happen in autocommands). |
13442
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
4824 if (!win_valid(wp) |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
4825 || curbuf_locked() |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
4826 || (wp->w_buffer->b_nwindows == 1 && wp->w_buffer->b_locked > 0)) |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
4827 return TRUE; |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
4828 |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
4829 if (quit_all || (check_more(FALSE, forceit) == OK && only_one_window())) |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
4830 { |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
4831 apply_autocmds(EVENT_EXITPRE, NULL, NULL, FALSE, curbuf); |
18406
fa6efc49d71f
patch 8.1.2197: ExitPre autocommand may cause accessing freed memory
Bram Moolenaar <Bram@vim.org>
parents:
18402
diff
changeset
|
4832 // Refuse to quit when locked or when the window was closed or the |
fa6efc49d71f
patch 8.1.2197: ExitPre autocommand may cause accessing freed memory
Bram Moolenaar <Bram@vim.org>
parents:
18402
diff
changeset
|
4833 // buffer in the last window is being closed (can only happen in |
fa6efc49d71f
patch 8.1.2197: ExitPre autocommand may cause accessing freed memory
Bram Moolenaar <Bram@vim.org>
parents:
18402
diff
changeset
|
4834 // autocommands). |
fa6efc49d71f
patch 8.1.2197: ExitPre autocommand may cause accessing freed memory
Bram Moolenaar <Bram@vim.org>
parents:
18402
diff
changeset
|
4835 if (!win_valid(wp) || curbuf_locked() |
13442
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
4836 || (curbuf->b_nwindows == 1 && curbuf->b_locked > 0)) |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
4837 return TRUE; |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
4838 } |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
4839 |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
4840 return FALSE; |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
4841 } |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
4842 |
7 | 4843 /* |
6409 | 4844 * ":quit": quit current window, quit Vim if the last window is closed. |
13442
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
4845 * ":{nr}quit": quit window {nr} |
18402
527b7084c556
patch 8.1.2195: Vim does not exit when the terminal window is last window
Bram Moolenaar <Bram@vim.org>
parents:
18386
diff
changeset
|
4846 * Also used when closing a terminal window that's the last one. |
527b7084c556
patch 8.1.2195: Vim does not exit when the terminal window is last window
Bram Moolenaar <Bram@vim.org>
parents:
18386
diff
changeset
|
4847 */ |
527b7084c556
patch 8.1.2195: Vim does not exit when the terminal window is last window
Bram Moolenaar <Bram@vim.org>
parents:
18386
diff
changeset
|
4848 void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4849 ex_quit(exarg_T *eap) |
7 | 4850 { |
6398 | 4851 win_T *wp; |
4852 | |
7 | 4853 #ifdef FEAT_CMDWIN |
4854 if (cmdwin_type != 0) | |
4855 { | |
4856 cmdwin_result = Ctrl_C; | |
4857 return; | |
4858 } | |
4859 #endif | |
631 | 4860 /* Don't quit while editing the command line. */ |
633 | 4861 if (text_locked()) |
4862 { | |
4863 text_locked_msg(); | |
631 | 4864 return; |
4865 } | |
6398 | 4866 if (eap->addr_count > 0) |
4867 { | |
6409 | 4868 int wnr = eap->line2; |
4869 | |
4870 for (wp = firstwin; wp->w_next != NULL; wp = wp->w_next) | |
4871 if (--wnr <= 0) | |
6398 | 4872 break; |
4873 } | |
4874 else | |
4875 wp = curwin; | |
6409 | 4876 |
12652
272ecbaf1b4f
patch 8.0.1204: a QuitPre autocommand may get the wrong file name
Christian Brabandt <cb@256bit.org>
parents:
12624
diff
changeset
|
4877 /* Refuse to quit when locked. */ |
272ecbaf1b4f
patch 8.0.1204: a QuitPre autocommand may get the wrong file name
Christian Brabandt <cb@256bit.org>
parents:
12624
diff
changeset
|
4878 if (curbuf_locked()) |
272ecbaf1b4f
patch 8.0.1204: a QuitPre autocommand may get the wrong file name
Christian Brabandt <cb@256bit.org>
parents:
12624
diff
changeset
|
4879 return; |
13442
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
4880 |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
4881 /* Trigger QuitPre and maybe ExitPre */ |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
4882 if (before_quit_autocmds(wp, FALSE, eap->forceit)) |
819 | 4883 return; |
7 | 4884 |
4885 #ifdef FEAT_NETBEANS_INTG | |
4886 netbeansForcedQuit = eap->forceit; | |
4887 #endif | |
4888 | |
4889 /* | |
4890 * If there are more files or windows we won't exit. | |
4891 */ | |
4892 if (check_more(FALSE, eap->forceit) == OK && only_one_window()) | |
4893 exiting = TRUE; | |
12654
d03798bddf5e
patch 8.0.1205: it is possible to unload a changed buffer
Christian Brabandt <cb@256bit.org>
parents:
12652
diff
changeset
|
4894 if ((!buf_hide(wp->w_buffer) |
d03798bddf5e
patch 8.0.1205: it is possible to unload a changed buffer
Christian Brabandt <cb@256bit.org>
parents:
12652
diff
changeset
|
4895 && check_changed(wp->w_buffer, (p_awa ? CCGD_AW : 0) |
5464 | 4896 | (eap->forceit ? CCGD_FORCEIT : 0) |
4897 | CCGD_EXCMD)) | |
7 | 4898 || check_more(TRUE, eap->forceit) == FAIL |
7469
15eefe1b0dad
commit https://github.com/vim/vim/commit/027387f70c671f62e3e08e0bdd09ec05b0232735
Christian Brabandt <cb@256bit.org>
parents:
7465
diff
changeset
|
4899 || (only_one_window() && check_changed_any(eap->forceit, TRUE))) |
7 | 4900 { |
4901 not_exiting(); | |
4902 } | |
4903 else | |
4904 { | |
6838 | 4905 /* quit last window |
4906 * Note: only_one_window() returns true, even so a help window is | |
4907 * still open. In that case only quit, if no address has been | |
4908 * specified. Example: | |
4909 * :h|wincmd w|1q - don't quit | |
4910 * :h|wincmd w|q - quit | |
4911 */ | |
10349
cf988222b150
commit https://github.com/vim/vim/commit/a1f4cb93ba50ea9e40cd4b1f5592b8a6d1398660
Christian Brabandt <cb@256bit.org>
parents:
10275
diff
changeset
|
4912 if (only_one_window() && (ONE_WINDOW || eap->addr_count == 0)) |
7 | 4913 getout(0); |
12624
ae2802b6bf7d
patch 8.0.1190: unusable after opening new window in BufWritePre event
Christian Brabandt <cb@256bit.org>
parents:
12622
diff
changeset
|
4914 not_exiting(); |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
4915 #ifdef FEAT_GUI |
7 | 4916 need_mouse_correct = TRUE; |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
4917 #endif |
7 | 4918 /* close window; may free buffer */ |
11957
bc0fee081e1e
patch 8.0.0858: can exit while a terminal is still running a job
Christian Brabandt <cb@256bit.org>
parents:
11806
diff
changeset
|
4919 win_close(wp, !buf_hide(wp->w_buffer) || eap->forceit); |
7 | 4920 } |
4921 } | |
4922 | |
4923 /* | |
4924 * ":cquit". | |
4925 */ | |
4926 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4927 ex_cquit(exarg_T *eap UNUSED) |
7 | 4928 { |
4929 getout(1); /* this does not always pass on the exit code to the Manx | |
4930 compiler. why? */ | |
4931 } | |
4932 | |
4933 /* | |
4934 * ":qall": try to quit all windows | |
4935 */ | |
4936 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4937 ex_quit_all(exarg_T *eap) |
7 | 4938 { |
4939 # ifdef FEAT_CMDWIN | |
4940 if (cmdwin_type != 0) | |
4941 { | |
4942 if (eap->forceit) | |
4943 cmdwin_result = K_XF1; /* ex_window() takes care of this */ | |
4944 else | |
4945 cmdwin_result = K_XF2; | |
4946 return; | |
4947 } | |
4948 # endif | |
631 | 4949 |
4950 /* Don't quit while editing the command line. */ | |
633 | 4951 if (text_locked()) |
4952 { | |
4953 text_locked_msg(); | |
631 | 4954 return; |
4955 } | |
13442
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
4956 |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
4957 if (before_quit_autocmds(curwin, TRUE, eap->forceit)) |
819 | 4958 return; |
631 | 4959 |
7 | 4960 exiting = TRUE; |
7469
15eefe1b0dad
commit https://github.com/vim/vim/commit/027387f70c671f62e3e08e0bdd09ec05b0232735
Christian Brabandt <cb@256bit.org>
parents:
7465
diff
changeset
|
4961 if (eap->forceit || !check_changed_any(FALSE, FALSE)) |
7 | 4962 getout(0); |
4963 not_exiting(); | |
4964 } | |
4965 | |
4966 /* | |
4967 * ":close": close current window, unless it is the last one | |
4968 */ | |
4969 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4970 ex_close(exarg_T *eap) |
7 | 4971 { |
6398 | 4972 win_T *win; |
4973 int winnr = 0; | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
4974 #ifdef FEAT_CMDWIN |
7 | 4975 if (cmdwin_type != 0) |
2839 | 4976 cmdwin_result = Ctrl_C; |
7 | 4977 else |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
4978 #endif |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
4979 if (!text_locked() && !curbuf_locked()) |
6398 | 4980 { |
4981 if (eap->addr_count == 0) | |
4982 ex_win_close(eap->forceit, curwin, NULL); | |
14035
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13866
diff
changeset
|
4983 else |
bccd66fa00c1
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents:
13866
diff
changeset
|
4984 { |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9538
diff
changeset
|
4985 FOR_ALL_WINDOWS(win) |
6398 | 4986 { |
4987 winnr++; | |
4988 if (winnr == eap->line2) | |
4989 break; | |
4990 } | |
4991 if (win == NULL) | |
4992 win = lastwin; | |
4993 ex_win_close(eap->forceit, win, NULL); | |
4994 } | |
4995 } | |
667 | 4996 } |
4997 | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
4998 #ifdef FEAT_QUICKFIX |
667 | 4999 /* |
5000 * ":pclose": Close any preview window. | |
5001 */ | |
5002 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5003 ex_pclose(exarg_T *eap) |
667 | 5004 { |
5005 win_T *win; | |
5006 | |
17431
ce35cdbe9f74
patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
17336
diff
changeset
|
5007 // First close any normal window. |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9538
diff
changeset
|
5008 FOR_ALL_WINDOWS(win) |
667 | 5009 if (win->w_p_pvw) |
5010 { | |
671 | 5011 ex_win_close(eap->forceit, win, NULL); |
17431
ce35cdbe9f74
patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
17336
diff
changeset
|
5012 return; |
ce35cdbe9f74
patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
17336
diff
changeset
|
5013 } |
ce35cdbe9f74
patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
17336
diff
changeset
|
5014 # ifdef FEAT_TEXT_PROP |
ce35cdbe9f74
patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
17336
diff
changeset
|
5015 // Also when 'previewpopup' is empty, it might have been cleared. |
17817
e8a7029efa40
patch 8.1.1905: cannot set all properties of the info popup
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
5016 popup_close_preview(); |
17431
ce35cdbe9f74
patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
17336
diff
changeset
|
5017 # endif |
667 | 5018 } |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5019 #endif |
667 | 5020 |
671 | 5021 /* |
5022 * Close window "win" and take care of handling closing the last window for a | |
5023 * modified buffer. | |
5024 */ | |
5025 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5026 ex_win_close( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5027 int forceit, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5028 win_T *win, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5029 tabpage_T *tp) /* NULL or the tab page "win" is in */ |
7 | 5030 { |
5031 int need_hide; | |
5032 buf_T *buf = win->w_buffer; | |
5033 | |
5034 need_hide = (bufIsChanged(buf) && buf->b_nwindows <= 1); | |
11957
bc0fee081e1e
patch 8.0.0858: can exit while a terminal is still running a job
Christian Brabandt <cb@256bit.org>
parents:
11806
diff
changeset
|
5035 if (need_hide && !buf_hide(buf) && !forceit) |
7 | 5036 { |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5037 #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) |
7 | 5038 if ((p_confirm || cmdmod.confirm) && p_write) |
5039 { | |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9460
diff
changeset
|
5040 bufref_T bufref; |
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9460
diff
changeset
|
5041 |
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9460
diff
changeset
|
5042 set_bufref(&bufref, buf); |
7 | 5043 dialog_changed(buf, FALSE); |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9460
diff
changeset
|
5044 if (bufref_valid(&bufref) && bufIsChanged(buf)) |
7 | 5045 return; |
5046 need_hide = FALSE; | |
5047 } | |
5048 else | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5049 #endif |
7 | 5050 { |
12146
59c1e09cf1a9
patch 8.0.0953: get "no write since last change" error in terminal window
Christian Brabandt <cb@256bit.org>
parents:
11995
diff
changeset
|
5051 no_write_message(); |
7 | 5052 return; |
5053 } | |
5054 } | |
5055 | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5056 #ifdef FEAT_GUI |
7 | 5057 need_mouse_correct = TRUE; |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5058 #endif |
671 | 5059 |
7 | 5060 /* free buffer when not hiding it or when it's a scratch buffer */ |
671 | 5061 if (tp == NULL) |
11957
bc0fee081e1e
patch 8.0.0858: can exit while a terminal is still running a job
Christian Brabandt <cb@256bit.org>
parents:
11806
diff
changeset
|
5062 win_close(win, !need_hide && !buf_hide(buf)); |
671 | 5063 else |
11957
bc0fee081e1e
patch 8.0.0858: can exit while a terminal is still running a job
Christian Brabandt <cb@256bit.org>
parents:
11806
diff
changeset
|
5064 win_close_othertab(win, !need_hide && !buf_hide(buf), tp); |
671 | 5065 } |
5066 | |
5067 /* | |
10741
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5068 * Handle the argument for a tabpage related ex command. |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5069 * Returns a tabpage number. |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5070 * When an error is encountered then eap->errmsg is set. |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5071 */ |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5072 static int |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5073 get_tabpage_arg(exarg_T *eap) |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5074 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5075 int tab_number; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5076 int unaccept_arg0 = (eap->cmdidx == CMD_tabmove) ? 0 : 1; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5077 |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5078 if (eap->arg && *eap->arg != NUL) |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5079 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5080 char_u *p = eap->arg; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5081 char_u *p_save; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5082 int relative = 0; /* argument +N/-N means: go to N places to the |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5083 * right/left relative to the current position. */ |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5084 |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5085 if (*p == '-') |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5086 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5087 relative = -1; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5088 p++; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5089 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5090 else if (*p == '+') |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5091 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5092 relative = 1; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5093 p++; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5094 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5095 |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5096 p_save = p; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5097 tab_number = getdigits(&p); |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5098 |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5099 if (relative == 0) |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5100 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5101 if (STRCMP(p, "$") == 0) |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5102 tab_number = LAST_TAB_NR; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5103 else if (p == p_save || *p_save == '-' || *p != NUL |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5104 || tab_number > LAST_TAB_NR) |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5105 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5106 /* No numbers as argument. */ |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5107 eap->errmsg = e_invarg; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5108 goto theend; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5109 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5110 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5111 else |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5112 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5113 if (*p_save == NUL) |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5114 tab_number = 1; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5115 else if (p == p_save || *p_save == '-' || *p != NUL |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5116 || tab_number == 0) |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5117 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5118 /* No numbers as argument. */ |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5119 eap->errmsg = e_invarg; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5120 goto theend; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5121 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5122 tab_number = tab_number * relative + tabpage_index(curtab); |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5123 if (!unaccept_arg0 && relative == -1) |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5124 --tab_number; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5125 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5126 if (tab_number < unaccept_arg0 || tab_number > LAST_TAB_NR) |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5127 eap->errmsg = e_invarg; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5128 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5129 else if (eap->addr_count > 0) |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5130 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5131 if (unaccept_arg0 && eap->line2 == 0) |
10753
4961e7acdd8c
patch 8.0.0266: compiler warning for using uninitialized variable
Christian Brabandt <cb@256bit.org>
parents:
10741
diff
changeset
|
5132 { |
10741
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5133 eap->errmsg = e_invrange; |
10753
4961e7acdd8c
patch 8.0.0266: compiler warning for using uninitialized variable
Christian Brabandt <cb@256bit.org>
parents:
10741
diff
changeset
|
5134 tab_number = 0; |
4961e7acdd8c
patch 8.0.0266: compiler warning for using uninitialized variable
Christian Brabandt <cb@256bit.org>
parents:
10741
diff
changeset
|
5135 } |
10741
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5136 else |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5137 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5138 tab_number = eap->line2; |
15573
060cb54565c1
patch 8.1.0794: white space before " -Ntabmove" causes problems
Bram Moolenaar <Bram@vim.org>
parents:
15565
diff
changeset
|
5139 if (!unaccept_arg0 && *skipwhite(*eap->cmdlinep) == '-') |
10741
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5140 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5141 --tab_number; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5142 if (tab_number < unaccept_arg0) |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5143 eap->errmsg = e_invarg; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5144 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5145 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5146 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5147 else |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5148 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5149 switch (eap->cmdidx) |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5150 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5151 case CMD_tabnext: |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5152 tab_number = tabpage_index(curtab) + 1; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5153 if (tab_number > LAST_TAB_NR) |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5154 tab_number = 1; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5155 break; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5156 case CMD_tabmove: |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5157 tab_number = LAST_TAB_NR; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5158 break; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5159 default: |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5160 tab_number = tabpage_index(curtab); |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5161 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5162 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5163 |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5164 theend: |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5165 return tab_number; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5166 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5167 |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5168 /* |
671 | 5169 * ":tabclose": close current tab page, unless it is the last one. |
5170 * ":tabclose N": close tab page N. | |
667 | 5171 */ |
5172 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5173 ex_tabclose(exarg_T *eap) |
667 | 5174 { |
671 | 5175 tabpage_T *tp; |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5176 int tab_number; |
671 | 5177 |
667 | 5178 # ifdef FEAT_CMDWIN |
5179 if (cmdwin_type != 0) | |
5180 cmdwin_result = K_IGNORE; | |
5181 else | |
5182 # endif | |
671 | 5183 if (first_tabpage->tp_next == NULL) |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
5184 emsg(_("E784: Cannot close last tab page")); |
671 | 5185 else |
5186 { | |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5187 tab_number = get_tabpage_arg(eap); |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5188 if (eap->errmsg == NULL) |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5189 { |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5190 tp = find_tabpage(tab_number); |
671 | 5191 if (tp == NULL) |
5192 { | |
5193 beep_flush(); | |
5194 return; | |
5195 } | |
674 | 5196 if (tp != curtab) |
671 | 5197 { |
5198 tabpage_close_other(tp, eap->forceit); | |
5199 return; | |
5200 } | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
5201 else if (!text_locked() && !curbuf_locked()) |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5202 tabpage_close(eap->forceit); |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5203 } |
671 | 5204 } |
672 | 5205 } |
5206 | |
5207 /* | |
5208 * ":tabonly": close all tab pages except the current one | |
5209 */ | |
5210 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5211 ex_tabonly(exarg_T *eap) |
672 | 5212 { |
5213 tabpage_T *tp; | |
5214 int done; | |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5215 int tab_number; |
672 | 5216 |
5217 # ifdef FEAT_CMDWIN | |
5218 if (cmdwin_type != 0) | |
5219 cmdwin_result = K_IGNORE; | |
5220 else | |
5221 # endif | |
5222 if (first_tabpage->tp_next == NULL) | |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15510
diff
changeset
|
5223 msg(_("Already only one tab page")); |
672 | 5224 else |
5225 { | |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5226 tab_number = get_tabpage_arg(eap); |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5227 if (eap->errmsg == NULL) |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5228 { |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5229 goto_tabpage(tab_number); |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5230 /* Repeat this up to a 1000 times, because autocommands may |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5231 * mess up the lists. */ |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5232 for (done = 0; done < 1000; ++done) |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5233 { |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5234 FOR_ALL_TABPAGES(tp) |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5235 if (tp->tp_topframe != topframe) |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5236 { |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5237 tabpage_close_other(tp, eap->forceit); |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5238 /* if we failed to close it quit */ |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5239 if (valid_tabpage(tp)) |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5240 done = 1000; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5241 /* start over, "tp" is now invalid */ |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5242 break; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5243 } |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5244 if (first_tabpage->tp_next == NULL) |
672 | 5245 break; |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5246 } |
672 | 5247 } |
5248 } | |
671 | 5249 } |
5250 | |
5251 /* | |
5252 * Close the current tab page. | |
5253 */ | |
5254 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5255 tabpage_close(int forceit) |
671 | 5256 { |
5257 /* First close all the windows but the current one. If that worked then | |
5258 * close the last window in this tab, that will close it. */ | |
10357
59d01e335858
commit https://github.com/vim/vim/commit/459ca563128f2edb7e3bb190090bbb755a56dd55
Christian Brabandt <cb@256bit.org>
parents:
10349
diff
changeset
|
5259 if (!ONE_WINDOW) |
675 | 5260 close_others(TRUE, forceit); |
10357
59d01e335858
commit https://github.com/vim/vim/commit/459ca563128f2edb7e3bb190090bbb755a56dd55
Christian Brabandt <cb@256bit.org>
parents:
10349
diff
changeset
|
5261 if (ONE_WINDOW) |
671 | 5262 ex_win_close(forceit, curwin, NULL); |
5263 # ifdef FEAT_GUI | |
5264 need_mouse_correct = TRUE; | |
5265 # endif | |
5266 } | |
5267 | |
5268 /* | |
5269 * Close tab page "tp", which is not the current tab page. | |
5270 * Note that autocommands may make "tp" invalid. | |
971 | 5271 * Also takes care of the tab pages line disappearing when closing the |
5272 * last-but-one tab page. | |
671 | 5273 */ |
5274 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5275 tabpage_close_other(tabpage_T *tp, int forceit) |
671 | 5276 { |
5277 int done = 0; | |
672 | 5278 win_T *wp; |
971 | 5279 int h = tabline_height(); |
671 | 5280 |
5281 /* Limit to 1000 windows, autocommands may add a window while we close | |
5282 * one. OK, so I'm paranoid... */ | |
5283 while (++done < 1000) | |
5284 { | |
672 | 5285 wp = tp->tp_firstwin; |
5286 ex_win_close(forceit, wp, tp); | |
5287 | |
5288 /* Autocommands may delete the tab page under our fingers and we may | |
5289 * fail to close a window with a modified buffer. */ | |
5290 if (!valid_tabpage(tp) || tp->tp_firstwin == wp) | |
671 | 5291 break; |
5292 } | |
971 | 5293 |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9538
diff
changeset
|
5294 apply_autocmds(EVENT_TABCLOSED, NULL, NULL, FALSE, curbuf); |
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9538
diff
changeset
|
5295 |
672 | 5296 redraw_tabline = TRUE; |
971 | 5297 if (h != tabline_height()) |
5298 shell_new_rows(); | |
667 | 5299 } |
7 | 5300 |
5301 /* | |
5302 * ":only". | |
5303 */ | |
5304 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5305 ex_only(exarg_T *eap) |
7 | 5306 { |
6398 | 5307 win_T *wp; |
5308 int wnr; | |
7 | 5309 # ifdef FEAT_GUI |
5310 need_mouse_correct = TRUE; | |
5311 # endif | |
6398 | 5312 if (eap->addr_count > 0) |
5313 { | |
5314 wnr = eap->line2; | |
5315 for (wp = firstwin; --wnr > 0; ) | |
5316 { | |
5317 if (wp->w_next == NULL) | |
5318 break; | |
5319 else | |
5320 wp = wp->w_next; | |
5321 } | |
5322 win_goto(wp); | |
5323 } | |
7 | 5324 close_others(TRUE, eap->forceit); |
5325 } | |
5326 | |
5327 static void | |
10492
b2cd5a71f4bb
commit https://github.com/vim/vim/commit/5e1e6d265d26ee2952c4a018a5ff72c950d2d700
Christian Brabandt <cb@256bit.org>
parents:
10490
diff
changeset
|
5328 ex_hide(exarg_T *eap UNUSED) |
7 | 5329 { |
10383
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5330 /* ":hide" or ":hide | cmd": hide current window */ |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5331 if (!eap->skip) |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5332 { |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5333 #ifdef FEAT_GUI |
10383
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5334 need_mouse_correct = TRUE; |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5335 #endif |
10383
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5336 if (eap->addr_count == 0) |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5337 win_close(curwin, FALSE); /* don't free buffer */ |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5338 else |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5339 { |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5340 int winnr = 0; |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5341 win_T *win; |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5342 |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5343 FOR_ALL_WINDOWS(win) |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5344 { |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5345 winnr++; |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5346 if (winnr == eap->line2) |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5347 break; |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5348 } |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5349 if (win == NULL) |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5350 win = lastwin; |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5351 win_close(win, FALSE); |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5352 } |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5353 } |
7 | 5354 } |
5355 | |
5356 /* | |
5357 * ":stop" and ":suspend": Suspend Vim. | |
5358 */ | |
5359 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5360 ex_stop(exarg_T *eap) |
7 | 5361 { |
5362 /* | |
5363 * Disallow suspending for "rvim". | |
5364 */ | |
10264
c036c0f636d5
commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents:
10240
diff
changeset
|
5365 if (!check_restricted()) |
7 | 5366 { |
5367 if (!eap->forceit) | |
5368 autowrite_all(); | |
5369 windgoto((int)Rows - 1, 0); | |
5370 out_char('\n'); | |
5371 out_flush(); | |
5372 stoptermcap(); | |
5373 out_flush(); /* needed for SUN to restore xterm buffer */ | |
5374 #ifdef FEAT_TITLE | |
14479
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14433
diff
changeset
|
5375 mch_restore_title(SAVE_RESTORE_BOTH); /* restore window titles */ |
7 | 5376 #endif |
5377 ui_suspend(); /* call machine specific function */ | |
5378 #ifdef FEAT_TITLE | |
5379 maketitle(); | |
5380 resettitle(); /* force updating the title */ | |
5381 #endif | |
5382 starttermcap(); | |
5383 scroll_start(); /* scroll screen before redrawing */ | |
5384 redraw_later_clear(); | |
5385 shell_resized(); /* may have resized window */ | |
5386 } | |
5387 } | |
5388 | |
5389 /* | |
13442
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5390 * ":exit", ":xit" and ":wq": Write file and quite the current window. |
7 | 5391 */ |
5392 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5393 ex_exit(exarg_T *eap) |
7 | 5394 { |
5395 #ifdef FEAT_CMDWIN | |
5396 if (cmdwin_type != 0) | |
5397 { | |
5398 cmdwin_result = Ctrl_C; | |
5399 return; | |
5400 } | |
5401 #endif | |
631 | 5402 /* Don't quit while editing the command line. */ |
633 | 5403 if (text_locked()) |
5404 { | |
5405 text_locked_msg(); | |
631 | 5406 return; |
5407 } | |
13442
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5408 |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5409 if (before_quit_autocmds(curwin, FALSE, eap->forceit)) |
819 | 5410 return; |
7 | 5411 |
5412 /* | |
5413 * if more files or windows we won't exit | |
5414 */ | |
5415 if (check_more(FALSE, eap->forceit) == OK && only_one_window()) | |
5416 exiting = TRUE; | |
5417 if ( ((eap->cmdidx == CMD_wq | |
5418 || curbufIsChanged()) | |
5419 && do_write(eap) == FAIL) | |
5420 || check_more(TRUE, eap->forceit) == FAIL | |
7469
15eefe1b0dad
commit https://github.com/vim/vim/commit/027387f70c671f62e3e08e0bdd09ec05b0232735
Christian Brabandt <cb@256bit.org>
parents:
7465
diff
changeset
|
5421 || (only_one_window() && check_changed_any(eap->forceit, FALSE))) |
7 | 5422 { |
5423 not_exiting(); | |
5424 } | |
5425 else | |
5426 { | |
5427 if (only_one_window()) /* quit last window, exit Vim */ | |
5428 getout(0); | |
12624
ae2802b6bf7d
patch 8.0.1190: unusable after opening new window in BufWritePre event
Christian Brabandt <cb@256bit.org>
parents:
12622
diff
changeset
|
5429 not_exiting(); |
7 | 5430 # ifdef FEAT_GUI |
5431 need_mouse_correct = TRUE; | |
5432 # endif | |
5245
8c6615a30951
updated for version 7.4a.047
Bram Moolenaar <bram@vim.org>
parents:
5198
diff
changeset
|
5433 /* Quit current window, may free the buffer. */ |
11957
bc0fee081e1e
patch 8.0.0858: can exit while a terminal is still running a job
Christian Brabandt <cb@256bit.org>
parents:
11806
diff
changeset
|
5434 win_close(curwin, !buf_hide(curwin->w_buffer)); |
7 | 5435 } |
5436 } | |
5437 | |
5438 /* | |
5439 * ":print", ":list", ":number". | |
5440 */ | |
5441 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5442 ex_print(exarg_T *eap) |
7 | 5443 { |
167 | 5444 if (curbuf->b_ml.ml_flags & ML_EMPTY) |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
5445 emsg(_(e_emptybuf)); |
167 | 5446 else |
5447 { | |
5448 for ( ;!got_int; ui_breakcheck()) | |
5449 { | |
5450 print_line(eap->line1, | |
5451 (eap->cmdidx == CMD_number || eap->cmdidx == CMD_pound | |
5452 || (eap->flags & EXFLAG_NR)), | |
5453 eap->cmdidx == CMD_list || (eap->flags & EXFLAG_LIST)); | |
5454 if (++eap->line1 > eap->line2) | |
5455 break; | |
5456 out_flush(); /* show one line at a time */ | |
5457 } | |
5458 setpcmark(); | |
5459 /* put cursor at last line */ | |
5460 curwin->w_cursor.lnum = eap->line2; | |
5461 beginline(BL_SOL | BL_FIX); | |
5462 } | |
7 | 5463 |
5464 ex_no_reprint = TRUE; | |
5465 } | |
5466 | |
5467 #ifdef FEAT_BYTEOFF | |
5468 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5469 ex_goto(exarg_T *eap) |
7 | 5470 { |
5471 goto_byte(eap->line2); | |
5472 } | |
5473 #endif | |
5474 | |
5475 /* | |
5476 * ":shell". | |
5477 */ | |
5478 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5479 ex_shell(exarg_T *eap UNUSED) |
7 | 5480 { |
5481 do_shell(NULL, 0); | |
5482 } | |
5483 | |
14428
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5484 #if defined(HAVE_DROP_FILE) || defined(PROTO) |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5485 |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5486 static int drop_busy = FALSE; |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5487 static int drop_filec; |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5488 static char_u **drop_filev = NULL; |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5489 static int drop_split; |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5490 static void (*drop_callback)(void *); |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5491 static void *drop_cookie; |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5492 |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5493 static void |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5494 handle_drop_internal(void) |
7 | 5495 { |
5496 exarg_T ea; | |
5497 int save_msg_scroll = msg_scroll; | |
5498 | |
14428
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5499 // Setting the argument list may cause screen updates and being called |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5500 // recursively. Avoid that by setting drop_busy. |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5501 drop_busy = TRUE; |
7 | 5502 |
5503 /* Check whether the current buffer is changed. If so, we will need | |
5504 * to split the current window or data could be lost. | |
5505 * We don't need to check if the 'hidden' option is set, as in this | |
5506 * case the buffer won't be lost. | |
5507 */ | |
14428
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5508 if (!buf_hide(curbuf) && !drop_split) |
7 | 5509 { |
5510 ++emsg_off; | |
14428
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5511 drop_split = check_changed(curbuf, CCGD_AW); |
7 | 5512 --emsg_off; |
5513 } | |
14428
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5514 if (drop_split) |
7 | 5515 { |
5516 if (win_split(0, 0) == FAIL) | |
5517 return; | |
2583 | 5518 RESET_BINDING(curwin); |
7 | 5519 |
5520 /* When splitting the window, create a new alist. Otherwise the | |
5521 * existing one is overwritten. */ | |
5522 alist_unlink(curwin->w_alist); | |
5523 alist_new(); | |
5524 } | |
5525 | |
5526 /* | |
5527 * Set up the new argument list. | |
5528 */ | |
14428
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5529 alist_set(ALIST(curwin), drop_filec, drop_filev, FALSE, NULL, 0); |
7 | 5530 |
5531 /* | |
5532 * Move to the first file. | |
5533 */ | |
5534 /* Fake up a minimal "next" command for do_argfile() */ | |
5535 vim_memset(&ea, 0, sizeof(ea)); | |
5536 ea.cmd = (char_u *)"next"; | |
5537 do_argfile(&ea, 0); | |
5538 | |
5539 /* do_ecmd() may set need_start_insertmode, but since we never left Insert | |
5540 * mode that is not needed here. */ | |
5541 need_start_insertmode = FALSE; | |
5542 | |
5543 /* Restore msg_scroll, otherwise a following command may cause scrolling | |
5544 * unexpectedly. The screen will be redrawn by the caller, thus | |
5545 * msg_scroll being set by displaying a message is irrelevant. */ | |
5546 msg_scroll = save_msg_scroll; | |
14428
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5547 |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5548 if (drop_callback != NULL) |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5549 drop_callback(drop_cookie); |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5550 |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5551 drop_filev = NULL; |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5552 drop_busy = FALSE; |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5553 } |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5554 |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5555 /* |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5556 * Handle a file drop. The code is here because a drop is *nearly* like an |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5557 * :args command, but not quite (we have a list of exact filenames, so we |
15490
98c35d312987
patch 8.1.0753: printf format not checked for semsg()
Bram Moolenaar <Bram@vim.org>
parents:
15488
diff
changeset
|
5558 * don't want to (a) parse a command line, or (b) expand wildcards). So the |
14428
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5559 * code is very similar to :args and hence needs access to a lot of the static |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5560 * functions in this file. |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5561 * |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5562 * The "filev" list must have been allocated using alloc(), as should each item |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5563 * in the list. This function takes over responsibility for freeing the "filev" |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5564 * list. |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5565 */ |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5566 void |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5567 handle_drop( |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5568 int filec, // the number of files dropped |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5569 char_u **filev, // the list of files dropped |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5570 int split, // force splitting the window |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5571 void (*callback)(void *), // to be called after setting the argument |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5572 // list |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5573 void *cookie) // argument for "callback" (allocated) |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5574 { |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5575 // Cannot handle recursive drops, finish the pending one. |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5576 if (drop_busy) |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5577 { |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5578 FreeWild(filec, filev); |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5579 vim_free(cookie); |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5580 return; |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5581 } |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5582 |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5583 // When calling handle_drop() more than once in a row we only use the last |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5584 // one. |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5585 if (drop_filev != NULL) |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5586 { |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5587 FreeWild(drop_filec, drop_filev); |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5588 vim_free(drop_cookie); |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5589 } |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5590 |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5591 drop_filec = filec; |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5592 drop_filev = filev; |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5593 drop_split = split; |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5594 drop_callback = callback; |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5595 drop_cookie = cookie; |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5596 |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5597 // Postpone this when: |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5598 // - editing the command line |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5599 // - not possible to change the current buffer |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5600 // - updating the screen |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5601 // As it may change buffers and window structures that are in use and cause |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5602 // freed memory to be used. |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5603 if (text_locked() || curbuf_locked() || updating_screen) |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5604 return; |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5605 |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5606 handle_drop_internal(); |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5607 } |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5608 |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5609 /* |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5610 * To be called when text is unlocked, curbuf is unlocked or updating_screen is |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5611 * reset: Handle a postponed drop. |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5612 */ |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5613 void |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5614 handle_any_postponed_drop(void) |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5615 { |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5616 if (!drop_busy && drop_filev != NULL |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5617 && !text_locked() && !curbuf_locked() && !updating_screen) |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5618 handle_drop_internal(); |
7 | 5619 } |
5620 #endif | |
5621 | |
5622 /* | |
5623 * ":preserve". | |
5624 */ | |
5625 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5626 ex_preserve(exarg_T *eap UNUSED) |
7 | 5627 { |
164 | 5628 curbuf->b_flags |= BF_PRESERVED; |
7 | 5629 ml_preserve(curbuf, TRUE); |
5630 } | |
5631 | |
5632 /* | |
5633 * ":recover". | |
5634 */ | |
5635 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5636 ex_recover(exarg_T *eap) |
7 | 5637 { |
5638 /* Set recoverymode right away to avoid the ATTENTION prompt. */ | |
5639 recoverymode = TRUE; | |
5464 | 5640 if (!check_changed(curbuf, (p_awa ? CCGD_AW : 0) |
5641 | CCGD_MULTWIN | |
5642 | (eap->forceit ? CCGD_FORCEIT : 0) | |
5643 | CCGD_EXCMD) | |
5644 | |
7 | 5645 && (*eap->arg == NUL |
5646 || setfname(curbuf, eap->arg, NULL, TRUE) == OK)) | |
16738
b52ea9c5f1db
patch 8.1.1371: cannot recover from a swap file
Bram Moolenaar <Bram@vim.org>
parents:
16608
diff
changeset
|
5647 ml_recover(TRUE); |
7 | 5648 recoverymode = FALSE; |
5649 } | |
5650 | |
5651 /* | |
5652 * Command modifier used in a wrong way. | |
5653 */ | |
5654 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5655 ex_wrongmodifier(exarg_T *eap) |
7 | 5656 { |
5657 eap->errmsg = e_invcmd; | |
5658 } | |
5659 | |
5660 /* | |
5661 * :sview [+command] file split window with new file, read-only | |
5662 * :split [[+command] file] split window with current or new file | |
5663 * :vsplit [[+command] file] split window vertically with current or new file | |
5664 * :new [[+command] file] split window with no or new file | |
5665 * :vnew [[+command] file] split vertically window with no or new file | |
5666 * :sfind [+command] file split window with file in 'path' | |
675 | 5667 * |
5668 * :tabedit open new Tab page with empty window | |
5669 * :tabedit [+command] file open new Tab page and edit "file" | |
5670 * :tabnew [[+command] file] just like :tabedit | |
5671 * :tabfind [+command] file open new Tab page and find "file" | |
7 | 5672 */ |
5673 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5674 ex_splitview(exarg_T *eap) |
7 | 5675 { |
675 | 5676 win_T *old_curwin = curwin; |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5677 #if defined(FEAT_SEARCHPATH) || defined(FEAT_BROWSE) |
7 | 5678 char_u *fname = NULL; |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5679 #endif |
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5680 #ifdef FEAT_BROWSE |
7 | 5681 int browse_flag = cmdmod.browse; |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5682 #endif |
14155
da09e29e59d9
patch 8.1.0095: dialog for ":browse tabnew" says "new window"
Christian Brabandt <cb@256bit.org>
parents:
14059
diff
changeset
|
5683 int use_tab = eap->cmdidx == CMD_tabedit |
da09e29e59d9
patch 8.1.0095: dialog for ":browse tabnew" says "new window"
Christian Brabandt <cb@256bit.org>
parents:
14059
diff
changeset
|
5684 || eap->cmdidx == CMD_tabfind |
da09e29e59d9
patch 8.1.0095: dialog for ":browse tabnew" says "new window"
Christian Brabandt <cb@256bit.org>
parents:
14059
diff
changeset
|
5685 || eap->cmdidx == CMD_tabnew; |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5686 |
17111
af861fccc309
patch 8.1.1555: NOT_IN_POPUP_WINDOW is confusing
Bram Moolenaar <Bram@vim.org>
parents:
17095
diff
changeset
|
5687 if (ERROR_IF_POPUP_WINDOW) |
16874
da5f5836e90c
patch 8.1.1438: some commands cause trouble in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
5688 return; |
da5f5836e90c
patch 8.1.1438: some commands cause trouble in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
5689 |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5690 #ifdef FEAT_GUI |
7 | 5691 need_mouse_correct = TRUE; |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5692 #endif |
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5693 |
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5694 #ifdef FEAT_QUICKFIX |
7 | 5695 /* A ":split" in the quickfix window works like ":new". Don't want two |
1661 | 5696 * quickfix windows. But it's OK when doing ":tab split". */ |
5697 if (bt_quickfix(curbuf) && cmdmod.tab == 0) | |
7 | 5698 { |
5699 if (eap->cmdidx == CMD_split) | |
5700 eap->cmdidx = CMD_new; | |
5701 if (eap->cmdidx == CMD_vsplit) | |
5702 eap->cmdidx = CMD_vnew; | |
667 | 5703 } |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5704 #endif |
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5705 |
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5706 #ifdef FEAT_SEARCHPATH |
675 | 5707 if (eap->cmdidx == CMD_sfind || eap->cmdidx == CMD_tabfind) |
7 | 5708 { |
5709 fname = find_file_in_path(eap->arg, (int)STRLEN(eap->arg), | |
5710 FNAME_MESS, TRUE, curbuf->b_ffname); | |
5711 if (fname == NULL) | |
5712 goto theend; | |
5713 eap->arg = fname; | |
5714 } | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5715 # ifdef FEAT_BROWSE |
7 | 5716 else |
5717 # endif | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5718 #endif |
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5719 #ifdef FEAT_BROWSE |
7 | 5720 if (cmdmod.browse |
5721 && eap->cmdidx != CMD_vnew | |
5722 && eap->cmdidx != CMD_new) | |
5723 { | |
461 | 5724 if ( |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
5725 # ifdef FEAT_GUI |
461 | 5726 !gui.in_use && |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
5727 # endif |
461 | 5728 au_has_group((char_u *)"FileExplorer")) |
5729 { | |
5730 /* No browsing supported but we do have the file explorer: | |
5731 * Edit the directory. */ | |
5732 if (*eap->arg == NUL || !mch_isdir(eap->arg)) | |
5733 eap->arg = (char_u *)"."; | |
5734 } | |
5735 else | |
5736 { | |
14155
da09e29e59d9
patch 8.1.0095: dialog for ":browse tabnew" says "new window"
Christian Brabandt <cb@256bit.org>
parents:
14059
diff
changeset
|
5737 fname = do_browse(0, (char_u *)(use_tab |
da09e29e59d9
patch 8.1.0095: dialog for ":browse tabnew" says "new window"
Christian Brabandt <cb@256bit.org>
parents:
14059
diff
changeset
|
5738 ? _("Edit File in new tab page") |
da09e29e59d9
patch 8.1.0095: dialog for ":browse tabnew" says "new window"
Christian Brabandt <cb@256bit.org>
parents:
14059
diff
changeset
|
5739 : _("Edit File in new window")), |
7 | 5740 eap->arg, NULL, NULL, NULL, curbuf); |
461 | 5741 if (fname == NULL) |
5742 goto theend; | |
5743 eap->arg = fname; | |
5744 } | |
7 | 5745 } |
5746 cmdmod.browse = FALSE; /* Don't browse again in do_ecmd(). */ | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5747 #endif |
7 | 5748 |
675 | 5749 /* |
5750 * Either open new tab page or split the window. | |
5751 */ | |
14155
da09e29e59d9
patch 8.1.0095: dialog for ":browse tabnew" says "new window"
Christian Brabandt <cb@256bit.org>
parents:
14059
diff
changeset
|
5752 if (use_tab) |
675 | 5753 { |
820 | 5754 if (win_new_tabpage(cmdmod.tab != 0 ? cmdmod.tab |
5755 : eap->addr_count == 0 ? 0 | |
5756 : (int)eap->line2 + 1) != FAIL) | |
675 | 5757 { |
1498 | 5758 do_exedit(eap, old_curwin); |
675 | 5759 |
5760 /* set the alternate buffer for the window we came from */ | |
5761 if (curwin != old_curwin | |
5762 && win_valid(old_curwin) | |
5763 && old_curwin->w_buffer != curbuf | |
5764 && !cmdmod.keepalt) | |
5765 old_curwin->w_alt_fnum = curbuf->b_fnum; | |
5766 } | |
5767 } | |
5768 else if (win_split(eap->addr_count > 0 ? (int)eap->line2 : 0, | |
7 | 5769 *eap->cmd == 'v' ? WSP_VERT : 0) != FAIL) |
5770 { | |
5771 /* Reset 'scrollbind' when editing another file, but keep it when | |
5772 * doing ":split" without arguments. */ | |
5773 if (*eap->arg != NUL | |
13384
6740c499de13
patch 8.0.1566: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13380
diff
changeset
|
5774 # ifdef FEAT_BROWSE |
7 | 5775 || cmdmod.browse |
13384
6740c499de13
patch 8.0.1566: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13380
diff
changeset
|
5776 # endif |
7 | 5777 ) |
2583 | 5778 RESET_BINDING(curwin); |
7 | 5779 else |
5780 do_check_scrollbind(FALSE); | |
5781 do_exedit(eap, old_curwin); | |
5782 } | |
5783 | |
667 | 5784 # ifdef FEAT_BROWSE |
7 | 5785 cmdmod.browse = browse_flag; |
667 | 5786 # endif |
5787 | |
5788 # if defined(FEAT_SEARCHPATH) || defined(FEAT_BROWSE) | |
7 | 5789 theend: |
5790 vim_free(fname); | |
667 | 5791 # endif |
5792 } | |
5793 | |
5794 /* | |
682 | 5795 * Open a new tab page. |
667 | 5796 */ |
5797 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5798 tabpage_new(void) |
682 | 5799 { |
5800 exarg_T ea; | |
5801 | |
5802 vim_memset(&ea, 0, sizeof(ea)); | |
5803 ea.cmdidx = CMD_tabnew; | |
5804 ea.cmd = (char_u *)"tabn"; | |
5805 ea.arg = (char_u *)""; | |
5806 ex_splitview(&ea); | |
5807 } | |
5808 | |
5809 /* | |
5810 * :tabnext command | |
5811 */ | |
5812 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5813 ex_tabnext(exarg_T *eap) |
682 | 5814 { |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5815 int tab_number; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5816 |
17111
af861fccc309
patch 8.1.1555: NOT_IN_POPUP_WINDOW is confusing
Bram Moolenaar <Bram@vim.org>
parents:
17095
diff
changeset
|
5817 if (ERROR_IF_POPUP_WINDOW) |
16874
da5f5836e90c
patch 8.1.1438: some commands cause trouble in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
5818 return; |
685 | 5819 switch (eap->cmdidx) |
5820 { | |
5821 case CMD_tabfirst: | |
5822 case CMD_tabrewind: | |
5823 goto_tabpage(1); | |
5824 break; | |
5825 case CMD_tablast: | |
5826 goto_tabpage(9999); | |
5827 break; | |
5828 case CMD_tabprevious: | |
5829 case CMD_tabNext: | |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5830 if (eap->arg && *eap->arg != NUL) |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5831 { |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5832 char_u *p = eap->arg; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5833 char_u *p_save = p; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5834 |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5835 tab_number = getdigits(&p); |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5836 if (p == p_save || *p_save == '-' || *p != NUL |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5837 || tab_number == 0) |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5838 { |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5839 /* No numbers as argument. */ |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5840 eap->errmsg = e_invarg; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5841 return; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5842 } |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5843 } |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5844 else |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5845 { |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5846 if (eap->addr_count == 0) |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5847 tab_number = 1; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5848 else |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5849 { |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5850 tab_number = eap->line2; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5851 if (tab_number < 1) |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5852 { |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5853 eap->errmsg = e_invrange; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5854 return; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5855 } |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5856 } |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5857 } |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5858 goto_tabpage(-tab_number); |
685 | 5859 break; |
5860 default: /* CMD_tabnext */ | |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5861 tab_number = get_tabpage_arg(eap); |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5862 if (eap->errmsg == NULL) |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5863 goto_tabpage(tab_number); |
685 | 5864 break; |
5865 } | |
682 | 5866 } |
5867 | |
5868 /* | |
5869 * :tabmove command | |
5870 */ | |
5871 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5872 ex_tabmove(exarg_T *eap) |
682 | 5873 { |
6775 | 5874 int tab_number; |
3662 | 5875 |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5876 tab_number = get_tabpage_arg(eap); |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5877 if (eap->errmsg == NULL) |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5878 tabpage_move(tab_number); |
667 | 5879 } |
5880 | |
5881 /* | |
5882 * :tabs command: List tabs and their contents. | |
5883 */ | |
5884 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5885 ex_tabs(exarg_T *eap UNUSED) |
667 | 5886 { |
5887 tabpage_T *tp; | |
5888 win_T *wp; | |
5889 int tabcount = 1; | |
5890 | |
5891 msg_start(); | |
5892 msg_scroll = TRUE; | |
5893 for (tp = first_tabpage; tp != NULL && !got_int; tp = tp->tp_next) | |
5894 { | |
5895 msg_putchar('\n'); | |
5896 vim_snprintf((char *)IObuff, IOSIZE, _("Tab page %d"), tabcount++); | |
11158
501f46f7644c
patch 8.0.0466: still macros that should be all-caps
Christian Brabandt <cb@256bit.org>
parents:
11129
diff
changeset
|
5897 msg_outtrans_attr(IObuff, HL_ATTR(HLF_T)); |
667 | 5898 out_flush(); /* output one line at a time */ |
5899 ui_breakcheck(); | |
5900 | |
678 | 5901 if (tp == curtab) |
667 | 5902 wp = firstwin; |
5903 else | |
5904 wp = tp->tp_firstwin; | |
5905 for ( ; wp != NULL && !got_int; wp = wp->w_next) | |
5906 { | |
682 | 5907 msg_putchar('\n'); |
5908 msg_putchar(wp == curwin ? '>' : ' '); | |
5909 msg_putchar(' '); | |
672 | 5910 msg_putchar(bufIsChanged(wp->w_buffer) ? '+' : ' '); |
5911 msg_putchar(' '); | |
667 | 5912 if (buf_spname(wp->w_buffer) != NULL) |
3839 | 5913 vim_strncpy(IObuff, buf_spname(wp->w_buffer), IOSIZE - 1); |
667 | 5914 else |
5915 home_replace(wp->w_buffer, wp->w_buffer->b_fname, | |
5916 IObuff, IOSIZE, TRUE); | |
5917 msg_outtrans(IObuff); | |
5918 out_flush(); /* output one line at a time */ | |
5919 ui_breakcheck(); | |
5920 } | |
5921 } | |
5922 } | |
5923 | |
7 | 5924 /* |
5925 * ":mode": Set screen mode. | |
5926 * If no argument given, just get the screen size and redraw. | |
5927 */ | |
5928 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5929 ex_mode(exarg_T *eap) |
7 | 5930 { |
5931 if (*eap->arg == NUL) | |
5932 shell_resized(); | |
5933 else | |
5934 mch_screenmode(eap->arg); | |
5935 } | |
5936 | |
5937 /* | |
5938 * ":resize". | |
5939 * set, increment or decrement current window height | |
5940 */ | |
5941 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5942 ex_resize(exarg_T *eap) |
7 | 5943 { |
5944 int n; | |
5945 win_T *wp = curwin; | |
5946 | |
5947 if (eap->addr_count > 0) | |
5948 { | |
5949 n = eap->line2; | |
5950 for (wp = firstwin; wp->w_next != NULL && --n > 0; wp = wp->w_next) | |
5951 ; | |
5952 } | |
5953 | |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8577
diff
changeset
|
5954 # ifdef FEAT_GUI |
7 | 5955 need_mouse_correct = TRUE; |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8577
diff
changeset
|
5956 # endif |
7 | 5957 n = atol((char *)eap->arg); |
5958 if (cmdmod.split & WSP_VERT) | |
5959 { | |
5960 if (*eap->arg == '-' || *eap->arg == '+') | |
12515
972ea22c946f
patch 8.0.1136: W_WIDTH() is always the same
Christian Brabandt <cb@256bit.org>
parents:
12513
diff
changeset
|
5961 n += curwin->w_width; |
7 | 5962 else if (n == 0 && eap->arg[0] == NUL) /* default is very wide */ |
5963 n = 9999; | |
5964 win_setwidth_win((int)n, wp); | |
5965 } | |
5966 else | |
5967 { | |
5968 if (*eap->arg == '-' || *eap->arg == '+') | |
5969 n += curwin->w_height; | |
11757
74abb6c84984
patch 8.0.0761: options not set properly for a terminal buffer
Christian Brabandt <cb@256bit.org>
parents:
11635
diff
changeset
|
5970 else if (n == 0 && eap->arg[0] == NUL) /* default is very high */ |
7 | 5971 n = 9999; |
5972 win_setheight_win((int)n, wp); | |
5973 } | |
5974 } | |
5975 | |
5976 /* | |
5977 * ":find [+command] <file>" command. | |
5978 */ | |
5979 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5980 ex_find(exarg_T *eap) |
7 | 5981 { |
5982 #ifdef FEAT_SEARCHPATH | |
5983 char_u *fname; | |
5984 int count; | |
5985 | |
5986 fname = find_file_in_path(eap->arg, (int)STRLEN(eap->arg), FNAME_MESS, | |
5987 TRUE, curbuf->b_ffname); | |
5988 if (eap->addr_count > 0) | |
5989 { | |
5990 /* Repeat finding the file "count" times. This matters when it | |
5991 * appears several times in the path. */ | |
5992 count = eap->line2; | |
5993 while (fname != NULL && --count > 0) | |
5994 { | |
5995 vim_free(fname); | |
5996 fname = find_file_in_path(NULL, 0, FNAME_MESS, | |
5997 FALSE, curbuf->b_ffname); | |
5998 } | |
5999 } | |
6000 | |
6001 if (fname != NULL) | |
6002 { | |
6003 eap->arg = fname; | |
6004 #endif | |
6005 do_exedit(eap, NULL); | |
6006 #ifdef FEAT_SEARCHPATH | |
6007 vim_free(fname); | |
6008 } | |
6009 #endif | |
6010 } | |
6011 | |
6012 /* | |
167 | 6013 * ":open" simulation: for now just work like ":visual". |
6014 */ | |
6015 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6016 ex_open(exarg_T *eap) |
167 | 6017 { |
6018 regmatch_T regmatch; | |
6019 char_u *p; | |
6020 | |
6021 curwin->w_cursor.lnum = eap->line2; | |
6022 beginline(BL_SOL | BL_FIX); | |
6023 if (*eap->arg == '/') | |
6024 { | |
6025 /* ":open /pattern/": put cursor in column found with pattern */ | |
6026 ++eap->arg; | |
6027 p = skip_regexp(eap->arg, '/', p_magic, NULL); | |
6028 *p = NUL; | |
6029 regmatch.regprog = vim_regcomp(eap->arg, p_magic ? RE_MAGIC : 0); | |
6030 if (regmatch.regprog != NULL) | |
6031 { | |
6032 regmatch.rm_ic = p_ic; | |
6033 p = ml_get_curline(); | |
6034 if (vim_regexec(®match, p, (colnr_T)0)) | |
835 | 6035 curwin->w_cursor.col = (colnr_T)(regmatch.startp[0] - p); |
167 | 6036 else |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
6037 emsg(_(e_nomatch)); |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4803
diff
changeset
|
6038 vim_regfree(regmatch.regprog); |
167 | 6039 } |
6040 /* Move to the NUL, ignore any other arguments. */ | |
6041 eap->arg += STRLEN(eap->arg); | |
6042 } | |
6043 check_cursor(); | |
6044 | |
6045 eap->cmdidx = CMD_visual; | |
6046 do_exedit(eap, NULL); | |
6047 } | |
6048 | |
6049 /* | |
6050 * ":edit", ":badd", ":visual". | |
7 | 6051 */ |
6052 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6053 ex_edit(exarg_T *eap) |
7 | 6054 { |
6055 do_exedit(eap, NULL); | |
6056 } | |
6057 | |
6058 /* | |
6059 * ":edit <file>" command and alikes. | |
6060 */ | |
6061 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6062 do_exedit( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6063 exarg_T *eap, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6064 win_T *old_curwin) /* curwin before doing a split or NULL */ |
7 | 6065 { |
6066 int n; | |
6067 int need_hide; | |
167 | 6068 int exmode_was = exmode_active; |
7 | 6069 |
17644
daa1dea1c1b3
patch 8.1.1819: :pedit does not work with a popup preview window
Bram Moolenaar <Bram@vim.org>
parents:
17622
diff
changeset
|
6070 if (eap->cmdidx != CMD_pedit && ERROR_IF_POPUP_WINDOW) |
16874
da5f5836e90c
patch 8.1.1438: some commands cause trouble in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
6071 return; |
7 | 6072 /* |
6073 * ":vi" command ends Ex mode. | |
6074 */ | |
6075 if (exmode_active && (eap->cmdidx == CMD_visual | |
6076 || eap->cmdidx == CMD_view)) | |
6077 { | |
6078 exmode_active = FALSE; | |
6079 if (*eap->arg == NUL) | |
167 | 6080 { |
6081 /* Special case: ":global/pat/visual\NLvi-commands" */ | |
6082 if (global_busy) | |
6083 { | |
6084 int rd = RedrawingDisabled; | |
6085 int nwr = no_wait_return; | |
6086 int ms = msg_scroll; | |
6087 #ifdef FEAT_GUI | |
6088 int he = hold_gui_events; | |
6089 #endif | |
6090 | |
6091 if (eap->nextcmd != NULL) | |
6092 { | |
6093 stuffReadbuff(eap->nextcmd); | |
6094 eap->nextcmd = NULL; | |
6095 } | |
6096 | |
6097 if (exmode_was != EXMODE_VIM) | |
6098 settmode(TMODE_RAW); | |
6099 RedrawingDisabled = 0; | |
6100 no_wait_return = 0; | |
6101 need_wait_return = FALSE; | |
6102 msg_scroll = 0; | |
6103 #ifdef FEAT_GUI | |
6104 hold_gui_events = 0; | |
6105 #endif | |
6106 must_redraw = CLEAR; | |
6107 | |
6108 main_loop(FALSE, TRUE); | |
6109 | |
6110 RedrawingDisabled = rd; | |
6111 no_wait_return = nwr; | |
6112 msg_scroll = ms; | |
6113 #ifdef FEAT_GUI | |
6114 hold_gui_events = he; | |
6115 #endif | |
6116 } | |
7 | 6117 return; |
167 | 6118 } |
7 | 6119 } |
6120 | |
6121 if ((eap->cmdidx == CMD_new | |
675 | 6122 || eap->cmdidx == CMD_tabnew |
6123 || eap->cmdidx == CMD_tabedit | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
6124 || eap->cmdidx == CMD_vnew) && *eap->arg == NUL) |
7 | 6125 { |
675 | 6126 /* ":new" or ":tabnew" without argument: edit an new empty buffer */ |
7 | 6127 setpcmark(); |
6128 (void)do_ecmd(0, NULL, NULL, eap, ECMD_ONE, | |
1743 | 6129 ECMD_HIDE + (eap->forceit ? ECMD_FORCEIT : 0), |
6130 old_curwin == NULL ? curwin : NULL); | |
7 | 6131 } |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
6132 else if ((eap->cmdidx != CMD_split && eap->cmdidx != CMD_vsplit) |
7 | 6133 || *eap->arg != NUL |
6134 #ifdef FEAT_BROWSE | |
6135 || cmdmod.browse | |
6136 #endif | |
6137 ) | |
6138 { | |
822 | 6139 /* Can't edit another file when "curbuf_lock" is set. Only ":edit" |
6140 * can bring us here, others are stopped earlier. */ | |
6141 if (*eap->arg != NUL && curbuf_locked()) | |
6142 return; | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
6143 |
7 | 6144 n = readonlymode; |
6145 if (eap->cmdidx == CMD_view || eap->cmdidx == CMD_sview) | |
6146 readonlymode = TRUE; | |
6147 else if (eap->cmdidx == CMD_enew) | |
6148 readonlymode = FALSE; /* 'readonly' doesn't make sense in an | |
6149 empty buffer */ | |
6150 setpcmark(); | |
6151 if (do_ecmd(0, (eap->cmdidx == CMD_enew ? NULL : eap->arg), | |
6152 NULL, eap, | |
6153 /* ":edit" goes to first line if Vi compatible */ | |
6154 (*eap->arg == NUL && eap->do_ecmd_lnum == 0 | |
6155 && vim_strchr(p_cpo, CPO_GOTO1) != NULL) | |
6156 ? ECMD_ONE : eap->do_ecmd_lnum, | |
11957
bc0fee081e1e
patch 8.0.0858: can exit while a terminal is still running a job
Christian Brabandt <cb@256bit.org>
parents:
11806
diff
changeset
|
6157 (buf_hide(curbuf) ? ECMD_HIDE : 0) |
7 | 6158 + (eap->forceit ? ECMD_FORCEIT : 0) |
5741 | 6159 /* after a split we can use an existing buffer */ |
6160 + (old_curwin != NULL ? ECMD_OLDBUF : 0) | |
7 | 6161 + (eap->cmdidx == CMD_badd ? ECMD_ADDBUF : 0 ) |
1743 | 6162 , old_curwin == NULL ? curwin : NULL) == FAIL) |
7 | 6163 { |
6164 /* Editing the file failed. If the window was split, close it. */ | |
6165 if (old_curwin != NULL) | |
6166 { | |
6167 need_hide = (curbufIsChanged() && curbuf->b_nwindows <= 1); | |
11957
bc0fee081e1e
patch 8.0.0858: can exit while a terminal is still running a job
Christian Brabandt <cb@256bit.org>
parents:
11806
diff
changeset
|
6168 if (!need_hide || buf_hide(curbuf)) |
7 | 6169 { |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
6170 #if defined(FEAT_EVAL) |
24 | 6171 cleanup_T cs; |
6172 | |
6173 /* Reset the error/interrupt/exception state here so that | |
6174 * aborting() returns FALSE when closing a window. */ | |
6175 enter_cleanup(&cs); | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
6176 #endif |
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
6177 #ifdef FEAT_GUI |
7 | 6178 need_mouse_correct = TRUE; |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
6179 #endif |
11957
bc0fee081e1e
patch 8.0.0858: can exit while a terminal is still running a job
Christian Brabandt <cb@256bit.org>
parents:
11806
diff
changeset
|
6180 win_close(curwin, !need_hide && !buf_hide(curbuf)); |
24 | 6181 |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
6182 #if defined(FEAT_EVAL) |
24 | 6183 /* Restore the error/interrupt/exception state if not |
6184 * discarded by a new aborting error, interrupt, or | |
6185 * uncaught exception. */ | |
6186 leave_cleanup(&cs); | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
6187 #endif |
7 | 6188 } |
6189 } | |
6190 } | |
6191 else if (readonlymode && curbuf->b_nwindows == 1) | |
6192 { | |
6193 /* When editing an already visited buffer, 'readonly' won't be set | |
6194 * but the previous value is kept. With ":view" and ":sview" we | |
6195 * want the file to be readonly, except when another window is | |
6196 * editing the same buffer. */ | |
6197 curbuf->b_p_ro = TRUE; | |
6198 } | |
6199 readonlymode = n; | |
6200 } | |
6201 else | |
6202 { | |
6203 if (eap->do_ecmd_cmd != NULL) | |
6204 do_cmdline_cmd(eap->do_ecmd_cmd); | |
6205 #ifdef FEAT_TITLE | |
6206 n = curwin->w_arg_idx_invalid; | |
6207 #endif | |
6208 check_arg_idx(curwin); | |
6209 #ifdef FEAT_TITLE | |
6210 if (n != curwin->w_arg_idx_invalid) | |
6211 maketitle(); | |
6212 #endif | |
6213 } | |
6214 | |
6215 /* | |
6216 * if ":split file" worked, set alternate file name in old window to new | |
6217 * file | |
6218 */ | |
6219 if (old_curwin != NULL | |
6220 && *eap->arg != NUL | |
6221 && curwin != old_curwin | |
6222 && win_valid(old_curwin) | |
22 | 6223 && old_curwin->w_buffer != curbuf |
6224 && !cmdmod.keepalt) | |
7 | 6225 old_curwin->w_alt_fnum = curbuf->b_fnum; |
6226 | |
6227 ex_no_reprint = TRUE; | |
6228 } | |
6229 | |
6230 #ifndef FEAT_GUI | |
6231 /* | |
6232 * ":gui" and ":gvim" when there is no GUI. | |
6233 */ | |
6234 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6235 ex_nogui(exarg_T *eap) |
7 | 6236 { |
6237 eap->errmsg = e_nogvim; | |
6238 } | |
6239 #endif | |
6240 | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15866
diff
changeset
|
6241 #if defined(FEAT_GUI_MSWIN) && defined(FEAT_MENU) && defined(FEAT_TEAROFF) |
7 | 6242 static void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6243 ex_tearoff(exarg_T *eap) |
7 | 6244 { |
6245 gui_make_tearoff(eap->arg); | |
6246 } | |
6247 #endif | |
6248 | |
13392
d5347779fb20
patch 8.0.1570: can't use :popup for a menu in the terminal
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
6249 #if (defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_GTK) \ |
d5347779fb20
patch 8.0.1570: can't use :popup for a menu in the terminal
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
6250 || defined(FEAT_TERM_POPUP_MENU)) && defined(FEAT_MENU) |
7 | 6251 static void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6252 ex_popup(exarg_T *eap) |
7 | 6253 { |
13392
d5347779fb20
patch 8.0.1570: can't use :popup for a menu in the terminal
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
6254 # if defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_GTK) |
d5347779fb20
patch 8.0.1570: can't use :popup for a menu in the terminal
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
6255 if (gui.in_use) |
d5347779fb20
patch 8.0.1570: can't use :popup for a menu in the terminal
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
6256 gui_make_popup(eap->arg, eap->forceit); |
d5347779fb20
patch 8.0.1570: can't use :popup for a menu in the terminal
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
6257 # ifdef FEAT_TERM_POPUP_MENU |
d5347779fb20
patch 8.0.1570: can't use :popup for a menu in the terminal
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
6258 else |
d5347779fb20
patch 8.0.1570: can't use :popup for a menu in the terminal
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
6259 # endif |
d5347779fb20
patch 8.0.1570: can't use :popup for a menu in the terminal
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
6260 # endif |
d5347779fb20
patch 8.0.1570: can't use :popup for a menu in the terminal
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
6261 # ifdef FEAT_TERM_POPUP_MENU |
d5347779fb20
patch 8.0.1570: can't use :popup for a menu in the terminal
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
6262 pum_make_popup(eap->arg, eap->forceit); |
d5347779fb20
patch 8.0.1570: can't use :popup for a menu in the terminal
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
6263 # endif |
7 | 6264 } |
6265 #endif | |
6266 | |
6267 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6268 ex_swapname(exarg_T *eap UNUSED) |
7 | 6269 { |
6270 if (curbuf->b_ml.ml_mfp == NULL || curbuf->b_ml.ml_mfp->mf_fname == NULL) | |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15510
diff
changeset
|
6271 msg(_("No swap file")); |
7 | 6272 else |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15510
diff
changeset
|
6273 msg((char *)curbuf->b_ml.ml_mfp->mf_fname); |
7 | 6274 } |
6275 | |
6276 /* | |
6277 * ":syncbind" forces all 'scrollbind' windows to have the same relative | |
6278 * offset. | |
6279 * (1998-11-02 16:21:01 R. Edward Ralston <eralston@computer.org>) | |
6280 */ | |
6281 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6282 ex_syncbind(exarg_T *eap UNUSED) |
7 | 6283 { |
6284 win_T *wp; | |
5566 | 6285 win_T *save_curwin = curwin; |
6286 buf_T *save_curbuf = curbuf; | |
7 | 6287 long topline; |
6288 long y; | |
6289 linenr_T old_linenr = curwin->w_cursor.lnum; | |
6290 | |
6291 setpcmark(); | |
6292 | |
6293 /* | |
6294 * determine max topline | |
6295 */ | |
6296 if (curwin->w_p_scb) | |
6297 { | |
6298 topline = curwin->w_topline; | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9538
diff
changeset
|
6299 FOR_ALL_WINDOWS(wp) |
7 | 6300 { |
6301 if (wp->w_p_scb && wp->w_buffer) | |
6302 { | |
15713
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15663
diff
changeset
|
6303 y = wp->w_buffer->b_ml.ml_line_count - get_scrolloff_value(); |
7 | 6304 if (topline > y) |
6305 topline = y; | |
6306 } | |
6307 } | |
6308 if (topline < 1) | |
6309 topline = 1; | |
6310 } | |
6311 else | |
6312 { | |
6313 topline = 1; | |
6314 } | |
6315 | |
6316 | |
6317 /* | |
5566 | 6318 * Set all scrollbind windows to the same topline. |
7 | 6319 */ |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9538
diff
changeset
|
6320 FOR_ALL_WINDOWS(curwin) |
7 | 6321 { |
6322 if (curwin->w_p_scb) | |
6323 { | |
5566 | 6324 curbuf = curwin->w_buffer; |
7 | 6325 y = topline - curwin->w_topline; |
6326 if (y > 0) | |
6327 scrollup(y, TRUE); | |
6328 else | |
6329 scrolldown(-y, TRUE); | |
6330 curwin->w_scbind_pos = topline; | |
6331 redraw_later(VALID); | |
6332 cursor_correct(); | |
6333 curwin->w_redr_status = TRUE; | |
6334 } | |
6335 } | |
5566 | 6336 curwin = save_curwin; |
6337 curbuf = save_curbuf; | |
7 | 6338 if (curwin->w_p_scb) |
6339 { | |
6340 did_syncbind = TRUE; | |
6341 checkpcmark(); | |
6342 if (old_linenr != curwin->w_cursor.lnum) | |
6343 { | |
6344 char_u ctrl_o[2]; | |
6345 | |
6346 ctrl_o[0] = Ctrl_O; | |
6347 ctrl_o[1] = 0; | |
6348 ins_typebuf(ctrl_o, REMAP_NONE, 0, TRUE, FALSE); | |
6349 } | |
6350 } | |
6351 } | |
6352 | |
6353 | |
6354 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6355 ex_read(exarg_T *eap) |
7 | 6356 { |
167 | 6357 int i; |
6358 int empty = (curbuf->b_ml.ml_flags & ML_EMPTY); | |
6359 linenr_T lnum; | |
7 | 6360 |
6361 if (eap->usefilter) /* :r!cmd */ | |
6362 do_bang(1, eap, FALSE, FALSE, TRUE); | |
6363 else | |
6364 { | |
6365 if (u_save(eap->line2, (linenr_T)(eap->line2 + 1)) == FAIL) | |
6366 return; | |
6367 | |
6368 #ifdef FEAT_BROWSE | |
6369 if (cmdmod.browse) | |
6370 { | |
6371 char_u *browseFile; | |
6372 | |
28 | 6373 browseFile = do_browse(0, (char_u *)_("Append File"), eap->arg, |
7 | 6374 NULL, NULL, NULL, curbuf); |
6375 if (browseFile != NULL) | |
6376 { | |
6377 i = readfile(browseFile, NULL, | |
6378 eap->line2, (linenr_T)0, (linenr_T)MAXLNUM, eap, 0); | |
6379 vim_free(browseFile); | |
6380 } | |
6381 else | |
6382 i = OK; | |
6383 } | |
6384 else | |
6385 #endif | |
6386 if (*eap->arg == NUL) | |
6387 { | |
6388 if (check_fname() == FAIL) /* check for no file name */ | |
6389 return; | |
6390 i = readfile(curbuf->b_ffname, curbuf->b_fname, | |
6391 eap->line2, (linenr_T)0, (linenr_T)MAXLNUM, eap, 0); | |
6392 } | |
6393 else | |
6394 { | |
6395 if (vim_strchr(p_cpo, CPO_ALTREAD) != NULL) | |
6396 (void)setaltfname(eap->arg, eap->arg, (linenr_T)1); | |
6397 i = readfile(eap->arg, NULL, | |
6398 eap->line2, (linenr_T)0, (linenr_T)MAXLNUM, eap, 0); | |
6399 | |
6400 } | |
10575
01a5f64a7a20
patch 8.0.0177: BufEnter autocommand not fired for a directory
Christian Brabandt <cb@256bit.org>
parents:
10520
diff
changeset
|
6401 if (i != OK) |
7 | 6402 { |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
6403 #if defined(FEAT_EVAL) |
7 | 6404 if (!aborting()) |
6405 #endif | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
6406 semsg(_(e_notopen), eap->arg); |
7 | 6407 } |
6408 else | |
167 | 6409 { |
6410 if (empty && exmode_active) | |
6411 { | |
6412 /* Delete the empty line that remains. Historically ex does | |
6413 * this but vi doesn't. */ | |
6414 if (eap->line2 == 0) | |
6415 lnum = curbuf->b_ml.ml_line_count; | |
6416 else | |
6417 lnum = 1; | |
573 | 6418 if (*ml_get(lnum) == NUL && u_savedel(lnum, 1L) == OK) |
167 | 6419 { |
6420 ml_delete(lnum, FALSE); | |
573 | 6421 if (curwin->w_cursor.lnum > 1 |
6422 && curwin->w_cursor.lnum >= lnum) | |
167 | 6423 --curwin->w_cursor.lnum; |
1929 | 6424 deleted_lines_mark(lnum, 1L); |
167 | 6425 } |
6426 } | |
7 | 6427 redraw_curbuf_later(VALID); |
167 | 6428 } |
7 | 6429 } |
6430 } | |
6431 | |
358 | 6432 static char_u *prev_dir = NULL; |
6433 | |
6434 #if defined(EXITFREE) || defined(PROTO) | |
6435 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6436 free_cd_dir(void) |
358 | 6437 { |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13221
diff
changeset
|
6438 VIM_CLEAR(prev_dir); |
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13221
diff
changeset
|
6439 VIM_CLEAR(globaldir); |
358 | 6440 } |
6441 #endif | |
6442 | |
4704
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
6443 /* |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
6444 * Deal with the side effects of changing the current directory. |
16576
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6445 * When 'scope' is CDSCOPE_TABPAGE then this was after an ":tcd" command. |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6446 * When 'scope' is CDSCOPE_WINDOW then this was after an ":lcd" command. |
4704
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
6447 */ |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
6448 void |
16576
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6449 post_chdir(cdscope_T scope) |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6450 { |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6451 if (scope != CDSCOPE_WINDOW) |
16427
8c3a1bd270bb
patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents:
16411
diff
changeset
|
6452 // Clear tab local directory for both :cd and :tcd |
8c3a1bd270bb
patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents:
16411
diff
changeset
|
6453 VIM_CLEAR(curtab->tp_localdir); |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13221
diff
changeset
|
6454 VIM_CLEAR(curwin->w_localdir); |
16576
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6455 if (scope != CDSCOPE_GLOBAL) |
4704
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
6456 { |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
6457 /* If still in global directory, need to remember current |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
6458 * directory as global directory. */ |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
6459 if (globaldir == NULL && prev_dir != NULL) |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
6460 globaldir = vim_strsave(prev_dir); |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
6461 /* Remember this local directory for the window. */ |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
6462 if (mch_dirname(NameBuff, MAXPATHL) == OK) |
16427
8c3a1bd270bb
patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents:
16411
diff
changeset
|
6463 { |
16576
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6464 if (scope == CDSCOPE_TABPAGE) |
16427
8c3a1bd270bb
patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents:
16411
diff
changeset
|
6465 curtab->tp_localdir = vim_strsave(NameBuff); |
8c3a1bd270bb
patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents:
16411
diff
changeset
|
6466 else |
8c3a1bd270bb
patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents:
16411
diff
changeset
|
6467 curwin->w_localdir = vim_strsave(NameBuff); |
8c3a1bd270bb
patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents:
16411
diff
changeset
|
6468 } |
4704
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
6469 } |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
6470 else |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
6471 { |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
6472 /* We are now in the global directory, no need to remember its |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
6473 * name. */ |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13221
diff
changeset
|
6474 VIM_CLEAR(globaldir); |
4704
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
6475 } |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
6476 |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
6477 shorten_fnames(TRUE); |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
6478 } |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
6479 |
16576
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6480 /* |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6481 * Change directory function used by :cd/:tcd/:lcd Ex commands and the |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6482 * chdir() function. If 'winlocaldir' is TRUE, then changes the window-local |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6483 * directory. If 'tablocaldir' is TRUE, then changes the tab-local directory. |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6484 * Otherwise changes the global directory. |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6485 * Returns TRUE if the directory is successfully changed. |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6486 */ |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6487 int |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6488 changedir_func( |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6489 char_u *new_dir, |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6490 int forceit, |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6491 cdscope_T scope) |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6492 { |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6493 char_u *tofree; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6494 int dir_differs; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6495 int retval = FALSE; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6496 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6497 if (allbuf_locked()) |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6498 return FALSE; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6499 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6500 if (vim_strchr(p_cpo, CPO_CHDIR) != NULL && curbufIsChanged() && !forceit) |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6501 { |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6502 emsg(_("E747: Cannot change directory, buffer is modified (add ! to override)")); |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6503 return FALSE; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6504 } |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6505 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6506 // ":cd -": Change to previous directory |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6507 if (STRCMP(new_dir, "-") == 0) |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6508 { |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6509 if (prev_dir == NULL) |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6510 { |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6511 emsg(_("E186: No previous directory")); |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6512 return FALSE; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6513 } |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6514 new_dir = prev_dir; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6515 } |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6516 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6517 // Save current directory for next ":cd -" |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6518 tofree = prev_dir; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6519 if (mch_dirname(NameBuff, MAXPATHL) == OK) |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6520 prev_dir = vim_strsave(NameBuff); |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6521 else |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6522 prev_dir = NULL; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6523 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6524 #if defined(UNIX) || defined(VMS) |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6525 // for UNIX ":cd" means: go to home directory |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6526 if (*new_dir == NUL) |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6527 { |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6528 // use NameBuff for home directory name |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6529 # ifdef VMS |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6530 char_u *p; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6531 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6532 p = mch_getenv((char_u *)"SYS$LOGIN"); |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6533 if (p == NULL || *p == NUL) // empty is the same as not set |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6534 NameBuff[0] = NUL; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6535 else |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6536 vim_strncpy(NameBuff, p, MAXPATHL - 1); |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6537 # else |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6538 expand_env((char_u *)"$HOME", NameBuff, MAXPATHL); |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6539 # endif |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6540 new_dir = NameBuff; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6541 } |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6542 #endif |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6543 dir_differs = new_dir == NULL || prev_dir == NULL |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6544 || pathcmp((char *)prev_dir, (char *)new_dir, -1) != 0; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6545 if (new_dir == NULL || (dir_differs && vim_chdir(new_dir))) |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6546 emsg(_(e_failed)); |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6547 else |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6548 { |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6549 char_u *acmd_fname; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6550 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6551 post_chdir(scope); |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6552 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6553 if (dir_differs) |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6554 { |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6555 if (scope == CDSCOPE_WINDOW) |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6556 acmd_fname = (char_u *)"window"; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6557 else if (scope == CDSCOPE_TABPAGE) |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6558 acmd_fname = (char_u *)"tabpage"; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6559 else |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6560 acmd_fname = (char_u *)"global"; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6561 apply_autocmds(EVENT_DIRCHANGED, acmd_fname, new_dir, FALSE, |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6562 curbuf); |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6563 } |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6564 retval = TRUE; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6565 } |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6566 vim_free(tofree); |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6567 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6568 return retval; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6569 } |
358 | 6570 |
7 | 6571 /* |
16427
8c3a1bd270bb
patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents:
16411
diff
changeset
|
6572 * ":cd", ":tcd", ":lcd", ":chdir" ":tchdir" and ":lchdir". |
7 | 6573 */ |
1411 | 6574 void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6575 ex_cd(exarg_T *eap) |
7 | 6576 { |
15184
90ab2d3ce11d
patch 8.1.0602: DirChanged is also triggered when directory didn't change
Bram Moolenaar <Bram@vim.org>
parents:
15152
diff
changeset
|
6577 char_u *new_dir; |
7 | 6578 |
6579 new_dir = eap->arg; | |
6580 #if !defined(UNIX) && !defined(VMS) | |
16576
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6581 // for non-UNIX ":cd" means: print current directory |
7 | 6582 if (*new_dir == NUL) |
6583 ex_pwd(NULL); | |
6584 else | |
6585 #endif | |
6586 { | |
16576
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6587 cdscope_T scope = CDSCOPE_GLOBAL; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6588 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6589 if (eap->cmdidx == CMD_lcd || eap->cmdidx == CMD_lchdir) |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6590 scope = CDSCOPE_WINDOW; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6591 else if (eap->cmdidx == CMD_tcd || eap->cmdidx == CMD_tchdir) |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6592 scope = CDSCOPE_TABPAGE; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6593 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6594 if (changedir_func(new_dir, eap->forceit, scope)) |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6595 { |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6596 // Echo the new current directory if the command was typed. |
1930 | 6597 if (KeyTyped || p_verbose >= 5) |
7 | 6598 ex_pwd(eap); |
16576
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6599 } |
7 | 6600 } |
6601 } | |
6602 | |
6603 /* | |
6604 * ":pwd". | |
6605 */ | |
6606 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6607 ex_pwd(exarg_T *eap UNUSED) |
7 | 6608 { |
6609 if (mch_dirname(NameBuff, MAXPATHL) == OK) | |
6610 { | |
6611 #ifdef BACKSLASH_IN_FILENAME | |
6612 slash_adjust(NameBuff); | |
6613 #endif | |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15510
diff
changeset
|
6614 msg((char *)NameBuff); |
7 | 6615 } |
6616 else | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
6617 emsg(_("E187: Unknown")); |
7 | 6618 } |
6619 | |
6620 /* | |
6621 * ":=". | |
6622 */ | |
6623 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6624 ex_equal(exarg_T *eap) |
7 | 6625 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
6626 smsg("%ld", (long)eap->line2); |
167 | 6627 ex_may_print(eap); |
7 | 6628 } |
6629 | |
6630 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6631 ex_sleep(exarg_T *eap) |
7 | 6632 { |
236 | 6633 int n; |
6634 long len; | |
7 | 6635 |
6636 if (cursor_valid()) | |
6637 { | |
6638 n = W_WINROW(curwin) + curwin->w_wrow - msg_scrolled; | |
6639 if (n >= 0) | |
12513
3ca08bf99396
patch 8.0.1135: W_WINCOL() is always the same
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
6640 windgoto((int)n, curwin->w_wincol + curwin->w_wcol); |
7 | 6641 } |
236 | 6642 |
6643 len = eap->line2; | |
6644 switch (*eap->arg) | |
6645 { | |
6646 case 'm': break; | |
6647 case NUL: len *= 1000L; break; | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
6648 default: semsg(_(e_invarg2), eap->arg); return; |
236 | 6649 } |
6650 do_sleep(len); | |
7 | 6651 } |
6652 | |
6653 /* | |
6654 * Sleep for "msec" milliseconds, but keep checking for a CTRL-C every second. | |
6655 */ | |
6656 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6657 do_sleep(long msec) |
7 | 6658 { |
17712
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
6659 long done = 0; |
8577
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
6660 long wait_now; |
17712
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
6661 # ifdef ELAPSED_FUNC |
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
6662 elapsed_T start_tv; |
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
6663 |
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
6664 // Remember at what time we started, so that we know how much longer we |
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
6665 // should wait after waiting for a bit. |
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
6666 ELAPSED_INIT(start_tv); |
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
6667 # endif |
7 | 6668 |
6669 cursor_on(); | |
14860
ac5d0d27aef9
patch 8.1.0442: GUI: cursor not drawn after ":redraw | sleep"
Christian Brabandt <cb@256bit.org>
parents:
14760
diff
changeset
|
6670 out_flush_cursor(FALSE, FALSE); |
17712
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
6671 while (!got_int && done < msec) |
8577
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
6672 { |
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
6673 wait_now = msec - done > 1000L ? 1000L : msec - done; |
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
6674 #ifdef FEAT_TIMERS |
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
6675 { |
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
6676 long due_time = check_due_timer(); |
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
6677 |
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
6678 if (due_time > 0 && due_time < wait_now) |
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
6679 wait_now = due_time; |
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
6680 } |
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
6681 #endif |
10240
175b1116f96a
commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents:
10184
diff
changeset
|
6682 #ifdef FEAT_JOB_CHANNEL |
17708
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17652
diff
changeset
|
6683 if (has_any_channel() && wait_now > 20L) |
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17652
diff
changeset
|
6684 wait_now = 20L; |
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17652
diff
changeset
|
6685 #endif |
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17652
diff
changeset
|
6686 #ifdef FEAT_SOUND |
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17652
diff
changeset
|
6687 if (has_any_sound_callback() && wait_now > 20L) |
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17652
diff
changeset
|
6688 wait_now = 20L; |
10240
175b1116f96a
commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents:
10184
diff
changeset
|
6689 #endif |
8577
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
6690 ui_delay(wait_now, TRUE); |
17712
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
6691 |
10240
175b1116f96a
commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents:
10184
diff
changeset
|
6692 #ifdef FEAT_JOB_CHANNEL |
175b1116f96a
commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents:
10184
diff
changeset
|
6693 if (has_any_channel()) |
175b1116f96a
commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents:
10184
diff
changeset
|
6694 ui_breakcheck_force(TRUE); |
175b1116f96a
commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents:
10184
diff
changeset
|
6695 else |
175b1116f96a
commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents:
10184
diff
changeset
|
6696 #endif |
175b1116f96a
commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents:
10184
diff
changeset
|
6697 ui_breakcheck(); |
7109
fa95595fbc52
commit https://github.com/vim/vim/commit/93c88e0f6a4a8f7634ed84721daf4af46fc0d5db
Christian Brabandt <cb@256bit.org>
parents:
7105
diff
changeset
|
6698 #ifdef MESSAGE_QUEUE |
17712
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
6699 // Process the netbeans and clientserver messages that may have been |
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
6700 // received in the call to ui_breakcheck() when the GUI is in use. This |
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
6701 // may occur when running a test case. |
7109
fa95595fbc52
commit https://github.com/vim/vim/commit/93c88e0f6a4a8f7634ed84721daf4af46fc0d5db
Christian Brabandt <cb@256bit.org>
parents:
7105
diff
changeset
|
6702 parse_queued_messages(); |
3151 | 6703 #endif |
17712
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
6704 |
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
6705 # ifdef ELAPSED_FUNC |
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
6706 // actual time passed |
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
6707 done = ELAPSED_FUNC(start_tv); |
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
6708 # else |
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
6709 // guestimate time passed (will actually be more) |
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
6710 done += wait_now; |
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
6711 # endif |
7 | 6712 } |
14284
7cd8298c4c04
patch 8.1.0158: GUI: input() fails if CTRL-C was pressed before
Christian Brabandt <cb@256bit.org>
parents:
14266
diff
changeset
|
6713 |
7cd8298c4c04
patch 8.1.0158: GUI: input() fails if CTRL-C was pressed before
Christian Brabandt <cb@256bit.org>
parents:
14266
diff
changeset
|
6714 // If CTRL-C was typed to interrupt the sleep, drop the CTRL-C from the |
7cd8298c4c04
patch 8.1.0158: GUI: input() fails if CTRL-C was pressed before
Christian Brabandt <cb@256bit.org>
parents:
14266
diff
changeset
|
6715 // input buffer, otherwise a following call to input() fails. |
7cd8298c4c04
patch 8.1.0158: GUI: input() fails if CTRL-C was pressed before
Christian Brabandt <cb@256bit.org>
parents:
14266
diff
changeset
|
6716 if (got_int) |
7cd8298c4c04
patch 8.1.0158: GUI: input() fails if CTRL-C was pressed before
Christian Brabandt <cb@256bit.org>
parents:
14266
diff
changeset
|
6717 (void)vpeekc(); |
7 | 6718 } |
6719 | |
6720 /* | |
6721 * ":winsize" command (obsolete). | |
6722 */ | |
6723 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6724 ex_winsize(exarg_T *eap) |
7 | 6725 { |
6726 int w, h; | |
6727 char_u *arg = eap->arg; | |
6728 char_u *p; | |
6729 | |
6730 w = getdigits(&arg); | |
6731 arg = skipwhite(arg); | |
6732 p = arg; | |
6733 h = getdigits(&arg); | |
6734 if (*p != NUL && *arg == NUL) | |
6735 set_shellsize(w, h, TRUE); | |
6736 else | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
6737 emsg(_("E465: :winsize requires two number arguments")); |
7 | 6738 } |
6739 | |
6740 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6741 ex_wincmd(exarg_T *eap) |
7 | 6742 { |
6743 int xchar = NUL; | |
6744 char_u *p; | |
6745 | |
6746 if (*eap->arg == 'g' || *eap->arg == Ctrl_G) | |
6747 { | |
6748 /* CTRL-W g and CTRL-W CTRL-G have an extra command character */ | |
6749 if (eap->arg[1] == NUL) | |
6750 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
6751 emsg(_(e_invarg)); |
7 | 6752 return; |
6753 } | |
6754 xchar = eap->arg[1]; | |
6755 p = eap->arg + 2; | |
6756 } | |
6757 else | |
6758 p = eap->arg + 1; | |
6759 | |
6760 eap->nextcmd = check_nextcmd(p); | |
6761 p = skipwhite(p); | |
6762 if (*p != NUL && *p != '"' && eap->nextcmd == NULL) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
6763 emsg(_(e_invarg)); |
2887 | 6764 else if (!eap->skip) |
7 | 6765 { |
6766 /* Pass flags on for ":vertical wincmd ]". */ | |
6767 postponed_split_flags = cmdmod.split; | |
1090 | 6768 postponed_split_tab = cmdmod.tab; |
7 | 6769 do_window(*eap->arg, eap->addr_count > 0 ? eap->line2 : 0L, xchar); |
6770 postponed_split_flags = 0; | |
1090 | 6771 postponed_split_tab = 0; |
7 | 6772 } |
6773 } | |
6774 | |
11 | 6775 #if defined(FEAT_GUI) || defined(UNIX) || defined(VMS) || defined(MSWIN) |
7 | 6776 /* |
6777 * ":winpos". | |
6778 */ | |
6779 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6780 ex_winpos(exarg_T *eap) |
7 | 6781 { |
6782 int x, y; | |
6783 char_u *arg = eap->arg; | |
6784 char_u *p; | |
6785 | |
6786 if (*arg == NUL) | |
6787 { | |
11 | 6788 # if defined(FEAT_GUI) || defined(MSWIN) |
16451
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16427
diff
changeset
|
6789 # ifdef VIMDLL |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16427
diff
changeset
|
6790 if (gui.in_use ? gui_mch_get_winpos(&x, &y) != FAIL : |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16427
diff
changeset
|
6791 mch_get_winpos(&x, &y) != FAIL) |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16427
diff
changeset
|
6792 # elif defined(FEAT_GUI) |
7 | 6793 if (gui.in_use && gui_mch_get_winpos(&x, &y) != FAIL) |
11 | 6794 # else |
6795 if (mch_get_winpos(&x, &y) != FAIL) | |
6796 # endif | |
7 | 6797 { |
6798 sprintf((char *)IObuff, _("Window position: X %d, Y %d"), x, y); | |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15510
diff
changeset
|
6799 msg((char *)IObuff); |
7 | 6800 } |
6801 else | |
6802 # endif | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
6803 emsg(_("E188: Obtaining window position not implemented for this platform")); |
7 | 6804 } |
6805 else | |
6806 { | |
6807 x = getdigits(&arg); | |
6808 arg = skipwhite(arg); | |
6809 p = arg; | |
6810 y = getdigits(&arg); | |
6811 if (*p == NUL || *arg != NUL) | |
6812 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
6813 emsg(_("E466: :winpos requires two number arguments")); |
7 | 6814 return; |
6815 } | |
6816 # ifdef FEAT_GUI | |
6817 if (gui.in_use) | |
6818 gui_mch_set_winpos(x, y); | |
6819 else if (gui.starting) | |
6820 { | |
6821 /* Remember the coordinates for when the window is opened. */ | |
6822 gui_win_x = x; | |
6823 gui_win_y = y; | |
6824 } | |
16451
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16427
diff
changeset
|
6825 # if defined(HAVE_TGETENT) || defined(VIMDLL) |
7 | 6826 else |
6827 # endif | |
16451
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16427
diff
changeset
|
6828 # endif |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16427
diff
changeset
|
6829 # if defined(MSWIN) && (!defined(FEAT_GUI) || defined(VIMDLL)) |
11 | 6830 mch_set_winpos(x, y); |
7 | 6831 # endif |
6832 # ifdef HAVE_TGETENT | |
6833 if (*T_CWP) | |
6834 term_set_winpos(x, y); | |
6835 # endif | |
6836 } | |
6837 } | |
6838 #endif | |
6839 | |
6840 /* | |
6841 * Handle command that work like operators: ":delete", ":yank", ":>" and ":<". | |
6842 */ | |
6843 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6844 ex_operators(exarg_T *eap) |
7 | 6845 { |
6846 oparg_T oa; | |
6847 | |
6848 clear_oparg(&oa); | |
6849 oa.regname = eap->regname; | |
6850 oa.start.lnum = eap->line1; | |
6851 oa.end.lnum = eap->line2; | |
6852 oa.line_count = eap->line2 - eap->line1 + 1; | |
6853 oa.motion_type = MLINE; | |
6854 virtual_op = FALSE; | |
6855 if (eap->cmdidx != CMD_yank) /* position cursor for undo */ | |
6856 { | |
6857 setpcmark(); | |
6858 curwin->w_cursor.lnum = eap->line1; | |
6859 beginline(BL_SOL | BL_FIX); | |
6860 } | |
6861 | |
5498 | 6862 if (VIsual_active) |
6863 end_visual_mode(); | |
6864 | |
7 | 6865 switch (eap->cmdidx) |
6866 { | |
6867 case CMD_delete: | |
6868 oa.op_type = OP_DELETE; | |
6869 op_delete(&oa); | |
6870 break; | |
6871 | |
6872 case CMD_yank: | |
6873 oa.op_type = OP_YANK; | |
6874 (void)op_yank(&oa, FALSE, TRUE); | |
6875 break; | |
6876 | |
6877 default: /* CMD_rshift or CMD_lshift */ | |
4889
25d64a4edc0b
updated for version 7.3.1190
Bram Moolenaar <bram@vim.org>
parents:
4857
diff
changeset
|
6878 if ( |
7 | 6879 #ifdef FEAT_RIGHTLEFT |
4889
25d64a4edc0b
updated for version 7.3.1190
Bram Moolenaar <bram@vim.org>
parents:
4857
diff
changeset
|
6880 (eap->cmdidx == CMD_rshift) ^ curwin->w_p_rl |
25d64a4edc0b
updated for version 7.3.1190
Bram Moolenaar <bram@vim.org>
parents:
4857
diff
changeset
|
6881 #else |
25d64a4edc0b
updated for version 7.3.1190
Bram Moolenaar <bram@vim.org>
parents:
4857
diff
changeset
|
6882 eap->cmdidx == CMD_rshift |
25d64a4edc0b
updated for version 7.3.1190
Bram Moolenaar <bram@vim.org>
parents:
4857
diff
changeset
|
6883 #endif |
25d64a4edc0b
updated for version 7.3.1190
Bram Moolenaar <bram@vim.org>
parents:
4857
diff
changeset
|
6884 ) |
7 | 6885 oa.op_type = OP_RSHIFT; |
6886 else | |
6887 oa.op_type = OP_LSHIFT; | |
6888 op_shift(&oa, FALSE, eap->amount); | |
6889 break; | |
6890 } | |
6891 virtual_op = MAYBE; | |
167 | 6892 ex_may_print(eap); |
7 | 6893 } |
6894 | |
6895 /* | |
6896 * ":put". | |
6897 */ | |
6898 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6899 ex_put(exarg_T *eap) |
7 | 6900 { |
6901 /* ":0put" works like ":1put!". */ | |
6902 if (eap->line2 == 0) | |
6903 { | |
6904 eap->line2 = 1; | |
6905 eap->forceit = TRUE; | |
6906 } | |
6907 curwin->w_cursor.lnum = eap->line2; | |
167 | 6908 do_put(eap->regname, eap->forceit ? BACKWARD : FORWARD, 1L, |
6909 PUT_LINE|PUT_CURSLINE); | |
7 | 6910 } |
6911 | |
6912 /* | |
6913 * Handle ":copy" and ":move". | |
6914 */ | |
6915 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6916 ex_copymove(exarg_T *eap) |
7 | 6917 { |
6918 long n; | |
6919 | |
14760
fd69edd2c67e
patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents:
14700
diff
changeset
|
6920 n = get_address(eap, &eap->arg, eap->addr_type, FALSE, FALSE, FALSE, 1); |
7 | 6921 if (eap->arg == NULL) /* error detected */ |
6922 { | |
6923 eap->nextcmd = NULL; | |
6924 return; | |
6925 } | |
167 | 6926 get_flags(eap); |
7 | 6927 |
6928 /* | |
6929 * move or copy lines from 'eap->line1'-'eap->line2' to below line 'n' | |
6930 */ | |
6931 if (n == MAXLNUM || n < 0 || n > curbuf->b_ml.ml_line_count) | |
6932 { | |
17650
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
6933 emsg(_(e_invrange)); |
7 | 6934 return; |
6935 } | |
6936 | |
6937 if (eap->cmdidx == CMD_move) | |
6938 { | |
6939 if (do_move(eap->line1, eap->line2, n) == FAIL) | |
6940 return; | |
6941 } | |
6942 else | |
6943 ex_copy(eap->line1, eap->line2, n); | |
6944 u_clearline(); | |
6945 beginline(BL_SOL | BL_FIX); | |
167 | 6946 ex_may_print(eap); |
6947 } | |
6948 | |
6949 /* | |
6950 * Print the current line if flags were given to the Ex command. | |
6951 */ | |
5776 | 6952 void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6953 ex_may_print(exarg_T *eap) |
167 | 6954 { |
6955 if (eap->flags != 0) | |
6956 { | |
6957 print_line(curwin->w_cursor.lnum, (eap->flags & EXFLAG_NR), | |
6958 (eap->flags & EXFLAG_LIST)); | |
6959 ex_no_reprint = TRUE; | |
6960 } | |
7 | 6961 } |
6962 | |
6963 /* | |
6964 * ":smagic" and ":snomagic". | |
6965 */ | |
6966 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6967 ex_submagic(exarg_T *eap) |
7 | 6968 { |
6969 int magic_save = p_magic; | |
6970 | |
6971 p_magic = (eap->cmdidx == CMD_smagic); | |
6972 do_sub(eap); | |
6973 p_magic = magic_save; | |
6974 } | |
6975 | |
6976 /* | |
6977 * ":join". | |
6978 */ | |
6979 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6980 ex_join(exarg_T *eap) |
7 | 6981 { |
6982 curwin->w_cursor.lnum = eap->line1; | |
6983 if (eap->line1 == eap->line2) | |
6984 { | |
6985 if (eap->addr_count >= 2) /* :2,2join does nothing */ | |
6986 return; | |
6987 if (eap->line2 == curbuf->b_ml.ml_line_count) | |
6988 { | |
6989 beep_flush(); | |
6990 return; | |
6991 } | |
6992 ++eap->line2; | |
6993 } | |
5848 | 6994 (void)do_join(eap->line2 - eap->line1 + 1, !eap->forceit, TRUE, TRUE, TRUE); |
7 | 6995 beginline(BL_WHITE | BL_FIX); |
167 | 6996 ex_may_print(eap); |
7 | 6997 } |
6998 | |
6999 /* | |
7000 * ":[addr]@r" or ":[addr]*r": execute register | |
7001 */ | |
7002 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7003 ex_at(exarg_T *eap) |
7 | 7004 { |
7005 int c; | |
1973 | 7006 int prev_len = typebuf.tb_len; |
7 | 7007 |
7008 curwin->w_cursor.lnum = eap->line2; | |
10184
4669440016f2
commit https://github.com/vim/vim/commit/4930a76a0357f76a829eafe4985d04cf3ce0e9e0
Christian Brabandt <cb@256bit.org>
parents:
10106
diff
changeset
|
7009 check_cursor_col(); |
7 | 7010 |
7011 #ifdef USE_ON_FLY_SCROLL | |
7012 dont_scroll = TRUE; /* disallow scrolling here */ | |
7013 #endif | |
7014 | |
7015 /* get the register name. No name means to use the previous one */ | |
7016 c = *eap->arg; | |
7017 if (c == NUL || (c == '*' && *eap->cmd == '*')) | |
7018 c = '@'; | |
1034 | 7019 /* Put the register in the typeahead buffer with the "silent" flag. */ |
7020 if (do_execreg(c, TRUE, vim_strchr(p_cpo, CPO_EXECBUF) != NULL, TRUE) | |
7021 == FAIL) | |
167 | 7022 { |
7 | 7023 beep_flush(); |
167 | 7024 } |
7 | 7025 else |
7026 { | |
7027 int save_efr = exec_from_reg; | |
7028 | |
7029 exec_from_reg = TRUE; | |
7030 | |
7031 /* | |
7032 * Execute from the typeahead buffer. | |
1973 | 7033 * Continue until the stuff buffer is empty and all added characters |
7034 * have been consumed. | |
7 | 7035 */ |
1973 | 7036 while (!stuff_empty() || typebuf.tb_len > prev_len) |
7 | 7037 (void)do_cmdline(NULL, getexline, NULL, DOCMD_NOWAIT|DOCMD_VERBOSE); |
7038 | |
7039 exec_from_reg = save_efr; | |
7040 } | |
7041 } | |
7042 | |
7043 /* | |
7044 * ":!". | |
7045 */ | |
7046 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7047 ex_bang(exarg_T *eap) |
7 | 7048 { |
7049 do_bang(eap->addr_count, eap, eap->forceit, TRUE, TRUE); | |
7050 } | |
7051 | |
7052 /* | |
7053 * ":undo". | |
7054 */ | |
7055 static void | |
8368
db2a07b710ed
commit https://github.com/vim/vim/commit/f1d2501ebe33e148886c2914acd33140e20ee222
Christian Brabandt <cb@256bit.org>
parents:
8281
diff
changeset
|
7056 ex_undo(exarg_T *eap) |
7 | 7057 { |
771 | 7058 if (eap->addr_count == 1) /* :undo 123 */ |
2281
e41433ea71df
Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents:
2276
diff
changeset
|
7059 undo_time(eap->line2, FALSE, FALSE, TRUE); |
771 | 7060 else |
7061 u_undo(1); | |
7 | 7062 } |
7063 | |
2214
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
7064 #ifdef FEAT_PERSISTENT_UNDO |
2340
99c1eba60b2d
Make automatic prototype generation work with more interfaces.
Bram Moolenaar <bram@vim.org>
parents:
2333
diff
changeset
|
7065 static void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7066 ex_wundo(exarg_T *eap) |
2214
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
7067 { |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
7068 char_u hash[UNDO_HASH_SIZE]; |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
7069 |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
7070 u_compute_hash(hash); |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
7071 u_write_undo(eap->arg, eap->forceit, curbuf, hash); |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
7072 } |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
7073 |
2340
99c1eba60b2d
Make automatic prototype generation work with more interfaces.
Bram Moolenaar <bram@vim.org>
parents:
2333
diff
changeset
|
7074 static void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7075 ex_rundo(exarg_T *eap) |
2214
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
7076 { |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
7077 char_u hash[UNDO_HASH_SIZE]; |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
7078 |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
7079 u_compute_hash(hash); |
2238
3d0a7beb0d75
Made reading/writing undo info a bit more robust.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
7080 u_read_undo(eap->arg, hash, NULL); |
2214
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
7081 } |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
7082 #endif |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
7083 |
7 | 7084 /* |
7085 * ":redo". | |
7086 */ | |
7087 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7088 ex_redo(exarg_T *eap UNUSED) |
7 | 7089 { |
7090 u_redo(1); | |
7091 } | |
7092 | |
7093 /* | |
756 | 7094 * ":earlier" and ":later". |
7095 */ | |
7096 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7097 ex_later(exarg_T *eap) |
756 | 7098 { |
7099 long count = 0; | |
7100 int sec = FALSE; | |
2281
e41433ea71df
Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents:
2276
diff
changeset
|
7101 int file = FALSE; |
756 | 7102 char_u *p = eap->arg; |
7103 | |
7104 if (*p == NUL) | |
7105 count = 1; | |
7106 else if (isdigit(*p)) | |
7107 { | |
7108 count = getdigits(&p); | |
7109 switch (*p) | |
7110 { | |
7111 case 's': ++p; sec = TRUE; break; | |
7112 case 'm': ++p; sec = TRUE; count *= 60; break; | |
7113 case 'h': ++p; sec = TRUE; count *= 60 * 60; break; | |
2281
e41433ea71df
Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents:
2276
diff
changeset
|
7114 case 'd': ++p; sec = TRUE; count *= 24 * 60 * 60; break; |
e41433ea71df
Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents:
2276
diff
changeset
|
7115 case 'f': ++p; file = TRUE; break; |
756 | 7116 } |
7117 } | |
7118 | |
7119 if (*p != NUL) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7120 semsg(_(e_invarg2), eap->arg); |
756 | 7121 else |
2281
e41433ea71df
Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents:
2276
diff
changeset
|
7122 undo_time(eap->cmdidx == CMD_earlier ? -count : count, |
e41433ea71df
Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents:
2276
diff
changeset
|
7123 sec, file, FALSE); |
756 | 7124 } |
7125 | |
7126 /* | |
7 | 7127 * ":redir": start/stop redirection. |
7128 */ | |
7129 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7130 ex_redir(exarg_T *eap) |
7 | 7131 { |
7132 char *mode; | |
7133 char_u *fname; | |
122 | 7134 char_u *arg = eap->arg; |
7 | 7135 |
9440
73c0d07cc15e
commit https://github.com/vim/vim/commit/ba768495c2e6bae74e49d22d489fbf211ecad55e
Christian Brabandt <cb@256bit.org>
parents:
9438
diff
changeset
|
7136 #ifdef FEAT_EVAL |
9454
9da0cb39cbee
commit https://github.com/vim/vim/commit/79815f1ec77406f2f21a618c053e5793b597db7a
Christian Brabandt <cb@256bit.org>
parents:
9440
diff
changeset
|
7137 if (redir_execute) |
9da0cb39cbee
commit https://github.com/vim/vim/commit/79815f1ec77406f2f21a618c053e5793b597db7a
Christian Brabandt <cb@256bit.org>
parents:
9440
diff
changeset
|
7138 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7139 emsg(_("E930: Cannot use :redir inside execute()")); |
9438
7897b1e4f3e7
commit https://github.com/vim/vim/commit/245a7cb6d33e556415c9fcaa874b784a6d8f0ef3
Christian Brabandt <cb@256bit.org>
parents:
9432
diff
changeset
|
7140 return; |
7897b1e4f3e7
commit https://github.com/vim/vim/commit/245a7cb6d33e556415c9fcaa874b784a6d8f0ef3
Christian Brabandt <cb@256bit.org>
parents:
9432
diff
changeset
|
7141 } |
9440
73c0d07cc15e
commit https://github.com/vim/vim/commit/ba768495c2e6bae74e49d22d489fbf211ecad55e
Christian Brabandt <cb@256bit.org>
parents:
9438
diff
changeset
|
7142 #endif |
9438
7897b1e4f3e7
commit https://github.com/vim/vim/commit/245a7cb6d33e556415c9fcaa874b784a6d8f0ef3
Christian Brabandt <cb@256bit.org>
parents:
9432
diff
changeset
|
7143 |
7 | 7144 if (STRICMP(eap->arg, "END") == 0) |
7145 close_redir(); | |
7146 else | |
7147 { | |
122 | 7148 if (*arg == '>') |
7149 { | |
7150 ++arg; | |
7151 if (*arg == '>') | |
7152 { | |
7153 ++arg; | |
7 | 7154 mode = "a"; |
7155 } | |
7156 else | |
7157 mode = "w"; | |
122 | 7158 arg = skipwhite(arg); |
7 | 7159 |
7160 close_redir(); | |
7161 | |
7162 /* Expand environment variables and "~/". */ | |
122 | 7163 fname = expand_env_save(arg); |
7 | 7164 if (fname == NULL) |
7165 return; | |
7166 #ifdef FEAT_BROWSE | |
7167 if (cmdmod.browse) | |
7168 { | |
7169 char_u *browseFile; | |
7170 | |
28 | 7171 browseFile = do_browse(BROWSE_SAVE, |
7172 (char_u *)_("Save Redirection"), | |
13802
378f9f8e6d8f
patch 8.0.1773: dialog messages are not translated
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
7173 fname, NULL, NULL, |
378f9f8e6d8f
patch 8.0.1773: dialog messages are not translated
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
7174 (char_u *)_(BROWSE_FILTER_ALL_FILES), curbuf); |
7 | 7175 if (browseFile == NULL) |
7176 return; /* operation cancelled */ | |
7177 vim_free(fname); | |
7178 fname = browseFile; | |
7179 eap->forceit = TRUE; /* since dialog already asked */ | |
7180 } | |
7181 #endif | |
7182 | |
7183 redir_fd = open_exfile(fname, eap->forceit, mode); | |
7184 vim_free(fname); | |
7185 } | |
7186 #ifdef FEAT_EVAL | |
122 | 7187 else if (*arg == '@') |
7 | 7188 { |
7189 /* redirect to a register a-z (resp. A-Z for appending) */ | |
7190 close_redir(); | |
122 | 7191 ++arg; |
7192 if (ASCII_ISALPHA(*arg) | |
7 | 7193 # ifdef FEAT_CLIPBOARD |
122 | 7194 || *arg == '*' |
1038 | 7195 || *arg == '+' |
7 | 7196 # endif |
122 | 7197 || *arg == '"') |
7198 { | |
7199 redir_reg = *arg++; | |
1427 | 7200 if (*arg == '>' && arg[1] == '>') /* append */ |
268 | 7201 arg += 2; |
1427 | 7202 else |
7 | 7203 { |
1427 | 7204 /* Can use both "@a" and "@a>". */ |
296 | 7205 if (*arg == '>') |
7206 arg++; | |
1427 | 7207 /* Make register empty when not using @A-@Z and the |
7208 * command is valid. */ | |
7209 if (*arg == NUL && !isupper(redir_reg)) | |
7210 write_reg_contents(redir_reg, (char_u *)"", -1, FALSE); | |
7 | 7211 } |
167 | 7212 } |
7213 if (*arg != NUL) | |
7214 { | |
268 | 7215 redir_reg = 0; |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7216 semsg(_(e_invarg2), eap->arg); |
167 | 7217 } |
7218 } | |
7219 else if (*arg == '=' && arg[1] == '>') | |
7220 { | |
7221 int append; | |
7222 | |
7223 /* redirect to a variable */ | |
7224 close_redir(); | |
7225 arg += 2; | |
7226 | |
7227 if (*arg == '>') | |
7228 { | |
7229 ++arg; | |
7230 append = TRUE; | |
7 | 7231 } |
7232 else | |
167 | 7233 append = FALSE; |
7234 | |
7235 if (var_redir_start(skipwhite(arg), append) == OK) | |
7236 redir_vname = 1; | |
7 | 7237 } |
7238 #endif | |
7239 | |
7240 /* TODO: redirect to a buffer */ | |
7241 | |
7242 else | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7243 semsg(_(e_invarg2), eap->arg); |
7 | 7244 } |
972 | 7245 |
7246 /* Make sure redirection is not off. Can happen for cmdline completion | |
7247 * that indirectly invokes a command to catch its output. */ | |
7248 if (redir_fd != NULL | |
7249 #ifdef FEAT_EVAL | |
7250 || redir_reg || redir_vname | |
7251 #endif | |
7252 ) | |
7253 redir_off = FALSE; | |
7 | 7254 } |
7255 | |
7256 /* | |
7257 * ":redraw": force redraw | |
7258 */ | |
7864
6b0891de44a9
commit https://github.com/vim/vim/commit/fb1f62691eae7c79a28b3b17a60e72ce198c71a2
Christian Brabandt <cb@256bit.org>
parents:
7850
diff
changeset
|
7259 void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7260 ex_redraw(exarg_T *eap) |
7 | 7261 { |
7262 int r = RedrawingDisabled; | |
7263 int p = p_lz; | |
7264 | |
7265 RedrawingDisabled = 0; | |
7266 p_lz = FALSE; | |
11010
c004e17fa36b
patch 8.0.0394: tabs are not aligned when scrolling horizontally
Christian Brabandt <cb@256bit.org>
parents:
10952
diff
changeset
|
7267 validate_cursor(); |
7 | 7268 update_topline(); |
5735 | 7269 update_screen(eap->forceit ? CLEAR : VIsual_active ? INVERTED : 0); |
7 | 7270 #ifdef FEAT_TITLE |
7271 if (need_maketitle) | |
7272 maketitle(); | |
7273 #endif | |
16451
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16427
diff
changeset
|
7274 #if defined(MSWIN) && (!defined(FEAT_GUI_MSWIN) || defined(VIMDLL)) |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16427
diff
changeset
|
7275 # ifdef VIMDLL |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16427
diff
changeset
|
7276 if (!gui.in_use) |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16427
diff
changeset
|
7277 # endif |
7ae2396cef62
patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents:
16427
diff
changeset
|
7278 resize_console_buf(); |
15866
6ddcd10aa7af
patch 8.1.0940: MS-Windows console resizing not handled properly
Bram Moolenaar <Bram@vim.org>
parents:
15748
diff
changeset
|
7279 #endif |
7 | 7280 RedrawingDisabled = r; |
7281 p_lz = p; | |
7282 | |
7283 /* Reset msg_didout, so that a message that's there is overwritten. */ | |
7284 msg_didout = FALSE; | |
7285 msg_col = 0; | |
7286 | |
5198
1b89e3f916c5
updated for version 7.4a.025
Bram Moolenaar <bram@vim.org>
parents:
4928
diff
changeset
|
7287 /* No need to wait after an intentional redraw. */ |
1b89e3f916c5
updated for version 7.4a.025
Bram Moolenaar <bram@vim.org>
parents:
4928
diff
changeset
|
7288 need_wait_return = FALSE; |
1b89e3f916c5
updated for version 7.4a.025
Bram Moolenaar <bram@vim.org>
parents:
4928
diff
changeset
|
7289 |
7 | 7290 out_flush(); |
7291 } | |
7292 | |
7293 /* | |
7294 * ":redrawstatus": force redraw of status line(s) | |
7295 */ | |
7296 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7297 ex_redrawstatus(exarg_T *eap UNUSED) |
7 | 7298 { |
7299 int r = RedrawingDisabled; | |
7300 int p = p_lz; | |
7301 | |
7302 RedrawingDisabled = 0; | |
7303 p_lz = FALSE; | |
7304 if (eap->forceit) | |
7305 status_redraw_all(); | |
7306 else | |
7307 status_redraw_curbuf(); | |
5735 | 7308 update_screen(VIsual_active ? INVERTED : 0); |
7 | 7309 RedrawingDisabled = r; |
7310 p_lz = p; | |
7311 out_flush(); | |
7312 } | |
7313 | |
15396
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7314 /* |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7315 * ":redrawtabline": force redraw of the tabline |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7316 */ |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7317 static void |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7318 ex_redrawtabline(exarg_T *eap UNUSED) |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7319 { |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7320 int r = RedrawingDisabled; |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7321 int p = p_lz; |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7322 |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7323 RedrawingDisabled = 0; |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7324 p_lz = FALSE; |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7325 |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7326 draw_tabline(); |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7327 |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7328 RedrawingDisabled = r; |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7329 p_lz = p; |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7330 out_flush(); |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7331 } |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7332 |
7 | 7333 static void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7334 close_redir(void) |
7 | 7335 { |
7336 if (redir_fd != NULL) | |
7337 { | |
7338 fclose(redir_fd); | |
7339 redir_fd = NULL; | |
7340 } | |
7341 #ifdef FEAT_EVAL | |
7342 redir_reg = 0; | |
167 | 7343 if (redir_vname) |
7344 { | |
7345 var_redir_stop(); | |
7346 redir_vname = 0; | |
7347 } | |
7 | 7348 #endif |
7349 } | |
7350 | |
17539
554240b9574b
patch 8.1.1767: FEAT_SESSION defined separately
Bram Moolenaar <Bram@vim.org>
parents:
17536
diff
changeset
|
7351 #if (defined(FEAT_SESSION) || defined(FEAT_EVAL)) || defined(PROTO) |
167 | 7352 int |
18139
59bc3cd42cf5
patch 8.1.2064: MS-Windows: compiler warnings for unused arguments
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
7353 vim_mkdir_emsg(char_u *name, int prot UNUSED) |
167 | 7354 { |
7355 if (vim_mkdir(name, prot) != 0) | |
7356 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7357 semsg(_("E739: Cannot create directory: %s"), name); |
167 | 7358 return FAIL; |
7359 } | |
7360 return OK; | |
7361 } | |
7362 #endif | |
7363 | |
7 | 7364 /* |
7365 * Open a file for writing for an Ex command, with some checks. | |
7366 * Return file descriptor, or NULL on failure. | |
7367 */ | |
7368 FILE * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7369 open_exfile( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7370 char_u *fname, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7371 int forceit, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7372 char *mode) /* "w" for create new file or "a" for append */ |
7 | 7373 { |
7374 FILE *fd; | |
7375 | |
7376 #ifdef UNIX | |
7377 /* with Unix it is possible to open a directory */ | |
7378 if (mch_isdir(fname)) | |
7379 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7380 semsg(_(e_isadir2), fname); |
7 | 7381 return NULL; |
7382 } | |
7383 #endif | |
7384 if (!forceit && *mode != 'a' && vim_fexists(fname)) | |
7385 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7386 semsg(_("E189: \"%s\" exists (add ! to override)"), fname); |
7 | 7387 return NULL; |
7388 } | |
7389 | |
7390 if ((fd = mch_fopen((char *)fname, mode)) == NULL) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7391 semsg(_("E190: Cannot open \"%s\" for writing"), fname); |
7 | 7392 |
7393 return fd; | |
7394 } | |
7395 | |
7396 /* | |
7397 * ":mark" and ":k". | |
7398 */ | |
7399 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7400 ex_mark(exarg_T *eap) |
7 | 7401 { |
7402 pos_T pos; | |
7403 | |
7404 if (*eap->arg == NUL) /* No argument? */ | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7405 emsg(_(e_argreq)); |
7 | 7406 else if (eap->arg[1] != NUL) /* more than one character? */ |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7407 emsg(_(e_trailing)); |
7 | 7408 else |
7409 { | |
7410 pos = curwin->w_cursor; /* save curwin->w_cursor */ | |
7411 curwin->w_cursor.lnum = eap->line2; | |
7412 beginline(BL_WHITE | BL_FIX); | |
7413 if (setmark(*eap->arg) == FAIL) /* set mark */ | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7414 emsg(_("E191: Argument must be a letter or forward/backward quote")); |
7 | 7415 curwin->w_cursor = pos; /* restore curwin->w_cursor */ |
7416 } | |
7417 } | |
7418 | |
7419 /* | |
7420 * Update w_topline, w_leftcol and the cursor position. | |
7421 */ | |
7422 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7423 update_topline_cursor(void) |
7 | 7424 { |
7425 check_cursor(); /* put cursor on valid line */ | |
7426 update_topline(); | |
7427 if (!curwin->w_p_wrap) | |
7428 validate_cursor(); | |
7429 update_curswant(); | |
7430 } | |
7431 | |
7432 /* | |
12521
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7433 * Save the current State and go to Normal mode. |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7434 * Return TRUE if the typeahead could be saved. |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7435 */ |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7436 int |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7437 save_current_state(save_state_T *sst) |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7438 { |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7439 sst->save_msg_scroll = msg_scroll; |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7440 sst->save_restart_edit = restart_edit; |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7441 sst->save_msg_didout = msg_didout; |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7442 sst->save_State = State; |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7443 sst->save_insertmode = p_im; |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7444 sst->save_finish_op = finish_op; |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7445 sst->save_opcount = opcount; |
15973
393a9a3a2da2
patch 8.1.0992: a :normal command resets the reg_executing() result
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
7446 sst->save_reg_executing = reg_executing; |
12521
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7447 |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7448 msg_scroll = FALSE; /* no msg scrolling in Normal mode */ |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7449 restart_edit = 0; /* don't go to Insert mode */ |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7450 p_im = FALSE; /* don't use 'insertmode' */ |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7451 |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7452 /* |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7453 * Save the current typeahead. This is required to allow using ":normal" |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7454 * from an event handler and makes sure we don't hang when the argument |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7455 * ends with half a command. |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7456 */ |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7457 save_typeahead(&sst->tabuf); |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7458 return sst->tabuf.typebuf_valid; |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7459 } |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7460 |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7461 void |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7462 restore_current_state(save_state_T *sst) |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7463 { |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7464 /* Restore the previous typeahead. */ |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7465 restore_typeahead(&sst->tabuf); |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7466 |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7467 msg_scroll = sst->save_msg_scroll; |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7468 restart_edit = sst->save_restart_edit; |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7469 p_im = sst->save_insertmode; |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7470 finish_op = sst->save_finish_op; |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7471 opcount = sst->save_opcount; |
15973
393a9a3a2da2
patch 8.1.0992: a :normal command resets the reg_executing() result
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
7472 reg_executing = sst->save_reg_executing; |
12521
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7473 msg_didout |= sst->save_msg_didout; /* don't reset msg_didout now */ |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7474 |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7475 /* Restore the state (needed when called from a function executed for |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7476 * 'indentexpr'). Update the mouse and cursor, they may have changed. */ |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7477 State = sst->save_State; |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7478 #ifdef CURSOR_SHAPE |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7479 ui_cursor_shape(); /* may show different cursor shape */ |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7480 #endif |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7481 } |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7482 |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7483 /* |
7 | 7484 * ":normal[!] {commands}": Execute normal mode commands. |
7485 */ | |
7840
28f569c7dab9
commit https://github.com/vim/vim/commit/20fb9f346497daca4d19402fdfa5de7958642477
Christian Brabandt <cb@256bit.org>
parents:
7819
diff
changeset
|
7486 void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7487 ex_normal(exarg_T *eap) |
7 | 7488 { |
12521
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7489 save_state_T save_state; |
7 | 7490 char_u *arg = NULL; |
7491 int l; | |
7492 char_u *p; | |
7493 | |
856 | 7494 if (ex_normal_lock > 0) |
7495 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7496 emsg(_(e_secure)); |
856 | 7497 return; |
7498 } | |
7 | 7499 if (ex_normal_busy >= p_mmd) |
7500 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7501 emsg(_("E192: Recursive use of :normal too deep")); |
7 | 7502 return; |
7503 } | |
7504 | |
7505 /* | |
7506 * vgetc() expects a CSI and K_SPECIAL to have been escaped. Don't do | |
7507 * this for the K_SPECIAL leading byte, otherwise special keys will not | |
7508 * work. | |
7509 */ | |
7510 if (has_mbyte) | |
7511 { | |
7512 int len = 0; | |
7513 | |
7514 /* Count the number of characters to be escaped. */ | |
7515 for (p = eap->arg; *p != NUL; ++p) | |
7516 { | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
7517 #ifdef FEAT_GUI |
7 | 7518 if (*p == CSI) /* leadbyte CSI */ |
7519 len += 2; | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
7520 #endif |
474 | 7521 for (l = (*mb_ptr2len)(p) - 1; l > 0; --l) |
7 | 7522 if (*++p == K_SPECIAL /* trailbyte K_SPECIAL or CSI */ |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
7523 #ifdef FEAT_GUI |
7 | 7524 || *p == CSI |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
7525 #endif |
7 | 7526 ) |
7527 len += 2; | |
7528 } | |
7529 if (len > 0) | |
7530 { | |
16764
ef00b6bc186b
patch 8.1.1384: using "int" for alloc() often results in compiler warnings
Bram Moolenaar <Bram@vim.org>
parents:
16738
diff
changeset
|
7531 arg = alloc(STRLEN(eap->arg) + len + 1); |
7 | 7532 if (arg != NULL) |
7533 { | |
7534 len = 0; | |
7535 for (p = eap->arg; *p != NUL; ++p) | |
7536 { | |
7537 arg[len++] = *p; | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
7538 #ifdef FEAT_GUI |
7 | 7539 if (*p == CSI) |
7540 { | |
7541 arg[len++] = KS_EXTRA; | |
7542 arg[len++] = (int)KE_CSI; | |
7543 } | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
7544 #endif |
474 | 7545 for (l = (*mb_ptr2len)(p) - 1; l > 0; --l) |
7 | 7546 { |
7547 arg[len++] = *++p; | |
7548 if (*p == K_SPECIAL) | |
7549 { | |
7550 arg[len++] = KS_SPECIAL; | |
7551 arg[len++] = KE_FILLER; | |
7552 } | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
7553 #ifdef FEAT_GUI |
7 | 7554 else if (*p == CSI) |
7555 { | |
7556 arg[len++] = KS_EXTRA; | |
7557 arg[len++] = (int)KE_CSI; | |
7558 } | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
7559 #endif |
7 | 7560 } |
7561 arg[len] = NUL; | |
7562 } | |
7563 } | |
7564 } | |
7565 } | |
7566 | |
12521
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7567 ++ex_normal_busy; |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7568 if (save_current_state(&save_state)) |
7 | 7569 { |
7570 /* | |
7571 * Repeat the :normal command for each line in the range. When no | |
7572 * range given, execute it just once, without positioning the cursor | |
7573 * first. | |
7574 */ | |
7575 do | |
7576 { | |
7577 if (eap->addr_count != 0) | |
7578 { | |
7579 curwin->w_cursor.lnum = eap->line1++; | |
7580 curwin->w_cursor.col = 0; | |
11258
84f71a8a5f2c
patch 8.0.0515: ml_get errors in silent Ex mode
Christian Brabandt <cb@256bit.org>
parents:
11256
diff
changeset
|
7581 check_cursor_moved(curwin); |
7 | 7582 } |
7583 | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
7584 exec_normal_cmd(arg != NULL |
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
7585 ? arg |
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
7586 : eap->arg, eap->forceit ? REMAP_NONE : REMAP_YES, FALSE); |
7 | 7587 } |
7588 while (eap->addr_count > 0 && eap->line1 <= eap->line2 && !got_int); | |
7589 } | |
7590 | |
7591 /* Might not return to the main loop when in an event handler. */ | |
7592 update_topline_cursor(); | |
7593 | |
12521
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7594 restore_current_state(&save_state); |
7 | 7595 --ex_normal_busy; |
6322 | 7596 setmouse(); |
7597 #ifdef CURSOR_SHAPE | |
7598 ui_cursor_shape(); /* may show different cursor shape */ | |
7599 #endif | |
7600 | |
7 | 7601 vim_free(arg); |
7602 } | |
7603 | |
7604 /* | |
598 | 7605 * ":startinsert", ":startreplace" and ":startgreplace" |
7 | 7606 */ |
7607 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7608 ex_startinsert(exarg_T *eap) |
7 | 7609 { |
98 | 7610 if (eap->forceit) |
7611 { | |
17984
2ea47dee7ddd
patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
7612 // cursor line can be zero on startup |
12545
241fbf588b95
patch 8.0.1151: "vim -c startinsert!" doesn't append
Christian Brabandt <cb@256bit.org>
parents:
12521
diff
changeset
|
7613 if (!curwin->w_cursor.lnum) |
241fbf588b95
patch 8.0.1151: "vim -c startinsert!" doesn't append
Christian Brabandt <cb@256bit.org>
parents:
12521
diff
changeset
|
7614 curwin->w_cursor.lnum = 1; |
17984
2ea47dee7ddd
patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
7615 set_cursor_for_append_to_line(); |
2ea47dee7ddd
patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
7616 } |
2ea47dee7ddd
patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
7617 |
2ea47dee7ddd
patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
7618 // Ignore the command when already in Insert mode. Inserting an |
2ea47dee7ddd
patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
7619 // expression register that invokes a function can do this. |
89 | 7620 if (State & INSERT) |
7621 return; | |
7622 | |
598 | 7623 if (eap->cmdidx == CMD_startinsert) |
7624 restart_edit = 'a'; | |
7625 else if (eap->cmdidx == CMD_startreplace) | |
7626 restart_edit = 'R'; | |
7 | 7627 else |
598 | 7628 restart_edit = 'V'; |
7629 | |
7630 if (!eap->forceit) | |
7 | 7631 { |
14 | 7632 if (eap->cmdidx == CMD_startinsert) |
7633 restart_edit = 'i'; | |
17984
2ea47dee7ddd
patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
7634 curwin->w_curswant = 0; // avoid MAXCOL |
7 | 7635 } |
7636 } | |
7637 | |
7638 /* | |
7639 * ":stopinsert" | |
7640 */ | |
7641 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7642 ex_stopinsert(exarg_T *eap UNUSED) |
7 | 7643 { |
7644 restart_edit = 0; | |
7645 stop_insert_mode = TRUE; | |
8817
b7eb7bbd71d0
commit https://github.com/vim/vim/commit/fd773e9e88add7d1ffef890fb9f3a00d613b4326
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
7646 clearmode(); |
7 | 7647 } |
7850
10f17a228661
commit https://github.com/vim/vim/commit/e2c3810c2ae290bbc2cba18eb47cc2d44e4b9797
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
7648 |
36 | 7649 /* |
7650 * Execute normal mode command "cmd". | |
7651 * "remap" can be REMAP_NONE or REMAP_YES. | |
7652 */ | |
7653 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7654 exec_normal_cmd(char_u *cmd, int remap, int silent) |
36 | 7655 { |
7703
39251e981d1f
commit https://github.com/vim/vim/commit/25281634cda03ce302aaf9f906a9520b5f81f91e
Christian Brabandt <cb@256bit.org>
parents:
7549
diff
changeset
|
7656 /* Stuff the argument into the typeahead buffer. */ |
39251e981d1f
commit https://github.com/vim/vim/commit/25281634cda03ce302aaf9f906a9520b5f81f91e
Christian Brabandt <cb@256bit.org>
parents:
7549
diff
changeset
|
7657 ins_typebuf(cmd, remap, 0, TRUE, silent); |
14871
f20df682c8af
patch 8.1.0447: GUI scrollbar test fails with Athena and Motif
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
7658 exec_normal(FALSE, FALSE, FALSE); |
7703
39251e981d1f
commit https://github.com/vim/vim/commit/25281634cda03ce302aaf9f906a9520b5f81f91e
Christian Brabandt <cb@256bit.org>
parents:
7549
diff
changeset
|
7659 } |
7850
10f17a228661
commit https://github.com/vim/vim/commit/e2c3810c2ae290bbc2cba18eb47cc2d44e4b9797
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
7660 |
7703
39251e981d1f
commit https://github.com/vim/vim/commit/25281634cda03ce302aaf9f906a9520b5f81f91e
Christian Brabandt <cb@256bit.org>
parents:
7549
diff
changeset
|
7661 /* |
39251e981d1f
commit https://github.com/vim/vim/commit/25281634cda03ce302aaf9f906a9520b5f81f91e
Christian Brabandt <cb@256bit.org>
parents:
7549
diff
changeset
|
7662 * Execute normal_cmd() until there is no typeahead left. |
14871
f20df682c8af
patch 8.1.0447: GUI scrollbar test fails with Athena and Motif
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
7663 * When "use_vpeekc" is TRUE use vpeekc() to check for available chars. |
7703
39251e981d1f
commit https://github.com/vim/vim/commit/25281634cda03ce302aaf9f906a9520b5f81f91e
Christian Brabandt <cb@256bit.org>
parents:
7549
diff
changeset
|
7664 */ |
39251e981d1f
commit https://github.com/vim/vim/commit/25281634cda03ce302aaf9f906a9520b5f81f91e
Christian Brabandt <cb@256bit.org>
parents:
7549
diff
changeset
|
7665 void |
14871
f20df682c8af
patch 8.1.0447: GUI scrollbar test fails with Athena and Motif
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
7666 exec_normal(int was_typed, int use_vpeekc, int may_use_terminal_loop UNUSED) |
7703
39251e981d1f
commit https://github.com/vim/vim/commit/25281634cda03ce302aaf9f906a9520b5f81f91e
Christian Brabandt <cb@256bit.org>
parents:
7549
diff
changeset
|
7667 { |
36 | 7668 oparg_T oa; |
16263
d3377393e3d9
patch 8.1.1136: decoding of mouse click escape sequence is not tested
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
7669 int c; |
d3377393e3d9
patch 8.1.1136: decoding of mouse click escape sequence is not tested
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
7670 |
d3377393e3d9
patch 8.1.1136: decoding of mouse click escape sequence is not tested
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
7671 // When calling vpeekc() from feedkeys() it will return Ctrl_C when there |
d3377393e3d9
patch 8.1.1136: decoding of mouse click escape sequence is not tested
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
7672 // is nothing to get, so also check for Ctrl_C. |
36 | 7673 clear_oparg(&oa); |
7674 finish_op = FALSE; | |
14871
f20df682c8af
patch 8.1.0447: GUI scrollbar test fails with Athena and Motif
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
7675 while ((!stuff_empty() |
f20df682c8af
patch 8.1.0447: GUI scrollbar test fails with Athena and Motif
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
7676 || ((was_typed || !typebuf_typed()) && typebuf.tb_len > 0) |
16263
d3377393e3d9
patch 8.1.1136: decoding of mouse click escape sequence is not tested
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
7677 || (use_vpeekc && (c = vpeekc()) != NUL && c != Ctrl_C)) |
14871
f20df682c8af
patch 8.1.0447: GUI scrollbar test fails with Athena and Motif
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
7678 && !got_int) |
36 | 7679 { |
7680 update_topline_cursor(); | |
13829
044337cbf854
patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents:
13802
diff
changeset
|
7681 #ifdef FEAT_TERMINAL |
13866
4b35f2835ce4
patch 8.0.1804: using :normal in terminal window causes problems
Christian Brabandt <cb@256bit.org>
parents:
13829
diff
changeset
|
7682 if (may_use_terminal_loop && term_use_loop() |
13829
044337cbf854
patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents:
13802
diff
changeset
|
7683 && oa.op_type == OP_NOP && oa.regname == NUL |
044337cbf854
patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents:
13802
diff
changeset
|
7684 && !VIsual_active) |
044337cbf854
patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents:
13802
diff
changeset
|
7685 { |
044337cbf854
patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents:
13802
diff
changeset
|
7686 /* If terminal_loop() returns OK we got a key that is handled |
044337cbf854
patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents:
13802
diff
changeset
|
7687 * in Normal model. With FAIL we first need to position the |
044337cbf854
patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents:
13802
diff
changeset
|
7688 * cursor and the screen needs to be redrawn. */ |
044337cbf854
patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents:
13802
diff
changeset
|
7689 if (terminal_loop(TRUE) == OK) |
044337cbf854
patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents:
13802
diff
changeset
|
7690 normal_cmd(&oa, TRUE); |
044337cbf854
patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents:
13802
diff
changeset
|
7691 } |
044337cbf854
patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents:
13802
diff
changeset
|
7692 else |
044337cbf854
patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents:
13802
diff
changeset
|
7693 #endif |
044337cbf854
patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents:
13802
diff
changeset
|
7694 /* execute a Normal mode cmd */ |
044337cbf854
patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents:
13802
diff
changeset
|
7695 normal_cmd(&oa, TRUE); |
36 | 7696 } |
7697 } | |
7698 | |
7 | 7699 #ifdef FEAT_FIND_ID |
7700 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7701 ex_checkpath(exarg_T *eap) |
7 | 7702 { |
7703 find_pattern_in_path(NULL, 0, 0, FALSE, FALSE, CHECK_PATH, 1L, | |
7704 eap->forceit ? ACTION_SHOW_ALL : ACTION_SHOW, | |
7705 (linenr_T)1, (linenr_T)MAXLNUM); | |
7706 } | |
7707 | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
7708 #if defined(FEAT_QUICKFIX) |
7 | 7709 /* |
7710 * ":psearch" | |
7711 */ | |
7712 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7713 ex_psearch(exarg_T *eap) |
7 | 7714 { |
7715 g_do_tagpreview = p_pvh; | |
7716 ex_findpat(eap); | |
7717 g_do_tagpreview = 0; | |
7718 } | |
7719 #endif | |
7720 | |
7721 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7722 ex_findpat(exarg_T *eap) |
7 | 7723 { |
7724 int whole = TRUE; | |
7725 long n; | |
7726 char_u *p; | |
7727 int action; | |
7728 | |
7729 switch (cmdnames[eap->cmdidx].cmd_name[2]) | |
7730 { | |
7731 case 'e': /* ":psearch", ":isearch" and ":dsearch" */ | |
7732 if (cmdnames[eap->cmdidx].cmd_name[0] == 'p') | |
7733 action = ACTION_GOTO; | |
7734 else | |
7735 action = ACTION_SHOW; | |
7736 break; | |
7737 case 'i': /* ":ilist" and ":dlist" */ | |
7738 action = ACTION_SHOW_ALL; | |
7739 break; | |
7740 case 'u': /* ":ijump" and ":djump" */ | |
7741 action = ACTION_GOTO; | |
7742 break; | |
7743 default: /* ":isplit" and ":dsplit" */ | |
7744 action = ACTION_SPLIT; | |
7745 break; | |
7746 } | |
7747 | |
7748 n = 1; | |
7749 if (vim_isdigit(*eap->arg)) /* get count */ | |
7750 { | |
7751 n = getdigits(&eap->arg); | |
7752 eap->arg = skipwhite(eap->arg); | |
7753 } | |
7754 if (*eap->arg == '/') /* Match regexp, not just whole words */ | |
7755 { | |
7756 whole = FALSE; | |
7757 ++eap->arg; | |
7758 p = skip_regexp(eap->arg, '/', p_magic, NULL); | |
7759 if (*p) | |
7760 { | |
7761 *p++ = NUL; | |
7762 p = skipwhite(p); | |
7763 | |
7764 /* Check for trailing illegal characters */ | |
7765 if (!ends_excmd(*p)) | |
7766 eap->errmsg = e_trailing; | |
7767 else | |
7768 eap->nextcmd = check_nextcmd(p); | |
7769 } | |
7770 } | |
7771 if (!eap->skip) | |
7772 find_pattern_in_path(eap->arg, 0, (int)STRLEN(eap->arg), | |
7773 whole, !eap->forceit, | |
7774 *eap->cmd == 'd' ? FIND_DEFINE : FIND_ANY, | |
7775 n, action, eap->line1, eap->line2); | |
7776 } | |
7777 #endif | |
7778 | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
7779 |
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
7780 #ifdef FEAT_QUICKFIX |
7 | 7781 /* |
7782 * ":ptag", ":ptselect", ":ptjump", ":ptnext", etc. | |
7783 */ | |
7784 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7785 ex_ptag(exarg_T *eap) |
7 | 7786 { |
2633 | 7787 g_do_tagpreview = p_pvh; /* will be reset to 0 in ex_tag_cmd() */ |
7 | 7788 ex_tag_cmd(eap, cmdnames[eap->cmdidx].cmd_name + 1); |
7789 } | |
7790 | |
7791 /* | |
7792 * ":pedit" | |
7793 */ | |
7794 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7795 ex_pedit(exarg_T *eap) |
7 | 7796 { |
7797 win_T *curwin_save = curwin; | |
7798 | |
17746
a4e488a6655c
patch 8.1.1870: using :pedit from a help file sets help filetype
Bram Moolenaar <Bram@vim.org>
parents:
17744
diff
changeset
|
7799 // Open the preview window or popup and make it the current window. |
7 | 7800 g_do_tagpreview = p_pvh; |
17767
c75da1064e33
patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
17746
diff
changeset
|
7801 prepare_tagpreview(TRUE, TRUE, FALSE); |
17644
daa1dea1c1b3
patch 8.1.1819: :pedit does not work with a popup preview window
Bram Moolenaar <Bram@vim.org>
parents:
17622
diff
changeset
|
7802 |
17746
a4e488a6655c
patch 8.1.1870: using :pedit from a help file sets help filetype
Bram Moolenaar <Bram@vim.org>
parents:
17744
diff
changeset
|
7803 // Edit the file. |
7 | 7804 do_exedit(eap, NULL); |
17644
daa1dea1c1b3
patch 8.1.1819: :pedit does not work with a popup preview window
Bram Moolenaar <Bram@vim.org>
parents:
17622
diff
changeset
|
7805 |
7 | 7806 if (curwin != curwin_save && win_valid(curwin_save)) |
7807 { | |
17746
a4e488a6655c
patch 8.1.1870: using :pedit from a help file sets help filetype
Bram Moolenaar <Bram@vim.org>
parents:
17744
diff
changeset
|
7808 // Return cursor to where we were |
7 | 7809 validate_cursor(); |
7810 redraw_later(VALID); | |
7811 win_enter(curwin_save, TRUE); | |
7812 } | |
17644
daa1dea1c1b3
patch 8.1.1819: :pedit does not work with a popup preview window
Bram Moolenaar <Bram@vim.org>
parents:
17622
diff
changeset
|
7813 # ifdef FEAT_TEXT_PROP |
daa1dea1c1b3
patch 8.1.1819: :pedit does not work with a popup preview window
Bram Moolenaar <Bram@vim.org>
parents:
17622
diff
changeset
|
7814 else if (WIN_IS_POPUP(curwin)) |
daa1dea1c1b3
patch 8.1.1819: :pedit does not work with a popup preview window
Bram Moolenaar <Bram@vim.org>
parents:
17622
diff
changeset
|
7815 { |
daa1dea1c1b3
patch 8.1.1819: :pedit does not work with a popup preview window
Bram Moolenaar <Bram@vim.org>
parents:
17622
diff
changeset
|
7816 // can't keep focus in popup window |
daa1dea1c1b3
patch 8.1.1819: :pedit does not work with a popup preview window
Bram Moolenaar <Bram@vim.org>
parents:
17622
diff
changeset
|
7817 win_enter(firstwin, TRUE); |
daa1dea1c1b3
patch 8.1.1819: :pedit does not work with a popup preview window
Bram Moolenaar <Bram@vim.org>
parents:
17622
diff
changeset
|
7818 } |
daa1dea1c1b3
patch 8.1.1819: :pedit does not work with a popup preview window
Bram Moolenaar <Bram@vim.org>
parents:
17622
diff
changeset
|
7819 # endif |
7 | 7820 g_do_tagpreview = 0; |
7821 } | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
7822 #endif |
7 | 7823 |
7824 /* | |
7825 * ":stag", ":stselect" and ":stjump". | |
7826 */ | |
7827 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7828 ex_stag(exarg_T *eap) |
7 | 7829 { |
7830 postponed_split = -1; | |
7831 postponed_split_flags = cmdmod.split; | |
1090 | 7832 postponed_split_tab = cmdmod.tab; |
7 | 7833 ex_tag_cmd(eap, cmdnames[eap->cmdidx].cmd_name + 1); |
7834 postponed_split_flags = 0; | |
1090 | 7835 postponed_split_tab = 0; |
7 | 7836 } |
7837 | |
7838 /* | |
7839 * ":tag", ":tselect", ":tjump", ":tnext", etc. | |
7840 */ | |
7841 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7842 ex_tag(exarg_T *eap) |
7 | 7843 { |
7844 ex_tag_cmd(eap, cmdnames[eap->cmdidx].cmd_name); | |
7845 } | |
7846 | |
7847 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7848 ex_tag_cmd(exarg_T *eap, char_u *name) |
7 | 7849 { |
7850 int cmd; | |
7851 | |
7852 switch (name[1]) | |
7853 { | |
7854 case 'j': cmd = DT_JUMP; /* ":tjump" */ | |
7855 break; | |
7856 case 's': cmd = DT_SELECT; /* ":tselect" */ | |
7857 break; | |
7858 case 'p': cmd = DT_PREV; /* ":tprevious" */ | |
7859 break; | |
7860 case 'N': cmd = DT_PREV; /* ":tNext" */ | |
7861 break; | |
7862 case 'n': cmd = DT_NEXT; /* ":tnext" */ | |
7863 break; | |
7864 case 'o': cmd = DT_POP; /* ":pop" */ | |
7865 break; | |
7866 case 'f': /* ":tfirst" */ | |
7867 case 'r': cmd = DT_FIRST; /* ":trewind" */ | |
7868 break; | |
7869 case 'l': cmd = DT_LAST; /* ":tlast" */ | |
7870 break; | |
7871 default: /* ":tag" */ | |
7872 #ifdef FEAT_CSCOPE | |
1603 | 7873 if (p_cst && *eap->arg != NUL) |
7 | 7874 { |
10373
bd674706408a
commit https://github.com/vim/vim/commit/d4db7719bdfbc54df396eac08d8cbb2389feacf4
Christian Brabandt <cb@256bit.org>
parents:
10361
diff
changeset
|
7875 ex_cstag(eap); |
7 | 7876 return; |
7877 } | |
7878 #endif | |
7879 cmd = DT_TAG; | |
7880 break; | |
7881 } | |
7882 | |
649 | 7883 if (name[0] == 'l') |
7884 { | |
7885 #ifndef FEAT_QUICKFIX | |
7886 ex_ni(eap); | |
7887 return; | |
7888 #else | |
7889 cmd = DT_LTAG; | |
7890 #endif | |
7891 } | |
7892 | |
7 | 7893 do_tag(eap->arg, cmd, eap->addr_count > 0 ? (int)eap->line2 : 1, |
7894 eap->forceit, TRUE); | |
7895 } | |
7896 | |
7897 /* | |
1661 | 7898 * Check "str" for starting with a special cmdline variable. |
7899 * If found return one of the SPEC_ values and set "*usedlen" to the length of | |
7900 * the variable. Otherwise return -1 and "*usedlen" is unchanged. | |
7901 */ | |
7902 int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7903 find_cmdline_var(char_u *src, int *usedlen) |
1661 | 7904 { |
7905 int len; | |
7906 int i; | |
1879 | 7907 static char *(spec_str[]) = { |
1661 | 7908 "%", |
7909 #define SPEC_PERC 0 | |
7910 "#", | |
12421
da55ea30842c
patch 8.0.1090: cannot get the text under the cursor like v:beval_text
Christian Brabandt <cb@256bit.org>
parents:
12419
diff
changeset
|
7911 #define SPEC_HASH (SPEC_PERC + 1) |
1661 | 7912 "<cword>", /* cursor word */ |
12421
da55ea30842c
patch 8.0.1090: cannot get the text under the cursor like v:beval_text
Christian Brabandt <cb@256bit.org>
parents:
12419
diff
changeset
|
7913 #define SPEC_CWORD (SPEC_HASH + 1) |
1661 | 7914 "<cWORD>", /* cursor WORD */ |
12421
da55ea30842c
patch 8.0.1090: cannot get the text under the cursor like v:beval_text
Christian Brabandt <cb@256bit.org>
parents:
12419
diff
changeset
|
7915 #define SPEC_CCWORD (SPEC_CWORD + 1) |
da55ea30842c
patch 8.0.1090: cannot get the text under the cursor like v:beval_text
Christian Brabandt <cb@256bit.org>
parents:
12419
diff
changeset
|
7916 "<cexpr>", /* expr under cursor */ |
da55ea30842c
patch 8.0.1090: cannot get the text under the cursor like v:beval_text
Christian Brabandt <cb@256bit.org>
parents:
12419
diff
changeset
|
7917 #define SPEC_CEXPR (SPEC_CCWORD + 1) |
1661 | 7918 "<cfile>", /* cursor path name */ |
12421
da55ea30842c
patch 8.0.1090: cannot get the text under the cursor like v:beval_text
Christian Brabandt <cb@256bit.org>
parents:
12419
diff
changeset
|
7919 #define SPEC_CFILE (SPEC_CEXPR + 1) |
1661 | 7920 "<sfile>", /* ":so" file name */ |
12421
da55ea30842c
patch 8.0.1090: cannot get the text under the cursor like v:beval_text
Christian Brabandt <cb@256bit.org>
parents:
12419
diff
changeset
|
7921 #define SPEC_SFILE (SPEC_CFILE + 1) |
2645 | 7922 "<slnum>", /* ":so" file line number */ |
12421
da55ea30842c
patch 8.0.1090: cannot get the text under the cursor like v:beval_text
Christian Brabandt <cb@256bit.org>
parents:
12419
diff
changeset
|
7923 #define SPEC_SLNUM (SPEC_SFILE + 1) |
1661 | 7924 "<afile>", /* autocommand file name */ |
14700
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14677
diff
changeset
|
7925 #define SPEC_AFILE (SPEC_SLNUM + 1) |
1661 | 7926 "<abuf>", /* autocommand buffer number */ |
14700
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14677
diff
changeset
|
7927 #define SPEC_ABUF (SPEC_AFILE + 1) |
1661 | 7928 "<amatch>", /* autocommand match name */ |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
7929 #define SPEC_AMATCH (SPEC_ABUF + 1) |
14700
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14677
diff
changeset
|
7930 "<sflnum>", /* script file line number */ |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14677
diff
changeset
|
7931 #define SPEC_SFLNUM (SPEC_AMATCH + 1) |
1661 | 7932 #ifdef FEAT_CLIENTSERVER |
7933 "<client>" | |
14700
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14677
diff
changeset
|
7934 # define SPEC_CLIENT (SPEC_SFLNUM + 1) |
1661 | 7935 #endif |
7936 }; | |
1872 | 7937 |
7938 for (i = 0; i < (int)(sizeof(spec_str) / sizeof(char *)); ++i) | |
1661 | 7939 { |
7940 len = (int)STRLEN(spec_str[i]); | |
7941 if (STRNCMP(src, spec_str[i], len) == 0) | |
7942 { | |
7943 *usedlen = len; | |
7944 return i; | |
7945 } | |
7946 } | |
7947 return -1; | |
7948 } | |
7949 | |
7950 /* | |
7 | 7951 * Evaluate cmdline variables. |
7952 * | |
7953 * change '%' to curbuf->b_ffname | |
7954 * '#' to curwin->w_altfile | |
7955 * '<cword>' to word under the cursor | |
7956 * '<cWORD>' to WORD under the cursor | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
7957 * '<cexpr>' to C-expression under the cursor |
7 | 7958 * '<cfile>' to path name under the cursor |
7959 * '<sfile>' to sourced file name | |
2645 | 7960 * '<slnum>' to sourced file line number |
7 | 7961 * '<afile>' to file name for autocommand |
7962 * '<abuf>' to buffer number for autocommand | |
7963 * '<amatch>' to matching name for autocommand | |
7964 * | |
7965 * When an error is detected, "errormsg" is set to a non-NULL pointer (may be | |
7966 * "" for error without a message) and NULL is returned. | |
7967 * Returns an allocated string if a valid match was found. | |
7968 * Returns NULL if no match was found. "usedlen" then still contains the | |
7969 * number of characters to skip. | |
7970 */ | |
7971 char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7972 eval_vars( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7973 char_u *src, /* pointer into commandline */ |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7974 char_u *srcstart, /* beginning of valid memory for src */ |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7975 int *usedlen, /* characters after src that are used */ |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7976 linenr_T *lnump, /* line number for :e command, or NULL */ |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7977 char **errormsg, /* pointer to error message */ |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7978 int *escaped) /* return value has escaped white space (can |
1098 | 7979 * be NULL) */ |
7 | 7980 { |
7981 int i; | |
7982 char_u *s; | |
7983 char_u *result; | |
7984 char_u *resultbuf = NULL; | |
7985 int resultlen; | |
7986 buf_T *buf; | |
7987 int valid = VALID_HEAD + VALID_PATH; /* assume valid result */ | |
7988 int spec_idx; | |
14405
289b850d2cbf
patch 8.1.0217: compiler warning for variable set but not used
Christian Brabandt <cb@256bit.org>
parents:
14393
diff
changeset
|
7989 int tilde_file = FALSE; |
7 | 7990 int skip_mod = FALSE; |
7991 char_u strbuf[30]; | |
7992 | |
7993 *errormsg = NULL; | |
1098 | 7994 if (escaped != NULL) |
7995 *escaped = FALSE; | |
7 | 7996 |
7997 /* | |
7998 * Check if there is something to do. | |
7999 */ | |
1661 | 8000 spec_idx = find_cmdline_var(src, usedlen); |
8001 if (spec_idx < 0) /* no match */ | |
7 | 8002 { |
8003 *usedlen = 1; | |
8004 return NULL; | |
8005 } | |
8006 | |
8007 /* | |
8008 * Skip when preceded with a backslash "\%" and "\#". | |
8009 * Note: In "\\%" the % is also not recognized! | |
8010 */ | |
8011 if (src > srcstart && src[-1] == '\\') | |
8012 { | |
8013 *usedlen = 0; | |
1619 | 8014 STRMOVE(src - 1, src); /* remove backslash */ |
7 | 8015 return NULL; |
8016 } | |
8017 | |
8018 /* | |
8019 * word or WORD under cursor | |
8020 */ | |
12421
da55ea30842c
patch 8.0.1090: cannot get the text under the cursor like v:beval_text
Christian Brabandt <cb@256bit.org>
parents:
12419
diff
changeset
|
8021 if (spec_idx == SPEC_CWORD || spec_idx == SPEC_CCWORD |
da55ea30842c
patch 8.0.1090: cannot get the text under the cursor like v:beval_text
Christian Brabandt <cb@256bit.org>
parents:
12419
diff
changeset
|
8022 || spec_idx == SPEC_CEXPR) |
da55ea30842c
patch 8.0.1090: cannot get the text under the cursor like v:beval_text
Christian Brabandt <cb@256bit.org>
parents:
12419
diff
changeset
|
8023 { |
da55ea30842c
patch 8.0.1090: cannot get the text under the cursor like v:beval_text
Christian Brabandt <cb@256bit.org>
parents:
12419
diff
changeset
|
8024 resultlen = find_ident_under_cursor(&result, |
da55ea30842c
patch 8.0.1090: cannot get the text under the cursor like v:beval_text
Christian Brabandt <cb@256bit.org>
parents:
12419
diff
changeset
|
8025 spec_idx == SPEC_CWORD ? (FIND_IDENT | FIND_STRING) |
da55ea30842c
patch 8.0.1090: cannot get the text under the cursor like v:beval_text
Christian Brabandt <cb@256bit.org>
parents:
12419
diff
changeset
|
8026 : spec_idx == SPEC_CEXPR ? (FIND_IDENT | FIND_STRING | FIND_EVAL) |
da55ea30842c
patch 8.0.1090: cannot get the text under the cursor like v:beval_text
Christian Brabandt <cb@256bit.org>
parents:
12419
diff
changeset
|
8027 : FIND_STRING); |
7 | 8028 if (resultlen == 0) |
8029 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8030 *errormsg = ""; |
7 | 8031 return NULL; |
8032 } | |
8033 } | |
8034 | |
8035 /* | |
8036 * '#': Alternate file name | |
8037 * '%': Current file name | |
8038 * File name under the cursor | |
8039 * File name for autocommand | |
8040 * and following modifiers | |
8041 */ | |
8042 else | |
8043 { | |
8044 switch (spec_idx) | |
8045 { | |
8046 case SPEC_PERC: /* '%': current file */ | |
8047 if (curbuf->b_fname == NULL) | |
8048 { | |
8049 result = (char_u *)""; | |
8050 valid = 0; /* Must have ":p:h" to be valid */ | |
8051 } | |
8052 else | |
14393
c62601adad69
patch 8.1.0211: expanding a file name "~" results in $HOME
Christian Brabandt <cb@256bit.org>
parents:
14286
diff
changeset
|
8053 { |
7 | 8054 result = curbuf->b_fname; |
14393
c62601adad69
patch 8.1.0211: expanding a file name "~" results in $HOME
Christian Brabandt <cb@256bit.org>
parents:
14286
diff
changeset
|
8055 tilde_file = STRCMP(result, "~") == 0; |
c62601adad69
patch 8.1.0211: expanding a file name "~" results in $HOME
Christian Brabandt <cb@256bit.org>
parents:
14286
diff
changeset
|
8056 } |
7 | 8057 break; |
8058 | |
8059 case SPEC_HASH: /* '#' or "#99": alternate file */ | |
8060 if (src[1] == '#') /* "##": the argument list */ | |
8061 { | |
8062 result = arg_all(); | |
8063 resultbuf = result; | |
8064 *usedlen = 2; | |
1098 | 8065 if (escaped != NULL) |
8066 *escaped = TRUE; | |
7 | 8067 skip_mod = TRUE; |
8068 break; | |
8069 } | |
8070 s = src + 1; | |
1733 | 8071 if (*s == '<') /* "#<99" uses v:oldfiles */ |
8072 ++s; | |
7 | 8073 i = (int)getdigits(&s); |
12706
9b882316aa63
patch 8.0.1231: expanding file name drops dash
Christian Brabandt <cb@256bit.org>
parents:
12674
diff
changeset
|
8074 if (s == src + 2 && src[1] == '-') |
9b882316aa63
patch 8.0.1231: expanding file name drops dash
Christian Brabandt <cb@256bit.org>
parents:
12674
diff
changeset
|
8075 /* just a minus sign, don't skip over it */ |
9b882316aa63
patch 8.0.1231: expanding file name drops dash
Christian Brabandt <cb@256bit.org>
parents:
12674
diff
changeset
|
8076 s--; |
7 | 8077 *usedlen = (int)(s - src); /* length of what we expand */ |
8078 | |
12706
9b882316aa63
patch 8.0.1231: expanding file name drops dash
Christian Brabandt <cb@256bit.org>
parents:
12674
diff
changeset
|
8079 if (src[1] == '<' && i != 0) |
7 | 8080 { |
1733 | 8081 if (*usedlen < 2) |
8082 { | |
8083 /* Should we give an error message for #<text? */ | |
8084 *usedlen = 1; | |
8085 return NULL; | |
8086 } | |
8087 #ifdef FEAT_EVAL | |
8088 result = list_find_str(get_vim_var_list(VV_OLDFILES), | |
8089 (long)i); | |
8090 if (result == NULL) | |
8091 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8092 *errormsg = ""; |
1733 | 8093 return NULL; |
8094 } | |
8095 #else | |
15488
da8b98c008bf
patch 8.1.0752: one more compiler warning for signed/unsigned string
Bram Moolenaar <Bram@vim.org>
parents:
15474
diff
changeset
|
8096 *errormsg = _("E809: #< is not available without the +eval feature"); |
7 | 8097 return NULL; |
1733 | 8098 #endif |
7 | 8099 } |
8100 else | |
1733 | 8101 { |
12706
9b882316aa63
patch 8.0.1231: expanding file name drops dash
Christian Brabandt <cb@256bit.org>
parents:
12674
diff
changeset
|
8102 if (i == 0 && src[1] == '<' && *usedlen > 1) |
9b882316aa63
patch 8.0.1231: expanding file name drops dash
Christian Brabandt <cb@256bit.org>
parents:
12674
diff
changeset
|
8103 *usedlen = 1; |
1733 | 8104 buf = buflist_findnr(i); |
8105 if (buf == NULL) | |
8106 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8107 *errormsg = _("E194: No alternate file name to substitute for '#'"); |
1733 | 8108 return NULL; |
8109 } | |
8110 if (lnump != NULL) | |
8111 *lnump = ECMD_LAST; | |
8112 if (buf->b_fname == NULL) | |
8113 { | |
8114 result = (char_u *)""; | |
8115 valid = 0; /* Must have ":p:h" to be valid */ | |
8116 } | |
8117 else | |
14393
c62601adad69
patch 8.1.0211: expanding a file name "~" results in $HOME
Christian Brabandt <cb@256bit.org>
parents:
14286
diff
changeset
|
8118 { |
1733 | 8119 result = buf->b_fname; |
14393
c62601adad69
patch 8.1.0211: expanding a file name "~" results in $HOME
Christian Brabandt <cb@256bit.org>
parents:
14286
diff
changeset
|
8120 tilde_file = STRCMP(result, "~") == 0; |
c62601adad69
patch 8.1.0211: expanding a file name "~" results in $HOME
Christian Brabandt <cb@256bit.org>
parents:
14286
diff
changeset
|
8121 } |
1733 | 8122 } |
7 | 8123 break; |
8124 | |
8125 #ifdef FEAT_SEARCHPATH | |
8126 case SPEC_CFILE: /* file name under cursor */ | |
681 | 8127 result = file_name_at_cursor(FNAME_MESS|FNAME_HYP, 1L, NULL); |
7 | 8128 if (result == NULL) |
8129 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8130 *errormsg = ""; |
7 | 8131 return NULL; |
8132 } | |
8133 resultbuf = result; /* remember allocated string */ | |
8134 break; | |
8135 #endif | |
8136 | |
8137 case SPEC_AFILE: /* file name for autocommand */ | |
8138 result = autocmd_fname; | |
1723 | 8139 if (result != NULL && !autocmd_fname_full) |
8140 { | |
8141 /* Still need to turn the fname into a full path. It is | |
8142 * postponed to avoid a delay when <afile> is not used. */ | |
8143 autocmd_fname_full = TRUE; | |
8144 result = FullName_save(autocmd_fname, FALSE); | |
8145 vim_free(autocmd_fname); | |
8146 autocmd_fname = result; | |
8147 } | |
7 | 8148 if (result == NULL) |
8149 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8150 *errormsg = _("E495: no autocommand file name to substitute for \"<afile>\""); |
7 | 8151 return NULL; |
8152 } | |
1471 | 8153 result = shorten_fname1(result); |
7 | 8154 break; |
8155 | |
8156 case SPEC_ABUF: /* buffer number for autocommand */ | |
8157 if (autocmd_bufnr <= 0) | |
8158 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8159 *errormsg = _("E496: no autocommand buffer number to substitute for \"<abuf>\""); |
7 | 8160 return NULL; |
8161 } | |
8162 sprintf((char *)strbuf, "%d", autocmd_bufnr); | |
8163 result = strbuf; | |
8164 break; | |
8165 | |
8166 case SPEC_AMATCH: /* match name for autocommand */ | |
8167 result = autocmd_match; | |
8168 if (result == NULL) | |
8169 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8170 *errormsg = _("E497: no autocommand match name to substitute for \"<amatch>\""); |
7 | 8171 return NULL; |
8172 } | |
8173 break; | |
8174 | |
8175 case SPEC_SFILE: /* file name for ":so" command */ | |
8176 result = sourcing_name; | |
8177 if (result == NULL) | |
8178 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8179 *errormsg = _("E498: no :source file name to substitute for \"<sfile>\""); |
7 | 8180 return NULL; |
8181 } | |
8182 break; | |
14700
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14677
diff
changeset
|
8183 |
2645 | 8184 case SPEC_SLNUM: /* line in file for ":so" command */ |
8185 if (sourcing_name == NULL || sourcing_lnum == 0) | |
8186 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8187 *errormsg = _("E842: no line number to use for \"<slnum>\""); |
2645 | 8188 return NULL; |
8189 } | |
8190 sprintf((char *)strbuf, "%ld", (long)sourcing_lnum); | |
8191 result = strbuf; | |
8192 break; | |
14700
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14677
diff
changeset
|
8193 |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14677
diff
changeset
|
8194 #ifdef FEAT_EVAL |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14677
diff
changeset
|
8195 case SPEC_SFLNUM: /* line in script file */ |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14677
diff
changeset
|
8196 if (current_sctx.sc_lnum + sourcing_lnum == 0) |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14677
diff
changeset
|
8197 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8198 *errormsg = _("E961: no line number to use for \"<sflnum>\""); |
14700
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14677
diff
changeset
|
8199 return NULL; |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14677
diff
changeset
|
8200 } |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14677
diff
changeset
|
8201 sprintf((char *)strbuf, "%ld", |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14677
diff
changeset
|
8202 (long)(current_sctx.sc_lnum + sourcing_lnum)); |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14677
diff
changeset
|
8203 result = strbuf; |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14677
diff
changeset
|
8204 break; |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14677
diff
changeset
|
8205 #endif |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14677
diff
changeset
|
8206 |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14677
diff
changeset
|
8207 #ifdef FEAT_CLIENTSERVER |
7 | 8208 case SPEC_CLIENT: /* Source of last submitted input */ |
840 | 8209 sprintf((char *)strbuf, PRINTF_HEX_LONG_U, |
8210 (long_u)clientWindow); | |
7 | 8211 result = strbuf; |
8212 break; | |
8213 #endif | |
14700
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14677
diff
changeset
|
8214 |
11428
346168f2a6cb
patch 8.0.0598: building with gcc 7.1 yields new warnings
Christian Brabandt <cb@256bit.org>
parents:
11374
diff
changeset
|
8215 default: |
346168f2a6cb
patch 8.0.0598: building with gcc 7.1 yields new warnings
Christian Brabandt <cb@256bit.org>
parents:
11374
diff
changeset
|
8216 result = (char_u *)""; /* avoid gcc warning */ |
346168f2a6cb
patch 8.0.0598: building with gcc 7.1 yields new warnings
Christian Brabandt <cb@256bit.org>
parents:
11374
diff
changeset
|
8217 break; |
7 | 8218 } |
8219 | |
8220 resultlen = (int)STRLEN(result); /* length of new string */ | |
8221 if (src[*usedlen] == '<') /* remove the file name extension */ | |
8222 { | |
8223 ++*usedlen; | |
8224 if ((s = vim_strrchr(result, '.')) != NULL && s >= gettail(result)) | |
8225 resultlen = (int)(s - result); | |
8226 } | |
8227 else if (!skip_mod) | |
8228 { | |
14393
c62601adad69
patch 8.1.0211: expanding a file name "~" results in $HOME
Christian Brabandt <cb@256bit.org>
parents:
14286
diff
changeset
|
8229 valid |= modify_fname(src, tilde_file, usedlen, &result, &resultbuf, |
7 | 8230 &resultlen); |
8231 if (result == NULL) | |
8232 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8233 *errormsg = ""; |
7 | 8234 return NULL; |
8235 } | |
8236 } | |
8237 } | |
8238 | |
8239 if (resultlen == 0 || valid != VALID_HEAD + VALID_PATH) | |
8240 { | |
8241 if (valid != VALID_HEAD + VALID_PATH) | |
8242 /* xgettext:no-c-format */ | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8243 *errormsg = _("E499: Empty file name for '%' or '#', only works with \":p:h\""); |
7 | 8244 else |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8245 *errormsg = _("E500: Evaluates to an empty string"); |
7 | 8246 result = NULL; |
8247 } | |
8248 else | |
8249 result = vim_strnsave(result, resultlen); | |
8250 vim_free(resultbuf); | |
8251 return result; | |
8252 } | |
8253 | |
8254 /* | |
8255 * Expand the <sfile> string in "arg". | |
8256 * | |
8257 * Returns an allocated string, or NULL for any error. | |
8258 */ | |
8259 char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8260 expand_sfile(char_u *arg) |
7 | 8261 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8262 char *errormsg; |
7 | 8263 int len; |
8264 char_u *result; | |
8265 char_u *newres; | |
8266 char_u *repl; | |
8267 int srclen; | |
8268 char_u *p; | |
8269 | |
8270 result = vim_strsave(arg); | |
8271 if (result == NULL) | |
8272 return NULL; | |
8273 | |
8274 for (p = result; *p; ) | |
8275 { | |
8276 if (STRNCMP(p, "<sfile>", 7) != 0) | |
8277 ++p; | |
8278 else | |
8279 { | |
8280 /* replace "<sfile>" with the sourced file name, and do ":" stuff */ | |
1098 | 8281 repl = eval_vars(p, result, &srclen, NULL, &errormsg, NULL); |
7 | 8282 if (errormsg != NULL) |
8283 { | |
8284 if (*errormsg) | |
8285 emsg(errormsg); | |
8286 vim_free(result); | |
8287 return NULL; | |
8288 } | |
8289 if (repl == NULL) /* no match (cannot happen) */ | |
8290 { | |
8291 p += srclen; | |
8292 continue; | |
8293 } | |
8294 len = (int)STRLEN(result) - srclen + (int)STRLEN(repl) + 1; | |
8295 newres = alloc(len); | |
8296 if (newres == NULL) | |
8297 { | |
8298 vim_free(repl); | |
8299 vim_free(result); | |
8300 return NULL; | |
8301 } | |
8302 mch_memmove(newres, result, (size_t)(p - result)); | |
8303 STRCPY(newres + (p - result), repl); | |
8304 len = (int)STRLEN(newres); | |
8305 STRCAT(newres, p + srclen); | |
8306 vim_free(repl); | |
8307 vim_free(result); | |
8308 result = newres; | |
8309 p = newres + len; /* continue after the match */ | |
8310 } | |
8311 } | |
8312 | |
8313 return result; | |
8314 } | |
8315 | |
8316 #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) || defined(PROTO) | |
272 | 8317 /* |
2770 | 8318 * Make a dialog message in "buff[DIALOG_MSG_SIZE]". |
310 | 8319 * "format" must contain "%s". |
272 | 8320 */ |
7 | 8321 void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8322 dialog_msg(char_u *buff, char *format, char_u *fname) |
7 | 8323 { |
8324 if (fname == NULL) | |
8325 fname = (char_u *)_("Untitled"); | |
2770 | 8326 vim_snprintf((char *)buff, DIALOG_MSG_SIZE, format, fname); |
7 | 8327 } |
8328 #endif | |
8329 | |
8330 /* | |
8331 * ":behave {mswin,xterm}" | |
8332 */ | |
8333 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8334 ex_behave(exarg_T *eap) |
7 | 8335 { |
8336 if (STRCMP(eap->arg, "mswin") == 0) | |
8337 { | |
8338 set_option_value((char_u *)"selection", 0L, (char_u *)"exclusive", 0); | |
8339 set_option_value((char_u *)"selectmode", 0L, (char_u *)"mouse,key", 0); | |
8340 set_option_value((char_u *)"mousemodel", 0L, (char_u *)"popup", 0); | |
8341 set_option_value((char_u *)"keymodel", 0L, | |
8342 (char_u *)"startsel,stopsel", 0); | |
8343 } | |
8344 else if (STRCMP(eap->arg, "xterm") == 0) | |
8345 { | |
8346 set_option_value((char_u *)"selection", 0L, (char_u *)"inclusive", 0); | |
8347 set_option_value((char_u *)"selectmode", 0L, (char_u *)"", 0); | |
8348 set_option_value((char_u *)"mousemodel", 0L, (char_u *)"extend", 0); | |
8349 set_option_value((char_u *)"keymodel", 0L, (char_u *)"", 0); | |
8350 } | |
8351 else | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8352 semsg(_(e_invarg2), eap->arg); |
7 | 8353 } |
8354 | |
8355 static int filetype_detect = FALSE; | |
8356 static int filetype_plugin = FALSE; | |
8357 static int filetype_indent = FALSE; | |
8358 | |
8359 /* | |
8360 * ":filetype [plugin] [indent] {on,off,detect}" | |
8361 * on: Load the filetype.vim file to install autocommands for file types. | |
8362 * off: Load the ftoff.vim file to remove all autocommands for file types. | |
8363 * plugin on: load filetype.vim and ftplugin.vim | |
8364 * plugin off: load ftplugof.vim | |
8365 * indent on: load filetype.vim and indent.vim | |
8366 * indent off: load indoff.vim | |
8367 */ | |
8368 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8369 ex_filetype(exarg_T *eap) |
7 | 8370 { |
8371 char_u *arg = eap->arg; | |
8372 int plugin = FALSE; | |
8373 int indent = FALSE; | |
8374 | |
8375 if (*eap->arg == NUL) | |
8376 { | |
8377 /* Print current status. */ | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8378 smsg("filetype detection:%s plugin:%s indent:%s", |
7 | 8379 filetype_detect ? "ON" : "OFF", |
8380 filetype_plugin ? (filetype_detect ? "ON" : "(on)") : "OFF", | |
8381 filetype_indent ? (filetype_detect ? "ON" : "(on)") : "OFF"); | |
8382 return; | |
8383 } | |
8384 | |
8385 /* Accept "plugin" and "indent" in any order. */ | |
8386 for (;;) | |
8387 { | |
8388 if (STRNCMP(arg, "plugin", 6) == 0) | |
8389 { | |
8390 plugin = TRUE; | |
8391 arg = skipwhite(arg + 6); | |
8392 continue; | |
8393 } | |
8394 if (STRNCMP(arg, "indent", 6) == 0) | |
8395 { | |
8396 indent = TRUE; | |
8397 arg = skipwhite(arg + 6); | |
8398 continue; | |
8399 } | |
8400 break; | |
8401 } | |
8402 if (STRCMP(arg, "on") == 0 || STRCMP(arg, "detect") == 0) | |
8403 { | |
8404 if (*arg == 'o' || !filetype_detect) | |
8405 { | |
8524
2f57bbe870ea
commit https://github.com/vim/vim/commit/7f8989dd8a627af2185df381195351a913f3777f
Christian Brabandt <cb@256bit.org>
parents:
8402
diff
changeset
|
8406 source_runtime((char_u *)FILETYPE_FILE, DIP_ALL); |
7 | 8407 filetype_detect = TRUE; |
8408 if (plugin) | |
8409 { | |
8524
2f57bbe870ea
commit https://github.com/vim/vim/commit/7f8989dd8a627af2185df381195351a913f3777f
Christian Brabandt <cb@256bit.org>
parents:
8402
diff
changeset
|
8410 source_runtime((char_u *)FTPLUGIN_FILE, DIP_ALL); |
7 | 8411 filetype_plugin = TRUE; |
8412 } | |
8413 if (indent) | |
8414 { | |
8524
2f57bbe870ea
commit https://github.com/vim/vim/commit/7f8989dd8a627af2185df381195351a913f3777f
Christian Brabandt <cb@256bit.org>
parents:
8402
diff
changeset
|
8415 source_runtime((char_u *)INDENT_FILE, DIP_ALL); |
7 | 8416 filetype_indent = TRUE; |
8417 } | |
8418 } | |
8419 if (*arg == 'd') | |
8420 { | |
9260
ac8180818504
commit https://github.com/vim/vim/commit/1610d052413e0ed664498853a47acc2d677a22d1
Christian Brabandt <cb@256bit.org>
parents:
9230
diff
changeset
|
8421 (void)do_doautocmd((char_u *)"filetypedetect BufRead", TRUE, NULL); |
717 | 8422 do_modelines(0); |
7 | 8423 } |
8424 } | |
8425 else if (STRCMP(arg, "off") == 0) | |
8426 { | |
8427 if (plugin || indent) | |
8428 { | |
8429 if (plugin) | |
8430 { | |
8524
2f57bbe870ea
commit https://github.com/vim/vim/commit/7f8989dd8a627af2185df381195351a913f3777f
Christian Brabandt <cb@256bit.org>
parents:
8402
diff
changeset
|
8431 source_runtime((char_u *)FTPLUGOF_FILE, DIP_ALL); |
7 | 8432 filetype_plugin = FALSE; |
8433 } | |
8434 if (indent) | |
8435 { | |
8524
2f57bbe870ea
commit https://github.com/vim/vim/commit/7f8989dd8a627af2185df381195351a913f3777f
Christian Brabandt <cb@256bit.org>
parents:
8402
diff
changeset
|
8436 source_runtime((char_u *)INDOFF_FILE, DIP_ALL); |
7 | 8437 filetype_indent = FALSE; |
8438 } | |
8439 } | |
8440 else | |
8441 { | |
8524
2f57bbe870ea
commit https://github.com/vim/vim/commit/7f8989dd8a627af2185df381195351a913f3777f
Christian Brabandt <cb@256bit.org>
parents:
8402
diff
changeset
|
8442 source_runtime((char_u *)FTOFF_FILE, DIP_ALL); |
7 | 8443 filetype_detect = FALSE; |
8444 } | |
8445 } | |
8446 else | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8447 semsg(_(e_invarg2), arg); |
7 | 8448 } |
8449 | |
8450 /* | |
11459
561b76ed9d12
patch 8.0.0613: the conf filetype is used before ftdetect from packages
Christian Brabandt <cb@256bit.org>
parents:
11428
diff
changeset
|
8451 * ":setfiletype [FALLBACK] {name}" |
7 | 8452 */ |
8453 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8454 ex_setfiletype(exarg_T *eap) |
7 | 8455 { |
8456 if (!did_filetype) | |
11459
561b76ed9d12
patch 8.0.0613: the conf filetype is used before ftdetect from packages
Christian Brabandt <cb@256bit.org>
parents:
11428
diff
changeset
|
8457 { |
561b76ed9d12
patch 8.0.0613: the conf filetype is used before ftdetect from packages
Christian Brabandt <cb@256bit.org>
parents:
11428
diff
changeset
|
8458 char_u *arg = eap->arg; |
561b76ed9d12
patch 8.0.0613: the conf filetype is used before ftdetect from packages
Christian Brabandt <cb@256bit.org>
parents:
11428
diff
changeset
|
8459 |
561b76ed9d12
patch 8.0.0613: the conf filetype is used before ftdetect from packages
Christian Brabandt <cb@256bit.org>
parents:
11428
diff
changeset
|
8460 if (STRNCMP(arg, "FALLBACK ", 9) == 0) |
561b76ed9d12
patch 8.0.0613: the conf filetype is used before ftdetect from packages
Christian Brabandt <cb@256bit.org>
parents:
11428
diff
changeset
|
8461 arg += 9; |
561b76ed9d12
patch 8.0.0613: the conf filetype is used before ftdetect from packages
Christian Brabandt <cb@256bit.org>
parents:
11428
diff
changeset
|
8462 |
561b76ed9d12
patch 8.0.0613: the conf filetype is used before ftdetect from packages
Christian Brabandt <cb@256bit.org>
parents:
11428
diff
changeset
|
8463 set_option_value((char_u *)"filetype", 0L, arg, OPT_LOCAL); |
561b76ed9d12
patch 8.0.0613: the conf filetype is used before ftdetect from packages
Christian Brabandt <cb@256bit.org>
parents:
11428
diff
changeset
|
8464 if (arg != eap->arg) |
561b76ed9d12
patch 8.0.0613: the conf filetype is used before ftdetect from packages
Christian Brabandt <cb@256bit.org>
parents:
11428
diff
changeset
|
8465 did_filetype = FALSE; |
561b76ed9d12
patch 8.0.0613: the conf filetype is used before ftdetect from packages
Christian Brabandt <cb@256bit.org>
parents:
11428
diff
changeset
|
8466 } |
7 | 8467 } |
8468 | |
8469 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8470 ex_digraphs(exarg_T *eap UNUSED) |
7 | 8471 { |
8472 #ifdef FEAT_DIGRAPHS | |
8473 if (*eap->arg != NUL) | |
8474 putdigraph(eap->arg); | |
8475 else | |
15152
1ef429366fd4
patch 8.1.0586: :digraph output is not easy to read
Bram Moolenaar <Bram@vim.org>
parents:
15125
diff
changeset
|
8476 listdigraphs(eap->forceit); |
7 | 8477 #else |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8478 emsg(_("E196: No digraphs in this version")); |
7 | 8479 #endif |
8480 } | |
8481 | |
8482 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8483 ex_set(exarg_T *eap) |
7 | 8484 { |
8485 int flags = 0; | |
8486 | |
8487 if (eap->cmdidx == CMD_setlocal) | |
8488 flags = OPT_LOCAL; | |
8489 else if (eap->cmdidx == CMD_setglobal) | |
8490 flags = OPT_GLOBAL; | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
8491 #if defined(FEAT_EVAL) && defined(FEAT_BROWSE) |
7 | 8492 if (cmdmod.browse && flags == 0) |
8493 ex_options(eap); | |
8494 else | |
8495 #endif | |
8496 (void)do_set(eap->arg, flags); | |
8497 } | |
8498 | |
13792
0e9b2971d7c3
patch 8.0.1768: SET_NO_HLSEARCH() used in a wrong way
Christian Brabandt <cb@256bit.org>
parents:
13581
diff
changeset
|
8499 #if defined(FEAT_SEARCH_EXTRA) || defined(PROTO) |
0e9b2971d7c3
patch 8.0.1768: SET_NO_HLSEARCH() used in a wrong way
Christian Brabandt <cb@256bit.org>
parents:
13581
diff
changeset
|
8500 void |
0e9b2971d7c3
patch 8.0.1768: SET_NO_HLSEARCH() used in a wrong way
Christian Brabandt <cb@256bit.org>
parents:
13581
diff
changeset
|
8501 set_no_hlsearch(int flag) |
0e9b2971d7c3
patch 8.0.1768: SET_NO_HLSEARCH() used in a wrong way
Christian Brabandt <cb@256bit.org>
parents:
13581
diff
changeset
|
8502 { |
0e9b2971d7c3
patch 8.0.1768: SET_NO_HLSEARCH() used in a wrong way
Christian Brabandt <cb@256bit.org>
parents:
13581
diff
changeset
|
8503 no_hlsearch = flag; |
0e9b2971d7c3
patch 8.0.1768: SET_NO_HLSEARCH() used in a wrong way
Christian Brabandt <cb@256bit.org>
parents:
13581
diff
changeset
|
8504 # ifdef FEAT_EVAL |
0e9b2971d7c3
patch 8.0.1768: SET_NO_HLSEARCH() used in a wrong way
Christian Brabandt <cb@256bit.org>
parents:
13581
diff
changeset
|
8505 set_vim_var_nr(VV_HLSEARCH, !no_hlsearch && p_hls); |
0e9b2971d7c3
patch 8.0.1768: SET_NO_HLSEARCH() used in a wrong way
Christian Brabandt <cb@256bit.org>
parents:
13581
diff
changeset
|
8506 # endif |
0e9b2971d7c3
patch 8.0.1768: SET_NO_HLSEARCH() used in a wrong way
Christian Brabandt <cb@256bit.org>
parents:
13581
diff
changeset
|
8507 } |
0e9b2971d7c3
patch 8.0.1768: SET_NO_HLSEARCH() used in a wrong way
Christian Brabandt <cb@256bit.org>
parents:
13581
diff
changeset
|
8508 |
7 | 8509 /* |
8510 * ":nohlsearch" | |
8511 */ | |
8512 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8513 ex_nohlsearch(exarg_T *eap UNUSED) |
7 | 8514 { |
13792
0e9b2971d7c3
patch 8.0.1768: SET_NO_HLSEARCH() used in a wrong way
Christian Brabandt <cb@256bit.org>
parents:
13581
diff
changeset
|
8515 set_no_hlsearch(TRUE); |
737 | 8516 redraw_all_later(SOME_VALID); |
7 | 8517 } |
8518 #endif | |
8519 | |
8520 #ifdef FEAT_CRYPT | |
8521 /* | |
8522 * ":X": Get crypt key | |
8523 */ | |
8524 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8525 ex_X(exarg_T *eap UNUSED) |
7 | 8526 { |
6353 | 8527 crypt_check_current_method(); |
6122 | 8528 (void)crypt_get_key(TRUE, TRUE); |
7 | 8529 } |
8530 #endif | |
8531 | |
8532 #ifdef FEAT_FOLDING | |
8533 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8534 ex_fold(exarg_T *eap) |
7 | 8535 { |
8536 if (foldManualAllowed(TRUE)) | |
8537 foldCreate(eap->line1, eap->line2); | |
8538 } | |
8539 | |
8540 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8541 ex_foldopen(exarg_T *eap) |
7 | 8542 { |
8543 opFoldRange(eap->line1, eap->line2, eap->cmdidx == CMD_foldopen, | |
8544 eap->forceit, FALSE); | |
8545 } | |
8546 | |
8547 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8548 ex_folddo(exarg_T *eap) |
7 | 8549 { |
8550 linenr_T lnum; | |
8551 | |
18297
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
8552 # ifdef FEAT_CLIPBOARD |
6116 | 8553 start_global_changes(); |
18297
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
8554 # endif |
6116 | 8555 |
7 | 8556 /* First set the marks for all lines closed/open. */ |
8557 for (lnum = eap->line1; lnum <= eap->line2; ++lnum) | |
8558 if (hasFolding(lnum, NULL, NULL) == (eap->cmdidx == CMD_folddoclosed)) | |
8559 ml_setmarked(lnum); | |
8560 | |
8561 /* Execute the command on the marked lines. */ | |
8562 global_exe(eap->arg); | |
8563 ml_clearmarked(); /* clear rest of the marks */ | |
18297
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
8564 # ifdef FEAT_CLIPBOARD |
6116 | 8565 end_global_changes(); |
18297
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
8566 # endif |
6116 | 8567 } |
8568 #endif | |
12459
937356f8f8d6
patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents:
12457
diff
changeset
|
8569 |
14550
60b9b6196644
patch 8.1.0288: quickfix code uses cmdidx too often
Christian Brabandt <cb@256bit.org>
parents:
14538
diff
changeset
|
8570 #ifdef FEAT_QUICKFIX |
60b9b6196644
patch 8.1.0288: quickfix code uses cmdidx too often
Christian Brabandt <cb@256bit.org>
parents:
14538
diff
changeset
|
8571 /* |
60b9b6196644
patch 8.1.0288: quickfix code uses cmdidx too often
Christian Brabandt <cb@256bit.org>
parents:
14538
diff
changeset
|
8572 * Returns TRUE if the supplied Ex cmdidx is for a location list command |
60b9b6196644
patch 8.1.0288: quickfix code uses cmdidx too often
Christian Brabandt <cb@256bit.org>
parents:
14538
diff
changeset
|
8573 * instead of a quickfix command. |
60b9b6196644
patch 8.1.0288: quickfix code uses cmdidx too often
Christian Brabandt <cb@256bit.org>
parents:
14538
diff
changeset
|
8574 */ |
60b9b6196644
patch 8.1.0288: quickfix code uses cmdidx too often
Christian Brabandt <cb@256bit.org>
parents:
14538
diff
changeset
|
8575 int |
60b9b6196644
patch 8.1.0288: quickfix code uses cmdidx too often
Christian Brabandt <cb@256bit.org>
parents:
14538
diff
changeset
|
8576 is_loclist_cmd(int cmdidx) |
60b9b6196644
patch 8.1.0288: quickfix code uses cmdidx too often
Christian Brabandt <cb@256bit.org>
parents:
14538
diff
changeset
|
8577 { |
14621
89cc3e7ecb68
patch 8.1.0324: off-by-one error in cmdidx check
Christian Brabandt <cb@256bit.org>
parents:
14591
diff
changeset
|
8578 if (cmdidx < 0 || cmdidx >= CMD_SIZE) |
14550
60b9b6196644
patch 8.1.0288: quickfix code uses cmdidx too often
Christian Brabandt <cb@256bit.org>
parents:
14538
diff
changeset
|
8579 return FALSE; |
60b9b6196644
patch 8.1.0288: quickfix code uses cmdidx too often
Christian Brabandt <cb@256bit.org>
parents:
14538
diff
changeset
|
8580 return cmdnames[cmdidx].cmd_name[0] == 'l'; |
60b9b6196644
patch 8.1.0288: quickfix code uses cmdidx too often
Christian Brabandt <cb@256bit.org>
parents:
14538
diff
changeset
|
8581 } |
60b9b6196644
patch 8.1.0288: quickfix code uses cmdidx too often
Christian Brabandt <cb@256bit.org>
parents:
14538
diff
changeset
|
8582 #endif |
60b9b6196644
patch 8.1.0288: quickfix code uses cmdidx too often
Christian Brabandt <cb@256bit.org>
parents:
14538
diff
changeset
|
8583 |
18297
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
8584 #if defined(FEAT_TIMERS) || defined(PROTO) |
12459
937356f8f8d6
patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents:
12457
diff
changeset
|
8585 int |
937356f8f8d6
patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents:
12457
diff
changeset
|
8586 get_pressedreturn(void) |
937356f8f8d6
patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents:
12457
diff
changeset
|
8587 { |
937356f8f8d6
patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents:
12457
diff
changeset
|
8588 return ex_pressedreturn; |
937356f8f8d6
patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents:
12457
diff
changeset
|
8589 } |
937356f8f8d6
patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents:
12457
diff
changeset
|
8590 |
937356f8f8d6
patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents:
12457
diff
changeset
|
8591 void |
937356f8f8d6
patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents:
12457
diff
changeset
|
8592 set_pressedreturn(int val) |
937356f8f8d6
patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents:
12457
diff
changeset
|
8593 { |
937356f8f8d6
patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents:
12457
diff
changeset
|
8594 ex_pressedreturn = val; |
937356f8f8d6
patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents:
12457
diff
changeset
|
8595 } |
937356f8f8d6
patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents:
12457
diff
changeset
|
8596 #endif |