Mercurial > vim
annotate src/ex_docmd.c @ 20027:23a4aef4f923 v8.2.0569
patch 8.2.0569: build failure with tiny version
Commit: https://github.com/vim/vim/commit/fbda69b309ca1c9748eaac38ab85b9e3425bf834
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Apr 13 15:06:53 2020 +0200
patch 8.2.0569: build failure with tiny version
Problem: Build failure with tiny version.
Solution: Add #ifdef.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 13 Apr 2020 15:15:04 +0200 |
parents | c85d4e173cc9 |
children | de756b3f4dee |
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 | |
18904
2bdc2e1f6e1f
patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents:
18849
diff
changeset
|
23 static char_u *do_one_cmd(char_u **, int, cstack_T *, 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); |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
26 static int if_level = 0; // depth in :if |
7 | 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 |
7 | 31 #ifndef FEAT_MENU |
32 # define ex_emenu ex_ni | |
33 # define ex_menu ex_ni | |
34 # define ex_menutranslate ex_ni | |
35 #endif | |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
36 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
|
37 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
|
38 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
|
39 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
|
40 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
|
41 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
|
42 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
|
43 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
|
44 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
|
45 static char_u *getargcmd(char_u **); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
46 static int getargopt(exarg_T *eap); |
7 | 47 #ifndef FEAT_QUICKFIX |
48 # define ex_make ex_ni | |
41 | 49 # define ex_cbuffer ex_ni |
7 | 50 # define ex_cc ex_ni |
51 # 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
|
52 # define ex_cbelow ex_ni |
7 | 53 # define ex_cfile ex_ni |
54 # define qf_list ex_ni | |
55 # define qf_age ex_ni | |
9538
26da1efa9e46
commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
56 # define qf_history ex_ni |
7 | 57 # define ex_helpgrep ex_ni |
41 | 58 # define ex_vimgrep ex_ni |
7 | 59 #endif |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
60 #if !defined(FEAT_QUICKFIX) |
7 | 61 # define ex_cclose ex_ni |
62 # define ex_copen ex_ni | |
63 # define ex_cwindow ex_ni | |
9432
abb72f0b9e06
commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents:
9284
diff
changeset
|
64 # define ex_cbottom ex_ni |
7 | 65 #endif |
532 | 66 #if !defined(FEAT_QUICKFIX) || !defined(FEAT_EVAL) |
67 # define ex_cexpr ex_ni | |
68 #endif | |
7 | 69 |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
70 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
|
71 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
|
72 #if !defined(FEAT_PERL) \ |
aee7e1e5e0ce
Build problem when using all interfaces except Lua.
Bram Moolenaar <bram@vim.org>
parents:
2330
diff
changeset
|
73 || !defined(FEAT_PYTHON) || !defined(FEAT_PYTHON3) \ |
aee7e1e5e0ce
Build problem when using all interfaces except Lua.
Bram Moolenaar <bram@vim.org>
parents:
2330
diff
changeset
|
74 || !defined(FEAT_TCL) \ |
aee7e1e5e0ce
Build problem when using all interfaces except Lua.
Bram Moolenaar <bram@vim.org>
parents:
2330
diff
changeset
|
75 || !defined(FEAT_RUBY) \ |
aee7e1e5e0ce
Build problem when using all interfaces except Lua.
Bram Moolenaar <bram@vim.org>
parents:
2330
diff
changeset
|
76 || !defined(FEAT_LUA) \ |
aee7e1e5e0ce
Build problem when using all interfaces except Lua.
Bram Moolenaar <bram@vim.org>
parents:
2330
diff
changeset
|
77 || !defined(FEAT_MZSCHEME) |
1315 | 78 # define HAVE_EX_SCRIPT_NI |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
79 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
|
80 #endif |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
81 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
|
82 static void correct_range(exarg_T *eap); |
344 | 83 #ifdef FEAT_QUICKFIX |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
84 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
|
85 #endif |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
86 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
|
87 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
|
88 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
|
89 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
|
90 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
|
91 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
|
92 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
|
93 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
|
94 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
|
95 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
|
96 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
|
97 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
|
98 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
|
99 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
|
100 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
|
101 #if defined(FEAT_QUICKFIX) |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
102 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
|
103 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
|
104 static void ex_pedit(exarg_T *eap); |
7 | 105 #else |
106 # define ex_pclose ex_ni | |
107 # define ex_ptag ex_ni | |
108 # define ex_pedit ex_ni | |
109 #endif | |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
110 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
|
111 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
|
112 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
|
113 static void ex_print(exarg_T *eap); |
7 | 114 #ifdef FEAT_BYTEOFF |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
115 static void ex_goto(exarg_T *eap); |
7 | 116 #else |
117 # define ex_goto ex_ni | |
118 #endif | |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
119 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
|
120 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
|
121 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
|
122 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
|
123 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
|
124 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
|
125 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
|
126 static void ex_edit(exarg_T *eap); |
7 | 127 #ifndef FEAT_GUI |
128 # define ex_gui ex_nogui | |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
129 static void ex_nogui(exarg_T *eap); |
7 | 130 #endif |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15866
diff
changeset
|
131 #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
|
132 static void ex_tearoff(exarg_T *eap); |
7 | 133 #else |
134 # define ex_tearoff ex_ni | |
135 #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
|
136 #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
|
137 || 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
|
138 static void ex_popup(exarg_T *eap); |
7 | 139 #else |
140 # define ex_popup ex_ni | |
141 #endif | |
142 #ifndef FEAT_GUI_MSWIN | |
143 # define ex_simalt ex_ni | |
144 #endif | |
573 | 145 #if !defined(FEAT_GUI_MSWIN) && !defined(FEAT_GUI_GTK) && !defined(FEAT_GUI_MOTIF) |
7 | 146 # define gui_mch_find_dialog ex_ni |
147 # define gui_mch_replace_dialog ex_ni | |
148 #endif | |
573 | 149 #if !defined(FEAT_GUI_GTK) |
7 | 150 # define ex_helpfind ex_ni |
151 #endif | |
152 #ifndef FEAT_CSCOPE | |
10373
bd674706408a
commit https://github.com/vim/vim/commit/d4db7719bdfbc54df396eac08d8cbb2389feacf4
Christian Brabandt <cb@256bit.org>
parents:
10361
diff
changeset
|
153 # define ex_cscope ex_ni |
bd674706408a
commit https://github.com/vim/vim/commit/d4db7719bdfbc54df396eac08d8cbb2389feacf4
Christian Brabandt <cb@256bit.org>
parents:
10361
diff
changeset
|
154 # define ex_scscope ex_ni |
bd674706408a
commit https://github.com/vim/vim/commit/d4db7719bdfbc54df396eac08d8cbb2389feacf4
Christian Brabandt <cb@256bit.org>
parents:
10361
diff
changeset
|
155 # define ex_cstag ex_ni |
7 | 156 #endif |
157 #ifndef FEAT_SYN_HL | |
158 # define ex_syntax ex_ni | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2238
diff
changeset
|
159 # define ex_ownsyntax ex_ni |
737 | 160 #endif |
4766
ec24ff78a79c
updated for version 7.3.1130
Bram Moolenaar <bram@vim.org>
parents:
4764
diff
changeset
|
161 #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
|
162 # define ex_syntime ex_ni |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4710
diff
changeset
|
163 #endif |
737 | 164 #ifndef FEAT_SPELL |
310 | 165 # define ex_spell ex_ni |
236 | 166 # define ex_mkspell ex_ni |
351 | 167 # define ex_spelldump ex_ni |
714 | 168 # define ex_spellinfo ex_ni |
372 | 169 # define ex_spellrepall ex_ni |
236 | 170 #endif |
2214
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
171 #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
|
172 # 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
|
173 # 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
|
174 #endif |
2320
966a5609669e
Added Lua interfae. (Luis Carvalho)
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
175 #ifndef FEAT_LUA |
966a5609669e
Added Lua interfae. (Luis Carvalho)
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
176 # define ex_lua ex_script_ni |
966a5609669e
Added Lua interfae. (Luis Carvalho)
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
177 # define ex_luado ex_ni |
966a5609669e
Added Lua interfae. (Luis Carvalho)
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
178 # define ex_luafile ex_ni |
966a5609669e
Added Lua interfae. (Luis Carvalho)
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
179 #endif |
14 | 180 #ifndef FEAT_MZSCHEME |
181 # define ex_mzscheme ex_script_ni | |
182 # define ex_mzfile ex_ni | |
183 #endif | |
7 | 184 #ifndef FEAT_PERL |
185 # define ex_perl ex_script_ni | |
186 # define ex_perldo ex_ni | |
187 #endif | |
188 #ifndef FEAT_PYTHON | |
189 # define ex_python ex_script_ni | |
4435 | 190 # define ex_pydo ex_ni |
7 | 191 # define ex_pyfile ex_ni |
192 #endif | |
2329
ad2889f48843
Added support for Python 3. (Roland Puntaier)
Bram Moolenaar <bram@vim.org>
parents:
2320
diff
changeset
|
193 #ifndef FEAT_PYTHON3 |
2350
06feaf4fe36a
Rename some "python3" symbols to "py3", as the command name.
Bram Moolenaar <bram@vim.org>
parents:
2340
diff
changeset
|
194 # define ex_py3 ex_script_ni |
4417 | 195 # define ex_py3do ex_ni |
2329
ad2889f48843
Added support for Python 3. (Roland Puntaier)
Bram Moolenaar <bram@vim.org>
parents:
2320
diff
changeset
|
196 # define ex_py3file ex_ni |
ad2889f48843
Added support for Python 3. (Roland Puntaier)
Bram Moolenaar <bram@vim.org>
parents:
2320
diff
changeset
|
197 #endif |
10722
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10656
diff
changeset
|
198 #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
|
199 # 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
|
200 # 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
|
201 # 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
|
202 #endif |
7 | 203 #ifndef FEAT_TCL |
204 # define ex_tcl ex_script_ni | |
205 # define ex_tcldo ex_ni | |
206 # define ex_tclfile ex_ni | |
207 #endif | |
208 #ifndef FEAT_RUBY | |
209 # define ex_ruby ex_script_ni | |
210 # define ex_rubydo ex_ni | |
211 # define ex_rubyfile ex_ni | |
212 #endif | |
213 #ifndef FEAT_KEYMAP | |
214 # define ex_loadkeymap ex_ni | |
215 #endif | |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
216 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
|
217 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
|
218 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
|
219 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
|
220 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
|
221 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
|
222 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
|
223 static void ex_wincmd(exarg_T *eap); |
11 | 224 #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
|
225 static void ex_winpos(exarg_T *eap); |
7 | 226 #else |
227 # define ex_winpos ex_ni | |
228 #endif | |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
229 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
|
230 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
|
231 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
|
232 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
|
233 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
|
234 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
|
235 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
|
236 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
|
237 #ifdef FEAT_PERSISTENT_UNDO |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
238 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
|
239 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
|
240 #endif |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
241 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
|
242 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
|
243 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
|
244 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
|
245 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
|
246 static void close_redir(void); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
247 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
|
248 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
|
249 static void ex_stopinsert(exarg_T *eap); |
7 | 250 #ifdef FEAT_FIND_ID |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
251 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
|
252 static void ex_findpat(exarg_T *eap); |
7 | 253 #else |
254 # define ex_findpat ex_ni | |
255 # define ex_checkpath ex_ni | |
256 #endif | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
257 #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
|
258 static void ex_psearch(exarg_T *eap); |
7 | 259 #else |
260 # define ex_psearch ex_ni | |
261 #endif | |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
262 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
|
263 static void ex_tag_cmd(exarg_T *eap, char_u *name); |
7 | 264 #ifndef FEAT_EVAL |
17622
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
265 # define ex_break ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
266 # define ex_breakadd ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
267 # define ex_breakdel ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
268 # define ex_breaklist ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
269 # define ex_call ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
270 # define ex_catch ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
271 # define ex_compiler ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
272 # define ex_const ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
273 # define ex_continue ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
274 # define ex_debug ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
275 # define ex_debuggreedy ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
276 # define ex_delfunction ex_ni |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
277 # define ex_disassemble 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 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
303 # define ex_vim9script ex_ni |
17622
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
304 # define ex_while ex_ni |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
305 # define ex_import ex_ni |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
306 # define ex_export ex_ni |
7 | 307 #endif |
17536
e00d12c085a5
patch 8.1.1766: code for writing session file is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17496
diff
changeset
|
308 #ifndef FEAT_SESSION |
7 | 309 # define ex_loadview ex_ni |
310 #endif | |
17458
cfdef48743ed
patch 8.1.1727: code for viminfo support is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17431
diff
changeset
|
311 #ifndef FEAT_VIMINFO |
7 | 312 # define ex_viminfo ex_ni |
313 #endif | |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
314 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
|
315 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
|
316 static void ex_setfiletype(exarg_T *eap); |
7 | 317 #ifndef FEAT_DIFF |
16 | 318 # define ex_diffoff ex_ni |
7 | 319 # define ex_diffpatch ex_ni |
320 # define ex_diffgetput ex_ni | |
321 # define ex_diffsplit ex_ni | |
322 # define ex_diffthis ex_ni | |
323 # define ex_diffupdate ex_ni | |
324 #endif | |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
325 static void ex_digraphs(exarg_T *eap); |
7 | 326 #ifdef FEAT_SEARCH_EXTRA |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
327 static void ex_nohlsearch(exarg_T *eap); |
7 | 328 #else |
329 # define ex_nohlsearch ex_ni | |
330 # define ex_match ex_ni | |
331 #endif | |
332 #ifdef FEAT_CRYPT | |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
333 static void ex_X(exarg_T *eap); |
7 | 334 #else |
335 # define ex_X ex_ni | |
336 #endif | |
337 #ifdef FEAT_FOLDING | |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
338 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
|
339 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
|
340 static void ex_folddo(exarg_T *eap); |
7 | 341 #else |
342 # define ex_fold ex_ni | |
343 # define ex_foldopen ex_ni | |
344 # define ex_folddo ex_ni | |
345 #endif | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
346 #if !(defined(HAVE_LOCALE_H) || defined(X_LOCALE)) |
7 | 347 # define ex_language ex_ni |
348 #endif | |
349 #ifndef FEAT_SIGNS | |
350 # define ex_sign ex_ni | |
351 #endif | |
33 | 352 #ifndef FEAT_NETBEANS_INTG |
2210 | 353 # define ex_nbclose ex_ni |
33 | 354 # define ex_nbkey ex_ni |
2210 | 355 # define ex_nbstart ex_ni |
33 | 356 #endif |
7 | 357 |
358 #ifndef FEAT_JUMPLIST | |
359 # define ex_jumps ex_ni | |
9284
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
9260
diff
changeset
|
360 # define ex_clearjumps ex_ni |
7 | 361 # define ex_changes ex_ni |
362 #endif | |
363 | |
170 | 364 #ifndef FEAT_PROFILE |
365 # define ex_profile ex_ni | |
366 #endif | |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
11547
diff
changeset
|
367 #ifndef FEAT_TERMINAL |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
11547
diff
changeset
|
368 # define ex_terminal ex_ni |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
11547
diff
changeset
|
369 #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
|
370 #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
|
371 # 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
|
372 #endif |
18763
49b78d6465e5
patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents:
18715
diff
changeset
|
373 #if !defined(FEAT_PROP_POPUP) |
16780
491c01280a5d
patch 8.1.1392: build failure in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
374 # define ex_popupclear ex_ni |
491c01280a5d
patch 8.1.1392: build failure in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
375 #endif |
170 | 376 |
7 | 377 /* |
378 * Declare cmdnames[]. | |
379 */ | |
380 #define DO_DECLARE_EXCMD | |
381 #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
|
382 #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
|
383 |
7 | 384 static char_u dollar_command[2] = {'$', 0}; |
385 | |
386 | |
387 #ifdef FEAT_EVAL | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
388 // Struct for storing a line inside a while/for loop |
7 | 389 typedef struct |
390 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
391 char_u *line; // command line |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
392 linenr_T lnum; // sourcing_lnum of the line |
7 | 393 } wcmd_T; |
394 | |
395 /* | |
72 | 396 * Structure used to store info for line position in a while or for loop. |
7 | 397 * This is required, because do_one_cmd() may invoke ex_function(), which |
72 | 398 * reads more lines that may come from the while/for loop. |
399 */ | |
400 struct loop_cookie | |
7 | 401 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
402 garray_T *lines_gap; // growarray with line info |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
403 int current_line; // last read line from growarray |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
404 int repeating; // TRUE when looping a second time |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
405 // 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
|
406 char_u *(*getline)(int, void *, int, int); |
7 | 407 void *cookie; |
408 }; | |
409 | |
17178
40c4cb095d53
patch 8.1.1588: in :let-heredoc line continuation is recognized
Bram Moolenaar <Bram@vim.org>
parents:
17111
diff
changeset
|
410 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
|
411 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
|
412 static void free_cmdlines(garray_T *gap); |
8 | 413 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
414 // Struct to save a few things while debugging. Used in do_cmdline() only. |
8 | 415 struct dbg_stuff |
416 { | |
417 int trylevel; | |
418 int force_abort; | |
419 except_T *caught_stack; | |
420 char_u *vv_exception; | |
421 char_u *vv_throwpoint; | |
422 int did_emsg; | |
423 int got_int; | |
424 int did_throw; | |
425 int need_rethrow; | |
426 int check_cstack; | |
427 except_T *current_exception; | |
428 }; | |
429 | |
430 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
431 save_dbg_stuff(struct dbg_stuff *dsp) |
8 | 432 { |
433 dsp->trylevel = trylevel; trylevel = 0; | |
434 dsp->force_abort = force_abort; force_abort = FALSE; | |
435 dsp->caught_stack = caught_stack; caught_stack = NULL; | |
436 dsp->vv_exception = v_exception(NULL); | |
437 dsp->vv_throwpoint = v_throwpoint(NULL); | |
438 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
439 // Necessary for debugging an inactive ":catch", ":finally", ":endtry" |
8 | 440 dsp->did_emsg = did_emsg; did_emsg = FALSE; |
441 dsp->got_int = got_int; got_int = FALSE; | |
442 dsp->did_throw = did_throw; did_throw = FALSE; | |
443 dsp->need_rethrow = need_rethrow; need_rethrow = FALSE; | |
444 dsp->check_cstack = check_cstack; check_cstack = FALSE; | |
445 dsp->current_exception = current_exception; current_exception = NULL; | |
446 } | |
447 | |
448 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
449 restore_dbg_stuff(struct dbg_stuff *dsp) |
8 | 450 { |
451 suppress_errthrow = FALSE; | |
452 trylevel = dsp->trylevel; | |
453 force_abort = dsp->force_abort; | |
454 caught_stack = dsp->caught_stack; | |
455 (void)v_exception(dsp->vv_exception); | |
456 (void)v_throwpoint(dsp->vv_throwpoint); | |
457 did_emsg = dsp->did_emsg; | |
458 got_int = dsp->got_int; | |
459 did_throw = dsp->did_throw; | |
460 need_rethrow = dsp->need_rethrow; | |
461 check_cstack = dsp->check_cstack; | |
462 current_exception = dsp->current_exception; | |
463 } | |
7 | 464 #endif |
465 | |
466 /* | |
467 * do_exmode(): Repeatedly get commands for the "Ex" mode, until the ":vi" | |
468 * command is given. | |
469 */ | |
470 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
471 do_exmode( |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
472 int improved) // TRUE for "improved Ex" mode |
7 | 473 { |
474 int save_msg_scroll; | |
475 int prev_msg_row; | |
476 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
|
477 varnumber_T changedtick; |
167 | 478 |
479 if (improved) | |
480 exmode_active = EXMODE_VIM; | |
481 else | |
482 exmode_active = EXMODE_NORMAL; | |
483 State = NORMAL; | |
484 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
485 // When using ":global /pat/ visual" and then "Q" we return to continue |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
486 // the :global command. |
167 | 487 if (global_busy) |
488 return; | |
7 | 489 |
490 save_msg_scroll = msg_scroll; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
491 ++RedrawingDisabled; // don't redisplay the window |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
492 ++no_wait_return; // don't wait for return |
7 | 493 #ifdef FEAT_GUI |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
494 // Ignore scrollbar and mouse events in Ex mode |
7 | 495 ++hold_gui_events; |
496 #endif | |
497 | |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15510
diff
changeset
|
498 msg(_("Entering Ex mode. Type \"visual\" to go to Normal mode.")); |
7 | 499 while (exmode_active) |
500 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
501 // Check for a ":normal" command and no more characters left. |
161 | 502 if (ex_normal_busy > 0 && typebuf.tb_len == 0) |
503 { | |
504 exmode_active = FALSE; | |
505 break; | |
506 } | |
7 | 507 msg_scroll = TRUE; |
508 need_wait_return = FALSE; | |
509 ex_pressedreturn = FALSE; | |
510 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
|
511 changedtick = CHANGEDTICK(curbuf); |
7 | 512 prev_msg_row = msg_row; |
513 prev_line = curwin->w_cursor.lnum; | |
514 if (improved) | |
515 { | |
516 cmdline_row = msg_row; | |
517 do_cmdline(NULL, getexline, NULL, 0); | |
518 } | |
519 else | |
520 do_cmdline(NULL, getexmodeline, NULL, DOCMD_NOWAIT); | |
521 lines_left = Rows - 1; | |
522 | |
167 | 523 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
|
524 || changedtick != CHANGEDTICK(curbuf)) && !ex_no_reprint) |
167 | 525 { |
526 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
|
527 emsg(_(e_emptybuf)); |
167 | 528 else |
529 { | |
530 if (ex_pressedreturn) | |
531 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
532 // go up one line, to overwrite the ":<CR>" line, so the |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
533 // output doesn't contain empty lines. |
167 | 534 msg_row = prev_msg_row; |
535 if (prev_msg_row == Rows - 1) | |
536 msg_row--; | |
537 } | |
538 msg_col = 0; | |
539 print_line_no_prefix(curwin->w_cursor.lnum, FALSE, FALSE); | |
540 msg_clr_eos(); | |
541 } | |
542 } | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
543 else if (ex_pressedreturn && !ex_no_reprint) // must be at EOF |
167 | 544 { |
545 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
|
546 emsg(_(e_emptybuf)); |
167 | 547 else |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
548 emsg(_("E501: At end-of-file")); |
167 | 549 } |
7 | 550 } |
551 | |
552 #ifdef FEAT_GUI | |
553 --hold_gui_events; | |
554 #endif | |
555 --RedrawingDisabled; | |
556 --no_wait_return; | |
557 update_screen(CLEAR); | |
558 need_wait_return = FALSE; | |
559 msg_scroll = save_msg_scroll; | |
560 } | |
561 | |
562 /* | |
18297
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
563 * 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
|
564 * 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
|
565 */ |
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
566 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
|
567 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
|
568 { |
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
569 ++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
|
570 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
|
571 |
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
572 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
|
573 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
|
574 else |
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
575 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
|
576 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
|
577 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
|
578 |
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
579 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
|
580 --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
|
581 } |
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
582 |
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
583 /* |
7 | 584 * Execute a simple command line. Used for translated commands like "*". |
585 */ | |
586 int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
587 do_cmdline_cmd(char_u *cmd) |
7 | 588 { |
589 return do_cmdline(cmd, NULL, NULL, | |
590 DOCMD_VERBOSE|DOCMD_NOWAIT|DOCMD_KEYTYPED); | |
591 } | |
592 | |
593 /* | |
594 * do_cmdline(): execute one Ex command line | |
595 * | |
596 * 1. Execute "cmdline" when it is not NULL. | |
2635 | 597 * If "cmdline" is NULL, or more lines are needed, fgetline() is used. |
7 | 598 * 2. Split up in parts separated with '|'. |
599 * | |
600 * This function can be called recursively! | |
601 * | |
602 * flags: | |
603 * DOCMD_VERBOSE - The command will be included in the error message. | |
604 * DOCMD_NOWAIT - Don't call wait_return() and friends. | |
2635 | 605 * DOCMD_REPEAT - Repeat execution until fgetline() returns NULL. |
7 | 606 * DOCMD_KEYTYPED - Don't reset KeyTyped. |
607 * DOCMD_EXCRESET - Reset the exception environment (used for debugging). | |
608 * DOCMD_KEEPLINE - Store first typed line (for repeating with "."). | |
609 * | |
610 * return FAIL if cmdline could not be executed, OK otherwise | |
611 */ | |
612 int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
613 do_cmdline( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
614 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
|
615 char_u *(*fgetline)(int, void *, int, int), |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
616 void *cookie, // argument for fgetline() |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
617 int flags) |
7 | 618 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
619 char_u *next_cmdline; // next cmd to execute |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
620 char_u *cmdline_copy = NULL; // copy of cmd line |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
621 int used_getline = FALSE; // used "fgetline" to obtain command |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
622 static int recursive = 0; // recursive depth |
7 | 623 int msg_didout_before_start = 0; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
624 int count = 0; // line number count |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
625 int did_inc = FALSE; // incremented RedrawingDisabled |
7 | 626 int retval = OK; |
627 #ifdef FEAT_EVAL | |
18904
2bdc2e1f6e1f
patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents:
18849
diff
changeset
|
628 cstack_T cstack; // conditional stack |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
629 garray_T lines_ga; // keep lines for ":while"/":for" |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
630 int current_line = 0; // active line in lines_ga |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
631 char_u *fname = NULL; // function or script name |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
632 linenr_T *breakpoint = NULL; // ptr to breakpoint field in cookie |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
633 int *dbg_tick = NULL; // ptr to dbg_tick field in cookie |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
634 struct dbg_stuff debug_saved; // saved things for debug mode |
7 | 635 int initial_trylevel; |
636 struct msglist **saved_msg_list = NULL; | |
637 struct msglist *private_msg_list; | |
638 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
639 // "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
|
640 char_u *(*cmd_getline)(int, void *, int, int); |
7 | 641 void *cmd_cookie; |
72 | 642 struct loop_cookie cmd_loop_cookie; |
7 | 643 void *real_cookie; |
170 | 644 int getline_is_func; |
7 | 645 #else |
2635 | 646 # define cmd_getline fgetline |
7 | 647 # define cmd_cookie cookie |
648 #endif | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
649 static int call_depth = 0; // recursiveness |
20009
6eb3c91d9875
patch 8.2.0560: compiler warning in tiny build
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
650 #ifdef FEAT_EVAL |
19075
af1eca322b9e
patch 8.2.0098: exe stack length can be wrong without being detected
Bram Moolenaar <Bram@vim.org>
parents:
19069
diff
changeset
|
651 ESTACK_CHECK_DECLARATION |
7 | 652 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
653 // For every pair of do_cmdline()/do_one_cmd() calls, use an extra memory |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
654 // location for storing error messages to be converted to an exception. |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
655 // This ensures that the do_errthrow() call in do_one_cmd() does not |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
656 // combine the messages stored by an earlier invocation of do_one_cmd() |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
657 // with the command name of the later one. This would happen when |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
658 // BufWritePost autocommands are executed after a write error. |
7 | 659 saved_msg_list = msg_list; |
660 msg_list = &private_msg_list; | |
661 private_msg_list = NULL; | |
662 #endif | |
663 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
664 // It's possible to create an endless loop with ":execute", catch that |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
665 // here. The value of 200 allows nested function calls, ":source", etc. |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
666 // 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
|
667 if (call_depth >= 200 |
8f2191b56d52
commit https://github.com/vim/vim/commit/b094ff4b2be4d8b7364c566a1cc7e27aa4452a50
Christian Brabandt <cb@256bit.org>
parents:
10488
diff
changeset
|
668 #ifdef FEAT_EVAL |
8f2191b56d52
commit https://github.com/vim/vim/commit/b094ff4b2be4d8b7364c566a1cc7e27aa4452a50
Christian Brabandt <cb@256bit.org>
parents:
10488
diff
changeset
|
669 && call_depth >= p_mfd |
8f2191b56d52
commit https://github.com/vim/vim/commit/b094ff4b2be4d8b7364c566a1cc7e27aa4452a50
Christian Brabandt <cb@256bit.org>
parents:
10488
diff
changeset
|
670 #endif |
8f2191b56d52
commit https://github.com/vim/vim/commit/b094ff4b2be4d8b7364c566a1cc7e27aa4452a50
Christian Brabandt <cb@256bit.org>
parents:
10488
diff
changeset
|
671 ) |
7 | 672 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
673 emsg(_("E169: Command too recursive")); |
7 | 674 #ifdef FEAT_EVAL |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
675 // When converting to an exception, we do not include the command name |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
676 // since this is not an error of the specific command. |
18904
2bdc2e1f6e1f
patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents:
18849
diff
changeset
|
677 do_errthrow((cstack_T *)NULL, (char_u *)NULL); |
7 | 678 msg_list = saved_msg_list; |
679 #endif | |
680 return FAIL; | |
681 } | |
682 ++call_depth; | |
683 | |
684 #ifdef FEAT_EVAL | |
685 cstack.cs_idx = -1; | |
72 | 686 cstack.cs_looplevel = 0; |
7 | 687 cstack.cs_trylevel = 0; |
688 cstack.cs_emsg_silent_list = NULL; | |
72 | 689 cstack.cs_lflags = 0; |
7 | 690 ga_init2(&lines_ga, (int)sizeof(wcmd_T), 10); |
691 | |
2635 | 692 real_cookie = getline_cookie(fgetline, cookie); |
7 | 693 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
694 // Inside a function use a higher nesting level. |
2635 | 695 getline_is_func = getline_equal(fgetline, cookie, get_func_line); |
170 | 696 if (getline_is_func && ex_nesting_level == func_level(real_cookie)) |
7 | 697 ++ex_nesting_level; |
698 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
699 // Get the function or script name and the address where the next breakpoint |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
700 // line and the debug tick for a function or script are stored. |
170 | 701 if (getline_is_func) |
7 | 702 { |
703 fname = func_name(real_cookie); | |
704 breakpoint = func_breakpoint(real_cookie); | |
705 dbg_tick = func_dbg_tick(real_cookie); | |
706 } | |
2635 | 707 else if (getline_equal(fgetline, cookie, getsourceline)) |
7 | 708 { |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18904
diff
changeset
|
709 fname = SOURCING_NAME; |
7 | 710 breakpoint = source_breakpoint(real_cookie); |
711 dbg_tick = source_dbg_tick(real_cookie); | |
712 } | |
713 | |
714 /* | |
715 * Initialize "force_abort" and "suppress_errthrow" at the top level. | |
716 */ | |
717 if (!recursive) | |
718 { | |
719 force_abort = FALSE; | |
720 suppress_errthrow = FALSE; | |
721 } | |
722 | |
723 /* | |
724 * If requested, store and reset the global values controlling the | |
944 | 725 * exception handling (used when debugging). Otherwise clear it to avoid |
726 * a bogus compiler warning when the optimizer uses inline functions... | |
7 | 727 */ |
878 | 728 if (flags & DOCMD_EXCRESET) |
8 | 729 save_dbg_stuff(&debug_saved); |
944 | 730 else |
20007
aadd1cae2ff5
patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
731 CLEAR_FIELD(debug_saved); |
7 | 732 |
733 initial_trylevel = trylevel; | |
734 | |
735 /* | |
736 * "did_throw" will be set to TRUE when an exception is being thrown. | |
737 */ | |
738 did_throw = FALSE; | |
739 #endif | |
740 /* | |
741 * "did_emsg" will be set to TRUE when emsg() is used, in which case we | |
72 | 742 * cancel the whole command line, and any if/endif or loop. |
7 | 743 * If force_abort is set, we cancel everything. |
744 */ | |
745 did_emsg = FALSE; | |
746 | |
747 /* | |
748 * KeyTyped is only set when calling vgetc(). Reset it here when not | |
749 * calling vgetc() (sourced command lines). | |
750 */ | |
2635 | 751 if (!(flags & DOCMD_KEYTYPED) |
752 && !getline_equal(fgetline, cookie, getexline)) | |
7 | 753 KeyTyped = FALSE; |
754 | |
755 /* | |
756 * Continue executing command lines: | |
72 | 757 * - when inside an ":if", ":while" or ":for" |
7 | 758 * - for multiple commands on one line, separated with '|' |
759 * - when repeating until there are no more lines (for ":source") | |
760 */ | |
761 next_cmdline = cmdline; | |
762 do | |
763 { | |
170 | 764 #ifdef FEAT_EVAL |
2635 | 765 getline_is_func = getline_equal(fgetline, cookie, get_func_line); |
170 | 766 #endif |
767 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
768 // stop skipping cmds for an error msg after all endif/while/for |
7 | 769 if (next_cmdline == NULL |
770 #ifdef FEAT_EVAL | |
771 && !force_abort | |
772 && cstack.cs_idx < 0 | |
170 | 773 && !(getline_is_func && func_has_abort(real_cookie)) |
7 | 774 #endif |
775 ) | |
776 did_emsg = FALSE; | |
777 | |
778 /* | |
72 | 779 * 1. If repeating a line in a loop, get a line from lines_ga. |
2635 | 780 * 2. If no line given: Get an allocated line with fgetline(). |
7 | 781 * 3. If a line is given: Make a copy, so we can mess with it. |
782 */ | |
783 | |
784 #ifdef FEAT_EVAL | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
785 // 1. If repeating, get a previous line from lines_ga. |
72 | 786 if (cstack.cs_looplevel > 0 && current_line < lines_ga.ga_len) |
7 | 787 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
788 // Each '|' separated command is stored separately in lines_ga, to |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
789 // 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
|
790 VIM_CLEAR(cmdline_copy); |
7 | 791 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
792 // Check if a function has returned or, unless it has an unclosed |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
793 // try conditional, aborted. |
170 | 794 if (getline_is_func) |
795 { | |
796 # ifdef FEAT_PROFILE | |
788 | 797 if (do_profiling == PROF_YES) |
170 | 798 func_line_end(real_cookie); |
799 # endif | |
800 if (func_has_ended(real_cookie)) | |
801 { | |
802 retval = FAIL; | |
803 break; | |
804 } | |
805 } | |
806 #ifdef FEAT_PROFILE | |
788 | 807 else if (do_profiling == PROF_YES |
2635 | 808 && getline_equal(fgetline, cookie, getsourceline)) |
170 | 809 script_line_end(); |
810 #endif | |
7 | 811 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
812 // Check if a sourced file hit a ":finish" command. |
2635 | 813 if (source_finished(fgetline, cookie)) |
7 | 814 { |
815 retval = FAIL; | |
816 break; | |
817 } | |
818 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
819 // If breakpoints have been added/deleted need to check for it. |
7 | 820 if (breakpoint != NULL && dbg_tick != NULL |
821 && *dbg_tick != debug_tick) | |
822 { | |
823 *breakpoint = dbg_find_breakpoint( | |
2635 | 824 getline_equal(fgetline, cookie, getsourceline), |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18904
diff
changeset
|
825 fname, SOURCING_LNUM); |
7 | 826 *dbg_tick = debug_tick; |
827 } | |
828 | |
829 next_cmdline = ((wcmd_T *)(lines_ga.ga_data))[current_line].line; | |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18904
diff
changeset
|
830 SOURCING_LNUM = ((wcmd_T *)(lines_ga.ga_data))[current_line].lnum; |
7 | 831 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
832 // Did we encounter a breakpoint? |
7 | 833 if (breakpoint != NULL && *breakpoint != 0 |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18904
diff
changeset
|
834 && *breakpoint <= SOURCING_LNUM) |
7 | 835 { |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18904
diff
changeset
|
836 dbg_breakpoint(fname, SOURCING_LNUM); |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
837 // Find next breakpoint. |
7 | 838 *breakpoint = dbg_find_breakpoint( |
2635 | 839 getline_equal(fgetline, cookie, getsourceline), |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18904
diff
changeset
|
840 fname, SOURCING_LNUM); |
7 | 841 *dbg_tick = debug_tick; |
842 } | |
170 | 843 # ifdef FEAT_PROFILE |
788 | 844 if (do_profiling == PROF_YES) |
170 | 845 { |
846 if (getline_is_func) | |
847 func_line_start(real_cookie); | |
2635 | 848 else if (getline_equal(fgetline, cookie, getsourceline)) |
170 | 849 script_line_start(); |
850 } | |
851 # endif | |
7 | 852 } |
853 | |
72 | 854 if (cstack.cs_looplevel > 0) |
855 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
856 // Inside a while/for loop we need to store the lines and use them |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
857 // again. Pass a different "fgetline" function to do_one_cmd() |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
858 // below, so that it stores lines in or reads them from |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
859 // "lines_ga". Makes it possible to define a function inside a |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
860 // while/for loop. |
72 | 861 cmd_getline = get_loop_line; |
862 cmd_cookie = (void *)&cmd_loop_cookie; | |
863 cmd_loop_cookie.lines_gap = &lines_ga; | |
864 cmd_loop_cookie.current_line = current_line; | |
2635 | 865 cmd_loop_cookie.getline = fgetline; |
72 | 866 cmd_loop_cookie.cookie = cookie; |
867 cmd_loop_cookie.repeating = (current_line < lines_ga.ga_len); | |
7 | 868 } |
869 else | |
870 { | |
2635 | 871 cmd_getline = fgetline; |
7 | 872 cmd_cookie = cookie; |
873 } | |
874 #endif | |
875 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
876 // 2. If no line given, get an allocated line with fgetline(). |
7 | 877 if (next_cmdline == NULL) |
878 { | |
879 /* | |
880 * Need to set msg_didout for the first line after an ":if", | |
881 * otherwise the ":if" will be overwritten. | |
882 */ | |
2635 | 883 if (count == 1 && getline_equal(fgetline, cookie, getexline)) |
7 | 884 msg_didout = TRUE; |
2635 | 885 if (fgetline == NULL || (next_cmdline = fgetline(':', cookie, |
7 | 886 #ifdef FEAT_EVAL |
887 cstack.cs_idx < 0 ? 0 : (cstack.cs_idx + 1) * 2 | |
888 #else | |
889 0 | |
890 #endif | |
17178
40c4cb095d53
patch 8.1.1588: in :let-heredoc line continuation is recognized
Bram Moolenaar <Bram@vim.org>
parents:
17111
diff
changeset
|
891 , TRUE)) == NULL) |
7 | 892 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
893 // Don't call wait_return for aborted command line. The NULL |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
894 // returned for the end of a sourced file or executed function |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
895 // doesn't do this. |
7 | 896 if (KeyTyped && !(flags & DOCMD_REPEAT)) |
897 need_wait_return = FALSE; | |
898 retval = FAIL; | |
899 break; | |
900 } | |
901 used_getline = TRUE; | |
902 | |
903 /* | |
904 * Keep the first typed line. Clear it when more lines are typed. | |
905 */ | |
906 if (flags & DOCMD_KEEPLINE) | |
907 { | |
908 vim_free(repeat_cmdline); | |
909 if (count == 0) | |
910 repeat_cmdline = vim_strsave(next_cmdline); | |
911 else | |
912 repeat_cmdline = NULL; | |
913 } | |
914 } | |
915 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
916 // 3. Make a copy of the command so we can mess with it. |
7 | 917 else if (cmdline_copy == NULL) |
918 { | |
919 next_cmdline = vim_strsave(next_cmdline); | |
920 if (next_cmdline == NULL) | |
921 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
922 emsg(_(e_outofmem)); |
7 | 923 retval = FAIL; |
924 break; | |
925 } | |
926 } | |
927 cmdline_copy = next_cmdline; | |
928 | |
929 #ifdef FEAT_EVAL | |
930 /* | |
72 | 931 * Save the current line when inside a ":while" or ":for", and when |
932 * the command looks like a ":while" or ":for", because we may need it | |
933 * later. When there is a '|' and another command, it is stored | |
934 * separately, because we need to be able to jump back to it from an | |
935 * :endwhile/:endfor. | |
7 | 936 */ |
72 | 937 if (current_line == lines_ga.ga_len |
938 && (cstack.cs_looplevel || has_loop_cmd(next_cmdline))) | |
939 { | |
940 if (store_loop_line(&lines_ga, next_cmdline) == FAIL) | |
7 | 941 { |
942 retval = FAIL; | |
943 break; | |
944 } | |
945 } | |
946 did_endif = FALSE; | |
947 #endif | |
948 | |
949 if (count++ == 0) | |
950 { | |
951 /* | |
952 * All output from the commands is put below each other, without | |
953 * waiting for a return. Don't do this when executing commands | |
954 * from a script or when being called recursive (e.g. for ":e | |
955 * +command file"). | |
956 */ | |
957 if (!(flags & DOCMD_NOWAIT) && !recursive) | |
958 { | |
959 msg_didout_before_start = msg_didout; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
960 msg_didany = FALSE; // no output yet |
7 | 961 msg_start(); |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
962 msg_scroll = TRUE; // put messages below each other |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
963 ++no_wait_return; // don't wait for return until finished |
7 | 964 ++RedrawingDisabled; |
965 did_inc = TRUE; | |
966 } | |
967 } | |
968 | |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18904
diff
changeset
|
969 if (p_verbose >= 15 && SOURCING_NAME != NULL) |
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18904
diff
changeset
|
970 msg_verbose_cmd(SOURCING_LNUM, cmdline_copy); |
7 | 971 |
972 /* | |
973 * 2. Execute one '|' separated command. | |
974 * do_one_cmd() will return NULL if there is no trailing '|'. | |
975 * "cmdline_copy" can change, e.g. for '%' and '#' expansion. | |
976 */ | |
977 ++recursive; | |
978 next_cmdline = do_one_cmd(&cmdline_copy, flags & DOCMD_VERBOSE, | |
979 #ifdef FEAT_EVAL | |
980 &cstack, | |
981 #endif | |
982 cmd_getline, cmd_cookie); | |
983 --recursive; | |
984 | |
985 #ifdef FEAT_EVAL | |
72 | 986 if (cmd_cookie == (void *)&cmd_loop_cookie) |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
987 // Use "current_line" from "cmd_loop_cookie", it may have been |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
988 // incremented when defining a function. |
72 | 989 current_line = cmd_loop_cookie.current_line; |
7 | 990 #endif |
991 | |
992 if (next_cmdline == NULL) | |
993 { | |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13221
diff
changeset
|
994 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
|
995 |
7 | 996 /* |
997 * If the command was typed, remember it for the ':' register. | |
998 * Do this AFTER executing the command to make :@: work. | |
999 */ | |
2635 | 1000 if (getline_equal(fgetline, cookie, getexline) |
7 | 1001 && new_last_cmdline != NULL) |
1002 { | |
1003 vim_free(last_cmdline); | |
1004 last_cmdline = new_last_cmdline; | |
1005 new_last_cmdline = NULL; | |
1006 } | |
1007 } | |
1008 else | |
1009 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1010 // need to copy the command after the '|' to cmdline_copy, for the |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1011 // next do_one_cmd() |
1619 | 1012 STRMOVE(cmdline_copy, next_cmdline); |
7 | 1013 next_cmdline = cmdline_copy; |
1014 } | |
1015 | |
1016 | |
1017 #ifdef FEAT_EVAL | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1018 // reset did_emsg for a function that is not aborted by an error |
7 | 1019 if (did_emsg && !force_abort |
2635 | 1020 && getline_equal(fgetline, cookie, get_func_line) |
7 | 1021 && !func_has_abort(real_cookie)) |
1022 did_emsg = FALSE; | |
1023 | |
72 | 1024 if (cstack.cs_looplevel > 0) |
7 | 1025 { |
1026 ++current_line; | |
1027 | |
1028 /* | |
72 | 1029 * An ":endwhile", ":endfor" and ":continue" is handled here. |
1030 * If we were executing commands, jump back to the ":while" or | |
1031 * ":for". | |
1032 * If we were not executing commands, decrement cs_looplevel. | |
7 | 1033 */ |
72 | 1034 if (cstack.cs_lflags & (CSL_HAD_CONT | CSL_HAD_ENDLOOP)) |
1035 { | |
1036 cstack.cs_lflags &= ~(CSL_HAD_CONT | CSL_HAD_ENDLOOP); | |
1037 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1038 // Jump back to the matching ":while" or ":for". Be careful |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1039 // not to use a cs_line[] from an entry that isn't a ":while" |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1040 // or ":for": It would make "current_line" invalid and can |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1041 // cause a crash. |
7 | 1042 if (!did_emsg && !got_int && !did_throw |
1043 && cstack.cs_idx >= 0 | |
72 | 1044 && (cstack.cs_flags[cstack.cs_idx] |
1045 & (CSF_WHILE | CSF_FOR)) | |
7 | 1046 && cstack.cs_line[cstack.cs_idx] >= 0 |
1047 && (cstack.cs_flags[cstack.cs_idx] & CSF_ACTIVE)) | |
1048 { | |
1049 current_line = cstack.cs_line[cstack.cs_idx]; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1050 // remember we jumped there |
72 | 1051 cstack.cs_lflags |= CSL_HAD_LOOP; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1052 line_breakcheck(); // check if CTRL-C typed |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1053 |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1054 // Check for the next breakpoint at or after the ":while" |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1055 // or ":for". |
7 | 1056 if (breakpoint != NULL) |
1057 { | |
1058 *breakpoint = dbg_find_breakpoint( | |
2635 | 1059 getline_equal(fgetline, cookie, getsourceline), |
7 | 1060 fname, |
1061 ((wcmd_T *)lines_ga.ga_data)[current_line].lnum-1); | |
1062 *dbg_tick = debug_tick; | |
1063 } | |
1064 } | |
72 | 1065 else |
7 | 1066 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1067 // can only get here with ":endwhile" or ":endfor" |
7 | 1068 if (cstack.cs_idx >= 0) |
77 | 1069 rewind_conditionals(&cstack, cstack.cs_idx - 1, |
1070 CSF_WHILE | CSF_FOR, &cstack.cs_looplevel); | |
7 | 1071 } |
1072 } | |
1073 | |
1074 /* | |
72 | 1075 * For a ":while" or ":for" we need to remember the line number. |
7 | 1076 */ |
72 | 1077 else if (cstack.cs_lflags & CSL_HAD_LOOP) |
1078 { | |
1079 cstack.cs_lflags &= ~CSL_HAD_LOOP; | |
7 | 1080 cstack.cs_line[cstack.cs_idx] = current_line - 1; |
1081 } | |
1082 } | |
1083 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1084 // Check for the next breakpoint after a watchexpression |
13262
69278c25429d
patch 8.0.1505: debugger can't break on a condition
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
1085 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
|
1086 { |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18904
diff
changeset
|
1087 *breakpoint = dbg_find_breakpoint(FALSE, fname, SOURCING_LNUM); |
13262
69278c25429d
patch 8.0.1505: debugger can't break on a condition
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
1088 *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
|
1089 } |
69278c25429d
patch 8.0.1505: debugger can't break on a condition
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
1090 |
7 | 1091 /* |
1092 * When not inside any ":while" loop, clear remembered lines. | |
1093 */ | |
72 | 1094 if (cstack.cs_looplevel == 0) |
7 | 1095 { |
1096 if (lines_ga.ga_len > 0) | |
1097 { | |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18904
diff
changeset
|
1098 SOURCING_LNUM = |
7 | 1099 ((wcmd_T *)lines_ga.ga_data)[lines_ga.ga_len - 1].lnum; |
1100 free_cmdlines(&lines_ga); | |
1101 } | |
1102 current_line = 0; | |
1103 } | |
1104 | |
1105 /* | |
72 | 1106 * A ":finally" makes did_emsg, got_int, and did_throw pending for |
1107 * being restored at the ":endtry". Reset them here and set the | |
1108 * ACTIVE and FINALLY flags, so that the finally clause gets executed. | |
1109 * This includes the case where a missing ":endif", ":endwhile" or | |
1110 * ":endfor" was detected by the ":finally" itself. | |
7 | 1111 */ |
72 | 1112 if (cstack.cs_lflags & CSL_HAD_FINA) |
1113 { | |
1114 cstack.cs_lflags &= ~CSL_HAD_FINA; | |
1115 report_make_pending(cstack.cs_pending[cstack.cs_idx] | |
1116 & (CSTP_ERROR | CSTP_INTERRUPT | CSTP_THROW), | |
7 | 1117 did_throw ? (void *)current_exception : NULL); |
1118 did_emsg = got_int = did_throw = FALSE; | |
1119 cstack.cs_flags[cstack.cs_idx] |= CSF_ACTIVE | CSF_FINALLY; | |
1120 } | |
1121 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1122 // Update global "trylevel" for recursive calls to do_cmdline() from |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1123 // within this loop. |
7 | 1124 trylevel = initial_trylevel + cstack.cs_trylevel; |
1125 | |
1126 /* | |
1190 | 1127 * If the outermost try conditional (across function calls and sourced |
7 | 1128 * files) is aborted because of an error, an interrupt, or an uncaught |
1129 * exception, cancel everything. If it is left normally, reset | |
1130 * force_abort to get the non-EH compatible abortion behavior for | |
1131 * the rest of the script. | |
1132 */ | |
1133 if (trylevel == 0 && !did_emsg && !got_int && !did_throw) | |
1134 force_abort = FALSE; | |
1135 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1136 // Convert an interrupt to an exception if appropriate. |
7 | 1137 (void)do_intthrow(&cstack); |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1138 #endif // FEAT_EVAL |
7 | 1139 |
1140 } | |
1141 /* | |
1142 * Continue executing command lines when: | |
1143 * - no CTRL-C typed, no aborting error, no exception thrown or try | |
1144 * conditionals need to be checked for executing finally clauses or | |
1145 * catching an interrupt exception | |
1146 * - didn't get an error message or lines are not typed | |
72 | 1147 * - there is a command after '|', inside a :if, :while, :for or :try, or |
7 | 1148 * looping for ":source" command or function call. |
1149 */ | |
1150 while (!((got_int | |
1151 #ifdef FEAT_EVAL | |
1152 || (did_emsg && force_abort) || did_throw | |
1153 #endif | |
1154 ) | |
1155 #ifdef FEAT_EVAL | |
1156 && cstack.cs_trylevel == 0 | |
1157 #endif | |
1158 ) | |
3757 | 1159 && !(did_emsg |
1160 #ifdef FEAT_EVAL | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1161 // Keep going when inside try/catch, so that the error can be |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1162 // deal with, except when it is a syntax error, it may cause |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1163 // the :endtry to be missed. |
3757 | 1164 && (cstack.cs_trylevel == 0 || did_emsg_syntax) |
1165 #endif | |
1166 && used_getline | |
2635 | 1167 && (getline_equal(fgetline, cookie, getexmodeline) |
1168 || getline_equal(fgetline, cookie, getexline))) | |
7 | 1169 && (next_cmdline != NULL |
1170 #ifdef FEAT_EVAL | |
1171 || cstack.cs_idx >= 0 | |
1172 #endif | |
1173 || (flags & DOCMD_REPEAT))); | |
1174 | |
1175 vim_free(cmdline_copy); | |
3757 | 1176 did_emsg_syntax = FALSE; |
7 | 1177 #ifdef FEAT_EVAL |
1178 free_cmdlines(&lines_ga); | |
1179 ga_clear(&lines_ga); | |
1180 | |
1181 if (cstack.cs_idx >= 0) | |
1182 { | |
1183 /* | |
1184 * If a sourced file or executed function ran to its end, report the | |
1185 * unclosed conditional. | |
1186 */ | |
1187 if (!got_int && !did_throw | |
2635 | 1188 && ((getline_equal(fgetline, cookie, getsourceline) |
1189 && !source_finished(fgetline, cookie)) | |
1190 || (getline_equal(fgetline, cookie, get_func_line) | |
7 | 1191 && !func_has_ended(real_cookie)))) |
1192 { | |
1193 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
|
1194 emsg(_(e_endtry)); |
7 | 1195 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
|
1196 emsg(_(e_endwhile)); |
72 | 1197 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
|
1198 emsg(_(e_endfor)); |
7 | 1199 else |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
1200 emsg(_(e_endif)); |
7 | 1201 } |
1202 | |
1203 /* | |
1204 * Reset "trylevel" in case of a ":finish" or ":return" or a missing | |
1205 * ":endtry" in a sourced file or executed function. If the try | |
1206 * conditional is in its finally clause, ignore anything pending. | |
1207 * If it is in a catch clause, finish the caught exception. | |
77 | 1208 * Also cleanup any "cs_forinfo" structures. |
7 | 1209 */ |
1210 do | |
77 | 1211 { |
1212 int idx = cleanup_conditionals(&cstack, 0, TRUE); | |
1213 | |
111 | 1214 if (idx >= 0) |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1215 --idx; // remove try block not in its finally clause |
77 | 1216 rewind_conditionals(&cstack, idx, CSF_WHILE | CSF_FOR, |
1217 &cstack.cs_looplevel); | |
1218 } | |
1219 while (cstack.cs_idx >= 0); | |
7 | 1220 trylevel = initial_trylevel; |
1221 } | |
1222 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1223 // If a missing ":endtry", ":endwhile", ":endfor", or ":endif" or a memory |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1224 // lack was reported above and the error message is to be converted to an |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1225 // exception, do this now after rewinding the cstack. |
2635 | 1226 do_errthrow(&cstack, getline_equal(fgetline, cookie, get_func_line) |
7 | 1227 ? (char_u *)"endfunction" : (char_u *)NULL); |
1228 | |
1229 if (trylevel == 0) | |
1230 { | |
1231 /* | |
1232 * When an exception is being thrown out of the outermost try | |
1233 * conditional, discard the uncaught exception, disable the conversion | |
1234 * of interrupts or errors to exceptions, and ensure that no more | |
1235 * commands are executed. | |
1236 */ | |
1237 if (did_throw) | |
1238 { | |
1239 void *p = NULL; | |
1240 struct msglist *messages = NULL, *next; | |
1241 | |
1242 /* | |
1243 * If the uncaught exception is a user exception, report it as an | |
1244 * error. If it is an error exception, display the saved error | |
1245 * message now. For an interrupt exception, do nothing; the | |
1246 * interrupt message is given elsewhere. | |
1247 */ | |
1248 switch (current_exception->type) | |
1249 { | |
1250 case ET_USER: | |
272 | 1251 vim_snprintf((char *)IObuff, IOSIZE, |
1252 _("E605: Exception not caught: %s"), | |
7 | 1253 current_exception->value); |
1254 p = vim_strsave(IObuff); | |
1255 break; | |
1256 case ET_ERROR: | |
1257 messages = current_exception->messages; | |
1258 current_exception->messages = NULL; | |
1259 break; | |
1260 case ET_INTERRUPT: | |
1261 break; | |
1262 } | |
1263 | |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18904
diff
changeset
|
1264 estack_push(ETYPE_EXCEPT, current_exception->throw_name, |
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18904
diff
changeset
|
1265 current_exception->throw_lnum); |
19075
af1eca322b9e
patch 8.2.0098: exe stack length can be wrong without being detected
Bram Moolenaar <Bram@vim.org>
parents:
19069
diff
changeset
|
1266 ESTACK_CHECK_SETUP |
7 | 1267 current_exception->throw_name = NULL; |
1268 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1269 discard_current_exception(); // uses IObuff if 'verbose' |
7 | 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 } | |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18904
diff
changeset
|
1290 vim_free(SOURCING_NAME); |
19075
af1eca322b9e
patch 8.2.0098: exe stack length can be wrong without being detected
Bram Moolenaar <Bram@vim.org>
parents:
19069
diff
changeset
|
1291 ESTACK_CHECK_NOW |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18904
diff
changeset
|
1292 estack_pop(); |
7 | 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 | |
20009
6eb3c91d9875
patch 8.2.0560: compiler warning in tiny build
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
1298 * converted anymore, here.) This enables also the interrupt message |
7 | 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 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
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; | |
19685
d64f403289db
patch 8.2.0399: various memory leaks
Bram Moolenaar <Bram@vim.org>
parents:
19621
diff
changeset
|
1349 |
d64f403289db
patch 8.2.0399: various memory leaks
Bram Moolenaar <Bram@vim.org>
parents:
19621
diff
changeset
|
1350 // Cleanup if "cs_emsg_silent_list" remains. |
d64f403289db
patch 8.2.0399: various memory leaks
Bram Moolenaar <Bram@vim.org>
parents:
19621
diff
changeset
|
1351 if (cstack.cs_emsg_silent_list != NULL) |
d64f403289db
patch 8.2.0399: various memory leaks
Bram Moolenaar <Bram@vim.org>
parents:
19621
diff
changeset
|
1352 { |
d64f403289db
patch 8.2.0399: various memory leaks
Bram Moolenaar <Bram@vim.org>
parents:
19621
diff
changeset
|
1353 eslist_T *elem, *temp; |
d64f403289db
patch 8.2.0399: various memory leaks
Bram Moolenaar <Bram@vim.org>
parents:
19621
diff
changeset
|
1354 |
d64f403289db
patch 8.2.0399: various memory leaks
Bram Moolenaar <Bram@vim.org>
parents:
19621
diff
changeset
|
1355 for (elem = cstack.cs_emsg_silent_list; elem != NULL; elem = temp) |
d64f403289db
patch 8.2.0399: various memory leaks
Bram Moolenaar <Bram@vim.org>
parents:
19621
diff
changeset
|
1356 { |
d64f403289db
patch 8.2.0399: various memory leaks
Bram Moolenaar <Bram@vim.org>
parents:
19621
diff
changeset
|
1357 temp = elem->next; |
d64f403289db
patch 8.2.0399: various memory leaks
Bram Moolenaar <Bram@vim.org>
parents:
19621
diff
changeset
|
1358 vim_free(elem); |
d64f403289db
patch 8.2.0399: various memory leaks
Bram Moolenaar <Bram@vim.org>
parents:
19621
diff
changeset
|
1359 } |
d64f403289db
patch 8.2.0399: various memory leaks
Bram Moolenaar <Bram@vim.org>
parents:
19621
diff
changeset
|
1360 } |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1361 #endif // FEAT_EVAL |
7 | 1362 |
1363 /* | |
1364 * If there was too much output to fit on the command line, ask the user to | |
1365 * hit return before redrawing the screen. With the ":global" command we do | |
1366 * this only once after the command is finished. | |
1367 */ | |
1368 if (did_inc) | |
1369 { | |
1370 --RedrawingDisabled; | |
1371 --no_wait_return; | |
1372 msg_scroll = FALSE; | |
1373 | |
1374 /* | |
1375 * When just finished an ":if"-":else" which was typed, no need to | |
1376 * wait for hit-return. Also for an error situation. | |
1377 */ | |
1378 if (retval == FAIL | |
1379 #ifdef FEAT_EVAL | |
1380 || (did_endif && KeyTyped && !did_emsg) | |
1381 #endif | |
1382 ) | |
1383 { | |
1384 need_wait_return = FALSE; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1385 msg_didany = FALSE; // don't wait when restarting edit |
7 | 1386 } |
1387 else if (need_wait_return) | |
1388 { | |
1389 /* | |
1390 * The msg_start() above clears msg_didout. The wait_return we do | |
1391 * here should not overwrite the command that may be shown before | |
1392 * doing that. | |
1393 */ | |
1394 msg_didout |= msg_didout_before_start; | |
1395 wait_return(FALSE); | |
1396 } | |
1397 } | |
1398 | |
3976 | 1399 #ifdef FEAT_EVAL |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1400 did_endif = FALSE; // in case do_cmdline used recursively |
3976 | 1401 #else |
7 | 1402 /* |
1403 * Reset if_level, in case a sourced script file contains more ":if" than | |
1404 * ":endif" (could be ":if x | foo | endif"). | |
1405 */ | |
1406 if_level = 0; | |
3972 | 1407 #endif |
3963 | 1408 |
7 | 1409 --call_depth; |
1410 return retval; | |
1411 } | |
1412 | |
1413 #ifdef FEAT_EVAL | |
1414 /* | |
72 | 1415 * Obtain a line when inside a ":while" or ":for" loop. |
7 | 1416 */ |
1417 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
|
1418 get_loop_line(int c, void *cookie, int indent, int do_concat) |
7 | 1419 { |
72 | 1420 struct loop_cookie *cp = (struct loop_cookie *)cookie; |
7 | 1421 wcmd_T *wp; |
1422 char_u *line; | |
1423 | |
1424 if (cp->current_line + 1 >= cp->lines_gap->ga_len) | |
1425 { | |
1426 if (cp->repeating) | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1427 return NULL; // trying to read past ":endwhile"/":endfor" |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1428 |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1429 // First time inside the ":while"/":for": get line normally. |
7 | 1430 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
|
1431 line = getcmdline(c, 0L, indent, do_concat); |
7 | 1432 else |
17178
40c4cb095d53
patch 8.1.1588: in :let-heredoc line continuation is recognized
Bram Moolenaar <Bram@vim.org>
parents:
17111
diff
changeset
|
1433 line = cp->getline(c, cp->cookie, indent, do_concat); |
857 | 1434 if (line != NULL && store_loop_line(cp->lines_gap, line) == OK) |
7 | 1435 ++cp->current_line; |
1436 | |
1437 return line; | |
1438 } | |
1439 | |
1440 KeyTyped = FALSE; | |
1441 ++cp->current_line; | |
1442 wp = (wcmd_T *)(cp->lines_gap->ga_data) + cp->current_line; | |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18904
diff
changeset
|
1443 SOURCING_LNUM = wp->lnum; |
7 | 1444 return vim_strsave(wp->line); |
1445 } | |
1446 | |
1447 /* | |
1448 * Store a line in "gap" so that a ":while" loop can execute it again. | |
1449 */ | |
1450 static int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
1451 store_loop_line(garray_T *gap, char_u *line) |
7 | 1452 { |
1453 if (ga_grow(gap, 1) == FAIL) | |
1454 return FAIL; | |
1455 ((wcmd_T *)(gap->ga_data))[gap->ga_len].line = vim_strsave(line); | |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18904
diff
changeset
|
1456 ((wcmd_T *)(gap->ga_data))[gap->ga_len].lnum = SOURCING_LNUM; |
7 | 1457 ++gap->ga_len; |
1458 return OK; | |
1459 } | |
1460 | |
1461 /* | |
72 | 1462 * Free the lines stored for a ":while" or ":for" loop. |
7 | 1463 */ |
1464 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
1465 free_cmdlines(garray_T *gap) |
7 | 1466 { |
1467 while (gap->ga_len > 0) | |
1468 { | |
1469 vim_free(((wcmd_T *)(gap->ga_data))[gap->ga_len - 1].line); | |
1470 --gap->ga_len; | |
1471 } | |
1472 } | |
1473 #endif | |
1474 | |
1475 /* | |
944 | 1476 * If "fgetline" is get_loop_line(), return TRUE if the getline it uses equals |
1477 * "func". * Otherwise return TRUE when "fgetline" equals "func". | |
7 | 1478 */ |
1479 int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
1480 getline_equal( |
17178
40c4cb095d53
patch 8.1.1588: in :let-heredoc line continuation is recognized
Bram Moolenaar <Bram@vim.org>
parents:
17111
diff
changeset
|
1481 char_u *(*fgetline)(int, void *, int, int), |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1482 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
|
1483 char_u *(*func)(int, void *, int, int)) |
7 | 1484 { |
1485 #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
|
1486 char_u *(*gp)(int, void *, int, int); |
72 | 1487 struct loop_cookie *cp; |
1488 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1489 // When "fgetline" is "get_loop_line()" use the "cookie" to find the |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1490 // function that's originally used to obtain the lines. This may be |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1491 // nested several levels. |
944 | 1492 gp = fgetline; |
72 | 1493 cp = (struct loop_cookie *)cookie; |
1494 while (gp == get_loop_line) | |
7 | 1495 { |
1496 gp = cp->getline; | |
1497 cp = cp->cookie; | |
1498 } | |
1499 return gp == func; | |
1500 #else | |
944 | 1501 return fgetline == func; |
7 | 1502 #endif |
1503 } | |
1504 | |
1505 /* | |
944 | 1506 * If "fgetline" is get_loop_line(), return the cookie used by the original |
7 | 1507 * getline function. Otherwise return "cookie". |
1508 */ | |
1509 void * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
1510 getline_cookie( |
17178
40c4cb095d53
patch 8.1.1588: in :let-heredoc line continuation is recognized
Bram Moolenaar <Bram@vim.org>
parents:
17111
diff
changeset
|
1511 char_u *(*fgetline)(int, void *, int, int) UNUSED, |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1512 void *cookie) // argument for fgetline() |
7 | 1513 { |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
1514 #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
|
1515 char_u *(*gp)(int, void *, int, int); |
72 | 1516 struct loop_cookie *cp; |
1517 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1518 // When "fgetline" is "get_loop_line()" use the "cookie" to find the |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1519 // cookie that's originally used to obtain the lines. This may be nested |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1520 // several levels. |
944 | 1521 gp = fgetline; |
72 | 1522 cp = (struct loop_cookie *)cookie; |
1523 while (gp == get_loop_line) | |
7 | 1524 { |
1525 gp = cp->getline; | |
1526 cp = cp->cookie; | |
1527 } | |
1528 return cp; | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
1529 #else |
7 | 1530 return cookie; |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
1531 #endif |
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
1532 } |
7 | 1533 |
6398 | 1534 |
1535 /* | |
1536 * Helper function to apply an offset for buffer commands, i.e. ":bdelete", | |
1537 * ":bwipeout", etc. | |
1538 * Returns the buffer number. | |
1539 */ | |
1540 static int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
1541 compute_buffer_local_count(int addr_type, int lnum, int offset) |
6398 | 1542 { |
1543 buf_T *buf; | |
6417 | 1544 buf_T *nextbuf; |
6398 | 1545 int count = offset; |
1546 | |
1547 buf = firstbuf; | |
1548 while (buf->b_next != NULL && buf->b_fnum < lnum) | |
1549 buf = buf->b_next; | |
1550 while (count != 0) | |
1551 { | |
6417 | 1552 count += (offset < 0) ? 1 : -1; |
1553 nextbuf = (offset < 0) ? buf->b_prev : buf->b_next; | |
1554 if (nextbuf == NULL) | |
6398 | 1555 break; |
6417 | 1556 buf = nextbuf; |
6398 | 1557 if (addr_type == ADDR_LOADED_BUFFERS) |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1558 // skip over unloaded buffers |
6417 | 1559 while (buf->b_ml.ml_mfp == NULL) |
1560 { | |
1561 nextbuf = (offset < 0) ? buf->b_prev : buf->b_next; | |
1562 if (nextbuf == NULL) | |
1563 break; | |
1564 buf = nextbuf; | |
1565 } | |
1566 } | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1567 // we might have gone too far, last buffer is not loadedd |
6417 | 1568 if (addr_type == ADDR_LOADED_BUFFERS) |
1569 while (buf->b_ml.ml_mfp == NULL) | |
1570 { | |
1571 nextbuf = (offset >= 0) ? buf->b_prev : buf->b_next; | |
1572 if (nextbuf == NULL) | |
1573 break; | |
1574 buf = nextbuf; | |
1575 } | |
6398 | 1576 return buf->b_fnum; |
1577 } | |
1578 | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
1579 /* |
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
1580 * 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
|
1581 * 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
|
1582 */ |
6409 | 1583 static int |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
1584 current_win_nr(win_T *win) |
6409 | 1585 { |
1586 win_T *wp; | |
1587 int nr = 0; | |
1588 | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9538
diff
changeset
|
1589 FOR_ALL_WINDOWS(wp) |
6409 | 1590 { |
1591 ++nr; | |
1592 if (wp == win) | |
1593 break; | |
1594 } | |
1595 return nr; | |
1596 } | |
1597 | |
1598 static int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
1599 current_tab_nr(tabpage_T *tab) |
6409 | 1600 { |
1601 tabpage_T *tp; | |
1602 int nr = 0; | |
1603 | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9538
diff
changeset
|
1604 FOR_ALL_TABPAGES(tp) |
6409 | 1605 { |
1606 ++nr; | |
1607 if (tp == tab) | |
1608 break; | |
1609 } | |
1610 return nr; | |
1611 } | |
1612 | |
1613 # define CURRENT_WIN_NR current_win_nr(curwin) | |
1614 # define LAST_WIN_NR current_win_nr(NULL) | |
1615 # define CURRENT_TAB_NR current_tab_nr(curtab) | |
1616 # define LAST_TAB_NR current_tab_nr(NULL) | |
6398 | 1617 |
7 | 1618 /* |
1619 * Execute one Ex command. | |
1620 * | |
1621 * If 'sourcing' is TRUE, the command will be included in the error message. | |
1622 * | |
1623 * 1. skip comment lines and leading space | |
1624 * 2. handle command modifiers | |
6400 | 1625 * 3. find the command |
6398 | 1626 * 4. parse range |
6400 | 1627 * 5. Parse the command. |
6398 | 1628 * 6. parse arguments |
1629 * 7. switch on command name | |
7 | 1630 * |
944 | 1631 * Note: "fgetline" can be NULL. |
7 | 1632 * |
1633 * This function may be called recursively! | |
1634 */ | |
1635 #if (_MSC_VER == 1200) | |
1636 /* | |
8 | 1637 * Avoid optimisation bug in VC++ version 6.0 |
7 | 1638 */ |
128 | 1639 #pragma optimize( "g", off ) |
7 | 1640 #endif |
1641 static char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
1642 do_one_cmd( |
18904
2bdc2e1f6e1f
patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents:
18849
diff
changeset
|
1643 char_u **cmdlinep, |
2bdc2e1f6e1f
patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents:
18849
diff
changeset
|
1644 int sourcing, |
7 | 1645 #ifdef FEAT_EVAL |
18904
2bdc2e1f6e1f
patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents:
18849
diff
changeset
|
1646 cstack_T *cstack, |
2bdc2e1f6e1f
patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents:
18849
diff
changeset
|
1647 #endif |
2bdc2e1f6e1f
patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents:
18849
diff
changeset
|
1648 char_u *(*fgetline)(int, void *, int, int), |
2bdc2e1f6e1f
patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents:
18849
diff
changeset
|
1649 void *cookie) // argument for fgetline() |
2bdc2e1f6e1f
patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents:
18849
diff
changeset
|
1650 { |
2bdc2e1f6e1f
patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents:
18849
diff
changeset
|
1651 char_u *p; |
2bdc2e1f6e1f
patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents:
18849
diff
changeset
|
1652 linenr_T lnum; |
2bdc2e1f6e1f
patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents:
18849
diff
changeset
|
1653 long n; |
2bdc2e1f6e1f
patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents:
18849
diff
changeset
|
1654 char *errormsg = NULL; // error message |
2bdc2e1f6e1f
patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents:
18849
diff
changeset
|
1655 char_u *after_modifier = NULL; |
2bdc2e1f6e1f
patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents:
18849
diff
changeset
|
1656 exarg_T ea; // Ex command arguments |
2bdc2e1f6e1f
patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents:
18849
diff
changeset
|
1657 int save_msg_scroll = msg_scroll; |
2bdc2e1f6e1f
patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents:
18849
diff
changeset
|
1658 cmdmod_T save_cmdmod; |
2bdc2e1f6e1f
patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents:
18849
diff
changeset
|
1659 int save_reg_executing = reg_executing; |
2bdc2e1f6e1f
patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents:
18849
diff
changeset
|
1660 int ni; // set when Not Implemented |
2bdc2e1f6e1f
patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents:
18849
diff
changeset
|
1661 char_u *cmd; |
19497
639b1d672757
patch 8.2.0306: Vim9: :substitute(pat(repl does not work in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
19481
diff
changeset
|
1662 #ifdef FEAT_EVAL |
639b1d672757
patch 8.2.0306: Vim9: :substitute(pat(repl does not work in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
19481
diff
changeset
|
1663 int starts_with_colon; |
639b1d672757
patch 8.2.0306: Vim9: :substitute(pat(repl does not work in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
19481
diff
changeset
|
1664 #endif |
7 | 1665 |
20007
aadd1cae2ff5
patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
1666 CLEAR_FIELD(ea); |
7 | 1667 ea.line1 = 1; |
1668 ea.line2 = 1; | |
1669 #ifdef FEAT_EVAL | |
1670 ++ex_nesting_level; | |
1671 #endif | |
1672 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1673 // When the last file has not been edited :q has to be typed twice. |
7 | 1674 if (quitmore |
1675 #ifdef FEAT_EVAL | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1676 // avoid that a function call in 'statusline' does this |
944 | 1677 && !getline_equal(fgetline, cookie, get_func_line) |
4133 | 1678 #endif |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1679 // 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
|
1680 && !getline_equal(fgetline, cookie, getnextac)) |
7 | 1681 --quitmore; |
1682 | |
1683 /* | |
1684 * Reset browse, confirm, etc.. They are restored when returning, for | |
1685 * recursive calls. | |
1686 */ | |
1687 save_cmdmod = cmdmod; | |
1688 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1689 // "#!anything" is handled like a comment. |
930 | 1690 if ((*cmdlinep)[0] == '#' && (*cmdlinep)[1] == '!') |
1691 goto doend; | |
1692 | |
18297
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
1693 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
|
1694 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
|
1695 |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
1696 /* |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
1697 * 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
|
1698 * 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
|
1699 */ |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
1700 // The "ea" structure holds the arguments that can be used. |
7 | 1701 ea.cmd = *cmdlinep; |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
1702 ea.cmdlinep = cmdlinep; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
1703 ea.getline = fgetline; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
1704 ea.cookie = cookie; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
1705 #ifdef FEAT_EVAL |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
1706 ea.cstack = cstack; |
19497
639b1d672757
patch 8.2.0306: Vim9: :substitute(pat(repl does not work in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
19481
diff
changeset
|
1707 starts_with_colon = *skipwhite(ea.cmd) == ':'; |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
1708 #endif |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
1709 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
|
1710 goto doend; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
1711 |
9941
e975914c17e9
commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
9927
diff
changeset
|
1712 after_modifier = ea.cmd; |
7 | 1713 |
1714 #ifdef FEAT_EVAL | |
1715 ea.skip = did_emsg || got_int || did_throw || (cstack->cs_idx >= 0 | |
1716 && !(cstack->cs_flags[cstack->cs_idx] & CSF_ACTIVE)); | |
1717 #else | |
1718 ea.skip = (if_level > 0); | |
1719 #endif | |
1720 | |
1721 /* | |
6398 | 1722 * 3. Skip over the range to find the command. Let "p" point to after it. |
1723 * | |
1724 * We need the command to know what kind of range it uses. | |
1725 */ | |
1726 cmd = ea.cmd; | |
1727 ea.cmd = skip_range(ea.cmd, NULL); | |
1728 if (*ea.cmd == '*' && vim_strchr(p_cpo, CPO_STAR) == NULL) | |
1729 ea.cmd = skipwhite(ea.cmd + 1); | |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
1730 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
1731 #ifdef FEAT_EVAL |
19497
639b1d672757
patch 8.2.0306: Vim9: :substitute(pat(repl does not work in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
19481
diff
changeset
|
1732 if (current_sctx.sc_version == SCRIPT_VERSION_VIM9 && !starts_with_colon) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
1733 p = find_ex_command(&ea, NULL, lookup_scriptvar, NULL); |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
1734 else |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
1735 #endif |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
1736 p = find_ex_command(&ea, NULL, NULL, NULL); |
6398 | 1737 |
14591
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1738 #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
|
1739 # 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
|
1740 // 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
|
1741 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
|
1742 && (!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
|
1743 && (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
|
1744 { |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1745 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
|
1746 |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1747 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
|
1748 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
|
1749 && (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
|
1750 && !(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
|
1751 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
|
1752 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
|
1753 && !(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
|
1754 & (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
|
1755 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
|
1756 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
|
1757 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
|
1758 && 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
|
1759 && 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
|
1760 && 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
|
1761 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
|
1762 |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1763 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
|
1764 { |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1765 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
|
1766 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
|
1767 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
|
1768 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
|
1769 } |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1770 } |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1771 # endif |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1772 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1773 // May go to debug mode. If this happens and the ">quit" debug command is |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1774 // used, throw an interrupt exception and skip the next command. |
14591
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1775 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
|
1776 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
|
1777 { |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1778 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
|
1779 (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
|
1780 } |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1781 #endif |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1782 |
6398 | 1783 /* |
1784 * 4. parse a range specifier of the form: addr [,addr] [;addr] .. | |
7 | 1785 * |
1786 * where 'addr' is: | |
1787 * | |
1788 * % (entire file) | |
1789 * $ [+-NUM] | |
1790 * 'x [+-NUM] (where x denotes a currently defined mark) | |
1791 * . [+-NUM] | |
1792 * [+-NUM].. | |
1793 * NUM | |
1794 * | |
1795 * The ea.cmd pointer is updated to point to the first character following the | |
1796 * range spec. If an initial address is found, but no second, the upper bound | |
1797 * is equal to the lower. | |
1798 */ | |
1799 | |
16515
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
1800 // ea.addr_type for user commands is set by find_ucmd |
6489 | 1801 if (!IS_USER_CMDIDX(ea.cmdidx)) |
1802 { | |
1803 if (ea.cmdidx != CMD_SIZE) | |
1804 ea.addr_type = cmdnames[(int)ea.cmdidx].cmd_addr_type; | |
1805 else | |
1806 ea.addr_type = ADDR_LINES; | |
1807 | |
16515
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
1808 // :wincmd range depends on the argument. |
6506 | 1809 if (ea.cmdidx == CMD_wincmd && p != NULL) |
1810 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
|
1811 #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
|
1812 // :.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
|
1813 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
|
1814 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
|
1815 #endif |
6489 | 1816 } |
6398 | 1817 |
6489 | 1818 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
|
1819 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
|
1820 goto doend; |
7 | 1821 |
1822 /* | |
6398 | 1823 * 5. Parse the command. |
7 | 1824 */ |
1825 | |
1826 /* | |
1827 * Skip ':' and any white space | |
1828 */ | |
1829 ea.cmd = skipwhite(ea.cmd); | |
1830 while (*ea.cmd == ':') | |
1831 ea.cmd = skipwhite(ea.cmd + 1); | |
1832 | |
1833 /* | |
1834 * If we got a line, but no command, then go to the line. | |
1835 * If we find a '|' or '\n' we set ea.nextcmd. | |
1836 */ | |
6398 | 1837 if (*ea.cmd == NUL || *ea.cmd == '"' |
1838 || (ea.nextcmd = check_nextcmd(ea.cmd)) != NULL) | |
7 | 1839 { |
1840 /* | |
1841 * strange vi behaviour: | |
1842 * ":3" jumps to line 3 | |
1843 * ":3|..." prints line 3 | |
1844 * ":|" prints current line | |
1845 */ | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1846 if (ea.skip) // skip this if inside :if |
7 | 1847 goto doend; |
167 | 1848 if (*ea.cmd == '|' || (exmode_active && ea.line1 != ea.line2)) |
7 | 1849 { |
1850 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
|
1851 ea.argt = EX_RANGE+EX_COUNT+EX_TRLBAR; |
7 | 1852 if ((errormsg = invalid_range(&ea)) == NULL) |
1853 { | |
1854 correct_range(&ea); | |
1855 ex_print(&ea); | |
1856 } | |
1857 } | |
1858 else if (ea.addr_count != 0) | |
1859 { | |
631 | 1860 if (ea.line2 > curbuf->b_ml.ml_line_count) |
1861 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1862 // With '-' in 'cpoptions' a line number past the file is an |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1863 // error, otherwise put it at the end of the file. |
631 | 1864 if (vim_strchr(p_cpo, CPO_MINUS) != NULL) |
1865 ea.line2 = -1; | |
1866 else | |
1867 ea.line2 = curbuf->b_ml.ml_line_count; | |
1868 } | |
1869 | |
1870 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
|
1871 errormsg = _(e_invrange); |
7 | 1872 else |
1873 { | |
1874 if (ea.line2 == 0) | |
1875 curwin->w_cursor.lnum = 1; | |
1876 else | |
1877 curwin->w_cursor.lnum = ea.line2; | |
1878 beginline(BL_SOL | BL_FIX); | |
1879 } | |
1880 } | |
1881 goto doend; | |
1882 } | |
1883 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1884 // If this looks like an undefined user command and there are CmdUndefined |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1885 // autocommands defined, trigger the matching autocommands. |
6154 | 1886 if (p != NULL && ea.cmdidx == CMD_SIZE && !ea.skip |
1887 && ASCII_ISUPPER(*ea.cmd) | |
1888 && has_cmdundefined()) | |
1889 { | |
1890 int ret; | |
1891 | |
6156 | 1892 p = ea.cmd; |
6154 | 1893 while (ASCII_ISALNUM(*p)) |
1894 ++p; | |
6191 | 1895 p = vim_strnsave(ea.cmd, (int)(p - ea.cmd)); |
6154 | 1896 ret = apply_autocmds(EVENT_CMDUNDEFINED, p, p, TRUE, NULL); |
1897 vim_free(p); | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1898 // If the autocommands did something and didn't cause an error, try |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1899 // finding the command again. |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
1900 p = (ret |
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
1901 #ifdef FEAT_EVAL |
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
1902 && !aborting() |
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
1903 #endif |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
1904 ) ? find_ex_command(&ea, NULL, NULL, NULL) : ea.cmd; |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
1905 } |
6154 | 1906 |
7 | 1907 if (p == NULL) |
1908 { | |
1909 if (!ea.skip) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
1910 errormsg = _("E464: Ambiguous use of user-defined command"); |
7 | 1911 goto doend; |
1912 } | |
16411
5b5c5daf57de
patch 8.1.1210: support for user commands is spread out
Bram Moolenaar <Bram@vim.org>
parents:
16399
diff
changeset
|
1913 // 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
|
1914 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
|
1915 && !IS_USER_CMDIDX(ea.cmdidx)) |
7 | 1916 { |
1917 errormsg = uc_fun_cmd(); | |
1918 goto doend; | |
1919 } | |
16411
5b5c5daf57de
patch 8.1.1210: support for user commands is spread out
Bram Moolenaar <Bram@vim.org>
parents:
16399
diff
changeset
|
1920 |
7 | 1921 if (ea.cmdidx == CMD_SIZE) |
1922 { | |
1923 if (!ea.skip) | |
1924 { | |
1925 STRCPY(IObuff, _("E492: Not an editor command")); | |
1926 if (!sourcing) | |
9941
e975914c17e9
commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
9927
diff
changeset
|
1927 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1928 // If the modifier was parsed OK the error must be in the |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1929 // following command |
9941
e975914c17e9
commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
9927
diff
changeset
|
1930 if (after_modifier != NULL) |
e975914c17e9
commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
9927
diff
changeset
|
1931 append_command(after_modifier); |
e975914c17e9
commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
9927
diff
changeset
|
1932 else |
e975914c17e9
commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
9927
diff
changeset
|
1933 append_command(*cmdlinep); |
e975914c17e9
commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
9927
diff
changeset
|
1934 } |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
1935 errormsg = (char *)IObuff; |
3757 | 1936 did_emsg_syntax = TRUE; |
7 | 1937 } |
1938 goto doend; | |
1939 } | |
1940 | |
6305 | 1941 ni = (!IS_USER_CMDIDX(ea.cmdidx) |
1942 && (cmdnames[ea.cmdidx].cmd_func == ex_ni | |
1315 | 1943 #ifdef HAVE_EX_SCRIPT_NI |
1944 || cmdnames[ea.cmdidx].cmd_func == ex_script_ni | |
1945 #endif | |
1946 )); | |
7 | 1947 |
1948 #ifndef FEAT_EVAL | |
1949 /* | |
1950 * When the expression evaluation is disabled, recognize the ":if" and | |
1951 * ":endif" commands and ignore everything in between it. | |
1952 */ | |
1953 if (ea.cmdidx == CMD_if) | |
1954 ++if_level; | |
1955 if (if_level) | |
1956 { | |
1957 if (ea.cmdidx == CMD_endif) | |
1958 --if_level; | |
1959 goto doend; | |
1960 } | |
1961 | |
1962 #endif | |
1963 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1964 // forced commands |
1613 | 1965 if (*p == '!' && ea.cmdidx != CMD_substitute |
1966 && ea.cmdidx != CMD_smagic && ea.cmdidx != CMD_snomagic) | |
7 | 1967 { |
1968 ++p; | |
1969 ea.forceit = TRUE; | |
1970 } | |
1971 else | |
1972 ea.forceit = FALSE; | |
1973 | |
1974 /* | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
1975 * 6. Parse arguments. Then check for errors. |
7 | 1976 */ |
6305 | 1977 if (!IS_USER_CMDIDX(ea.cmdidx)) |
835 | 1978 ea.argt = (long)cmdnames[(int)ea.cmdidx].cmd_argt; |
7 | 1979 |
1980 if (!ea.skip) | |
1981 { | |
1982 #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
|
1983 if (sandbox != 0 && !(ea.argt & EX_SBOXOK)) |
7 | 1984 { |
15748
93b78c4a7cd5
patch 8.1.0881: can execute shell commands in rvim through interfaces
Bram Moolenaar <Bram@vim.org>
parents:
15713
diff
changeset
|
1985 // 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
|
1986 errormsg = _(e_sandbox); |
7 | 1987 goto doend; |
1988 } | |
1989 #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
|
1990 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
|
1991 { |
93b78c4a7cd5
patch 8.1.0881: can execute shell commands in rvim through interfaces
Bram Moolenaar <Bram@vim.org>
parents:
15713
diff
changeset
|
1992 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
|
1993 goto doend; |
93b78c4a7cd5
patch 8.1.0881: can execute shell commands in rvim through interfaces
Bram Moolenaar <Bram@vim.org>
parents:
15713
diff
changeset
|
1994 } |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
1995 if (!curbuf->b_p_ma && (ea.argt & EX_MODIFY)) |
7 | 1996 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1997 // 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
|
1998 errormsg = _(e_modifiable); |
7 | 1999 goto doend; |
2000 } | |
631 | 2001 |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2002 if (text_locked() && !(ea.argt & EX_CMDWIN) |
6305 | 2003 && !IS_USER_CMDIDX(ea.cmdidx)) |
7 | 2004 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2005 // 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
|
2006 errormsg = _(get_text_locked_msg()); |
7 | 2007 goto doend; |
2008 } | |
14648
c3222a7342ab
patch 8.1.0337: :file fails in quickfix command
Christian Brabandt <cb@256bit.org>
parents:
14640
diff
changeset
|
2009 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2010 // Disallow editing another buffer when "curbuf_lock" is set. |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2011 // Do allow ":checktime" (it is postponed). |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2012 // Do allow ":edit" (check for an argument later). |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2013 // 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
|
2014 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
|
2015 && ea.cmdidx != CMD_checktime |
822 | 2016 && ea.cmdidx != CMD_edit |
14648
c3222a7342ab
patch 8.1.0337: :file fails in quickfix command
Christian Brabandt <cb@256bit.org>
parents:
14640
diff
changeset
|
2017 && ea.cmdidx != CMD_file |
6305 | 2018 && !IS_USER_CMDIDX(ea.cmdidx) |
819 | 2019 && curbuf_locked()) |
2020 goto doend; | |
7 | 2021 |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2022 if (!ni && !(ea.argt & EX_RANGE) && ea.addr_count > 0) |
7 | 2023 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2024 // no range allowed |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2025 errormsg = _(e_norange); |
7 | 2026 goto doend; |
2027 } | |
2028 } | |
2029 | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2030 if (!ni && !(ea.argt & EX_BANG) && ea.forceit) // no <!> allowed |
7 | 2031 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2032 errormsg = _(e_nobang); |
7 | 2033 goto doend; |
2034 } | |
2035 | |
2036 /* | |
2037 * Don't complain about the range if it is not used | |
2038 * (could happen if line_count is accidentally set to 0). | |
2039 */ | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2040 if (!ea.skip && !ni && (ea.argt & EX_RANGE)) |
7 | 2041 { |
2042 /* | |
2043 * If the range is backwards, ask for confirmation and, if given, swap | |
2044 * ea.line1 & ea.line2 so it's forwards again. | |
2045 * When global command is busy, don't ask, will fail below. | |
2046 */ | |
2047 if (!global_busy && ea.line1 > ea.line2) | |
2048 { | |
557 | 2049 if (msg_silent == 0) |
2050 { | |
2051 if (sourcing || exmode_active) | |
2052 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2053 errormsg = _("E493: Backwards range given"); |
557 | 2054 goto doend; |
2055 } | |
7 | 2056 if (ask_yesno((char_u *) |
2057 _("Backwards range given, OK to swap"), FALSE) != 'y') | |
557 | 2058 goto doend; |
7 | 2059 } |
2060 lnum = ea.line1; | |
2061 ea.line1 = ea.line2; | |
2062 ea.line2 = lnum; | |
2063 } | |
2064 if ((errormsg = invalid_range(&ea)) != NULL) | |
2065 goto doend; | |
2066 } | |
2067 | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
2068 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
|
2069 // default is 1, not cursor |
7 | 2070 ea.line2 = 1; |
2071 | |
2072 correct_range(&ea); | |
2073 | |
2074 #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
|
2075 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
|
2076 && ea.addr_type == ADDR_LINES) |
7 | 2077 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2078 // Put the first line at the start of a closed fold, put the last line |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2079 // at the end of a closed fold. |
7 | 2080 (void)hasFolding(ea.line1, &ea.line1, NULL); |
2081 (void)hasFolding(ea.line2, NULL, &ea.line2); | |
2082 } | |
2083 #endif | |
2084 | |
2085 #ifdef FEAT_QUICKFIX | |
2086 /* | |
41 | 2087 * For the ":make" and ":grep" commands we insert the 'makeprg'/'grepprg' |
7 | 2088 * option here, so things like % get expanded. |
2089 */ | |
344 | 2090 p = replace_makeprg(&ea, p, cmdlinep); |
2091 if (p == NULL) | |
2092 goto doend; | |
7 | 2093 #endif |
2094 | |
2095 /* | |
2096 * Skip to start of argument. | |
2097 * Don't do this for the ":!" command, because ":!! -l" needs the space. | |
2098 */ | |
2099 if (ea.cmdidx == CMD_bang) | |
2100 ea.arg = p; | |
2101 else | |
2102 ea.arg = skipwhite(p); | |
2103 | |
14648
c3222a7342ab
patch 8.1.0337: :file fails in quickfix command
Christian Brabandt <cb@256bit.org>
parents:
14640
diff
changeset
|
2104 // ":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
|
2105 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
|
2106 goto doend; |
c3222a7342ab
patch 8.1.0337: :file fails in quickfix command
Christian Brabandt <cb@256bit.org>
parents:
14640
diff
changeset
|
2107 |
7 | 2108 /* |
2109 * Check for "++opt=val" argument. | |
2110 * Must be first, allow ":w ++enc=utf8 !cmd" | |
2111 */ | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2112 if (ea.argt & EX_ARGOPT) |
7 | 2113 while (ea.arg[0] == '+' && ea.arg[1] == '+') |
2114 if (getargopt(&ea) == FAIL && !ni) | |
2115 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2116 errormsg = _(e_invarg); |
7 | 2117 goto doend; |
2118 } | |
2119 | |
2120 if (ea.cmdidx == CMD_write || ea.cmdidx == CMD_update) | |
2121 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2122 if (*ea.arg == '>') // append |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2123 { |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2124 if (*++ea.arg != '>') // typed wrong |
7 | 2125 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2126 errormsg = _("E494: Use w or w>>"); |
7 | 2127 goto doend; |
2128 } | |
2129 ea.arg = skipwhite(ea.arg + 1); | |
2130 ea.append = TRUE; | |
2131 } | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2132 else if (*ea.arg == '!' && ea.cmdidx == CMD_write) // :w !filter |
7 | 2133 { |
2134 ++ea.arg; | |
2135 ea.usefilter = TRUE; | |
2136 } | |
2137 } | |
2138 | |
2139 if (ea.cmdidx == CMD_read) | |
2140 { | |
2141 if (ea.forceit) | |
2142 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2143 ea.usefilter = TRUE; // :r! filter if ea.forceit |
7 | 2144 ea.forceit = FALSE; |
2145 } | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2146 else if (*ea.arg == '!') // :r !filter |
7 | 2147 { |
2148 ++ea.arg; | |
2149 ea.usefilter = TRUE; | |
2150 } | |
2151 } | |
2152 | |
2153 if (ea.cmdidx == CMD_lshift || ea.cmdidx == CMD_rshift) | |
2154 { | |
2155 ea.amount = 1; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2156 while (*ea.arg == *ea.cmd) // count number of '>' or '<' |
7 | 2157 { |
2158 ++ea.arg; | |
2159 ++ea.amount; | |
2160 } | |
2161 ea.arg = skipwhite(ea.arg); | |
2162 } | |
2163 | |
2164 /* | |
2165 * Check for "+command" argument, before checking for next command. | |
2166 * Don't do this for ":read !cmd" and ":write !cmd". | |
2167 */ | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2168 if ((ea.argt & EX_CMDARG) && !ea.usefilter) |
7 | 2169 ea.do_ecmd_cmd = getargcmd(&ea.arg); |
2170 | |
2171 /* | |
2172 * Check for '|' to separate commands and '"' to start comments. | |
2173 * Don't do this for ":read !cmd" and ":write !cmd". | |
2174 */ | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2175 if ((ea.argt & EX_TRLBAR) && !ea.usefilter) |
7 | 2176 separate_nextcmd(&ea); |
2177 | |
2178 /* | |
2179 * Check for <newline> to end a shell command. | |
167 | 2180 * Also do this for ":read !cmd", ":write !cmd" and ":global". |
2181 * Any others? | |
7 | 2182 */ |
167 | 2183 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
|
2184 || ea.cmdidx == CMD_terminal |
167 | 2185 || ea.cmdidx == CMD_global |
2186 || ea.cmdidx == CMD_vglobal | |
2187 || ea.usefilter) | |
7 | 2188 { |
2189 for (p = ea.arg; *p; ++p) | |
2190 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2191 // Remove one backslash before a newline, so that it's possible to |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2192 // pass a newline to the shell and also a newline that is preceded |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2193 // with a backslash. This makes it impossible to end a shell |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2194 // command in a backslash, but that doesn't appear useful. |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2195 // Halving the number of backslashes is incompatible with previous |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2196 // versions. |
7 | 2197 if (*p == '\\' && p[1] == '\n') |
1619 | 2198 STRMOVE(p, p + 1); |
7 | 2199 else if (*p == '\n') |
2200 { | |
2201 ea.nextcmd = p + 1; | |
2202 *p = NUL; | |
2203 break; | |
2204 } | |
2205 } | |
2206 } | |
2207 | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2208 if ((ea.argt & EX_DFLALL) && ea.addr_count == 0) |
7 | 2209 { |
6424 | 2210 buf_T *buf; |
2211 | |
7 | 2212 ea.line1 = 1; |
6424 | 2213 switch (ea.addr_type) |
2214 { | |
2215 case ADDR_LINES: | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
2216 case ADDR_OTHER: |
6424 | 2217 ea.line2 = curbuf->b_ml.ml_line_count; |
2218 break; | |
2219 case ADDR_LOADED_BUFFERS: | |
2220 buf = firstbuf; | |
2221 while (buf->b_next != NULL && buf->b_ml.ml_mfp == NULL) | |
2222 buf = buf->b_next; | |
2223 ea.line1 = buf->b_fnum; | |
2224 buf = lastbuf; | |
2225 while (buf->b_prev != NULL && buf->b_ml.ml_mfp == NULL) | |
2226 buf = buf->b_prev; | |
2227 ea.line2 = buf->b_fnum; | |
2228 break; | |
2229 case ADDR_BUFFERS: | |
2230 ea.line1 = firstbuf->b_fnum; | |
2231 ea.line2 = lastbuf->b_fnum; | |
2232 break; | |
2233 case ADDR_WINDOWS: | |
2234 ea.line2 = LAST_WIN_NR; | |
2235 break; | |
2236 case ADDR_TABS: | |
2237 ea.line2 = LAST_TAB_NR; | |
2238 break; | |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
2239 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
|
2240 ea.line2 = 1; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
2241 break; |
6424 | 2242 case ADDR_ARGUMENTS: |
2243 if (ARGCOUNT == 0) | |
2244 ea.line1 = ea.line2 = 0; | |
2245 else | |
2246 ea.line2 = ARGCOUNT; | |
2247 break; | |
16515
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
2248 case ADDR_QUICKFIX_VALID: |
7105
f4456e686406
commit https://github.com/vim/vim/commit/e906c502079770ae0e0071c74cefb802689ff193
Christian Brabandt <cb@256bit.org>
parents:
7092
diff
changeset
|
2249 #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
|
2250 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
|
2251 if (ea.line2 == 0) |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
2252 ea.line2 = 1; |
16479
7dcf301d1432
patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents:
16475
diff
changeset
|
2253 #endif |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
2254 break; |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
2255 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
|
2256 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
|
2257 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
|
2258 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
|
2259 break; |
6424 | 2260 } |
7 | 2261 } |
2262 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2263 // 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
|
2264 if ( (ea.argt & EX_REGSTR) |
7 | 2265 && *ea.arg != NUL |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2266 // Do not allow register = for user commands |
6305 | 2267 && (!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
|
2268 && !((ea.argt & EX_COUNT) && VIM_ISDIGIT(*ea.arg))) |
7 | 2269 { |
2791 | 2270 #ifndef FEAT_CLIPBOARD |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2271 // check these explicitly for a more specific error message |
2791 | 2272 if (*ea.arg == '*' || *ea.arg == '+') |
2273 { | |
15474
79e3dcc5aa50
patch 8.1.0745: compiler warnings for signed/unsigned string
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
2274 errormsg = _(e_invalidreg); |
2791 | 2275 goto doend; |
2276 } | |
2277 #endif | |
6305 | 2278 if (valid_yank_reg(*ea.arg, (ea.cmdidx != CMD_put |
2279 && !IS_USER_CMDIDX(ea.cmdidx)))) | |
2791 | 2280 { |
2281 ea.regname = *ea.arg++; | |
7 | 2282 #ifdef FEAT_EVAL |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2283 // for '=' register: accept the rest of the line as an expression |
2791 | 2284 if (ea.arg[-1] == '=' && ea.arg[0] != NUL) |
2285 { | |
2286 set_expr_line(vim_strsave(ea.arg)); | |
2287 ea.arg += STRLEN(ea.arg); | |
2288 } | |
2289 #endif | |
2290 ea.arg = skipwhite(ea.arg); | |
2291 } | |
7 | 2292 } |
2293 | |
2294 /* | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2295 * Check for a count. When accepting a EX_BUFNAME, don't use "123foo" as a |
7 | 2296 * count, it's a buffer name. |
2297 */ | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2298 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
|
2299 && (!(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
|
2300 || VIM_ISWHITE(*p))) |
7 | 2301 { |
2302 n = getdigits(&ea.arg); | |
2303 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
|
2304 if (n <= 0 && !ni && (ea.argt & EX_ZEROR) == 0) |
7 | 2305 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2306 errormsg = _(e_zerocount); |
7 | 2307 goto doend; |
2308 } | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
2309 if (ea.addr_type != ADDR_LINES) // e.g. :buffer 2, :sleep 3 |
7 | 2310 { |
2311 ea.line2 = n; | |
2312 if (ea.addr_count == 0) | |
2313 ea.addr_count = 1; | |
2314 } | |
2315 else | |
2316 { | |
2317 ea.line1 = ea.line2; | |
2318 ea.line2 += n - 1; | |
2319 ++ea.addr_count; | |
2320 /* | |
2321 * Be vi compatible: no error message for out of range. | |
2322 */ | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
2323 if (ea.line2 > curbuf->b_ml.ml_line_count) |
7 | 2324 ea.line2 = curbuf->b_ml.ml_line_count; |
2325 } | |
2326 } | |
167 | 2327 |
2328 /* | |
2329 * Check for flags: 'l', 'p' and '#'. | |
2330 */ | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2331 if (ea.argt & EX_FLAGS) |
167 | 2332 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
|
2333 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
|
2334 && *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
|
2335 { |
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2336 // 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
|
2337 errormsg = _(e_trailing); |
7 | 2338 goto doend; |
2339 } | |
2340 | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2341 if (!ni && (ea.argt & EX_NEEDARG) && *ea.arg == NUL) |
7 | 2342 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2343 errormsg = _(e_argreq); |
7 | 2344 goto doend; |
2345 } | |
2346 | |
2347 #ifdef FEAT_EVAL | |
2348 /* | |
2349 * Skip the command when it's not going to be executed. | |
2350 * The commands like :if, :endif, etc. always need to be executed. | |
2351 * Also make an exception for commands that handle a trailing command | |
2352 * themselves. | |
2353 */ | |
2354 if (ea.skip) | |
2355 { | |
2356 switch (ea.cmdidx) | |
2357 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2358 // commands that need evaluation |
7 | 2359 case CMD_while: |
2360 case CMD_endwhile: | |
72 | 2361 case CMD_for: |
2362 case CMD_endfor: | |
7 | 2363 case CMD_if: |
2364 case CMD_elseif: | |
2365 case CMD_else: | |
2366 case CMD_endif: | |
2367 case CMD_try: | |
2368 case CMD_catch: | |
2369 case CMD_finally: | |
2370 case CMD_endtry: | |
2371 case CMD_function: | |
19575
3c0de44077cd
patch 8.2.0344: ":def" not skipped properly
Bram Moolenaar <Bram@vim.org>
parents:
19497
diff
changeset
|
2372 case CMD_def: |
7 | 2373 break; |
2374 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2375 // Commands that handle '|' themselves. Check: A command should |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2376 // either have the EX_TRLBAR flag, appear in this list or appear in |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2377 // the list at ":help :bar". |
7 | 2378 case CMD_aboveleft: |
2379 case CMD_and: | |
2380 case CMD_belowright: | |
2381 case CMD_botright: | |
2382 case CMD_browse: | |
2383 case CMD_call: | |
2384 case CMD_confirm: | |
18713
baf890fa1621
patch 8.1.2348: :const cannot be followed by "| endif"
Bram Moolenaar <Bram@vim.org>
parents:
18406
diff
changeset
|
2385 case CMD_const: |
7 | 2386 case CMD_delfunction: |
2387 case CMD_djump: | |
2388 case CMD_dlist: | |
2389 case CMD_dsearch: | |
2390 case CMD_dsplit: | |
2391 case CMD_echo: | |
2392 case CMD_echoerr: | |
2393 case CMD_echomsg: | |
2394 case CMD_echon: | |
19415
90e24240904b
patch 8.2.0265: "eval" after "if 0" doesn't check for following command
Bram Moolenaar <Bram@vim.org>
parents:
19348
diff
changeset
|
2395 case CMD_eval: |
7 | 2396 case CMD_execute: |
9941
e975914c17e9
commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
9927
diff
changeset
|
2397 case CMD_filter: |
7 | 2398 case CMD_help: |
2399 case CMD_hide: | |
2400 case CMD_ijump: | |
2401 case CMD_ilist: | |
2402 case CMD_isearch: | |
2403 case CMD_isplit: | |
22 | 2404 case CMD_keepalt: |
7 | 2405 case CMD_keepjumps: |
2406 case CMD_keepmarks: | |
5467 | 2407 case CMD_keeppatterns: |
7 | 2408 case CMD_leftabove: |
2409 case CMD_let: | |
2410 case CMD_lockmarks: | |
18715
bd4c34db84ab
patch 8.1.2349: :lockvar and :unlockvar cannot be followed by "| endif"
Bram Moolenaar <Bram@vim.org>
parents:
18713
diff
changeset
|
2411 case CMD_lockvar: |
2320
966a5609669e
Added Lua interfae. (Luis Carvalho)
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
2412 case CMD_lua: |
7 | 2413 case CMD_match: |
14 | 2414 case CMD_mzscheme: |
5737 | 2415 case CMD_noautocmd: |
2416 case CMD_noswapfile: | |
7 | 2417 case CMD_perl: |
2418 case CMD_psearch: | |
2419 case CMD_python: | |
2350
06feaf4fe36a
Rename some "python3" symbols to "py3", as the command name.
Bram Moolenaar <bram@vim.org>
parents:
2340
diff
changeset
|
2420 case CMD_py3: |
2366
7a57fe6a5157
Fix that :py3file was not working.
Bram Moolenaar <bram@vim.org>
parents:
2360
diff
changeset
|
2421 case CMD_python3: |
7 | 2422 case CMD_return: |
2423 case CMD_rightbelow: | |
2424 case CMD_ruby: | |
2425 case CMD_silent: | |
2426 case CMD_smagic: | |
2427 case CMD_snomagic: | |
2428 case CMD_substitute: | |
2429 case CMD_syntax: | |
690 | 2430 case CMD_tab: |
7 | 2431 case CMD_tcl: |
2432 case CMD_throw: | |
2433 case CMD_tilde: | |
2434 case CMD_topleft: | |
2435 case CMD_unlet: | |
18715
bd4c34db84ab
patch 8.1.2349: :lockvar and :unlockvar cannot be followed by "| endif"
Bram Moolenaar <Bram@vim.org>
parents:
18713
diff
changeset
|
2436 case CMD_unlockvar: |
7 | 2437 case CMD_verbose: |
2438 case CMD_vertical: | |
2887 | 2439 case CMD_wincmd: |
7 | 2440 break; |
2441 | |
2442 default: goto doend; | |
2443 } | |
2444 } | |
2445 #endif | |
2446 | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2447 if (ea.argt & EX_XFILE) |
7 | 2448 { |
2449 if (expand_filename(&ea, cmdlinep, &errormsg) == FAIL) | |
2450 goto doend; | |
2451 } | |
2452 | |
2453 /* | |
2454 * Accept buffer name. Cannot be used at the same time with a buffer | |
2455 * number. Don't do this for a user command. | |
2456 */ | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2457 if ((ea.argt & EX_BUFNAME) && *ea.arg != NUL && ea.addr_count == 0 |
6305 | 2458 && !IS_USER_CMDIDX(ea.cmdidx)) |
7 | 2459 { |
2460 /* | |
2461 * :bdelete, :bwipeout and :bunload take several arguments, separated | |
2462 * by spaces: find next space (skipping over escaped characters). | |
2463 * The others take one argument: ignore trailing spaces. | |
2464 */ | |
2465 if (ea.cmdidx == CMD_bdelete || ea.cmdidx == CMD_bwipeout | |
2466 || ea.cmdidx == CMD_bunload) | |
2467 p = skiptowhite_esc(ea.arg); | |
2468 else | |
2469 { | |
2470 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
|
2471 while (p > ea.arg && VIM_ISWHITE(p[-1])) |
7 | 2472 --p; |
2473 } | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2474 ea.line2 = buflist_findpat(ea.arg, p, (ea.argt & EX_BUFUNL) != 0, |
4236 | 2475 FALSE, FALSE); |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2476 if (ea.line2 < 0) // failed |
7 | 2477 goto doend; |
2478 ea.addr_count = 1; | |
2479 ea.arg = skipwhite(p); | |
2480 } | |
2481 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2482 // The :try command saves the emsg_silent flag, reset it here when |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2483 // ":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
|
2484 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
|
2485 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2486 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
|
2487 if (emsg_silent < 0) |
530943a23d3f
patch 8.0.1518: error messages suppressed after ":silent! try"
Christian Brabandt <cb@256bit.org>
parents:
13268
diff
changeset
|
2488 emsg_silent = 0; |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2489 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
|
2490 } |
530943a23d3f
patch 8.0.1518: error messages suppressed after ":silent! try"
Christian Brabandt <cb@256bit.org>
parents:
13268
diff
changeset
|
2491 |
530943a23d3f
patch 8.0.1518: error messages suppressed after ":silent! try"
Christian Brabandt <cb@256bit.org>
parents:
13268
diff
changeset
|
2492 /* |
530943a23d3f
patch 8.0.1518: error messages suppressed after ":silent! try"
Christian Brabandt <cb@256bit.org>
parents:
13268
diff
changeset
|
2493 * 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
|
2494 */ |
7 | 2495 |
6305 | 2496 if (IS_USER_CMDIDX(ea.cmdidx)) |
7 | 2497 { |
2498 /* | |
2499 * Execute a user-defined command. | |
2500 */ | |
2501 do_ucmd(&ea); | |
2502 } | |
2503 else | |
2504 { | |
2505 /* | |
16411
5b5c5daf57de
patch 8.1.1210: support for user commands is spread out
Bram Moolenaar <Bram@vim.org>
parents:
16399
diff
changeset
|
2506 * Call the function to execute the builtin command. |
7 | 2507 */ |
2508 ea.errmsg = NULL; | |
2509 (cmdnames[ea.cmdidx].cmd_func)(&ea); | |
2510 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
|
2511 errormsg = _(ea.errmsg); |
7 | 2512 } |
2513 | |
2514 #ifdef FEAT_EVAL | |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
2515 // Set flag that any command was executed, used by ex_vim9script(). |
19348
b6da81589f8c
patch 8.2.0232: the :compiler command causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
19271
diff
changeset
|
2516 if (getline_equal(ea.getline, ea.cookie, getsourceline) |
b6da81589f8c
patch 8.2.0232: the :compiler command causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
19271
diff
changeset
|
2517 && current_sctx.sc_sid > 0) |
19191
133ef7ba4e4e
patch 8.2.0154: reallocating the list of scripts is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
19181
diff
changeset
|
2518 SCRIPT_ITEM(current_sctx.sc_sid)->sn_had_command = TRUE; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
2519 |
7 | 2520 /* |
2521 * If the command just executed called do_cmdline(), any throw or ":return" | |
2522 * or ":finish" encountered there must also check the cstack of the still | |
2523 * active do_cmdline() that called this do_one_cmd(). Rethrow an uncaught | |
2524 * exception, or reanimate a returned function or finished script file and | |
2525 * return or finish it again. | |
2526 */ | |
2527 if (need_rethrow) | |
2528 do_throw(cstack); | |
2529 else if (check_cstack) | |
2530 { | |
944 | 2531 if (source_finished(fgetline, cookie)) |
7 | 2532 do_finish(&ea, TRUE); |
944 | 2533 else if (getline_equal(fgetline, cookie, get_func_line) |
7 | 2534 && current_func_returned()) |
2535 do_return(&ea, TRUE, FALSE, NULL); | |
2536 } | |
2537 need_rethrow = check_cstack = FALSE; | |
2538 #endif | |
2539 | |
2540 doend: | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2541 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
|
2542 { |
7 | 2543 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
|
2544 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
|
2545 } |
7 | 2546 |
2547 if (errormsg != NULL && *errormsg != NUL && !did_emsg) | |
2548 { | |
2549 if (sourcing) | |
2550 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2551 if (errormsg != (char *)IObuff) |
7 | 2552 { |
2553 STRCPY(IObuff, errormsg); | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2554 errormsg = (char *)IObuff; |
7 | 2555 } |
3097 | 2556 append_command(*cmdlinep); |
7 | 2557 } |
2558 emsg(errormsg); | |
2559 } | |
2560 #ifdef FEAT_EVAL | |
2561 do_errthrow(cstack, | |
6305 | 2562 (ea.cmdidx != CMD_SIZE && !IS_USER_CMDIDX(ea.cmdidx)) |
2563 ? cmdnames[(int)ea.cmdidx].cmd_name : (char_u *)NULL); | |
7 | 2564 #endif |
2565 | |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2566 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
|
2567 p_verbose = ea.verbose_save; |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
2568 |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2569 free_cmdmod(); |
7 | 2570 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
|
2571 reg_executing = save_reg_executing; |
7 | 2572 |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2573 if (ea.save_msg_silent != -1) |
7 | 2574 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2575 // messages could be enabled for a serious error, need to check if the |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2576 // 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
|
2577 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
|
2578 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
|
2579 emsg_silent -= ea.did_esilent; |
7 | 2580 if (emsg_silent < 0) |
2581 emsg_silent = 0; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2582 // Restore msg_scroll, it's set by file I/O commands, even when no |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2583 // message is actually displayed. |
7 | 2584 msg_scroll = save_msg_scroll; |
1854 | 2585 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2586 // "silent reg" or "silent echo x" inside "redir" leaves msg_col |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2587 // somewhere in the line. Put it back in the first column. |
1854 | 2588 if (redirecting()) |
2589 msg_col = 0; | |
7 | 2590 } |
2591 | |
28 | 2592 #ifdef HAVE_SANDBOX |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2593 if (ea.did_sandbox) |
28 | 2594 --sandbox; |
2595 #endif | |
2596 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2597 if (ea.nextcmd && *ea.nextcmd == NUL) // not really a next command |
7 | 2598 ea.nextcmd = NULL; |
2599 | |
2600 #ifdef FEAT_EVAL | |
2601 --ex_nesting_level; | |
2602 #endif | |
2603 | |
2604 return ea.nextcmd; | |
2605 } | |
2606 #if (_MSC_VER == 1200) | |
128 | 2607 #pragma optimize( "", on ) |
7 | 2608 #endif |
2609 | |
2610 /* | |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2611 * 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
|
2612 * - update eap->cmd |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2613 * - store flags in "cmdmod". |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2614 * - 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
|
2615 * - 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
|
2616 * - 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
|
2617 * - 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
|
2618 * - 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
|
2619 * 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
|
2620 * "cmdmod". |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2621 * 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
|
2622 * 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
|
2623 */ |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2624 int |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2625 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
|
2626 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2627 char_u *p; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2628 |
20007
aadd1cae2ff5
patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
2629 CLEAR_FIELD(cmdmod); |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2630 eap->verbose_save = -1; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2631 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
|
2632 |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2633 // 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
|
2634 for (;;) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2635 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2636 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
|
2637 ++eap->cmd; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2638 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2639 // in ex mode, an empty line works like :+ |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2640 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
|
2641 && (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
|
2642 || 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
|
2643 && 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
|
2644 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2645 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
|
2646 if (!skip_only) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2647 ex_pressedreturn = TRUE; |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2648 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2649 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2650 // ignore comment and empty lines |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2651 if (*eap->cmd == '"') |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2652 return FAIL; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2653 if (*eap->cmd == NUL) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2654 { |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2655 if (!skip_only) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2656 ex_pressedreturn = TRUE; |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2657 return FAIL; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2658 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2659 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2660 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
|
2661 switch (*p) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2662 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2663 // When adding an entry, also modify cmd_exists(). |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2664 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
|
2665 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2666 cmdmod.split |= WSP_ABOVE; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2667 continue; |
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 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
|
2670 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2671 cmdmod.split |= WSP_BELOW; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2672 continue; |
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 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
|
2675 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2676 #ifdef FEAT_BROWSE_CMD |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2677 cmdmod.browse = TRUE; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2678 #endif |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2679 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2680 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2681 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
|
2682 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2683 cmdmod.split |= WSP_BOT; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2684 continue; |
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 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
|
2687 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2688 #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
|
2689 cmdmod.confirm = TRUE; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2690 #endif |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2691 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2692 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2693 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
|
2694 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2695 cmdmod.keepmarks = TRUE; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2696 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2697 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2698 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
|
2699 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2700 cmdmod.keepalt = TRUE; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2701 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2702 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2703 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
|
2704 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2705 cmdmod.keeppatterns = TRUE; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2706 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2707 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2708 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
|
2709 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2710 cmdmod.keepjumps = TRUE; |
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 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2713 case 'f': // only accept ":filter {pat} cmd" |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2714 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2715 char_u *reg_pat; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2716 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2717 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
|
2718 || *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
|
2719 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2720 if (*p == '!') |
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 cmdmod.filter_force = TRUE; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2723 p = skipwhite(p + 1); |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2724 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
|
2725 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2726 } |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2727 if (skip_only) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2728 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
|
2729 else |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2730 // 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
|
2731 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
|
2732 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
|
2733 break; |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2734 if (!skip_only) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2735 { |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2736 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
|
2737 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
|
2738 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
|
2739 break; |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2740 } |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2741 eap->cmd = p; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2742 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2743 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2744 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2745 // ":hide" and ":hide | cmd" are not modifiers |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2746 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
|
2747 || *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
|
2748 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2749 eap->cmd = p; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2750 cmdmod.hide = TRUE; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2751 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2752 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2753 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
|
2754 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2755 cmdmod.lockmarks = TRUE; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2756 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2757 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2758 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2759 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
|
2760 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2761 cmdmod.split |= WSP_ABOVE; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2762 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2763 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2764 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
|
2765 { |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2766 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
|
2767 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2768 // Set 'eventignore' to "all". Restore the |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2769 // existing option value later. |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2770 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
|
2771 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
|
2772 (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
|
2773 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2774 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2775 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2776 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
|
2777 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2778 cmdmod.noswapfile = TRUE; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2779 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2780 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2781 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
|
2782 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2783 cmdmod.split |= WSP_BELOW; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2784 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2785 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2786 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
|
2787 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2788 #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
|
2789 if (!skip_only) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2790 { |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2791 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
|
2792 ++sandbox; |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2793 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
|
2794 } |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2795 #endif |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2796 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2797 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2798 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
|
2799 break; |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2800 if (!skip_only) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2801 { |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2802 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
|
2803 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
|
2804 ++msg_silent; |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2805 } |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2806 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
|
2807 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2808 // ":silent!", but not "silent !cmd" |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2809 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
|
2810 if (!skip_only) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2811 { |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2812 ++emsg_silent; |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2813 ++eap->did_esilent; |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2814 } |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2815 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2816 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2817 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2818 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
|
2819 { |
15263
ad065b8123e8
patch 8.1.0640: get E14 while typing command :tab with 'incsearch' set
Bram Moolenaar <Bram@vim.org>
parents:
15239
diff
changeset
|
2820 if (!skip_only) |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2821 { |
15263
ad065b8123e8
patch 8.1.0640: get E14 while typing command :tab with 'incsearch' set
Bram Moolenaar <Bram@vim.org>
parents:
15239
diff
changeset
|
2822 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
|
2823 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
|
2824 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
|
2825 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
|
2826 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
|
2827 else |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2828 { |
15263
ad065b8123e8
patch 8.1.0640: get E14 while typing command :tab with 'incsearch' set
Bram Moolenaar <Bram@vim.org>
parents:
15239
diff
changeset
|
2829 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
|
2830 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2831 *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
|
2832 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
|
2833 } |
ad065b8123e8
patch 8.1.0640: get E14 while typing command :tab with 'incsearch' set
Bram Moolenaar <Bram@vim.org>
parents:
15239
diff
changeset
|
2834 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
|
2835 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2836 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2837 eap->cmd = p; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2838 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2839 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2840 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
|
2841 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2842 cmdmod.split |= WSP_TOP; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2843 continue; |
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 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
|
2846 break; |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2847 if (!skip_only) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2848 { |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2849 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
|
2850 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
|
2851 msg_silent = 0; |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2852 } |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2853 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2854 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2855 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
|
2856 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2857 cmdmod.split |= WSP_VERT; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2858 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2859 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2860 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
|
2861 break; |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2862 if (!skip_only) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2863 { |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2864 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
|
2865 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
|
2866 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
|
2867 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
|
2868 else |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2869 p_verbose = 1; |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2870 } |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2871 eap->cmd = p; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2872 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2873 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2874 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2875 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2876 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2877 return OK; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2878 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2879 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2880 /* |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2881 * 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
|
2882 */ |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2883 static void |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2884 free_cmdmod(void) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2885 { |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2886 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
|
2887 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2888 // Restore 'eventignore' to the value before ":noautocmd". |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2889 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
|
2890 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
|
2891 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
|
2892 } |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2893 |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2894 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
|
2895 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
|
2896 } |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2897 |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2898 /* |
14505
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2899 * 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
|
2900 * 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
|
2901 * 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
|
2902 */ |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2903 int |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2904 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
|
2905 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2906 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
|
2907 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
|
2908 |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2909 // 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
|
2910 for (;;) |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2911 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2912 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
|
2913 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
|
2914 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2915 case ADDR_LINES: |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
2916 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
|
2917 // 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
|
2918 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
|
2919 break; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2920 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
|
2921 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
|
2922 break; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2923 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
|
2924 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
|
2925 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
|
2926 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
|
2927 break; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2928 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
|
2929 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
|
2930 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
|
2931 break; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2932 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
|
2933 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
|
2934 break; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2935 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
|
2936 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
|
2937 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
|
2938 break; |
16479
7dcf301d1432
patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents:
16475
diff
changeset
|
2939 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
|
2940 #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
|
2941 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
|
2942 #endif |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
2943 break; |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
2944 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
|
2945 #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
|
2946 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
|
2947 #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
|
2948 break; |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
2949 case ADDR_NONE: |
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
2950 // 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
|
2951 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
|
2952 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2953 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
|
2954 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
|
2955 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
|
2956 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
|
2957 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
|
2958 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
|
2959 { |
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 (*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
|
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->cmd; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2963 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
|
2964 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2965 case ADDR_LINES: |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
2966 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
|
2967 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
|
2968 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
|
2969 break; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2970 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
|
2971 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2972 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
|
2973 |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2974 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
|
2975 && 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
|
2976 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
|
2977 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
|
2978 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
|
2979 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
|
2980 && 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
|
2981 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
|
2982 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
|
2983 break; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2984 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2985 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
|
2986 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
|
2987 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
|
2988 break; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2989 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
|
2990 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
|
2991 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
|
2992 { |
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->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
|
2994 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
|
2995 ? 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
|
2996 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2997 else |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2998 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2999 // 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
|
3000 // 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
|
3001 *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
|
3002 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
|
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 break; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3005 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
|
3006 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
|
3007 case ADDR_QUICKFIX: |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
3008 *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
|
3009 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
|
3010 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
|
3011 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
|
3012 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
|
3013 else |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3014 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3015 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
|
3016 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
|
3017 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3018 break; |
16515
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
3019 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
|
3020 #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
|
3021 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
|
3022 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
|
3023 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
|
3024 eap->line2 = 1; |
16479
7dcf301d1432
patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents:
16475
diff
changeset
|
3025 #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
|
3026 break; |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
3027 case ADDR_NONE: |
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
3028 // 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
|
3029 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
|
3030 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3031 ++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
|
3032 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3033 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
|
3034 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3035 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
|
3036 |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3037 // '*' - 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
|
3038 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
|
3039 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
3040 *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
|
3041 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
|
3042 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3043 |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3044 ++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
|
3045 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
|
3046 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3047 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
|
3048 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
|
3049 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
|
3050 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
|
3051 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
|
3052 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
|
3053 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
|
3054 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
|
3055 ++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
|
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 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3058 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3059 else |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3060 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
|
3061 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
|
3062 |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3063 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
|
3064 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3065 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
|
3066 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3067 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
|
3068 // 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
|
3069 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
|
3070 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3071 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3072 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
|
3073 break; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3074 ++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
|
3075 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3076 |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3077 // 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
|
3078 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
|
3079 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3080 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
|
3081 // ... 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
|
3082 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
|
3083 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
|
3084 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3085 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
|
3086 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3087 |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3088 /* |
93 | 3089 * Check for an Ex command with optional tail. |
7 | 3090 * If there is a match advance "pp" to the argument and return TRUE. |
3091 */ | |
93 | 3092 int |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3093 checkforcmd( |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3094 char_u **pp, // start of command |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3095 char *cmd, // name of command |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3096 int len) // required length |
7 | 3097 { |
3098 int i; | |
3099 | |
3100 for (i = 0; cmd[i] != NUL; ++i) | |
1872 | 3101 if (((char_u *)cmd)[i] != (*pp)[i]) |
7 | 3102 break; |
3103 if (i >= len && !isalpha((*pp)[i])) | |
3104 { | |
3105 *pp = skipwhite(*pp + i); | |
3106 return TRUE; | |
3107 } | |
3108 return FALSE; | |
3109 } | |
3110 | |
3111 /* | |
3097 | 3112 * Append "cmd" to the error message in IObuff. |
3113 * Takes care of limiting the length and handling 0xa0, which would be | |
3114 * invisible otherwise. | |
3115 */ | |
3116 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3117 append_command(char_u *cmd) |
3097 | 3118 { |
3119 char_u *s = cmd; | |
3120 char_u *d; | |
3121 | |
3122 STRCAT(IObuff, ": "); | |
3123 d = IObuff + STRLEN(IObuff); | |
3124 while (*s != NUL && d - IObuff < IOSIZE - 7) | |
3125 { | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
3126 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
|
3127 { |
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
3128 s += enc_utf8 ? 2 : 1; |
3097 | 3129 STRCPY(d, "<a0>"); |
3130 d += 4; | |
3131 } | |
3132 else | |
3133 MB_COPY_CHAR(s, d); | |
3134 } | |
3135 *d = NUL; | |
3136 } | |
3137 | |
3138 /* | |
7 | 3139 * Find an Ex command by its name, either built-in or user. |
184 | 3140 * 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
|
3141 * Sets eap->cmdidx and returns a pointer to char after the command name. |
184 | 3142 * "full" is set to TRUE if the whole command name matched. |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3143 * |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3144 * If "lookup" is not NULL recognize expression without "eval" or "call" and |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3145 * assignment without "let". Sets eap->cmdidx to the command while returning |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3146 * "eap->cmd". |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3147 * |
7 | 3148 * Returns NULL for an ambiguous user command. |
3149 */ | |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3150 char_u * |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3151 find_ex_command( |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3152 exarg_T *eap, |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3153 int *full UNUSED, |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3154 int (*lookup)(char_u *, size_t, cctx_T *) UNUSED, |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3155 cctx_T *cctx UNUSED) |
7 | 3156 { |
3157 int len; | |
3158 char_u *p; | |
167 | 3159 int i; |
7 | 3160 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3161 #ifdef FEAT_EVAL |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3162 /* |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3163 * Recognize a Vim9 script function/method call and assignment: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3164 * "lvar = value", "lvar(arg)", "[1, 2 3]->Func()" |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3165 */ |
19481
c27837cbe922
patch 8.2.0298: Vim9 script: cannot start command with a string constant
Bram Moolenaar <Bram@vim.org>
parents:
19475
diff
changeset
|
3166 p = eap->cmd; |
c27837cbe922
patch 8.2.0298: Vim9 script: cannot start command with a string constant
Bram Moolenaar <Bram@vim.org>
parents:
19475
diff
changeset
|
3167 if (lookup != NULL && (*p == '(' |
c27837cbe922
patch 8.2.0298: Vim9 script: cannot start command with a string constant
Bram Moolenaar <Bram@vim.org>
parents:
19475
diff
changeset
|
3168 || ((p = to_name_const_end(eap->cmd)) > eap->cmd && *p != NUL))) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3169 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3170 int oplen; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3171 int heredoc; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3172 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3173 // "funcname(" is always a function call. |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3174 // "varname[]" is an expression. |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3175 // "g:varname" is an expression. |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3176 // "varname->expr" is an expression. |
19481
c27837cbe922
patch 8.2.0298: Vim9 script: cannot start command with a string constant
Bram Moolenaar <Bram@vim.org>
parents:
19475
diff
changeset
|
3177 // "(..." is an expression. |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3178 if (*p == '(' |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3179 || *p == '[' |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3180 || p[1] == ':' |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3181 || (*p == '-' && p[1] == '>')) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3182 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3183 eap->cmdidx = CMD_eval; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3184 return eap->cmd; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3185 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3186 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3187 oplen = assignment_len(skipwhite(p), &heredoc); |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3188 if (oplen > 0) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3189 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3190 // Recognize an assignment if we recognize the variable name: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3191 // "g:var = expr" |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3192 // "var = expr" where "var" is a local var name. |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3193 if (((p - eap->cmd) > 2 && eap->cmd[1] == ':') |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3194 || lookup(eap->cmd, p - eap->cmd, cctx) >= 0) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3195 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3196 eap->cmdidx = CMD_let; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3197 return eap->cmd; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3198 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3199 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3200 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3201 #endif |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3202 |
7 | 3203 /* |
3204 * Isolate the command and search for it in the command table. | |
1441 | 3205 * Exceptions: |
7 | 3206 * - the 'k' command can directly be followed by any character. |
3207 * - the 's' command can be followed directly by 'c', 'g', 'i', 'I' or 'r' | |
6472 | 3208 * but :sre[wind] is another command, as are :scr[iptnames], |
7 | 3209 * :scs[cope], :sim[alt], :sig[ns] and :sil[ent]. |
167 | 3210 * - the "d" command can directly be followed by 'l' or 'p' flag. |
7 | 3211 */ |
3212 p = eap->cmd; | |
3213 if (*p == 'k') | |
3214 { | |
3215 eap->cmdidx = CMD_k; | |
3216 ++p; | |
3217 } | |
3218 else if (p[0] == 's' | |
6987 | 3219 && ((p[1] == 'c' && (p[2] == NUL || (p[2] != 's' && p[2] != 'r' |
3220 && (p[3] == NUL || (p[3] != 'i' && p[4] != 'p'))))) | |
7 | 3221 || p[1] == 'g' |
3222 || (p[1] == 'i' && p[2] != 'm' && p[2] != 'l' && p[2] != 'g') | |
3223 || p[1] == 'I' | |
3224 || (p[1] == 'r' && p[2] != 'e'))) | |
3225 { | |
3226 eap->cmdidx = CMD_substitute; | |
3227 ++p; | |
3228 } | |
3229 else | |
3230 { | |
3231 while (ASCII_ISALPHA(*p)) | |
3232 ++p; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3233 // for python 3.x support ":py3", ":python3", ":py3file", etc. |
2330 | 3234 if (eap->cmd[0] == 'p' && eap->cmd[1] == 'y') |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3235 { |
2366
7a57fe6a5157
Fix that :py3file was not working.
Bram Moolenaar <bram@vim.org>
parents:
2360
diff
changeset
|
3236 while (ASCII_ISALNUM(*p)) |
7a57fe6a5157
Fix that :py3file was not working.
Bram Moolenaar <bram@vim.org>
parents:
2360
diff
changeset
|
3237 ++p; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3238 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3239 else if (*p == '9' && STRNCMP("vim9", eap->cmd, 4) == 0) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3240 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3241 // include "9" for "vim9script" |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3242 ++p; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3243 while (ASCII_ISALPHA(*p)) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3244 ++p; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3245 } |
2329
ad2889f48843
Added support for Python 3. (Roland Puntaier)
Bram Moolenaar <bram@vim.org>
parents:
2320
diff
changeset
|
3246 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3247 // check for non-alpha command |
7 | 3248 if (p == eap->cmd && vim_strchr((char_u *)"@*!=><&~#", *p) != NULL) |
3249 ++p; | |
3250 len = (int)(p - eap->cmd); | |
167 | 3251 if (*eap->cmd == 'd' && (p[-1] == 'l' || p[-1] == 'p')) |
3252 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3253 // Check for ":dl", ":dell", etc. to ":deletel": that's |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3254 // :delete with the 'l' flag. Same for 'p'. |
167 | 3255 for (i = 0; i < len; ++i) |
1872 | 3256 if (eap->cmd[i] != ((char_u *)"delete")[i]) |
167 | 3257 break; |
3258 if (i == len - 1) | |
3259 { | |
3260 --len; | |
3261 if (p[-1] == 'l') | |
3262 eap->flags |= EXFLAG_LIST; | |
3263 else | |
3264 eap->flags |= EXFLAG_PRINT; | |
3265 } | |
3266 } | |
7 | 3267 |
11236
62c96fee518e
patch 8.0.0504: looking up an Ex command is a bit slow
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
3268 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
|
3269 { |
11240
06307d812ca7
patch 8.0.0506: can't build with ANSI C
Christian Brabandt <cb@256bit.org>
parents:
11236
diff
changeset
|
3270 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
|
3271 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
|
3272 |
11236
62c96fee518e
patch 8.0.0504: looking up an Ex command is a bit slow
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
3273 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
|
3274 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
3275 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
|
3276 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
|
3277 } |
62c96fee518e
patch 8.0.0504: looking up an Ex command is a bit slow
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
3278 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3279 // Use a precomputed index for fast look-up in cmdnames[] |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3280 // taking into account the first 2 letters of eap->cmd. |
11236
62c96fee518e
patch 8.0.0504: looking up an Ex command is a bit slow
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
3281 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
|
3282 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
|
3283 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
|
3284 } |
7 | 3285 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
|
3286 eap->cmdidx = CMD_bang; |
7 | 3287 |
3288 for ( ; (int)eap->cmdidx < (int)CMD_SIZE; | |
3289 eap->cmdidx = (cmdidx_T)((int)eap->cmdidx + 1)) | |
3290 if (STRNCMP(cmdnames[(int)eap->cmdidx].cmd_name, (char *)eap->cmd, | |
3291 (size_t)len) == 0) | |
3292 { | |
3293 #ifdef FEAT_EVAL | |
3294 if (full != NULL | |
3295 && cmdnames[(int)eap->cmdidx].cmd_name[len] == NUL) | |
3296 *full = TRUE; | |
3297 #endif | |
3298 break; | |
3299 } | |
3300 | |
16411
5b5c5daf57de
patch 8.1.1210: support for user commands is spread out
Bram Moolenaar <Bram@vim.org>
parents:
16399
diff
changeset
|
3301 // 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
|
3302 // overruled by a user defined command. |
2633 | 3303 if ((eap->cmdidx == CMD_SIZE || eap->cmdidx == CMD_Print) |
3304 && *eap->cmd >= 'A' && *eap->cmd <= 'Z') | |
7 | 3305 { |
16411
5b5c5daf57de
patch 8.1.1210: support for user commands is spread out
Bram Moolenaar <Bram@vim.org>
parents:
16399
diff
changeset
|
3306 // User defined commands may contain digits. |
7 | 3307 while (ASCII_ISALNUM(*p)) |
3308 ++p; | |
184 | 3309 p = find_ucmd(eap, p, full, NULL, NULL); |
3310 } | |
3311 if (p == eap->cmd) | |
7 | 3312 eap->cmdidx = CMD_SIZE; |
3313 } | |
3314 | |
3315 return p; | |
3316 } | |
3317 | |
3318 #if defined(FEAT_EVAL) || defined(PROTO) | |
1447 | 3319 static struct cmdmod |
3320 { | |
3321 char *name; | |
3322 int minlen; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3323 int has_count; // :123verbose :3tab |
1447 | 3324 } cmdmods[] = { |
3325 {"aboveleft", 3, FALSE}, | |
3326 {"belowright", 3, FALSE}, | |
3327 {"botright", 2, FALSE}, | |
3328 {"browse", 3, FALSE}, | |
3329 {"confirm", 4, FALSE}, | |
9941
e975914c17e9
commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
9927
diff
changeset
|
3330 {"filter", 4, FALSE}, |
1447 | 3331 {"hide", 3, FALSE}, |
3332 {"keepalt", 5, FALSE}, | |
3333 {"keepjumps", 5, FALSE}, | |
3334 {"keepmarks", 3, FALSE}, | |
5467 | 3335 {"keeppatterns", 5, FALSE}, |
1447 | 3336 {"leftabove", 5, FALSE}, |
3337 {"lockmarks", 3, FALSE}, | |
1721 | 3338 {"noautocmd", 3, FALSE}, |
5737 | 3339 {"noswapfile", 3, FALSE}, |
1447 | 3340 {"rightbelow", 6, FALSE}, |
3341 {"sandbox", 3, FALSE}, | |
3342 {"silent", 3, FALSE}, | |
3343 {"tab", 3, TRUE}, | |
3344 {"topleft", 2, FALSE}, | |
1926 | 3345 {"unsilent", 3, FALSE}, |
1447 | 3346 {"verbose", 4, TRUE}, |
3347 {"vertical", 4, FALSE}, | |
3348 }; | |
3349 | |
3350 /* | |
3351 * Return length of a command modifier (including optional count). | |
3352 * Return zero when it's not a modifier. | |
3353 */ | |
3354 int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3355 modifier_len(char_u *cmd) |
1447 | 3356 { |
3357 int i, j; | |
3358 char_u *p = cmd; | |
3359 | |
3360 if (VIM_ISDIGIT(*cmd)) | |
3361 p = skipwhite(skipdigits(cmd)); | |
1880 | 3362 for (i = 0; i < (int)(sizeof(cmdmods) / sizeof(struct cmdmod)); ++i) |
1447 | 3363 { |
3364 for (j = 0; p[j] != NUL; ++j) | |
3365 if (p[j] != cmdmods[i].name[j]) | |
3366 break; | |
4857
84a8d1ba81c3
updated for version 7.3.1175
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3367 if (!ASCII_ISALPHA(p[j]) && j >= cmdmods[i].minlen |
1447 | 3368 && (p == cmd || cmdmods[i].has_count)) |
1570 | 3369 return j + (int)(p - cmd); |
1447 | 3370 } |
3371 return 0; | |
3372 } | |
3373 | |
7 | 3374 /* |
3375 * Return > 0 if an Ex command "name" exists. | |
3376 * Return 2 if there is an exact match. | |
3377 * Return 3 if there is an ambiguous match. | |
3378 */ | |
3379 int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3380 cmd_exists(char_u *name) |
7 | 3381 { |
3382 exarg_T ea; | |
3383 int full = FALSE; | |
3384 int i; | |
3385 int j; | |
866 | 3386 char_u *p; |
7 | 3387 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3388 // Check command modifiers. |
1880 | 3389 for (i = 0; i < (int)(sizeof(cmdmods) / sizeof(struct cmdmod)); ++i) |
7 | 3390 { |
3391 for (j = 0; name[j] != NUL; ++j) | |
3392 if (name[j] != cmdmods[i].name[j]) | |
3393 break; | |
3394 if (name[j] == NUL && j >= cmdmods[i].minlen) | |
3395 return (cmdmods[i].name[j] == NUL ? 2 : 1); | |
3396 } | |
3397 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3398 // Check built-in commands and user defined commands. |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3399 // For ":2match" and ":3match" we need to skip the number. |
862 | 3400 ea.cmd = (*name == '2' || *name == '3') ? name + 1 : name; |
7 | 3401 ea.cmdidx = (cmdidx_T)0; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3402 p = find_ex_command(&ea, &full, NULL, NULL); |
866 | 3403 if (p == NULL) |
7 | 3404 return 3; |
862 | 3405 if (vim_isdigit(*name) && ea.cmdidx != CMD_match) |
3406 return 0; | |
866 | 3407 if (*skipwhite(p) != NUL) |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3408 return 0; // trailing garbage |
7 | 3409 return (ea.cmdidx == CMD_SIZE ? 0 : (full ? 2 : 1)); |
3410 } | |
3411 #endif | |
3412 | |
17835
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17823
diff
changeset
|
3413 cmdidx_T |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17823
diff
changeset
|
3414 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
|
3415 { |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17823
diff
changeset
|
3416 cmdidx_T idx; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17823
diff
changeset
|
3417 |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17823
diff
changeset
|
3418 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
|
3419 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
|
3420 if (STRNCMP(cmdnames[(int)idx].cmd_name, cmd, (size_t)len) == 0) |
7 | 3421 break; |
3422 | |
17835
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17823
diff
changeset
|
3423 return idx; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17823
diff
changeset
|
3424 } |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17823
diff
changeset
|
3425 |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17823
diff
changeset
|
3426 long |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17823
diff
changeset
|
3427 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
|
3428 { |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17823
diff
changeset
|
3429 return (long)cmdnames[(int)idx].cmd_argt; |
7 | 3430 } |
3431 | |
3432 /* | |
14505
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3433 * Skip a range specifier of the form: addr [,addr] [;addr] .. |
7 | 3434 * |
3435 * Backslashed delimiters after / or ? will be skipped, and commands will | |
3436 * not be expanded between /'s and ?'s or after "'". | |
3437 * | |
167 | 3438 * Also skip white space and ":" characters. |
7 | 3439 * Returns the "cmd" pointer advanced to beyond the range. |
3440 */ | |
3441 char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3442 skip_range( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3443 char_u *cmd, |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3444 int *ctx) // pointer to xp_context or NULL |
7 | 3445 { |
1872 | 3446 unsigned delim; |
7 | 3447 |
10817
cc8079703414
patch 8.0.0298: Ex command range with repeated search does not work
Christian Brabandt <cb@256bit.org>
parents:
10809
diff
changeset
|
3448 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
|
3449 { |
cc8079703414
patch 8.0.0298: Ex command range with repeated search does not work
Christian Brabandt <cb@256bit.org>
parents:
10809
diff
changeset
|
3450 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
|
3451 { |
cc8079703414
patch 8.0.0298: Ex command range with repeated search does not work
Christian Brabandt <cb@256bit.org>
parents:
10809
diff
changeset
|
3452 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
|
3453 ++cmd; |
cc8079703414
patch 8.0.0298: Ex command range with repeated search does not work
Christian Brabandt <cb@256bit.org>
parents:
10809
diff
changeset
|
3454 else |
cc8079703414
patch 8.0.0298: Ex command range with repeated search does not work
Christian Brabandt <cb@256bit.org>
parents:
10809
diff
changeset
|
3455 break; |
cc8079703414
patch 8.0.0298: Ex command range with repeated search does not work
Christian Brabandt <cb@256bit.org>
parents:
10809
diff
changeset
|
3456 } |
cc8079703414
patch 8.0.0298: Ex command range with repeated search does not work
Christian Brabandt <cb@256bit.org>
parents:
10809
diff
changeset
|
3457 else if (*cmd == '\'') |
7 | 3458 { |
3459 if (*++cmd == NUL && ctx != NULL) | |
3460 *ctx = EXPAND_NOTHING; | |
3461 } | |
3462 else if (*cmd == '/' || *cmd == '?') | |
3463 { | |
3464 delim = *cmd++; | |
3465 while (*cmd != NUL && *cmd != delim) | |
3466 if (*cmd++ == '\\' && *cmd != NUL) | |
3467 ++cmd; | |
3468 if (*cmd == NUL && ctx != NULL) | |
3469 *ctx = EXPAND_NOTHING; | |
3470 } | |
3471 if (*cmd != NUL) | |
3472 ++cmd; | |
3473 } | |
167 | 3474 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3475 // Skip ":" and white space. |
167 | 3476 while (*cmd == ':') |
3477 cmd = skipwhite(cmd + 1); | |
3478 | |
7 | 3479 return cmd; |
3480 } | |
3481 | |
17650
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
3482 static void |
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
3483 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
|
3484 { |
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
3485 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
|
3486 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
|
3487 else |
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
3488 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
|
3489 } |
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
3490 |
7 | 3491 /* |
14677
7771a1ff8b99
patch 8.1.0351: 'incsearch' for :/foo/s//<Esc> changes last search pattern
Christian Brabandt <cb@256bit.org>
parents:
14648
diff
changeset
|
3492 * Get a single EX address. |
7 | 3493 * |
3494 * Set ptr to the next character after the part that was interpreted. | |
3495 * 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
|
3496 * This may set the last used search pattern. |
7 | 3497 * |
3498 * Return MAXLNUM when no Ex address was found. | |
3499 */ | |
3500 static linenr_T | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3501 get_address( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3502 exarg_T *eap UNUSED, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3503 char_u **ptr, |
18849
b77ef4b8af7c
patch 8.1.2411: function argument copied unnecessarily
Bram Moolenaar <Bram@vim.org>
parents:
18779
diff
changeset
|
3504 cmd_addr_T addr_type, |
14760
fd69edd2c67e
patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents:
14700
diff
changeset
|
3505 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
|
3506 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
|
3507 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
|
3508 int address_count UNUSED) // 1 for first address, >1 after comma |
7 | 3509 { |
3510 int c; | |
3511 int i; | |
3512 long n; | |
3513 char_u *cmd; | |
3514 pos_T pos; | |
3515 pos_T *fp; | |
3516 linenr_T lnum; | |
6424 | 3517 buf_T *buf; |
7 | 3518 |
3519 cmd = skipwhite(*ptr); | |
3520 lnum = MAXLNUM; | |
3521 do | |
3522 { | |
3523 switch (*cmd) | |
3524 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3525 case '.': // '.' - Cursor position |
6398 | 3526 ++cmd; |
3527 switch (addr_type) | |
3528 { | |
3529 case ADDR_LINES: | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
3530 case ADDR_OTHER: |
7 | 3531 lnum = curwin->w_cursor.lnum; |
3532 break; | |
6398 | 3533 case ADDR_WINDOWS: |
6409 | 3534 lnum = CURRENT_WIN_NR; |
6398 | 3535 break; |
3536 case ADDR_ARGUMENTS: | |
3537 lnum = curwin->w_arg_idx + 1; | |
3538 break; | |
3539 case ADDR_LOADED_BUFFERS: | |
6424 | 3540 case ADDR_BUFFERS: |
6398 | 3541 lnum = curbuf->b_fnum; |
3542 break; | |
3543 case ADDR_TABS: | |
6409 | 3544 lnum = CURRENT_TAB_NR; |
6398 | 3545 break; |
17650
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
3546 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
|
3547 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
|
3548 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
|
3549 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
|
3550 cmd = NULL; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
3551 goto error; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
3552 break; |
16479
7dcf301d1432
patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents:
16475
diff
changeset
|
3553 case ADDR_QUICKFIX: |
7105
f4456e686406
commit https://github.com/vim/vim/commit/e906c502079770ae0e0071c74cefb802689ff193
Christian Brabandt <cb@256bit.org>
parents:
7092
diff
changeset
|
3554 #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
|
3555 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
|
3556 #endif |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
3557 break; |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
3558 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
|
3559 #ifdef FEAT_QUICKFIX |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
3560 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
|
3561 #endif |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
3562 break; |
6398 | 3563 } |
3564 break; | |
7 | 3565 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3566 case '$': // '$' - last line |
6398 | 3567 ++cmd; |
3568 switch (addr_type) | |
3569 { | |
3570 case ADDR_LINES: | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
3571 case ADDR_OTHER: |
7 | 3572 lnum = curbuf->b_ml.ml_line_count; |
3573 break; | |
6398 | 3574 case ADDR_WINDOWS: |
6409 | 3575 lnum = LAST_WIN_NR; |
6398 | 3576 break; |
3577 case ADDR_ARGUMENTS: | |
3578 lnum = ARGCOUNT; | |
3579 break; | |
3580 case ADDR_LOADED_BUFFERS: | |
6424 | 3581 buf = lastbuf; |
3582 while (buf->b_ml.ml_mfp == NULL) | |
3583 { | |
3584 if (buf->b_prev == NULL) | |
3585 break; | |
3586 buf = buf->b_prev; | |
3587 } | |
3588 lnum = buf->b_fnum; | |
3589 break; | |
3590 case ADDR_BUFFERS: | |
6398 | 3591 lnum = lastbuf->b_fnum; |
3592 break; | |
3593 case ADDR_TABS: | |
6409 | 3594 lnum = LAST_TAB_NR; |
6398 | 3595 break; |
17650
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
3596 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
|
3597 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
|
3598 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
|
3599 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
|
3600 cmd = NULL; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
3601 goto error; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
3602 break; |
16479
7dcf301d1432
patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents:
16475
diff
changeset
|
3603 case ADDR_QUICKFIX: |
7105
f4456e686406
commit https://github.com/vim/vim/commit/e906c502079770ae0e0071c74cefb802689ff193
Christian Brabandt <cb@256bit.org>
parents:
7092
diff
changeset
|
3604 #ifdef FEAT_QUICKFIX |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
3605 lnum = qf_get_size(eap); |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
3606 if (lnum == 0) |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
3607 lnum = 1; |
16479
7dcf301d1432
patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents:
16475
diff
changeset
|
3608 #endif |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
3609 break; |
16515
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
3610 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
|
3611 #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
|
3612 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
|
3613 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
|
3614 lnum = 1; |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
3615 #endif |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
3616 break; |
6398 | 3617 } |
3618 break; | |
7 | 3619 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3620 case '\'': // ''' - mark |
6398 | 3621 if (*++cmd == NUL) |
3622 { | |
3623 cmd = NULL; | |
3624 goto error; | |
3625 } | |
3626 if (addr_type != ADDR_LINES) | |
3627 { | |
17650
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
3628 addr_error(addr_type); |
6581 | 3629 cmd = NULL; |
6398 | 3630 goto error; |
3631 } | |
3632 if (skip) | |
3633 ++cmd; | |
3634 else | |
3635 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3636 // Only accept a mark in another file when it is |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3637 // used by itself: ":'M". |
6398 | 3638 fp = getmark(*cmd, to_other_file && cmd[1] == NUL); |
3639 ++cmd; | |
3640 if (fp == (pos_T *)-1) | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3641 // Jumped to another file. |
6398 | 3642 lnum = curwin->w_cursor.lnum; |
3643 else | |
3644 { | |
3645 if (check_mark(fp) == FAIL) | |
7 | 3646 { |
3647 cmd = NULL; | |
3648 goto error; | |
3649 } | |
6398 | 3650 lnum = fp->lnum; |
3651 } | |
3652 } | |
3653 break; | |
7 | 3654 |
3655 case '/': | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3656 case '?': // '/' or '?' - search |
6398 | 3657 c = *cmd++; |
3658 if (addr_type != ADDR_LINES) | |
3659 { | |
17650
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
3660 addr_error(addr_type); |
6581 | 3661 cmd = NULL; |
6398 | 3662 goto error; |
3663 } | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3664 if (skip) // skip "/pat/" |
6398 | 3665 { |
19892
5feb426d2ea1
patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19685
diff
changeset
|
3666 cmd = skip_regexp(cmd, c, (int)p_magic); |
6398 | 3667 if (*cmd == c) |
3668 ++cmd; | |
3669 } | |
3670 else | |
3671 { | |
14760
fd69edd2c67e
patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents:
14700
diff
changeset
|
3672 int flags; |
fd69edd2c67e
patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents:
14700
diff
changeset
|
3673 |
fd69edd2c67e
patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents:
14700
diff
changeset
|
3674 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
|
3675 |
fd69edd2c67e
patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents:
14700
diff
changeset
|
3676 // 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
|
3677 // there. |
6398 | 3678 if (lnum != MAXLNUM) |
3679 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
|
3680 |
fd69edd2c67e
patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents:
14700
diff
changeset
|
3681 // 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
|
3682 // 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
|
3683 // 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
|
3684 // 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
|
3685 // 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
|
3686 // next/previous line. |
13082
a80082fd1a1d
patch 8.0.1416: crash when searching for a sentence
Christian Brabandt <cb@256bit.org>
parents:
12824
diff
changeset
|
3687 if (c == '/' && curwin->w_cursor.lnum > 0) |
6398 | 3688 curwin->w_cursor.col = MAXCOL; |
3689 else | |
3690 curwin->w_cursor.col = 0; | |
3691 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
|
3692 flags = silent ? 0 : SEARCH_HIS | SEARCH_MSG; |
19475
5512aa74cb62
patch 8.2.0295: highlighting for :s wrong when using different separator
Bram Moolenaar <Bram@vim.org>
parents:
19433
diff
changeset
|
3693 if (!do_search(NULL, c, c, cmd, 1L, flags, NULL)) |
6398 | 3694 { |
3695 curwin->w_cursor = pos; | |
3696 cmd = NULL; | |
3697 goto error; | |
3698 } | |
3699 lnum = curwin->w_cursor.lnum; | |
3700 curwin->w_cursor = pos; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3701 // adjust command string pointer |
6398 | 3702 cmd += searchcmdlen; |
3703 } | |
3704 break; | |
7 | 3705 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3706 case '\\': // "\?", "\/" or "\&", repeat search |
6398 | 3707 ++cmd; |
3708 if (addr_type != ADDR_LINES) | |
3709 { | |
17650
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
3710 addr_error(addr_type); |
6581 | 3711 cmd = NULL; |
6398 | 3712 goto error; |
3713 } | |
3714 if (*cmd == '&') | |
3715 i = RE_SUBST; | |
3716 else if (*cmd == '?' || *cmd == '/') | |
3717 i = RE_SEARCH; | |
3718 else | |
3719 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
3720 emsg(_(e_backslash)); |
6398 | 3721 cmd = NULL; |
3722 goto error; | |
3723 } | |
3724 | |
3725 if (!skip) | |
3726 { | |
3727 /* | |
3728 * When search follows another address, start from | |
3729 * there. | |
3730 */ | |
3731 if (lnum != MAXLNUM) | |
3732 pos.lnum = lnum; | |
3733 else | |
3734 pos.lnum = curwin->w_cursor.lnum; | |
3735 | |
3736 /* | |
3737 * Start the search just like for the above | |
3738 * do_search(). | |
3739 */ | |
3740 if (*cmd != '?') | |
3741 pos.col = MAXCOL; | |
3742 else | |
3743 pos.col = 0; | |
7007 | 3744 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
|
3745 if (searchit(curwin, curbuf, &pos, NULL, |
6398 | 3746 *cmd == '?' ? BACKWARD : FORWARD, |
18358
34d5cd432cac
patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents:
18297
diff
changeset
|
3747 (char_u *)"", 1L, SEARCH_MSG, i, NULL) != FAIL) |
6398 | 3748 lnum = pos.lnum; |
3749 else | |
3750 { | |
3751 cmd = NULL; | |
3752 goto error; | |
3753 } | |
3754 } | |
3755 ++cmd; | |
3756 break; | |
7 | 3757 |
3758 default: | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3759 if (VIM_ISDIGIT(*cmd)) // absolute line number |
6398 | 3760 lnum = getdigits(&cmd); |
7 | 3761 } |
3762 | |
3763 for (;;) | |
3764 { | |
3765 cmd = skipwhite(cmd); | |
3766 if (*cmd != '-' && *cmd != '+' && !VIM_ISDIGIT(*cmd)) | |
3767 break; | |
3768 | |
3769 if (lnum == MAXLNUM) | |
6398 | 3770 { |
3771 switch (addr_type) | |
3772 { | |
3773 case ADDR_LINES: | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
3774 case ADDR_OTHER: |
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
3775 // "+1" is same as ".+1" |
6409 | 3776 lnum = curwin->w_cursor.lnum; |
6398 | 3777 break; |
3778 case ADDR_WINDOWS: | |
6409 | 3779 lnum = CURRENT_WIN_NR; |
6398 | 3780 break; |
3781 case ADDR_ARGUMENTS: | |
3782 lnum = curwin->w_arg_idx + 1; | |
3783 break; | |
3784 case ADDR_LOADED_BUFFERS: | |
6424 | 3785 case ADDR_BUFFERS: |
6398 | 3786 lnum = curbuf->b_fnum; |
3787 break; | |
3788 case ADDR_TABS: | |
6409 | 3789 lnum = CURRENT_TAB_NR; |
6398 | 3790 break; |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
3791 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
|
3792 lnum = 1; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
3793 break; |
16479
7dcf301d1432
patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents:
16475
diff
changeset
|
3794 case ADDR_QUICKFIX: |
7105
f4456e686406
commit https://github.com/vim/vim/commit/e906c502079770ae0e0071c74cefb802689ff193
Christian Brabandt <cb@256bit.org>
parents:
7092
diff
changeset
|
3795 #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
|
3796 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
|
3797 #endif |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
3798 break; |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
3799 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
|
3800 #ifdef FEAT_QUICKFIX |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
3801 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
|
3802 #endif |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
3803 break; |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
3804 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
|
3805 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
|
3806 lnum = 0; |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
3807 break; |
6398 | 3808 } |
3809 } | |
3810 | |
7 | 3811 if (VIM_ISDIGIT(*cmd)) |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3812 i = '+'; // "number" is same as "+number" |
7 | 3813 else |
3814 i = *cmd++; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3815 if (!VIM_ISDIGIT(*cmd)) // '+' is '+1', but '+0' is not '+1' |
7 | 3816 n = 1; |
3817 else | |
3818 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
|
3819 |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
3820 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
|
3821 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
3822 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
|
3823 cmd = NULL; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
3824 goto error; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
3825 } |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
3826 else if (addr_type == ADDR_LOADED_BUFFERS |
6424 | 3827 || addr_type == ADDR_BUFFERS) |
6581 | 3828 lnum = compute_buffer_local_count( |
3829 addr_type, lnum, (i == '-') ? -1 * n : n); | |
7 | 3830 else |
10484
c7de1536780a
commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
10480
diff
changeset
|
3831 { |
c7de1536780a
commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
10480
diff
changeset
|
3832 #ifdef FEAT_FOLDING |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3833 // Relative line addressing, need to adjust for folded lines |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3834 // now, but only do it after the first address. |
10484
c7de1536780a
commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
10480
diff
changeset
|
3835 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
|
3836 && address_count >= 2) |
c7de1536780a
commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
10480
diff
changeset
|
3837 (void)hasFolding(lnum, NULL, &lnum); |
c7de1536780a
commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
10480
diff
changeset
|
3838 #endif |
c7de1536780a
commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
10480
diff
changeset
|
3839 if (i == '-') |
c7de1536780a
commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
10480
diff
changeset
|
3840 lnum -= n; |
c7de1536780a
commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
10480
diff
changeset
|
3841 else |
c7de1536780a
commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
10480
diff
changeset
|
3842 lnum += n; |
c7de1536780a
commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
10480
diff
changeset
|
3843 } |
7 | 3844 } |
3845 } while (*cmd == '/' || *cmd == '?'); | |
3846 | |
3847 error: | |
3848 *ptr = cmd; | |
3849 return lnum; | |
3850 } | |
3851 | |
3852 /* | |
167 | 3853 * Get flags from an Ex command argument. |
3854 */ | |
3855 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3856 get_flags(exarg_T *eap) |
167 | 3857 { |
3858 while (vim_strchr((char_u *)"lp#", *eap->arg) != NULL) | |
3859 { | |
3860 if (*eap->arg == 'l') | |
3861 eap->flags |= EXFLAG_LIST; | |
3862 else if (*eap->arg == 'p') | |
3863 eap->flags |= EXFLAG_PRINT; | |
3864 else | |
3865 eap->flags |= EXFLAG_NR; | |
3866 eap->arg = skipwhite(eap->arg + 1); | |
3867 } | |
3868 } | |
3869 | |
3870 /* | |
7 | 3871 * Function called for command which is Not Implemented. NI! |
3872 */ | |
3873 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3874 ex_ni(exarg_T *eap) |
7 | 3875 { |
3876 if (!eap->skip) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
3877 eap->errmsg = N_("E319: Sorry, the command is not available in this version"); |
7 | 3878 } |
3879 | |
1315 | 3880 #ifdef HAVE_EX_SCRIPT_NI |
7 | 3881 /* |
3882 * Function called for script command which is Not Implemented. NI! | |
3883 * Skips over ":perl <<EOF" constructs. | |
3884 */ | |
3885 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3886 ex_script_ni(exarg_T *eap) |
7 | 3887 { |
3888 if (!eap->skip) | |
3889 ex_ni(eap); | |
3890 else | |
3891 vim_free(script_get(eap, eap->arg)); | |
3892 } | |
3893 #endif | |
3894 | |
3895 /* | |
3896 * Check range in Ex command for validity. | |
3897 * Return NULL when valid, error message when invalid. | |
3898 */ | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
3899 static char * |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3900 invalid_range(exarg_T *eap) |
7 | 3901 { |
6472 | 3902 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
|
3903 |
7 | 3904 if ( eap->line1 < 0 |
3905 || eap->line2 < 0 | |
6472 | 3906 || 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
|
3907 return _(e_invrange); |
6472 | 3908 |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
3909 if (eap->argt & EX_RANGE) |
6472 | 3910 { |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
3911 switch (eap->addr_type) |
6472 | 3912 { |
3913 case ADDR_LINES: | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
3914 if (eap->line2 > curbuf->b_ml.ml_line_count |
7 | 3915 #ifdef FEAT_DIFF |
6472 | 3916 + (eap->cmdidx == CMD_diffget) |
3917 #endif | |
3918 ) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
3919 return _(e_invrange); |
6472 | 3920 break; |
3921 case ADDR_ARGUMENTS: | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3922 // add 1 if ARGCOUNT is 0 |
6581 | 3923 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
|
3924 return _(e_invrange); |
6472 | 3925 break; |
3926 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
|
3927 // 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
|
3928 // exist. |
7e6b7a4f13bc
patch 8.1.1908: every popup window consumes a buffer number
Bram Moolenaar <Bram@vim.org>
parents:
17817
diff
changeset
|
3929 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
|
3930 return _(e_invrange); |
6472 | 3931 break; |
3932 case ADDR_LOADED_BUFFERS: | |
3933 buf = firstbuf; | |
3934 while (buf->b_ml.ml_mfp == NULL) | |
3935 { | |
3936 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
|
3937 return _(e_invrange); |
6472 | 3938 buf = buf->b_next; |
3939 } | |
3940 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
|
3941 return _(e_invrange); |
6472 | 3942 buf = lastbuf; |
3943 while (buf->b_ml.ml_mfp == NULL) | |
3944 { | |
3945 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
|
3946 return _(e_invrange); |
6472 | 3947 buf = buf->b_prev; |
3948 } | |
3949 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
|
3950 return _(e_invrange); |
6472 | 3951 break; |
3952 case ADDR_WINDOWS: | |
6480 | 3953 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
|
3954 return _(e_invrange); |
6472 | 3955 break; |
3956 case ADDR_TABS: | |
3957 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
|
3958 return _(e_invrange); |
6472 | 3959 break; |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
3960 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
|
3961 case ADDR_OTHER: |
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
3962 // 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
|
3963 break; |
16479
7dcf301d1432
patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents:
16475
diff
changeset
|
3964 case ADDR_QUICKFIX: |
7105
f4456e686406
commit https://github.com/vim/vim/commit/e906c502079770ae0e0071c74cefb802689ff193
Christian Brabandt <cb@256bit.org>
parents:
7092
diff
changeset
|
3965 #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
|
3966 // 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
|
3967 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
|
3968 return _(e_invrange); |
16479
7dcf301d1432
patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents:
16475
diff
changeset
|
3969 #endif |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
3970 break; |
16515
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
3971 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
|
3972 #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
|
3973 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
|
3974 || 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
|
3975 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
|
3976 #endif |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
3977 break; |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
3978 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
|
3979 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
|
3980 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
|
3981 break; |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
3982 case ADDR_NONE: |
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
3983 // 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
|
3984 break; |
6472 | 3985 } |
3986 } | |
7 | 3987 return NULL; |
3988 } | |
3989 | |
3990 /* | |
3991 * Correct the range for zero line number, if required. | |
3992 */ | |
3993 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3994 correct_range(exarg_T *eap) |
7 | 3995 { |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
3996 if (!(eap->argt & EX_ZEROR)) // zero in range not allowed |
7 | 3997 { |
3998 if (eap->line1 == 0) | |
3999 eap->line1 = 1; | |
4000 if (eap->line2 == 0) | |
4001 eap->line2 = 1; | |
4002 } | |
4003 } | |
4004 | |
153 | 4005 #ifdef FEAT_QUICKFIX |
4006 /* | |
4007 * For a ":vimgrep" or ":vimgrepadd" command return a pointer past the | |
4008 * pattern. Otherwise return eap->arg. | |
4009 */ | |
4010 static char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4011 skip_grep_pat(exarg_T *eap) |
153 | 4012 { |
4013 char_u *p = eap->arg; | |
4014 | |
655 | 4015 if (*p != NUL && (eap->cmdidx == CMD_vimgrep || eap->cmdidx == CMD_lvimgrep |
4016 || eap->cmdidx == CMD_vimgrepadd | |
4017 || eap->cmdidx == CMD_lvimgrepadd | |
4018 || grep_internal(eap->cmdidx))) | |
153 | 4019 { |
170 | 4020 p = skip_vimgrep_pat(p, NULL, NULL); |
153 | 4021 if (p == NULL) |
4022 p = eap->arg; | |
4023 } | |
4024 return p; | |
4025 } | |
344 | 4026 |
4027 /* | |
4028 * For the ":make" and ":grep" commands insert the 'makeprg'/'grepprg' option | |
4029 * in the command line, so that things like % get expanded. | |
4030 */ | |
4031 static char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4032 replace_makeprg(exarg_T *eap, char_u *p, char_u **cmdlinep) |
344 | 4033 { |
4034 char_u *new_cmdline; | |
4035 char_u *program; | |
4036 char_u *pos; | |
4037 char_u *ptr; | |
4038 int len; | |
4039 int i; | |
4040 | |
4041 /* | |
4042 * Don't do it when ":vimgrep" is used for ":grep". | |
4043 */ | |
655 | 4044 if ((eap->cmdidx == CMD_make || eap->cmdidx == CMD_lmake |
4045 || eap->cmdidx == CMD_grep || eap->cmdidx == CMD_lgrep | |
4046 || eap->cmdidx == CMD_grepadd | |
4047 || eap->cmdidx == CMD_lgrepadd) | |
344 | 4048 && !grep_internal(eap->cmdidx)) |
4049 { | |
655 | 4050 if (eap->cmdidx == CMD_grep || eap->cmdidx == CMD_lgrep |
4051 || eap->cmdidx == CMD_grepadd || eap->cmdidx == CMD_lgrepadd) | |
344 | 4052 { |
4053 if (*curbuf->b_p_gp == NUL) | |
4054 program = p_gp; | |
4055 else | |
4056 program = curbuf->b_p_gp; | |
4057 } | |
4058 else | |
4059 { | |
4060 if (*curbuf->b_p_mp == NUL) | |
4061 program = p_mp; | |
4062 else | |
4063 program = curbuf->b_p_mp; | |
4064 } | |
4065 | |
4066 p = skipwhite(p); | |
4067 | |
4068 if ((pos = (char_u *)strstr((char *)program, "$*")) != NULL) | |
4069 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4070 // replace $* by given arguments |
344 | 4071 i = 1; |
4072 while ((pos = (char_u *)strstr((char *)pos + 2, "$*")) != NULL) | |
4073 ++i; | |
4074 len = (int)STRLEN(p); | |
16782
fc58fee685e2
patch 8.1.1393: unnecessary type casts
Bram Moolenaar <Bram@vim.org>
parents:
16780
diff
changeset
|
4075 new_cmdline = alloc(STRLEN(program) + i * (len - 2) + 1); |
344 | 4076 if (new_cmdline == NULL) |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4077 return NULL; // out of memory |
344 | 4078 ptr = new_cmdline; |
4079 while ((pos = (char_u *)strstr((char *)program, "$*")) != NULL) | |
4080 { | |
4081 i = (int)(pos - program); | |
4082 STRNCPY(ptr, program, i); | |
4083 STRCPY(ptr += i, p); | |
4084 ptr += len; | |
4085 program = pos + 2; | |
4086 } | |
4087 STRCPY(ptr, program); | |
4088 } | |
4089 else | |
4090 { | |
16782
fc58fee685e2
patch 8.1.1393: unnecessary type casts
Bram Moolenaar <Bram@vim.org>
parents:
16780
diff
changeset
|
4091 new_cmdline = alloc(STRLEN(program) + STRLEN(p) + 2); |
344 | 4092 if (new_cmdline == NULL) |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4093 return NULL; // out of memory |
344 | 4094 STRCPY(new_cmdline, program); |
4095 STRCAT(new_cmdline, " "); | |
4096 STRCAT(new_cmdline, p); | |
4097 } | |
4098 msg_make(p); | |
4099 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4100 // 'eap->cmd' is not set here, because it is not used at CMD_make |
344 | 4101 vim_free(*cmdlinep); |
4102 *cmdlinep = new_cmdline; | |
4103 p = new_cmdline; | |
4104 } | |
4105 return p; | |
4106 } | |
153 | 4107 #endif |
4108 | |
7 | 4109 /* |
4110 * 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
|
4111 * When an error is detected, "errormsgp" is set to a non-NULL pointer. |
7 | 4112 * Return FAIL for failure, OK otherwise. |
4113 */ | |
4114 int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4115 expand_filename( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4116 exarg_T *eap, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4117 char_u **cmdlinep, |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
4118 char **errormsgp) |
7 | 4119 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4120 int has_wildcards; // need to expand wildcards |
7 | 4121 char_u *repl; |
4122 int srclen; | |
4123 char_u *p; | |
4124 int n; | |
1098 | 4125 int escaped; |
7 | 4126 |
153 | 4127 #ifdef FEAT_QUICKFIX |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4128 // Skip a regexp pattern for ":vimgrep[add] pat file..." |
153 | 4129 p = skip_grep_pat(eap); |
4130 #else | |
4131 p = eap->arg; | |
4132 #endif | |
4133 | |
7 | 4134 /* |
4135 * Decide to expand wildcards *before* replacing '%', '#', etc. If | |
4136 * the file name contains a wildcard it should not cause expanding. | |
4137 * (it will be expanded anyway if there is a wildcard before replacing). | |
4138 */ | |
153 | 4139 has_wildcards = mch_has_wildcard(p); |
4140 while (*p != NUL) | |
7 | 4141 { |
9 | 4142 #ifdef FEAT_EVAL |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4143 // Skip over `=expr`, wildcards in it are not expanded. |
9 | 4144 if (p[0] == '`' && p[1] == '=') |
4145 { | |
4146 p += 2; | |
4147 (void)skip_expr(&p); | |
4148 if (*p == '`') | |
4149 ++p; | |
4150 continue; | |
4151 } | |
4152 #endif | |
7 | 4153 /* |
4154 * Quick check if this cannot be the start of a special string. | |
4155 * Also removes backslash before '%', '#' and '<'. | |
4156 */ | |
4157 if (vim_strchr((char_u *)"%#<", *p) == NULL) | |
4158 { | |
4159 ++p; | |
4160 continue; | |
4161 } | |
4162 | |
4163 /* | |
4164 * Try to find a match at this position. | |
4165 */ | |
1098 | 4166 repl = eval_vars(p, eap->arg, &srclen, &(eap->do_ecmd_lnum), |
4167 errormsgp, &escaped); | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4168 if (*errormsgp != NULL) // error detected |
7 | 4169 return FAIL; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4170 if (repl == NULL) // no match found |
7 | 4171 { |
4172 p += srclen; | |
4173 continue; | |
4174 } | |
4175 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4176 // Wildcards won't be expanded below, the replacement is taken |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4177 // literally. But do expand "~/file", "~user/file" and "$HOME/file". |
37 | 4178 if (vim_strchr(repl, '$') != NULL || vim_strchr(repl, '~') != NULL) |
4179 { | |
4180 char_u *l = repl; | |
4181 | |
4182 repl = expand_env_save(repl); | |
4183 vim_free(l); | |
4184 } | |
4185 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4186 // Need to escape white space et al. with a backslash. |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4187 // Don't do this for: |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4188 // - replacement that already has been escaped: "##" |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4189 // - shell commands (may have to use quotes instead). |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4190 // - non-unix systems when there is a single argument (spaces don't |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4191 // separate arguments then). |
7 | 4192 if (!eap->usefilter |
1098 | 4193 && !escaped |
7 | 4194 && eap->cmdidx != CMD_bang |
4195 && 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
|
4196 && eap->cmdidx != CMD_grepadd |
1c1cb1e9b7b3
patch 8.0.0785: wildcards are not expanded for :terminal
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
4197 && eap->cmdidx != CMD_hardcopy |
655 | 4198 && eap->cmdidx != CMD_lgrep |
4199 && 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
|
4200 && eap->cmdidx != CMD_lmake |
1c1cb1e9b7b3
patch 8.0.0785: wildcards are not expanded for :terminal
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
4201 && eap->cmdidx != CMD_make |
1c1cb1e9b7b3
patch 8.0.0785: wildcards are not expanded for :terminal
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
4202 && eap->cmdidx != CMD_terminal |
7 | 4203 #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
|
4204 && !(eap->argt & EX_NOSPC) |
7 | 4205 #endif |
4206 ) | |
4207 { | |
4208 char_u *l; | |
4209 #ifdef BACKSLASH_IN_FILENAME | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4210 // Don't escape a backslash here, because rem_backslash() doesn't |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4211 // remove it later. |
7 | 4212 static char_u *nobslash = (char_u *)" \t\"|"; |
4213 # define ESCAPE_CHARS nobslash | |
4214 #else | |
4215 # define ESCAPE_CHARS escape_chars | |
4216 #endif | |
4217 | |
4218 for (l = repl; *l; ++l) | |
4219 if (vim_strchr(ESCAPE_CHARS, *l) != NULL) | |
4220 { | |
4221 l = vim_strsave_escaped(repl, ESCAPE_CHARS); | |
4222 if (l != NULL) | |
4223 { | |
4224 vim_free(repl); | |
4225 repl = l; | |
4226 } | |
4227 break; | |
4228 } | |
4229 } | |
4230 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4231 // 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
|
4232 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
|
4233 || eap->cmdidx == CMD_terminal) |
5778 | 4234 && vim_strpbrk(repl, (char_u *)"!") != NULL) |
7 | 4235 { |
4236 char_u *l; | |
4237 | |
5778 | 4238 l = vim_strsave_escaped(repl, (char_u *)"!"); |
7 | 4239 if (l != NULL) |
4240 { | |
4241 vim_free(repl); | |
4242 repl = l; | |
4243 } | |
4244 } | |
4245 | |
4246 p = repl_cmdline(eap, p, srclen, repl, cmdlinep); | |
4247 vim_free(repl); | |
4248 if (p == NULL) | |
4249 return FAIL; | |
4250 } | |
4251 | |
4252 /* | |
4253 * One file argument: Expand wildcards. | |
4254 * Don't do this with ":r !command" or ":w !command". | |
4255 */ | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
4256 if ((eap->argt & EX_NOSPC) && !eap->usefilter) |
7 | 4257 { |
4258 /* | |
4259 * May do this twice: | |
4260 * 1. Replace environment variables. | |
4261 * 2. Replace any other wildcards, remove backslashes. | |
4262 */ | |
4263 for (n = 1; n <= 2; ++n) | |
4264 { | |
4265 if (n == 2) | |
4266 { | |
4267 /* | |
4268 * Halve the number of backslashes (this is Vi compatible). | |
4269 * For Unix and OS/2, when wildcards are expanded, this is | |
4270 * done by ExpandOne() below. | |
4271 */ | |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7262
diff
changeset
|
4272 #if defined(UNIX) |
7 | 4273 if (!has_wildcards) |
4274 #endif | |
4275 backslash_halve(eap->arg); | |
4276 } | |
4277 | |
4278 if (has_wildcards) | |
4279 { | |
4280 if (n == 1) | |
4281 { | |
4282 /* | |
4283 * First loop: May expand environment variables. This | |
4284 * can be done much faster with expand_env() than with | |
4285 * something else (e.g., calling a shell). | |
4286 * After expanding environment variables, check again | |
4287 * if there are still wildcards present. | |
4288 */ | |
4289 if (vim_strchr(eap->arg, '$') != NULL | |
4290 || vim_strchr(eap->arg, '~') != NULL) | |
4291 { | |
372 | 4292 expand_env_esc(eap->arg, NameBuff, MAXPATHL, |
1408 | 4293 TRUE, TRUE, NULL); |
7 | 4294 has_wildcards = mch_has_wildcard(NameBuff); |
4295 p = NameBuff; | |
4296 } | |
4297 else | |
4298 p = NULL; | |
4299 } | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4300 else // n == 2 |
7 | 4301 { |
4302 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
|
4303 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
|
4304 | WILD_NOERROR | WILD_ADD_SLASH; |
7 | 4305 |
4306 ExpandInit(&xpc); | |
4307 xpc.xp_context = EXPAND_FILES; | |
2652 | 4308 if (p_wic) |
4309 options += WILD_ICASE; | |
7 | 4310 p = ExpandOne(&xpc, eap->arg, NULL, |
2652 | 4311 options, WILD_EXPAND_FREE); |
7 | 4312 if (p == NULL) |
4313 return FAIL; | |
4314 } | |
4315 if (p != NULL) | |
4316 { | |
4317 (void)repl_cmdline(eap, eap->arg, (int)STRLEN(eap->arg), | |
4318 p, cmdlinep); | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4319 if (n == 2) // p came from ExpandOne() |
7 | 4320 vim_free(p); |
4321 } | |
4322 } | |
4323 } | |
4324 } | |
4325 return OK; | |
4326 } | |
4327 | |
4328 /* | |
4329 * Replace part of the command line, keeping eap->cmd, eap->arg and | |
4330 * eap->nextcmd correct. | |
4331 * "src" points to the part that is to be replaced, of length "srclen". | |
4332 * "repl" is the replacement string. | |
4333 * Returns a pointer to the character after the replaced string. | |
4334 * Returns NULL for failure. | |
4335 */ | |
4336 static char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4337 repl_cmdline( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4338 exarg_T *eap, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4339 char_u *src, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4340 int srclen, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4341 char_u *repl, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4342 char_u **cmdlinep) |
7 | 4343 { |
4344 int len; | |
4345 int i; | |
4346 char_u *new_cmdline; | |
4347 | |
4348 /* | |
4349 * The new command line is build in new_cmdline[]. | |
4350 * First allocate it. | |
4351 * Careful: a "+cmd" argument may have been NUL terminated. | |
4352 */ | |
4353 len = (int)STRLEN(repl); | |
4354 i = (int)(src - *cmdlinep) + (int)STRLEN(src + srclen) + len + 3; | |
698 | 4355 if (eap->nextcmd != NULL) |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4356 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
|
4357 if ((new_cmdline = alloc(i)) == NULL) |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4358 return NULL; // out of memory! |
7 | 4359 |
4360 /* | |
4361 * Copy the stuff before the expanded part. | |
4362 * Copy the expanded stuff. | |
4363 * Copy what came after the expanded part. | |
4364 * Copy the next commands, if there are any. | |
4365 */ | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4366 i = (int)(src - *cmdlinep); // length of part before match |
7 | 4367 mch_memmove(new_cmdline, *cmdlinep, (size_t)i); |
434 | 4368 |
7 | 4369 mch_memmove(new_cmdline + i, repl, (size_t)len); |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4370 i += len; // remember the end of the string |
7 | 4371 STRCPY(new_cmdline + i, src + srclen); |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4372 src = new_cmdline + i; // remember where to continue |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4373 |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4374 if (eap->nextcmd != NULL) // append next command |
7 | 4375 { |
4376 i = (int)STRLEN(new_cmdline) + 1; | |
4377 STRCPY(new_cmdline + i, eap->nextcmd); | |
4378 eap->nextcmd = new_cmdline + i; | |
4379 } | |
4380 eap->cmd = new_cmdline + (eap->cmd - *cmdlinep); | |
4381 eap->arg = new_cmdline + (eap->arg - *cmdlinep); | |
4382 if (eap->do_ecmd_cmd != NULL && eap->do_ecmd_cmd != dollar_command) | |
4383 eap->do_ecmd_cmd = new_cmdline + (eap->do_ecmd_cmd - *cmdlinep); | |
4384 vim_free(*cmdlinep); | |
4385 *cmdlinep = new_cmdline; | |
4386 | |
4387 return src; | |
4388 } | |
4389 | |
4390 /* | |
4391 * Check for '|' to separate commands and '"' to start comments. | |
4392 */ | |
4393 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4394 separate_nextcmd(exarg_T *eap) |
7 | 4395 { |
4396 char_u *p; | |
4397 | |
153 | 4398 #ifdef FEAT_QUICKFIX |
4399 p = skip_grep_pat(eap); | |
4400 #else | |
41 | 4401 p = eap->arg; |
4402 #endif | |
4403 | |
11127
506f5d8b7d8b
patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11010
diff
changeset
|
4404 for ( ; *p; MB_PTR_ADV(p)) |
7 | 4405 { |
4406 if (*p == Ctrl_V) | |
4407 { | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
4408 if (eap->argt & (EX_CTRLV | EX_XFILE)) |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4409 ++p; // skip CTRL-V and next char |
7 | 4410 else |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4411 // remove CTRL-V and skip next char |
1619 | 4412 STRMOVE(p, p + 1); |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4413 if (*p == NUL) // stop at NUL after CTRL-V |
7 | 4414 break; |
4415 } | |
9 | 4416 |
4417 #ifdef FEAT_EVAL | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4418 // 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
|
4419 else if (p[0] == '`' && p[1] == '=' && (eap->argt & EX_XFILE)) |
9 | 4420 { |
4421 p += 2; | |
4422 (void)skip_expr(&p); | |
4423 } | |
4424 #endif | |
4425 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4426 // Check for '"': start of comment or '|': next command |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4427 // :@" and :*" do not start a comment! |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4428 // :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
|
4429 else if ((*p == '"' && !(eap->argt & EX_NOTRLCOM) |
7 | 4430 && ((eap->cmdidx != CMD_at && eap->cmdidx != CMD_star) |
4431 || p != eap->arg) | |
4432 && (eap->cmdidx != CMD_redir | |
4433 || p != eap->arg + 1 || p[-1] != '@')) | |
4434 || *p == '|' || *p == '\n') | |
4435 { | |
4436 /* | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
4437 * We remove the '\' before the '|', unless EX_CTRLV is used |
7 | 4438 * AND 'b' is present in 'cpoptions'. |
4439 */ | |
4440 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
|
4441 || !(eap->argt & EX_CTRLV)) && *(p - 1) == '\\') |
7 | 4442 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4443 STRMOVE(p - 1, p); // remove the '\' |
7 | 4444 --p; |
4445 } | |
4446 else | |
4447 { | |
4448 eap->nextcmd = check_nextcmd(p); | |
4449 *p = NUL; | |
4450 break; | |
4451 } | |
4452 } | |
41 | 4453 } |
4454 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4455 if (!(eap->argt & EX_NOTRLCOM)) // remove trailing spaces |
7 | 4456 del_trailing_spaces(eap->arg); |
4457 } | |
4458 | |
4459 /* | |
4460 * get + command from ex argument | |
4461 */ | |
4462 static char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4463 getargcmd(char_u **argp) |
7 | 4464 { |
4465 char_u *arg = *argp; | |
4466 char_u *command = NULL; | |
4467 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4468 if (*arg == '+') // +[command] |
7 | 4469 { |
4470 ++arg; | |
5790 | 4471 if (vim_isspace(*arg) || *arg == NUL) |
7 | 4472 command = dollar_command; |
4473 else | |
4474 { | |
4475 command = arg; | |
4476 arg = skip_cmd_arg(command, TRUE); | |
4477 if (*arg != NUL) | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4478 *arg++ = NUL; // terminate command with NUL |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4479 } |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4480 |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4481 arg = skipwhite(arg); // skip over spaces |
7 | 4482 *argp = arg; |
4483 } | |
4484 return command; | |
4485 } | |
4486 | |
4487 /* | |
4488 * Find end of "+command" argument. Skip over "\ " and "\\". | |
4489 */ | |
17835
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17823
diff
changeset
|
4490 char_u * |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4491 skip_cmd_arg( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4492 char_u *p, |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4493 int rembs) // TRUE to halve the number of backslashes |
7 | 4494 { |
4495 while (*p && !vim_isspace(*p)) | |
4496 { | |
4497 if (*p == '\\' && p[1] != NUL) | |
4498 { | |
4499 if (rembs) | |
1619 | 4500 STRMOVE(p, p + 1); |
7 | 4501 else |
4502 ++p; | |
4503 } | |
11127
506f5d8b7d8b
patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11010
diff
changeset
|
4504 MB_PTR_ADV(p); |
7 | 4505 } |
4506 return p; | |
4507 } | |
4508 | |
13575
4df23d9bad47
patch 8.0.1660: the terminal API "drop" command doesn't support options
Christian Brabandt <cb@256bit.org>
parents:
13553
diff
changeset
|
4509 int |
4df23d9bad47
patch 8.0.1660: the terminal API "drop" command doesn't support options
Christian Brabandt <cb@256bit.org>
parents:
13553
diff
changeset
|
4510 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
|
4511 { |
4df23d9bad47
patch 8.0.1660: the terminal API "drop" command doesn't support options
Christian Brabandt <cb@256bit.org>
parents:
13553
diff
changeset
|
4512 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
|
4513 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
|
4514 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
|
4515 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
|
4516 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
|
4517 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
|
4518 else |
c1ead25ed819
patch 8.1.0043: ++bad argument of :edit does not work properly
Christian Brabandt <cb@256bit.org>
parents:
14035
diff
changeset
|
4519 return FAIL; |
c1ead25ed819
patch 8.1.0043: ++bad argument of :edit does not work properly
Christian Brabandt <cb@256bit.org>
parents:
14035
diff
changeset
|
4520 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
|
4521 } |
4df23d9bad47
patch 8.0.1660: the terminal API "drop" command doesn't support options
Christian Brabandt <cb@256bit.org>
parents:
13553
diff
changeset
|
4522 |
7 | 4523 /* |
4524 * Get "++opt=arg" argument. | |
4525 * Return FAIL or OK. | |
4526 */ | |
4527 static int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4528 getargopt(exarg_T *eap) |
7 | 4529 { |
4530 char_u *arg = eap->arg + 2; | |
4531 int *pp = NULL; | |
2168 | 4532 int bad_char_idx; |
7 | 4533 char_u *p; |
4534 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4535 // ":edit ++[no]bin[ary] file" |
7 | 4536 if (STRNCMP(arg, "bin", 3) == 0 || STRNCMP(arg, "nobin", 5) == 0) |
4537 { | |
4538 if (*arg == 'n') | |
4539 { | |
4540 arg += 2; | |
4541 eap->force_bin = FORCE_NOBIN; | |
4542 } | |
4543 else | |
4544 eap->force_bin = FORCE_BIN; | |
4545 if (!checkforcmd(&arg, "binary", 3)) | |
4546 return FAIL; | |
4547 eap->arg = skipwhite(arg); | |
4548 return OK; | |
4549 } | |
4550 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4551 // ":read ++edit file" |
819 | 4552 if (STRNCMP(arg, "edit", 4) == 0) |
4553 { | |
4554 eap->read_edit = TRUE; | |
4555 eap->arg = skipwhite(arg + 4); | |
4556 return OK; | |
4557 } | |
4558 | |
7 | 4559 if (STRNCMP(arg, "ff", 2) == 0) |
4560 { | |
4561 arg += 2; | |
4562 pp = &eap->force_ff; | |
4563 } | |
4564 else if (STRNCMP(arg, "fileformat", 10) == 0) | |
4565 { | |
4566 arg += 10; | |
4567 pp = &eap->force_ff; | |
4568 } | |
4569 else if (STRNCMP(arg, "enc", 3) == 0) | |
4570 { | |
3208 | 4571 if (STRNCMP(arg, "encoding", 8) == 0) |
4572 arg += 8; | |
4573 else | |
4574 arg += 3; | |
7 | 4575 pp = &eap->force_enc; |
4576 } | |
595 | 4577 else if (STRNCMP(arg, "bad", 3) == 0) |
4578 { | |
4579 arg += 3; | |
2168 | 4580 pp = &bad_char_idx; |
595 | 4581 } |
7 | 4582 |
4583 if (pp == NULL || *arg != '=') | |
4584 return FAIL; | |
4585 | |
4586 ++arg; | |
4587 *pp = (int)(arg - eap->cmd); | |
4588 arg = skip_cmd_arg(arg, FALSE); | |
4589 eap->arg = skipwhite(arg); | |
4590 *arg = NUL; | |
4591 | |
4592 if (pp == &eap->force_ff) | |
4593 { | |
4594 if (check_ff_value(eap->cmd + eap->force_ff) == FAIL) | |
4595 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
|
4596 eap->force_ff = eap->cmd[eap->force_ff]; |
7 | 4597 } |
595 | 4598 else if (pp == &eap->force_enc) |
7 | 4599 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4600 // Make 'fileencoding' lower case. |
7 | 4601 for (p = eap->cmd + eap->force_enc; *p != NUL; ++p) |
4602 *p = TOLOWER_ASC(*p); | |
4603 } | |
595 | 4604 else |
4605 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4606 // Check ++bad= argument. Must be a single-byte character, "keep" or |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4607 // "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
|
4608 if (get_bad_opt(eap->cmd + bad_char_idx, eap) == FAIL) |
595 | 4609 return FAIL; |
4610 } | |
7 | 4611 |
4612 return OK; | |
4613 } | |
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_autocmd(exarg_T *eap) |
7 | 4617 { |
4618 /* | |
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
|
4619 * Disallow autocommands from .exrc and .vimrc in current |
7 | 4620 * directory for security reasons. |
4621 */ | |
4622 if (secure) | |
4623 { | |
4624 secure = 2; | |
4625 eap->errmsg = e_curdir; | |
4626 } | |
4627 else if (eap->cmdidx == CMD_autocmd) | |
4628 do_autocmd(eap->arg, eap->forceit); | |
4629 else | |
4630 do_augroup(eap->arg, eap->forceit); | |
4631 } | |
4632 | |
4633 /* | |
4634 * ":doautocmd": Apply the automatic commands to the current buffer. | |
4635 */ | |
4636 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4637 ex_doautocmd(exarg_T *eap) |
7 | 4638 { |
3350 | 4639 char_u *arg = eap->arg; |
4640 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
|
4641 int did_aucmd; |
ac8180818504
commit https://github.com/vim/vim/commit/1610d052413e0ed664498853a47acc2d677a22d1
Christian Brabandt <cb@256bit.org>
parents:
9230
diff
changeset
|
4642 |
ac8180818504
commit https://github.com/vim/vim/commit/1610d052413e0ed664498853a47acc2d677a22d1
Christian Brabandt <cb@256bit.org>
parents:
9230
diff
changeset
|
4643 (void)do_doautocmd(arg, TRUE, &did_aucmd); |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4644 // Only when there is no <nomodeline>. |
9260
ac8180818504
commit https://github.com/vim/vim/commit/1610d052413e0ed664498853a47acc2d677a22d1
Christian Brabandt <cb@256bit.org>
parents:
9230
diff
changeset
|
4645 if (call_do_modelines && did_aucmd) |
3350 | 4646 do_modelines(0); |
7 | 4647 } |
4648 | |
4649 /* | |
4650 * :[N]bunload[!] [N] [bufname] unload buffer | |
4651 * :[N]bdelete[!] [N] [bufname] delete buffer from buffer list | |
4652 * :[N]bwipeout[!] [N] [bufname] delete buffer really | |
4653 */ | |
4654 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4655 ex_bunload(exarg_T *eap) |
7 | 4656 { |
19271
ebeeb4b4a1fa
patch 8.2.0194: some commands can cause problems in terminal popup
Bram Moolenaar <Bram@vim.org>
parents:
19261
diff
changeset
|
4657 if (ERROR_IF_ANY_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
|
4658 return; |
7 | 4659 eap->errmsg = do_bufdel( |
4660 eap->cmdidx == CMD_bdelete ? DOBUF_DEL | |
4661 : eap->cmdidx == CMD_bwipeout ? DOBUF_WIPE | |
4662 : DOBUF_UNLOAD, eap->arg, | |
4663 eap->addr_count, (int)eap->line1, (int)eap->line2, eap->forceit); | |
4664 } | |
4665 | |
4666 /* | |
4667 * :[N]buffer [N] to buffer N | |
4668 * :[N]sbuffer [N] to buffer N | |
4669 */ | |
4670 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4671 ex_buffer(exarg_T *eap) |
7 | 4672 { |
19271
ebeeb4b4a1fa
patch 8.2.0194: some commands can cause problems in terminal popup
Bram Moolenaar <Bram@vim.org>
parents:
19261
diff
changeset
|
4673 if (ERROR_IF_ANY_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
|
4674 return; |
7 | 4675 if (*eap->arg) |
4676 eap->errmsg = e_trailing; | |
4677 else | |
4678 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4679 if (eap->addr_count == 0) // default is current buffer |
7 | 4680 goto_buffer(eap, DOBUF_CURRENT, FORWARD, 0); |
4681 else | |
4682 goto_buffer(eap, DOBUF_FIRST, FORWARD, (int)eap->line2); | |
6230 | 4683 if (eap->do_ecmd_cmd != NULL) |
4684 do_cmdline_cmd(eap->do_ecmd_cmd); | |
7 | 4685 } |
4686 } | |
4687 | |
4688 /* | |
4689 * :[N]bmodified [N] to next mod. buffer | |
4690 * :[N]sbmodified [N] to next mod. buffer | |
4691 */ | |
4692 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4693 ex_bmodified(exarg_T *eap) |
7 | 4694 { |
4695 goto_buffer(eap, DOBUF_MOD, FORWARD, (int)eap->line2); | |
6230 | 4696 if (eap->do_ecmd_cmd != NULL) |
4697 do_cmdline_cmd(eap->do_ecmd_cmd); | |
7 | 4698 } |
4699 | |
4700 /* | |
4701 * :[N]bnext [N] to next buffer | |
4702 * :[N]sbnext [N] split and to next buffer | |
4703 */ | |
4704 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4705 ex_bnext(exarg_T *eap) |
7 | 4706 { |
19271
ebeeb4b4a1fa
patch 8.2.0194: some commands can cause problems in terminal popup
Bram Moolenaar <Bram@vim.org>
parents:
19261
diff
changeset
|
4707 if (ERROR_IF_ANY_POPUP_WINDOW) |
19135
17722555af22
patch 8.2.0127: some buffer commands work in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19131
diff
changeset
|
4708 return; |
17722555af22
patch 8.2.0127: some buffer commands work in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19131
diff
changeset
|
4709 |
7 | 4710 goto_buffer(eap, DOBUF_CURRENT, FORWARD, (int)eap->line2); |
6230 | 4711 if (eap->do_ecmd_cmd != NULL) |
4712 do_cmdline_cmd(eap->do_ecmd_cmd); | |
7 | 4713 } |
4714 | |
4715 /* | |
4716 * :[N]bNext [N] to previous buffer | |
4717 * :[N]bprevious [N] to previous buffer | |
4718 * :[N]sbNext [N] split and to previous buffer | |
4719 * :[N]sbprevious [N] split and to previous buffer | |
4720 */ | |
4721 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4722 ex_bprevious(exarg_T *eap) |
7 | 4723 { |
19271
ebeeb4b4a1fa
patch 8.2.0194: some commands can cause problems in terminal popup
Bram Moolenaar <Bram@vim.org>
parents:
19261
diff
changeset
|
4724 if (ERROR_IF_ANY_POPUP_WINDOW) |
19135
17722555af22
patch 8.2.0127: some buffer commands work in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19131
diff
changeset
|
4725 return; |
17722555af22
patch 8.2.0127: some buffer commands work in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19131
diff
changeset
|
4726 |
7 | 4727 goto_buffer(eap, DOBUF_CURRENT, BACKWARD, (int)eap->line2); |
6230 | 4728 if (eap->do_ecmd_cmd != NULL) |
4729 do_cmdline_cmd(eap->do_ecmd_cmd); | |
7 | 4730 } |
4731 | |
4732 /* | |
4733 * :brewind to first buffer | |
4734 * :bfirst to first buffer | |
4735 * :sbrewind split and to first buffer | |
4736 * :sbfirst split and to first buffer | |
4737 */ | |
4738 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4739 ex_brewind(exarg_T *eap) |
7 | 4740 { |
19271
ebeeb4b4a1fa
patch 8.2.0194: some commands can cause problems in terminal popup
Bram Moolenaar <Bram@vim.org>
parents:
19261
diff
changeset
|
4741 if (ERROR_IF_ANY_POPUP_WINDOW) |
19135
17722555af22
patch 8.2.0127: some buffer commands work in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19131
diff
changeset
|
4742 return; |
17722555af22
patch 8.2.0127: some buffer commands work in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19131
diff
changeset
|
4743 |
7 | 4744 goto_buffer(eap, DOBUF_FIRST, FORWARD, 0); |
6230 | 4745 if (eap->do_ecmd_cmd != NULL) |
4746 do_cmdline_cmd(eap->do_ecmd_cmd); | |
7 | 4747 } |
4748 | |
4749 /* | |
4750 * :blast to last buffer | |
4751 * :sblast split and to last buffer | |
4752 */ | |
4753 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4754 ex_blast(exarg_T *eap) |
7 | 4755 { |
19271
ebeeb4b4a1fa
patch 8.2.0194: some commands can cause problems in terminal popup
Bram Moolenaar <Bram@vim.org>
parents:
19261
diff
changeset
|
4756 if (ERROR_IF_ANY_POPUP_WINDOW) |
19135
17722555af22
patch 8.2.0127: some buffer commands work in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19131
diff
changeset
|
4757 return; |
17722555af22
patch 8.2.0127: some buffer commands work in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19131
diff
changeset
|
4758 |
7 | 4759 goto_buffer(eap, DOBUF_LAST, BACKWARD, 0); |
6230 | 4760 if (eap->do_ecmd_cmd != NULL) |
4761 do_cmdline_cmd(eap->do_ecmd_cmd); | |
7 | 4762 } |
4763 | |
4764 int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4765 ends_excmd(int c) |
7 | 4766 { |
20027
23a4aef4f923
patch 8.2.0569: build failure with tiny version
Bram Moolenaar <Bram@vim.org>
parents:
20023
diff
changeset
|
4767 #ifdef FEAT_EVAL |
20023
c85d4e173cc9
patch 8.2.0567: Vim9: cannot put comments halfway expressions
Bram Moolenaar <Bram@vim.org>
parents:
20009
diff
changeset
|
4768 if (c == '#') |
c85d4e173cc9
patch 8.2.0567: Vim9: cannot put comments halfway expressions
Bram Moolenaar <Bram@vim.org>
parents:
20009
diff
changeset
|
4769 // TODO: should check for preceding white space |
c85d4e173cc9
patch 8.2.0567: Vim9: cannot put comments halfway expressions
Bram Moolenaar <Bram@vim.org>
parents:
20009
diff
changeset
|
4770 return in_vim9script(); |
20027
23a4aef4f923
patch 8.2.0569: build failure with tiny version
Bram Moolenaar <Bram@vim.org>
parents:
20023
diff
changeset
|
4771 #endif |
7 | 4772 return (c == NUL || c == '|' || c == '"' || c == '\n'); |
4773 } | |
4774 | |
4775 #if defined(FEAT_SYN_HL) || defined(FEAT_SEARCH_EXTRA) || defined(FEAT_EVAL) \ | |
4776 || defined(PROTO) | |
4777 /* | |
4778 * Return the next command, after the first '|' or '\n'. | |
4779 * Return NULL if not found. | |
4780 */ | |
4781 char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4782 find_nextcmd(char_u *p) |
7 | 4783 { |
4784 while (*p != '|' && *p != '\n') | |
4785 { | |
4786 if (*p == NUL) | |
4787 return NULL; | |
4788 ++p; | |
4789 } | |
4790 return (p + 1); | |
4791 } | |
4792 #endif | |
4793 | |
4794 /* | |
10383
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
4795 * 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
|
4796 * Return NULL if it isn't, the following character if it is. |
7 | 4797 */ |
4798 char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4799 check_nextcmd(char_u *p) |
7 | 4800 { |
10383
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
4801 char_u *s = skipwhite(p); |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
4802 |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
4803 if (*s == '|' || *s == '\n') |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
4804 return (s + 1); |
7 | 4805 else |
4806 return NULL; | |
4807 } | |
4808 | |
4809 /* | |
4810 * - if there are more files to edit | |
4811 * - and this is the last window | |
4812 * - and forceit not used | |
4813 * - and not repeated twice on a row | |
4814 * return FAIL and give error message if 'message' TRUE | |
4815 * return OK otherwise | |
4816 */ | |
4817 static int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4818 check_more( |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4819 int message, // when FALSE check only, no messages |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4820 int forceit) |
7 | 4821 { |
4822 int n = ARGCOUNT - curwin->w_arg_idx - 1; | |
4823 | |
672 | 4824 if (!forceit && only_one_window() |
4825 && ARGCOUNT > 1 && !arg_had_last && n >= 0 && quitmore == 0) | |
7 | 4826 { |
4827 if (message) | |
4828 { | |
4829 #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) | |
4830 if ((p_confirm || cmdmod.confirm) && curbuf->b_fname != NULL) | |
4831 { | |
2770 | 4832 char_u buff[DIALOG_MSG_SIZE]; |
7 | 4833 |
14585
c8f07e8b273e
patch 8.1.0306: plural messages are not translated properly
Christian Brabandt <cb@256bit.org>
parents:
14550
diff
changeset
|
4834 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
|
4835 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
|
4836 "%d more files to edit. Quit anyway?", n), n); |
7 | 4837 if (vim_dialog_yesno(VIM_QUESTION, NULL, buff, 1) == VIM_YES) |
4838 return OK; | |
4839 return FAIL; | |
4840 } | |
4841 #endif | |
15490
98c35d312987
patch 8.1.0753: printf format not checked for semsg()
Bram Moolenaar <Bram@vim.org>
parents:
15488
diff
changeset
|
4842 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
|
4843 "E173: %d more files to edit", n), n); |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4844 quitmore = 2; // next try to quit is allowed |
7 | 4845 } |
4846 return FAIL; | |
4847 } | |
4848 return OK; | |
4849 } | |
4850 | |
4851 /* | |
4852 * Function given to ExpandGeneric() to obtain the list of command names. | |
4853 */ | |
4854 char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4855 get_command_name(expand_T *xp UNUSED, int idx) |
7 | 4856 { |
4857 if (idx >= (int)CMD_SIZE) | |
4858 return get_user_command_name(idx); | |
4859 return cmdnames[idx].cmd_name; | |
4860 } | |
4861 | |
4862 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4863 ex_colorscheme(exarg_T *eap) |
7 | 4864 { |
2142
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4865 if (*eap->arg == NUL) |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4866 { |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4867 #ifdef FEAT_EVAL |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4868 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
|
4869 char_u *p = NULL; |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4870 |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4871 if (expr != NULL) |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4872 { |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4873 ++emsg_off; |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4874 p = eval_to_string(expr, NULL, FALSE); |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4875 --emsg_off; |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4876 vim_free(expr); |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4877 } |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4878 if (p != NULL) |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4879 { |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15510
diff
changeset
|
4880 msg((char *)p); |
2142
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4881 vim_free(p); |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4882 } |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4883 else |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15510
diff
changeset
|
4884 msg("default"); |
2142
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4885 #else |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15510
diff
changeset
|
4886 msg(_("unknown")); |
2142
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4887 #endif |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4888 } |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4889 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
|
4890 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
|
4891 |
61448894376e
patch 8.1.0839: when using VTP wrong colors after a color scheme change
Bram Moolenaar <Bram@vim.org>
parents:
15643
diff
changeset
|
4892 #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
|
4893 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
|
4894 { |
61448894376e
patch 8.1.0839: when using VTP wrong colors after a color scheme change
Bram Moolenaar <Bram@vim.org>
parents:
15643
diff
changeset
|
4895 // 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
|
4896 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
|
4897 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
|
4898 } |
61448894376e
patch 8.1.0839: when using VTP wrong colors after a color scheme change
Bram Moolenaar <Bram@vim.org>
parents:
15643
diff
changeset
|
4899 #endif |
7 | 4900 } |
4901 | |
4902 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4903 ex_highlight(exarg_T *eap) |
7 | 4904 { |
4905 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
|
4906 msg(_("Greetings, Vim user!")); |
7 | 4907 do_highlight(eap->arg, eap->forceit, FALSE); |
4908 } | |
4909 | |
4910 | |
4911 /* | |
4912 * Call this function if we thought we were going to exit, but we won't | |
4913 * (because of an error). May need to restore the terminal mode. | |
4914 */ | |
4915 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4916 not_exiting(void) |
7 | 4917 { |
4918 exiting = FALSE; | |
4919 settmode(TMODE_RAW); | |
4920 } | |
4921 | |
13442
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
4922 static int |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
4923 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
|
4924 { |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
4925 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
|
4926 |
18406
fa6efc49d71f
patch 8.1.2197: ExitPre autocommand may cause accessing freed memory
Bram Moolenaar <Bram@vim.org>
parents:
18402
diff
changeset
|
4927 // 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
|
4928 // 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
|
4929 // only happen in autocommands). |
13442
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
4930 if (!win_valid(wp) |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
4931 || curbuf_locked() |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
4932 || (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
|
4933 return TRUE; |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
4934 |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
4935 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
|
4936 { |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
4937 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
|
4938 // 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
|
4939 // 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
|
4940 // autocommands). |
fa6efc49d71f
patch 8.1.2197: ExitPre autocommand may cause accessing freed memory
Bram Moolenaar <Bram@vim.org>
parents:
18402
diff
changeset
|
4941 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
|
4942 || (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
|
4943 return TRUE; |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
4944 } |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
4945 |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
4946 return FALSE; |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
4947 } |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
4948 |
7 | 4949 /* |
6409 | 4950 * ":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
|
4951 * ":{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
|
4952 * 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
|
4953 */ |
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
|
4954 void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4955 ex_quit(exarg_T *eap) |
7 | 4956 { |
6398 | 4957 win_T *wp; |
4958 | |
7 | 4959 #ifdef FEAT_CMDWIN |
4960 if (cmdwin_type != 0) | |
4961 { | |
4962 cmdwin_result = Ctrl_C; | |
4963 return; | |
4964 } | |
4965 #endif | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4966 // Don't quit while editing the command line. |
633 | 4967 if (text_locked()) |
4968 { | |
4969 text_locked_msg(); | |
631 | 4970 return; |
4971 } | |
6398 | 4972 if (eap->addr_count > 0) |
4973 { | |
6409 | 4974 int wnr = eap->line2; |
4975 | |
4976 for (wp = firstwin; wp->w_next != NULL; wp = wp->w_next) | |
4977 if (--wnr <= 0) | |
6398 | 4978 break; |
4979 } | |
4980 else | |
4981 wp = curwin; | |
6409 | 4982 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4983 // Refuse to quit when locked. |
12652
272ecbaf1b4f
patch 8.0.1204: a QuitPre autocommand may get the wrong file name
Christian Brabandt <cb@256bit.org>
parents:
12624
diff
changeset
|
4984 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
|
4985 return; |
13442
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
4986 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4987 // Trigger QuitPre and maybe ExitPre |
13442
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
4988 if (before_quit_autocmds(wp, FALSE, eap->forceit)) |
819 | 4989 return; |
7 | 4990 |
4991 #ifdef FEAT_NETBEANS_INTG | |
4992 netbeansForcedQuit = eap->forceit; | |
4993 #endif | |
4994 | |
4995 /* | |
4996 * If there are more files or windows we won't exit. | |
4997 */ | |
4998 if (check_more(FALSE, eap->forceit) == OK && only_one_window()) | |
4999 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
|
5000 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
|
5001 && check_changed(wp->w_buffer, (p_awa ? CCGD_AW : 0) |
5464 | 5002 | (eap->forceit ? CCGD_FORCEIT : 0) |
5003 | CCGD_EXCMD)) | |
7 | 5004 || 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
|
5005 || (only_one_window() && check_changed_any(eap->forceit, TRUE))) |
7 | 5006 { |
5007 not_exiting(); | |
5008 } | |
5009 else | |
5010 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5011 // quit last window |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5012 // Note: only_one_window() returns true, even so a help window is |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5013 // still open. In that case only quit, if no address has been |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5014 // specified. Example: |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5015 // :h|wincmd w|1q - don't quit |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5016 // :h|wincmd w|q - quit |
10349
cf988222b150
commit https://github.com/vim/vim/commit/a1f4cb93ba50ea9e40cd4b1f5592b8a6d1398660
Christian Brabandt <cb@256bit.org>
parents:
10275
diff
changeset
|
5017 if (only_one_window() && (ONE_WINDOW || eap->addr_count == 0)) |
7 | 5018 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
|
5019 not_exiting(); |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5020 #ifdef FEAT_GUI |
7 | 5021 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
|
5022 #endif |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5023 // 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
|
5024 win_close(wp, !buf_hide(wp->w_buffer) || eap->forceit); |
7 | 5025 } |
5026 } | |
5027 | |
5028 /* | |
5029 * ":cquit". | |
5030 */ | |
5031 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5032 ex_cquit(exarg_T *eap UNUSED) |
7 | 5033 { |
19069
e14feba578f1
patch 8.2.0095: cannot specify exit code for :cquit
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
5034 // this does not always pass on the exit code to the Manx compiler. why? |
e14feba578f1
patch 8.2.0095: cannot specify exit code for :cquit
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
5035 getout(eap->addr_count > 0 ? (int)eap->line2 : EXIT_FAILURE); |
7 | 5036 } |
5037 | |
5038 /* | |
5039 * ":qall": try to quit all windows | |
5040 */ | |
5041 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5042 ex_quit_all(exarg_T *eap) |
7 | 5043 { |
5044 # ifdef FEAT_CMDWIN | |
5045 if (cmdwin_type != 0) | |
5046 { | |
5047 if (eap->forceit) | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5048 cmdwin_result = K_XF1; // ex_window() takes care of this |
7 | 5049 else |
5050 cmdwin_result = K_XF2; | |
5051 return; | |
5052 } | |
5053 # endif | |
631 | 5054 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5055 // Don't quit while editing the command line. |
633 | 5056 if (text_locked()) |
5057 { | |
5058 text_locked_msg(); | |
631 | 5059 return; |
5060 } | |
13442
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5061 |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5062 if (before_quit_autocmds(curwin, TRUE, eap->forceit)) |
819 | 5063 return; |
631 | 5064 |
7 | 5065 exiting = TRUE; |
7469
15eefe1b0dad
commit https://github.com/vim/vim/commit/027387f70c671f62e3e08e0bdd09ec05b0232735
Christian Brabandt <cb@256bit.org>
parents:
7465
diff
changeset
|
5066 if (eap->forceit || !check_changed_any(FALSE, FALSE)) |
7 | 5067 getout(0); |
5068 not_exiting(); | |
5069 } | |
5070 | |
5071 /* | |
5072 * ":close": close current window, unless it is the last one | |
5073 */ | |
5074 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5075 ex_close(exarg_T *eap) |
7 | 5076 { |
6398 | 5077 win_T *win; |
5078 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
|
5079 #ifdef FEAT_CMDWIN |
7 | 5080 if (cmdwin_type != 0) |
2839 | 5081 cmdwin_result = Ctrl_C; |
7 | 5082 else |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5083 #endif |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
5084 if (!text_locked() && !curbuf_locked()) |
6398 | 5085 { |
5086 if (eap->addr_count == 0) | |
5087 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
|
5088 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
|
5089 { |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9538
diff
changeset
|
5090 FOR_ALL_WINDOWS(win) |
6398 | 5091 { |
5092 winnr++; | |
5093 if (winnr == eap->line2) | |
5094 break; | |
5095 } | |
5096 if (win == NULL) | |
5097 win = lastwin; | |
5098 ex_win_close(eap->forceit, win, NULL); | |
5099 } | |
5100 } | |
667 | 5101 } |
5102 | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5103 #ifdef FEAT_QUICKFIX |
667 | 5104 /* |
5105 * ":pclose": Close any preview window. | |
5106 */ | |
5107 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5108 ex_pclose(exarg_T *eap) |
667 | 5109 { |
5110 win_T *win; | |
5111 | |
17431
ce35cdbe9f74
patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
17336
diff
changeset
|
5112 // First close any normal window. |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9538
diff
changeset
|
5113 FOR_ALL_WINDOWS(win) |
667 | 5114 if (win->w_p_pvw) |
5115 { | |
671 | 5116 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
|
5117 return; |
ce35cdbe9f74
patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
17336
diff
changeset
|
5118 } |
18763
49b78d6465e5
patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents:
18715
diff
changeset
|
5119 # ifdef FEAT_PROP_POPUP |
17431
ce35cdbe9f74
patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
17336
diff
changeset
|
5120 // 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
|
5121 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
|
5122 # endif |
667 | 5123 } |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5124 #endif |
667 | 5125 |
671 | 5126 /* |
5127 * Close window "win" and take care of handling closing the last window for a | |
5128 * modified buffer. | |
5129 */ | |
5130 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5131 ex_win_close( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5132 int forceit, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5133 win_T *win, |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5134 tabpage_T *tp) // NULL or the tab page "win" is in |
7 | 5135 { |
5136 int need_hide; | |
5137 buf_T *buf = win->w_buffer; | |
5138 | |
5139 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
|
5140 if (need_hide && !buf_hide(buf) && !forceit) |
7 | 5141 { |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5142 #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) |
7 | 5143 if ((p_confirm || cmdmod.confirm) && p_write) |
5144 { | |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9460
diff
changeset
|
5145 bufref_T bufref; |
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9460
diff
changeset
|
5146 |
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9460
diff
changeset
|
5147 set_bufref(&bufref, buf); |
7 | 5148 dialog_changed(buf, FALSE); |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9460
diff
changeset
|
5149 if (bufref_valid(&bufref) && bufIsChanged(buf)) |
7 | 5150 return; |
5151 need_hide = FALSE; | |
5152 } | |
5153 else | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5154 #endif |
7 | 5155 { |
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
|
5156 no_write_message(); |
7 | 5157 return; |
5158 } | |
5159 } | |
5160 | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5161 #ifdef FEAT_GUI |
7 | 5162 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
|
5163 #endif |
671 | 5164 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5165 // free buffer when not hiding it or when it's a scratch buffer |
671 | 5166 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
|
5167 win_close(win, !need_hide && !buf_hide(buf)); |
671 | 5168 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
|
5169 win_close_othertab(win, !need_hide && !buf_hide(buf), tp); |
671 | 5170 } |
5171 | |
5172 /* | |
10741
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5173 * 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
|
5174 * Returns a tabpage number. |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5175 * 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
|
5176 */ |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5177 static int |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5178 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
|
5179 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5180 int tab_number; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5181 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
|
5182 |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5183 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
|
5184 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5185 char_u *p = eap->arg; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5186 char_u *p_save; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5187 int relative = 0; // argument +N/-N means: go to N places to the |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5188 // right/left relative to the current position. |
10741
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5189 |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5190 if (*p == '-') |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5191 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5192 relative = -1; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5193 p++; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5194 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5195 else if (*p == '+') |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5196 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5197 relative = 1; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5198 p++; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5199 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5200 |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5201 p_save = p; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5202 tab_number = getdigits(&p); |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5203 |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5204 if (relative == 0) |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5205 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5206 if (STRCMP(p, "$") == 0) |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5207 tab_number = LAST_TAB_NR; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5208 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
|
5209 || tab_number > LAST_TAB_NR) |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5210 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5211 // No numbers as argument. |
10741
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5212 eap->errmsg = e_invarg; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5213 goto theend; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5214 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5215 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5216 else |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5217 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5218 if (*p_save == NUL) |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5219 tab_number = 1; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5220 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
|
5221 || tab_number == 0) |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5222 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5223 // No numbers as argument. |
10741
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5224 eap->errmsg = e_invarg; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5225 goto theend; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5226 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5227 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
|
5228 if (!unaccept_arg0 && relative == -1) |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5229 --tab_number; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5230 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5231 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
|
5232 eap->errmsg = e_invarg; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5233 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5234 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
|
5235 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5236 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
|
5237 { |
10741
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5238 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
|
5239 tab_number = 0; |
4961e7acdd8c
patch 8.0.0266: compiler warning for using uninitialized variable
Christian Brabandt <cb@256bit.org>
parents:
10741
diff
changeset
|
5240 } |
10741
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5241 else |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5242 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5243 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
|
5244 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
|
5245 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5246 --tab_number; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5247 if (tab_number < unaccept_arg0) |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5248 eap->errmsg = e_invarg; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5249 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5250 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5251 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5252 else |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5253 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5254 switch (eap->cmdidx) |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5255 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5256 case CMD_tabnext: |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5257 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
|
5258 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
|
5259 tab_number = 1; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5260 break; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5261 case CMD_tabmove: |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5262 tab_number = LAST_TAB_NR; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5263 break; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5264 default: |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5265 tab_number = tabpage_index(curtab); |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5266 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5267 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5268 |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5269 theend: |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5270 return tab_number; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5271 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5272 |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5273 /* |
671 | 5274 * ":tabclose": close current tab page, unless it is the last one. |
5275 * ":tabclose N": close tab page N. | |
667 | 5276 */ |
5277 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5278 ex_tabclose(exarg_T *eap) |
667 | 5279 { |
671 | 5280 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
|
5281 int tab_number; |
671 | 5282 |
667 | 5283 # ifdef FEAT_CMDWIN |
5284 if (cmdwin_type != 0) | |
5285 cmdwin_result = K_IGNORE; | |
5286 else | |
5287 # endif | |
671 | 5288 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
|
5289 emsg(_("E784: Cannot close last tab page")); |
671 | 5290 else |
5291 { | |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5292 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
|
5293 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
|
5294 { |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5295 tp = find_tabpage(tab_number); |
671 | 5296 if (tp == NULL) |
5297 { | |
5298 beep_flush(); | |
5299 return; | |
5300 } | |
674 | 5301 if (tp != curtab) |
671 | 5302 { |
5303 tabpage_close_other(tp, eap->forceit); | |
5304 return; | |
5305 } | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
5306 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
|
5307 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
|
5308 } |
671 | 5309 } |
672 | 5310 } |
5311 | |
5312 /* | |
5313 * ":tabonly": close all tab pages except the current one | |
5314 */ | |
5315 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5316 ex_tabonly(exarg_T *eap) |
672 | 5317 { |
5318 tabpage_T *tp; | |
5319 int done; | |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5320 int tab_number; |
672 | 5321 |
5322 # ifdef FEAT_CMDWIN | |
5323 if (cmdwin_type != 0) | |
5324 cmdwin_result = K_IGNORE; | |
5325 else | |
5326 # endif | |
5327 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
|
5328 msg(_("Already only one tab page")); |
672 | 5329 else |
5330 { | |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5331 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
|
5332 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
|
5333 { |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5334 goto_tabpage(tab_number); |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5335 // Repeat this up to a 1000 times, because autocommands may |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5336 // mess up the lists. |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5337 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
|
5338 { |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5339 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
|
5340 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
|
5341 { |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5342 tabpage_close_other(tp, eap->forceit); |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5343 // if we failed to close it quit |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5344 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
|
5345 done = 1000; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5346 // start over, "tp" is now invalid |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5347 break; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5348 } |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5349 if (first_tabpage->tp_next == NULL) |
672 | 5350 break; |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5351 } |
672 | 5352 } |
5353 } | |
671 | 5354 } |
5355 | |
5356 /* | |
5357 * Close the current tab page. | |
5358 */ | |
5359 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5360 tabpage_close(int forceit) |
671 | 5361 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5362 // First close all the windows but the current one. If that worked then |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5363 // 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
|
5364 if (!ONE_WINDOW) |
675 | 5365 close_others(TRUE, forceit); |
10357
59d01e335858
commit https://github.com/vim/vim/commit/459ca563128f2edb7e3bb190090bbb755a56dd55
Christian Brabandt <cb@256bit.org>
parents:
10349
diff
changeset
|
5366 if (ONE_WINDOW) |
671 | 5367 ex_win_close(forceit, curwin, NULL); |
5368 # ifdef FEAT_GUI | |
5369 need_mouse_correct = TRUE; | |
5370 # endif | |
5371 } | |
5372 | |
5373 /* | |
5374 * Close tab page "tp", which is not the current tab page. | |
5375 * Note that autocommands may make "tp" invalid. | |
971 | 5376 * Also takes care of the tab pages line disappearing when closing the |
5377 * last-but-one tab page. | |
671 | 5378 */ |
5379 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5380 tabpage_close_other(tabpage_T *tp, int forceit) |
671 | 5381 { |
5382 int done = 0; | |
672 | 5383 win_T *wp; |
971 | 5384 int h = tabline_height(); |
671 | 5385 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5386 // Limit to 1000 windows, autocommands may add a window while we close |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5387 // one. OK, so I'm paranoid... |
671 | 5388 while (++done < 1000) |
5389 { | |
672 | 5390 wp = tp->tp_firstwin; |
5391 ex_win_close(forceit, wp, tp); | |
5392 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5393 // Autocommands may delete the tab page under our fingers and we may |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5394 // fail to close a window with a modified buffer. |
672 | 5395 if (!valid_tabpage(tp) || tp->tp_firstwin == wp) |
671 | 5396 break; |
5397 } | |
971 | 5398 |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9538
diff
changeset
|
5399 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
|
5400 |
672 | 5401 redraw_tabline = TRUE; |
971 | 5402 if (h != tabline_height()) |
5403 shell_new_rows(); | |
667 | 5404 } |
7 | 5405 |
5406 /* | |
5407 * ":only". | |
5408 */ | |
5409 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5410 ex_only(exarg_T *eap) |
7 | 5411 { |
6398 | 5412 win_T *wp; |
5413 int wnr; | |
7 | 5414 # ifdef FEAT_GUI |
5415 need_mouse_correct = TRUE; | |
5416 # endif | |
6398 | 5417 if (eap->addr_count > 0) |
5418 { | |
5419 wnr = eap->line2; | |
5420 for (wp = firstwin; --wnr > 0; ) | |
5421 { | |
5422 if (wp->w_next == NULL) | |
5423 break; | |
5424 else | |
5425 wp = wp->w_next; | |
5426 } | |
5427 win_goto(wp); | |
5428 } | |
7 | 5429 close_others(TRUE, eap->forceit); |
5430 } | |
5431 | |
5432 static void | |
10492
b2cd5a71f4bb
commit https://github.com/vim/vim/commit/5e1e6d265d26ee2952c4a018a5ff72c950d2d700
Christian Brabandt <cb@256bit.org>
parents:
10490
diff
changeset
|
5433 ex_hide(exarg_T *eap UNUSED) |
7 | 5434 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5435 // ":hide" or ":hide | cmd": hide current window |
10383
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5436 if (!eap->skip) |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5437 { |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5438 #ifdef FEAT_GUI |
10383
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5439 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
|
5440 #endif |
10383
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5441 if (eap->addr_count == 0) |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5442 win_close(curwin, FALSE); // don't free buffer |
10383
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5443 else |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5444 { |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5445 int winnr = 0; |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5446 win_T *win; |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5447 |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5448 FOR_ALL_WINDOWS(win) |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5449 { |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5450 winnr++; |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5451 if (winnr == eap->line2) |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5452 break; |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5453 } |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5454 if (win == NULL) |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5455 win = lastwin; |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5456 win_close(win, FALSE); |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5457 } |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5458 } |
7 | 5459 } |
5460 | |
5461 /* | |
5462 * ":stop" and ":suspend": Suspend Vim. | |
5463 */ | |
5464 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5465 ex_stop(exarg_T *eap) |
7 | 5466 { |
5467 /* | |
5468 * Disallow suspending for "rvim". | |
5469 */ | |
10264
c036c0f636d5
commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents:
10240
diff
changeset
|
5470 if (!check_restricted()) |
7 | 5471 { |
5472 if (!eap->forceit) | |
5473 autowrite_all(); | |
5474 windgoto((int)Rows - 1, 0); | |
5475 out_char('\n'); | |
5476 out_flush(); | |
5477 stoptermcap(); | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5478 out_flush(); // needed for SUN to restore xterm buffer |
7 | 5479 #ifdef FEAT_TITLE |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5480 mch_restore_title(SAVE_RESTORE_BOTH); // restore window titles |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5481 #endif |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5482 ui_suspend(); // call machine specific function |
7 | 5483 #ifdef FEAT_TITLE |
5484 maketitle(); | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5485 resettitle(); // force updating the title |
7 | 5486 #endif |
5487 starttermcap(); | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5488 scroll_start(); // scroll screen before redrawing |
7 | 5489 redraw_later_clear(); |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5490 shell_resized(); // may have resized window |
7 | 5491 } |
5492 } | |
5493 | |
5494 /* | |
13442
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5495 * ":exit", ":xit" and ":wq": Write file and quite the current window. |
7 | 5496 */ |
5497 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5498 ex_exit(exarg_T *eap) |
7 | 5499 { |
5500 #ifdef FEAT_CMDWIN | |
5501 if (cmdwin_type != 0) | |
5502 { | |
5503 cmdwin_result = Ctrl_C; | |
5504 return; | |
5505 } | |
5506 #endif | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5507 // Don't quit while editing the command line. |
633 | 5508 if (text_locked()) |
5509 { | |
5510 text_locked_msg(); | |
631 | 5511 return; |
5512 } | |
13442
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5513 |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5514 if (before_quit_autocmds(curwin, FALSE, eap->forceit)) |
819 | 5515 return; |
7 | 5516 |
5517 /* | |
5518 * if more files or windows we won't exit | |
5519 */ | |
5520 if (check_more(FALSE, eap->forceit) == OK && only_one_window()) | |
5521 exiting = TRUE; | |
5522 if ( ((eap->cmdidx == CMD_wq | |
5523 || curbufIsChanged()) | |
5524 && do_write(eap) == FAIL) | |
5525 || 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
|
5526 || (only_one_window() && check_changed_any(eap->forceit, FALSE))) |
7 | 5527 { |
5528 not_exiting(); | |
5529 } | |
5530 else | |
5531 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5532 if (only_one_window()) // quit last window, exit Vim |
7 | 5533 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
|
5534 not_exiting(); |
7 | 5535 # ifdef FEAT_GUI |
5536 need_mouse_correct = TRUE; | |
5537 # endif | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5538 // 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
|
5539 win_close(curwin, !buf_hide(curwin->w_buffer)); |
7 | 5540 } |
5541 } | |
5542 | |
5543 /* | |
5544 * ":print", ":list", ":number". | |
5545 */ | |
5546 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5547 ex_print(exarg_T *eap) |
7 | 5548 { |
167 | 5549 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
|
5550 emsg(_(e_emptybuf)); |
167 | 5551 else |
5552 { | |
5553 for ( ;!got_int; ui_breakcheck()) | |
5554 { | |
5555 print_line(eap->line1, | |
5556 (eap->cmdidx == CMD_number || eap->cmdidx == CMD_pound | |
5557 || (eap->flags & EXFLAG_NR)), | |
5558 eap->cmdidx == CMD_list || (eap->flags & EXFLAG_LIST)); | |
5559 if (++eap->line1 > eap->line2) | |
5560 break; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5561 out_flush(); // show one line at a time |
167 | 5562 } |
5563 setpcmark(); | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5564 // put cursor at last line |
167 | 5565 curwin->w_cursor.lnum = eap->line2; |
5566 beginline(BL_SOL | BL_FIX); | |
5567 } | |
7 | 5568 |
5569 ex_no_reprint = TRUE; | |
5570 } | |
5571 | |
5572 #ifdef FEAT_BYTEOFF | |
5573 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5574 ex_goto(exarg_T *eap) |
7 | 5575 { |
5576 goto_byte(eap->line2); | |
5577 } | |
5578 #endif | |
5579 | |
5580 /* | |
5581 * ":shell". | |
5582 */ | |
5583 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5584 ex_shell(exarg_T *eap UNUSED) |
7 | 5585 { |
5586 do_shell(NULL, 0); | |
5587 } | |
5588 | |
14428
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5589 #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
|
5590 |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5591 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
|
5592 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
|
5593 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
|
5594 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
|
5595 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
|
5596 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
|
5597 |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5598 static void |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5599 handle_drop_internal(void) |
7 | 5600 { |
5601 exarg_T ea; | |
5602 int save_msg_scroll = msg_scroll; | |
5603 | |
14428
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5604 // 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
|
5605 // 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
|
5606 drop_busy = TRUE; |
7 | 5607 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5608 // Check whether the current buffer is changed. If so, we will need |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5609 // to split the current window or data could be lost. |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5610 // We don't need to check if the 'hidden' option is set, as in this |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5611 // case the buffer won't be lost. |
14428
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5612 if (!buf_hide(curbuf) && !drop_split) |
7 | 5613 { |
5614 ++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
|
5615 drop_split = check_changed(curbuf, CCGD_AW); |
7 | 5616 --emsg_off; |
5617 } | |
14428
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5618 if (drop_split) |
7 | 5619 { |
5620 if (win_split(0, 0) == FAIL) | |
5621 return; | |
2583 | 5622 RESET_BINDING(curwin); |
7 | 5623 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5624 // When splitting the window, create a new alist. Otherwise the |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5625 // existing one is overwritten. |
7 | 5626 alist_unlink(curwin->w_alist); |
5627 alist_new(); | |
5628 } | |
5629 | |
5630 /* | |
5631 * Set up the new argument list. | |
5632 */ | |
14428
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5633 alist_set(ALIST(curwin), drop_filec, drop_filev, FALSE, NULL, 0); |
7 | 5634 |
5635 /* | |
5636 * Move to the first file. | |
5637 */ | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5638 // Fake up a minimal "next" command for do_argfile() |
20007
aadd1cae2ff5
patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
5639 CLEAR_FIELD(ea); |
7 | 5640 ea.cmd = (char_u *)"next"; |
5641 do_argfile(&ea, 0); | |
5642 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5643 // do_ecmd() may set need_start_insertmode, but since we never left Insert |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5644 // mode that is not needed here. |
7 | 5645 need_start_insertmode = FALSE; |
5646 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5647 // Restore msg_scroll, otherwise a following command may cause scrolling |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5648 // unexpectedly. The screen will be redrawn by the caller, thus |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5649 // msg_scroll being set by displaying a message is irrelevant. |
7 | 5650 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
|
5651 |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5652 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
|
5653 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
|
5654 |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5655 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
|
5656 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
|
5657 } |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5658 |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5659 /* |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5660 * 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
|
5661 * :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
|
5662 * 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
|
5663 * 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
|
5664 * 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
|
5665 * |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5666 * 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
|
5667 * 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
|
5668 * list. |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5669 */ |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5670 void |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5671 handle_drop( |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5672 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
|
5673 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
|
5674 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
|
5675 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
|
5676 // list |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5677 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
|
5678 { |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5679 // 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
|
5680 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
|
5681 { |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5682 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
|
5683 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
|
5684 return; |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5685 } |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5686 |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5687 // 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
|
5688 // one. |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5689 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
|
5690 { |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5691 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
|
5692 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
|
5693 } |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5694 |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5695 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
|
5696 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
|
5697 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
|
5698 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
|
5699 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
|
5700 |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5701 // 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
|
5702 // - 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
|
5703 // - 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
|
5704 // - 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
|
5705 // 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
|
5706 // 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
|
5707 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
|
5708 return; |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5709 |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5710 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
|
5711 } |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5712 |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5713 /* |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5714 * 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
|
5715 * 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
|
5716 */ |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5717 void |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5718 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
|
5719 { |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5720 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
|
5721 && !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
|
5722 handle_drop_internal(); |
7 | 5723 } |
5724 #endif | |
5725 | |
5726 /* | |
5727 * ":preserve". | |
5728 */ | |
5729 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5730 ex_preserve(exarg_T *eap UNUSED) |
7 | 5731 { |
164 | 5732 curbuf->b_flags |= BF_PRESERVED; |
7 | 5733 ml_preserve(curbuf, TRUE); |
5734 } | |
5735 | |
5736 /* | |
5737 * ":recover". | |
5738 */ | |
5739 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5740 ex_recover(exarg_T *eap) |
7 | 5741 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5742 // Set recoverymode right away to avoid the ATTENTION prompt. |
7 | 5743 recoverymode = TRUE; |
5464 | 5744 if (!check_changed(curbuf, (p_awa ? CCGD_AW : 0) |
5745 | CCGD_MULTWIN | |
5746 | (eap->forceit ? CCGD_FORCEIT : 0) | |
5747 | CCGD_EXCMD) | |
5748 | |
7 | 5749 && (*eap->arg == NUL |
5750 || 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
|
5751 ml_recover(TRUE); |
7 | 5752 recoverymode = FALSE; |
5753 } | |
5754 | |
5755 /* | |
5756 * Command modifier used in a wrong way. | |
5757 */ | |
5758 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5759 ex_wrongmodifier(exarg_T *eap) |
7 | 5760 { |
5761 eap->errmsg = e_invcmd; | |
5762 } | |
5763 | |
5764 /* | |
5765 * :sview [+command] file split window with new file, read-only | |
5766 * :split [[+command] file] split window with current or new file | |
5767 * :vsplit [[+command] file] split window vertically with current or new file | |
5768 * :new [[+command] file] split window with no or new file | |
5769 * :vnew [[+command] file] split vertically window with no or new file | |
5770 * :sfind [+command] file split window with file in 'path' | |
675 | 5771 * |
5772 * :tabedit open new Tab page with empty window | |
5773 * :tabedit [+command] file open new Tab page and edit "file" | |
5774 * :tabnew [[+command] file] just like :tabedit | |
5775 * :tabfind [+command] file open new Tab page and find "file" | |
7 | 5776 */ |
5777 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5778 ex_splitview(exarg_T *eap) |
7 | 5779 { |
675 | 5780 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
|
5781 #if defined(FEAT_SEARCHPATH) || defined(FEAT_BROWSE) |
7 | 5782 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
|
5783 #endif |
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5784 #ifdef FEAT_BROWSE |
7 | 5785 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
|
5786 #endif |
14155
da09e29e59d9
patch 8.1.0095: dialog for ":browse tabnew" says "new window"
Christian Brabandt <cb@256bit.org>
parents:
14059
diff
changeset
|
5787 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
|
5788 || 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
|
5789 || 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
|
5790 |
19271
ebeeb4b4a1fa
patch 8.2.0194: some commands can cause problems in terminal popup
Bram Moolenaar <Bram@vim.org>
parents:
19261
diff
changeset
|
5791 if (ERROR_IF_ANY_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
|
5792 return; |
da5f5836e90c
patch 8.1.1438: some commands cause trouble in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
5793 |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5794 #ifdef FEAT_GUI |
7 | 5795 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
|
5796 #endif |
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5797 |
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5798 #ifdef FEAT_QUICKFIX |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5799 // A ":split" in the quickfix window works like ":new". Don't want two |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5800 // quickfix windows. But it's OK when doing ":tab split". |
1661 | 5801 if (bt_quickfix(curbuf) && cmdmod.tab == 0) |
7 | 5802 { |
5803 if (eap->cmdidx == CMD_split) | |
5804 eap->cmdidx = CMD_new; | |
5805 if (eap->cmdidx == CMD_vsplit) | |
5806 eap->cmdidx = CMD_vnew; | |
667 | 5807 } |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5808 #endif |
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5809 |
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5810 #ifdef FEAT_SEARCHPATH |
675 | 5811 if (eap->cmdidx == CMD_sfind || eap->cmdidx == CMD_tabfind) |
7 | 5812 { |
5813 fname = find_file_in_path(eap->arg, (int)STRLEN(eap->arg), | |
5814 FNAME_MESS, TRUE, curbuf->b_ffname); | |
5815 if (fname == NULL) | |
5816 goto theend; | |
5817 eap->arg = fname; | |
5818 } | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5819 # ifdef FEAT_BROWSE |
7 | 5820 else |
5821 # endif | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5822 #endif |
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5823 #ifdef FEAT_BROWSE |
7 | 5824 if (cmdmod.browse |
5825 && eap->cmdidx != CMD_vnew | |
5826 && eap->cmdidx != CMD_new) | |
5827 { | |
461 | 5828 if ( |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
5829 # ifdef FEAT_GUI |
461 | 5830 !gui.in_use && |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
5831 # endif |
461 | 5832 au_has_group((char_u *)"FileExplorer")) |
5833 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5834 // No browsing supported but we do have the file explorer: |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5835 // Edit the directory. |
461 | 5836 if (*eap->arg == NUL || !mch_isdir(eap->arg)) |
5837 eap->arg = (char_u *)"."; | |
5838 } | |
5839 else | |
5840 { | |
14155
da09e29e59d9
patch 8.1.0095: dialog for ":browse tabnew" says "new window"
Christian Brabandt <cb@256bit.org>
parents:
14059
diff
changeset
|
5841 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
|
5842 ? _("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
|
5843 : _("Edit File in new window")), |
7 | 5844 eap->arg, NULL, NULL, NULL, curbuf); |
461 | 5845 if (fname == NULL) |
5846 goto theend; | |
5847 eap->arg = fname; | |
5848 } | |
7 | 5849 } |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5850 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
|
5851 #endif |
7 | 5852 |
675 | 5853 /* |
5854 * Either open new tab page or split the window. | |
5855 */ | |
14155
da09e29e59d9
patch 8.1.0095: dialog for ":browse tabnew" says "new window"
Christian Brabandt <cb@256bit.org>
parents:
14059
diff
changeset
|
5856 if (use_tab) |
675 | 5857 { |
820 | 5858 if (win_new_tabpage(cmdmod.tab != 0 ? cmdmod.tab |
5859 : eap->addr_count == 0 ? 0 | |
5860 : (int)eap->line2 + 1) != FAIL) | |
675 | 5861 { |
1498 | 5862 do_exedit(eap, old_curwin); |
675 | 5863 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5864 // set the alternate buffer for the window we came from |
675 | 5865 if (curwin != old_curwin |
5866 && win_valid(old_curwin) | |
5867 && old_curwin->w_buffer != curbuf | |
5868 && !cmdmod.keepalt) | |
5869 old_curwin->w_alt_fnum = curbuf->b_fnum; | |
5870 } | |
5871 } | |
5872 else if (win_split(eap->addr_count > 0 ? (int)eap->line2 : 0, | |
7 | 5873 *eap->cmd == 'v' ? WSP_VERT : 0) != FAIL) |
5874 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5875 // Reset 'scrollbind' when editing another file, but keep it when |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5876 // doing ":split" without arguments. |
7 | 5877 if (*eap->arg != NUL |
13384
6740c499de13
patch 8.0.1566: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13380
diff
changeset
|
5878 # ifdef FEAT_BROWSE |
7 | 5879 || cmdmod.browse |
13384
6740c499de13
patch 8.0.1566: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13380
diff
changeset
|
5880 # endif |
7 | 5881 ) |
2583 | 5882 RESET_BINDING(curwin); |
7 | 5883 else |
5884 do_check_scrollbind(FALSE); | |
5885 do_exedit(eap, old_curwin); | |
5886 } | |
5887 | |
667 | 5888 # ifdef FEAT_BROWSE |
7 | 5889 cmdmod.browse = browse_flag; |
667 | 5890 # endif |
5891 | |
5892 # if defined(FEAT_SEARCHPATH) || defined(FEAT_BROWSE) | |
7 | 5893 theend: |
5894 vim_free(fname); | |
667 | 5895 # endif |
5896 } | |
5897 | |
5898 /* | |
682 | 5899 * Open a new tab page. |
667 | 5900 */ |
5901 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5902 tabpage_new(void) |
682 | 5903 { |
5904 exarg_T ea; | |
5905 | |
20007
aadd1cae2ff5
patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
5906 CLEAR_FIELD(ea); |
682 | 5907 ea.cmdidx = CMD_tabnew; |
5908 ea.cmd = (char_u *)"tabn"; | |
5909 ea.arg = (char_u *)""; | |
5910 ex_splitview(&ea); | |
5911 } | |
5912 | |
5913 /* | |
5914 * :tabnext command | |
5915 */ | |
5916 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5917 ex_tabnext(exarg_T *eap) |
682 | 5918 { |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5919 int tab_number; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5920 |
17111
af861fccc309
patch 8.1.1555: NOT_IN_POPUP_WINDOW is confusing
Bram Moolenaar <Bram@vim.org>
parents:
17095
diff
changeset
|
5921 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
|
5922 return; |
685 | 5923 switch (eap->cmdidx) |
5924 { | |
5925 case CMD_tabfirst: | |
5926 case CMD_tabrewind: | |
5927 goto_tabpage(1); | |
5928 break; | |
5929 case CMD_tablast: | |
5930 goto_tabpage(9999); | |
5931 break; | |
5932 case CMD_tabprevious: | |
5933 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
|
5934 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
|
5935 { |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5936 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
|
5937 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
|
5938 |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5939 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
|
5940 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
|
5941 || tab_number == 0) |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5942 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5943 // No numbers as argument. |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5944 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
|
5945 return; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5946 } |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5947 } |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5948 else |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5949 { |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5950 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
|
5951 tab_number = 1; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5952 else |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5953 { |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5954 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
|
5955 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
|
5956 { |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5957 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
|
5958 return; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5959 } |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5960 } |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5961 } |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5962 goto_tabpage(-tab_number); |
685 | 5963 break; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5964 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
|
5965 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
|
5966 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
|
5967 goto_tabpage(tab_number); |
685 | 5968 break; |
5969 } | |
682 | 5970 } |
5971 | |
5972 /* | |
5973 * :tabmove command | |
5974 */ | |
5975 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5976 ex_tabmove(exarg_T *eap) |
682 | 5977 { |
6775 | 5978 int tab_number; |
3662 | 5979 |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5980 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
|
5981 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
|
5982 tabpage_move(tab_number); |
667 | 5983 } |
5984 | |
5985 /* | |
5986 * :tabs command: List tabs and their contents. | |
5987 */ | |
5988 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5989 ex_tabs(exarg_T *eap UNUSED) |
667 | 5990 { |
5991 tabpage_T *tp; | |
5992 win_T *wp; | |
5993 int tabcount = 1; | |
5994 | |
5995 msg_start(); | |
5996 msg_scroll = TRUE; | |
5997 for (tp = first_tabpage; tp != NULL && !got_int; tp = tp->tp_next) | |
5998 { | |
5999 msg_putchar('\n'); | |
6000 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
|
6001 msg_outtrans_attr(IObuff, HL_ATTR(HLF_T)); |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6002 out_flush(); // output one line at a time |
667 | 6003 ui_breakcheck(); |
6004 | |
678 | 6005 if (tp == curtab) |
667 | 6006 wp = firstwin; |
6007 else | |
6008 wp = tp->tp_firstwin; | |
6009 for ( ; wp != NULL && !got_int; wp = wp->w_next) | |
6010 { | |
682 | 6011 msg_putchar('\n'); |
6012 msg_putchar(wp == curwin ? '>' : ' '); | |
6013 msg_putchar(' '); | |
672 | 6014 msg_putchar(bufIsChanged(wp->w_buffer) ? '+' : ' '); |
6015 msg_putchar(' '); | |
667 | 6016 if (buf_spname(wp->w_buffer) != NULL) |
3839 | 6017 vim_strncpy(IObuff, buf_spname(wp->w_buffer), IOSIZE - 1); |
667 | 6018 else |
6019 home_replace(wp->w_buffer, wp->w_buffer->b_fname, | |
6020 IObuff, IOSIZE, TRUE); | |
6021 msg_outtrans(IObuff); | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6022 out_flush(); // output one line at a time |
667 | 6023 ui_breakcheck(); |
6024 } | |
6025 } | |
6026 } | |
6027 | |
7 | 6028 /* |
6029 * ":mode": Set screen mode. | |
6030 * If no argument given, just get the screen size and redraw. | |
6031 */ | |
6032 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6033 ex_mode(exarg_T *eap) |
7 | 6034 { |
6035 if (*eap->arg == NUL) | |
6036 shell_resized(); | |
6037 else | |
19131
1fe99999625c
patch 8.2.0125: :mode no longer works for any system
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
6038 emsg(_(e_screenmode)); |
7 | 6039 } |
6040 | |
6041 /* | |
6042 * ":resize". | |
6043 * set, increment or decrement current window height | |
6044 */ | |
6045 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6046 ex_resize(exarg_T *eap) |
7 | 6047 { |
6048 int n; | |
6049 win_T *wp = curwin; | |
6050 | |
6051 if (eap->addr_count > 0) | |
6052 { | |
6053 n = eap->line2; | |
6054 for (wp = firstwin; wp->w_next != NULL && --n > 0; wp = wp->w_next) | |
6055 ; | |
6056 } | |
6057 | |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8577
diff
changeset
|
6058 # ifdef FEAT_GUI |
7 | 6059 need_mouse_correct = TRUE; |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8577
diff
changeset
|
6060 # endif |
7 | 6061 n = atol((char *)eap->arg); |
6062 if (cmdmod.split & WSP_VERT) | |
6063 { | |
6064 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
|
6065 n += curwin->w_width; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6066 else if (n == 0 && eap->arg[0] == NUL) // default is very wide |
7 | 6067 n = 9999; |
6068 win_setwidth_win((int)n, wp); | |
6069 } | |
6070 else | |
6071 { | |
6072 if (*eap->arg == '-' || *eap->arg == '+') | |
6073 n += curwin->w_height; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6074 else if (n == 0 && eap->arg[0] == NUL) // default is very high |
7 | 6075 n = 9999; |
6076 win_setheight_win((int)n, wp); | |
6077 } | |
6078 } | |
6079 | |
6080 /* | |
6081 * ":find [+command] <file>" command. | |
6082 */ | |
6083 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6084 ex_find(exarg_T *eap) |
7 | 6085 { |
6086 #ifdef FEAT_SEARCHPATH | |
6087 char_u *fname; | |
6088 int count; | |
6089 | |
6090 fname = find_file_in_path(eap->arg, (int)STRLEN(eap->arg), FNAME_MESS, | |
6091 TRUE, curbuf->b_ffname); | |
6092 if (eap->addr_count > 0) | |
6093 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6094 // Repeat finding the file "count" times. This matters when it |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6095 // appears several times in the path. |
7 | 6096 count = eap->line2; |
6097 while (fname != NULL && --count > 0) | |
6098 { | |
6099 vim_free(fname); | |
6100 fname = find_file_in_path(NULL, 0, FNAME_MESS, | |
6101 FALSE, curbuf->b_ffname); | |
6102 } | |
6103 } | |
6104 | |
6105 if (fname != NULL) | |
6106 { | |
6107 eap->arg = fname; | |
6108 #endif | |
6109 do_exedit(eap, NULL); | |
6110 #ifdef FEAT_SEARCHPATH | |
6111 vim_free(fname); | |
6112 } | |
6113 #endif | |
6114 } | |
6115 | |
6116 /* | |
167 | 6117 * ":open" simulation: for now just work like ":visual". |
6118 */ | |
6119 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6120 ex_open(exarg_T *eap) |
167 | 6121 { |
6122 regmatch_T regmatch; | |
6123 char_u *p; | |
6124 | |
6125 curwin->w_cursor.lnum = eap->line2; | |
6126 beginline(BL_SOL | BL_FIX); | |
6127 if (*eap->arg == '/') | |
6128 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6129 // ":open /pattern/": put cursor in column found with pattern |
167 | 6130 ++eap->arg; |
19892
5feb426d2ea1
patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19685
diff
changeset
|
6131 p = skip_regexp(eap->arg, '/', p_magic); |
167 | 6132 *p = NUL; |
6133 regmatch.regprog = vim_regcomp(eap->arg, p_magic ? RE_MAGIC : 0); | |
6134 if (regmatch.regprog != NULL) | |
6135 { | |
6136 regmatch.rm_ic = p_ic; | |
6137 p = ml_get_curline(); | |
6138 if (vim_regexec(®match, p, (colnr_T)0)) | |
835 | 6139 curwin->w_cursor.col = (colnr_T)(regmatch.startp[0] - p); |
167 | 6140 else |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
6141 emsg(_(e_nomatch)); |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4803
diff
changeset
|
6142 vim_regfree(regmatch.regprog); |
167 | 6143 } |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6144 // Move to the NUL, ignore any other arguments. |
167 | 6145 eap->arg += STRLEN(eap->arg); |
6146 } | |
6147 check_cursor(); | |
6148 | |
6149 eap->cmdidx = CMD_visual; | |
6150 do_exedit(eap, NULL); | |
6151 } | |
6152 | |
6153 /* | |
6154 * ":edit", ":badd", ":visual". | |
7 | 6155 */ |
6156 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6157 ex_edit(exarg_T *eap) |
7 | 6158 { |
6159 do_exedit(eap, NULL); | |
6160 } | |
6161 | |
6162 /* | |
19195
2ef19eed524a
patch 8.2.0156: various typos in source files and tests
Bram Moolenaar <Bram@vim.org>
parents:
19191
diff
changeset
|
6163 * ":edit <file>" command and alike. |
7 | 6164 */ |
6165 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6166 do_exedit( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6167 exarg_T *eap, |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6168 win_T *old_curwin) // curwin before doing a split or NULL |
7 | 6169 { |
6170 int n; | |
6171 int need_hide; | |
167 | 6172 int exmode_was = exmode_active; |
7 | 6173 |
19271
ebeeb4b4a1fa
patch 8.2.0194: some commands can cause problems in terminal popup
Bram Moolenaar <Bram@vim.org>
parents:
19261
diff
changeset
|
6174 if ((eap->cmdidx != CMD_pedit && ERROR_IF_POPUP_WINDOW) |
ebeeb4b4a1fa
patch 8.2.0194: some commands can cause problems in terminal popup
Bram Moolenaar <Bram@vim.org>
parents:
19261
diff
changeset
|
6175 || ERROR_IF_TERM_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
|
6176 return; |
7 | 6177 /* |
6178 * ":vi" command ends Ex mode. | |
6179 */ | |
6180 if (exmode_active && (eap->cmdidx == CMD_visual | |
6181 || eap->cmdidx == CMD_view)) | |
6182 { | |
6183 exmode_active = FALSE; | |
6184 if (*eap->arg == NUL) | |
167 | 6185 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6186 // Special case: ":global/pat/visual\NLvi-commands" |
167 | 6187 if (global_busy) |
6188 { | |
6189 int rd = RedrawingDisabled; | |
6190 int nwr = no_wait_return; | |
6191 int ms = msg_scroll; | |
6192 #ifdef FEAT_GUI | |
6193 int he = hold_gui_events; | |
6194 #endif | |
6195 | |
6196 if (eap->nextcmd != NULL) | |
6197 { | |
6198 stuffReadbuff(eap->nextcmd); | |
6199 eap->nextcmd = NULL; | |
6200 } | |
6201 | |
6202 if (exmode_was != EXMODE_VIM) | |
6203 settmode(TMODE_RAW); | |
6204 RedrawingDisabled = 0; | |
6205 no_wait_return = 0; | |
6206 need_wait_return = FALSE; | |
6207 msg_scroll = 0; | |
6208 #ifdef FEAT_GUI | |
6209 hold_gui_events = 0; | |
6210 #endif | |
6211 must_redraw = CLEAR; | |
19433
af9d5585cfbf
patch 8.2.0274: hang with combination of feedkeys(), Ex mode and :global
Bram Moolenaar <Bram@vim.org>
parents:
19415
diff
changeset
|
6212 pending_exmode_active = TRUE; |
167 | 6213 |
6214 main_loop(FALSE, TRUE); | |
6215 | |
19433
af9d5585cfbf
patch 8.2.0274: hang with combination of feedkeys(), Ex mode and :global
Bram Moolenaar <Bram@vim.org>
parents:
19415
diff
changeset
|
6216 pending_exmode_active = FALSE; |
167 | 6217 RedrawingDisabled = rd; |
6218 no_wait_return = nwr; | |
6219 msg_scroll = ms; | |
6220 #ifdef FEAT_GUI | |
6221 hold_gui_events = he; | |
6222 #endif | |
6223 } | |
7 | 6224 return; |
167 | 6225 } |
7 | 6226 } |
6227 | |
6228 if ((eap->cmdidx == CMD_new | |
675 | 6229 || eap->cmdidx == CMD_tabnew |
6230 || 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
|
6231 || eap->cmdidx == CMD_vnew) && *eap->arg == NUL) |
7 | 6232 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6233 // ":new" or ":tabnew" without argument: edit an new empty buffer |
7 | 6234 setpcmark(); |
6235 (void)do_ecmd(0, NULL, NULL, eap, ECMD_ONE, | |
1743 | 6236 ECMD_HIDE + (eap->forceit ? ECMD_FORCEIT : 0), |
6237 old_curwin == NULL ? curwin : NULL); | |
7 | 6238 } |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
6239 else if ((eap->cmdidx != CMD_split && eap->cmdidx != CMD_vsplit) |
7 | 6240 || *eap->arg != NUL |
6241 #ifdef FEAT_BROWSE | |
6242 || cmdmod.browse | |
6243 #endif | |
6244 ) | |
6245 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6246 // Can't edit another file when "curbuf_lock" is set. Only ":edit" |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6247 // can bring us here, others are stopped earlier. |
822 | 6248 if (*eap->arg != NUL && curbuf_locked()) |
6249 return; | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
6250 |
7 | 6251 n = readonlymode; |
6252 if (eap->cmdidx == CMD_view || eap->cmdidx == CMD_sview) | |
6253 readonlymode = TRUE; | |
6254 else if (eap->cmdidx == CMD_enew) | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6255 readonlymode = FALSE; // 'readonly' doesn't make sense in an |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6256 // empty buffer |
7 | 6257 setpcmark(); |
6258 if (do_ecmd(0, (eap->cmdidx == CMD_enew ? NULL : eap->arg), | |
6259 NULL, eap, | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6260 // ":edit" goes to first line if Vi compatible |
7 | 6261 (*eap->arg == NUL && eap->do_ecmd_lnum == 0 |
6262 && vim_strchr(p_cpo, CPO_GOTO1) != NULL) | |
6263 ? 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
|
6264 (buf_hide(curbuf) ? ECMD_HIDE : 0) |
7 | 6265 + (eap->forceit ? ECMD_FORCEIT : 0) |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6266 // after a split we can use an existing buffer |
5741 | 6267 + (old_curwin != NULL ? ECMD_OLDBUF : 0) |
7 | 6268 + (eap->cmdidx == CMD_badd ? ECMD_ADDBUF : 0 ) |
1743 | 6269 , old_curwin == NULL ? curwin : NULL) == FAIL) |
7 | 6270 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6271 // Editing the file failed. If the window was split, close it. |
7 | 6272 if (old_curwin != NULL) |
6273 { | |
6274 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
|
6275 if (!need_hide || buf_hide(curbuf)) |
7 | 6276 { |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
6277 #if defined(FEAT_EVAL) |
24 | 6278 cleanup_T cs; |
6279 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6280 // Reset the error/interrupt/exception state here so that |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6281 // aborting() returns FALSE when closing a window. |
24 | 6282 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
|
6283 #endif |
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
6284 #ifdef FEAT_GUI |
7 | 6285 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
|
6286 #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
|
6287 win_close(curwin, !need_hide && !buf_hide(curbuf)); |
24 | 6288 |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
6289 #if defined(FEAT_EVAL) |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6290 // Restore the error/interrupt/exception state if not |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6291 // discarded by a new aborting error, interrupt, or |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6292 // uncaught exception. |
24 | 6293 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
|
6294 #endif |
7 | 6295 } |
6296 } | |
6297 } | |
6298 else if (readonlymode && curbuf->b_nwindows == 1) | |
6299 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6300 // When editing an already visited buffer, 'readonly' won't be set |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6301 // but the previous value is kept. With ":view" and ":sview" we |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6302 // want the file to be readonly, except when another window is |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6303 // editing the same buffer. |
7 | 6304 curbuf->b_p_ro = TRUE; |
6305 } | |
6306 readonlymode = n; | |
6307 } | |
6308 else | |
6309 { | |
6310 if (eap->do_ecmd_cmd != NULL) | |
6311 do_cmdline_cmd(eap->do_ecmd_cmd); | |
6312 #ifdef FEAT_TITLE | |
6313 n = curwin->w_arg_idx_invalid; | |
6314 #endif | |
6315 check_arg_idx(curwin); | |
6316 #ifdef FEAT_TITLE | |
6317 if (n != curwin->w_arg_idx_invalid) | |
6318 maketitle(); | |
6319 #endif | |
6320 } | |
6321 | |
6322 /* | |
6323 * if ":split file" worked, set alternate file name in old window to new | |
6324 * file | |
6325 */ | |
6326 if (old_curwin != NULL | |
6327 && *eap->arg != NUL | |
6328 && curwin != old_curwin | |
6329 && win_valid(old_curwin) | |
22 | 6330 && old_curwin->w_buffer != curbuf |
6331 && !cmdmod.keepalt) | |
7 | 6332 old_curwin->w_alt_fnum = curbuf->b_fnum; |
6333 | |
6334 ex_no_reprint = TRUE; | |
6335 } | |
6336 | |
6337 #ifndef FEAT_GUI | |
6338 /* | |
6339 * ":gui" and ":gvim" when there is no GUI. | |
6340 */ | |
6341 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6342 ex_nogui(exarg_T *eap) |
7 | 6343 { |
6344 eap->errmsg = e_nogvim; | |
6345 } | |
6346 #endif | |
6347 | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15866
diff
changeset
|
6348 #if defined(FEAT_GUI_MSWIN) && defined(FEAT_MENU) && defined(FEAT_TEAROFF) |
7 | 6349 static void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6350 ex_tearoff(exarg_T *eap) |
7 | 6351 { |
6352 gui_make_tearoff(eap->arg); | |
6353 } | |
6354 #endif | |
6355 | |
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
|
6356 #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
|
6357 || defined(FEAT_TERM_POPUP_MENU)) && defined(FEAT_MENU) |
7 | 6358 static void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6359 ex_popup(exarg_T *eap) |
7 | 6360 { |
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
|
6361 # 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
|
6362 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
|
6363 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
|
6364 # 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
|
6365 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
|
6366 # 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
|
6367 # 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
|
6368 # 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
|
6369 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
|
6370 # endif |
7 | 6371 } |
6372 #endif | |
6373 | |
6374 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6375 ex_swapname(exarg_T *eap UNUSED) |
7 | 6376 { |
6377 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
|
6378 msg(_("No swap file")); |
7 | 6379 else |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15510
diff
changeset
|
6380 msg((char *)curbuf->b_ml.ml_mfp->mf_fname); |
7 | 6381 } |
6382 | |
6383 /* | |
6384 * ":syncbind" forces all 'scrollbind' windows to have the same relative | |
6385 * offset. | |
6386 * (1998-11-02 16:21:01 R. Edward Ralston <eralston@computer.org>) | |
6387 */ | |
6388 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6389 ex_syncbind(exarg_T *eap UNUSED) |
7 | 6390 { |
6391 win_T *wp; | |
5566 | 6392 win_T *save_curwin = curwin; |
6393 buf_T *save_curbuf = curbuf; | |
7 | 6394 long topline; |
6395 long y; | |
6396 linenr_T old_linenr = curwin->w_cursor.lnum; | |
6397 | |
6398 setpcmark(); | |
6399 | |
6400 /* | |
6401 * determine max topline | |
6402 */ | |
6403 if (curwin->w_p_scb) | |
6404 { | |
6405 topline = curwin->w_topline; | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9538
diff
changeset
|
6406 FOR_ALL_WINDOWS(wp) |
7 | 6407 { |
6408 if (wp->w_p_scb && wp->w_buffer) | |
6409 { | |
15713
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15663
diff
changeset
|
6410 y = wp->w_buffer->b_ml.ml_line_count - get_scrolloff_value(); |
7 | 6411 if (topline > y) |
6412 topline = y; | |
6413 } | |
6414 } | |
6415 if (topline < 1) | |
6416 topline = 1; | |
6417 } | |
6418 else | |
6419 { | |
6420 topline = 1; | |
6421 } | |
6422 | |
6423 | |
6424 /* | |
5566 | 6425 * Set all scrollbind windows to the same topline. |
7 | 6426 */ |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9538
diff
changeset
|
6427 FOR_ALL_WINDOWS(curwin) |
7 | 6428 { |
6429 if (curwin->w_p_scb) | |
6430 { | |
5566 | 6431 curbuf = curwin->w_buffer; |
7 | 6432 y = topline - curwin->w_topline; |
6433 if (y > 0) | |
6434 scrollup(y, TRUE); | |
6435 else | |
6436 scrolldown(-y, TRUE); | |
6437 curwin->w_scbind_pos = topline; | |
6438 redraw_later(VALID); | |
6439 cursor_correct(); | |
6440 curwin->w_redr_status = TRUE; | |
6441 } | |
6442 } | |
5566 | 6443 curwin = save_curwin; |
6444 curbuf = save_curbuf; | |
7 | 6445 if (curwin->w_p_scb) |
6446 { | |
6447 did_syncbind = TRUE; | |
6448 checkpcmark(); | |
6449 if (old_linenr != curwin->w_cursor.lnum) | |
6450 { | |
6451 char_u ctrl_o[2]; | |
6452 | |
6453 ctrl_o[0] = Ctrl_O; | |
6454 ctrl_o[1] = 0; | |
6455 ins_typebuf(ctrl_o, REMAP_NONE, 0, TRUE, FALSE); | |
6456 } | |
6457 } | |
6458 } | |
6459 | |
6460 | |
6461 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6462 ex_read(exarg_T *eap) |
7 | 6463 { |
167 | 6464 int i; |
6465 int empty = (curbuf->b_ml.ml_flags & ML_EMPTY); | |
6466 linenr_T lnum; | |
7 | 6467 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6468 if (eap->usefilter) // :r!cmd |
7 | 6469 do_bang(1, eap, FALSE, FALSE, TRUE); |
6470 else | |
6471 { | |
6472 if (u_save(eap->line2, (linenr_T)(eap->line2 + 1)) == FAIL) | |
6473 return; | |
6474 | |
6475 #ifdef FEAT_BROWSE | |
6476 if (cmdmod.browse) | |
6477 { | |
6478 char_u *browseFile; | |
6479 | |
28 | 6480 browseFile = do_browse(0, (char_u *)_("Append File"), eap->arg, |
7 | 6481 NULL, NULL, NULL, curbuf); |
6482 if (browseFile != NULL) | |
6483 { | |
6484 i = readfile(browseFile, NULL, | |
6485 eap->line2, (linenr_T)0, (linenr_T)MAXLNUM, eap, 0); | |
6486 vim_free(browseFile); | |
6487 } | |
6488 else | |
6489 i = OK; | |
6490 } | |
6491 else | |
6492 #endif | |
6493 if (*eap->arg == NUL) | |
6494 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6495 if (check_fname() == FAIL) // check for no file name |
7 | 6496 return; |
6497 i = readfile(curbuf->b_ffname, curbuf->b_fname, | |
6498 eap->line2, (linenr_T)0, (linenr_T)MAXLNUM, eap, 0); | |
6499 } | |
6500 else | |
6501 { | |
6502 if (vim_strchr(p_cpo, CPO_ALTREAD) != NULL) | |
6503 (void)setaltfname(eap->arg, eap->arg, (linenr_T)1); | |
6504 i = readfile(eap->arg, NULL, | |
6505 eap->line2, (linenr_T)0, (linenr_T)MAXLNUM, eap, 0); | |
6506 | |
6507 } | |
10575
01a5f64a7a20
patch 8.0.0177: BufEnter autocommand not fired for a directory
Christian Brabandt <cb@256bit.org>
parents:
10520
diff
changeset
|
6508 if (i != OK) |
7 | 6509 { |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
6510 #if defined(FEAT_EVAL) |
7 | 6511 if (!aborting()) |
6512 #endif | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
6513 semsg(_(e_notopen), eap->arg); |
7 | 6514 } |
6515 else | |
167 | 6516 { |
6517 if (empty && exmode_active) | |
6518 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6519 // Delete the empty line that remains. Historically ex does |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6520 // this but vi doesn't. |
167 | 6521 if (eap->line2 == 0) |
6522 lnum = curbuf->b_ml.ml_line_count; | |
6523 else | |
6524 lnum = 1; | |
573 | 6525 if (*ml_get(lnum) == NUL && u_savedel(lnum, 1L) == OK) |
167 | 6526 { |
6527 ml_delete(lnum, FALSE); | |
573 | 6528 if (curwin->w_cursor.lnum > 1 |
6529 && curwin->w_cursor.lnum >= lnum) | |
167 | 6530 --curwin->w_cursor.lnum; |
1929 | 6531 deleted_lines_mark(lnum, 1L); |
167 | 6532 } |
6533 } | |
7 | 6534 redraw_curbuf_later(VALID); |
167 | 6535 } |
7 | 6536 } |
6537 } | |
6538 | |
358 | 6539 static char_u *prev_dir = NULL; |
6540 | |
6541 #if defined(EXITFREE) || defined(PROTO) | |
6542 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6543 free_cd_dir(void) |
358 | 6544 { |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13221
diff
changeset
|
6545 VIM_CLEAR(prev_dir); |
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13221
diff
changeset
|
6546 VIM_CLEAR(globaldir); |
358 | 6547 } |
6548 #endif | |
6549 | |
4704
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
6550 /* |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
6551 * 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
|
6552 * 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
|
6553 * 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
|
6554 */ |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
6555 void |
16576
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6556 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
|
6557 { |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6558 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
|
6559 // 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
|
6560 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
|
6561 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
|
6562 if (scope != CDSCOPE_GLOBAL) |
4704
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
6563 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6564 // If still in global directory, need to remember current |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6565 // directory as global directory. |
4704
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
6566 if (globaldir == NULL && prev_dir != NULL) |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
6567 globaldir = vim_strsave(prev_dir); |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6568 // Remember this local directory for the window. |
4704
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
6569 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
|
6570 { |
16576
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6571 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
|
6572 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
|
6573 else |
8c3a1bd270bb
patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents:
16411
diff
changeset
|
6574 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
|
6575 } |
4704
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
6576 } |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
6577 else |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
6578 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6579 // We are now in the global directory, no need to remember its |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6580 // name. |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13221
diff
changeset
|
6581 VIM_CLEAR(globaldir); |
4704
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
6582 } |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
6583 |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
6584 shorten_fnames(TRUE); |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
6585 } |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
6586 |
16576
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6587 /* |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6588 * 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
|
6589 * 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
|
6590 * 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
|
6591 * 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
|
6592 * 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
|
6593 */ |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6594 int |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6595 changedir_func( |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6596 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
|
6597 int forceit, |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6598 cdscope_T scope) |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6599 { |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6600 char_u *tofree; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6601 int dir_differs; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6602 int retval = FALSE; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6603 |
19261
a20c66f13a6e
patch 8.2.0189: cd() with NULL argument crashes
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
6604 if (new_dir == NULL || allbuf_locked()) |
16576
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6605 return FALSE; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6606 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6607 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
|
6608 { |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6609 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
|
6610 return FALSE; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6611 } |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6612 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6613 // ":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
|
6614 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
|
6615 { |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6616 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
|
6617 { |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6618 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
|
6619 return FALSE; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6620 } |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6621 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
|
6622 } |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6623 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6624 // 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
|
6625 tofree = prev_dir; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6626 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
|
6627 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
|
6628 else |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6629 prev_dir = NULL; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6630 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6631 #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
|
6632 // 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
|
6633 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
|
6634 { |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6635 // 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
|
6636 # ifdef VMS |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6637 char_u *p; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6638 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6639 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
|
6640 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
|
6641 NameBuff[0] = NUL; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6642 else |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6643 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
|
6644 # else |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6645 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
|
6646 # endif |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6647 new_dir = NameBuff; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6648 } |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6649 #endif |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6650 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
|
6651 || 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
|
6652 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
|
6653 emsg(_(e_failed)); |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6654 else |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6655 { |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6656 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
|
6657 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6658 post_chdir(scope); |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6659 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6660 if (dir_differs) |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6661 { |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6662 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
|
6663 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
|
6664 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
|
6665 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
|
6666 else |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6667 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
|
6668 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
|
6669 curbuf); |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6670 } |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6671 retval = TRUE; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6672 } |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6673 vim_free(tofree); |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6674 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6675 return retval; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6676 } |
358 | 6677 |
7 | 6678 /* |
16427
8c3a1bd270bb
patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents:
16411
diff
changeset
|
6679 * ":cd", ":tcd", ":lcd", ":chdir" ":tchdir" and ":lchdir". |
7 | 6680 */ |
1411 | 6681 void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6682 ex_cd(exarg_T *eap) |
7 | 6683 { |
15184
90ab2d3ce11d
patch 8.1.0602: DirChanged is also triggered when directory didn't change
Bram Moolenaar <Bram@vim.org>
parents:
15152
diff
changeset
|
6684 char_u *new_dir; |
7 | 6685 |
6686 new_dir = eap->arg; | |
6687 #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
|
6688 // for non-UNIX ":cd" means: print current directory |
7 | 6689 if (*new_dir == NUL) |
6690 ex_pwd(NULL); | |
6691 else | |
6692 #endif | |
6693 { | |
16576
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6694 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
|
6695 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6696 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
|
6697 scope = CDSCOPE_WINDOW; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6698 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
|
6699 scope = CDSCOPE_TABPAGE; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6700 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6701 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
|
6702 { |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6703 // Echo the new current directory if the command was typed. |
1930 | 6704 if (KeyTyped || p_verbose >= 5) |
7 | 6705 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
|
6706 } |
7 | 6707 } |
6708 } | |
6709 | |
6710 /* | |
6711 * ":pwd". | |
6712 */ | |
6713 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6714 ex_pwd(exarg_T *eap UNUSED) |
7 | 6715 { |
6716 if (mch_dirname(NameBuff, MAXPATHL) == OK) | |
6717 { | |
6718 #ifdef BACKSLASH_IN_FILENAME | |
6719 slash_adjust(NameBuff); | |
6720 #endif | |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15510
diff
changeset
|
6721 msg((char *)NameBuff); |
7 | 6722 } |
6723 else | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
6724 emsg(_("E187: Unknown")); |
7 | 6725 } |
6726 | |
6727 /* | |
6728 * ":=". | |
6729 */ | |
6730 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6731 ex_equal(exarg_T *eap) |
7 | 6732 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
6733 smsg("%ld", (long)eap->line2); |
167 | 6734 ex_may_print(eap); |
7 | 6735 } |
6736 | |
6737 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6738 ex_sleep(exarg_T *eap) |
7 | 6739 { |
236 | 6740 int n; |
6741 long len; | |
7 | 6742 |
6743 if (cursor_valid()) | |
6744 { | |
6745 n = W_WINROW(curwin) + curwin->w_wrow - msg_scrolled; | |
6746 if (n >= 0) | |
12513
3ca08bf99396
patch 8.0.1135: W_WINCOL() is always the same
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
6747 windgoto((int)n, curwin->w_wincol + curwin->w_wcol); |
7 | 6748 } |
236 | 6749 |
6750 len = eap->line2; | |
6751 switch (*eap->arg) | |
6752 { | |
6753 case 'm': break; | |
6754 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
|
6755 default: semsg(_(e_invarg2), eap->arg); return; |
236 | 6756 } |
6757 do_sleep(len); | |
7 | 6758 } |
6759 | |
6760 /* | |
6761 * Sleep for "msec" milliseconds, but keep checking for a CTRL-C every second. | |
6762 */ | |
6763 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6764 do_sleep(long msec) |
7 | 6765 { |
17712
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
6766 long done = 0; |
8577
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
6767 long wait_now; |
17712
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
6768 # ifdef ELAPSED_FUNC |
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
6769 elapsed_T start_tv; |
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
6770 |
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
6771 // 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
|
6772 // 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
|
6773 ELAPSED_INIT(start_tv); |
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
6774 # endif |
7 | 6775 |
6776 cursor_on(); | |
14860
ac5d0d27aef9
patch 8.1.0442: GUI: cursor not drawn after ":redraw | sleep"
Christian Brabandt <cb@256bit.org>
parents:
14760
diff
changeset
|
6777 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
|
6778 while (!got_int && done < msec) |
8577
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
6779 { |
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
6780 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
|
6781 #ifdef FEAT_TIMERS |
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
6782 { |
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
6783 long due_time = check_due_timer(); |
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
6784 |
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
6785 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
|
6786 wait_now = due_time; |
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
6787 } |
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
6788 #endif |
10240
175b1116f96a
commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents:
10184
diff
changeset
|
6789 #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
|
6790 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
|
6791 wait_now = 20L; |
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17652
diff
changeset
|
6792 #endif |
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17652
diff
changeset
|
6793 #ifdef FEAT_SOUND |
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17652
diff
changeset
|
6794 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
|
6795 wait_now = 20L; |
10240
175b1116f96a
commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents:
10184
diff
changeset
|
6796 #endif |
8577
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
6797 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
|
6798 |
10240
175b1116f96a
commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents:
10184
diff
changeset
|
6799 #ifdef FEAT_JOB_CHANNEL |
175b1116f96a
commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents:
10184
diff
changeset
|
6800 if (has_any_channel()) |
175b1116f96a
commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents:
10184
diff
changeset
|
6801 ui_breakcheck_force(TRUE); |
175b1116f96a
commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents:
10184
diff
changeset
|
6802 else |
175b1116f96a
commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents:
10184
diff
changeset
|
6803 #endif |
175b1116f96a
commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents:
10184
diff
changeset
|
6804 ui_breakcheck(); |
7109
fa95595fbc52
commit https://github.com/vim/vim/commit/93c88e0f6a4a8f7634ed84721daf4af46fc0d5db
Christian Brabandt <cb@256bit.org>
parents:
7105
diff
changeset
|
6805 #ifdef MESSAGE_QUEUE |
17712
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
6806 // 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
|
6807 // 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
|
6808 // 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
|
6809 parse_queued_messages(); |
3151 | 6810 #endif |
17712
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
6811 |
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
6812 # ifdef ELAPSED_FUNC |
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
6813 // actual time passed |
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
6814 done = ELAPSED_FUNC(start_tv); |
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
6815 # else |
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
6816 // 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
|
6817 done += wait_now; |
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
6818 # endif |
7 | 6819 } |
14284
7cd8298c4c04
patch 8.1.0158: GUI: input() fails if CTRL-C was pressed before
Christian Brabandt <cb@256bit.org>
parents:
14266
diff
changeset
|
6820 |
7cd8298c4c04
patch 8.1.0158: GUI: input() fails if CTRL-C was pressed before
Christian Brabandt <cb@256bit.org>
parents:
14266
diff
changeset
|
6821 // 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
|
6822 // 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
|
6823 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
|
6824 (void)vpeekc(); |
7 | 6825 } |
6826 | |
6827 /* | |
6828 * ":winsize" command (obsolete). | |
6829 */ | |
6830 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6831 ex_winsize(exarg_T *eap) |
7 | 6832 { |
6833 int w, h; | |
6834 char_u *arg = eap->arg; | |
6835 char_u *p; | |
6836 | |
6837 w = getdigits(&arg); | |
6838 arg = skipwhite(arg); | |
6839 p = arg; | |
6840 h = getdigits(&arg); | |
6841 if (*p != NUL && *arg == NUL) | |
6842 set_shellsize(w, h, TRUE); | |
6843 else | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
6844 emsg(_("E465: :winsize requires two number arguments")); |
7 | 6845 } |
6846 | |
6847 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6848 ex_wincmd(exarg_T *eap) |
7 | 6849 { |
6850 int xchar = NUL; | |
6851 char_u *p; | |
6852 | |
6853 if (*eap->arg == 'g' || *eap->arg == Ctrl_G) | |
6854 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6855 // CTRL-W g and CTRL-W CTRL-G have an extra command character |
7 | 6856 if (eap->arg[1] == NUL) |
6857 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
6858 emsg(_(e_invarg)); |
7 | 6859 return; |
6860 } | |
6861 xchar = eap->arg[1]; | |
6862 p = eap->arg + 2; | |
6863 } | |
6864 else | |
6865 p = eap->arg + 1; | |
6866 | |
6867 eap->nextcmd = check_nextcmd(p); | |
6868 p = skipwhite(p); | |
6869 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
|
6870 emsg(_(e_invarg)); |
2887 | 6871 else if (!eap->skip) |
7 | 6872 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6873 // Pass flags on for ":vertical wincmd ]". |
7 | 6874 postponed_split_flags = cmdmod.split; |
1090 | 6875 postponed_split_tab = cmdmod.tab; |
7 | 6876 do_window(*eap->arg, eap->addr_count > 0 ? eap->line2 : 0L, xchar); |
6877 postponed_split_flags = 0; | |
1090 | 6878 postponed_split_tab = 0; |
7 | 6879 } |
6880 } | |
6881 | |
11 | 6882 #if defined(FEAT_GUI) || defined(UNIX) || defined(VMS) || defined(MSWIN) |
7 | 6883 /* |
6884 * ":winpos". | |
6885 */ | |
6886 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6887 ex_winpos(exarg_T *eap) |
7 | 6888 { |
6889 int x, y; | |
6890 char_u *arg = eap->arg; | |
6891 char_u *p; | |
6892 | |
6893 if (*arg == NUL) | |
6894 { | |
11 | 6895 # 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
|
6896 # 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
|
6897 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
|
6898 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
|
6899 # elif defined(FEAT_GUI) |
7 | 6900 if (gui.in_use && gui_mch_get_winpos(&x, &y) != FAIL) |
11 | 6901 # else |
6902 if (mch_get_winpos(&x, &y) != FAIL) | |
6903 # endif | |
7 | 6904 { |
6905 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
|
6906 msg((char *)IObuff); |
7 | 6907 } |
6908 else | |
6909 # endif | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
6910 emsg(_("E188: Obtaining window position not implemented for this platform")); |
7 | 6911 } |
6912 else | |
6913 { | |
6914 x = getdigits(&arg); | |
6915 arg = skipwhite(arg); | |
6916 p = arg; | |
6917 y = getdigits(&arg); | |
6918 if (*p == NUL || *arg != NUL) | |
6919 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
6920 emsg(_("E466: :winpos requires two number arguments")); |
7 | 6921 return; |
6922 } | |
6923 # ifdef FEAT_GUI | |
6924 if (gui.in_use) | |
6925 gui_mch_set_winpos(x, y); | |
6926 else if (gui.starting) | |
6927 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6928 // Remember the coordinates for when the window is opened. |
7 | 6929 gui_win_x = x; |
6930 gui_win_y = y; | |
6931 } | |
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
|
6932 # if defined(HAVE_TGETENT) || defined(VIMDLL) |
7 | 6933 else |
6934 # 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
|
6935 # 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
|
6936 # if defined(MSWIN) && (!defined(FEAT_GUI) || defined(VIMDLL)) |
11 | 6937 mch_set_winpos(x, y); |
7 | 6938 # endif |
6939 # ifdef HAVE_TGETENT | |
6940 if (*T_CWP) | |
6941 term_set_winpos(x, y); | |
6942 # endif | |
6943 } | |
6944 } | |
6945 #endif | |
6946 | |
6947 /* | |
6948 * Handle command that work like operators: ":delete", ":yank", ":>" and ":<". | |
6949 */ | |
6950 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6951 ex_operators(exarg_T *eap) |
7 | 6952 { |
6953 oparg_T oa; | |
6954 | |
6955 clear_oparg(&oa); | |
6956 oa.regname = eap->regname; | |
6957 oa.start.lnum = eap->line1; | |
6958 oa.end.lnum = eap->line2; | |
6959 oa.line_count = eap->line2 - eap->line1 + 1; | |
6960 oa.motion_type = MLINE; | |
6961 virtual_op = FALSE; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6962 if (eap->cmdidx != CMD_yank) // position cursor for undo |
7 | 6963 { |
6964 setpcmark(); | |
6965 curwin->w_cursor.lnum = eap->line1; | |
6966 beginline(BL_SOL | BL_FIX); | |
6967 } | |
6968 | |
5498 | 6969 if (VIsual_active) |
6970 end_visual_mode(); | |
6971 | |
7 | 6972 switch (eap->cmdidx) |
6973 { | |
6974 case CMD_delete: | |
6975 oa.op_type = OP_DELETE; | |
6976 op_delete(&oa); | |
6977 break; | |
6978 | |
6979 case CMD_yank: | |
6980 oa.op_type = OP_YANK; | |
6981 (void)op_yank(&oa, FALSE, TRUE); | |
6982 break; | |
6983 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6984 default: // CMD_rshift or CMD_lshift |
4889
25d64a4edc0b
updated for version 7.3.1190
Bram Moolenaar <bram@vim.org>
parents:
4857
diff
changeset
|
6985 if ( |
7 | 6986 #ifdef FEAT_RIGHTLEFT |
4889
25d64a4edc0b
updated for version 7.3.1190
Bram Moolenaar <bram@vim.org>
parents:
4857
diff
changeset
|
6987 (eap->cmdidx == CMD_rshift) ^ curwin->w_p_rl |
25d64a4edc0b
updated for version 7.3.1190
Bram Moolenaar <bram@vim.org>
parents:
4857
diff
changeset
|
6988 #else |
25d64a4edc0b
updated for version 7.3.1190
Bram Moolenaar <bram@vim.org>
parents:
4857
diff
changeset
|
6989 eap->cmdidx == CMD_rshift |
25d64a4edc0b
updated for version 7.3.1190
Bram Moolenaar <bram@vim.org>
parents:
4857
diff
changeset
|
6990 #endif |
25d64a4edc0b
updated for version 7.3.1190
Bram Moolenaar <bram@vim.org>
parents:
4857
diff
changeset
|
6991 ) |
7 | 6992 oa.op_type = OP_RSHIFT; |
6993 else | |
6994 oa.op_type = OP_LSHIFT; | |
6995 op_shift(&oa, FALSE, eap->amount); | |
6996 break; | |
6997 } | |
6998 virtual_op = MAYBE; | |
167 | 6999 ex_may_print(eap); |
7 | 7000 } |
7001 | |
7002 /* | |
7003 * ":put". | |
7004 */ | |
7005 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7006 ex_put(exarg_T *eap) |
7 | 7007 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7008 // ":0put" works like ":1put!". |
7 | 7009 if (eap->line2 == 0) |
7010 { | |
7011 eap->line2 = 1; | |
7012 eap->forceit = TRUE; | |
7013 } | |
7014 curwin->w_cursor.lnum = eap->line2; | |
167 | 7015 do_put(eap->regname, eap->forceit ? BACKWARD : FORWARD, 1L, |
7016 PUT_LINE|PUT_CURSLINE); | |
7 | 7017 } |
7018 | |
7019 /* | |
7020 * Handle ":copy" and ":move". | |
7021 */ | |
7022 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7023 ex_copymove(exarg_T *eap) |
7 | 7024 { |
7025 long n; | |
7026 | |
14760
fd69edd2c67e
patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents:
14700
diff
changeset
|
7027 n = get_address(eap, &eap->arg, eap->addr_type, FALSE, FALSE, FALSE, 1); |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7028 if (eap->arg == NULL) // error detected |
7 | 7029 { |
7030 eap->nextcmd = NULL; | |
7031 return; | |
7032 } | |
167 | 7033 get_flags(eap); |
7 | 7034 |
7035 /* | |
7036 * move or copy lines from 'eap->line1'-'eap->line2' to below line 'n' | |
7037 */ | |
7038 if (n == MAXLNUM || n < 0 || n > curbuf->b_ml.ml_line_count) | |
7039 { | |
17650
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
7040 emsg(_(e_invrange)); |
7 | 7041 return; |
7042 } | |
7043 | |
7044 if (eap->cmdidx == CMD_move) | |
7045 { | |
7046 if (do_move(eap->line1, eap->line2, n) == FAIL) | |
7047 return; | |
7048 } | |
7049 else | |
7050 ex_copy(eap->line1, eap->line2, n); | |
7051 u_clearline(); | |
7052 beginline(BL_SOL | BL_FIX); | |
167 | 7053 ex_may_print(eap); |
7054 } | |
7055 | |
7056 /* | |
7057 * Print the current line if flags were given to the Ex command. | |
7058 */ | |
5776 | 7059 void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7060 ex_may_print(exarg_T *eap) |
167 | 7061 { |
7062 if (eap->flags != 0) | |
7063 { | |
7064 print_line(curwin->w_cursor.lnum, (eap->flags & EXFLAG_NR), | |
7065 (eap->flags & EXFLAG_LIST)); | |
7066 ex_no_reprint = TRUE; | |
7067 } | |
7 | 7068 } |
7069 | |
7070 /* | |
7071 * ":smagic" and ":snomagic". | |
7072 */ | |
7073 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7074 ex_submagic(exarg_T *eap) |
7 | 7075 { |
7076 int magic_save = p_magic; | |
7077 | |
7078 p_magic = (eap->cmdidx == CMD_smagic); | |
7079 do_sub(eap); | |
7080 p_magic = magic_save; | |
7081 } | |
7082 | |
7083 /* | |
7084 * ":join". | |
7085 */ | |
7086 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7087 ex_join(exarg_T *eap) |
7 | 7088 { |
7089 curwin->w_cursor.lnum = eap->line1; | |
7090 if (eap->line1 == eap->line2) | |
7091 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7092 if (eap->addr_count >= 2) // :2,2join does nothing |
7 | 7093 return; |
7094 if (eap->line2 == curbuf->b_ml.ml_line_count) | |
7095 { | |
7096 beep_flush(); | |
7097 return; | |
7098 } | |
7099 ++eap->line2; | |
7100 } | |
5848 | 7101 (void)do_join(eap->line2 - eap->line1 + 1, !eap->forceit, TRUE, TRUE, TRUE); |
7 | 7102 beginline(BL_WHITE | BL_FIX); |
167 | 7103 ex_may_print(eap); |
7 | 7104 } |
7105 | |
7106 /* | |
7107 * ":[addr]@r" or ":[addr]*r": execute register | |
7108 */ | |
7109 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7110 ex_at(exarg_T *eap) |
7 | 7111 { |
7112 int c; | |
1973 | 7113 int prev_len = typebuf.tb_len; |
7 | 7114 |
7115 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
|
7116 check_cursor_col(); |
7 | 7117 |
7118 #ifdef USE_ON_FLY_SCROLL | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7119 dont_scroll = TRUE; // disallow scrolling here |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7120 #endif |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7121 |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7122 // get the register name. No name means to use the previous one |
7 | 7123 c = *eap->arg; |
7124 if (c == NUL || (c == '*' && *eap->cmd == '*')) | |
7125 c = '@'; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7126 // Put the register in the typeahead buffer with the "silent" flag. |
1034 | 7127 if (do_execreg(c, TRUE, vim_strchr(p_cpo, CPO_EXECBUF) != NULL, TRUE) |
7128 == FAIL) | |
167 | 7129 { |
7 | 7130 beep_flush(); |
167 | 7131 } |
7 | 7132 else |
7133 { | |
7134 int save_efr = exec_from_reg; | |
7135 | |
7136 exec_from_reg = TRUE; | |
7137 | |
7138 /* | |
7139 * Execute from the typeahead buffer. | |
1973 | 7140 * Continue until the stuff buffer is empty and all added characters |
7141 * have been consumed. | |
7 | 7142 */ |
1973 | 7143 while (!stuff_empty() || typebuf.tb_len > prev_len) |
7 | 7144 (void)do_cmdline(NULL, getexline, NULL, DOCMD_NOWAIT|DOCMD_VERBOSE); |
7145 | |
7146 exec_from_reg = save_efr; | |
7147 } | |
7148 } | |
7149 | |
7150 /* | |
7151 * ":!". | |
7152 */ | |
7153 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7154 ex_bang(exarg_T *eap) |
7 | 7155 { |
7156 do_bang(eap->addr_count, eap, eap->forceit, TRUE, TRUE); | |
7157 } | |
7158 | |
7159 /* | |
7160 * ":undo". | |
7161 */ | |
7162 static void | |
8368
db2a07b710ed
commit https://github.com/vim/vim/commit/f1d2501ebe33e148886c2914acd33140e20ee222
Christian Brabandt <cb@256bit.org>
parents:
8281
diff
changeset
|
7163 ex_undo(exarg_T *eap) |
7 | 7164 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7165 if (eap->addr_count == 1) // :undo 123 |
2281
e41433ea71df
Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents:
2276
diff
changeset
|
7166 undo_time(eap->line2, FALSE, FALSE, TRUE); |
771 | 7167 else |
7168 u_undo(1); | |
7 | 7169 } |
7170 | |
2214
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
7171 #ifdef FEAT_PERSISTENT_UNDO |
2340
99c1eba60b2d
Make automatic prototype generation work with more interfaces.
Bram Moolenaar <bram@vim.org>
parents:
2333
diff
changeset
|
7172 static void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7173 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
|
7174 { |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
7175 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
|
7176 |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
7177 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
|
7178 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
|
7179 } |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
7180 |
2340
99c1eba60b2d
Make automatic prototype generation work with more interfaces.
Bram Moolenaar <bram@vim.org>
parents:
2333
diff
changeset
|
7181 static void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7182 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
|
7183 { |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
7184 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
|
7185 |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
7186 u_compute_hash(hash); |
2238
3d0a7beb0d75
Made reading/writing undo info a bit more robust.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
7187 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
|
7188 } |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
7189 #endif |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
7190 |
7 | 7191 /* |
7192 * ":redo". | |
7193 */ | |
7194 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7195 ex_redo(exarg_T *eap UNUSED) |
7 | 7196 { |
7197 u_redo(1); | |
7198 } | |
7199 | |
7200 /* | |
756 | 7201 * ":earlier" and ":later". |
7202 */ | |
7203 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7204 ex_later(exarg_T *eap) |
756 | 7205 { |
7206 long count = 0; | |
7207 int sec = FALSE; | |
2281
e41433ea71df
Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents:
2276
diff
changeset
|
7208 int file = FALSE; |
756 | 7209 char_u *p = eap->arg; |
7210 | |
7211 if (*p == NUL) | |
7212 count = 1; | |
7213 else if (isdigit(*p)) | |
7214 { | |
7215 count = getdigits(&p); | |
7216 switch (*p) | |
7217 { | |
7218 case 's': ++p; sec = TRUE; break; | |
7219 case 'm': ++p; sec = TRUE; count *= 60; break; | |
7220 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
|
7221 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
|
7222 case 'f': ++p; file = TRUE; break; |
756 | 7223 } |
7224 } | |
7225 | |
7226 if (*p != NUL) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7227 semsg(_(e_invarg2), eap->arg); |
756 | 7228 else |
2281
e41433ea71df
Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents:
2276
diff
changeset
|
7229 undo_time(eap->cmdidx == CMD_earlier ? -count : count, |
e41433ea71df
Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents:
2276
diff
changeset
|
7230 sec, file, FALSE); |
756 | 7231 } |
7232 | |
7233 /* | |
7 | 7234 * ":redir": start/stop redirection. |
7235 */ | |
7236 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7237 ex_redir(exarg_T *eap) |
7 | 7238 { |
7239 char *mode; | |
7240 char_u *fname; | |
122 | 7241 char_u *arg = eap->arg; |
7 | 7242 |
9440
73c0d07cc15e
commit https://github.com/vim/vim/commit/ba768495c2e6bae74e49d22d489fbf211ecad55e
Christian Brabandt <cb@256bit.org>
parents:
9438
diff
changeset
|
7243 #ifdef FEAT_EVAL |
9454
9da0cb39cbee
commit https://github.com/vim/vim/commit/79815f1ec77406f2f21a618c053e5793b597db7a
Christian Brabandt <cb@256bit.org>
parents:
9440
diff
changeset
|
7244 if (redir_execute) |
9da0cb39cbee
commit https://github.com/vim/vim/commit/79815f1ec77406f2f21a618c053e5793b597db7a
Christian Brabandt <cb@256bit.org>
parents:
9440
diff
changeset
|
7245 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7246 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
|
7247 return; |
7897b1e4f3e7
commit https://github.com/vim/vim/commit/245a7cb6d33e556415c9fcaa874b784a6d8f0ef3
Christian Brabandt <cb@256bit.org>
parents:
9432
diff
changeset
|
7248 } |
9440
73c0d07cc15e
commit https://github.com/vim/vim/commit/ba768495c2e6bae74e49d22d489fbf211ecad55e
Christian Brabandt <cb@256bit.org>
parents:
9438
diff
changeset
|
7249 #endif |
9438
7897b1e4f3e7
commit https://github.com/vim/vim/commit/245a7cb6d33e556415c9fcaa874b784a6d8f0ef3
Christian Brabandt <cb@256bit.org>
parents:
9432
diff
changeset
|
7250 |
7 | 7251 if (STRICMP(eap->arg, "END") == 0) |
7252 close_redir(); | |
7253 else | |
7254 { | |
122 | 7255 if (*arg == '>') |
7256 { | |
7257 ++arg; | |
7258 if (*arg == '>') | |
7259 { | |
7260 ++arg; | |
7 | 7261 mode = "a"; |
7262 } | |
7263 else | |
7264 mode = "w"; | |
122 | 7265 arg = skipwhite(arg); |
7 | 7266 |
7267 close_redir(); | |
7268 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7269 // Expand environment variables and "~/". |
122 | 7270 fname = expand_env_save(arg); |
7 | 7271 if (fname == NULL) |
7272 return; | |
7273 #ifdef FEAT_BROWSE | |
7274 if (cmdmod.browse) | |
7275 { | |
7276 char_u *browseFile; | |
7277 | |
28 | 7278 browseFile = do_browse(BROWSE_SAVE, |
7279 (char_u *)_("Save Redirection"), | |
13802
378f9f8e6d8f
patch 8.0.1773: dialog messages are not translated
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
7280 fname, NULL, NULL, |
378f9f8e6d8f
patch 8.0.1773: dialog messages are not translated
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
7281 (char_u *)_(BROWSE_FILTER_ALL_FILES), curbuf); |
7 | 7282 if (browseFile == NULL) |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7283 return; // operation cancelled |
7 | 7284 vim_free(fname); |
7285 fname = browseFile; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7286 eap->forceit = TRUE; // since dialog already asked |
7 | 7287 } |
7288 #endif | |
7289 | |
7290 redir_fd = open_exfile(fname, eap->forceit, mode); | |
7291 vim_free(fname); | |
7292 } | |
7293 #ifdef FEAT_EVAL | |
122 | 7294 else if (*arg == '@') |
7 | 7295 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7296 // redirect to a register a-z (resp. A-Z for appending) |
7 | 7297 close_redir(); |
122 | 7298 ++arg; |
7299 if (ASCII_ISALPHA(*arg) | |
7 | 7300 # ifdef FEAT_CLIPBOARD |
122 | 7301 || *arg == '*' |
1038 | 7302 || *arg == '+' |
7 | 7303 # endif |
122 | 7304 || *arg == '"') |
7305 { | |
7306 redir_reg = *arg++; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7307 if (*arg == '>' && arg[1] == '>') // append |
268 | 7308 arg += 2; |
1427 | 7309 else |
7 | 7310 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7311 // Can use both "@a" and "@a>". |
296 | 7312 if (*arg == '>') |
7313 arg++; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7314 // Make register empty when not using @A-@Z and the |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7315 // command is valid. |
1427 | 7316 if (*arg == NUL && !isupper(redir_reg)) |
7317 write_reg_contents(redir_reg, (char_u *)"", -1, FALSE); | |
7 | 7318 } |
167 | 7319 } |
7320 if (*arg != NUL) | |
7321 { | |
268 | 7322 redir_reg = 0; |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7323 semsg(_(e_invarg2), eap->arg); |
167 | 7324 } |
7325 } | |
7326 else if (*arg == '=' && arg[1] == '>') | |
7327 { | |
7328 int append; | |
7329 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7330 // redirect to a variable |
167 | 7331 close_redir(); |
7332 arg += 2; | |
7333 | |
7334 if (*arg == '>') | |
7335 { | |
7336 ++arg; | |
7337 append = TRUE; | |
7 | 7338 } |
7339 else | |
167 | 7340 append = FALSE; |
7341 | |
7342 if (var_redir_start(skipwhite(arg), append) == OK) | |
7343 redir_vname = 1; | |
7 | 7344 } |
7345 #endif | |
7346 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7347 // TODO: redirect to a buffer |
7 | 7348 |
7349 else | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7350 semsg(_(e_invarg2), eap->arg); |
7 | 7351 } |
972 | 7352 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7353 // Make sure redirection is not off. Can happen for cmdline completion |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7354 // that indirectly invokes a command to catch its output. |
972 | 7355 if (redir_fd != NULL |
7356 #ifdef FEAT_EVAL | |
7357 || redir_reg || redir_vname | |
7358 #endif | |
7359 ) | |
7360 redir_off = FALSE; | |
7 | 7361 } |
7362 | |
7363 /* | |
7364 * ":redraw": force redraw | |
7365 */ | |
7864
6b0891de44a9
commit https://github.com/vim/vim/commit/fb1f62691eae7c79a28b3b17a60e72ce198c71a2
Christian Brabandt <cb@256bit.org>
parents:
7850
diff
changeset
|
7366 void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7367 ex_redraw(exarg_T *eap) |
7 | 7368 { |
7369 int r = RedrawingDisabled; | |
7370 int p = p_lz; | |
7371 | |
7372 RedrawingDisabled = 0; | |
7373 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
|
7374 validate_cursor(); |
7 | 7375 update_topline(); |
5735 | 7376 update_screen(eap->forceit ? CLEAR : VIsual_active ? INVERTED : 0); |
7 | 7377 #ifdef FEAT_TITLE |
7378 if (need_maketitle) | |
7379 maketitle(); | |
7380 #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
|
7381 #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
|
7382 # 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
|
7383 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
|
7384 # 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
|
7385 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
|
7386 #endif |
7 | 7387 RedrawingDisabled = r; |
7388 p_lz = p; | |
7389 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7390 // Reset msg_didout, so that a message that's there is overwritten. |
7 | 7391 msg_didout = FALSE; |
7392 msg_col = 0; | |
7393 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7394 // No need to wait after an intentional redraw. |
5198
1b89e3f916c5
updated for version 7.4a.025
Bram Moolenaar <bram@vim.org>
parents:
4928
diff
changeset
|
7395 need_wait_return = FALSE; |
1b89e3f916c5
updated for version 7.4a.025
Bram Moolenaar <bram@vim.org>
parents:
4928
diff
changeset
|
7396 |
7 | 7397 out_flush(); |
7398 } | |
7399 | |
7400 /* | |
7401 * ":redrawstatus": force redraw of status line(s) | |
7402 */ | |
7403 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7404 ex_redrawstatus(exarg_T *eap UNUSED) |
7 | 7405 { |
7406 int r = RedrawingDisabled; | |
7407 int p = p_lz; | |
7408 | |
7409 RedrawingDisabled = 0; | |
7410 p_lz = FALSE; | |
7411 if (eap->forceit) | |
7412 status_redraw_all(); | |
7413 else | |
7414 status_redraw_curbuf(); | |
5735 | 7415 update_screen(VIsual_active ? INVERTED : 0); |
7 | 7416 RedrawingDisabled = r; |
7417 p_lz = p; | |
7418 out_flush(); | |
7419 } | |
7420 | |
15396
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7421 /* |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7422 * ":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
|
7423 */ |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7424 static void |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7425 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
|
7426 { |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7427 int r = RedrawingDisabled; |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7428 int p = p_lz; |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7429 |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7430 RedrawingDisabled = 0; |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7431 p_lz = FALSE; |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7432 |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7433 draw_tabline(); |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7434 |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7435 RedrawingDisabled = r; |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7436 p_lz = p; |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7437 out_flush(); |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7438 } |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7439 |
7 | 7440 static void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7441 close_redir(void) |
7 | 7442 { |
7443 if (redir_fd != NULL) | |
7444 { | |
7445 fclose(redir_fd); | |
7446 redir_fd = NULL; | |
7447 } | |
7448 #ifdef FEAT_EVAL | |
7449 redir_reg = 0; | |
167 | 7450 if (redir_vname) |
7451 { | |
7452 var_redir_stop(); | |
7453 redir_vname = 0; | |
7454 } | |
7 | 7455 #endif |
7456 } | |
7457 | |
17539
554240b9574b
patch 8.1.1767: FEAT_SESSION defined separately
Bram Moolenaar <Bram@vim.org>
parents:
17536
diff
changeset
|
7458 #if (defined(FEAT_SESSION) || defined(FEAT_EVAL)) || defined(PROTO) |
167 | 7459 int |
18139
59bc3cd42cf5
patch 8.1.2064: MS-Windows: compiler warnings for unused arguments
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
7460 vim_mkdir_emsg(char_u *name, int prot UNUSED) |
167 | 7461 { |
7462 if (vim_mkdir(name, prot) != 0) | |
7463 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7464 semsg(_("E739: Cannot create directory: %s"), name); |
167 | 7465 return FAIL; |
7466 } | |
7467 return OK; | |
7468 } | |
7469 #endif | |
7470 | |
7 | 7471 /* |
7472 * Open a file for writing for an Ex command, with some checks. | |
7473 * Return file descriptor, or NULL on failure. | |
7474 */ | |
7475 FILE * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7476 open_exfile( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7477 char_u *fname, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7478 int forceit, |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7479 char *mode) // "w" for create new file or "a" for append |
7 | 7480 { |
7481 FILE *fd; | |
7482 | |
7483 #ifdef UNIX | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7484 // with Unix it is possible to open a directory |
7 | 7485 if (mch_isdir(fname)) |
7486 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7487 semsg(_(e_isadir2), fname); |
7 | 7488 return NULL; |
7489 } | |
7490 #endif | |
7491 if (!forceit && *mode != 'a' && vim_fexists(fname)) | |
7492 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7493 semsg(_("E189: \"%s\" exists (add ! to override)"), fname); |
7 | 7494 return NULL; |
7495 } | |
7496 | |
7497 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
|
7498 semsg(_("E190: Cannot open \"%s\" for writing"), fname); |
7 | 7499 |
7500 return fd; | |
7501 } | |
7502 | |
7503 /* | |
7504 * ":mark" and ":k". | |
7505 */ | |
7506 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7507 ex_mark(exarg_T *eap) |
7 | 7508 { |
7509 pos_T pos; | |
7510 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7511 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
|
7512 emsg(_(e_argreq)); |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7513 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
|
7514 emsg(_(e_trailing)); |
7 | 7515 else |
7516 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7517 pos = curwin->w_cursor; // save curwin->w_cursor |
7 | 7518 curwin->w_cursor.lnum = eap->line2; |
7519 beginline(BL_WHITE | BL_FIX); | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7520 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
|
7521 emsg(_("E191: Argument must be a letter or forward/backward quote")); |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7522 curwin->w_cursor = pos; // restore curwin->w_cursor |
7 | 7523 } |
7524 } | |
7525 | |
7526 /* | |
7527 * Update w_topline, w_leftcol and the cursor position. | |
7528 */ | |
7529 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7530 update_topline_cursor(void) |
7 | 7531 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7532 check_cursor(); // put cursor on valid line |
7 | 7533 update_topline(); |
7534 if (!curwin->w_p_wrap) | |
7535 validate_cursor(); | |
7536 update_curswant(); | |
7537 } | |
7538 | |
7539 /* | |
12521
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7540 * 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
|
7541 * 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
|
7542 */ |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7543 int |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7544 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
|
7545 { |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7546 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
|
7547 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
|
7548 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
|
7549 sst->save_State = State; |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7550 sst->save_insertmode = p_im; |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7551 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
|
7552 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
|
7553 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
|
7554 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7555 msg_scroll = FALSE; // no msg scrolling in Normal mode |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7556 restart_edit = 0; // don't go to Insert mode |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7557 p_im = FALSE; // don't use 'insertmode' |
12521
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7558 |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7559 /* |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7560 * 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
|
7561 * 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
|
7562 * ends with half a command. |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7563 */ |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7564 save_typeahead(&sst->tabuf); |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7565 return sst->tabuf.typebuf_valid; |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7566 } |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7567 |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7568 void |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7569 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
|
7570 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7571 // Restore the previous typeahead. |
12521
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7572 restore_typeahead(&sst->tabuf); |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7573 |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7574 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
|
7575 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
|
7576 p_im = sst->save_insertmode; |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7577 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
|
7578 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
|
7579 reg_executing = sst->save_reg_executing; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7580 msg_didout |= sst->save_msg_didout; // don't reset msg_didout now |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7581 |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7582 // Restore the state (needed when called from a function executed for |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7583 // 'indentexpr'). Update the mouse and cursor, they may have changed. |
12521
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7584 State = sst->save_State; |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7585 #ifdef CURSOR_SHAPE |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7586 ui_cursor_shape(); // may show different cursor shape |
12521
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7587 #endif |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7588 } |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7589 |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7590 /* |
7 | 7591 * ":normal[!] {commands}": Execute normal mode commands. |
7592 */ | |
7840
28f569c7dab9
commit https://github.com/vim/vim/commit/20fb9f346497daca4d19402fdfa5de7958642477
Christian Brabandt <cb@256bit.org>
parents:
7819
diff
changeset
|
7593 void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7594 ex_normal(exarg_T *eap) |
7 | 7595 { |
12521
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7596 save_state_T save_state; |
7 | 7597 char_u *arg = NULL; |
7598 int l; | |
7599 char_u *p; | |
7600 | |
856 | 7601 if (ex_normal_lock > 0) |
7602 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7603 emsg(_(e_secure)); |
856 | 7604 return; |
7605 } | |
7 | 7606 if (ex_normal_busy >= p_mmd) |
7607 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7608 emsg(_("E192: Recursive use of :normal too deep")); |
7 | 7609 return; |
7610 } | |
7611 | |
7612 /* | |
7613 * vgetc() expects a CSI and K_SPECIAL to have been escaped. Don't do | |
7614 * this for the K_SPECIAL leading byte, otherwise special keys will not | |
7615 * work. | |
7616 */ | |
7617 if (has_mbyte) | |
7618 { | |
7619 int len = 0; | |
7620 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7621 // Count the number of characters to be escaped. |
7 | 7622 for (p = eap->arg; *p != NUL; ++p) |
7623 { | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
7624 #ifdef FEAT_GUI |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7625 if (*p == CSI) // leadbyte CSI |
7 | 7626 len += 2; |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
7627 #endif |
474 | 7628 for (l = (*mb_ptr2len)(p) - 1; l > 0; --l) |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7629 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
|
7630 #ifdef FEAT_GUI |
7 | 7631 || *p == CSI |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
7632 #endif |
7 | 7633 ) |
7634 len += 2; | |
7635 } | |
7636 if (len > 0) | |
7637 { | |
16764
ef00b6bc186b
patch 8.1.1384: using "int" for alloc() often results in compiler warnings
Bram Moolenaar <Bram@vim.org>
parents:
16738
diff
changeset
|
7638 arg = alloc(STRLEN(eap->arg) + len + 1); |
7 | 7639 if (arg != NULL) |
7640 { | |
7641 len = 0; | |
7642 for (p = eap->arg; *p != NUL; ++p) | |
7643 { | |
7644 arg[len++] = *p; | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
7645 #ifdef FEAT_GUI |
7 | 7646 if (*p == CSI) |
7647 { | |
7648 arg[len++] = KS_EXTRA; | |
7649 arg[len++] = (int)KE_CSI; | |
7650 } | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
7651 #endif |
474 | 7652 for (l = (*mb_ptr2len)(p) - 1; l > 0; --l) |
7 | 7653 { |
7654 arg[len++] = *++p; | |
7655 if (*p == K_SPECIAL) | |
7656 { | |
7657 arg[len++] = KS_SPECIAL; | |
7658 arg[len++] = KE_FILLER; | |
7659 } | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
7660 #ifdef FEAT_GUI |
7 | 7661 else if (*p == CSI) |
7662 { | |
7663 arg[len++] = KS_EXTRA; | |
7664 arg[len++] = (int)KE_CSI; | |
7665 } | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
7666 #endif |
7 | 7667 } |
7668 arg[len] = NUL; | |
7669 } | |
7670 } | |
7671 } | |
7672 } | |
7673 | |
12521
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7674 ++ex_normal_busy; |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7675 if (save_current_state(&save_state)) |
7 | 7676 { |
7677 /* | |
7678 * Repeat the :normal command for each line in the range. When no | |
7679 * range given, execute it just once, without positioning the cursor | |
7680 * first. | |
7681 */ | |
7682 do | |
7683 { | |
7684 if (eap->addr_count != 0) | |
7685 { | |
7686 curwin->w_cursor.lnum = eap->line1++; | |
7687 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
|
7688 check_cursor_moved(curwin); |
7 | 7689 } |
7690 | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
7691 exec_normal_cmd(arg != NULL |
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
7692 ? arg |
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
7693 : eap->arg, eap->forceit ? REMAP_NONE : REMAP_YES, FALSE); |
7 | 7694 } |
7695 while (eap->addr_count > 0 && eap->line1 <= eap->line2 && !got_int); | |
7696 } | |
7697 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7698 // Might not return to the main loop when in an event handler. |
7 | 7699 update_topline_cursor(); |
7700 | |
12521
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7701 restore_current_state(&save_state); |
7 | 7702 --ex_normal_busy; |
6322 | 7703 setmouse(); |
7704 #ifdef CURSOR_SHAPE | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7705 ui_cursor_shape(); // may show different cursor shape |
6322 | 7706 #endif |
7707 | |
7 | 7708 vim_free(arg); |
7709 } | |
7710 | |
7711 /* | |
598 | 7712 * ":startinsert", ":startreplace" and ":startgreplace" |
7 | 7713 */ |
7714 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7715 ex_startinsert(exarg_T *eap) |
7 | 7716 { |
98 | 7717 if (eap->forceit) |
7718 { | |
17984
2ea47dee7ddd
patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
7719 // 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
|
7720 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
|
7721 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
|
7722 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
|
7723 } |
2ea47dee7ddd
patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
7724 |
2ea47dee7ddd
patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
7725 // 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
|
7726 // expression register that invokes a function can do this. |
89 | 7727 if (State & INSERT) |
7728 return; | |
7729 | |
598 | 7730 if (eap->cmdidx == CMD_startinsert) |
7731 restart_edit = 'a'; | |
7732 else if (eap->cmdidx == CMD_startreplace) | |
7733 restart_edit = 'R'; | |
7 | 7734 else |
598 | 7735 restart_edit = 'V'; |
7736 | |
7737 if (!eap->forceit) | |
7 | 7738 { |
14 | 7739 if (eap->cmdidx == CMD_startinsert) |
7740 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
|
7741 curwin->w_curswant = 0; // avoid MAXCOL |
7 | 7742 } |
7743 } | |
7744 | |
7745 /* | |
7746 * ":stopinsert" | |
7747 */ | |
7748 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7749 ex_stopinsert(exarg_T *eap UNUSED) |
7 | 7750 { |
7751 restart_edit = 0; | |
7752 stop_insert_mode = TRUE; | |
8817
b7eb7bbd71d0
commit https://github.com/vim/vim/commit/fd773e9e88add7d1ffef890fb9f3a00d613b4326
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
7753 clearmode(); |
7 | 7754 } |
7850
10f17a228661
commit https://github.com/vim/vim/commit/e2c3810c2ae290bbc2cba18eb47cc2d44e4b9797
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
7755 |
36 | 7756 /* |
7757 * Execute normal mode command "cmd". | |
7758 * "remap" can be REMAP_NONE or REMAP_YES. | |
7759 */ | |
7760 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7761 exec_normal_cmd(char_u *cmd, int remap, int silent) |
36 | 7762 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7763 // Stuff the argument into the typeahead buffer. |
7703
39251e981d1f
commit https://github.com/vim/vim/commit/25281634cda03ce302aaf9f906a9520b5f81f91e
Christian Brabandt <cb@256bit.org>
parents:
7549
diff
changeset
|
7764 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
|
7765 exec_normal(FALSE, FALSE, FALSE); |
7703
39251e981d1f
commit https://github.com/vim/vim/commit/25281634cda03ce302aaf9f906a9520b5f81f91e
Christian Brabandt <cb@256bit.org>
parents:
7549
diff
changeset
|
7766 } |
7850
10f17a228661
commit https://github.com/vim/vim/commit/e2c3810c2ae290bbc2cba18eb47cc2d44e4b9797
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
7767 |
7703
39251e981d1f
commit https://github.com/vim/vim/commit/25281634cda03ce302aaf9f906a9520b5f81f91e
Christian Brabandt <cb@256bit.org>
parents:
7549
diff
changeset
|
7768 /* |
39251e981d1f
commit https://github.com/vim/vim/commit/25281634cda03ce302aaf9f906a9520b5f81f91e
Christian Brabandt <cb@256bit.org>
parents:
7549
diff
changeset
|
7769 * 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
|
7770 * 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
|
7771 */ |
39251e981d1f
commit https://github.com/vim/vim/commit/25281634cda03ce302aaf9f906a9520b5f81f91e
Christian Brabandt <cb@256bit.org>
parents:
7549
diff
changeset
|
7772 void |
14871
f20df682c8af
patch 8.1.0447: GUI scrollbar test fails with Athena and Motif
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
7773 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
|
7774 { |
36 | 7775 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
|
7776 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
|
7777 |
d3377393e3d9
patch 8.1.1136: decoding of mouse click escape sequence is not tested
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
7778 // 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
|
7779 // is nothing to get, so also check for Ctrl_C. |
36 | 7780 clear_oparg(&oa); |
7781 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
|
7782 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
|
7783 || ((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
|
7784 || (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
|
7785 && !got_int) |
36 | 7786 { |
7787 update_topline_cursor(); | |
13829
044337cbf854
patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents:
13802
diff
changeset
|
7788 #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
|
7789 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
|
7790 && 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
|
7791 && !VIsual_active) |
044337cbf854
patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents:
13802
diff
changeset
|
7792 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7793 // If terminal_loop() returns OK we got a key that is handled |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7794 // in Normal model. With FAIL we first need to position the |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7795 // cursor and the screen needs to be redrawn. |
13829
044337cbf854
patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents:
13802
diff
changeset
|
7796 if (terminal_loop(TRUE) == OK) |
044337cbf854
patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents:
13802
diff
changeset
|
7797 normal_cmd(&oa, TRUE); |
044337cbf854
patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents:
13802
diff
changeset
|
7798 } |
044337cbf854
patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents:
13802
diff
changeset
|
7799 else |
044337cbf854
patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents:
13802
diff
changeset
|
7800 #endif |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7801 // execute a Normal mode cmd |
13829
044337cbf854
patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents:
13802
diff
changeset
|
7802 normal_cmd(&oa, TRUE); |
36 | 7803 } |
7804 } | |
7805 | |
7 | 7806 #ifdef FEAT_FIND_ID |
7807 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7808 ex_checkpath(exarg_T *eap) |
7 | 7809 { |
7810 find_pattern_in_path(NULL, 0, 0, FALSE, FALSE, CHECK_PATH, 1L, | |
7811 eap->forceit ? ACTION_SHOW_ALL : ACTION_SHOW, | |
7812 (linenr_T)1, (linenr_T)MAXLNUM); | |
7813 } | |
7814 | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
7815 #if defined(FEAT_QUICKFIX) |
7 | 7816 /* |
7817 * ":psearch" | |
7818 */ | |
7819 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7820 ex_psearch(exarg_T *eap) |
7 | 7821 { |
7822 g_do_tagpreview = p_pvh; | |
7823 ex_findpat(eap); | |
7824 g_do_tagpreview = 0; | |
7825 } | |
7826 #endif | |
7827 | |
7828 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7829 ex_findpat(exarg_T *eap) |
7 | 7830 { |
7831 int whole = TRUE; | |
7832 long n; | |
7833 char_u *p; | |
7834 int action; | |
7835 | |
7836 switch (cmdnames[eap->cmdidx].cmd_name[2]) | |
7837 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7838 case 'e': // ":psearch", ":isearch" and ":dsearch" |
7 | 7839 if (cmdnames[eap->cmdidx].cmd_name[0] == 'p') |
7840 action = ACTION_GOTO; | |
7841 else | |
7842 action = ACTION_SHOW; | |
7843 break; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7844 case 'i': // ":ilist" and ":dlist" |
7 | 7845 action = ACTION_SHOW_ALL; |
7846 break; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7847 case 'u': // ":ijump" and ":djump" |
7 | 7848 action = ACTION_GOTO; |
7849 break; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7850 default: // ":isplit" and ":dsplit" |
7 | 7851 action = ACTION_SPLIT; |
7852 break; | |
7853 } | |
7854 | |
7855 n = 1; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7856 if (vim_isdigit(*eap->arg)) // get count |
7 | 7857 { |
7858 n = getdigits(&eap->arg); | |
7859 eap->arg = skipwhite(eap->arg); | |
7860 } | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7861 if (*eap->arg == '/') // Match regexp, not just whole words |
7 | 7862 { |
7863 whole = FALSE; | |
7864 ++eap->arg; | |
19892
5feb426d2ea1
patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19685
diff
changeset
|
7865 p = skip_regexp(eap->arg, '/', p_magic); |
7 | 7866 if (*p) |
7867 { | |
7868 *p++ = NUL; | |
7869 p = skipwhite(p); | |
7870 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7871 // Check for trailing illegal characters |
7 | 7872 if (!ends_excmd(*p)) |
7873 eap->errmsg = e_trailing; | |
7874 else | |
7875 eap->nextcmd = check_nextcmd(p); | |
7876 } | |
7877 } | |
7878 if (!eap->skip) | |
7879 find_pattern_in_path(eap->arg, 0, (int)STRLEN(eap->arg), | |
7880 whole, !eap->forceit, | |
7881 *eap->cmd == 'd' ? FIND_DEFINE : FIND_ANY, | |
7882 n, action, eap->line1, eap->line2); | |
7883 } | |
7884 #endif | |
7885 | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
7886 |
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
7887 #ifdef FEAT_QUICKFIX |
7 | 7888 /* |
7889 * ":ptag", ":ptselect", ":ptjump", ":ptnext", etc. | |
7890 */ | |
7891 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7892 ex_ptag(exarg_T *eap) |
7 | 7893 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7894 g_do_tagpreview = p_pvh; // will be reset to 0 in ex_tag_cmd() |
7 | 7895 ex_tag_cmd(eap, cmdnames[eap->cmdidx].cmd_name + 1); |
7896 } | |
7897 | |
7898 /* | |
7899 * ":pedit" | |
7900 */ | |
7901 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7902 ex_pedit(exarg_T *eap) |
7 | 7903 { |
7904 win_T *curwin_save = curwin; | |
7905 | |
19621
0d677257e35d
patch 8.2.0367: can use :pedit in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19575
diff
changeset
|
7906 if (ERROR_IF_ANY_POPUP_WINDOW) |
0d677257e35d
patch 8.2.0367: can use :pedit in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19575
diff
changeset
|
7907 return; |
0d677257e35d
patch 8.2.0367: can use :pedit in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19575
diff
changeset
|
7908 |
17746
a4e488a6655c
patch 8.1.1870: using :pedit from a help file sets help filetype
Bram Moolenaar <Bram@vim.org>
parents:
17744
diff
changeset
|
7909 // Open the preview window or popup and make it the current window. |
7 | 7910 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
|
7911 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
|
7912 |
17746
a4e488a6655c
patch 8.1.1870: using :pedit from a help file sets help filetype
Bram Moolenaar <Bram@vim.org>
parents:
17744
diff
changeset
|
7913 // Edit the file. |
7 | 7914 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
|
7915 |
7 | 7916 if (curwin != curwin_save && win_valid(curwin_save)) |
7917 { | |
17746
a4e488a6655c
patch 8.1.1870: using :pedit from a help file sets help filetype
Bram Moolenaar <Bram@vim.org>
parents:
17744
diff
changeset
|
7918 // Return cursor to where we were |
7 | 7919 validate_cursor(); |
7920 redraw_later(VALID); | |
7921 win_enter(curwin_save, TRUE); | |
7922 } | |
18763
49b78d6465e5
patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents:
18715
diff
changeset
|
7923 # ifdef FEAT_PROP_POPUP |
17644
daa1dea1c1b3
patch 8.1.1819: :pedit does not work with a popup preview window
Bram Moolenaar <Bram@vim.org>
parents:
17622
diff
changeset
|
7924 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
|
7925 { |
daa1dea1c1b3
patch 8.1.1819: :pedit does not work with a popup preview window
Bram Moolenaar <Bram@vim.org>
parents:
17622
diff
changeset
|
7926 // 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
|
7927 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
|
7928 } |
daa1dea1c1b3
patch 8.1.1819: :pedit does not work with a popup preview window
Bram Moolenaar <Bram@vim.org>
parents:
17622
diff
changeset
|
7929 # endif |
7 | 7930 g_do_tagpreview = 0; |
7931 } | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
7932 #endif |
7 | 7933 |
7934 /* | |
7935 * ":stag", ":stselect" and ":stjump". | |
7936 */ | |
7937 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7938 ex_stag(exarg_T *eap) |
7 | 7939 { |
7940 postponed_split = -1; | |
7941 postponed_split_flags = cmdmod.split; | |
1090 | 7942 postponed_split_tab = cmdmod.tab; |
7 | 7943 ex_tag_cmd(eap, cmdnames[eap->cmdidx].cmd_name + 1); |
7944 postponed_split_flags = 0; | |
1090 | 7945 postponed_split_tab = 0; |
7 | 7946 } |
7947 | |
7948 /* | |
7949 * ":tag", ":tselect", ":tjump", ":tnext", etc. | |
7950 */ | |
7951 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7952 ex_tag(exarg_T *eap) |
7 | 7953 { |
7954 ex_tag_cmd(eap, cmdnames[eap->cmdidx].cmd_name); | |
7955 } | |
7956 | |
7957 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7958 ex_tag_cmd(exarg_T *eap, char_u *name) |
7 | 7959 { |
7960 int cmd; | |
7961 | |
7962 switch (name[1]) | |
7963 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7964 case 'j': cmd = DT_JUMP; // ":tjump" |
7 | 7965 break; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7966 case 's': cmd = DT_SELECT; // ":tselect" |
7 | 7967 break; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7968 case 'p': cmd = DT_PREV; // ":tprevious" |
7 | 7969 break; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7970 case 'N': cmd = DT_PREV; // ":tNext" |
7 | 7971 break; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7972 case 'n': cmd = DT_NEXT; // ":tnext" |
7 | 7973 break; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7974 case 'o': cmd = DT_POP; // ":pop" |
7 | 7975 break; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7976 case 'f': // ":tfirst" |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7977 case 'r': cmd = DT_FIRST; // ":trewind" |
7 | 7978 break; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7979 case 'l': cmd = DT_LAST; // ":tlast" |
7 | 7980 break; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7981 default: // ":tag" |
7 | 7982 #ifdef FEAT_CSCOPE |
1603 | 7983 if (p_cst && *eap->arg != NUL) |
7 | 7984 { |
10373
bd674706408a
commit https://github.com/vim/vim/commit/d4db7719bdfbc54df396eac08d8cbb2389feacf4
Christian Brabandt <cb@256bit.org>
parents:
10361
diff
changeset
|
7985 ex_cstag(eap); |
7 | 7986 return; |
7987 } | |
7988 #endif | |
7989 cmd = DT_TAG; | |
7990 break; | |
7991 } | |
7992 | |
649 | 7993 if (name[0] == 'l') |
7994 { | |
7995 #ifndef FEAT_QUICKFIX | |
7996 ex_ni(eap); | |
7997 return; | |
7998 #else | |
7999 cmd = DT_LTAG; | |
8000 #endif | |
8001 } | |
8002 | |
7 | 8003 do_tag(eap->arg, cmd, eap->addr_count > 0 ? (int)eap->line2 : 1, |
8004 eap->forceit, TRUE); | |
8005 } | |
8006 | |
8007 /* | |
1661 | 8008 * Check "str" for starting with a special cmdline variable. |
8009 * If found return one of the SPEC_ values and set "*usedlen" to the length of | |
8010 * the variable. Otherwise return -1 and "*usedlen" is unchanged. | |
8011 */ | |
8012 int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8013 find_cmdline_var(char_u *src, int *usedlen) |
1661 | 8014 { |
8015 int len; | |
8016 int i; | |
1879 | 8017 static char *(spec_str[]) = { |
1661 | 8018 "%", |
8019 #define SPEC_PERC 0 | |
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 #define SPEC_HASH (SPEC_PERC + 1) |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8022 "<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
|
8023 #define SPEC_CWORD (SPEC_HASH + 1) |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8024 "<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
|
8025 #define SPEC_CCWORD (SPEC_CWORD + 1) |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8026 "<cexpr>", // expr under cursor |
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
|
8027 #define SPEC_CEXPR (SPEC_CCWORD + 1) |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8028 "<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
|
8029 #define SPEC_CFILE (SPEC_CEXPR + 1) |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8030 "<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
|
8031 #define SPEC_SFILE (SPEC_CFILE + 1) |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8032 "<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
|
8033 #define SPEC_SLNUM (SPEC_SFILE + 1) |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8034 "<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
|
8035 #define SPEC_AFILE (SPEC_SLNUM + 1) |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8036 "<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
|
8037 #define SPEC_ABUF (SPEC_AFILE + 1) |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8038 "<amatch>", // autocommand match name |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
8039 #define SPEC_AMATCH (SPEC_ABUF + 1) |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8040 "<sflnum>", // script file line 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
|
8041 #define SPEC_SFLNUM (SPEC_AMATCH + 1) |
1661 | 8042 #ifdef FEAT_CLIENTSERVER |
8043 "<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
|
8044 # define SPEC_CLIENT (SPEC_SFLNUM + 1) |
1661 | 8045 #endif |
8046 }; | |
1872 | 8047 |
8048 for (i = 0; i < (int)(sizeof(spec_str) / sizeof(char *)); ++i) | |
1661 | 8049 { |
8050 len = (int)STRLEN(spec_str[i]); | |
8051 if (STRNCMP(src, spec_str[i], len) == 0) | |
8052 { | |
8053 *usedlen = len; | |
8054 return i; | |
8055 } | |
8056 } | |
8057 return -1; | |
8058 } | |
8059 | |
8060 /* | |
7 | 8061 * Evaluate cmdline variables. |
8062 * | |
8063 * change '%' to curbuf->b_ffname | |
8064 * '#' to curwin->w_altfile | |
8065 * '<cword>' to word under the cursor | |
8066 * '<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
|
8067 * '<cexpr>' to C-expression under the cursor |
7 | 8068 * '<cfile>' to path name under the cursor |
8069 * '<sfile>' to sourced file name | |
2645 | 8070 * '<slnum>' to sourced file line number |
7 | 8071 * '<afile>' to file name for autocommand |
8072 * '<abuf>' to buffer number for autocommand | |
8073 * '<amatch>' to matching name for autocommand | |
8074 * | |
8075 * When an error is detected, "errormsg" is set to a non-NULL pointer (may be | |
8076 * "" for error without a message) and NULL is returned. | |
8077 * Returns an allocated string if a valid match was found. | |
8078 * Returns NULL if no match was found. "usedlen" then still contains the | |
8079 * number of characters to skip. | |
8080 */ | |
8081 char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8082 eval_vars( |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8083 char_u *src, // pointer into commandline |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8084 char_u *srcstart, // beginning of valid memory for src |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8085 int *usedlen, // characters after src that are used |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8086 linenr_T *lnump, // line number for :e command, or NULL |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8087 char **errormsg, // pointer to error message |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8088 int *escaped) // return value has escaped white space (can |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8089 // be NULL) |
7 | 8090 { |
8091 int i; | |
8092 char_u *s; | |
8093 char_u *result; | |
8094 char_u *resultbuf = NULL; | |
8095 int resultlen; | |
8096 buf_T *buf; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8097 int valid = VALID_HEAD + VALID_PATH; // assume valid result |
7 | 8098 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
|
8099 int tilde_file = FALSE; |
7 | 8100 int skip_mod = FALSE; |
8101 char_u strbuf[30]; | |
8102 | |
8103 *errormsg = NULL; | |
1098 | 8104 if (escaped != NULL) |
8105 *escaped = FALSE; | |
7 | 8106 |
8107 /* | |
8108 * Check if there is something to do. | |
8109 */ | |
1661 | 8110 spec_idx = find_cmdline_var(src, usedlen); |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8111 if (spec_idx < 0) // no match |
7 | 8112 { |
8113 *usedlen = 1; | |
8114 return NULL; | |
8115 } | |
8116 | |
8117 /* | |
8118 * Skip when preceded with a backslash "\%" and "\#". | |
8119 * Note: In "\\%" the % is also not recognized! | |
8120 */ | |
8121 if (src > srcstart && src[-1] == '\\') | |
8122 { | |
8123 *usedlen = 0; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8124 STRMOVE(src - 1, src); // remove backslash |
7 | 8125 return NULL; |
8126 } | |
8127 | |
8128 /* | |
8129 * word or WORD under cursor | |
8130 */ | |
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
|
8131 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
|
8132 || 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
|
8133 { |
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
|
8134 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
|
8135 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
|
8136 : 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
|
8137 : FIND_STRING); |
7 | 8138 if (resultlen == 0) |
8139 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8140 *errormsg = ""; |
7 | 8141 return NULL; |
8142 } | |
8143 } | |
8144 | |
8145 /* | |
8146 * '#': Alternate file name | |
8147 * '%': Current file name | |
8148 * File name under the cursor | |
8149 * File name for autocommand | |
8150 * and following modifiers | |
8151 */ | |
8152 else | |
8153 { | |
8154 switch (spec_idx) | |
8155 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8156 case SPEC_PERC: // '%': current file |
7 | 8157 if (curbuf->b_fname == NULL) |
8158 { | |
8159 result = (char_u *)""; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8160 valid = 0; // Must have ":p:h" to be valid |
7 | 8161 } |
8162 else | |
14393
c62601adad69
patch 8.1.0211: expanding a file name "~" results in $HOME
Christian Brabandt <cb@256bit.org>
parents:
14286
diff
changeset
|
8163 { |
7 | 8164 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
|
8165 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
|
8166 } |
7 | 8167 break; |
8168 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8169 case SPEC_HASH: // '#' or "#99": alternate file |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8170 if (src[1] == '#') // "##": the argument list |
7 | 8171 { |
8172 result = arg_all(); | |
8173 resultbuf = result; | |
8174 *usedlen = 2; | |
1098 | 8175 if (escaped != NULL) |
8176 *escaped = TRUE; | |
7 | 8177 skip_mod = TRUE; |
8178 break; | |
8179 } | |
8180 s = src + 1; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8181 if (*s == '<') // "#<99" uses v:oldfiles |
1733 | 8182 ++s; |
7 | 8183 i = (int)getdigits(&s); |
12706
9b882316aa63
patch 8.0.1231: expanding file name drops dash
Christian Brabandt <cb@256bit.org>
parents:
12674
diff
changeset
|
8184 if (s == src + 2 && src[1] == '-') |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8185 // just a minus sign, don't skip over it |
12706
9b882316aa63
patch 8.0.1231: expanding file name drops dash
Christian Brabandt <cb@256bit.org>
parents:
12674
diff
changeset
|
8186 s--; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8187 *usedlen = (int)(s - src); // length of what we expand |
7 | 8188 |
12706
9b882316aa63
patch 8.0.1231: expanding file name drops dash
Christian Brabandt <cb@256bit.org>
parents:
12674
diff
changeset
|
8189 if (src[1] == '<' && i != 0) |
7 | 8190 { |
1733 | 8191 if (*usedlen < 2) |
8192 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8193 // Should we give an error message for #<text? |
1733 | 8194 *usedlen = 1; |
8195 return NULL; | |
8196 } | |
8197 #ifdef FEAT_EVAL | |
8198 result = list_find_str(get_vim_var_list(VV_OLDFILES), | |
8199 (long)i); | |
8200 if (result == NULL) | |
8201 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8202 *errormsg = ""; |
1733 | 8203 return NULL; |
8204 } | |
8205 #else | |
15488
da8b98c008bf
patch 8.1.0752: one more compiler warning for signed/unsigned string
Bram Moolenaar <Bram@vim.org>
parents:
15474
diff
changeset
|
8206 *errormsg = _("E809: #< is not available without the +eval feature"); |
7 | 8207 return NULL; |
1733 | 8208 #endif |
7 | 8209 } |
8210 else | |
1733 | 8211 { |
12706
9b882316aa63
patch 8.0.1231: expanding file name drops dash
Christian Brabandt <cb@256bit.org>
parents:
12674
diff
changeset
|
8212 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
|
8213 *usedlen = 1; |
1733 | 8214 buf = buflist_findnr(i); |
8215 if (buf == NULL) | |
8216 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8217 *errormsg = _("E194: No alternate file name to substitute for '#'"); |
1733 | 8218 return NULL; |
8219 } | |
8220 if (lnump != NULL) | |
8221 *lnump = ECMD_LAST; | |
8222 if (buf->b_fname == NULL) | |
8223 { | |
8224 result = (char_u *)""; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8225 valid = 0; // Must have ":p:h" to be valid |
1733 | 8226 } |
8227 else | |
14393
c62601adad69
patch 8.1.0211: expanding a file name "~" results in $HOME
Christian Brabandt <cb@256bit.org>
parents:
14286
diff
changeset
|
8228 { |
1733 | 8229 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
|
8230 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
|
8231 } |
1733 | 8232 } |
7 | 8233 break; |
8234 | |
8235 #ifdef FEAT_SEARCHPATH | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8236 case SPEC_CFILE: // file name under cursor |
681 | 8237 result = file_name_at_cursor(FNAME_MESS|FNAME_HYP, 1L, NULL); |
7 | 8238 if (result == NULL) |
8239 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8240 *errormsg = ""; |
7 | 8241 return NULL; |
8242 } | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8243 resultbuf = result; // remember allocated string |
7 | 8244 break; |
8245 #endif | |
8246 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8247 case SPEC_AFILE: // file name for autocommand |
7 | 8248 result = autocmd_fname; |
1723 | 8249 if (result != NULL && !autocmd_fname_full) |
8250 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8251 // Still need to turn the fname into a full path. It is |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8252 // postponed to avoid a delay when <afile> is not used. |
1723 | 8253 autocmd_fname_full = TRUE; |
8254 result = FullName_save(autocmd_fname, FALSE); | |
8255 vim_free(autocmd_fname); | |
8256 autocmd_fname = result; | |
8257 } | |
7 | 8258 if (result == NULL) |
8259 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8260 *errormsg = _("E495: no autocommand file name to substitute for \"<afile>\""); |
7 | 8261 return NULL; |
8262 } | |
1471 | 8263 result = shorten_fname1(result); |
7 | 8264 break; |
8265 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8266 case SPEC_ABUF: // buffer number for autocommand |
7 | 8267 if (autocmd_bufnr <= 0) |
8268 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8269 *errormsg = _("E496: no autocommand buffer number to substitute for \"<abuf>\""); |
7 | 8270 return NULL; |
8271 } | |
8272 sprintf((char *)strbuf, "%d", autocmd_bufnr); | |
8273 result = strbuf; | |
8274 break; | |
8275 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8276 case SPEC_AMATCH: // match name for autocommand |
7 | 8277 result = autocmd_match; |
8278 if (result == NULL) | |
8279 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8280 *errormsg = _("E497: no autocommand match name to substitute for \"<amatch>\""); |
7 | 8281 return NULL; |
8282 } | |
8283 break; | |
8284 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8285 case SPEC_SFILE: // file name for ":so" command |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18904
diff
changeset
|
8286 result = estack_sfile(); |
7 | 8287 if (result == NULL) |
8288 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8289 *errormsg = _("E498: no :source file name to substitute for \"<sfile>\""); |
7 | 8290 return NULL; |
8291 } | |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18904
diff
changeset
|
8292 resultbuf = result; // remember allocated string |
7 | 8293 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
|
8294 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8295 case SPEC_SLNUM: // line in file for ":so" command |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18904
diff
changeset
|
8296 if (SOURCING_NAME == NULL || SOURCING_LNUM == 0) |
2645 | 8297 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8298 *errormsg = _("E842: no line number to use for \"<slnum>\""); |
2645 | 8299 return NULL; |
8300 } | |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18904
diff
changeset
|
8301 sprintf((char *)strbuf, "%ld", SOURCING_LNUM); |
2645 | 8302 result = strbuf; |
8303 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
|
8304 |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14677
diff
changeset
|
8305 #ifdef FEAT_EVAL |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8306 case SPEC_SFLNUM: // line in script file |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18904
diff
changeset
|
8307 if (current_sctx.sc_lnum + SOURCING_LNUM == 0) |
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
|
8308 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8309 *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
|
8310 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
|
8311 } |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14677
diff
changeset
|
8312 sprintf((char *)strbuf, "%ld", |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18904
diff
changeset
|
8313 (long)(current_sctx.sc_lnum + SOURCING_LNUM)); |
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
|
8314 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
|
8315 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
|
8316 #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
|
8317 |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14677
diff
changeset
|
8318 #ifdef FEAT_CLIENTSERVER |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8319 case SPEC_CLIENT: // Source of last submitted input |
840 | 8320 sprintf((char *)strbuf, PRINTF_HEX_LONG_U, |
8321 (long_u)clientWindow); | |
7 | 8322 result = strbuf; |
8323 break; | |
8324 #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
|
8325 |
11428
346168f2a6cb
patch 8.0.0598: building with gcc 7.1 yields new warnings
Christian Brabandt <cb@256bit.org>
parents:
11374
diff
changeset
|
8326 default: |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8327 result = (char_u *)""; // avoid gcc warning |
11428
346168f2a6cb
patch 8.0.0598: building with gcc 7.1 yields new warnings
Christian Brabandt <cb@256bit.org>
parents:
11374
diff
changeset
|
8328 break; |
7 | 8329 } |
8330 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8331 resultlen = (int)STRLEN(result); // length of new string |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8332 if (src[*usedlen] == '<') // remove the file name extension |
7 | 8333 { |
8334 ++*usedlen; | |
8335 if ((s = vim_strrchr(result, '.')) != NULL && s >= gettail(result)) | |
8336 resultlen = (int)(s - result); | |
8337 } | |
8338 else if (!skip_mod) | |
8339 { | |
14393
c62601adad69
patch 8.1.0211: expanding a file name "~" results in $HOME
Christian Brabandt <cb@256bit.org>
parents:
14286
diff
changeset
|
8340 valid |= modify_fname(src, tilde_file, usedlen, &result, &resultbuf, |
7 | 8341 &resultlen); |
8342 if (result == NULL) | |
8343 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8344 *errormsg = ""; |
7 | 8345 return NULL; |
8346 } | |
8347 } | |
8348 } | |
8349 | |
8350 if (resultlen == 0 || valid != VALID_HEAD + VALID_PATH) | |
8351 { | |
8352 if (valid != VALID_HEAD + VALID_PATH) | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8353 // 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
|
8354 *errormsg = _("E499: Empty file name for '%' or '#', only works with \":p:h\""); |
7 | 8355 else |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8356 *errormsg = _("E500: Evaluates to an empty string"); |
7 | 8357 result = NULL; |
8358 } | |
8359 else | |
8360 result = vim_strnsave(result, resultlen); | |
8361 vim_free(resultbuf); | |
8362 return result; | |
8363 } | |
8364 | |
8365 /* | |
8366 * Expand the <sfile> string in "arg". | |
8367 * | |
8368 * Returns an allocated string, or NULL for any error. | |
8369 */ | |
8370 char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8371 expand_sfile(char_u *arg) |
7 | 8372 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8373 char *errormsg; |
7 | 8374 int len; |
8375 char_u *result; | |
8376 char_u *newres; | |
8377 char_u *repl; | |
8378 int srclen; | |
8379 char_u *p; | |
8380 | |
8381 result = vim_strsave(arg); | |
8382 if (result == NULL) | |
8383 return NULL; | |
8384 | |
8385 for (p = result; *p; ) | |
8386 { | |
8387 if (STRNCMP(p, "<sfile>", 7) != 0) | |
8388 ++p; | |
8389 else | |
8390 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8391 // replace "<sfile>" with the sourced file name, and do ":" stuff |
1098 | 8392 repl = eval_vars(p, result, &srclen, NULL, &errormsg, NULL); |
7 | 8393 if (errormsg != NULL) |
8394 { | |
8395 if (*errormsg) | |
8396 emsg(errormsg); | |
8397 vim_free(result); | |
8398 return NULL; | |
8399 } | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8400 if (repl == NULL) // no match (cannot happen) |
7 | 8401 { |
8402 p += srclen; | |
8403 continue; | |
8404 } | |
8405 len = (int)STRLEN(result) - srclen + (int)STRLEN(repl) + 1; | |
8406 newres = alloc(len); | |
8407 if (newres == NULL) | |
8408 { | |
8409 vim_free(repl); | |
8410 vim_free(result); | |
8411 return NULL; | |
8412 } | |
8413 mch_memmove(newres, result, (size_t)(p - result)); | |
8414 STRCPY(newres + (p - result), repl); | |
8415 len = (int)STRLEN(newres); | |
8416 STRCAT(newres, p + srclen); | |
8417 vim_free(repl); | |
8418 vim_free(result); | |
8419 result = newres; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8420 p = newres + len; // continue after the match |
7 | 8421 } |
8422 } | |
8423 | |
8424 return result; | |
8425 } | |
8426 | |
8427 #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) || defined(PROTO) | |
272 | 8428 /* |
2770 | 8429 * Make a dialog message in "buff[DIALOG_MSG_SIZE]". |
310 | 8430 * "format" must contain "%s". |
272 | 8431 */ |
7 | 8432 void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8433 dialog_msg(char_u *buff, char *format, char_u *fname) |
7 | 8434 { |
8435 if (fname == NULL) | |
8436 fname = (char_u *)_("Untitled"); | |
2770 | 8437 vim_snprintf((char *)buff, DIALOG_MSG_SIZE, format, fname); |
7 | 8438 } |
8439 #endif | |
8440 | |
8441 /* | |
8442 * ":behave {mswin,xterm}" | |
8443 */ | |
8444 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8445 ex_behave(exarg_T *eap) |
7 | 8446 { |
8447 if (STRCMP(eap->arg, "mswin") == 0) | |
8448 { | |
8449 set_option_value((char_u *)"selection", 0L, (char_u *)"exclusive", 0); | |
8450 set_option_value((char_u *)"selectmode", 0L, (char_u *)"mouse,key", 0); | |
8451 set_option_value((char_u *)"mousemodel", 0L, (char_u *)"popup", 0); | |
8452 set_option_value((char_u *)"keymodel", 0L, | |
8453 (char_u *)"startsel,stopsel", 0); | |
8454 } | |
8455 else if (STRCMP(eap->arg, "xterm") == 0) | |
8456 { | |
8457 set_option_value((char_u *)"selection", 0L, (char_u *)"inclusive", 0); | |
8458 set_option_value((char_u *)"selectmode", 0L, (char_u *)"", 0); | |
8459 set_option_value((char_u *)"mousemodel", 0L, (char_u *)"extend", 0); | |
8460 set_option_value((char_u *)"keymodel", 0L, (char_u *)"", 0); | |
8461 } | |
8462 else | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8463 semsg(_(e_invarg2), eap->arg); |
7 | 8464 } |
8465 | |
8466 static int filetype_detect = FALSE; | |
8467 static int filetype_plugin = FALSE; | |
8468 static int filetype_indent = FALSE; | |
8469 | |
8470 /* | |
8471 * ":filetype [plugin] [indent] {on,off,detect}" | |
8472 * on: Load the filetype.vim file to install autocommands for file types. | |
8473 * off: Load the ftoff.vim file to remove all autocommands for file types. | |
8474 * plugin on: load filetype.vim and ftplugin.vim | |
8475 * plugin off: load ftplugof.vim | |
8476 * indent on: load filetype.vim and indent.vim | |
8477 * indent off: load indoff.vim | |
8478 */ | |
8479 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8480 ex_filetype(exarg_T *eap) |
7 | 8481 { |
8482 char_u *arg = eap->arg; | |
8483 int plugin = FALSE; | |
8484 int indent = FALSE; | |
8485 | |
8486 if (*eap->arg == NUL) | |
8487 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8488 // Print current status. |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8489 smsg("filetype detection:%s plugin:%s indent:%s", |
7 | 8490 filetype_detect ? "ON" : "OFF", |
8491 filetype_plugin ? (filetype_detect ? "ON" : "(on)") : "OFF", | |
8492 filetype_indent ? (filetype_detect ? "ON" : "(on)") : "OFF"); | |
8493 return; | |
8494 } | |
8495 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8496 // Accept "plugin" and "indent" in any order. |
7 | 8497 for (;;) |
8498 { | |
8499 if (STRNCMP(arg, "plugin", 6) == 0) | |
8500 { | |
8501 plugin = TRUE; | |
8502 arg = skipwhite(arg + 6); | |
8503 continue; | |
8504 } | |
8505 if (STRNCMP(arg, "indent", 6) == 0) | |
8506 { | |
8507 indent = TRUE; | |
8508 arg = skipwhite(arg + 6); | |
8509 continue; | |
8510 } | |
8511 break; | |
8512 } | |
8513 if (STRCMP(arg, "on") == 0 || STRCMP(arg, "detect") == 0) | |
8514 { | |
8515 if (*arg == 'o' || !filetype_detect) | |
8516 { | |
8524
2f57bbe870ea
commit https://github.com/vim/vim/commit/7f8989dd8a627af2185df381195351a913f3777f
Christian Brabandt <cb@256bit.org>
parents:
8402
diff
changeset
|
8517 source_runtime((char_u *)FILETYPE_FILE, DIP_ALL); |
7 | 8518 filetype_detect = TRUE; |
8519 if (plugin) | |
8520 { | |
8524
2f57bbe870ea
commit https://github.com/vim/vim/commit/7f8989dd8a627af2185df381195351a913f3777f
Christian Brabandt <cb@256bit.org>
parents:
8402
diff
changeset
|
8521 source_runtime((char_u *)FTPLUGIN_FILE, DIP_ALL); |
7 | 8522 filetype_plugin = TRUE; |
8523 } | |
8524 if (indent) | |
8525 { | |
8524
2f57bbe870ea
commit https://github.com/vim/vim/commit/7f8989dd8a627af2185df381195351a913f3777f
Christian Brabandt <cb@256bit.org>
parents:
8402
diff
changeset
|
8526 source_runtime((char_u *)INDENT_FILE, DIP_ALL); |
7 | 8527 filetype_indent = TRUE; |
8528 } | |
8529 } | |
8530 if (*arg == 'd') | |
8531 { | |
9260
ac8180818504
commit https://github.com/vim/vim/commit/1610d052413e0ed664498853a47acc2d677a22d1
Christian Brabandt <cb@256bit.org>
parents:
9230
diff
changeset
|
8532 (void)do_doautocmd((char_u *)"filetypedetect BufRead", TRUE, NULL); |
717 | 8533 do_modelines(0); |
7 | 8534 } |
8535 } | |
8536 else if (STRCMP(arg, "off") == 0) | |
8537 { | |
8538 if (plugin || indent) | |
8539 { | |
8540 if (plugin) | |
8541 { | |
8524
2f57bbe870ea
commit https://github.com/vim/vim/commit/7f8989dd8a627af2185df381195351a913f3777f
Christian Brabandt <cb@256bit.org>
parents:
8402
diff
changeset
|
8542 source_runtime((char_u *)FTPLUGOF_FILE, DIP_ALL); |
7 | 8543 filetype_plugin = FALSE; |
8544 } | |
8545 if (indent) | |
8546 { | |
8524
2f57bbe870ea
commit https://github.com/vim/vim/commit/7f8989dd8a627af2185df381195351a913f3777f
Christian Brabandt <cb@256bit.org>
parents:
8402
diff
changeset
|
8547 source_runtime((char_u *)INDOFF_FILE, DIP_ALL); |
7 | 8548 filetype_indent = FALSE; |
8549 } | |
8550 } | |
8551 else | |
8552 { | |
8524
2f57bbe870ea
commit https://github.com/vim/vim/commit/7f8989dd8a627af2185df381195351a913f3777f
Christian Brabandt <cb@256bit.org>
parents:
8402
diff
changeset
|
8553 source_runtime((char_u *)FTOFF_FILE, DIP_ALL); |
7 | 8554 filetype_detect = FALSE; |
8555 } | |
8556 } | |
8557 else | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8558 semsg(_(e_invarg2), arg); |
7 | 8559 } |
8560 | |
8561 /* | |
11459
561b76ed9d12
patch 8.0.0613: the conf filetype is used before ftdetect from packages
Christian Brabandt <cb@256bit.org>
parents:
11428
diff
changeset
|
8562 * ":setfiletype [FALLBACK] {name}" |
7 | 8563 */ |
8564 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8565 ex_setfiletype(exarg_T *eap) |
7 | 8566 { |
8567 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
|
8568 { |
561b76ed9d12
patch 8.0.0613: the conf filetype is used before ftdetect from packages
Christian Brabandt <cb@256bit.org>
parents:
11428
diff
changeset
|
8569 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
|
8570 |
561b76ed9d12
patch 8.0.0613: the conf filetype is used before ftdetect from packages
Christian Brabandt <cb@256bit.org>
parents:
11428
diff
changeset
|
8571 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
|
8572 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
|
8573 |
561b76ed9d12
patch 8.0.0613: the conf filetype is used before ftdetect from packages
Christian Brabandt <cb@256bit.org>
parents:
11428
diff
changeset
|
8574 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
|
8575 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
|
8576 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
|
8577 } |
7 | 8578 } |
8579 | |
8580 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8581 ex_digraphs(exarg_T *eap UNUSED) |
7 | 8582 { |
8583 #ifdef FEAT_DIGRAPHS | |
8584 if (*eap->arg != NUL) | |
8585 putdigraph(eap->arg); | |
8586 else | |
15152
1ef429366fd4
patch 8.1.0586: :digraph output is not easy to read
Bram Moolenaar <Bram@vim.org>
parents:
15125
diff
changeset
|
8587 listdigraphs(eap->forceit); |
7 | 8588 #else |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8589 emsg(_("E196: No digraphs in this version")); |
7 | 8590 #endif |
8591 } | |
8592 | |
13792
0e9b2971d7c3
patch 8.0.1768: SET_NO_HLSEARCH() used in a wrong way
Christian Brabandt <cb@256bit.org>
parents:
13581
diff
changeset
|
8593 #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
|
8594 void |
0e9b2971d7c3
patch 8.0.1768: SET_NO_HLSEARCH() used in a wrong way
Christian Brabandt <cb@256bit.org>
parents:
13581
diff
changeset
|
8595 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
|
8596 { |
0e9b2971d7c3
patch 8.0.1768: SET_NO_HLSEARCH() used in a wrong way
Christian Brabandt <cb@256bit.org>
parents:
13581
diff
changeset
|
8597 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
|
8598 # 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
|
8599 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
|
8600 # endif |
0e9b2971d7c3
patch 8.0.1768: SET_NO_HLSEARCH() used in a wrong way
Christian Brabandt <cb@256bit.org>
parents:
13581
diff
changeset
|
8601 } |
0e9b2971d7c3
patch 8.0.1768: SET_NO_HLSEARCH() used in a wrong way
Christian Brabandt <cb@256bit.org>
parents:
13581
diff
changeset
|
8602 |
7 | 8603 /* |
8604 * ":nohlsearch" | |
8605 */ | |
8606 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8607 ex_nohlsearch(exarg_T *eap UNUSED) |
7 | 8608 { |
13792
0e9b2971d7c3
patch 8.0.1768: SET_NO_HLSEARCH() used in a wrong way
Christian Brabandt <cb@256bit.org>
parents:
13581
diff
changeset
|
8609 set_no_hlsearch(TRUE); |
737 | 8610 redraw_all_later(SOME_VALID); |
7 | 8611 } |
8612 #endif | |
8613 | |
8614 #ifdef FEAT_CRYPT | |
8615 /* | |
8616 * ":X": Get crypt key | |
8617 */ | |
8618 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8619 ex_X(exarg_T *eap UNUSED) |
7 | 8620 { |
6353 | 8621 crypt_check_current_method(); |
6122 | 8622 (void)crypt_get_key(TRUE, TRUE); |
7 | 8623 } |
8624 #endif | |
8625 | |
8626 #ifdef FEAT_FOLDING | |
8627 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8628 ex_fold(exarg_T *eap) |
7 | 8629 { |
8630 if (foldManualAllowed(TRUE)) | |
8631 foldCreate(eap->line1, eap->line2); | |
8632 } | |
8633 | |
8634 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8635 ex_foldopen(exarg_T *eap) |
7 | 8636 { |
8637 opFoldRange(eap->line1, eap->line2, eap->cmdidx == CMD_foldopen, | |
8638 eap->forceit, FALSE); | |
8639 } | |
8640 | |
8641 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8642 ex_folddo(exarg_T *eap) |
7 | 8643 { |
8644 linenr_T lnum; | |
8645 | |
18297
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
8646 # ifdef FEAT_CLIPBOARD |
6116 | 8647 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
|
8648 # endif |
6116 | 8649 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8650 // First set the marks for all lines closed/open. |
7 | 8651 for (lnum = eap->line1; lnum <= eap->line2; ++lnum) |
8652 if (hasFolding(lnum, NULL, NULL) == (eap->cmdidx == CMD_folddoclosed)) | |
8653 ml_setmarked(lnum); | |
8654 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8655 // Execute the command on the marked lines. |
7 | 8656 global_exe(eap->arg); |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8657 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
|
8658 # ifdef FEAT_CLIPBOARD |
6116 | 8659 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
|
8660 # endif |
6116 | 8661 } |
8662 #endif | |
12459
937356f8f8d6
patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents:
12457
diff
changeset
|
8663 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
8664 #if defined(FEAT_QUICKFIX) || defined(PROTO) |
14550
60b9b6196644
patch 8.1.0288: quickfix code uses cmdidx too often
Christian Brabandt <cb@256bit.org>
parents:
14538
diff
changeset
|
8665 /* |
60b9b6196644
patch 8.1.0288: quickfix code uses cmdidx too often
Christian Brabandt <cb@256bit.org>
parents:
14538
diff
changeset
|
8666 * 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
|
8667 * 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
|
8668 */ |
60b9b6196644
patch 8.1.0288: quickfix code uses cmdidx too often
Christian Brabandt <cb@256bit.org>
parents:
14538
diff
changeset
|
8669 int |
60b9b6196644
patch 8.1.0288: quickfix code uses cmdidx too often
Christian Brabandt <cb@256bit.org>
parents:
14538
diff
changeset
|
8670 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
|
8671 { |
14621
89cc3e7ecb68
patch 8.1.0324: off-by-one error in cmdidx check
Christian Brabandt <cb@256bit.org>
parents:
14591
diff
changeset
|
8672 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
|
8673 return FALSE; |
60b9b6196644
patch 8.1.0288: quickfix code uses cmdidx too often
Christian Brabandt <cb@256bit.org>
parents:
14538
diff
changeset
|
8674 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
|
8675 } |
60b9b6196644
patch 8.1.0288: quickfix code uses cmdidx too often
Christian Brabandt <cb@256bit.org>
parents:
14538
diff
changeset
|
8676 #endif |
60b9b6196644
patch 8.1.0288: quickfix code uses cmdidx too often
Christian Brabandt <cb@256bit.org>
parents:
14538
diff
changeset
|
8677 |
18297
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
8678 #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
|
8679 int |
937356f8f8d6
patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents:
12457
diff
changeset
|
8680 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
|
8681 { |
937356f8f8d6
patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents:
12457
diff
changeset
|
8682 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
|
8683 } |
937356f8f8d6
patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents:
12457
diff
changeset
|
8684 |
937356f8f8d6
patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents:
12457
diff
changeset
|
8685 void |
937356f8f8d6
patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents:
12457
diff
changeset
|
8686 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
|
8687 { |
937356f8f8d6
patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents:
12457
diff
changeset
|
8688 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
|
8689 } |
937356f8f8d6
patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents:
12457
diff
changeset
|
8690 #endif |