Mercurial > vim
annotate src/ex_docmd.c @ 25409:e3f1086429d8 v8.2.3241
patch 8.2.3241: Vim9: memory leak when function reports an error
Commit: https://github.com/vim/vim/commit/6e850a6900793e215c08b39d6490173488cb05ce
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Jul 28 22:21:23 2021 +0200
patch 8.2.3241: Vim9: memory leak when function reports an error
Problem: Vim9: memory leak when function reports an error.
Solution: Clear the return value.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 28 Jul 2021 22:30:04 +0200 |
parents | e8e2c4d33b9b |
children | 65f04b6effd5 |
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 | |
21885
72525eabfe61
patch 8.2.1492: build failures
Bram Moolenaar <Bram@vim.org>
parents:
21883
diff
changeset
|
23 static char_u *do_one_cmd(char_u **, int, cstack_T *, char_u *(*fgetline)(int, void *, int, getline_opt_T), void *cookie); |
7 | 24 #else |
21885
72525eabfe61
patch 8.2.1492: build failures
Bram Moolenaar <Bram@vim.org>
parents:
21883
diff
changeset
|
25 static char_u *do_one_cmd(char_u **, int, char_u *(*fgetline)(int, void *, int, getline_opt_T), 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 |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
28 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
|
29 |
7 | 30 #ifndef FEAT_MENU |
31 # define ex_emenu ex_ni | |
32 # define ex_menu ex_ni | |
33 # define ex_menutranslate ex_ni | |
34 #endif | |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
35 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
|
36 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
|
37 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
|
38 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
|
39 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
|
40 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
|
41 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
|
42 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
|
43 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
|
44 static char_u *getargcmd(char_u **); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
45 static int getargopt(exarg_T *eap); |
7 | 46 #ifndef FEAT_QUICKFIX |
47 # define ex_make ex_ni | |
41 | 48 # define ex_cbuffer ex_ni |
7 | 49 # define ex_cc ex_ni |
50 # 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
|
51 # define ex_cbelow ex_ni |
7 | 52 # define ex_cfile ex_ni |
53 # define qf_list ex_ni | |
54 # define qf_age ex_ni | |
9538
26da1efa9e46
commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
55 # define qf_history ex_ni |
7 | 56 # define ex_helpgrep ex_ni |
41 | 57 # define ex_vimgrep ex_ni |
7 | 58 #endif |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
59 #if !defined(FEAT_QUICKFIX) |
7 | 60 # define ex_cclose ex_ni |
61 # define ex_copen ex_ni | |
62 # define ex_cwindow ex_ni | |
9432
abb72f0b9e06
commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents:
9284
diff
changeset
|
63 # define ex_cbottom ex_ni |
7 | 64 #endif |
532 | 65 #if !defined(FEAT_QUICKFIX) || !defined(FEAT_EVAL) |
66 # define ex_cexpr ex_ni | |
67 #endif | |
7 | 68 |
21939
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
69 static linenr_T default_address(exarg_T *eap); |
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); |
21939
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
71 static void address_default_all(exarg_T *eap); |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
72 static void get_flags(exarg_T *eap); |
2333
aee7e1e5e0ce
Build problem when using all interfaces except Lua.
Bram Moolenaar <bram@vim.org>
parents:
2330
diff
changeset
|
73 #if !defined(FEAT_PERL) \ |
aee7e1e5e0ce
Build problem when using all interfaces except Lua.
Bram Moolenaar <bram@vim.org>
parents:
2330
diff
changeset
|
74 || !defined(FEAT_PYTHON) || !defined(FEAT_PYTHON3) \ |
aee7e1e5e0ce
Build problem when using all interfaces except Lua.
Bram Moolenaar <bram@vim.org>
parents:
2330
diff
changeset
|
75 || !defined(FEAT_TCL) \ |
aee7e1e5e0ce
Build problem when using all interfaces except Lua.
Bram Moolenaar <bram@vim.org>
parents:
2330
diff
changeset
|
76 || !defined(FEAT_RUBY) \ |
aee7e1e5e0ce
Build problem when using all interfaces except Lua.
Bram Moolenaar <bram@vim.org>
parents:
2330
diff
changeset
|
77 || !defined(FEAT_LUA) \ |
aee7e1e5e0ce
Build problem when using all interfaces except Lua.
Bram Moolenaar <bram@vim.org>
parents:
2330
diff
changeset
|
78 || !defined(FEAT_MZSCHEME) |
1315 | 79 # define HAVE_EX_SCRIPT_NI |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
80 static void ex_script_ni(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
81 #endif |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
82 static char *invalid_range(exarg_T *eap); |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
83 static void correct_range(exarg_T *eap); |
344 | 84 #ifdef FEAT_QUICKFIX |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
85 static char_u *replace_makeprg(exarg_T *eap, char_u *p, char_u **cmdlinep); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
86 #endif |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
87 static char_u *repl_cmdline(exarg_T *eap, char_u *src, int srclen, char_u *repl, char_u **cmdlinep); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
88 static void ex_highlight(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
89 static void ex_colorscheme(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
90 static void ex_cquit(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
91 static void ex_quit_all(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
92 static void ex_close(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
93 static void ex_win_close(int forceit, win_T *win, tabpage_T *tp); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
94 static void ex_only(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
95 static void ex_resize(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
96 static void ex_stag(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
97 static void ex_tabclose(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
98 static void ex_tabonly(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
99 static void ex_tabnext(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
100 static void ex_tabmove(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
101 static void ex_tabs(exarg_T *eap); |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
102 #if defined(FEAT_QUICKFIX) |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
103 static void ex_pclose(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
104 static void ex_ptag(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
105 static void ex_pedit(exarg_T *eap); |
7 | 106 #else |
107 # define ex_pclose ex_ni | |
108 # define ex_ptag ex_ni | |
109 # define ex_pedit ex_ni | |
110 #endif | |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
111 static void ex_hide(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
112 static void ex_stop(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
113 static void ex_exit(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
114 static void ex_print(exarg_T *eap); |
7 | 115 #ifdef FEAT_BYTEOFF |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
116 static void ex_goto(exarg_T *eap); |
7 | 117 #else |
118 # define ex_goto ex_ni | |
119 #endif | |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
120 static void ex_shell(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
121 static void ex_preserve(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
122 static void ex_recover(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
123 static void ex_mode(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
124 static void ex_wrongmodifier(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
125 static void ex_find(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
126 static void ex_open(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
127 static void ex_edit(exarg_T *eap); |
7 | 128 #ifndef FEAT_GUI |
129 # define ex_gui ex_nogui | |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
130 static void ex_nogui(exarg_T *eap); |
7 | 131 #endif |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15866
diff
changeset
|
132 #if defined(FEAT_GUI_MSWIN) && defined(FEAT_MENU) && defined(FEAT_TEAROFF) |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
133 static void ex_tearoff(exarg_T *eap); |
7 | 134 #else |
135 # define ex_tearoff ex_ni | |
136 #endif | |
13392
d5347779fb20
patch 8.0.1570: can't use :popup for a menu in the terminal
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
137 #if (defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_GTK) \ |
d5347779fb20
patch 8.0.1570: can't use :popup for a menu in the terminal
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
138 || defined(FEAT_TERM_POPUP_MENU)) && defined(FEAT_MENU) |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
139 static void ex_popup(exarg_T *eap); |
7 | 140 #else |
141 # define ex_popup ex_ni | |
142 #endif | |
143 #ifndef FEAT_GUI_MSWIN | |
144 # define ex_simalt ex_ni | |
145 #endif | |
573 | 146 #if !defined(FEAT_GUI_MSWIN) && !defined(FEAT_GUI_GTK) && !defined(FEAT_GUI_MOTIF) |
7 | 147 # define gui_mch_find_dialog ex_ni |
148 # define gui_mch_replace_dialog ex_ni | |
149 #endif | |
573 | 150 #if !defined(FEAT_GUI_GTK) |
7 | 151 # define ex_helpfind ex_ni |
152 #endif | |
153 #ifndef FEAT_CSCOPE | |
10373
bd674706408a
commit https://github.com/vim/vim/commit/d4db7719bdfbc54df396eac08d8cbb2389feacf4
Christian Brabandt <cb@256bit.org>
parents:
10361
diff
changeset
|
154 # define ex_cscope ex_ni |
bd674706408a
commit https://github.com/vim/vim/commit/d4db7719bdfbc54df396eac08d8cbb2389feacf4
Christian Brabandt <cb@256bit.org>
parents:
10361
diff
changeset
|
155 # define ex_scscope ex_ni |
bd674706408a
commit https://github.com/vim/vim/commit/d4db7719bdfbc54df396eac08d8cbb2389feacf4
Christian Brabandt <cb@256bit.org>
parents:
10361
diff
changeset
|
156 # define ex_cstag ex_ni |
7 | 157 #endif |
158 #ifndef FEAT_SYN_HL | |
159 # define ex_syntax ex_ni | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2238
diff
changeset
|
160 # define ex_ownsyntax ex_ni |
737 | 161 #endif |
4766
ec24ff78a79c
updated for version 7.3.1130
Bram Moolenaar <bram@vim.org>
parents:
4764
diff
changeset
|
162 #if !defined(FEAT_SYN_HL) || !defined(FEAT_PROFILE) |
4764
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4710
diff
changeset
|
163 # define ex_syntime ex_ni |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4710
diff
changeset
|
164 #endif |
737 | 165 #ifndef FEAT_SPELL |
310 | 166 # define ex_spell ex_ni |
236 | 167 # define ex_mkspell ex_ni |
351 | 168 # define ex_spelldump ex_ni |
714 | 169 # define ex_spellinfo ex_ni |
372 | 170 # define ex_spellrepall ex_ni |
236 | 171 #endif |
2214
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
172 #ifndef FEAT_PERSISTENT_UNDO |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
173 # define ex_rundo ex_ni |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
174 # define ex_wundo ex_ni |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
175 #endif |
2320
966a5609669e
Added Lua interfae. (Luis Carvalho)
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
176 #ifndef FEAT_LUA |
966a5609669e
Added Lua interfae. (Luis Carvalho)
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
177 # define ex_lua ex_script_ni |
966a5609669e
Added Lua interfae. (Luis Carvalho)
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
178 # define ex_luado ex_ni |
966a5609669e
Added Lua interfae. (Luis Carvalho)
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
179 # define ex_luafile ex_ni |
966a5609669e
Added Lua interfae. (Luis Carvalho)
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
180 #endif |
14 | 181 #ifndef FEAT_MZSCHEME |
182 # define ex_mzscheme ex_script_ni | |
183 # define ex_mzfile ex_ni | |
184 #endif | |
7 | 185 #ifndef FEAT_PERL |
186 # define ex_perl ex_script_ni | |
187 # define ex_perldo ex_ni | |
188 #endif | |
189 #ifndef FEAT_PYTHON | |
190 # define ex_python ex_script_ni | |
4435 | 191 # define ex_pydo ex_ni |
7 | 192 # define ex_pyfile ex_ni |
193 #endif | |
2329
ad2889f48843
Added support for Python 3. (Roland Puntaier)
Bram Moolenaar <bram@vim.org>
parents:
2320
diff
changeset
|
194 #ifndef FEAT_PYTHON3 |
2350
06feaf4fe36a
Rename some "python3" symbols to "py3", as the command name.
Bram Moolenaar <bram@vim.org>
parents:
2340
diff
changeset
|
195 # define ex_py3 ex_script_ni |
4417 | 196 # define ex_py3do ex_ni |
2329
ad2889f48843
Added support for Python 3. (Roland Puntaier)
Bram Moolenaar <bram@vim.org>
parents:
2320
diff
changeset
|
197 # define ex_py3file ex_ni |
ad2889f48843
Added support for Python 3. (Roland Puntaier)
Bram Moolenaar <bram@vim.org>
parents:
2320
diff
changeset
|
198 #endif |
10722
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10656
diff
changeset
|
199 #if !defined(FEAT_PYTHON) && !defined(FEAT_PYTHON3) |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10656
diff
changeset
|
200 # define ex_pyx ex_script_ni |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10656
diff
changeset
|
201 # define ex_pyxdo ex_ni |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10656
diff
changeset
|
202 # define ex_pyxfile ex_ni |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10656
diff
changeset
|
203 #endif |
7 | 204 #ifndef FEAT_TCL |
205 # define ex_tcl ex_script_ni | |
206 # define ex_tcldo ex_ni | |
207 # define ex_tclfile ex_ni | |
208 #endif | |
209 #ifndef FEAT_RUBY | |
210 # define ex_ruby ex_script_ni | |
211 # define ex_rubydo ex_ni | |
212 # define ex_rubyfile ex_ni | |
213 #endif | |
214 #ifndef FEAT_KEYMAP | |
215 # define ex_loadkeymap ex_ni | |
216 #endif | |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
217 static void ex_swapname(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
218 static void ex_syncbind(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
219 static void ex_read(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
220 static void ex_pwd(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
221 static void ex_equal(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
222 static void ex_sleep(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
223 static void ex_winsize(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
224 static void ex_wincmd(exarg_T *eap); |
11 | 225 #if defined(FEAT_GUI) || defined(UNIX) || defined(VMS) || defined(MSWIN) |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
226 static void ex_winpos(exarg_T *eap); |
7 | 227 #else |
228 # define ex_winpos ex_ni | |
229 #endif | |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
230 static void ex_operators(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
231 static void ex_put(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
232 static void ex_copymove(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
233 static void ex_submagic(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
234 static void ex_join(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
235 static void ex_at(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
236 static void ex_bang(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
237 static void ex_undo(exarg_T *eap); |
2214
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
238 #ifdef FEAT_PERSISTENT_UNDO |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
239 static void ex_wundo(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
240 static void ex_rundo(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
241 #endif |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
242 static void ex_redo(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
243 static void ex_later(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
244 static void ex_redir(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
245 static void ex_redrawstatus(exarg_T *eap); |
15396
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
246 static void ex_redrawtabline(exarg_T *eap); |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
247 static void close_redir(void); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
248 static void ex_mark(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
249 static void ex_startinsert(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
250 static void ex_stopinsert(exarg_T *eap); |
7 | 251 #ifdef FEAT_FIND_ID |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
252 static void ex_checkpath(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
253 static void ex_findpat(exarg_T *eap); |
7 | 254 #else |
255 # define ex_findpat ex_ni | |
256 # define ex_checkpath ex_ni | |
257 #endif | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
258 #if defined(FEAT_FIND_ID) && defined(FEAT_QUICKFIX) |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
259 static void ex_psearch(exarg_T *eap); |
7 | 260 #else |
261 # define ex_psearch ex_ni | |
262 #endif | |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
263 static void ex_tag(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
264 static void ex_tag_cmd(exarg_T *eap, char_u *name); |
7 | 265 #ifndef FEAT_EVAL |
22559
715e8f14f314
patch 8.2.1828: build failure without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
22555
diff
changeset
|
266 # define ex_block ex_ni |
17622
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
267 # define ex_break ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
268 # define ex_breakadd ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
269 # define ex_breakdel ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
270 # define ex_breaklist ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
271 # define ex_call ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
272 # define ex_catch ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
273 # define ex_compiler ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
274 # define ex_continue ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
275 # define ex_debug ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
276 # define ex_debuggreedy ex_ni |
20528
489cb75c76b6
patch 8.2.0818: Vim9: using a discovery phase doesn't work well
Bram Moolenaar <Bram@vim.org>
parents:
20474
diff
changeset
|
277 # define ex_defcompile ex_ni |
17622
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
278 # 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
|
279 # define ex_disassemble ex_ni |
7 | 280 # define ex_echo ex_ni |
281 # 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
|
282 # define ex_else ex_ni |
22559
715e8f14f314
patch 8.2.1828: build failure without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
22555
diff
changeset
|
283 # define ex_endblock ex_ni |
17622
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
284 # define ex_endfunction ex_ni |
7 | 285 # 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
|
286 # define ex_endtry ex_ni |
7 | 287 # 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
|
288 # define ex_eval ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
289 # define ex_execute ex_ni |
24535
f522ef9e5ea3
patch 8.2.2807: build fails with tiny features
Bram Moolenaar <Bram@vim.org>
parents:
24533
diff
changeset
|
290 # define ex_incdec ex_ni |
17622
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
291 # define ex_finally ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
292 # define ex_finish ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
293 # define ex_function ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
294 # define ex_if ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
295 # define ex_let ex_ni |
22393
d1b9bd52d721
patch 8.2.1745: tiny version doesn't build
Bram Moolenaar <Bram@vim.org>
parents:
22391
diff
changeset
|
296 # define ex_var ex_ni |
17622
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
297 # define ex_lockvar ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
298 # define ex_oldfiles ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
299 # define ex_options ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
300 # define ex_packadd ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
301 # define ex_packloadall ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
302 # define ex_return ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
303 # define ex_scriptnames ex_ni |
7 | 304 # define ex_throw ex_ni |
305 # define ex_try ex_ni | |
306 # define ex_unlet ex_ni | |
146 | 307 # define ex_unlockvar ex_ni |
17622
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
308 # 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
|
309 # 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
|
310 # define ex_export ex_ni |
7 | 311 #endif |
17536
e00d12c085a5
patch 8.1.1766: code for writing session file is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17496
diff
changeset
|
312 #ifndef FEAT_SESSION |
7 | 313 # define ex_loadview ex_ni |
314 #endif | |
17458
cfdef48743ed
patch 8.1.1727: code for viminfo support is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17431
diff
changeset
|
315 #ifndef FEAT_VIMINFO |
7 | 316 # define ex_viminfo ex_ni |
317 #endif | |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
318 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
|
319 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
|
320 static void ex_setfiletype(exarg_T *eap); |
7 | 321 #ifndef FEAT_DIFF |
16 | 322 # define ex_diffoff ex_ni |
7 | 323 # define ex_diffpatch ex_ni |
324 # define ex_diffgetput ex_ni | |
325 # define ex_diffsplit ex_ni | |
326 # define ex_diffthis ex_ni | |
327 # define ex_diffupdate ex_ni | |
328 #endif | |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
329 static void ex_digraphs(exarg_T *eap); |
7 | 330 #ifdef FEAT_SEARCH_EXTRA |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
331 static void ex_nohlsearch(exarg_T *eap); |
7 | 332 #else |
333 # define ex_nohlsearch ex_ni | |
334 # define ex_match ex_ni | |
335 #endif | |
336 #ifdef FEAT_CRYPT | |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
337 static void ex_X(exarg_T *eap); |
7 | 338 #else |
339 # define ex_X ex_ni | |
340 #endif | |
341 #ifdef FEAT_FOLDING | |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
342 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
|
343 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
|
344 static void ex_folddo(exarg_T *eap); |
7 | 345 #else |
346 # define ex_fold ex_ni | |
347 # define ex_foldopen ex_ni | |
348 # define ex_folddo ex_ni | |
349 #endif | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
350 #if !(defined(HAVE_LOCALE_H) || defined(X_LOCALE)) |
7 | 351 # define ex_language ex_ni |
352 #endif | |
353 #ifndef FEAT_SIGNS | |
354 # define ex_sign ex_ni | |
355 #endif | |
33 | 356 #ifndef FEAT_NETBEANS_INTG |
2210 | 357 # define ex_nbclose ex_ni |
33 | 358 # define ex_nbkey ex_ni |
2210 | 359 # define ex_nbstart ex_ni |
33 | 360 #endif |
7 | 361 |
362 #ifndef FEAT_JUMPLIST | |
363 # define ex_jumps ex_ni | |
9284
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
9260
diff
changeset
|
364 # define ex_clearjumps ex_ni |
7 | 365 # define ex_changes ex_ni |
366 #endif | |
367 | |
170 | 368 #ifndef FEAT_PROFILE |
369 # define ex_profile ex_ni | |
370 #endif | |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
11547
diff
changeset
|
371 #ifndef FEAT_TERMINAL |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
11547
diff
changeset
|
372 # define ex_terminal ex_ni |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
11547
diff
changeset
|
373 #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
|
374 #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
|
375 # 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
|
376 #endif |
18763
49b78d6465e5
patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents:
18715
diff
changeset
|
377 #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
|
378 # define ex_popupclear ex_ni |
491c01280a5d
patch 8.1.1392: build failure in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
379 #endif |
170 | 380 |
7 | 381 /* |
382 * Declare cmdnames[]. | |
383 */ | |
384 #define DO_DECLARE_EXCMD | |
385 #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
|
386 #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
|
387 |
7 | 388 static char_u dollar_command[2] = {'$', 0}; |
389 | |
390 | |
391 #ifdef FEAT_EVAL | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
392 // Struct for storing a line inside a while/for loop |
7 | 393 typedef struct |
394 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
395 char_u *line; // command line |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
396 linenr_T lnum; // sourcing_lnum of the line |
7 | 397 } wcmd_T; |
398 | |
399 /* | |
72 | 400 * Structure used to store info for line position in a while or for loop. |
7 | 401 * This is required, because do_one_cmd() may invoke ex_function(), which |
72 | 402 * reads more lines that may come from the while/for loop. |
403 */ | |
404 struct loop_cookie | |
7 | 405 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
406 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
|
407 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
|
408 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
|
409 // When "repeating" is FALSE use "getline" and "cookie" to get lines |
21885
72525eabfe61
patch 8.2.1492: build failures
Bram Moolenaar <Bram@vim.org>
parents:
21883
diff
changeset
|
410 char_u *(*getline)(int, void *, int, getline_opt_T); |
7 | 411 void *cookie; |
412 }; | |
413 | |
21885
72525eabfe61
patch 8.2.1492: build failures
Bram Moolenaar <Bram@vim.org>
parents:
21883
diff
changeset
|
414 static char_u *get_loop_line(int c, void *cookie, int indent, getline_opt_T options); |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
415 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
|
416 static void free_cmdlines(garray_T *gap); |
8 | 417 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
418 // Struct to save a few things while debugging. Used in do_cmdline() only. |
8 | 419 struct dbg_stuff |
420 { | |
421 int trylevel; | |
422 int force_abort; | |
423 except_T *caught_stack; | |
424 char_u *vv_exception; | |
425 char_u *vv_throwpoint; | |
426 int did_emsg; | |
427 int got_int; | |
428 int did_throw; | |
429 int need_rethrow; | |
430 int check_cstack; | |
431 except_T *current_exception; | |
432 }; | |
433 | |
434 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
435 save_dbg_stuff(struct dbg_stuff *dsp) |
8 | 436 { |
437 dsp->trylevel = trylevel; trylevel = 0; | |
438 dsp->force_abort = force_abort; force_abort = FALSE; | |
439 dsp->caught_stack = caught_stack; caught_stack = NULL; | |
440 dsp->vv_exception = v_exception(NULL); | |
441 dsp->vv_throwpoint = v_throwpoint(NULL); | |
442 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
443 // Necessary for debugging an inactive ":catch", ":finally", ":endtry" |
8 | 444 dsp->did_emsg = did_emsg; did_emsg = FALSE; |
445 dsp->got_int = got_int; got_int = FALSE; | |
446 dsp->did_throw = did_throw; did_throw = FALSE; | |
447 dsp->need_rethrow = need_rethrow; need_rethrow = FALSE; | |
448 dsp->check_cstack = check_cstack; check_cstack = FALSE; | |
449 dsp->current_exception = current_exception; current_exception = NULL; | |
450 } | |
451 | |
452 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
453 restore_dbg_stuff(struct dbg_stuff *dsp) |
8 | 454 { |
455 suppress_errthrow = FALSE; | |
456 trylevel = dsp->trylevel; | |
457 force_abort = dsp->force_abort; | |
458 caught_stack = dsp->caught_stack; | |
459 (void)v_exception(dsp->vv_exception); | |
460 (void)v_throwpoint(dsp->vv_throwpoint); | |
461 did_emsg = dsp->did_emsg; | |
462 got_int = dsp->got_int; | |
463 did_throw = dsp->did_throw; | |
464 need_rethrow = dsp->need_rethrow; | |
465 check_cstack = dsp->check_cstack; | |
466 current_exception = dsp->current_exception; | |
467 } | |
7 | 468 #endif |
469 | |
470 /* | |
471 * do_exmode(): Repeatedly get commands for the "Ex" mode, until the ":vi" | |
472 * command is given. | |
473 */ | |
474 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
475 do_exmode( |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
476 int improved) // TRUE for "improved Ex" mode |
7 | 477 { |
478 int save_msg_scroll; | |
479 int prev_msg_row; | |
480 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
|
481 varnumber_T changedtick; |
167 | 482 |
483 if (improved) | |
484 exmode_active = EXMODE_VIM; | |
485 else | |
486 exmode_active = EXMODE_NORMAL; | |
487 State = NORMAL; | |
488 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
489 // 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
|
490 // the :global command. |
167 | 491 if (global_busy) |
492 return; | |
7 | 493 |
494 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
|
495 ++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
|
496 ++no_wait_return; // don't wait for return |
7 | 497 #ifdef FEAT_GUI |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
498 // Ignore scrollbar and mouse events in Ex mode |
7 | 499 ++hold_gui_events; |
500 #endif | |
501 | |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15510
diff
changeset
|
502 msg(_("Entering Ex mode. Type \"visual\" to go to Normal mode.")); |
7 | 503 while (exmode_active) |
504 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
505 // Check for a ":normal" command and no more characters left. |
161 | 506 if (ex_normal_busy > 0 && typebuf.tb_len == 0) |
507 { | |
508 exmode_active = FALSE; | |
509 break; | |
510 } | |
7 | 511 msg_scroll = TRUE; |
512 need_wait_return = FALSE; | |
513 ex_pressedreturn = FALSE; | |
514 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
|
515 changedtick = CHANGEDTICK(curbuf); |
7 | 516 prev_msg_row = msg_row; |
517 prev_line = curwin->w_cursor.lnum; | |
518 if (improved) | |
519 { | |
520 cmdline_row = msg_row; | |
521 do_cmdline(NULL, getexline, NULL, 0); | |
522 } | |
523 else | |
524 do_cmdline(NULL, getexmodeline, NULL, DOCMD_NOWAIT); | |
525 lines_left = Rows - 1; | |
526 | |
167 | 527 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
|
528 || changedtick != CHANGEDTICK(curbuf)) && !ex_no_reprint) |
167 | 529 { |
530 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
|
531 emsg(_(e_emptybuf)); |
167 | 532 else |
533 { | |
534 if (ex_pressedreturn) | |
535 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
536 // 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
|
537 // output doesn't contain empty lines. |
167 | 538 msg_row = prev_msg_row; |
539 if (prev_msg_row == Rows - 1) | |
540 msg_row--; | |
541 } | |
542 msg_col = 0; | |
543 print_line_no_prefix(curwin->w_cursor.lnum, FALSE, FALSE); | |
544 msg_clr_eos(); | |
545 } | |
546 } | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
547 else if (ex_pressedreturn && !ex_no_reprint) // must be at EOF |
167 | 548 { |
549 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
|
550 emsg(_(e_emptybuf)); |
167 | 551 else |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
552 emsg(_("E501: At end-of-file")); |
167 | 553 } |
7 | 554 } |
555 | |
556 #ifdef FEAT_GUI | |
557 --hold_gui_events; | |
558 #endif | |
559 --RedrawingDisabled; | |
560 --no_wait_return; | |
561 update_screen(CLEAR); | |
562 need_wait_return = FALSE; | |
563 msg_scroll = save_msg_scroll; | |
564 } | |
565 | |
566 /* | |
18297
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
567 * 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
|
568 * 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
|
569 */ |
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
570 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
|
571 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
|
572 { |
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
573 ++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
|
574 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
|
575 |
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 (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
|
577 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
|
578 else |
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
579 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
|
580 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
|
581 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
|
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 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
|
584 --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
|
585 } |
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
586 |
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
587 /* |
7 | 588 * Execute a simple command line. Used for translated commands like "*". |
589 */ | |
590 int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
591 do_cmdline_cmd(char_u *cmd) |
7 | 592 { |
593 return do_cmdline(cmd, NULL, NULL, | |
594 DOCMD_VERBOSE|DOCMD_NOWAIT|DOCMD_KEYTYPED); | |
595 } | |
596 | |
597 /* | |
23011
ec23d84a096d
patch 8.2.2052: Vim9: "edit +4 fname" gives an error
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
598 * Execute the "+cmd" argument of "edit +cmd fname" and the like. |
ec23d84a096d
patch 8.2.2052: Vim9: "edit +4 fname" gives an error
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
599 * This allows for using a range without ":" in Vim9 script. |
ec23d84a096d
patch 8.2.2052: Vim9: "edit +4 fname" gives an error
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
600 */ |
ec23d84a096d
patch 8.2.2052: Vim9: "edit +4 fname" gives an error
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
601 int |
ec23d84a096d
patch 8.2.2052: Vim9: "edit +4 fname" gives an error
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
602 do_cmd_argument(char_u *cmd) |
ec23d84a096d
patch 8.2.2052: Vim9: "edit +4 fname" gives an error
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
603 { |
ec23d84a096d
patch 8.2.2052: Vim9: "edit +4 fname" gives an error
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
604 return do_cmdline(cmd, NULL, NULL, |
ec23d84a096d
patch 8.2.2052: Vim9: "edit +4 fname" gives an error
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
605 DOCMD_VERBOSE|DOCMD_NOWAIT|DOCMD_KEYTYPED|DOCMD_RANGEOK); |
ec23d84a096d
patch 8.2.2052: Vim9: "edit +4 fname" gives an error
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
606 } |
ec23d84a096d
patch 8.2.2052: Vim9: "edit +4 fname" gives an error
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
607 |
ec23d84a096d
patch 8.2.2052: Vim9: "edit +4 fname" gives an error
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
608 /* |
7 | 609 * do_cmdline(): execute one Ex command line |
610 * | |
611 * 1. Execute "cmdline" when it is not NULL. | |
2635 | 612 * If "cmdline" is NULL, or more lines are needed, fgetline() is used. |
7 | 613 * 2. Split up in parts separated with '|'. |
614 * | |
615 * This function can be called recursively! | |
616 * | |
617 * flags: | |
618 * DOCMD_VERBOSE - The command will be included in the error message. | |
619 * DOCMD_NOWAIT - Don't call wait_return() and friends. | |
2635 | 620 * DOCMD_REPEAT - Repeat execution until fgetline() returns NULL. |
7 | 621 * DOCMD_KEYTYPED - Don't reset KeyTyped. |
622 * DOCMD_EXCRESET - Reset the exception environment (used for debugging). | |
623 * DOCMD_KEEPLINE - Store first typed line (for repeating with "."). | |
624 * | |
625 * return FAIL if cmdline could not be executed, OK otherwise | |
626 */ | |
627 int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
628 do_cmdline( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
629 char_u *cmdline, |
21883
a427f5f26419
patch 8.2.1491: Vim9: crash when compiling heredoc lines start with comment
Bram Moolenaar <Bram@vim.org>
parents:
21845
diff
changeset
|
630 char_u *(*fgetline)(int, void *, int, getline_opt_T), |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
631 void *cookie, // argument for fgetline() |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
632 int flags) |
7 | 633 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
634 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
|
635 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
|
636 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
|
637 static int recursive = 0; // recursive depth |
7 | 638 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
|
639 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
|
640 int did_inc = FALSE; // incremented RedrawingDisabled |
7 | 641 int retval = OK; |
642 #ifdef FEAT_EVAL | |
18904
2bdc2e1f6e1f
patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents:
18849
diff
changeset
|
643 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
|
644 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
|
645 int current_line = 0; // active line in lines_ga |
21056
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
646 int current_line_before = 0; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
647 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
|
648 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
|
649 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
|
650 struct dbg_stuff debug_saved; // saved things for debug mode |
7 | 651 int initial_trylevel; |
20538
9f921ba86d05
patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents:
20536
diff
changeset
|
652 msglist_T **saved_msg_list = NULL; |
22685
80b4e604d1d5
patch 8.2.1891: Vim9: skipping over expression doesn't handle line breaks
Bram Moolenaar <Bram@vim.org>
parents:
22616
diff
changeset
|
653 msglist_T *private_msg_list = NULL; |
7 | 654 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
655 // "fgetline" and "cookie" passed to do_one_cmd() |
21883
a427f5f26419
patch 8.2.1491: Vim9: crash when compiling heredoc lines start with comment
Bram Moolenaar <Bram@vim.org>
parents:
21845
diff
changeset
|
656 char_u *(*cmd_getline)(int, void *, int, getline_opt_T); |
7 | 657 void *cmd_cookie; |
72 | 658 struct loop_cookie cmd_loop_cookie; |
7 | 659 void *real_cookie; |
170 | 660 int getline_is_func; |
7 | 661 #else |
2635 | 662 # define cmd_getline fgetline |
7 | 663 # define cmd_cookie cookie |
664 #endif | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
665 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
|
666 #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
|
667 ESTACK_CHECK_DECLARATION |
7 | 668 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
669 // 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
|
670 // 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
|
671 // 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
|
672 // 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
|
673 // 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
|
674 // BufWritePost autocommands are executed after a write error. |
7 | 675 saved_msg_list = msg_list; |
676 msg_list = &private_msg_list; | |
677 #endif | |
678 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
679 // 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
|
680 // 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
|
681 // 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
|
682 if (call_depth >= 200 |
8f2191b56d52
commit https://github.com/vim/vim/commit/b094ff4b2be4d8b7364c566a1cc7e27aa4452a50
Christian Brabandt <cb@256bit.org>
parents:
10488
diff
changeset
|
683 #ifdef FEAT_EVAL |
8f2191b56d52
commit https://github.com/vim/vim/commit/b094ff4b2be4d8b7364c566a1cc7e27aa4452a50
Christian Brabandt <cb@256bit.org>
parents:
10488
diff
changeset
|
684 && call_depth >= p_mfd |
8f2191b56d52
commit https://github.com/vim/vim/commit/b094ff4b2be4d8b7364c566a1cc7e27aa4452a50
Christian Brabandt <cb@256bit.org>
parents:
10488
diff
changeset
|
685 #endif |
8f2191b56d52
commit https://github.com/vim/vim/commit/b094ff4b2be4d8b7364c566a1cc7e27aa4452a50
Christian Brabandt <cb@256bit.org>
parents:
10488
diff
changeset
|
686 ) |
7 | 687 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
688 emsg(_("E169: Command too recursive")); |
7 | 689 #ifdef FEAT_EVAL |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
690 // 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
|
691 // 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
|
692 do_errthrow((cstack_T *)NULL, (char_u *)NULL); |
7 | 693 msg_list = saved_msg_list; |
694 #endif | |
695 return FAIL; | |
696 } | |
697 ++call_depth; | |
698 | |
699 #ifdef FEAT_EVAL | |
23742
1f24fcf5945a
patch 8.2.2412: not all fields in "cstack" are initialized
Bram Moolenaar <Bram@vim.org>
parents:
23717
diff
changeset
|
700 CLEAR_FIELD(cstack); |
7 | 701 cstack.cs_idx = -1; |
702 ga_init2(&lines_ga, (int)sizeof(wcmd_T), 10); | |
703 | |
2635 | 704 real_cookie = getline_cookie(fgetline, cookie); |
7 | 705 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
706 // Inside a function use a higher nesting level. |
2635 | 707 getline_is_func = getline_equal(fgetline, cookie, get_func_line); |
170 | 708 if (getline_is_func && ex_nesting_level == func_level(real_cookie)) |
7 | 709 ++ex_nesting_level; |
710 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
711 // 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
|
712 // line and the debug tick for a function or script are stored. |
170 | 713 if (getline_is_func) |
7 | 714 { |
715 fname = func_name(real_cookie); | |
716 breakpoint = func_breakpoint(real_cookie); | |
717 dbg_tick = func_dbg_tick(real_cookie); | |
718 } | |
2635 | 719 else if (getline_equal(fgetline, cookie, getsourceline)) |
7 | 720 { |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18904
diff
changeset
|
721 fname = SOURCING_NAME; |
7 | 722 breakpoint = source_breakpoint(real_cookie); |
723 dbg_tick = source_dbg_tick(real_cookie); | |
724 } | |
725 | |
726 /* | |
727 * Initialize "force_abort" and "suppress_errthrow" at the top level. | |
728 */ | |
729 if (!recursive) | |
730 { | |
731 force_abort = FALSE; | |
732 suppress_errthrow = FALSE; | |
733 } | |
734 | |
735 /* | |
736 * If requested, store and reset the global values controlling the | |
944 | 737 * exception handling (used when debugging). Otherwise clear it to avoid |
738 * a bogus compiler warning when the optimizer uses inline functions... | |
7 | 739 */ |
878 | 740 if (flags & DOCMD_EXCRESET) |
8 | 741 save_dbg_stuff(&debug_saved); |
944 | 742 else |
20007
aadd1cae2ff5
patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
743 CLEAR_FIELD(debug_saved); |
7 | 744 |
745 initial_trylevel = trylevel; | |
746 | |
747 /* | |
748 * "did_throw" will be set to TRUE when an exception is being thrown. | |
749 */ | |
750 did_throw = FALSE; | |
751 #endif | |
752 /* | |
753 * "did_emsg" will be set to TRUE when emsg() is used, in which case we | |
72 | 754 * cancel the whole command line, and any if/endif or loop. |
7 | 755 * If force_abort is set, we cancel everything. |
756 */ | |
22948
707b90980de5
patch 8.2.2021: Vim9: get E1099 when autocommand resets did_emsg
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
757 #ifdef FEAT_EVAL |
707b90980de5
patch 8.2.2021: Vim9: get E1099 when autocommand resets did_emsg
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
758 did_emsg_cumul += did_emsg; |
707b90980de5
patch 8.2.2021: Vim9: get E1099 when autocommand resets did_emsg
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
759 #endif |
7 | 760 did_emsg = FALSE; |
761 | |
762 /* | |
763 * KeyTyped is only set when calling vgetc(). Reset it here when not | |
764 * calling vgetc() (sourced command lines). | |
765 */ | |
2635 | 766 if (!(flags & DOCMD_KEYTYPED) |
767 && !getline_equal(fgetline, cookie, getexline)) | |
7 | 768 KeyTyped = FALSE; |
769 | |
770 /* | |
771 * Continue executing command lines: | |
72 | 772 * - when inside an ":if", ":while" or ":for" |
7 | 773 * - for multiple commands on one line, separated with '|' |
774 * - when repeating until there are no more lines (for ":source") | |
775 */ | |
776 next_cmdline = cmdline; | |
777 do | |
778 { | |
170 | 779 #ifdef FEAT_EVAL |
2635 | 780 getline_is_func = getline_equal(fgetline, cookie, get_func_line); |
170 | 781 #endif |
782 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
783 // stop skipping cmds for an error msg after all endif/while/for |
7 | 784 if (next_cmdline == NULL |
785 #ifdef FEAT_EVAL | |
786 && !force_abort | |
787 && cstack.cs_idx < 0 | |
170 | 788 && !(getline_is_func && func_has_abort(real_cookie)) |
7 | 789 #endif |
790 ) | |
22948
707b90980de5
patch 8.2.2021: Vim9: get E1099 when autocommand resets did_emsg
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
791 { |
707b90980de5
patch 8.2.2021: Vim9: get E1099 when autocommand resets did_emsg
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
792 #ifdef FEAT_EVAL |
707b90980de5
patch 8.2.2021: Vim9: get E1099 when autocommand resets did_emsg
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
793 did_emsg_cumul += did_emsg; |
707b90980de5
patch 8.2.2021: Vim9: get E1099 when autocommand resets did_emsg
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
794 #endif |
7 | 795 did_emsg = FALSE; |
22948
707b90980de5
patch 8.2.2021: Vim9: get E1099 when autocommand resets did_emsg
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
796 } |
7 | 797 |
798 /* | |
72 | 799 * 1. If repeating a line in a loop, get a line from lines_ga. |
2635 | 800 * 2. If no line given: Get an allocated line with fgetline(). |
7 | 801 * 3. If a line is given: Make a copy, so we can mess with it. |
802 */ | |
803 | |
804 #ifdef FEAT_EVAL | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
805 // 1. If repeating, get a previous line from lines_ga. |
72 | 806 if (cstack.cs_looplevel > 0 && current_line < lines_ga.ga_len) |
7 | 807 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
808 // 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
|
809 // 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
|
810 VIM_CLEAR(cmdline_copy); |
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 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
|
813 // try conditional, aborted. |
170 | 814 if (getline_is_func) |
815 { | |
816 # ifdef FEAT_PROFILE | |
788 | 817 if (do_profiling == PROF_YES) |
170 | 818 func_line_end(real_cookie); |
819 # endif | |
820 if (func_has_ended(real_cookie)) | |
821 { | |
822 retval = FAIL; | |
823 break; | |
824 } | |
825 } | |
826 #ifdef FEAT_PROFILE | |
788 | 827 else if (do_profiling == PROF_YES |
2635 | 828 && getline_equal(fgetline, cookie, getsourceline)) |
170 | 829 script_line_end(); |
830 #endif | |
7 | 831 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
832 // Check if a sourced file hit a ":finish" command. |
2635 | 833 if (source_finished(fgetline, cookie)) |
7 | 834 { |
835 retval = FAIL; | |
836 break; | |
837 } | |
838 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
839 // If breakpoints have been added/deleted need to check for it. |
7 | 840 if (breakpoint != NULL && dbg_tick != NULL |
841 && *dbg_tick != debug_tick) | |
842 { | |
843 *breakpoint = dbg_find_breakpoint( | |
2635 | 844 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
|
845 fname, SOURCING_LNUM); |
7 | 846 *dbg_tick = debug_tick; |
847 } | |
848 | |
849 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
|
850 SOURCING_LNUM = ((wcmd_T *)(lines_ga.ga_data))[current_line].lnum; |
7 | 851 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
852 // Did we encounter a breakpoint? |
7 | 853 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
|
854 && *breakpoint <= SOURCING_LNUM) |
7 | 855 { |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18904
diff
changeset
|
856 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
|
857 // Find next breakpoint. |
7 | 858 *breakpoint = dbg_find_breakpoint( |
2635 | 859 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
|
860 fname, SOURCING_LNUM); |
7 | 861 *dbg_tick = debug_tick; |
862 } | |
170 | 863 # ifdef FEAT_PROFILE |
788 | 864 if (do_profiling == PROF_YES) |
170 | 865 { |
866 if (getline_is_func) | |
23717
e3720756acdc
patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents:
23709
diff
changeset
|
867 func_line_start(real_cookie, SOURCING_LNUM); |
2635 | 868 else if (getline_equal(fgetline, cookie, getsourceline)) |
170 | 869 script_line_start(); |
870 } | |
871 # endif | |
7 | 872 } |
873 #endif | |
874 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
875 // 2. If no line given, get an allocated line with fgetline(). |
7 | 876 if (next_cmdline == NULL) |
877 { | |
878 /* | |
879 * Need to set msg_didout for the first line after an ":if", | |
880 * otherwise the ":if" will be overwritten. | |
881 */ | |
2635 | 882 if (count == 1 && getline_equal(fgetline, cookie, getexline)) |
7 | 883 msg_didout = TRUE; |
2635 | 884 if (fgetline == NULL || (next_cmdline = fgetline(':', cookie, |
7 | 885 #ifdef FEAT_EVAL |
886 cstack.cs_idx < 0 ? 0 : (cstack.cs_idx + 1) * 2 | |
887 #else | |
888 0 | |
889 #endif | |
23398
40f824f5c7c7
patch 8.2.2242: Vim9: bar line continuation does not work at script level
Bram Moolenaar <Bram@vim.org>
parents:
23390
diff
changeset
|
890 , in_vim9script() ? GETLINE_CONCAT_CONTBAR |
40f824f5c7c7
patch 8.2.2242: Vim9: bar line continuation does not work at script level
Bram Moolenaar <Bram@vim.org>
parents:
23390
diff
changeset
|
891 : GETLINE_CONCAT_CONT)) == 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 { | |
25306
078edc1821bf
patch 8.2.3190: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
25304
diff
changeset
|
922 emsg(_(e_out_of_memory)); |
7 | 923 retval = FAIL; |
924 break; | |
925 } | |
926 } | |
927 cmdline_copy = next_cmdline; | |
928 | |
929 #ifdef FEAT_EVAL | |
930 /* | |
21056
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
931 * Inside a while/for loop, and when the command looks like a ":while" |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
932 * or ":for", the line is stored, because we may need it later when |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
933 * looping. |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
934 * |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
935 * When there is a '|' and another command, it is stored separately, |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
936 * because we need to be able to jump back to it from an |
72 | 937 * :endwhile/:endfor. |
21056
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
938 * |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
939 * Pass a different "fgetline" function to do_one_cmd() below, |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
940 * that it stores lines in or reads them from "lines_ga". Makes it |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
941 * possible to define a function inside a while/for loop and handles |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
942 * line continuation. |
7 | 943 */ |
21056
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
944 if ((cstack.cs_looplevel > 0 || has_loop_cmd(next_cmdline))) |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
945 { |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
946 cmd_getline = get_loop_line; |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
947 cmd_cookie = (void *)&cmd_loop_cookie; |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
948 cmd_loop_cookie.lines_gap = &lines_ga; |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
949 cmd_loop_cookie.current_line = current_line; |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
950 cmd_loop_cookie.getline = fgetline; |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
951 cmd_loop_cookie.cookie = cookie; |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
952 cmd_loop_cookie.repeating = (current_line < lines_ga.ga_len); |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
953 |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
954 // Save the current line when encountering it the first time. |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
955 if (current_line == lines_ga.ga_len |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
956 && store_loop_line(&lines_ga, next_cmdline) == FAIL) |
7 | 957 { |
958 retval = FAIL; | |
959 break; | |
960 } | |
21056
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
961 current_line_before = current_line; |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
962 } |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
963 else |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
964 { |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
965 cmd_getline = fgetline; |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
966 cmd_cookie = cookie; |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
967 } |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
968 |
7 | 969 did_endif = FALSE; |
970 #endif | |
971 | |
972 if (count++ == 0) | |
973 { | |
974 /* | |
975 * All output from the commands is put below each other, without | |
976 * waiting for a return. Don't do this when executing commands | |
977 * from a script or when being called recursive (e.g. for ":e | |
978 * +command file"). | |
979 */ | |
980 if (!(flags & DOCMD_NOWAIT) && !recursive) | |
981 { | |
982 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
|
983 msg_didany = FALSE; // no output yet |
7 | 984 msg_start(); |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
985 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
|
986 ++no_wait_return; // don't wait for return until finished |
7 | 987 ++RedrawingDisabled; |
988 did_inc = TRUE; | |
989 } | |
990 } | |
991 | |
20575
501b72481d0a
patch 8.2.0841: 'verbose' value 16 causes duplicate output
Bram Moolenaar <Bram@vim.org>
parents:
20538
diff
changeset
|
992 if ((p_verbose >= 15 && SOURCING_NAME != NULL) || p_verbose >= 16) |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18904
diff
changeset
|
993 msg_verbose_cmd(SOURCING_LNUM, cmdline_copy); |
7 | 994 |
995 /* | |
996 * 2. Execute one '|' separated command. | |
997 * do_one_cmd() will return NULL if there is no trailing '|'. | |
998 * "cmdline_copy" can change, e.g. for '%' and '#' expansion. | |
999 */ | |
1000 ++recursive; | |
23011
ec23d84a096d
patch 8.2.2052: Vim9: "edit +4 fname" gives an error
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
1001 next_cmdline = do_one_cmd(&cmdline_copy, flags, |
7 | 1002 #ifdef FEAT_EVAL |
1003 &cstack, | |
1004 #endif | |
1005 cmd_getline, cmd_cookie); | |
1006 --recursive; | |
1007 | |
1008 #ifdef FEAT_EVAL | |
72 | 1009 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
|
1010 // 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
|
1011 // incremented when defining a function. |
72 | 1012 current_line = cmd_loop_cookie.current_line; |
7 | 1013 #endif |
1014 | |
1015 if (next_cmdline == NULL) | |
1016 { | |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13221
diff
changeset
|
1017 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
|
1018 |
7 | 1019 /* |
1020 * If the command was typed, remember it for the ':' register. | |
1021 * Do this AFTER executing the command to make :@: work. | |
1022 */ | |
2635 | 1023 if (getline_equal(fgetline, cookie, getexline) |
7 | 1024 && new_last_cmdline != NULL) |
1025 { | |
1026 vim_free(last_cmdline); | |
1027 last_cmdline = new_last_cmdline; | |
1028 new_last_cmdline = NULL; | |
1029 } | |
1030 } | |
1031 else | |
1032 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1033 // 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
|
1034 // next do_one_cmd() |
1619 | 1035 STRMOVE(cmdline_copy, next_cmdline); |
7 | 1036 next_cmdline = cmdline_copy; |
1037 } | |
1038 | |
1039 | |
1040 #ifdef FEAT_EVAL | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1041 // reset did_emsg for a function that is not aborted by an error |
7 | 1042 if (did_emsg && !force_abort |
2635 | 1043 && getline_equal(fgetline, cookie, get_func_line) |
7 | 1044 && !func_has_abort(real_cookie)) |
22948
707b90980de5
patch 8.2.2021: Vim9: get E1099 when autocommand resets did_emsg
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1045 { |
707b90980de5
patch 8.2.2021: Vim9: get E1099 when autocommand resets did_emsg
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1046 // did_emsg_cumul is not set here |
7 | 1047 did_emsg = FALSE; |
22948
707b90980de5
patch 8.2.2021: Vim9: get E1099 when autocommand resets did_emsg
Bram Moolenaar <Bram@vim.org>
parents:
22862
diff
changeset
|
1048 } |
7 | 1049 |
72 | 1050 if (cstack.cs_looplevel > 0) |
7 | 1051 { |
1052 ++current_line; | |
1053 | |
1054 /* | |
72 | 1055 * An ":endwhile", ":endfor" and ":continue" is handled here. |
1056 * If we were executing commands, jump back to the ":while" or | |
1057 * ":for". | |
1058 * If we were not executing commands, decrement cs_looplevel. | |
7 | 1059 */ |
72 | 1060 if (cstack.cs_lflags & (CSL_HAD_CONT | CSL_HAD_ENDLOOP)) |
1061 { | |
1062 cstack.cs_lflags &= ~(CSL_HAD_CONT | CSL_HAD_ENDLOOP); | |
1063 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1064 // 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
|
1065 // 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
|
1066 // 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
|
1067 // cause a crash. |
7 | 1068 if (!did_emsg && !got_int && !did_throw |
1069 && cstack.cs_idx >= 0 | |
72 | 1070 && (cstack.cs_flags[cstack.cs_idx] |
1071 & (CSF_WHILE | CSF_FOR)) | |
7 | 1072 && cstack.cs_line[cstack.cs_idx] >= 0 |
1073 && (cstack.cs_flags[cstack.cs_idx] & CSF_ACTIVE)) | |
1074 { | |
1075 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
|
1076 // remember we jumped there |
72 | 1077 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
|
1078 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
|
1079 |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1080 // 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
|
1081 // or ":for". |
7 | 1082 if (breakpoint != NULL) |
1083 { | |
1084 *breakpoint = dbg_find_breakpoint( | |
2635 | 1085 getline_equal(fgetline, cookie, getsourceline), |
7 | 1086 fname, |
1087 ((wcmd_T *)lines_ga.ga_data)[current_line].lnum-1); | |
1088 *dbg_tick = debug_tick; | |
1089 } | |
1090 } | |
72 | 1091 else |
7 | 1092 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1093 // can only get here with ":endwhile" or ":endfor" |
7 | 1094 if (cstack.cs_idx >= 0) |
77 | 1095 rewind_conditionals(&cstack, cstack.cs_idx - 1, |
1096 CSF_WHILE | CSF_FOR, &cstack.cs_looplevel); | |
7 | 1097 } |
1098 } | |
1099 | |
1100 /* | |
72 | 1101 * For a ":while" or ":for" we need to remember the line number. |
7 | 1102 */ |
72 | 1103 else if (cstack.cs_lflags & CSL_HAD_LOOP) |
1104 { | |
1105 cstack.cs_lflags &= ~CSL_HAD_LOOP; | |
21056
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1106 cstack.cs_line[cstack.cs_idx] = current_line_before; |
7 | 1107 } |
1108 } | |
1109 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1110 // 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
|
1111 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
|
1112 { |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18904
diff
changeset
|
1113 *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
|
1114 *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
|
1115 } |
69278c25429d
patch 8.0.1505: debugger can't break on a condition
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
1116 |
7 | 1117 /* |
1118 * When not inside any ":while" loop, clear remembered lines. | |
1119 */ | |
72 | 1120 if (cstack.cs_looplevel == 0) |
7 | 1121 { |
1122 if (lines_ga.ga_len > 0) | |
1123 { | |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18904
diff
changeset
|
1124 SOURCING_LNUM = |
7 | 1125 ((wcmd_T *)lines_ga.ga_data)[lines_ga.ga_len - 1].lnum; |
1126 free_cmdlines(&lines_ga); | |
1127 } | |
1128 current_line = 0; | |
1129 } | |
1130 | |
1131 /* | |
72 | 1132 * A ":finally" makes did_emsg, got_int, and did_throw pending for |
1133 * being restored at the ":endtry". Reset them here and set the | |
1134 * ACTIVE and FINALLY flags, so that the finally clause gets executed. | |
1135 * This includes the case where a missing ":endif", ":endwhile" or | |
1136 * ":endfor" was detected by the ":finally" itself. | |
7 | 1137 */ |
72 | 1138 if (cstack.cs_lflags & CSL_HAD_FINA) |
1139 { | |
1140 cstack.cs_lflags &= ~CSL_HAD_FINA; | |
1141 report_make_pending(cstack.cs_pending[cstack.cs_idx] | |
1142 & (CSTP_ERROR | CSTP_INTERRUPT | CSTP_THROW), | |
7 | 1143 did_throw ? (void *)current_exception : NULL); |
1144 did_emsg = got_int = did_throw = FALSE; | |
1145 cstack.cs_flags[cstack.cs_idx] |= CSF_ACTIVE | CSF_FINALLY; | |
1146 } | |
1147 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1148 // 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
|
1149 // within this loop. |
7 | 1150 trylevel = initial_trylevel + cstack.cs_trylevel; |
1151 | |
1152 /* | |
1190 | 1153 * If the outermost try conditional (across function calls and sourced |
7 | 1154 * files) is aborted because of an error, an interrupt, or an uncaught |
1155 * exception, cancel everything. If it is left normally, reset | |
1156 * force_abort to get the non-EH compatible abortion behavior for | |
1157 * the rest of the script. | |
1158 */ | |
1159 if (trylevel == 0 && !did_emsg && !got_int && !did_throw) | |
1160 force_abort = FALSE; | |
1161 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1162 // Convert an interrupt to an exception if appropriate. |
7 | 1163 (void)do_intthrow(&cstack); |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1164 #endif // FEAT_EVAL |
7 | 1165 |
1166 } | |
1167 /* | |
1168 * Continue executing command lines when: | |
1169 * - no CTRL-C typed, no aborting error, no exception thrown or try | |
1170 * conditionals need to be checked for executing finally clauses or | |
1171 * catching an interrupt exception | |
1172 * - didn't get an error message or lines are not typed | |
72 | 1173 * - there is a command after '|', inside a :if, :while, :for or :try, or |
7 | 1174 * looping for ":source" command or function call. |
1175 */ | |
1176 while (!((got_int | |
1177 #ifdef FEAT_EVAL | |
24555
83877a1b66fd
patch 8.2.2817: Vim9: script sourcing continues after an error
Bram Moolenaar <Bram@vim.org>
parents:
24543
diff
changeset
|
1178 || (did_emsg && (force_abort || in_vim9script())) |
83877a1b66fd
patch 8.2.2817: Vim9: script sourcing continues after an error
Bram Moolenaar <Bram@vim.org>
parents:
24543
diff
changeset
|
1179 || did_throw |
7 | 1180 #endif |
1181 ) | |
1182 #ifdef FEAT_EVAL | |
1183 && cstack.cs_trylevel == 0 | |
1184 #endif | |
1185 ) | |
3757 | 1186 && !(did_emsg |
1187 #ifdef FEAT_EVAL | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1188 // 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
|
1189 // 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
|
1190 // the :endtry to be missed. |
3757 | 1191 && (cstack.cs_trylevel == 0 || did_emsg_syntax) |
1192 #endif | |
1193 && used_getline | |
2635 | 1194 && (getline_equal(fgetline, cookie, getexmodeline) |
1195 || getline_equal(fgetline, cookie, getexline))) | |
7 | 1196 && (next_cmdline != NULL |
1197 #ifdef FEAT_EVAL | |
1198 || cstack.cs_idx >= 0 | |
1199 #endif | |
1200 || (flags & DOCMD_REPEAT))); | |
1201 | |
1202 vim_free(cmdline_copy); | |
3757 | 1203 did_emsg_syntax = FALSE; |
7 | 1204 #ifdef FEAT_EVAL |
1205 free_cmdlines(&lines_ga); | |
1206 ga_clear(&lines_ga); | |
1207 | |
1208 if (cstack.cs_idx >= 0) | |
1209 { | |
1210 /* | |
1211 * If a sourced file or executed function ran to its end, report the | |
1212 * unclosed conditional. | |
24555
83877a1b66fd
patch 8.2.2817: Vim9: script sourcing continues after an error
Bram Moolenaar <Bram@vim.org>
parents:
24543
diff
changeset
|
1213 * In Vim9 script do not give a second error, executing aborts after |
83877a1b66fd
patch 8.2.2817: Vim9: script sourcing continues after an error
Bram Moolenaar <Bram@vim.org>
parents:
24543
diff
changeset
|
1214 * the first one. |
7 | 1215 */ |
24555
83877a1b66fd
patch 8.2.2817: Vim9: script sourcing continues after an error
Bram Moolenaar <Bram@vim.org>
parents:
24543
diff
changeset
|
1216 if (!got_int && !did_throw && !(did_emsg && in_vim9script()) |
2635 | 1217 && ((getline_equal(fgetline, cookie, getsourceline) |
1218 && !source_finished(fgetline, cookie)) | |
1219 || (getline_equal(fgetline, cookie, get_func_line) | |
7 | 1220 && !func_has_ended(real_cookie)))) |
1221 { | |
1222 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
|
1223 emsg(_(e_endtry)); |
7 | 1224 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
|
1225 emsg(_(e_endwhile)); |
72 | 1226 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
|
1227 emsg(_(e_endfor)); |
7 | 1228 else |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
1229 emsg(_(e_endif)); |
7 | 1230 } |
1231 | |
1232 /* | |
1233 * Reset "trylevel" in case of a ":finish" or ":return" or a missing | |
1234 * ":endtry" in a sourced file or executed function. If the try | |
1235 * conditional is in its finally clause, ignore anything pending. | |
1236 * If it is in a catch clause, finish the caught exception. | |
77 | 1237 * Also cleanup any "cs_forinfo" structures. |
7 | 1238 */ |
1239 do | |
77 | 1240 { |
1241 int idx = cleanup_conditionals(&cstack, 0, TRUE); | |
1242 | |
111 | 1243 if (idx >= 0) |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1244 --idx; // remove try block not in its finally clause |
77 | 1245 rewind_conditionals(&cstack, idx, CSF_WHILE | CSF_FOR, |
1246 &cstack.cs_looplevel); | |
1247 } | |
1248 while (cstack.cs_idx >= 0); | |
7 | 1249 trylevel = initial_trylevel; |
1250 } | |
1251 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1252 // 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
|
1253 // 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
|
1254 // exception, do this now after rewinding the cstack. |
2635 | 1255 do_errthrow(&cstack, getline_equal(fgetline, cookie, get_func_line) |
7 | 1256 ? (char_u *)"endfunction" : (char_u *)NULL); |
1257 | |
1258 if (trylevel == 0) | |
1259 { | |
22543
1722ed01c729
patch 8.2.1820: Vim9: crash when error happens in timer callback
Bram Moolenaar <Bram@vim.org>
parents:
22442
diff
changeset
|
1260 // Just in case did_throw got set but current_exception wasn't. |
1722ed01c729
patch 8.2.1820: Vim9: crash when error happens in timer callback
Bram Moolenaar <Bram@vim.org>
parents:
22442
diff
changeset
|
1261 if (current_exception == NULL) |
1722ed01c729
patch 8.2.1820: Vim9: crash when error happens in timer callback
Bram Moolenaar <Bram@vim.org>
parents:
22442
diff
changeset
|
1262 did_throw = FALSE; |
1722ed01c729
patch 8.2.1820: Vim9: crash when error happens in timer callback
Bram Moolenaar <Bram@vim.org>
parents:
22442
diff
changeset
|
1263 |
7 | 1264 /* |
1265 * When an exception is being thrown out of the outermost try | |
1266 * conditional, discard the uncaught exception, disable the conversion | |
1267 * of interrupts or errors to exceptions, and ensure that no more | |
1268 * commands are executed. | |
1269 */ | |
1270 if (did_throw) | |
1271 { | |
23616
8b6d289d182e
patch 8.2.2350: using "void" for no reason
Bram Moolenaar <Bram@vim.org>
parents:
23549
diff
changeset
|
1272 char *p = NULL; |
24369
a97fb00978f6
patch 8.2.2725: Vim9: message about compiling is wrong when using try/catch
Bram Moolenaar <Bram@vim.org>
parents:
24256
diff
changeset
|
1273 msglist_T *messages = NULL; |
7 | 1274 |
1275 /* | |
1276 * If the uncaught exception is a user exception, report it as an | |
1277 * error. If it is an error exception, display the saved error | |
1278 * message now. For an interrupt exception, do nothing; the | |
1279 * interrupt message is given elsewhere. | |
1280 */ | |
1281 switch (current_exception->type) | |
1282 { | |
1283 case ET_USER: | |
272 | 1284 vim_snprintf((char *)IObuff, IOSIZE, |
1285 _("E605: Exception not caught: %s"), | |
7 | 1286 current_exception->value); |
23616
8b6d289d182e
patch 8.2.2350: using "void" for no reason
Bram Moolenaar <Bram@vim.org>
parents:
23549
diff
changeset
|
1287 p = (char *)vim_strsave(IObuff); |
7 | 1288 break; |
1289 case ET_ERROR: | |
1290 messages = current_exception->messages; | |
1291 current_exception->messages = NULL; | |
1292 break; | |
1293 case ET_INTERRUPT: | |
1294 break; | |
1295 } | |
1296 | |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18904
diff
changeset
|
1297 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
|
1298 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
|
1299 ESTACK_CHECK_SETUP |
7 | 1300 current_exception->throw_name = NULL; |
1301 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1302 discard_current_exception(); // uses IObuff if 'verbose' |
7 | 1303 suppress_errthrow = TRUE; |
1304 force_abort = TRUE; | |
1305 | |
1306 if (messages != NULL) | |
1307 { | |
1308 do | |
1309 { | |
24369
a97fb00978f6
patch 8.2.2725: Vim9: message about compiling is wrong when using try/catch
Bram Moolenaar <Bram@vim.org>
parents:
24256
diff
changeset
|
1310 msglist_T *next = messages->next; |
a97fb00978f6
patch 8.2.2725: Vim9: message about compiling is wrong when using try/catch
Bram Moolenaar <Bram@vim.org>
parents:
24256
diff
changeset
|
1311 int save_compiling = estack_compiling; |
a97fb00978f6
patch 8.2.2725: Vim9: message about compiling is wrong when using try/catch
Bram Moolenaar <Bram@vim.org>
parents:
24256
diff
changeset
|
1312 |
a97fb00978f6
patch 8.2.2725: Vim9: message about compiling is wrong when using try/catch
Bram Moolenaar <Bram@vim.org>
parents:
24256
diff
changeset
|
1313 estack_compiling = messages->msg_compiling; |
7 | 1314 emsg(messages->msg); |
1315 vim_free(messages->msg); | |
20659
3437bf2ce2d4
patch 8.2.0883: memory leak in test 49
Bram Moolenaar <Bram@vim.org>
parents:
20645
diff
changeset
|
1316 vim_free(messages->sfile); |
7 | 1317 vim_free(messages); |
1318 messages = next; | |
24369
a97fb00978f6
patch 8.2.2725: Vim9: message about compiling is wrong when using try/catch
Bram Moolenaar <Bram@vim.org>
parents:
24256
diff
changeset
|
1319 estack_compiling = save_compiling; |
7 | 1320 } |
1321 while (messages != NULL); | |
1322 } | |
1323 else if (p != NULL) | |
1324 { | |
15490
98c35d312987
patch 8.1.0753: printf format not checked for semsg()
Bram Moolenaar <Bram@vim.org>
parents:
15488
diff
changeset
|
1325 emsg(p); |
7 | 1326 vim_free(p); |
1327 } | |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18904
diff
changeset
|
1328 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
|
1329 ESTACK_CHECK_NOW |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18904
diff
changeset
|
1330 estack_pop(); |
7 | 1331 } |
1332 | |
1333 /* | |
1334 * On an interrupt or an aborting error not converted to an exception, | |
1335 * 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
|
1336 * converted anymore, here.) This enables also the interrupt message |
7 | 1337 * when force_abort is set and did_emsg unset in case of an interrupt |
1338 * from a finally clause after an error. | |
1339 */ | |
1340 else if (got_int || (did_emsg && force_abort)) | |
1341 suppress_errthrow = TRUE; | |
1342 } | |
1343 | |
1344 /* | |
1345 * The current cstack will be freed when do_cmdline() returns. An uncaught | |
1346 * exception will have to be rethrown in the previous cstack. If a function | |
1347 * has just returned or a script file was just finished and the previous | |
1348 * cstack belongs to the same function or, respectively, script file, it | |
1349 * will have to be checked for finally clauses to be executed due to the | |
1350 * ":return" or ":finish". This is done in do_one_cmd(). | |
1351 */ | |
1352 if (did_throw) | |
1353 need_rethrow = TRUE; | |
2635 | 1354 if ((getline_equal(fgetline, cookie, getsourceline) |
7 | 1355 && ex_nesting_level > source_level(real_cookie)) |
2635 | 1356 || (getline_equal(fgetline, cookie, get_func_line) |
7 | 1357 && ex_nesting_level > func_level(real_cookie) + 1)) |
1358 { | |
1359 if (!did_throw) | |
1360 check_cstack = TRUE; | |
1361 } | |
1362 else | |
1363 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1364 // When leaving a function, reduce nesting level. |
2635 | 1365 if (getline_equal(fgetline, cookie, get_func_line)) |
7 | 1366 --ex_nesting_level; |
1367 /* | |
1368 * Go to debug mode when returning from a function in which we are | |
1369 * single-stepping. | |
1370 */ | |
2635 | 1371 if ((getline_equal(fgetline, cookie, getsourceline) |
1372 || getline_equal(fgetline, cookie, get_func_line)) | |
7 | 1373 && ex_nesting_level + 1 <= debug_break_level) |
2635 | 1374 do_debug(getline_equal(fgetline, cookie, getsourceline) |
7 | 1375 ? (char_u *)_("End of sourced file") |
1376 : (char_u *)_("End of function")); | |
1377 } | |
1378 | |
1379 /* | |
1380 * Restore the exception environment (done after returning from the | |
1381 * debugger). | |
1382 */ | |
1383 if (flags & DOCMD_EXCRESET) | |
8 | 1384 restore_dbg_stuff(&debug_saved); |
7 | 1385 |
1386 msg_list = saved_msg_list; | |
19685
d64f403289db
patch 8.2.0399: various memory leaks
Bram Moolenaar <Bram@vim.org>
parents:
19621
diff
changeset
|
1387 |
d64f403289db
patch 8.2.0399: various memory leaks
Bram Moolenaar <Bram@vim.org>
parents:
19621
diff
changeset
|
1388 // Cleanup if "cs_emsg_silent_list" remains. |
d64f403289db
patch 8.2.0399: various memory leaks
Bram Moolenaar <Bram@vim.org>
parents:
19621
diff
changeset
|
1389 if (cstack.cs_emsg_silent_list != NULL) |
d64f403289db
patch 8.2.0399: various memory leaks
Bram Moolenaar <Bram@vim.org>
parents:
19621
diff
changeset
|
1390 { |
d64f403289db
patch 8.2.0399: various memory leaks
Bram Moolenaar <Bram@vim.org>
parents:
19621
diff
changeset
|
1391 eslist_T *elem, *temp; |
d64f403289db
patch 8.2.0399: various memory leaks
Bram Moolenaar <Bram@vim.org>
parents:
19621
diff
changeset
|
1392 |
d64f403289db
patch 8.2.0399: various memory leaks
Bram Moolenaar <Bram@vim.org>
parents:
19621
diff
changeset
|
1393 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
|
1394 { |
d64f403289db
patch 8.2.0399: various memory leaks
Bram Moolenaar <Bram@vim.org>
parents:
19621
diff
changeset
|
1395 temp = elem->next; |
d64f403289db
patch 8.2.0399: various memory leaks
Bram Moolenaar <Bram@vim.org>
parents:
19621
diff
changeset
|
1396 vim_free(elem); |
d64f403289db
patch 8.2.0399: various memory leaks
Bram Moolenaar <Bram@vim.org>
parents:
19621
diff
changeset
|
1397 } |
d64f403289db
patch 8.2.0399: various memory leaks
Bram Moolenaar <Bram@vim.org>
parents:
19621
diff
changeset
|
1398 } |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1399 #endif // FEAT_EVAL |
7 | 1400 |
1401 /* | |
1402 * If there was too much output to fit on the command line, ask the user to | |
1403 * hit return before redrawing the screen. With the ":global" command we do | |
1404 * this only once after the command is finished. | |
1405 */ | |
1406 if (did_inc) | |
1407 { | |
1408 --RedrawingDisabled; | |
1409 --no_wait_return; | |
1410 msg_scroll = FALSE; | |
1411 | |
1412 /* | |
1413 * When just finished an ":if"-":else" which was typed, no need to | |
1414 * wait for hit-return. Also for an error situation. | |
1415 */ | |
1416 if (retval == FAIL | |
1417 #ifdef FEAT_EVAL | |
1418 || (did_endif && KeyTyped && !did_emsg) | |
1419 #endif | |
1420 ) | |
1421 { | |
1422 need_wait_return = FALSE; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1423 msg_didany = FALSE; // don't wait when restarting edit |
7 | 1424 } |
1425 else if (need_wait_return) | |
1426 { | |
1427 /* | |
1428 * The msg_start() above clears msg_didout. The wait_return we do | |
1429 * here should not overwrite the command that may be shown before | |
1430 * doing that. | |
1431 */ | |
1432 msg_didout |= msg_didout_before_start; | |
1433 wait_return(FALSE); | |
1434 } | |
1435 } | |
1436 | |
3976 | 1437 #ifdef FEAT_EVAL |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1438 did_endif = FALSE; // in case do_cmdline used recursively |
3976 | 1439 #else |
7 | 1440 /* |
1441 * Reset if_level, in case a sourced script file contains more ":if" than | |
1442 * ":endif" (could be ":if x | foo | endif"). | |
1443 */ | |
1444 if_level = 0; | |
3972 | 1445 #endif |
3963 | 1446 |
7 | 1447 --call_depth; |
1448 return retval; | |
1449 } | |
1450 | |
1451 #ifdef FEAT_EVAL | |
1452 /* | |
72 | 1453 * Obtain a line when inside a ":while" or ":for" loop. |
7 | 1454 */ |
1455 static char_u * | |
21885
72525eabfe61
patch 8.2.1492: build failures
Bram Moolenaar <Bram@vim.org>
parents:
21883
diff
changeset
|
1456 get_loop_line(int c, void *cookie, int indent, getline_opt_T options) |
7 | 1457 { |
72 | 1458 struct loop_cookie *cp = (struct loop_cookie *)cookie; |
7 | 1459 wcmd_T *wp; |
1460 char_u *line; | |
1461 | |
1462 if (cp->current_line + 1 >= cp->lines_gap->ga_len) | |
1463 { | |
1464 if (cp->repeating) | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1465 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
|
1466 |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1467 // First time inside the ":while"/":for": get line normally. |
7 | 1468 if (cp->getline == NULL) |
21885
72525eabfe61
patch 8.2.1492: build failures
Bram Moolenaar <Bram@vim.org>
parents:
21883
diff
changeset
|
1469 line = getcmdline(c, 0L, indent, options); |
7 | 1470 else |
21885
72525eabfe61
patch 8.2.1492: build failures
Bram Moolenaar <Bram@vim.org>
parents:
21883
diff
changeset
|
1471 line = cp->getline(c, cp->cookie, indent, options); |
857 | 1472 if (line != NULL && store_loop_line(cp->lines_gap, line) == OK) |
7 | 1473 ++cp->current_line; |
1474 | |
1475 return line; | |
1476 } | |
1477 | |
1478 KeyTyped = FALSE; | |
1479 ++cp->current_line; | |
1480 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
|
1481 SOURCING_LNUM = wp->lnum; |
7 | 1482 return vim_strsave(wp->line); |
1483 } | |
1484 | |
1485 /* | |
1486 * Store a line in "gap" so that a ":while" loop can execute it again. | |
1487 */ | |
1488 static int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
1489 store_loop_line(garray_T *gap, char_u *line) |
7 | 1490 { |
1491 if (ga_grow(gap, 1) == FAIL) | |
1492 return FAIL; | |
1493 ((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
|
1494 ((wcmd_T *)(gap->ga_data))[gap->ga_len].lnum = SOURCING_LNUM; |
7 | 1495 ++gap->ga_len; |
1496 return OK; | |
1497 } | |
1498 | |
1499 /* | |
72 | 1500 * Free the lines stored for a ":while" or ":for" loop. |
7 | 1501 */ |
1502 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
1503 free_cmdlines(garray_T *gap) |
7 | 1504 { |
1505 while (gap->ga_len > 0) | |
1506 { | |
1507 vim_free(((wcmd_T *)(gap->ga_data))[gap->ga_len - 1].line); | |
1508 --gap->ga_len; | |
1509 } | |
1510 } | |
1511 #endif | |
1512 | |
1513 /* | |
944 | 1514 * If "fgetline" is get_loop_line(), return TRUE if the getline it uses equals |
1515 * "func". * Otherwise return TRUE when "fgetline" equals "func". | |
7 | 1516 */ |
1517 int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
1518 getline_equal( |
21883
a427f5f26419
patch 8.2.1491: Vim9: crash when compiling heredoc lines start with comment
Bram Moolenaar <Bram@vim.org>
parents:
21845
diff
changeset
|
1519 char_u *(*fgetline)(int, void *, int, getline_opt_T), |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1520 void *cookie UNUSED, // argument for fgetline() |
21883
a427f5f26419
patch 8.2.1491: Vim9: crash when compiling heredoc lines start with comment
Bram Moolenaar <Bram@vim.org>
parents:
21845
diff
changeset
|
1521 char_u *(*func)(int, void *, int, getline_opt_T)) |
7 | 1522 { |
1523 #ifdef FEAT_EVAL | |
21885
72525eabfe61
patch 8.2.1492: build failures
Bram Moolenaar <Bram@vim.org>
parents:
21883
diff
changeset
|
1524 char_u *(*gp)(int, void *, int, getline_opt_T); |
72 | 1525 struct loop_cookie *cp; |
1526 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1527 // 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
|
1528 // 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
|
1529 // nested several levels. |
944 | 1530 gp = fgetline; |
72 | 1531 cp = (struct loop_cookie *)cookie; |
1532 while (gp == get_loop_line) | |
7 | 1533 { |
1534 gp = cp->getline; | |
1535 cp = cp->cookie; | |
1536 } | |
1537 return gp == func; | |
1538 #else | |
944 | 1539 return fgetline == func; |
7 | 1540 #endif |
1541 } | |
1542 | |
1543 /* | |
944 | 1544 * If "fgetline" is get_loop_line(), return the cookie used by the original |
7 | 1545 * getline function. Otherwise return "cookie". |
1546 */ | |
1547 void * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
1548 getline_cookie( |
21883
a427f5f26419
patch 8.2.1491: Vim9: crash when compiling heredoc lines start with comment
Bram Moolenaar <Bram@vim.org>
parents:
21845
diff
changeset
|
1549 char_u *(*fgetline)(int, void *, int, getline_opt_T) UNUSED, |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1550 void *cookie) // argument for fgetline() |
7 | 1551 { |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
1552 #ifdef FEAT_EVAL |
21885
72525eabfe61
patch 8.2.1492: build failures
Bram Moolenaar <Bram@vim.org>
parents:
21883
diff
changeset
|
1553 char_u *(*gp)(int, void *, int, getline_opt_T); |
21056
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1554 struct loop_cookie *cp; |
72 | 1555 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1556 // 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
|
1557 // 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
|
1558 // several levels. |
944 | 1559 gp = fgetline; |
72 | 1560 cp = (struct loop_cookie *)cookie; |
1561 while (gp == get_loop_line) | |
7 | 1562 { |
1563 gp = cp->getline; | |
1564 cp = cp->cookie; | |
1565 } | |
1566 return cp; | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
1567 #else |
7 | 1568 return cookie; |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
1569 #endif |
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
1570 } |
7 | 1571 |
21056
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1572 #if defined(FEAT_EVAL) || defined(PROT) |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1573 /* |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1574 * Get the next line source line without advancing. |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1575 */ |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1576 char_u * |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1577 getline_peek( |
21883
a427f5f26419
patch 8.2.1491: Vim9: crash when compiling heredoc lines start with comment
Bram Moolenaar <Bram@vim.org>
parents:
21845
diff
changeset
|
1578 char_u *(*fgetline)(int, void *, int, getline_opt_T) UNUSED, |
21056
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1579 void *cookie) // argument for fgetline() |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1580 { |
21885
72525eabfe61
patch 8.2.1492: build failures
Bram Moolenaar <Bram@vim.org>
parents:
21883
diff
changeset
|
1581 char_u *(*gp)(int, void *, int, getline_opt_T); |
21056
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1582 struct loop_cookie *cp; |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1583 wcmd_T *wp; |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1584 |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1585 // When "fgetline" is "get_loop_line()" use the "cookie" to find the |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1586 // cookie that's originally used to obtain the lines. This may be nested |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1587 // several levels. |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1588 gp = fgetline; |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1589 cp = (struct loop_cookie *)cookie; |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1590 while (gp == get_loop_line) |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1591 { |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1592 if (cp->current_line + 1 < cp->lines_gap->ga_len) |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1593 { |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1594 // executing lines a second time, use the stored copy |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1595 wp = (wcmd_T *)(cp->lines_gap->ga_data) + cp->current_line + 1; |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1596 return wp->line; |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1597 } |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1598 gp = cp->getline; |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1599 cp = cp->cookie; |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1600 } |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1601 if (gp == getsourceline) |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1602 return source_nextline(cp); |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1603 return NULL; |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1604 } |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1605 #endif |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1606 |
6398 | 1607 |
1608 /* | |
1609 * Helper function to apply an offset for buffer commands, i.e. ":bdelete", | |
1610 * ":bwipeout", etc. | |
1611 * Returns the buffer number. | |
1612 */ | |
1613 static int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
1614 compute_buffer_local_count(int addr_type, int lnum, int offset) |
6398 | 1615 { |
1616 buf_T *buf; | |
6417 | 1617 buf_T *nextbuf; |
6398 | 1618 int count = offset; |
1619 | |
1620 buf = firstbuf; | |
1621 while (buf->b_next != NULL && buf->b_fnum < lnum) | |
1622 buf = buf->b_next; | |
1623 while (count != 0) | |
1624 { | |
6417 | 1625 count += (offset < 0) ? 1 : -1; |
1626 nextbuf = (offset < 0) ? buf->b_prev : buf->b_next; | |
1627 if (nextbuf == NULL) | |
6398 | 1628 break; |
6417 | 1629 buf = nextbuf; |
6398 | 1630 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
|
1631 // skip over unloaded buffers |
6417 | 1632 while (buf->b_ml.ml_mfp == NULL) |
1633 { | |
1634 nextbuf = (offset < 0) ? buf->b_prev : buf->b_next; | |
1635 if (nextbuf == NULL) | |
1636 break; | |
1637 buf = nextbuf; | |
1638 } | |
1639 } | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1640 // we might have gone too far, last buffer is not loadedd |
6417 | 1641 if (addr_type == ADDR_LOADED_BUFFERS) |
1642 while (buf->b_ml.ml_mfp == NULL) | |
1643 { | |
1644 nextbuf = (offset >= 0) ? buf->b_prev : buf->b_next; | |
1645 if (nextbuf == NULL) | |
1646 break; | |
1647 buf = nextbuf; | |
1648 } | |
6398 | 1649 return buf->b_fnum; |
1650 } | |
1651 | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
1652 /* |
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
1653 * 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
|
1654 * 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
|
1655 */ |
6409 | 1656 static int |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
1657 current_win_nr(win_T *win) |
6409 | 1658 { |
1659 win_T *wp; | |
1660 int nr = 0; | |
1661 | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9538
diff
changeset
|
1662 FOR_ALL_WINDOWS(wp) |
6409 | 1663 { |
1664 ++nr; | |
1665 if (wp == win) | |
1666 break; | |
1667 } | |
1668 return nr; | |
1669 } | |
1670 | |
1671 static int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
1672 current_tab_nr(tabpage_T *tab) |
6409 | 1673 { |
1674 tabpage_T *tp; | |
1675 int nr = 0; | |
1676 | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9538
diff
changeset
|
1677 FOR_ALL_TABPAGES(tp) |
6409 | 1678 { |
1679 ++nr; | |
1680 if (tp == tab) | |
1681 break; | |
1682 } | |
1683 return nr; | |
1684 } | |
1685 | |
21357
72bf1b368cfe
patch 8.2.1229: build error without the eval feature
Bram Moolenaar <Bram@vim.org>
parents:
21353
diff
changeset
|
1686 static int |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21335
diff
changeset
|
1687 comment_start(char_u *p, int starts_with_colon UNUSED) |
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21335
diff
changeset
|
1688 { |
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21335
diff
changeset
|
1689 #ifdef FEAT_EVAL |
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21335
diff
changeset
|
1690 if (in_vim9script()) |
23179
821701ecbde7
patch 8.2.2135: Vim9: #{ still seen as start of dict in some places
Bram Moolenaar <Bram@vim.org>
parents:
23171
diff
changeset
|
1691 return p[0] == '#' && !starts_with_colon; |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21335
diff
changeset
|
1692 #endif |
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21335
diff
changeset
|
1693 return *p == '"'; |
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21335
diff
changeset
|
1694 } |
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21335
diff
changeset
|
1695 |
6409 | 1696 # define CURRENT_WIN_NR current_win_nr(curwin) |
1697 # define LAST_WIN_NR current_win_nr(NULL) | |
1698 # define CURRENT_TAB_NR current_tab_nr(curtab) | |
1699 # define LAST_TAB_NR current_tab_nr(NULL) | |
6398 | 1700 |
7 | 1701 /* |
1702 * Execute one Ex command. | |
1703 * | |
23011
ec23d84a096d
patch 8.2.2052: Vim9: "edit +4 fname" gives an error
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
1704 * If "flags" has DOCMD_VERBOSE, the command will be included in the error |
ec23d84a096d
patch 8.2.2052: Vim9: "edit +4 fname" gives an error
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
1705 * message. |
7 | 1706 * |
1707 * 1. skip comment lines and leading space | |
1708 * 2. handle command modifiers | |
6400 | 1709 * 3. find the command |
6398 | 1710 * 4. parse range |
6400 | 1711 * 5. Parse the command. |
6398 | 1712 * 6. parse arguments |
1713 * 7. switch on command name | |
7 | 1714 * |
944 | 1715 * Note: "fgetline" can be NULL. |
7 | 1716 * |
1717 * This function may be called recursively! | |
1718 */ | |
1719 #if (_MSC_VER == 1200) | |
1720 /* | |
8 | 1721 * Avoid optimisation bug in VC++ version 6.0 |
7 | 1722 */ |
128 | 1723 #pragma optimize( "g", off ) |
7 | 1724 #endif |
1725 static char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
1726 do_one_cmd( |
18904
2bdc2e1f6e1f
patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents:
18849
diff
changeset
|
1727 char_u **cmdlinep, |
23011
ec23d84a096d
patch 8.2.2052: Vim9: "edit +4 fname" gives an error
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
1728 int flags, |
7 | 1729 #ifdef FEAT_EVAL |
18904
2bdc2e1f6e1f
patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents:
18849
diff
changeset
|
1730 cstack_T *cstack, |
2bdc2e1f6e1f
patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents:
18849
diff
changeset
|
1731 #endif |
21885
72525eabfe61
patch 8.2.1492: build failures
Bram Moolenaar <Bram@vim.org>
parents:
21883
diff
changeset
|
1732 char_u *(*fgetline)(int, void *, int, getline_opt_T), |
18904
2bdc2e1f6e1f
patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents:
18849
diff
changeset
|
1733 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
|
1734 { |
2bdc2e1f6e1f
patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents:
18849
diff
changeset
|
1735 char_u *p; |
2bdc2e1f6e1f
patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents:
18849
diff
changeset
|
1736 linenr_T lnum; |
2bdc2e1f6e1f
patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents:
18849
diff
changeset
|
1737 long n; |
2bdc2e1f6e1f
patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents:
18849
diff
changeset
|
1738 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
|
1739 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
|
1740 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
|
1741 cmdmod_T save_cmdmod; |
2bdc2e1f6e1f
patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents:
18849
diff
changeset
|
1742 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
|
1743 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
|
1744 char_u *cmd; |
21357
72bf1b368cfe
patch 8.2.1229: build error without the eval feature
Bram Moolenaar <Bram@vim.org>
parents:
21353
diff
changeset
|
1745 int starts_with_colon = FALSE; |
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
|
1746 #ifdef FEAT_EVAL |
21526
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
1747 int may_have_range; |
23938
2a885d095bff
patch 8.2.2511: Vim9: cannot use Vim9 script syntax in some places
Bram Moolenaar <Bram@vim.org>
parents:
23884
diff
changeset
|
1748 int vim9script; |
22732
4c21a3a47707
patch 8.2.1914: Vim9: cannot put line break in expression for '=' register
Bram Moolenaar <Bram@vim.org>
parents:
22724
diff
changeset
|
1749 int did_set_expr_line = FALSE; |
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
|
1750 #endif |
23011
ec23d84a096d
patch 8.2.2052: Vim9: "edit +4 fname" gives an error
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
1751 int sourcing = flags & DOCMD_VERBOSE; |
7 | 1752 |
20007
aadd1cae2ff5
patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
1753 CLEAR_FIELD(ea); |
7 | 1754 ea.line1 = 1; |
1755 ea.line2 = 1; | |
1756 #ifdef FEAT_EVAL | |
1757 ++ex_nesting_level; | |
1758 #endif | |
1759 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1760 // When the last file has not been edited :q has to be typed twice. |
7 | 1761 if (quitmore |
1762 #ifdef FEAT_EVAL | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1763 // avoid that a function call in 'statusline' does this |
944 | 1764 && !getline_equal(fgetline, cookie, get_func_line) |
4133 | 1765 #endif |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1766 // 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
|
1767 && !getline_equal(fgetline, cookie, getnextac)) |
7 | 1768 --quitmore; |
1769 | |
1770 /* | |
1771 * Reset browse, confirm, etc.. They are restored when returning, for | |
1772 * recursive calls. | |
1773 */ | |
1774 save_cmdmod = cmdmod; | |
1775 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1776 // "#!anything" is handled like a comment. |
930 | 1777 if ((*cmdlinep)[0] == '#' && (*cmdlinep)[1] == '!') |
1778 goto doend; | |
1779 | |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
1780 /* |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
1781 * 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
|
1782 * 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
|
1783 */ |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
1784 // The "ea" structure holds the arguments that can be used. |
7 | 1785 ea.cmd = *cmdlinep; |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
1786 ea.cmdlinep = cmdlinep; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
1787 ea.getline = fgetline; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
1788 ea.cookie = cookie; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
1789 #ifdef FEAT_EVAL |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
1790 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
|
1791 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
|
1792 #endif |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
1793 if (parse_command_modifiers(&ea, &errormsg, &cmdmod, FALSE) == FAIL) |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
1794 goto doend; |
22697
c996700d569f
patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents:
22693
diff
changeset
|
1795 apply_cmdmod(&cmdmod); |
23944
6e593e0aaadf
patch 8.2.2514: Vim9: build error in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
23938
diff
changeset
|
1796 #ifdef FEAT_EVAL |
23938
2a885d095bff
patch 8.2.2511: Vim9: cannot use Vim9 script syntax in some places
Bram Moolenaar <Bram@vim.org>
parents:
23884
diff
changeset
|
1797 vim9script = in_vim9script(); |
23944
6e593e0aaadf
patch 8.2.2514: Vim9: build error in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
23938
diff
changeset
|
1798 #endif |
9941
e975914c17e9
commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
9927
diff
changeset
|
1799 after_modifier = ea.cmd; |
7 | 1800 |
1801 #ifdef FEAT_EVAL | |
1802 ea.skip = did_emsg || got_int || did_throw || (cstack->cs_idx >= 0 | |
1803 && !(cstack->cs_flags[cstack->cs_idx] & CSF_ACTIVE)); | |
1804 #else | |
1805 ea.skip = (if_level > 0); | |
1806 #endif | |
1807 | |
1808 /* | |
6398 | 1809 * 3. Skip over the range to find the command. Let "p" point to after it. |
1810 * | |
1811 * We need the command to know what kind of range it uses. | |
1812 */ | |
1813 cmd = ea.cmd; | |
21335
af3663df42bf
patch 8.2.1218: Vim9: cannot use 'text'->func()
Bram Moolenaar <Bram@vim.org>
parents:
21279
diff
changeset
|
1814 #ifdef FEAT_EVAL |
22772
82a7aff951d2
patch 8.2.1934: Vim9: command modifiers in :def function not tested
Bram Moolenaar <Bram@vim.org>
parents:
22750
diff
changeset
|
1815 // In Vim9 script a colon is required before the range. This may also be |
82a7aff951d2
patch 8.2.1934: Vim9: command modifiers in :def function not tested
Bram Moolenaar <Bram@vim.org>
parents:
22750
diff
changeset
|
1816 // after command modifiers. |
23011
ec23d84a096d
patch 8.2.2052: Vim9: "edit +4 fname" gives an error
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
1817 if (vim9script && (flags & DOCMD_RANGEOK) == 0) |
22772
82a7aff951d2
patch 8.2.1934: Vim9: command modifiers in :def function not tested
Bram Moolenaar <Bram@vim.org>
parents:
22750
diff
changeset
|
1818 { |
82a7aff951d2
patch 8.2.1934: Vim9: command modifiers in :def function not tested
Bram Moolenaar <Bram@vim.org>
parents:
22750
diff
changeset
|
1819 may_have_range = FALSE; |
82a7aff951d2
patch 8.2.1934: Vim9: command modifiers in :def function not tested
Bram Moolenaar <Bram@vim.org>
parents:
22750
diff
changeset
|
1820 for (p = ea.cmd; p >= *cmdlinep; --p) |
82a7aff951d2
patch 8.2.1934: Vim9: command modifiers in :def function not tested
Bram Moolenaar <Bram@vim.org>
parents:
22750
diff
changeset
|
1821 { |
82a7aff951d2
patch 8.2.1934: Vim9: command modifiers in :def function not tested
Bram Moolenaar <Bram@vim.org>
parents:
22750
diff
changeset
|
1822 if (*p == ':') |
82a7aff951d2
patch 8.2.1934: Vim9: command modifiers in :def function not tested
Bram Moolenaar <Bram@vim.org>
parents:
22750
diff
changeset
|
1823 may_have_range = TRUE; |
82a7aff951d2
patch 8.2.1934: Vim9: command modifiers in :def function not tested
Bram Moolenaar <Bram@vim.org>
parents:
22750
diff
changeset
|
1824 if (p < ea.cmd && !VIM_ISWHITE(*p)) |
82a7aff951d2
patch 8.2.1934: Vim9: command modifiers in :def function not tested
Bram Moolenaar <Bram@vim.org>
parents:
22750
diff
changeset
|
1825 break; |
82a7aff951d2
patch 8.2.1934: Vim9: command modifiers in :def function not tested
Bram Moolenaar <Bram@vim.org>
parents:
22750
diff
changeset
|
1826 } |
82a7aff951d2
patch 8.2.1934: Vim9: command modifiers in :def function not tested
Bram Moolenaar <Bram@vim.org>
parents:
22750
diff
changeset
|
1827 } |
82a7aff951d2
patch 8.2.1934: Vim9: command modifiers in :def function not tested
Bram Moolenaar <Bram@vim.org>
parents:
22750
diff
changeset
|
1828 else |
82a7aff951d2
patch 8.2.1934: Vim9: command modifiers in :def function not tested
Bram Moolenaar <Bram@vim.org>
parents:
22750
diff
changeset
|
1829 may_have_range = TRUE; |
21526
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
1830 if (may_have_range) |
21335
af3663df42bf
patch 8.2.1218: Vim9: cannot use 'text'->func()
Bram Moolenaar <Bram@vim.org>
parents:
21279
diff
changeset
|
1831 #endif |
22260
d7c1e3efa88e
patch 8.2.1679: Vim9: ":*" is not recognized as a range
Bram Moolenaar <Bram@vim.org>
parents:
22208
diff
changeset
|
1832 ea.cmd = skip_range(ea.cmd, TRUE, NULL); |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
1833 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
1834 #ifdef FEAT_EVAL |
22772
82a7aff951d2
patch 8.2.1934: Vim9: command modifiers in :def function not tested
Bram Moolenaar <Bram@vim.org>
parents:
22750
diff
changeset
|
1835 if (vim9script && !may_have_range) |
20982
bb49b5090a9c
patch 8.2.1042: Vim9: cannot put an operator on the next line
Bram Moolenaar <Bram@vim.org>
parents:
20897
diff
changeset
|
1836 { |
21526
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
1837 if (ea.cmd == cmd + 1 && *cmd == '$') |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
1838 // should be "$VAR = val" |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
1839 --ea.cmd; |
24049
fc4c2beea99a
patch 8.2.2566: Vim9: Function name is not recognized
Bram Moolenaar <Bram@vim.org>
parents:
23978
diff
changeset
|
1840 p = find_ex_command(&ea, NULL, lookup_scriptitem, NULL); |
22790
44317eb799d7
patch 8.2.1943: Vim9: wrong error message when colon is missing
Bram Moolenaar <Bram@vim.org>
parents:
22772
diff
changeset
|
1841 if (ea.cmdidx == CMD_SIZE) |
44317eb799d7
patch 8.2.1943: Vim9: wrong error message when colon is missing
Bram Moolenaar <Bram@vim.org>
parents:
22772
diff
changeset
|
1842 { |
44317eb799d7
patch 8.2.1943: Vim9: wrong error message when colon is missing
Bram Moolenaar <Bram@vim.org>
parents:
22772
diff
changeset
|
1843 char_u *ar = skip_range(ea.cmd, TRUE, NULL); |
44317eb799d7
patch 8.2.1943: Vim9: wrong error message when colon is missing
Bram Moolenaar <Bram@vim.org>
parents:
22772
diff
changeset
|
1844 |
44317eb799d7
patch 8.2.1943: Vim9: wrong error message when colon is missing
Bram Moolenaar <Bram@vim.org>
parents:
22772
diff
changeset
|
1845 // If a ':' before the range is missing, give a clearer error |
44317eb799d7
patch 8.2.1943: Vim9: wrong error message when colon is missing
Bram Moolenaar <Bram@vim.org>
parents:
22772
diff
changeset
|
1846 // message. |
24934
75bd12f3bfeb
patch 8.2.3004: Vim9: error for missing colon given while skipping
Bram Moolenaar <Bram@vim.org>
parents:
24846
diff
changeset
|
1847 if (ar > ea.cmd && !ea.skip) |
22790
44317eb799d7
patch 8.2.1943: Vim9: wrong error message when colon is missing
Bram Moolenaar <Bram@vim.org>
parents:
22772
diff
changeset
|
1848 { |
23346
2060f53b7c17
patch 8.2.2216: Vim9: range with missing colon can be hard to spot
Bram Moolenaar <Bram@vim.org>
parents:
23342
diff
changeset
|
1849 semsg(_(e_colon_required_before_range_str), ea.cmd); |
22790
44317eb799d7
patch 8.2.1943: Vim9: wrong error message when colon is missing
Bram Moolenaar <Bram@vim.org>
parents:
22772
diff
changeset
|
1850 goto doend; |
44317eb799d7
patch 8.2.1943: Vim9: wrong error message when colon is missing
Bram Moolenaar <Bram@vim.org>
parents:
22772
diff
changeset
|
1851 } |
44317eb799d7
patch 8.2.1943: Vim9: wrong error message when colon is missing
Bram Moolenaar <Bram@vim.org>
parents:
22772
diff
changeset
|
1852 } |
20982
bb49b5090a9c
patch 8.2.1042: Vim9: cannot put an operator on the next line
Bram Moolenaar <Bram@vim.org>
parents:
20897
diff
changeset
|
1853 } |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
1854 else |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
1855 #endif |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
1856 p = find_ex_command(&ea, NULL, NULL, NULL); |
6398 | 1857 |
14591
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1858 #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
|
1859 # 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
|
1860 // 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
|
1861 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
|
1862 && (!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
|
1863 && (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
|
1864 { |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1865 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
|
1866 |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1867 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
|
1868 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
|
1869 && (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
|
1870 && !(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
|
1871 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
|
1872 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
|
1873 && !(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
|
1874 & (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
|
1875 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
|
1876 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
|
1877 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
|
1878 && 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
|
1879 && 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
|
1880 && 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
|
1881 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
|
1882 |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1883 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
|
1884 { |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1885 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
|
1886 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
|
1887 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
|
1888 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
|
1889 } |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1890 } |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1891 # endif |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1892 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1893 // 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
|
1894 // 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
|
1895 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
|
1896 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
|
1897 { |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1898 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
|
1899 (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
|
1900 } |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1901 #endif |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1902 |
6398 | 1903 /* |
1904 * 4. parse a range specifier of the form: addr [,addr] [;addr] .. | |
7 | 1905 * |
1906 * where 'addr' is: | |
1907 * | |
1908 * % (entire file) | |
1909 * $ [+-NUM] | |
1910 * 'x [+-NUM] (where x denotes a currently defined mark) | |
1911 * . [+-NUM] | |
1912 * [+-NUM].. | |
1913 * NUM | |
1914 * | |
1915 * The ea.cmd pointer is updated to point to the first character following the | |
1916 * range spec. If an initial address is found, but no second, the upper bound | |
1917 * is equal to the lower. | |
1918 */ | |
1919 | |
16515
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
1920 // ea.addr_type for user commands is set by find_ucmd |
6489 | 1921 if (!IS_USER_CMDIDX(ea.cmdidx)) |
1922 { | |
1923 if (ea.cmdidx != CMD_SIZE) | |
1924 ea.addr_type = cmdnames[(int)ea.cmdidx].cmd_addr_type; | |
1925 else | |
1926 ea.addr_type = ADDR_LINES; | |
1927 | |
16515
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
1928 // :wincmd range depends on the argument. |
6506 | 1929 if (ea.cmdidx == CMD_wincmd && p != NULL) |
1930 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
|
1931 #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
|
1932 // :.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
|
1933 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
|
1934 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
|
1935 #endif |
6489 | 1936 } |
6398 | 1937 |
6489 | 1938 ea.cmd = cmd; |
21335
af3663df42bf
patch 8.2.1218: Vim9: cannot use 'text'->func()
Bram Moolenaar <Bram@vim.org>
parents:
21279
diff
changeset
|
1939 #ifdef FEAT_EVAL |
21939
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
1940 if (!may_have_range) |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
1941 ea.line1 = ea.line2 = default_address(&ea); |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
1942 else |
21335
af3663df42bf
patch 8.2.1218: Vim9: cannot use 'text'->func()
Bram Moolenaar <Bram@vim.org>
parents:
21279
diff
changeset
|
1943 #endif |
af3663df42bf
patch 8.2.1218: Vim9: cannot use 'text'->func()
Bram Moolenaar <Bram@vim.org>
parents:
21279
diff
changeset
|
1944 if (parse_cmd_address(&ea, &errormsg, FALSE) == FAIL) |
af3663df42bf
patch 8.2.1218: Vim9: cannot use 'text'->func()
Bram Moolenaar <Bram@vim.org>
parents:
21279
diff
changeset
|
1945 goto doend; |
7 | 1946 |
1947 /* | |
6398 | 1948 * 5. Parse the command. |
7 | 1949 */ |
1950 | |
1951 /* | |
1952 * Skip ':' and any white space | |
1953 */ | |
1954 ea.cmd = skipwhite(ea.cmd); | |
1955 while (*ea.cmd == ':') | |
1956 ea.cmd = skipwhite(ea.cmd + 1); | |
1957 | |
1958 /* | |
1959 * If we got a line, but no command, then go to the line. | |
1960 * If we find a '|' or '\n' we set ea.nextcmd. | |
1961 */ | |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21335
diff
changeset
|
1962 if (*ea.cmd == NUL || comment_start(ea.cmd, starts_with_colon) |
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21335
diff
changeset
|
1963 || (ea.nextcmd = check_nextcmd(ea.cmd)) != NULL) |
7 | 1964 { |
1965 /* | |
1966 * strange vi behaviour: | |
1967 * ":3" jumps to line 3 | |
23954
9c8a20cfa540
patch 8.2.2519: Vim9: no reason to keep strange Vi behavior
Bram Moolenaar <Bram@vim.org>
parents:
23944
diff
changeset
|
1968 * ":3|..." prints line 3 (not in Vim9 script) |
9c8a20cfa540
patch 8.2.2519: Vim9: no reason to keep strange Vi behavior
Bram Moolenaar <Bram@vim.org>
parents:
23944
diff
changeset
|
1969 * ":|" prints current line (not in Vim9 script) |
7 | 1970 */ |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1971 if (ea.skip) // skip this if inside :if |
7 | 1972 goto doend; |
23954
9c8a20cfa540
patch 8.2.2519: Vim9: no reason to keep strange Vi behavior
Bram Moolenaar <Bram@vim.org>
parents:
23944
diff
changeset
|
1973 if ((*ea.cmd == '|' || (exmode_active && ea.line1 != ea.line2)) |
9c8a20cfa540
patch 8.2.2519: Vim9: no reason to keep strange Vi behavior
Bram Moolenaar <Bram@vim.org>
parents:
23944
diff
changeset
|
1974 #ifdef FEAT_EVAL |
9c8a20cfa540
patch 8.2.2519: Vim9: no reason to keep strange Vi behavior
Bram Moolenaar <Bram@vim.org>
parents:
23944
diff
changeset
|
1975 && !vim9script |
9c8a20cfa540
patch 8.2.2519: Vim9: no reason to keep strange Vi behavior
Bram Moolenaar <Bram@vim.org>
parents:
23944
diff
changeset
|
1976 #endif |
9c8a20cfa540
patch 8.2.2519: Vim9: no reason to keep strange Vi behavior
Bram Moolenaar <Bram@vim.org>
parents:
23944
diff
changeset
|
1977 ) |
7 | 1978 { |
1979 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
|
1980 ea.argt = EX_RANGE+EX_COUNT+EX_TRLBAR; |
7 | 1981 if ((errormsg = invalid_range(&ea)) == NULL) |
1982 { | |
1983 correct_range(&ea); | |
1984 ex_print(&ea); | |
1985 } | |
1986 } | |
1987 else if (ea.addr_count != 0) | |
1988 { | |
631 | 1989 if (ea.line2 > curbuf->b_ml.ml_line_count) |
1990 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1991 // 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
|
1992 // error, otherwise put it at the end of the file. |
631 | 1993 if (vim_strchr(p_cpo, CPO_MINUS) != NULL) |
1994 ea.line2 = -1; | |
1995 else | |
1996 ea.line2 = curbuf->b_ml.ml_line_count; | |
1997 } | |
1998 | |
1999 if (ea.line2 < 0) | |
25064
8f2262c72178
patch 8.2.3069: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
24984
diff
changeset
|
2000 errormsg = _(e_invalid_range); |
7 | 2001 else |
2002 { | |
2003 if (ea.line2 == 0) | |
2004 curwin->w_cursor.lnum = 1; | |
2005 else | |
2006 curwin->w_cursor.lnum = ea.line2; | |
2007 beginline(BL_SOL | BL_FIX); | |
2008 } | |
2009 } | |
2010 goto doend; | |
2011 } | |
2012 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2013 // 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
|
2014 // autocommands defined, trigger the matching autocommands. |
6154 | 2015 if (p != NULL && ea.cmdidx == CMD_SIZE && !ea.skip |
2016 && ASCII_ISUPPER(*ea.cmd) | |
2017 && has_cmdundefined()) | |
2018 { | |
2019 int ret; | |
2020 | |
6156 | 2021 p = ea.cmd; |
6154 | 2022 while (ASCII_ISALNUM(*p)) |
2023 ++p; | |
20897
213fb059e02e
patch 8.2.1000: get error when leaving Ex mode with :visual
Bram Moolenaar <Bram@vim.org>
parents:
20711
diff
changeset
|
2024 p = vim_strnsave(ea.cmd, p - ea.cmd); |
6154 | 2025 ret = apply_autocmds(EVENT_CMDUNDEFINED, p, p, TRUE, NULL); |
2026 vim_free(p); | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2027 // 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
|
2028 // finding the command again. |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
2029 p = (ret |
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
2030 #ifdef FEAT_EVAL |
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
2031 && !aborting() |
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
2032 #endif |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
2033 ) ? 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
|
2034 } |
6154 | 2035 |
7 | 2036 if (p == NULL) |
2037 { | |
2038 if (!ea.skip) | |
23513
872239543313
patch 8.2.2299: Vim9: invalid memory access making error message flaky
Bram Moolenaar <Bram@vim.org>
parents:
23505
diff
changeset
|
2039 errormsg = _(e_ambiguous_use_of_user_defined_command); |
7 | 2040 goto doend; |
2041 } | |
16411
5b5c5daf57de
patch 8.1.1210: support for user commands is spread out
Bram Moolenaar <Bram@vim.org>
parents:
16399
diff
changeset
|
2042 // 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
|
2043 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
|
2044 && !IS_USER_CMDIDX(ea.cmdidx)) |
7 | 2045 { |
2046 errormsg = uc_fun_cmd(); | |
2047 goto doend; | |
2048 } | |
16411
5b5c5daf57de
patch 8.1.1210: support for user commands is spread out
Bram Moolenaar <Bram@vim.org>
parents:
16399
diff
changeset
|
2049 |
7 | 2050 if (ea.cmdidx == CMD_SIZE) |
2051 { | |
2052 if (!ea.skip) | |
2053 { | |
2054 STRCPY(IObuff, _("E492: Not an editor command")); | |
2055 if (!sourcing) | |
9941
e975914c17e9
commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
9927
diff
changeset
|
2056 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2057 // 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
|
2058 // following command |
9941
e975914c17e9
commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
9927
diff
changeset
|
2059 if (after_modifier != NULL) |
e975914c17e9
commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
9927
diff
changeset
|
2060 append_command(after_modifier); |
e975914c17e9
commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
9927
diff
changeset
|
2061 else |
e975914c17e9
commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
9927
diff
changeset
|
2062 append_command(*cmdlinep); |
e975914c17e9
commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
9927
diff
changeset
|
2063 } |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2064 errormsg = (char *)IObuff; |
3757 | 2065 did_emsg_syntax = TRUE; |
7 | 2066 } |
2067 goto doend; | |
2068 } | |
2069 | |
6305 | 2070 ni = (!IS_USER_CMDIDX(ea.cmdidx) |
2071 && (cmdnames[ea.cmdidx].cmd_func == ex_ni | |
1315 | 2072 #ifdef HAVE_EX_SCRIPT_NI |
2073 || cmdnames[ea.cmdidx].cmd_func == ex_script_ni | |
2074 #endif | |
2075 )); | |
7 | 2076 |
2077 #ifndef FEAT_EVAL | |
2078 /* | |
2079 * When the expression evaluation is disabled, recognize the ":if" and | |
2080 * ":endif" commands and ignore everything in between it. | |
2081 */ | |
2082 if (ea.cmdidx == CMD_if) | |
2083 ++if_level; | |
2084 if (if_level) | |
2085 { | |
2086 if (ea.cmdidx == CMD_endif) | |
2087 --if_level; | |
2088 goto doend; | |
2089 } | |
2090 | |
2091 #endif | |
2092 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2093 // forced commands |
1613 | 2094 if (*p == '!' && ea.cmdidx != CMD_substitute |
2095 && ea.cmdidx != CMD_smagic && ea.cmdidx != CMD_snomagic) | |
7 | 2096 { |
2097 ++p; | |
2098 ea.forceit = TRUE; | |
2099 } | |
2100 else | |
2101 ea.forceit = FALSE; | |
2102 | |
2103 /* | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
2104 * 6. Parse arguments. Then check for errors. |
7 | 2105 */ |
6305 | 2106 if (!IS_USER_CMDIDX(ea.cmdidx)) |
835 | 2107 ea.argt = (long)cmdnames[(int)ea.cmdidx].cmd_argt; |
7 | 2108 |
2109 if (!ea.skip) | |
2110 { | |
2111 #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
|
2112 if (sandbox != 0 && !(ea.argt & EX_SBOXOK)) |
7 | 2113 { |
15748
93b78c4a7cd5
patch 8.1.0881: can execute shell commands in rvim through interfaces
Bram Moolenaar <Bram@vim.org>
parents:
15713
diff
changeset
|
2114 // Command not allowed in sandbox. |
25320
1e6da8364a02
patch 8.2.3197: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
2115 errormsg = _(e_not_allowed_in_sandbox); |
7 | 2116 goto doend; |
2117 } | |
2118 #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
|
2119 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
|
2120 { |
93b78c4a7cd5
patch 8.1.0881: can execute shell commands in rvim through interfaces
Bram Moolenaar <Bram@vim.org>
parents:
15713
diff
changeset
|
2121 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
|
2122 goto doend; |
93b78c4a7cd5
patch 8.1.0881: can execute shell commands in rvim through interfaces
Bram Moolenaar <Bram@vim.org>
parents:
15713
diff
changeset
|
2123 } |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2124 if (!curbuf->b_p_ma && (ea.argt & EX_MODIFY)) |
7 | 2125 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2126 // Command not allowed in non-'modifiable' buffer |
25064
8f2262c72178
patch 8.2.3069: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
24984
diff
changeset
|
2127 errormsg = _(e_cannot_make_changes_modifiable_is_off); |
7 | 2128 goto doend; |
2129 } | |
631 | 2130 |
21487
5c92877092f9
patch 8.2.1294: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents:
21475
diff
changeset
|
2131 if (!IS_USER_CMDIDX(ea.cmdidx)) |
5c92877092f9
patch 8.2.1294: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents:
21475
diff
changeset
|
2132 { |
5c92877092f9
patch 8.2.1294: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents:
21475
diff
changeset
|
2133 #ifdef FEAT_CMDWIN |
5c92877092f9
patch 8.2.1294: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents:
21475
diff
changeset
|
2134 if (cmdwin_type != 0 && !(ea.argt & EX_CMDWIN)) |
5c92877092f9
patch 8.2.1294: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents:
21475
diff
changeset
|
2135 { |
5c92877092f9
patch 8.2.1294: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents:
21475
diff
changeset
|
2136 // Command not allowed in the command line window |
25064
8f2262c72178
patch 8.2.3069: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
24984
diff
changeset
|
2137 errormsg = _(e_invalid_in_cmdline_window); |
21487
5c92877092f9
patch 8.2.1294: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents:
21475
diff
changeset
|
2138 goto doend; |
5c92877092f9
patch 8.2.1294: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents:
21475
diff
changeset
|
2139 } |
5c92877092f9
patch 8.2.1294: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents:
21475
diff
changeset
|
2140 #endif |
5c92877092f9
patch 8.2.1294: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents:
21475
diff
changeset
|
2141 if (text_locked() && !(ea.argt & EX_LOCK_OK)) |
5c92877092f9
patch 8.2.1294: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents:
21475
diff
changeset
|
2142 { |
5c92877092f9
patch 8.2.1294: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents:
21475
diff
changeset
|
2143 // Command not allowed when text is locked |
5c92877092f9
patch 8.2.1294: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents:
21475
diff
changeset
|
2144 errormsg = _(get_text_locked_msg()); |
5c92877092f9
patch 8.2.1294: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents:
21475
diff
changeset
|
2145 goto doend; |
5c92877092f9
patch 8.2.1294: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents:
21475
diff
changeset
|
2146 } |
7 | 2147 } |
14648
c3222a7342ab
patch 8.1.0337: :file fails in quickfix command
Christian Brabandt <cb@256bit.org>
parents:
14640
diff
changeset
|
2148 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2149 // 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
|
2150 // 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
|
2151 // 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
|
2152 // Do allow ":file" with no arguments (check for an argument later). |
21664
60ba361a7fdb
patch 8.2.1382: Vim9: using :import in filetype plugin gives an error
Bram Moolenaar <Bram@vim.org>
parents:
21618
diff
changeset
|
2153 if (!(ea.argt & (EX_CMDWIN | EX_LOCK_OK)) |
14648
c3222a7342ab
patch 8.1.0337: :file fails in quickfix command
Christian Brabandt <cb@256bit.org>
parents:
14640
diff
changeset
|
2154 && ea.cmdidx != CMD_checktime |
822 | 2155 && ea.cmdidx != CMD_edit |
14648
c3222a7342ab
patch 8.1.0337: :file fails in quickfix command
Christian Brabandt <cb@256bit.org>
parents:
14640
diff
changeset
|
2156 && ea.cmdidx != CMD_file |
6305 | 2157 && !IS_USER_CMDIDX(ea.cmdidx) |
819 | 2158 && curbuf_locked()) |
2159 goto doend; | |
7 | 2160 |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2161 if (!ni && !(ea.argt & EX_RANGE) && ea.addr_count > 0) |
7 | 2162 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2163 // no range allowed |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2164 errormsg = _(e_norange); |
7 | 2165 goto doend; |
2166 } | |
2167 } | |
2168 | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2169 if (!ni && !(ea.argt & EX_BANG) && ea.forceit) // no <!> allowed |
7 | 2170 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2171 errormsg = _(e_nobang); |
7 | 2172 goto doend; |
2173 } | |
2174 | |
2175 /* | |
2176 * Don't complain about the range if it is not used | |
2177 * (could happen if line_count is accidentally set to 0). | |
2178 */ | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2179 if (!ea.skip && !ni && (ea.argt & EX_RANGE)) |
7 | 2180 { |
2181 /* | |
2182 * If the range is backwards, ask for confirmation and, if given, swap | |
2183 * ea.line1 & ea.line2 so it's forwards again. | |
2184 * When global command is busy, don't ask, will fail below. | |
2185 */ | |
2186 if (!global_busy && ea.line1 > ea.line2) | |
2187 { | |
557 | 2188 if (msg_silent == 0) |
2189 { | |
2190 if (sourcing || exmode_active) | |
2191 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2192 errormsg = _("E493: Backwards range given"); |
557 | 2193 goto doend; |
2194 } | |
7 | 2195 if (ask_yesno((char_u *) |
2196 _("Backwards range given, OK to swap"), FALSE) != 'y') | |
557 | 2197 goto doend; |
7 | 2198 } |
2199 lnum = ea.line1; | |
2200 ea.line1 = ea.line2; | |
2201 ea.line2 = lnum; | |
2202 } | |
2203 if ((errormsg = invalid_range(&ea)) != NULL) | |
2204 goto doend; | |
2205 } | |
2206 | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
2207 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
|
2208 // default is 1, not cursor |
7 | 2209 ea.line2 = 1; |
2210 | |
2211 correct_range(&ea); | |
2212 | |
2213 #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
|
2214 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
|
2215 && ea.addr_type == ADDR_LINES) |
7 | 2216 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2217 // 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
|
2218 // at the end of a closed fold. |
7 | 2219 (void)hasFolding(ea.line1, &ea.line1, NULL); |
2220 (void)hasFolding(ea.line2, NULL, &ea.line2); | |
2221 } | |
2222 #endif | |
2223 | |
2224 #ifdef FEAT_QUICKFIX | |
2225 /* | |
41 | 2226 * For the ":make" and ":grep" commands we insert the 'makeprg'/'grepprg' |
7 | 2227 * option here, so things like % get expanded. |
2228 */ | |
344 | 2229 p = replace_makeprg(&ea, p, cmdlinep); |
2230 if (p == NULL) | |
2231 goto doend; | |
7 | 2232 #endif |
2233 | |
2234 /* | |
2235 * Skip to start of argument. | |
2236 * Don't do this for the ":!" command, because ":!! -l" needs the space. | |
2237 */ | |
2238 if (ea.cmdidx == CMD_bang) | |
2239 ea.arg = p; | |
2240 else | |
2241 ea.arg = skipwhite(p); | |
2242 | |
14648
c3222a7342ab
patch 8.1.0337: :file fails in quickfix command
Christian Brabandt <cb@256bit.org>
parents:
14640
diff
changeset
|
2243 // ":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
|
2244 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
|
2245 goto doend; |
c3222a7342ab
patch 8.1.0337: :file fails in quickfix command
Christian Brabandt <cb@256bit.org>
parents:
14640
diff
changeset
|
2246 |
7 | 2247 /* |
2248 * Check for "++opt=val" argument. | |
2249 * Must be first, allow ":w ++enc=utf8 !cmd" | |
2250 */ | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2251 if (ea.argt & EX_ARGOPT) |
7 | 2252 while (ea.arg[0] == '+' && ea.arg[1] == '+') |
2253 if (getargopt(&ea) == FAIL && !ni) | |
2254 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2255 errormsg = _(e_invarg); |
7 | 2256 goto doend; |
2257 } | |
2258 | |
2259 if (ea.cmdidx == CMD_write || ea.cmdidx == CMD_update) | |
2260 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2261 if (*ea.arg == '>') // append |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2262 { |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2263 if (*++ea.arg != '>') // typed wrong |
7 | 2264 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2265 errormsg = _("E494: Use w or w>>"); |
7 | 2266 goto doend; |
2267 } | |
2268 ea.arg = skipwhite(ea.arg + 1); | |
2269 ea.append = TRUE; | |
2270 } | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2271 else if (*ea.arg == '!' && ea.cmdidx == CMD_write) // :w !filter |
7 | 2272 { |
2273 ++ea.arg; | |
2274 ea.usefilter = TRUE; | |
2275 } | |
2276 } | |
2277 | |
2278 if (ea.cmdidx == CMD_read) | |
2279 { | |
2280 if (ea.forceit) | |
2281 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2282 ea.usefilter = TRUE; // :r! filter if ea.forceit |
7 | 2283 ea.forceit = FALSE; |
2284 } | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2285 else if (*ea.arg == '!') // :r !filter |
7 | 2286 { |
2287 ++ea.arg; | |
2288 ea.usefilter = TRUE; | |
2289 } | |
2290 } | |
2291 | |
2292 if (ea.cmdidx == CMD_lshift || ea.cmdidx == CMD_rshift) | |
2293 { | |
2294 ea.amount = 1; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2295 while (*ea.arg == *ea.cmd) // count number of '>' or '<' |
7 | 2296 { |
2297 ++ea.arg; | |
2298 ++ea.amount; | |
2299 } | |
2300 ea.arg = skipwhite(ea.arg); | |
2301 } | |
2302 | |
2303 /* | |
2304 * Check for "+command" argument, before checking for next command. | |
2305 * Don't do this for ":read !cmd" and ":write !cmd". | |
2306 */ | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2307 if ((ea.argt & EX_CMDARG) && !ea.usefilter) |
7 | 2308 ea.do_ecmd_cmd = getargcmd(&ea.arg); |
2309 | |
2310 /* | |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21335
diff
changeset
|
2311 * Check for '|' to separate commands and '"' or '#' to start comments. |
7 | 2312 * Don't do this for ":read !cmd" and ":write !cmd". |
2313 */ | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2314 if ((ea.argt & EX_TRLBAR) && !ea.usefilter) |
7 | 2315 separate_nextcmd(&ea); |
2316 | |
2317 /* | |
2318 * Check for <newline> to end a shell command. | |
167 | 2319 * Also do this for ":read !cmd", ":write !cmd" and ":global". |
2320 * Any others? | |
7 | 2321 */ |
167 | 2322 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
|
2323 || ea.cmdidx == CMD_terminal |
167 | 2324 || ea.cmdidx == CMD_global |
2325 || ea.cmdidx == CMD_vglobal | |
2326 || ea.usefilter) | |
7 | 2327 { |
2328 for (p = ea.arg; *p; ++p) | |
2329 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2330 // 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
|
2331 // 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
|
2332 // 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
|
2333 // 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
|
2334 // 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
|
2335 // versions. |
7 | 2336 if (*p == '\\' && p[1] == '\n') |
1619 | 2337 STRMOVE(p, p + 1); |
7 | 2338 else if (*p == '\n') |
2339 { | |
2340 ea.nextcmd = p + 1; | |
2341 *p = NUL; | |
2342 break; | |
2343 } | |
2344 } | |
2345 } | |
2346 | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2347 if ((ea.argt & EX_DFLALL) && ea.addr_count == 0) |
21939
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
2348 address_default_all(&ea); |
7 | 2349 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2350 // 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
|
2351 if ( (ea.argt & EX_REGSTR) |
7 | 2352 && *ea.arg != NUL |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2353 // Do not allow register = for user commands |
6305 | 2354 && (!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
|
2355 && !((ea.argt & EX_COUNT) && VIM_ISDIGIT(*ea.arg))) |
7 | 2356 { |
2791 | 2357 #ifndef FEAT_CLIPBOARD |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2358 // check these explicitly for a more specific error message |
2791 | 2359 if (*ea.arg == '*' || *ea.arg == '+') |
2360 { | |
15474
79e3dcc5aa50
patch 8.1.0745: compiler warnings for signed/unsigned string
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
2361 errormsg = _(e_invalidreg); |
2791 | 2362 goto doend; |
2363 } | |
2364 #endif | |
6305 | 2365 if (valid_yank_reg(*ea.arg, (ea.cmdidx != CMD_put |
2366 && !IS_USER_CMDIDX(ea.cmdidx)))) | |
2791 | 2367 { |
2368 ea.regname = *ea.arg++; | |
7 | 2369 #ifdef FEAT_EVAL |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2370 // for '=' register: accept the rest of the line as an expression |
2791 | 2371 if (ea.arg[-1] == '=' && ea.arg[0] != NUL) |
2372 { | |
22732
4c21a3a47707
patch 8.2.1914: Vim9: cannot put line break in expression for '=' register
Bram Moolenaar <Bram@vim.org>
parents:
22724
diff
changeset
|
2373 set_expr_line(vim_strsave(ea.arg), &ea); |
2791 | 2374 ea.arg += STRLEN(ea.arg); |
22732
4c21a3a47707
patch 8.2.1914: Vim9: cannot put line break in expression for '=' register
Bram Moolenaar <Bram@vim.org>
parents:
22724
diff
changeset
|
2375 did_set_expr_line = TRUE; |
2791 | 2376 } |
2377 #endif | |
2378 ea.arg = skipwhite(ea.arg); | |
2379 } | |
7 | 2380 } |
2381 | |
2382 /* | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2383 * Check for a count. When accepting a EX_BUFNAME, don't use "123foo" as a |
7 | 2384 * count, it's a buffer name. |
2385 */ | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2386 if ((ea.argt & EX_COUNT) && VIM_ISDIGIT(*ea.arg) |
24665
661d15592d3c
patch 8.2.2871: unnessary VIM_ISDIGIT() calls, badly indented code
Bram Moolenaar <Bram@vim.org>
parents:
24555
diff
changeset
|
2387 && (!(ea.argt & EX_BUFNAME) || *(p = skipdigits(ea.arg + 1)) == NUL |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
2388 || VIM_ISWHITE(*p))) |
7 | 2389 { |
2390 n = getdigits(&ea.arg); | |
2391 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
|
2392 if (n <= 0 && !ni && (ea.argt & EX_ZEROR) == 0) |
7 | 2393 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2394 errormsg = _(e_zerocount); |
7 | 2395 goto doend; |
2396 } | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
2397 if (ea.addr_type != ADDR_LINES) // e.g. :buffer 2, :sleep 3 |
7 | 2398 { |
2399 ea.line2 = n; | |
2400 if (ea.addr_count == 0) | |
2401 ea.addr_count = 1; | |
2402 } | |
2403 else | |
2404 { | |
2405 ea.line1 = ea.line2; | |
2406 ea.line2 += n - 1; | |
2407 ++ea.addr_count; | |
2408 /* | |
2409 * Be vi compatible: no error message for out of range. | |
2410 */ | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
2411 if (ea.line2 > curbuf->b_ml.ml_line_count) |
7 | 2412 ea.line2 = curbuf->b_ml.ml_line_count; |
2413 } | |
2414 } | |
167 | 2415 |
2416 /* | |
2417 * Check for flags: 'l', 'p' and '#'. | |
2418 */ | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2419 if (ea.argt & EX_FLAGS) |
167 | 2420 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
|
2421 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
|
2422 && *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
|
2423 { |
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2424 // no arguments allowed but there is something |
21461
4dfd00f481fb
patch 8.2.1281: the "trailing characters" error can be hard to understand
Bram Moolenaar <Bram@vim.org>
parents:
21459
diff
changeset
|
2425 errormsg = ex_errmsg(e_trailing_arg, ea.arg); |
7 | 2426 goto doend; |
2427 } | |
2428 | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2429 if (!ni && (ea.argt & EX_NEEDARG) && *ea.arg == NUL) |
7 | 2430 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2431 errormsg = _(e_argreq); |
7 | 2432 goto doend; |
2433 } | |
2434 | |
2435 #ifdef FEAT_EVAL | |
2436 /* | |
2437 * Skip the command when it's not going to be executed. | |
2438 * The commands like :if, :endif, etc. always need to be executed. | |
2439 * Also make an exception for commands that handle a trailing command | |
2440 * themselves. | |
2441 */ | |
2442 if (ea.skip) | |
2443 { | |
2444 switch (ea.cmdidx) | |
2445 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2446 // commands that need evaluation |
7 | 2447 case CMD_while: |
2448 case CMD_endwhile: | |
72 | 2449 case CMD_for: |
2450 case CMD_endfor: | |
7 | 2451 case CMD_if: |
2452 case CMD_elseif: | |
2453 case CMD_else: | |
2454 case CMD_endif: | |
2455 case CMD_try: | |
2456 case CMD_catch: | |
2457 case CMD_finally: | |
2458 case CMD_endtry: | |
2459 case CMD_function: | |
19575
3c0de44077cd
patch 8.2.0344: ":def" not skipped properly
Bram Moolenaar <Bram@vim.org>
parents:
19497
diff
changeset
|
2460 case CMD_def: |
7 | 2461 break; |
2462 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2463 // 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
|
2464 // 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
|
2465 // the list at ":help :bar". |
7 | 2466 case CMD_aboveleft: |
2467 case CMD_and: | |
2468 case CMD_belowright: | |
2469 case CMD_botright: | |
2470 case CMD_browse: | |
2471 case CMD_call: | |
2472 case CMD_confirm: | |
18713
baf890fa1621
patch 8.1.2348: :const cannot be followed by "| endif"
Bram Moolenaar <Bram@vim.org>
parents:
18406
diff
changeset
|
2473 case CMD_const: |
7 | 2474 case CMD_delfunction: |
2475 case CMD_djump: | |
2476 case CMD_dlist: | |
2477 case CMD_dsearch: | |
2478 case CMD_dsplit: | |
2479 case CMD_echo: | |
2480 case CMD_echoerr: | |
2481 case CMD_echomsg: | |
2482 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
|
2483 case CMD_eval: |
7 | 2484 case CMD_execute: |
9941
e975914c17e9
commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
9927
diff
changeset
|
2485 case CMD_filter: |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22361
diff
changeset
|
2486 case CMD_final: |
7 | 2487 case CMD_help: |
2488 case CMD_hide: | |
2489 case CMD_ijump: | |
2490 case CMD_ilist: | |
2491 case CMD_isearch: | |
2492 case CMD_isplit: | |
22 | 2493 case CMD_keepalt: |
7 | 2494 case CMD_keepjumps: |
2495 case CMD_keepmarks: | |
5467 | 2496 case CMD_keeppatterns: |
7 | 2497 case CMD_leftabove: |
2498 case CMD_let: | |
2499 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
|
2500 case CMD_lockvar: |
2320
966a5609669e
Added Lua interfae. (Luis Carvalho)
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
2501 case CMD_lua: |
7 | 2502 case CMD_match: |
14 | 2503 case CMD_mzscheme: |
5737 | 2504 case CMD_noautocmd: |
2505 case CMD_noswapfile: | |
7 | 2506 case CMD_perl: |
2507 case CMD_psearch: | |
2350
06feaf4fe36a
Rename some "python3" symbols to "py3", as the command name.
Bram Moolenaar <bram@vim.org>
parents:
2340
diff
changeset
|
2508 case CMD_py3: |
2366
7a57fe6a5157
Fix that :py3file was not working.
Bram Moolenaar <bram@vim.org>
parents:
2360
diff
changeset
|
2509 case CMD_python3: |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22361
diff
changeset
|
2510 case CMD_python: |
7 | 2511 case CMD_return: |
2512 case CMD_rightbelow: | |
2513 case CMD_ruby: | |
2514 case CMD_silent: | |
2515 case CMD_smagic: | |
2516 case CMD_snomagic: | |
2517 case CMD_substitute: | |
2518 case CMD_syntax: | |
690 | 2519 case CMD_tab: |
7 | 2520 case CMD_tcl: |
2521 case CMD_throw: | |
2522 case CMD_tilde: | |
2523 case CMD_topleft: | |
2524 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
|
2525 case CMD_unlockvar: |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22361
diff
changeset
|
2526 case CMD_var: |
7 | 2527 case CMD_verbose: |
2528 case CMD_vertical: | |
2887 | 2529 case CMD_wincmd: |
7 | 2530 break; |
2531 | |
2532 default: goto doend; | |
2533 } | |
2534 } | |
2535 #endif | |
2536 | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2537 if (ea.argt & EX_XFILE) |
7 | 2538 { |
2539 if (expand_filename(&ea, cmdlinep, &errormsg) == FAIL) | |
2540 goto doend; | |
2541 } | |
2542 | |
2543 /* | |
2544 * Accept buffer name. Cannot be used at the same time with a buffer | |
2545 * number. Don't do this for a user command. | |
2546 */ | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2547 if ((ea.argt & EX_BUFNAME) && *ea.arg != NUL && ea.addr_count == 0 |
6305 | 2548 && !IS_USER_CMDIDX(ea.cmdidx)) |
7 | 2549 { |
2550 /* | |
2551 * :bdelete, :bwipeout and :bunload take several arguments, separated | |
2552 * by spaces: find next space (skipping over escaped characters). | |
2553 * The others take one argument: ignore trailing spaces. | |
2554 */ | |
2555 if (ea.cmdidx == CMD_bdelete || ea.cmdidx == CMD_bwipeout | |
2556 || ea.cmdidx == CMD_bunload) | |
2557 p = skiptowhite_esc(ea.arg); | |
2558 else | |
2559 { | |
2560 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
|
2561 while (p > ea.arg && VIM_ISWHITE(p[-1])) |
7 | 2562 --p; |
2563 } | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2564 ea.line2 = buflist_findpat(ea.arg, p, (ea.argt & EX_BUFUNL) != 0, |
4236 | 2565 FALSE, FALSE); |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2566 if (ea.line2 < 0) // failed |
7 | 2567 goto doend; |
2568 ea.addr_count = 1; | |
2569 ea.arg = skipwhite(p); | |
2570 } | |
2571 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2572 // 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
|
2573 // ":silent! try" was used, it should only apply to :try itself. |
22697
c996700d569f
patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents:
22693
diff
changeset
|
2574 if (ea.cmdidx == CMD_try && cmdmod.cmod_did_esilent > 0) |
c996700d569f
patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents:
22693
diff
changeset
|
2575 { |
c996700d569f
patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents:
22693
diff
changeset
|
2576 emsg_silent -= cmdmod.cmod_did_esilent; |
13288
530943a23d3f
patch 8.0.1518: error messages suppressed after ":silent! try"
Christian Brabandt <cb@256bit.org>
parents:
13268
diff
changeset
|
2577 if (emsg_silent < 0) |
530943a23d3f
patch 8.0.1518: error messages suppressed after ":silent! try"
Christian Brabandt <cb@256bit.org>
parents:
13268
diff
changeset
|
2578 emsg_silent = 0; |
22697
c996700d569f
patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents:
22693
diff
changeset
|
2579 cmdmod.cmod_did_esilent = 0; |
13288
530943a23d3f
patch 8.0.1518: error messages suppressed after ":silent! try"
Christian Brabandt <cb@256bit.org>
parents:
13268
diff
changeset
|
2580 } |
530943a23d3f
patch 8.0.1518: error messages suppressed after ":silent! try"
Christian Brabandt <cb@256bit.org>
parents:
13268
diff
changeset
|
2581 |
530943a23d3f
patch 8.0.1518: error messages suppressed after ":silent! try"
Christian Brabandt <cb@256bit.org>
parents:
13268
diff
changeset
|
2582 /* |
530943a23d3f
patch 8.0.1518: error messages suppressed after ":silent! try"
Christian Brabandt <cb@256bit.org>
parents:
13268
diff
changeset
|
2583 * 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
|
2584 */ |
7 | 2585 |
6305 | 2586 if (IS_USER_CMDIDX(ea.cmdidx)) |
7 | 2587 { |
2588 /* | |
2589 * Execute a user-defined command. | |
2590 */ | |
2591 do_ucmd(&ea); | |
2592 } | |
2593 else | |
2594 { | |
2595 /* | |
16411
5b5c5daf57de
patch 8.1.1210: support for user commands is spread out
Bram Moolenaar <Bram@vim.org>
parents:
16399
diff
changeset
|
2596 * Call the function to execute the builtin command. |
7 | 2597 */ |
2598 ea.errmsg = NULL; | |
2599 (cmdnames[ea.cmdidx].cmd_func)(&ea); | |
2600 if (ea.errmsg != NULL) | |
21459
a422bd80b434
patch 8.2.1280: Ex command error cannot contain an argument
Bram Moolenaar <Bram@vim.org>
parents:
21413
diff
changeset
|
2601 errormsg = ea.errmsg; |
7 | 2602 } |
2603 | |
2604 #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
|
2605 // Set flag that any command was executed, used by ex_vim9script(). |
23974
d4f7e4138544
patch 8.2.2529: Vim9: Not possible to use legacy and Vim9 script in one file
Bram Moolenaar <Bram@vim.org>
parents:
23966
diff
changeset
|
2606 // Not if this was a command that wasn't executed or :endif. |
19348
b6da81589f8c
patch 8.2.0232: the :compiler command causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
19271
diff
changeset
|
2607 if (getline_equal(ea.getline, ea.cookie, getsourceline) |
23974
d4f7e4138544
patch 8.2.2529: Vim9: Not possible to use legacy and Vim9 script in one file
Bram Moolenaar <Bram@vim.org>
parents:
23966
diff
changeset
|
2608 && current_sctx.sc_sid > 0 |
d4f7e4138544
patch 8.2.2529: Vim9: Not possible to use legacy and Vim9 script in one file
Bram Moolenaar <Bram@vim.org>
parents:
23966
diff
changeset
|
2609 && ea.cmdidx != CMD_endif |
d4f7e4138544
patch 8.2.2529: Vim9: Not possible to use legacy and Vim9 script in one file
Bram Moolenaar <Bram@vim.org>
parents:
23966
diff
changeset
|
2610 && (cstack->cs_idx < 0 |
d4f7e4138544
patch 8.2.2529: Vim9: Not possible to use legacy and Vim9 script in one file
Bram Moolenaar <Bram@vim.org>
parents:
23966
diff
changeset
|
2611 || (cstack->cs_flags[cstack->cs_idx] & CSF_ACTIVE))) |
23358
b3142fc0a414
patch 8.2.2222: Vim9: cannot keep script variables when reloading
Bram Moolenaar <Bram@vim.org>
parents:
23346
diff
changeset
|
2612 SCRIPT_ITEM(current_sctx.sc_sid)->sn_state = SN_STATE_HAD_COMMAND; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
2613 |
7 | 2614 /* |
2615 * If the command just executed called do_cmdline(), any throw or ":return" | |
2616 * or ":finish" encountered there must also check the cstack of the still | |
2617 * active do_cmdline() that called this do_one_cmd(). Rethrow an uncaught | |
2618 * exception, or reanimate a returned function or finished script file and | |
2619 * return or finish it again. | |
2620 */ | |
2621 if (need_rethrow) | |
2622 do_throw(cstack); | |
2623 else if (check_cstack) | |
2624 { | |
944 | 2625 if (source_finished(fgetline, cookie)) |
7 | 2626 do_finish(&ea, TRUE); |
944 | 2627 else if (getline_equal(fgetline, cookie, get_func_line) |
7 | 2628 && current_func_returned()) |
2629 do_return(&ea, TRUE, FALSE, NULL); | |
2630 } | |
2631 need_rethrow = check_cstack = FALSE; | |
2632 #endif | |
2633 | |
2634 doend: | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2635 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
|
2636 { |
7 | 2637 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
|
2638 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
|
2639 } |
7 | 2640 |
2641 if (errormsg != NULL && *errormsg != NUL && !did_emsg) | |
2642 { | |
2643 if (sourcing) | |
2644 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2645 if (errormsg != (char *)IObuff) |
7 | 2646 { |
2647 STRCPY(IObuff, errormsg); | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2648 errormsg = (char *)IObuff; |
7 | 2649 } |
3097 | 2650 append_command(*cmdlinep); |
7 | 2651 } |
2652 emsg(errormsg); | |
2653 } | |
2654 #ifdef FEAT_EVAL | |
2655 do_errthrow(cstack, | |
6305 | 2656 (ea.cmdidx != CMD_SIZE && !IS_USER_CMDIDX(ea.cmdidx)) |
2657 ? cmdnames[(int)ea.cmdidx].cmd_name : (char_u *)NULL); | |
22732
4c21a3a47707
patch 8.2.1914: Vim9: cannot put line break in expression for '=' register
Bram Moolenaar <Bram@vim.org>
parents:
22724
diff
changeset
|
2658 |
4c21a3a47707
patch 8.2.1914: Vim9: cannot put line break in expression for '=' register
Bram Moolenaar <Bram@vim.org>
parents:
22724
diff
changeset
|
2659 if (did_set_expr_line) |
4c21a3a47707
patch 8.2.1914: Vim9: cannot put line break in expression for '=' register
Bram Moolenaar <Bram@vim.org>
parents:
22724
diff
changeset
|
2660 set_expr_line(NULL, NULL); |
7 | 2661 #endif |
2662 | |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
2663 undo_cmdmod(&cmdmod); |
7 | 2664 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
|
2665 reg_executing = save_reg_executing; |
7 | 2666 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2667 if (ea.nextcmd && *ea.nextcmd == NUL) // not really a next command |
7 | 2668 ea.nextcmd = NULL; |
2669 | |
2670 #ifdef FEAT_EVAL | |
2671 --ex_nesting_level; | |
20996
3af71cbcfdbe
patch 8.2.1049: Vim9: leaking memory when using continuation line
Bram Moolenaar <Bram@vim.org>
parents:
20982
diff
changeset
|
2672 vim_free(ea.cmdline_tofree); |
7 | 2673 #endif |
2674 | |
2675 return ea.nextcmd; | |
2676 } | |
2677 #if (_MSC_VER == 1200) | |
128 | 2678 #pragma optimize( "", on ) |
7 | 2679 #endif |
2680 | |
21459
a422bd80b434
patch 8.2.1280: Ex command error cannot contain an argument
Bram Moolenaar <Bram@vim.org>
parents:
21413
diff
changeset
|
2681 static char ex_error_buf[MSG_BUF_LEN]; |
a422bd80b434
patch 8.2.1280: Ex command error cannot contain an argument
Bram Moolenaar <Bram@vim.org>
parents:
21413
diff
changeset
|
2682 |
a422bd80b434
patch 8.2.1280: Ex command error cannot contain an argument
Bram Moolenaar <Bram@vim.org>
parents:
21413
diff
changeset
|
2683 /* |
a422bd80b434
patch 8.2.1280: Ex command error cannot contain an argument
Bram Moolenaar <Bram@vim.org>
parents:
21413
diff
changeset
|
2684 * Return an error message with argument included. |
a422bd80b434
patch 8.2.1280: Ex command error cannot contain an argument
Bram Moolenaar <Bram@vim.org>
parents:
21413
diff
changeset
|
2685 * Uses a static buffer, only the last error will be kept. |
a422bd80b434
patch 8.2.1280: Ex command error cannot contain an argument
Bram Moolenaar <Bram@vim.org>
parents:
21413
diff
changeset
|
2686 * "msg" will be translated, caller should use N_(). |
a422bd80b434
patch 8.2.1280: Ex command error cannot contain an argument
Bram Moolenaar <Bram@vim.org>
parents:
21413
diff
changeset
|
2687 */ |
a422bd80b434
patch 8.2.1280: Ex command error cannot contain an argument
Bram Moolenaar <Bram@vim.org>
parents:
21413
diff
changeset
|
2688 char * |
a422bd80b434
patch 8.2.1280: Ex command error cannot contain an argument
Bram Moolenaar <Bram@vim.org>
parents:
21413
diff
changeset
|
2689 ex_errmsg(char *msg, char_u *arg) |
a422bd80b434
patch 8.2.1280: Ex command error cannot contain an argument
Bram Moolenaar <Bram@vim.org>
parents:
21413
diff
changeset
|
2690 { |
a422bd80b434
patch 8.2.1280: Ex command error cannot contain an argument
Bram Moolenaar <Bram@vim.org>
parents:
21413
diff
changeset
|
2691 vim_snprintf(ex_error_buf, MSG_BUF_LEN, _(msg), arg); |
a422bd80b434
patch 8.2.1280: Ex command error cannot contain an argument
Bram Moolenaar <Bram@vim.org>
parents:
21413
diff
changeset
|
2692 return ex_error_buf; |
a422bd80b434
patch 8.2.1280: Ex command error cannot contain an argument
Bram Moolenaar <Bram@vim.org>
parents:
21413
diff
changeset
|
2693 } |
a422bd80b434
patch 8.2.1280: Ex command error cannot contain an argument
Bram Moolenaar <Bram@vim.org>
parents:
21413
diff
changeset
|
2694 |
7 | 2695 /* |
24254
0868ac82ef18
patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
2696 * Check for an Ex command with optional tail. |
0868ac82ef18
patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
2697 * If there is a match advance "pp" to the argument and return TRUE. |
0868ac82ef18
patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
2698 * If "noparen" is TRUE do not recognize the command followed by "(". |
0868ac82ef18
patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
2699 */ |
0868ac82ef18
patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
2700 static int |
0868ac82ef18
patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
2701 checkforcmd_opt( |
0868ac82ef18
patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
2702 char_u **pp, // start of command |
0868ac82ef18
patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
2703 char *cmd, // name of command |
0868ac82ef18
patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
2704 int len, // required length |
0868ac82ef18
patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
2705 int noparen) |
0868ac82ef18
patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
2706 { |
0868ac82ef18
patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
2707 int i; |
0868ac82ef18
patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
2708 |
0868ac82ef18
patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
2709 for (i = 0; cmd[i] != NUL; ++i) |
0868ac82ef18
patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
2710 if (((char_u *)cmd)[i] != (*pp)[i]) |
0868ac82ef18
patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
2711 break; |
0868ac82ef18
patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
2712 if (i >= len && !isalpha((*pp)[i]) |
0868ac82ef18
patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
2713 && (*pp)[i] != '_' && (!noparen || (*pp)[i] != '(')) |
0868ac82ef18
patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
2714 { |
0868ac82ef18
patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
2715 *pp = skipwhite(*pp + i); |
0868ac82ef18
patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
2716 return TRUE; |
0868ac82ef18
patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
2717 } |
0868ac82ef18
patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
2718 return FALSE; |
0868ac82ef18
patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
2719 } |
0868ac82ef18
patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
2720 |
0868ac82ef18
patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
2721 /* |
0868ac82ef18
patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
2722 * Check for an Ex command with optional tail. |
0868ac82ef18
patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
2723 * If there is a match advance "pp" to the argument and return TRUE. |
0868ac82ef18
patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
2724 */ |
0868ac82ef18
patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
2725 int |
0868ac82ef18
patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
2726 checkforcmd( |
0868ac82ef18
patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
2727 char_u **pp, // start of command |
0868ac82ef18
patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
2728 char *cmd, // name of command |
0868ac82ef18
patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
2729 int len) // required length |
0868ac82ef18
patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
2730 { |
0868ac82ef18
patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
2731 return checkforcmd_opt(pp, cmd, len, FALSE); |
0868ac82ef18
patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
2732 } |
0868ac82ef18
patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
2733 |
0868ac82ef18
patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
2734 /* |
0868ac82ef18
patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
2735 * Check for an Ex command with optional tail, not followed by "(". |
0868ac82ef18
patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
2736 * If there is a match advance "pp" to the argument and return TRUE. |
0868ac82ef18
patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
2737 */ |
0868ac82ef18
patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
2738 static int |
0868ac82ef18
patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
2739 checkforcmd_noparen( |
0868ac82ef18
patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
2740 char_u **pp, // start of command |
0868ac82ef18
patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
2741 char *cmd, // name of command |
0868ac82ef18
patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
2742 int len) // required length |
0868ac82ef18
patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
2743 { |
0868ac82ef18
patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
2744 return checkforcmd_opt(pp, cmd, len, TRUE); |
0868ac82ef18
patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
2745 } |
0868ac82ef18
patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
2746 |
0868ac82ef18
patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
2747 /* |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2748 * 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
|
2749 * - update eap->cmd |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
2750 * - store flags in "cmod". |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2751 * - Set ex_pressedreturn for an empty command line. |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2752 * 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
|
2753 * "cmdmod". |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
2754 * When "skip_only" is FALSE then undo_cmdmod() must be called later to free |
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
2755 * any cmod_filter_regmatch.regprog. |
22697
c996700d569f
patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents:
22693
diff
changeset
|
2756 * Call apply_cmdmod() to get the side effects of the modifiers: |
c996700d569f
patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents:
22693
diff
changeset
|
2757 * - Increment "sandbox" for ":sandbox" |
c996700d569f
patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents:
22693
diff
changeset
|
2758 * - set p_verbose for ":verbose" |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
2759 * - set msg_silent for ":silent" |
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
2760 * - 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
|
2761 * 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
|
2762 * 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
|
2763 */ |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2764 int |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
2765 parse_command_modifiers( |
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
2766 exarg_T *eap, |
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
2767 char **errormsg, |
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
2768 cmdmod_T *cmod, |
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
2769 int skip_only) |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2770 { |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21335
diff
changeset
|
2771 char_u *p; |
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21335
diff
changeset
|
2772 int starts_with_colon = FALSE; |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2773 |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
2774 CLEAR_POINTER(cmod); |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2775 |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2776 // 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
|
2777 for (;;) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2778 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2779 while (*eap->cmd == ' ' || *eap->cmd == '\t' || *eap->cmd == ':') |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21335
diff
changeset
|
2780 { |
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21335
diff
changeset
|
2781 if (*eap->cmd == ':') |
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21335
diff
changeset
|
2782 starts_with_colon = TRUE; |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2783 ++eap->cmd; |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21335
diff
changeset
|
2784 } |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2785 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2786 // 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
|
2787 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
|
2788 && (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
|
2789 || 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
|
2790 && 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
|
2791 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2792 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
|
2793 if (!skip_only) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2794 ex_pressedreturn = TRUE; |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2795 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2796 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2797 // ignore comment and empty lines |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21335
diff
changeset
|
2798 if (comment_start(eap->cmd, starts_with_colon)) |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2799 return FAIL; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2800 if (*eap->cmd == NUL) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2801 { |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2802 if (!skip_only) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2803 ex_pressedreturn = TRUE; |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2804 return FAIL; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2805 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2806 |
22260
d7c1e3efa88e
patch 8.2.1679: Vim9: ":*" is not recognized as a range
Bram Moolenaar <Bram@vim.org>
parents:
22208
diff
changeset
|
2807 p = skip_range(eap->cmd, TRUE, NULL); |
23537
7f0fc2ab90e3
patch 8.2.2311: Vim9: cannot assign to variable that shadows command modifier
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2808 |
7f0fc2ab90e3
patch 8.2.2311: Vim9: cannot assign to variable that shadows command modifier
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2809 // In Vim9 script a variable can shadow a command modifier: |
7f0fc2ab90e3
patch 8.2.2311: Vim9: cannot assign to variable that shadows command modifier
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2810 // verbose = 123 |
7f0fc2ab90e3
patch 8.2.2311: Vim9: cannot assign to variable that shadows command modifier
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2811 // verbose += 123 |
7f0fc2ab90e3
patch 8.2.2311: Vim9: cannot assign to variable that shadows command modifier
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2812 // silent! verbose = func() |
7f0fc2ab90e3
patch 8.2.2311: Vim9: cannot assign to variable that shadows command modifier
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2813 // verbose.member = 2 |
7f0fc2ab90e3
patch 8.2.2311: Vim9: cannot assign to variable that shadows command modifier
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2814 // verbose[expr] = 2 |
23549
4156f972efb1
patch 8.2.2317: Vim9: command modifier before list unpack doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
23537
diff
changeset
|
2815 // But not: |
4156f972efb1
patch 8.2.2317: Vim9: command modifier before list unpack doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
23537
diff
changeset
|
2816 // verbose [a, b] = list |
23537
7f0fc2ab90e3
patch 8.2.2311: Vim9: cannot assign to variable that shadows command modifier
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2817 if (in_vim9script()) |
7f0fc2ab90e3
patch 8.2.2311: Vim9: cannot assign to variable that shadows command modifier
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2818 { |
23549
4156f972efb1
patch 8.2.2317: Vim9: command modifier before list unpack doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
23537
diff
changeset
|
2819 char_u *s, *n; |
23537
7f0fc2ab90e3
patch 8.2.2311: Vim9: cannot assign to variable that shadows command modifier
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2820 |
7f0fc2ab90e3
patch 8.2.2311: Vim9: cannot assign to variable that shadows command modifier
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2821 for (s = p; ASCII_ISALPHA(*s); ++s) |
7f0fc2ab90e3
patch 8.2.2311: Vim9: cannot assign to variable that shadows command modifier
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2822 ; |
23549
4156f972efb1
patch 8.2.2317: Vim9: command modifier before list unpack doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
23537
diff
changeset
|
2823 n = skipwhite(s); |
4156f972efb1
patch 8.2.2317: Vim9: command modifier before list unpack doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
23537
diff
changeset
|
2824 if (vim_strchr((char_u *)".=", *n) != NULL |
4156f972efb1
patch 8.2.2317: Vim9: command modifier before list unpack doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
23537
diff
changeset
|
2825 || *s == '[' |
4156f972efb1
patch 8.2.2317: Vim9: command modifier before list unpack doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
23537
diff
changeset
|
2826 || (*n != NUL && n[1] == '=')) |
23537
7f0fc2ab90e3
patch 8.2.2311: Vim9: cannot assign to variable that shadows command modifier
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2827 break; |
7f0fc2ab90e3
patch 8.2.2311: Vim9: cannot assign to variable that shadows command modifier
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2828 } |
7f0fc2ab90e3
patch 8.2.2311: Vim9: cannot assign to variable that shadows command modifier
Bram Moolenaar <Bram@vim.org>
parents:
23513
diff
changeset
|
2829 |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2830 switch (*p) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2831 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2832 // When adding an entry, also modify cmd_exists(). |
24254
0868ac82ef18
patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
2833 case 'a': if (!checkforcmd_noparen(&eap->cmd, "aboveleft", 3)) |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2834 break; |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
2835 cmod->cmod_split |= WSP_ABOVE; |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2836 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2837 |
24254
0868ac82ef18
patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
2838 case 'b': if (checkforcmd_noparen(&eap->cmd, "belowright", 3)) |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2839 { |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
2840 cmod->cmod_split |= WSP_BELOW; |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2841 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2842 } |
24254
0868ac82ef18
patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
2843 if (checkforcmd_opt(&eap->cmd, "browse", 3, TRUE)) |
14536
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 #ifdef FEAT_BROWSE_CMD |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
2846 cmod->cmod_flags |= CMOD_BROWSE; |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2847 #endif |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2848 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2849 } |
24254
0868ac82ef18
patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
2850 if (!checkforcmd_noparen(&eap->cmd, "botright", 2)) |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2851 break; |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
2852 cmod->cmod_split |= WSP_BOT; |
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 |
24254
0868ac82ef18
patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
2855 case 'c': if (!checkforcmd_opt(&eap->cmd, "confirm", 4, TRUE)) |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2856 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2857 #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
2858 cmod->cmod_flags |= CMOD_CONFIRM; |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2859 #endif |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2860 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2861 |
24254
0868ac82ef18
patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
2862 case 'k': if (checkforcmd_noparen(&eap->cmd, "keepmarks", 3)) |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2863 { |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
2864 cmod->cmod_flags |= CMOD_KEEPMARKS; |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2865 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2866 } |
24254
0868ac82ef18
patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
2867 if (checkforcmd_noparen(&eap->cmd, "keepalt", 5)) |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2868 { |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
2869 cmod->cmod_flags |= CMOD_KEEPALT; |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2870 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2871 } |
24254
0868ac82ef18
patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
2872 if (checkforcmd_noparen(&eap->cmd, "keeppatterns", 5)) |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2873 { |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
2874 cmod->cmod_flags |= CMOD_KEEPPATTERNS; |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2875 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2876 } |
24254
0868ac82ef18
patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
2877 if (!checkforcmd_noparen(&eap->cmd, "keepjumps", 5)) |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2878 break; |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
2879 cmod->cmod_flags |= CMOD_KEEPJUMPS; |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2880 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2881 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2882 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
|
2883 { |
24834
adcd50a18236
patch 8.2.2955: Vim9: using filter in compiled command does not work
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
2884 char_u *reg_pat; |
adcd50a18236
patch 8.2.2955: Vim9: using filter in compiled command does not work
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
2885 char_u *nulp = NULL; |
adcd50a18236
patch 8.2.2955: Vim9: using filter in compiled command does not work
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
2886 int c = 0; |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2887 |
24254
0868ac82ef18
patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
2888 if (!checkforcmd_noparen(&p, "filter", 4) |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2889 || *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
|
2890 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2891 if (*p == '!') |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2892 { |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
2893 cmod->cmod_filter_force = TRUE; |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2894 p = skipwhite(p + 1); |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2895 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
|
2896 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2897 } |
21259
ee0e2ada88c0
patch 8.2.1180: build failure in small version
Bram Moolenaar <Bram@vim.org>
parents:
21255
diff
changeset
|
2898 #ifdef FEAT_EVAL |
21255
4be91a7eafb2
patch 8.2.1178: Vim9: filter function recognized as command modifier
Bram Moolenaar <Bram@vim.org>
parents:
21212
diff
changeset
|
2899 // Avoid that "filter(arg)" is recognized. |
22750
f945413264d7
patch 8.2.1923: Vim9: "filter" command modifier doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
22732
diff
changeset
|
2900 if (in_vim9script() && !VIM_ISWHITE(p[-1])) |
21255
4be91a7eafb2
patch 8.2.1178: Vim9: filter function recognized as command modifier
Bram Moolenaar <Bram@vim.org>
parents:
21212
diff
changeset
|
2901 break; |
21259
ee0e2ada88c0
patch 8.2.1180: build failure in small version
Bram Moolenaar <Bram@vim.org>
parents:
21255
diff
changeset
|
2902 #endif |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2903 if (skip_only) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2904 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
|
2905 else |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2906 // NOTE: This puts a NUL after the pattern. |
24834
adcd50a18236
patch 8.2.2955: Vim9: using filter in compiled command does not work
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
2907 p = skip_vimgrep_pat_ext(p, ®_pat, NULL, |
adcd50a18236
patch 8.2.2955: Vim9: using filter in compiled command does not work
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
2908 &nulp, &c); |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2909 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
|
2910 break; |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2911 if (!skip_only) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2912 { |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
2913 cmod->cmod_filter_regmatch.regprog = |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2914 vim_regcomp(reg_pat, RE_MAGIC); |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
2915 if (cmod->cmod_filter_regmatch.regprog == NULL) |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2916 break; |
24834
adcd50a18236
patch 8.2.2955: Vim9: using filter in compiled command does not work
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
2917 // restore the character overwritten by NUL |
adcd50a18236
patch 8.2.2955: Vim9: using filter in compiled command does not work
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
2918 if (nulp != NULL) |
adcd50a18236
patch 8.2.2955: Vim9: using filter in compiled command does not work
Bram Moolenaar <Bram@vim.org>
parents:
24768
diff
changeset
|
2919 *nulp = c; |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2920 } |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2921 eap->cmd = p; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2922 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2923 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2924 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2925 // ":hide" and ":hide | cmd" are not modifiers |
24254
0868ac82ef18
patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
2926 case 'h': if (p != eap->cmd || !checkforcmd_noparen(&p, "hide", 3) |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2927 || *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
|
2928 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2929 eap->cmd = p; |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
2930 cmod->cmod_flags |= CMOD_HIDE; |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2931 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2932 |
24254
0868ac82ef18
patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
2933 case 'l': if (checkforcmd_noparen(&eap->cmd, "lockmarks", 3)) |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2934 { |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
2935 cmod->cmod_flags |= CMOD_LOCKMARKS; |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2936 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2937 } |
24531
3bfec39ce31c
patch 8.2.2805: Vim9: cannot use legacy syntax in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
24462
diff
changeset
|
2938 if (checkforcmd_noparen(&eap->cmd, "legacy", 3)) |
3bfec39ce31c
patch 8.2.2805: Vim9: cannot use legacy syntax in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
24462
diff
changeset
|
2939 { |
3bfec39ce31c
patch 8.2.2805: Vim9: cannot use legacy syntax in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
24462
diff
changeset
|
2940 if (ends_excmd2(p, eap->cmd)) |
3bfec39ce31c
patch 8.2.2805: Vim9: cannot use legacy syntax in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
24462
diff
changeset
|
2941 { |
3bfec39ce31c
patch 8.2.2805: Vim9: cannot use legacy syntax in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
24462
diff
changeset
|
2942 *errormsg = |
3bfec39ce31c
patch 8.2.2805: Vim9: cannot use legacy syntax in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
24462
diff
changeset
|
2943 _(e_vim9cmd_must_be_followed_by_command); |
3bfec39ce31c
patch 8.2.2805: Vim9: cannot use legacy syntax in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
24462
diff
changeset
|
2944 return FAIL; |
3bfec39ce31c
patch 8.2.2805: Vim9: cannot use legacy syntax in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
24462
diff
changeset
|
2945 } |
3bfec39ce31c
patch 8.2.2805: Vim9: cannot use legacy syntax in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
24462
diff
changeset
|
2946 cmod->cmod_flags |= CMOD_LEGACY; |
3bfec39ce31c
patch 8.2.2805: Vim9: cannot use legacy syntax in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
24462
diff
changeset
|
2947 continue; |
3bfec39ce31c
patch 8.2.2805: Vim9: cannot use legacy syntax in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
24462
diff
changeset
|
2948 } |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2949 |
24254
0868ac82ef18
patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
2950 if (!checkforcmd_noparen(&eap->cmd, "leftabove", 5)) |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2951 break; |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
2952 cmod->cmod_split |= WSP_ABOVE; |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2953 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2954 |
24254
0868ac82ef18
patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
2955 case 'n': if (checkforcmd_noparen(&eap->cmd, "noautocmd", 3)) |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2956 { |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
2957 cmod->cmod_flags |= CMOD_NOAUTOCMD; |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2958 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2959 } |
24254
0868ac82ef18
patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
2960 if (!checkforcmd_noparen(&eap->cmd, "noswapfile", 3)) |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2961 break; |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
2962 cmod->cmod_flags |= CMOD_NOSWAPFILE; |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2963 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2964 |
24254
0868ac82ef18
patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
2965 case 'r': if (!checkforcmd_noparen(&eap->cmd, "rightbelow", 6)) |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2966 break; |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
2967 cmod->cmod_split |= WSP_BELOW; |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2968 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2969 |
24254
0868ac82ef18
patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
2970 case 's': if (checkforcmd_noparen(&eap->cmd, "sandbox", 3)) |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2971 { |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
2972 cmod->cmod_flags |= CMOD_SANDBOX; |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2973 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2974 } |
24254
0868ac82ef18
patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
2975 if (!checkforcmd_noparen(&eap->cmd, "silent", 3)) |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2976 break; |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
2977 cmod->cmod_flags |= CMOD_SILENT; |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2978 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
|
2979 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2980 // ":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
|
2981 eap->cmd = skipwhite(eap->cmd + 1); |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
2982 cmod->cmod_flags |= CMOD_ERRSILENT; |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2983 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2984 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2985 |
24254
0868ac82ef18
patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
2986 case 't': if (checkforcmd_noparen(&p, "tab", 3)) |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2987 { |
15263
ad065b8123e8
patch 8.1.0640: get E14 while typing command :tab with 'incsearch' set
Bram Moolenaar <Bram@vim.org>
parents:
15239
diff
changeset
|
2988 if (!skip_only) |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2989 { |
15263
ad065b8123e8
patch 8.1.0640: get E14 while typing command :tab with 'incsearch' set
Bram Moolenaar <Bram@vim.org>
parents:
15239
diff
changeset
|
2990 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
|
2991 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
|
2992 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
|
2993 if (tabnr == MAXLNUM) |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
2994 cmod->cmod_tab = tabpage_index(curtab) + 1; |
15263
ad065b8123e8
patch 8.1.0640: get E14 while typing command :tab with 'incsearch' set
Bram Moolenaar <Bram@vim.org>
parents:
15239
diff
changeset
|
2995 else |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2996 { |
15263
ad065b8123e8
patch 8.1.0640: get E14 while typing command :tab with 'incsearch' set
Bram Moolenaar <Bram@vim.org>
parents:
15239
diff
changeset
|
2997 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
|
2998 { |
25064
8f2262c72178
patch 8.2.3069: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
24984
diff
changeset
|
2999 *errormsg = _(e_invalid_range); |
15263
ad065b8123e8
patch 8.1.0640: get E14 while typing command :tab with 'incsearch' set
Bram Moolenaar <Bram@vim.org>
parents:
15239
diff
changeset
|
3000 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
|
3001 } |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
3002 cmod->cmod_tab = tabnr + 1; |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
3003 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
3004 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
3005 eap->cmd = p; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
3006 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
3007 } |
24254
0868ac82ef18
patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
3008 if (!checkforcmd_noparen(&eap->cmd, "topleft", 2)) |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
3009 break; |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
3010 cmod->cmod_split |= WSP_TOP; |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
3011 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
3012 |
24254
0868ac82ef18
patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
3013 case 'u': if (!checkforcmd_noparen(&eap->cmd, "unsilent", 3)) |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
3014 break; |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
3015 cmod->cmod_flags |= CMOD_UNSILENT; |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
3016 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
3017 |
24254
0868ac82ef18
patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
3018 case 'v': if (checkforcmd_noparen(&eap->cmd, "vertical", 4)) |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
3019 { |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
3020 cmod->cmod_split |= WSP_VERT; |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
3021 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
3022 } |
24254
0868ac82ef18
patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
3023 if (checkforcmd_noparen(&eap->cmd, "vim9cmd", 4)) |
23938
2a885d095bff
patch 8.2.2511: Vim9: cannot use Vim9 script syntax in some places
Bram Moolenaar <Bram@vim.org>
parents:
23884
diff
changeset
|
3024 { |
2a885d095bff
patch 8.2.2511: Vim9: cannot use Vim9 script syntax in some places
Bram Moolenaar <Bram@vim.org>
parents:
23884
diff
changeset
|
3025 if (ends_excmd2(p, eap->cmd)) |
2a885d095bff
patch 8.2.2511: Vim9: cannot use Vim9 script syntax in some places
Bram Moolenaar <Bram@vim.org>
parents:
23884
diff
changeset
|
3026 { |
2a885d095bff
patch 8.2.2511: Vim9: cannot use Vim9 script syntax in some places
Bram Moolenaar <Bram@vim.org>
parents:
23884
diff
changeset
|
3027 *errormsg = |
2a885d095bff
patch 8.2.2511: Vim9: cannot use Vim9 script syntax in some places
Bram Moolenaar <Bram@vim.org>
parents:
23884
diff
changeset
|
3028 _(e_vim9cmd_must_be_followed_by_command); |
2a885d095bff
patch 8.2.2511: Vim9: cannot use Vim9 script syntax in some places
Bram Moolenaar <Bram@vim.org>
parents:
23884
diff
changeset
|
3029 return FAIL; |
2a885d095bff
patch 8.2.2511: Vim9: cannot use Vim9 script syntax in some places
Bram Moolenaar <Bram@vim.org>
parents:
23884
diff
changeset
|
3030 } |
2a885d095bff
patch 8.2.2511: Vim9: cannot use Vim9 script syntax in some places
Bram Moolenaar <Bram@vim.org>
parents:
23884
diff
changeset
|
3031 cmod->cmod_flags |= CMOD_VIM9CMD; |
2a885d095bff
patch 8.2.2511: Vim9: cannot use Vim9 script syntax in some places
Bram Moolenaar <Bram@vim.org>
parents:
23884
diff
changeset
|
3032 continue; |
2a885d095bff
patch 8.2.2511: Vim9: cannot use Vim9 script syntax in some places
Bram Moolenaar <Bram@vim.org>
parents:
23884
diff
changeset
|
3033 } |
24254
0868ac82ef18
patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
3034 if (!checkforcmd_noparen(&p, "verbose", 4)) |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
3035 break; |
22697
c996700d569f
patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents:
22693
diff
changeset
|
3036 if (vim_isdigit(*eap->cmd)) |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
3037 cmod->cmod_verbose = atoi((char *)eap->cmd); |
22697
c996700d569f
patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents:
22693
diff
changeset
|
3038 else |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
3039 cmod->cmod_verbose = 1; |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
3040 eap->cmd = p; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
3041 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
3042 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
3043 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
3044 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
3045 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
3046 return OK; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
3047 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
3048 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
3049 /* |
24222
a2e6029d354e
patch 8.2.2652: Vim9: can use command modifier without an effect
Bram Moolenaar <Bram@vim.org>
parents:
24176
diff
changeset
|
3050 * Return TRUE if "cmod" has anything set. |
a2e6029d354e
patch 8.2.2652: Vim9: can use command modifier without an effect
Bram Moolenaar <Bram@vim.org>
parents:
24176
diff
changeset
|
3051 */ |
a2e6029d354e
patch 8.2.2652: Vim9: can use command modifier without an effect
Bram Moolenaar <Bram@vim.org>
parents:
24176
diff
changeset
|
3052 int |
a2e6029d354e
patch 8.2.2652: Vim9: can use command modifier without an effect
Bram Moolenaar <Bram@vim.org>
parents:
24176
diff
changeset
|
3053 has_cmdmod(cmdmod_T *cmod) |
a2e6029d354e
patch 8.2.2652: Vim9: can use command modifier without an effect
Bram Moolenaar <Bram@vim.org>
parents:
24176
diff
changeset
|
3054 { |
a2e6029d354e
patch 8.2.2652: Vim9: can use command modifier without an effect
Bram Moolenaar <Bram@vim.org>
parents:
24176
diff
changeset
|
3055 return cmod->cmod_flags != 0 |
a2e6029d354e
patch 8.2.2652: Vim9: can use command modifier without an effect
Bram Moolenaar <Bram@vim.org>
parents:
24176
diff
changeset
|
3056 || cmod->cmod_split != 0 |
a2e6029d354e
patch 8.2.2652: Vim9: can use command modifier without an effect
Bram Moolenaar <Bram@vim.org>
parents:
24176
diff
changeset
|
3057 || cmod->cmod_verbose != 0 |
a2e6029d354e
patch 8.2.2652: Vim9: can use command modifier without an effect
Bram Moolenaar <Bram@vim.org>
parents:
24176
diff
changeset
|
3058 || cmod->cmod_tab != 0 |
a2e6029d354e
patch 8.2.2652: Vim9: can use command modifier without an effect
Bram Moolenaar <Bram@vim.org>
parents:
24176
diff
changeset
|
3059 || cmod->cmod_filter_regmatch.regprog != NULL; |
a2e6029d354e
patch 8.2.2652: Vim9: can use command modifier without an effect
Bram Moolenaar <Bram@vim.org>
parents:
24176
diff
changeset
|
3060 } |
a2e6029d354e
patch 8.2.2652: Vim9: can use command modifier without an effect
Bram Moolenaar <Bram@vim.org>
parents:
24176
diff
changeset
|
3061 |
a2e6029d354e
patch 8.2.2652: Vim9: can use command modifier without an effect
Bram Moolenaar <Bram@vim.org>
parents:
24176
diff
changeset
|
3062 /* |
a2e6029d354e
patch 8.2.2652: Vim9: can use command modifier without an effect
Bram Moolenaar <Bram@vim.org>
parents:
24176
diff
changeset
|
3063 * If Vim9 script and "cmdmod" has anything set give an error and return TRUE. |
a2e6029d354e
patch 8.2.2652: Vim9: can use command modifier without an effect
Bram Moolenaar <Bram@vim.org>
parents:
24176
diff
changeset
|
3064 */ |
a2e6029d354e
patch 8.2.2652: Vim9: can use command modifier without an effect
Bram Moolenaar <Bram@vim.org>
parents:
24176
diff
changeset
|
3065 int |
a2e6029d354e
patch 8.2.2652: Vim9: can use command modifier without an effect
Bram Moolenaar <Bram@vim.org>
parents:
24176
diff
changeset
|
3066 cmdmod_error(void) |
a2e6029d354e
patch 8.2.2652: Vim9: can use command modifier without an effect
Bram Moolenaar <Bram@vim.org>
parents:
24176
diff
changeset
|
3067 { |
a2e6029d354e
patch 8.2.2652: Vim9: can use command modifier without an effect
Bram Moolenaar <Bram@vim.org>
parents:
24176
diff
changeset
|
3068 if (in_vim9script() && has_cmdmod(&cmdmod)) |
a2e6029d354e
patch 8.2.2652: Vim9: can use command modifier without an effect
Bram Moolenaar <Bram@vim.org>
parents:
24176
diff
changeset
|
3069 { |
a2e6029d354e
patch 8.2.2652: Vim9: can use command modifier without an effect
Bram Moolenaar <Bram@vim.org>
parents:
24176
diff
changeset
|
3070 emsg(_(e_misplaced_command_modifier)); |
a2e6029d354e
patch 8.2.2652: Vim9: can use command modifier without an effect
Bram Moolenaar <Bram@vim.org>
parents:
24176
diff
changeset
|
3071 return TRUE; |
a2e6029d354e
patch 8.2.2652: Vim9: can use command modifier without an effect
Bram Moolenaar <Bram@vim.org>
parents:
24176
diff
changeset
|
3072 } |
a2e6029d354e
patch 8.2.2652: Vim9: can use command modifier without an effect
Bram Moolenaar <Bram@vim.org>
parents:
24176
diff
changeset
|
3073 return FALSE; |
a2e6029d354e
patch 8.2.2652: Vim9: can use command modifier without an effect
Bram Moolenaar <Bram@vim.org>
parents:
24176
diff
changeset
|
3074 } |
a2e6029d354e
patch 8.2.2652: Vim9: can use command modifier without an effect
Bram Moolenaar <Bram@vim.org>
parents:
24176
diff
changeset
|
3075 |
a2e6029d354e
patch 8.2.2652: Vim9: can use command modifier without an effect
Bram Moolenaar <Bram@vim.org>
parents:
24176
diff
changeset
|
3076 /* |
22697
c996700d569f
patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents:
22693
diff
changeset
|
3077 * Apply the command modifiers. Saves current state in "cmdmod", call |
c996700d569f
patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents:
22693
diff
changeset
|
3078 * undo_cmdmod() later. |
c996700d569f
patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents:
22693
diff
changeset
|
3079 */ |
c996700d569f
patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents:
22693
diff
changeset
|
3080 void |
c996700d569f
patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents:
22693
diff
changeset
|
3081 apply_cmdmod(cmdmod_T *cmod) |
c996700d569f
patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents:
22693
diff
changeset
|
3082 { |
c996700d569f
patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents:
22693
diff
changeset
|
3083 #ifdef HAVE_SANDBOX |
c996700d569f
patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents:
22693
diff
changeset
|
3084 if ((cmod->cmod_flags & CMOD_SANDBOX) && !cmod->cmod_did_sandbox) |
c996700d569f
patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents:
22693
diff
changeset
|
3085 { |
c996700d569f
patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents:
22693
diff
changeset
|
3086 ++sandbox; |
c996700d569f
patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents:
22693
diff
changeset
|
3087 cmod->cmod_did_sandbox = TRUE; |
c996700d569f
patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents:
22693
diff
changeset
|
3088 } |
c996700d569f
patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents:
22693
diff
changeset
|
3089 #endif |
c996700d569f
patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents:
22693
diff
changeset
|
3090 if (cmod->cmod_verbose > 0) |
c996700d569f
patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents:
22693
diff
changeset
|
3091 { |
c996700d569f
patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents:
22693
diff
changeset
|
3092 if (cmod->cmod_verbose_save == 0) |
c996700d569f
patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents:
22693
diff
changeset
|
3093 cmod->cmod_verbose_save = p_verbose + 1; |
c996700d569f
patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents:
22693
diff
changeset
|
3094 p_verbose = cmod->cmod_verbose; |
c996700d569f
patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents:
22693
diff
changeset
|
3095 } |
c996700d569f
patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents:
22693
diff
changeset
|
3096 |
c996700d569f
patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents:
22693
diff
changeset
|
3097 if ((cmod->cmod_flags & (CMOD_SILENT | CMOD_UNSILENT)) |
c996700d569f
patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents:
22693
diff
changeset
|
3098 && cmod->cmod_save_msg_silent == 0) |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
3099 { |
22697
c996700d569f
patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents:
22693
diff
changeset
|
3100 cmod->cmod_save_msg_silent = msg_silent + 1; |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
3101 cmod->cmod_save_msg_scroll = msg_scroll; |
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
3102 } |
22697
c996700d569f
patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents:
22693
diff
changeset
|
3103 if (cmod->cmod_flags & CMOD_SILENT) |
c996700d569f
patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents:
22693
diff
changeset
|
3104 ++msg_silent; |
c996700d569f
patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents:
22693
diff
changeset
|
3105 if (cmod->cmod_flags & CMOD_UNSILENT) |
c996700d569f
patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents:
22693
diff
changeset
|
3106 msg_silent = 0; |
c996700d569f
patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents:
22693
diff
changeset
|
3107 |
c996700d569f
patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents:
22693
diff
changeset
|
3108 if (cmod->cmod_flags & CMOD_ERRSILENT) |
c996700d569f
patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents:
22693
diff
changeset
|
3109 { |
c996700d569f
patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents:
22693
diff
changeset
|
3110 ++emsg_silent; |
c996700d569f
patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents:
22693
diff
changeset
|
3111 ++cmod->cmod_did_esilent; |
c996700d569f
patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents:
22693
diff
changeset
|
3112 } |
c996700d569f
patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents:
22693
diff
changeset
|
3113 |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
3114 if ((cmod->cmod_flags & CMOD_NOAUTOCMD) && cmod->cmod_save_ei == NULL) |
22697
c996700d569f
patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents:
22693
diff
changeset
|
3115 { |
c996700d569f
patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents:
22693
diff
changeset
|
3116 // Set 'eventignore' to "all". |
c996700d569f
patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents:
22693
diff
changeset
|
3117 // First save the existing option value for restoring it later. |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
3118 cmod->cmod_save_ei = vim_strsave(p_ei); |
22697
c996700d569f
patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents:
22693
diff
changeset
|
3119 set_string_option_direct((char_u *)"ei", -1, |
c996700d569f
patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents:
22693
diff
changeset
|
3120 (char_u *)"all", OPT_FREE, SID_NONE); |
c996700d569f
patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents:
22693
diff
changeset
|
3121 } |
c996700d569f
patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents:
22693
diff
changeset
|
3122 } |
c996700d569f
patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents:
22693
diff
changeset
|
3123 |
c996700d569f
patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents:
22693
diff
changeset
|
3124 /* |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
3125 * Undo and free contents of "cmod". |
21172
96ae8622cfb6
patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents:
21130
diff
changeset
|
3126 */ |
96ae8622cfb6
patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents:
21130
diff
changeset
|
3127 void |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
3128 undo_cmdmod(cmdmod_T *cmod) |
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
3129 { |
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
3130 if (cmod->cmod_verbose_save > 0) |
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
3131 { |
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
3132 p_verbose = cmod->cmod_verbose_save - 1; |
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
3133 cmod->cmod_verbose_save = 0; |
22697
c996700d569f
patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents:
22693
diff
changeset
|
3134 } |
c996700d569f
patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents:
22693
diff
changeset
|
3135 |
c996700d569f
patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents:
22693
diff
changeset
|
3136 #ifdef HAVE_SANDBOX |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
3137 if (cmod->cmod_did_sandbox) |
22697
c996700d569f
patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents:
22693
diff
changeset
|
3138 { |
c996700d569f
patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents:
22693
diff
changeset
|
3139 --sandbox; |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
3140 cmod->cmod_did_sandbox = FALSE; |
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
3141 } |
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
3142 #endif |
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
3143 |
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
3144 if (cmod->cmod_save_ei != NULL) |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
3145 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3146 // Restore 'eventignore' to the value before ":noautocmd". |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
3147 set_string_option_direct((char_u *)"ei", -1, cmod->cmod_save_ei, |
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
3148 OPT_FREE, SID_NONE); |
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
3149 free_string_option(cmod->cmod_save_ei); |
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
3150 cmod->cmod_save_ei = NULL; |
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
3151 } |
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
3152 |
22724
51bc501a13ca
patch 8.2.1910: reading past the end of the command line
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
3153 vim_regfree(cmod->cmod_filter_regmatch.regprog); |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
3154 |
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
3155 if (cmod->cmod_save_msg_silent > 0) |
21172
96ae8622cfb6
patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents:
21130
diff
changeset
|
3156 { |
96ae8622cfb6
patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents:
21130
diff
changeset
|
3157 // messages could be enabled for a serious error, need to check if the |
96ae8622cfb6
patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents:
21130
diff
changeset
|
3158 // counters don't become negative |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
3159 if (!did_emsg || msg_silent > cmod->cmod_save_msg_silent - 1) |
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
3160 msg_silent = cmod->cmod_save_msg_silent - 1; |
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
3161 emsg_silent -= cmod->cmod_did_esilent; |
21172
96ae8622cfb6
patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents:
21130
diff
changeset
|
3162 if (emsg_silent < 0) |
96ae8622cfb6
patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents:
21130
diff
changeset
|
3163 emsg_silent = 0; |
96ae8622cfb6
patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents:
21130
diff
changeset
|
3164 // Restore msg_scroll, it's set by file I/O commands, even when no |
96ae8622cfb6
patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents:
21130
diff
changeset
|
3165 // message is actually displayed. |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
3166 msg_scroll = cmod->cmod_save_msg_scroll; |
21172
96ae8622cfb6
patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents:
21130
diff
changeset
|
3167 |
96ae8622cfb6
patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents:
21130
diff
changeset
|
3168 // "silent reg" or "silent echo x" inside "redir" leaves msg_col |
96ae8622cfb6
patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents:
21130
diff
changeset
|
3169 // somewhere in the line. Put it back in the first column. |
96ae8622cfb6
patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents:
21130
diff
changeset
|
3170 if (redirecting()) |
96ae8622cfb6
patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents:
21130
diff
changeset
|
3171 msg_col = 0; |
22697
c996700d569f
patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents:
22693
diff
changeset
|
3172 |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
3173 cmod->cmod_save_msg_silent = 0; |
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
3174 cmod->cmod_did_esilent = 0; |
21172
96ae8622cfb6
patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents:
21130
diff
changeset
|
3175 } |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
3176 } |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
3177 |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
3178 /* |
14505
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3179 * 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
|
3180 * 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
|
3181 * 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
|
3182 */ |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3183 int |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
3184 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
|
3185 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3186 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
|
3187 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
|
3188 |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3189 // 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
|
3190 for (;;) |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3191 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3192 eap->line1 = eap->line2; |
21939
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
3193 eap->line2 = default_address(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
|
3194 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
|
3195 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
|
3196 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
|
3197 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
|
3198 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
|
3199 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
|
3200 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3201 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
|
3202 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3203 ++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
|
3204 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
|
3205 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3206 case ADDR_LINES: |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
3207 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
|
3208 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
|
3209 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
|
3210 break; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3211 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
|
3212 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3213 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
|
3214 |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3215 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
|
3216 && 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
|
3217 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
|
3218 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
|
3219 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
|
3220 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
|
3221 && 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
|
3222 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
|
3223 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
|
3224 break; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3225 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3226 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
|
3227 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
|
3228 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
|
3229 break; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3230 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
|
3231 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
|
3232 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
|
3233 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3234 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
|
3235 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
|
3236 ? 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
|
3237 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3238 else |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3239 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3240 // 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
|
3241 // ADDR_WINDOWS or ADDR_TABS |
25064
8f2262c72178
patch 8.2.3069: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
24984
diff
changeset
|
3242 *errormsg = _(e_invalid_range); |
14505
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3243 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
|
3244 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3245 break; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3246 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
|
3247 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
|
3248 case ADDR_QUICKFIX: |
25064
8f2262c72178
patch 8.2.3069: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
24984
diff
changeset
|
3249 *errormsg = _(e_invalid_range); |
14505
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3250 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
|
3251 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
|
3252 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
|
3253 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
|
3254 else |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3255 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3256 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
|
3257 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
|
3258 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3259 break; |
16515
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
3260 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
|
3261 #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
|
3262 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
|
3263 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
|
3264 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
|
3265 eap->line2 = 1; |
16479
7dcf301d1432
patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents:
16475
diff
changeset
|
3266 #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
|
3267 break; |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
3268 case ADDR_NONE: |
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
3269 // 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
|
3270 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
|
3271 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3272 ++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
|
3273 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3274 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
|
3275 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3276 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
|
3277 |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3278 // '*' - 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
|
3279 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
|
3280 { |
25064
8f2262c72178
patch 8.2.3069: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
24984
diff
changeset
|
3281 *errormsg = _(e_invalid_range); |
14505
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3282 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
|
3283 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3284 |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3285 ++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
|
3286 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
|
3287 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3288 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
|
3289 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
|
3290 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
|
3291 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
|
3292 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
|
3293 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
|
3294 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
|
3295 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
|
3296 ++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
|
3297 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3298 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3299 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3300 else |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3301 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
|
3302 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
|
3303 |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3304 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
|
3305 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3306 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
|
3307 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3308 curwin->w_cursor.lnum = eap->line2; |
20185
0610f1ddb3a0
patch 8.2.0648: semicolon search does not work in first line
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
3309 // Don't leave the cursor on an illegal line or column, but do |
0610f1ddb3a0
patch 8.2.0648: semicolon search does not work in first line
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
3310 // accept zero as address, so 0;/PATTERN/ works correctly. |
0610f1ddb3a0
patch 8.2.0648: semicolon search does not work in first line
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
3311 if (eap->line2 > 0) |
0610f1ddb3a0
patch 8.2.0648: semicolon search does not work in first line
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
3312 check_cursor(); |
14505
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3313 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3314 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3315 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
|
3316 break; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3317 ++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
|
3318 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3319 |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3320 // 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
|
3321 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
|
3322 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3323 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
|
3324 // ... 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
|
3325 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
|
3326 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
|
3327 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3328 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
|
3329 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3330 |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3331 /* |
3097 | 3332 * Append "cmd" to the error message in IObuff. |
3333 * Takes care of limiting the length and handling 0xa0, which would be | |
3334 * invisible otherwise. | |
3335 */ | |
3336 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3337 append_command(char_u *cmd) |
3097 | 3338 { |
3339 char_u *s = cmd; | |
3340 char_u *d; | |
3341 | |
3342 STRCAT(IObuff, ": "); | |
3343 d = IObuff + STRLEN(IObuff); | |
3344 while (*s != NUL && d - IObuff < IOSIZE - 7) | |
3345 { | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
3346 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
|
3347 { |
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
3348 s += enc_utf8 ? 2 : 1; |
3097 | 3349 STRCPY(d, "<a0>"); |
3350 d += 4; | |
3351 } | |
3352 else | |
3353 MB_COPY_CHAR(s, d); | |
3354 } | |
3355 *d = NUL; | |
3356 } | |
3357 | |
3358 /* | |
21937
b931df03adcc
patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents:
21893
diff
changeset
|
3359 * If "start" points "&opt", "&l:opt", "&g:opt" or "$ENV" return a pointer to |
b931df03adcc
patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents:
21893
diff
changeset
|
3360 * the name. Otherwise just return "start". |
b931df03adcc
patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents:
21893
diff
changeset
|
3361 */ |
b931df03adcc
patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents:
21893
diff
changeset
|
3362 char_u * |
b931df03adcc
patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents:
21893
diff
changeset
|
3363 skip_option_env_lead(char_u *start) |
b931df03adcc
patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents:
21893
diff
changeset
|
3364 { |
b931df03adcc
patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents:
21893
diff
changeset
|
3365 char_u *name = start; |
b931df03adcc
patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents:
21893
diff
changeset
|
3366 |
b931df03adcc
patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents:
21893
diff
changeset
|
3367 if (*start == '&') |
b931df03adcc
patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents:
21893
diff
changeset
|
3368 { |
b931df03adcc
patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents:
21893
diff
changeset
|
3369 if ((start[1] == 'l' || start[1] == 'g') && start[2] == ':') |
b931df03adcc
patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents:
21893
diff
changeset
|
3370 name += 3; |
b931df03adcc
patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents:
21893
diff
changeset
|
3371 else |
b931df03adcc
patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents:
21893
diff
changeset
|
3372 name += 1; |
b931df03adcc
patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents:
21893
diff
changeset
|
3373 } |
b931df03adcc
patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents:
21893
diff
changeset
|
3374 else if (*start == '$') |
b931df03adcc
patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents:
21893
diff
changeset
|
3375 name += 1; |
b931df03adcc
patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents:
21893
diff
changeset
|
3376 return name; |
b931df03adcc
patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents:
21893
diff
changeset
|
3377 } |
b931df03adcc
patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents:
21893
diff
changeset
|
3378 |
b931df03adcc
patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents:
21893
diff
changeset
|
3379 /* |
7 | 3380 * Find an Ex command by its name, either built-in or user. |
184 | 3381 * 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
|
3382 * Sets eap->cmdidx and returns a pointer to char after the command name. |
184 | 3383 * "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
|
3384 * |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3385 * 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
|
3386 * 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
|
3387 * "eap->cmd". |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3388 * |
7 | 3389 * Returns NULL for an ambiguous user command. |
3390 */ | |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3391 char_u * |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3392 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
|
3393 exarg_T *eap, |
20075
516b10943fdb
patch 8.2.0593: finding a user command is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
20063
diff
changeset
|
3394 int *full UNUSED, |
24124
f4061617c438
patch 8.2.2603: Vim9: no effect if user command is also a function
Bram Moolenaar <Bram@vim.org>
parents:
24114
diff
changeset
|
3395 int (*lookup)(char_u *, size_t, int cmd, cctx_T *) UNUSED, |
20075
516b10943fdb
patch 8.2.0593: finding a user command is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
20063
diff
changeset
|
3396 cctx_T *cctx UNUSED) |
7 | 3397 { |
3398 int len; | |
3399 char_u *p; | |
167 | 3400 int i; |
24699
b19c8150ee9d
patch 8.2.2888: Vim9: "k" command recognized in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
24697
diff
changeset
|
3401 #ifndef FEAT_EVAL |
b19c8150ee9d
patch 8.2.2888: Vim9: "k" command recognized in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
24697
diff
changeset
|
3402 int vim9 = FALSE; |
b19c8150ee9d
patch 8.2.2888: Vim9: "k" command recognized in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
24697
diff
changeset
|
3403 #else |
b19c8150ee9d
patch 8.2.2888: Vim9: "k" command recognized in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
24697
diff
changeset
|
3404 int vim9 = in_vim9script(); |
b19c8150ee9d
patch 8.2.2888: Vim9: "k" command recognized in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
24697
diff
changeset
|
3405 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3406 /* |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3407 * 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
|
3408 * "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
|
3409 */ |
19481
c27837cbe922
patch 8.2.0298: Vim9 script: cannot start command with a string constant
Bram Moolenaar <Bram@vim.org>
parents:
19475
diff
changeset
|
3410 p = eap->cmd; |
21526
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3411 if (lookup != NULL) |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3412 { |
21937
b931df03adcc
patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents:
21893
diff
changeset
|
3413 char_u *pskip = skip_option_env_lead(eap->cmd); |
21618
9ab43576a13b
patch 8.2.1359: Vim9: cannot assign to / register in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
21596
diff
changeset
|
3414 |
9ab43576a13b
patch 8.2.1359: Vim9: cannot assign to / register in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
21596
diff
changeset
|
3415 if (vim_strchr((char_u *)"{('[\"@", *p) != NULL |
21526
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3416 || ((p = to_name_const_end(pskip)) > eap->cmd && *p != NUL)) |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3417 { |
23709
a0c4d04a58c4
patch 8.2.2396: Vim9: no white space allowed before "->"
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
3418 int oplen; |
a0c4d04a58c4
patch 8.2.2396: Vim9: no white space allowed before "->"
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
3419 int heredoc; |
a0c4d04a58c4
patch 8.2.2396: Vim9: no white space allowed before "->"
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
3420 char_u *swp = skipwhite(p); |
21526
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3421 |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3422 if ( |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3423 // "(..." is an expression. |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3424 // "funcname(" is always a function call. |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3425 *p == '(' |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3426 || (p == eap->cmd |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3427 ? ( |
22555
7d25264c246c
patch 8.2.1826: Vim9: cannot use a {} block at script level
Bram Moolenaar <Bram@vim.org>
parents:
22543
diff
changeset
|
3428 // "{..." is a dict expression or block start. |
21526
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3429 *eap->cmd == '{' |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3430 // "'string'->func()" is an expression. |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3431 || *eap->cmd == '\'' |
21544
6c67c86a202a
patch 8.2.1322: Vim9: method on double quoted string doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
21526
diff
changeset
|
3432 // '"string"->func()' is an expression. |
6c67c86a202a
patch 8.2.1322: Vim9: method on double quoted string doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
21526
diff
changeset
|
3433 || *eap->cmd == '"' |
21526
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3434 // "g:varname" is an expression. |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3435 || eap->cmd[1] == ':' |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3436 ) |
22268
2eaee3396f7a
patch 8.2.1683: Vim9: assignment test fails
Bram Moolenaar <Bram@vim.org>
parents:
22260
diff
changeset
|
3437 // "varname->func()" is an expression. |
23709
a0c4d04a58c4
patch 8.2.2396: Vim9: no white space allowed before "->"
Bram Moolenaar <Bram@vim.org>
parents:
23648
diff
changeset
|
3438 : (*swp == '-' && swp[1] == '>'))) |
22268
2eaee3396f7a
patch 8.2.1683: Vim9: assignment test fails
Bram Moolenaar <Bram@vim.org>
parents:
22260
diff
changeset
|
3439 { |
22555
7d25264c246c
patch 8.2.1826: Vim9: cannot use a {} block at script level
Bram Moolenaar <Bram@vim.org>
parents:
22543
diff
changeset
|
3440 if (*eap->cmd == '{' && ends_excmd(*skipwhite(eap->cmd + 1))) |
7d25264c246c
patch 8.2.1826: Vim9: cannot use a {} block at script level
Bram Moolenaar <Bram@vim.org>
parents:
22543
diff
changeset
|
3441 { |
7d25264c246c
patch 8.2.1826: Vim9: cannot use a {} block at script level
Bram Moolenaar <Bram@vim.org>
parents:
22543
diff
changeset
|
3442 // "{" by itself is the start of a block. |
7d25264c246c
patch 8.2.1826: Vim9: cannot use a {} block at script level
Bram Moolenaar <Bram@vim.org>
parents:
22543
diff
changeset
|
3443 eap->cmdidx = CMD_block; |
7d25264c246c
patch 8.2.1826: Vim9: cannot use a {} block at script level
Bram Moolenaar <Bram@vim.org>
parents:
22543
diff
changeset
|
3444 return eap->cmd + 1; |
7d25264c246c
patch 8.2.1826: Vim9: cannot use a {} block at script level
Bram Moolenaar <Bram@vim.org>
parents:
22543
diff
changeset
|
3445 } |
22268
2eaee3396f7a
patch 8.2.1683: Vim9: assignment test fails
Bram Moolenaar <Bram@vim.org>
parents:
22260
diff
changeset
|
3446 eap->cmdidx = CMD_eval; |
2eaee3396f7a
patch 8.2.1683: Vim9: assignment test fails
Bram Moolenaar <Bram@vim.org>
parents:
22260
diff
changeset
|
3447 return eap->cmd; |
2eaee3396f7a
patch 8.2.1683: Vim9: assignment test fails
Bram Moolenaar <Bram@vim.org>
parents:
22260
diff
changeset
|
3448 } |
2eaee3396f7a
patch 8.2.1683: Vim9: assignment test fails
Bram Moolenaar <Bram@vim.org>
parents:
22260
diff
changeset
|
3449 |
2eaee3396f7a
patch 8.2.1683: Vim9: assignment test fails
Bram Moolenaar <Bram@vim.org>
parents:
22260
diff
changeset
|
3450 if (p != eap->cmd && ( |
21526
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3451 // "varname[]" is an expression. |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3452 *p == '[' |
22268
2eaee3396f7a
patch 8.2.1683: Vim9: assignment test fails
Bram Moolenaar <Bram@vim.org>
parents:
22260
diff
changeset
|
3453 // "varname.key" is an expression. |
25330
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25320
diff
changeset
|
3454 || (*p == '.' && (ASCII_ISALPHA(p[1]) |
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25320
diff
changeset
|
3455 || p[1] == '_')))) |
21413
8992d4f63761
patch 8.2.1257: Vim9: list unpack doesn't work at the script level
Bram Moolenaar <Bram@vim.org>
parents:
21357
diff
changeset
|
3456 { |
24434
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
24428
diff
changeset
|
3457 char_u *after = eap->cmd; |
22268
2eaee3396f7a
patch 8.2.1683: Vim9: assignment test fails
Bram Moolenaar <Bram@vim.org>
parents:
22260
diff
changeset
|
3458 |
2eaee3396f7a
patch 8.2.1683: Vim9: assignment test fails
Bram Moolenaar <Bram@vim.org>
parents:
22260
diff
changeset
|
3459 // When followed by "=" or "+=" then it is an assignment. |
24434
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
24428
diff
changeset
|
3460 // Skip over the whole thing, it can be: |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
24428
diff
changeset
|
3461 // name.member = val |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
24428
diff
changeset
|
3462 // name[a : b] = val |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
24428
diff
changeset
|
3463 // name[idx] = val |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
24428
diff
changeset
|
3464 // name[idx].member = val |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
24428
diff
changeset
|
3465 // etc. |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
24428
diff
changeset
|
3466 eap->cmdidx = CMD_eval; |
22268
2eaee3396f7a
patch 8.2.1683: Vim9: assignment test fails
Bram Moolenaar <Bram@vim.org>
parents:
22260
diff
changeset
|
3467 ++emsg_silent; |
23039
75241f4377a4
patch 8.2.2066: Vim9: assignment with += doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
23023
diff
changeset
|
3468 if (skip_expr(&after, NULL) == OK) |
24434
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
24428
diff
changeset
|
3469 { |
23039
75241f4377a4
patch 8.2.2066: Vim9: assignment with += doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
23023
diff
changeset
|
3470 after = skipwhite(after); |
24434
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
24428
diff
changeset
|
3471 if (*after == '=' || (*after != NUL && after[1] == '=') |
23039
75241f4377a4
patch 8.2.2066: Vim9: assignment with += doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
23023
diff
changeset
|
3472 || (after[0] == '.' && after[1] == '.' |
75241f4377a4
patch 8.2.2066: Vim9: assignment with += doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
23023
diff
changeset
|
3473 && after[2] == '=')) |
24434
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
24428
diff
changeset
|
3474 eap->cmdidx = CMD_var; |
602e528a8e43
patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents:
24428
diff
changeset
|
3475 } |
22268
2eaee3396f7a
patch 8.2.1683: Vim9: assignment test fails
Bram Moolenaar <Bram@vim.org>
parents:
22260
diff
changeset
|
3476 --emsg_silent; |
21413
8992d4f63761
patch 8.2.1257: Vim9: list unpack doesn't work at the script level
Bram Moolenaar <Bram@vim.org>
parents:
21357
diff
changeset
|
3477 return eap->cmd; |
8992d4f63761
patch 8.2.1257: Vim9: list unpack doesn't work at the script level
Bram Moolenaar <Bram@vim.org>
parents:
21357
diff
changeset
|
3478 } |
21526
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3479 |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3480 // "[...]->Method()" is a list expression, but "[a, b] = Func()" is |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3481 // an assignment. |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3482 // If there is no line break inside the "[...]" then "p" is |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3483 // advanced to after the "]" by to_name_const_end(): check if a "=" |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3484 // follows. |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3485 // If "[...]" has a line break "p" still points at the "[" and it |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3486 // can't be an assignment. |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3487 if (*eap->cmd == '[') |
21413
8992d4f63761
patch 8.2.1257: Vim9: list unpack doesn't work at the script level
Bram Moolenaar <Bram@vim.org>
parents:
21357
diff
changeset
|
3488 { |
24984
71b1e2ef0069
patch 8.2.3029: Vim9: crash when using operator and list unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
24966
diff
changeset
|
3489 char_u *eq; |
71b1e2ef0069
patch 8.2.3029: Vim9: crash when using operator and list unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
24966
diff
changeset
|
3490 |
21526
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3491 p = to_name_const_end(eap->cmd); |
23050
50442f932ff7
patch 8.2.2071: Vim9: list assign doesn't except empty remainder list
Bram Moolenaar <Bram@vim.org>
parents:
23039
diff
changeset
|
3492 if (p == eap->cmd && *p == '[') |
50442f932ff7
patch 8.2.2071: Vim9: list assign doesn't except empty remainder list
Bram Moolenaar <Bram@vim.org>
parents:
23039
diff
changeset
|
3493 { |
50442f932ff7
patch 8.2.2071: Vim9: list assign doesn't except empty remainder list
Bram Moolenaar <Bram@vim.org>
parents:
23039
diff
changeset
|
3494 int count = 0; |
50442f932ff7
patch 8.2.2071: Vim9: list assign doesn't except empty remainder list
Bram Moolenaar <Bram@vim.org>
parents:
23039
diff
changeset
|
3495 int semicolon = FALSE; |
50442f932ff7
patch 8.2.2071: Vim9: list assign doesn't except empty remainder list
Bram Moolenaar <Bram@vim.org>
parents:
23039
diff
changeset
|
3496 |
50442f932ff7
patch 8.2.2071: Vim9: list assign doesn't except empty remainder list
Bram Moolenaar <Bram@vim.org>
parents:
23039
diff
changeset
|
3497 p = skip_var_list(eap->cmd, TRUE, &count, &semicolon, TRUE); |
50442f932ff7
patch 8.2.2071: Vim9: list assign doesn't except empty remainder list
Bram Moolenaar <Bram@vim.org>
parents:
23039
diff
changeset
|
3498 } |
24984
71b1e2ef0069
patch 8.2.3029: Vim9: crash when using operator and list unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
24966
diff
changeset
|
3499 eq = p; |
71b1e2ef0069
patch 8.2.3029: Vim9: crash when using operator and list unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
24966
diff
changeset
|
3500 if (eq != NULL) |
71b1e2ef0069
patch 8.2.3029: Vim9: crash when using operator and list unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
24966
diff
changeset
|
3501 { |
71b1e2ef0069
patch 8.2.3029: Vim9: crash when using operator and list unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
24966
diff
changeset
|
3502 eq = skipwhite(eq); |
71b1e2ef0069
patch 8.2.3029: Vim9: crash when using operator and list unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
24966
diff
changeset
|
3503 if (vim_strchr((char_u *)"+-*/%", *eq) != NULL) |
71b1e2ef0069
patch 8.2.3029: Vim9: crash when using operator and list unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
24966
diff
changeset
|
3504 ++eq; |
71b1e2ef0069
patch 8.2.3029: Vim9: crash when using operator and list unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
24966
diff
changeset
|
3505 } |
71b1e2ef0069
patch 8.2.3029: Vim9: crash when using operator and list unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
24966
diff
changeset
|
3506 if (p == NULL || p == eap->cmd || *eq != '=') |
21526
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3507 { |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3508 eap->cmdidx = CMD_eval; |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3509 return eap->cmd; |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3510 } |
24984
71b1e2ef0069
patch 8.2.3029: Vim9: crash when using operator and list unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
24966
diff
changeset
|
3511 if (p > eap->cmd && *eq == '=') |
21526
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3512 { |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22361
diff
changeset
|
3513 eap->cmdidx = CMD_var; |
21526
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3514 return eap->cmd; |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3515 } |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3516 } |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3517 |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3518 // Recognize an assignment if we recognize the variable name: |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3519 // "g:var = expr" |
24462
7c4f50c02e18
patch 8.2.2771: Vim9: assignment not recognized if declaration was skipped
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
3520 // "var = expr" where "var" is a variable name or we are skipping |
7c4f50c02e18
patch 8.2.2771: Vim9: assignment not recognized if declaration was skipped
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
3521 // (variable declaration might have been skipped). |
21618
9ab43576a13b
patch 8.2.1359: Vim9: cannot assign to / register in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
21596
diff
changeset
|
3522 if (*eap->cmd == '@') |
9ab43576a13b
patch 8.2.1359: Vim9: cannot assign to / register in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
21596
diff
changeset
|
3523 p = eap->cmd + 2; |
21526
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3524 oplen = assignment_len(skipwhite(p), &heredoc); |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3525 if (oplen > 0) |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3526 { |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3527 if (((p - eap->cmd) > 2 && eap->cmd[1] == ':') |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3528 || *eap->cmd == '&' |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3529 || *eap->cmd == '$' |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3530 || *eap->cmd == '@' |
24462
7c4f50c02e18
patch 8.2.2771: Vim9: assignment not recognized if declaration was skipped
Bram Moolenaar <Bram@vim.org>
parents:
24434
diff
changeset
|
3531 || eap->skip |
24124
f4061617c438
patch 8.2.2603: Vim9: no effect if user command is also a function
Bram Moolenaar <Bram@vim.org>
parents:
24114
diff
changeset
|
3532 || lookup(eap->cmd, p - eap->cmd, TRUE, cctx) == OK) |
21526
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3533 { |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22361
diff
changeset
|
3534 eap->cmdidx = CMD_var; |
21526
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3535 return eap->cmd; |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3536 } |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3537 } |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3538 |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3539 // Recognize using a type for a w:, b:, t: or g: variable: |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3540 // "w:varname: number = 123". |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3541 if (eap->cmd[1] == ':' && *p == ':') |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3542 { |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3543 eap->cmdidx = CMD_eval; |
21413
8992d4f63761
patch 8.2.1257: Vim9: list unpack doesn't work at the script level
Bram Moolenaar <Bram@vim.org>
parents:
21357
diff
changeset
|
3544 return eap->cmd; |
8992d4f63761
patch 8.2.1257: Vim9: list unpack doesn't work at the script level
Bram Moolenaar <Bram@vim.org>
parents:
21357
diff
changeset
|
3545 } |
21130
4a1e8086759b
patch 8.2.1116: Vim9: parsing command checks for list twice
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
3546 } |
23823
262ab14b27db
patch 8.2.2453: Vim9: a variable name with "->" in the next line doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
23742
diff
changeset
|
3547 |
262ab14b27db
patch 8.2.2453: Vim9: a variable name with "->" in the next line doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
23742
diff
changeset
|
3548 // If it is an ID it might be a variable with an operator on the next |
262ab14b27db
patch 8.2.2453: Vim9: a variable name with "->" in the next line doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
23742
diff
changeset
|
3549 // line, if the variable exists it can't be an Ex command. |
262ab14b27db
patch 8.2.2453: Vim9: a variable name with "->" in the next line doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
23742
diff
changeset
|
3550 if (p > eap->cmd && ends_excmd(*skipwhite(p)) |
24124
f4061617c438
patch 8.2.2603: Vim9: no effect if user command is also a function
Bram Moolenaar <Bram@vim.org>
parents:
24114
diff
changeset
|
3551 && (lookup(eap->cmd, p - eap->cmd, TRUE, cctx) == OK |
23823
262ab14b27db
patch 8.2.2453: Vim9: a variable name with "->" in the next line doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
23742
diff
changeset
|
3552 || (ASCII_ISALPHA(eap->cmd[0]) && eap->cmd[1] == ':'))) |
262ab14b27db
patch 8.2.2453: Vim9: a variable name with "->" in the next line doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
23742
diff
changeset
|
3553 { |
262ab14b27db
patch 8.2.2453: Vim9: a variable name with "->" in the next line doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
23742
diff
changeset
|
3554 eap->cmdidx = CMD_eval; |
262ab14b27db
patch 8.2.2453: Vim9: a variable name with "->" in the next line doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
23742
diff
changeset
|
3555 return eap->cmd; |
262ab14b27db
patch 8.2.2453: Vim9: a variable name with "->" in the next line doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
23742
diff
changeset
|
3556 } |
24533
9c404d78d767
patch 8.2.2806: Vim9: using "++nr" as a command might not work
Bram Moolenaar <Bram@vim.org>
parents:
24531
diff
changeset
|
3557 |
9c404d78d767
patch 8.2.2806: Vim9: using "++nr" as a command might not work
Bram Moolenaar <Bram@vim.org>
parents:
24531
diff
changeset
|
3558 // Check for "++nr" and "--nr". |
9c404d78d767
patch 8.2.2806: Vim9: using "++nr" as a command might not work
Bram Moolenaar <Bram@vim.org>
parents:
24531
diff
changeset
|
3559 if (p == eap->cmd && p[0] == p[1] && (*p == '+' || *p == '-')) |
9c404d78d767
patch 8.2.2806: Vim9: using "++nr" as a command might not work
Bram Moolenaar <Bram@vim.org>
parents:
24531
diff
changeset
|
3560 { |
9c404d78d767
patch 8.2.2806: Vim9: using "++nr" as a command might not work
Bram Moolenaar <Bram@vim.org>
parents:
24531
diff
changeset
|
3561 eap->cmdidx = *p == '+' ? CMD_increment : CMD_decrement; |
9c404d78d767
patch 8.2.2806: Vim9: using "++nr" as a command might not work
Bram Moolenaar <Bram@vim.org>
parents:
24531
diff
changeset
|
3562 return eap->cmd + 2; |
9c404d78d767
patch 8.2.2806: Vim9: using "++nr" as a command might not work
Bram Moolenaar <Bram@vim.org>
parents:
24531
diff
changeset
|
3563 } |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3564 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3565 #endif |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3566 |
7 | 3567 /* |
3568 * Isolate the command and search for it in the command table. | |
1441 | 3569 * Exceptions: |
23978
54b2aa1f0d42
patch 8.2.2531: Vim9: the :k command is obscure
Bram Moolenaar <Bram@vim.org>
parents:
23974
diff
changeset
|
3570 * - The 'k' command can directly be followed by any character. |
54b2aa1f0d42
patch 8.2.2531: Vim9: the :k command is obscure
Bram Moolenaar <Bram@vim.org>
parents:
23974
diff
changeset
|
3571 * But it is not used in Vim9 script. |
7 | 3572 * - the 's' command can be followed directly by 'c', 'g', 'i', 'I' or 'r' |
6472 | 3573 * but :sre[wind] is another command, as are :scr[iptnames], |
7 | 3574 * :scs[cope], :sim[alt], :sig[ns] and :sil[ent]. |
167 | 3575 * - the "d" command can directly be followed by 'l' or 'p' flag. |
7 | 3576 */ |
3577 p = eap->cmd; | |
24699
b19c8150ee9d
patch 8.2.2888: Vim9: "k" command recognized in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
24697
diff
changeset
|
3578 if (!vim9 && *p == 'k') |
7 | 3579 { |
3580 eap->cmdidx = CMD_k; | |
3581 ++p; | |
3582 } | |
24699
b19c8150ee9d
patch 8.2.2888: Vim9: "k" command recognized in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
24697
diff
changeset
|
3583 else if (!vim9 |
b19c8150ee9d
patch 8.2.2888: Vim9: "k" command recognized in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
24697
diff
changeset
|
3584 && p[0] == 's' |
6987 | 3585 && ((p[1] == 'c' && (p[2] == NUL || (p[2] != 's' && p[2] != 'r' |
3586 && (p[3] == NUL || (p[3] != 'i' && p[4] != 'p'))))) | |
7 | 3587 || p[1] == 'g' |
3588 || (p[1] == 'i' && p[2] != 'm' && p[2] != 'l' && p[2] != 'g') | |
3589 || p[1] == 'I' | |
3590 || (p[1] == 'r' && p[2] != 'e'))) | |
3591 { | |
3592 eap->cmdidx = CMD_substitute; | |
3593 ++p; | |
3594 } | |
3595 else | |
3596 { | |
3597 while (ASCII_ISALPHA(*p)) | |
3598 ++p; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3599 // for python 3.x support ":py3", ":python3", ":py3file", etc. |
2330 | 3600 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
|
3601 { |
2366
7a57fe6a5157
Fix that :py3file was not working.
Bram Moolenaar <bram@vim.org>
parents:
2360
diff
changeset
|
3602 while (ASCII_ISALNUM(*p)) |
7a57fe6a5157
Fix that :py3file was not working.
Bram Moolenaar <bram@vim.org>
parents:
2360
diff
changeset
|
3603 ++p; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3604 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3605 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
|
3606 { |
24256
b471a413d36a
patch 8.2.2669: command line completion does not work after "vim9"
Bram Moolenaar <Bram@vim.org>
parents:
24254
diff
changeset
|
3607 // include "9" for "vim9*" commands; "vim9cmd" and "vim9script". |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3608 ++p; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3609 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
|
3610 ++p; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3611 } |
2329
ad2889f48843
Added support for Python 3. (Roland Puntaier)
Bram Moolenaar <bram@vim.org>
parents:
2320
diff
changeset
|
3612 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3613 // check for non-alpha command |
22555
7d25264c246c
patch 8.2.1826: Vim9: cannot use a {} block at script level
Bram Moolenaar <Bram@vim.org>
parents:
22543
diff
changeset
|
3614 if (p == eap->cmd && vim_strchr((char_u *)"@*!=><&~#}", *p) != NULL) |
7 | 3615 ++p; |
3616 len = (int)(p - eap->cmd); | |
24699
b19c8150ee9d
patch 8.2.2888: Vim9: "k" command recognized in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
24697
diff
changeset
|
3617 if (!vim9 && *eap->cmd == 'd' && (p[-1] == 'l' || p[-1] == 'p')) |
167 | 3618 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3619 // 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
|
3620 // :delete with the 'l' flag. Same for 'p'. |
167 | 3621 for (i = 0; i < len; ++i) |
1872 | 3622 if (eap->cmd[i] != ((char_u *)"delete")[i]) |
167 | 3623 break; |
3624 if (i == len - 1) | |
3625 { | |
3626 --len; | |
3627 if (p[-1] == 'l') | |
3628 eap->flags |= EXFLAG_LIST; | |
3629 else | |
3630 eap->flags |= EXFLAG_PRINT; | |
3631 } | |
3632 } | |
7 | 3633 |
11236
62c96fee518e
patch 8.0.0504: looking up an Ex command is a bit slow
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
3634 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
|
3635 { |
11240
06307d812ca7
patch 8.0.0506: can't build with ANSI C
Christian Brabandt <cb@256bit.org>
parents:
11236
diff
changeset
|
3636 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
|
3637 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
|
3638 |
11236
62c96fee518e
patch 8.0.0504: looking up an Ex command is a bit slow
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
3639 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
|
3640 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
3641 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
|
3642 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
|
3643 } |
62c96fee518e
patch 8.0.0504: looking up an Ex command is a bit slow
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
3644 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3645 // 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
|
3646 // 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
|
3647 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
|
3648 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
|
3649 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
|
3650 } |
20075
516b10943fdb
patch 8.2.0593: finding a user command is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
20063
diff
changeset
|
3651 else if (ASCII_ISUPPER(eap->cmd[0])) |
516b10943fdb
patch 8.2.0593: finding a user command is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
20063
diff
changeset
|
3652 eap->cmdidx = CMD_Next; |
7 | 3653 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
|
3654 eap->cmdidx = CMD_bang; |
7 | 3655 |
3656 for ( ; (int)eap->cmdidx < (int)CMD_SIZE; | |
3657 eap->cmdidx = (cmdidx_T)((int)eap->cmdidx + 1)) | |
3658 if (STRNCMP(cmdnames[(int)eap->cmdidx].cmd_name, (char *)eap->cmd, | |
3659 (size_t)len) == 0) | |
3660 { | |
3661 #ifdef FEAT_EVAL | |
3662 if (full != NULL | |
3663 && cmdnames[(int)eap->cmdidx].cmd_name[len] == NUL) | |
3664 *full = TRUE; | |
3665 #endif | |
3666 break; | |
3667 } | |
3668 | |
22950
1270401054d8
patch 8.2.2022: Vim9: star command recognized errornously
Bram Moolenaar <Bram@vim.org>
parents:
22948
diff
changeset
|
3669 // Not not recognize ":*" as the star command unless '*' is in |
1270401054d8
patch 8.2.2022: Vim9: star command recognized errornously
Bram Moolenaar <Bram@vim.org>
parents:
22948
diff
changeset
|
3670 // 'cpoptions'. |
1270401054d8
patch 8.2.2022: Vim9: star command recognized errornously
Bram Moolenaar <Bram@vim.org>
parents:
22948
diff
changeset
|
3671 if (eap->cmdidx == CMD_star && vim_strchr(p_cpo, CPO_STAR) == NULL) |
1270401054d8
patch 8.2.2022: Vim9: star command recognized errornously
Bram Moolenaar <Bram@vim.org>
parents:
22948
diff
changeset
|
3672 p = eap->cmd; |
1270401054d8
patch 8.2.2022: Vim9: star command recognized errornously
Bram Moolenaar <Bram@vim.org>
parents:
22948
diff
changeset
|
3673 |
16411
5b5c5daf57de
patch 8.1.1210: support for user commands is spread out
Bram Moolenaar <Bram@vim.org>
parents:
16399
diff
changeset
|
3674 // 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
|
3675 // overruled by a user defined command. |
2633 | 3676 if ((eap->cmdidx == CMD_SIZE || eap->cmdidx == CMD_Print) |
3677 && *eap->cmd >= 'A' && *eap->cmd <= 'Z') | |
7 | 3678 { |
16411
5b5c5daf57de
patch 8.1.1210: support for user commands is spread out
Bram Moolenaar <Bram@vim.org>
parents:
16399
diff
changeset
|
3679 // User defined commands may contain digits. |
7 | 3680 while (ASCII_ISALNUM(*p)) |
3681 ++p; | |
184 | 3682 p = find_ucmd(eap, p, full, NULL, NULL); |
3683 } | |
23205
d998222d314d
patch 8.2.2148: Vim9: crash when user command doesn't match
Bram Moolenaar <Bram@vim.org>
parents:
23189
diff
changeset
|
3684 if (p == NULL || p == eap->cmd) |
7 | 3685 eap->cmdidx = CMD_SIZE; |
3686 } | |
3687 | |
22395
03249b8976a9
patch 8.2.1746: Vim9: cannot use "fina" for "finally"
Bram Moolenaar <Bram@vim.org>
parents:
22393
diff
changeset
|
3688 // ":fina" means ":finally" for backwards compatibility. |
03249b8976a9
patch 8.2.1746: Vim9: cannot use "fina" for "finally"
Bram Moolenaar <Bram@vim.org>
parents:
22393
diff
changeset
|
3689 if (eap->cmdidx == CMD_final && p - eap->cmd == 4) |
03249b8976a9
patch 8.2.1746: Vim9: cannot use "fina" for "finally"
Bram Moolenaar <Bram@vim.org>
parents:
22393
diff
changeset
|
3690 eap->cmdidx = CMD_finally; |
03249b8976a9
patch 8.2.1746: Vim9: cannot use "fina" for "finally"
Bram Moolenaar <Bram@vim.org>
parents:
22393
diff
changeset
|
3691 |
23189
ea43f4117d06
patch 8.2.2140: build failure with tiny features
Bram Moolenaar <Bram@vim.org>
parents:
23185
diff
changeset
|
3692 #ifdef FEAT_EVAL |
23513
872239543313
patch 8.2.2299: Vim9: invalid memory access making error message flaky
Bram Moolenaar <Bram@vim.org>
parents:
23505
diff
changeset
|
3693 if (eap->cmdidx < CMD_SIZE |
24699
b19c8150ee9d
patch 8.2.2888: Vim9: "k" command recognized in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
24697
diff
changeset
|
3694 && vim9 |
25304
d39c12f97298
patch 8.2.3189: Vim9: error when using "try|"
Bram Moolenaar <Bram@vim.org>
parents:
25294
diff
changeset
|
3695 && !IS_WHITE_OR_NUL(*p) && *p != '\n' && *p != '!' && *p != '|' |
23513
872239543313
patch 8.2.2299: Vim9: invalid memory access making error message flaky
Bram Moolenaar <Bram@vim.org>
parents:
23505
diff
changeset
|
3696 && (eap->cmdidx < 0 || |
872239543313
patch 8.2.2299: Vim9: invalid memory access making error message flaky
Bram Moolenaar <Bram@vim.org>
parents:
23505
diff
changeset
|
3697 (cmdnames[eap->cmdidx].cmd_argt & EX_NONWHITE_OK) == 0)) |
23185
055fa9db6f39
patch 8.2.2138: Vim9: "exit_cb" causes Vim to exit
Bram Moolenaar <Bram@vim.org>
parents:
23179
diff
changeset
|
3698 { |
24543
b3bd27751e09
patch 8.2.2811: Vim9: error for missing white space doesn't say where
Bram Moolenaar <Bram@vim.org>
parents:
24535
diff
changeset
|
3699 char_u *cmd = vim_strnsave(eap->cmd, p - eap->cmd); |
b3bd27751e09
patch 8.2.2811: Vim9: error for missing white space doesn't say where
Bram Moolenaar <Bram@vim.org>
parents:
24535
diff
changeset
|
3700 |
b3bd27751e09
patch 8.2.2811: Vim9: error for missing white space doesn't say where
Bram Moolenaar <Bram@vim.org>
parents:
24535
diff
changeset
|
3701 semsg(_(e_command_str_not_followed_by_white_space_str), cmd, eap->cmd); |
23185
055fa9db6f39
patch 8.2.2138: Vim9: "exit_cb" causes Vim to exit
Bram Moolenaar <Bram@vim.org>
parents:
23179
diff
changeset
|
3702 eap->cmdidx = CMD_SIZE; |
24543
b3bd27751e09
patch 8.2.2811: Vim9: error for missing white space doesn't say where
Bram Moolenaar <Bram@vim.org>
parents:
24535
diff
changeset
|
3703 vim_free(cmd); |
23185
055fa9db6f39
patch 8.2.2138: Vim9: "exit_cb" causes Vim to exit
Bram Moolenaar <Bram@vim.org>
parents:
23179
diff
changeset
|
3704 } |
23189
ea43f4117d06
patch 8.2.2140: build failure with tiny features
Bram Moolenaar <Bram@vim.org>
parents:
23185
diff
changeset
|
3705 #endif |
23185
055fa9db6f39
patch 8.2.2138: Vim9: "exit_cb" causes Vim to exit
Bram Moolenaar <Bram@vim.org>
parents:
23179
diff
changeset
|
3706 |
7 | 3707 return p; |
3708 } | |
3709 | |
3710 #if defined(FEAT_EVAL) || defined(PROTO) | |
1447 | 3711 static struct cmdmod |
3712 { | |
3713 char *name; | |
3714 int minlen; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3715 int has_count; // :123verbose :3tab |
1447 | 3716 } cmdmods[] = { |
3717 {"aboveleft", 3, FALSE}, | |
3718 {"belowright", 3, FALSE}, | |
3719 {"botright", 2, FALSE}, | |
3720 {"browse", 3, FALSE}, | |
3721 {"confirm", 4, FALSE}, | |
9941
e975914c17e9
commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
9927
diff
changeset
|
3722 {"filter", 4, FALSE}, |
1447 | 3723 {"hide", 3, FALSE}, |
3724 {"keepalt", 5, FALSE}, | |
3725 {"keepjumps", 5, FALSE}, | |
3726 {"keepmarks", 3, FALSE}, | |
5467 | 3727 {"keeppatterns", 5, FALSE}, |
1447 | 3728 {"leftabove", 5, FALSE}, |
3729 {"lockmarks", 3, FALSE}, | |
1721 | 3730 {"noautocmd", 3, FALSE}, |
5737 | 3731 {"noswapfile", 3, FALSE}, |
1447 | 3732 {"rightbelow", 6, FALSE}, |
3733 {"sandbox", 3, FALSE}, | |
3734 {"silent", 3, FALSE}, | |
3735 {"tab", 3, TRUE}, | |
3736 {"topleft", 2, FALSE}, | |
1926 | 3737 {"unsilent", 3, FALSE}, |
1447 | 3738 {"verbose", 4, TRUE}, |
3739 {"vertical", 4, FALSE}, | |
3740 }; | |
3741 | |
3742 /* | |
3743 * Return length of a command modifier (including optional count). | |
3744 * Return zero when it's not a modifier. | |
3745 */ | |
3746 int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3747 modifier_len(char_u *cmd) |
1447 | 3748 { |
3749 int i, j; | |
3750 char_u *p = cmd; | |
3751 | |
3752 if (VIM_ISDIGIT(*cmd)) | |
24665
661d15592d3c
patch 8.2.2871: unnessary VIM_ISDIGIT() calls, badly indented code
Bram Moolenaar <Bram@vim.org>
parents:
24555
diff
changeset
|
3753 p = skipwhite(skipdigits(cmd + 1)); |
24768
7334bf933510
patch 8.2.2922: computing array length is done in various ways
Bram Moolenaar <Bram@vim.org>
parents:
24723
diff
changeset
|
3754 for (i = 0; i < (int)ARRAY_LENGTH(cmdmods); ++i) |
1447 | 3755 { |
3756 for (j = 0; p[j] != NUL; ++j) | |
3757 if (p[j] != cmdmods[i].name[j]) | |
3758 break; | |
4857
84a8d1ba81c3
updated for version 7.3.1175
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3759 if (!ASCII_ISALPHA(p[j]) && j >= cmdmods[i].minlen |
1447 | 3760 && (p == cmd || cmdmods[i].has_count)) |
1570 | 3761 return j + (int)(p - cmd); |
1447 | 3762 } |
3763 return 0; | |
3764 } | |
3765 | |
7 | 3766 /* |
3767 * Return > 0 if an Ex command "name" exists. | |
3768 * Return 2 if there is an exact match. | |
3769 * Return 3 if there is an ambiguous match. | |
3770 */ | |
3771 int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3772 cmd_exists(char_u *name) |
7 | 3773 { |
3774 exarg_T ea; | |
3775 int full = FALSE; | |
3776 int i; | |
3777 int j; | |
866 | 3778 char_u *p; |
7 | 3779 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3780 // Check command modifiers. |
24768
7334bf933510
patch 8.2.2922: computing array length is done in various ways
Bram Moolenaar <Bram@vim.org>
parents:
24723
diff
changeset
|
3781 for (i = 0; i < (int)ARRAY_LENGTH(cmdmods); ++i) |
7 | 3782 { |
3783 for (j = 0; name[j] != NUL; ++j) | |
3784 if (name[j] != cmdmods[i].name[j]) | |
3785 break; | |
3786 if (name[j] == NUL && j >= cmdmods[i].minlen) | |
3787 return (cmdmods[i].name[j] == NUL ? 2 : 1); | |
3788 } | |
3789 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3790 // 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
|
3791 // For ":2match" and ":3match" we need to skip the number. |
862 | 3792 ea.cmd = (*name == '2' || *name == '3') ? name + 1 : name; |
7 | 3793 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
|
3794 p = find_ex_command(&ea, &full, NULL, NULL); |
866 | 3795 if (p == NULL) |
7 | 3796 return 3; |
862 | 3797 if (vim_isdigit(*name) && ea.cmdidx != CMD_match) |
3798 return 0; | |
866 | 3799 if (*skipwhite(p) != NUL) |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3800 return 0; // trailing garbage |
7 | 3801 return (ea.cmdidx == CMD_SIZE ? 0 : (full ? 2 : 1)); |
3802 } | |
23853
a9ed31ab85c3
patch 8.2.2468: not easy to get the full command name from a shortened one
Bram Moolenaar <Bram@vim.org>
parents:
23823
diff
changeset
|
3803 |
a9ed31ab85c3
patch 8.2.2468: not easy to get the full command name from a shortened one
Bram Moolenaar <Bram@vim.org>
parents:
23823
diff
changeset
|
3804 /* |
a9ed31ab85c3
patch 8.2.2468: not easy to get the full command name from a shortened one
Bram Moolenaar <Bram@vim.org>
parents:
23823
diff
changeset
|
3805 * "fullcommand" function |
a9ed31ab85c3
patch 8.2.2468: not easy to get the full command name from a shortened one
Bram Moolenaar <Bram@vim.org>
parents:
23823
diff
changeset
|
3806 */ |
a9ed31ab85c3
patch 8.2.2468: not easy to get the full command name from a shortened one
Bram Moolenaar <Bram@vim.org>
parents:
23823
diff
changeset
|
3807 void |
a9ed31ab85c3
patch 8.2.2468: not easy to get the full command name from a shortened one
Bram Moolenaar <Bram@vim.org>
parents:
23823
diff
changeset
|
3808 f_fullcommand(typval_T *argvars, typval_T *rettv) |
a9ed31ab85c3
patch 8.2.2468: not easy to get the full command name from a shortened one
Bram Moolenaar <Bram@vim.org>
parents:
23823
diff
changeset
|
3809 { |
a9ed31ab85c3
patch 8.2.2468: not easy to get the full command name from a shortened one
Bram Moolenaar <Bram@vim.org>
parents:
23823
diff
changeset
|
3810 exarg_T ea; |
25384
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25330
diff
changeset
|
3811 char_u *name; |
23853
a9ed31ab85c3
patch 8.2.2468: not easy to get the full command name from a shortened one
Bram Moolenaar <Bram@vim.org>
parents:
23823
diff
changeset
|
3812 char_u *p; |
a9ed31ab85c3
patch 8.2.2468: not easy to get the full command name from a shortened one
Bram Moolenaar <Bram@vim.org>
parents:
23823
diff
changeset
|
3813 |
24697
a6e43da449af
patch 8.2.2887: crash when passing null string to fullcommand()
Bram Moolenaar <Bram@vim.org>
parents:
24665
diff
changeset
|
3814 rettv->v_type = VAR_STRING; |
a6e43da449af
patch 8.2.2887: crash when passing null string to fullcommand()
Bram Moolenaar <Bram@vim.org>
parents:
24665
diff
changeset
|
3815 rettv->vval.v_string = NULL; |
25384
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25330
diff
changeset
|
3816 |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25330
diff
changeset
|
3817 if (in_vim9script() && check_for_string_arg(argvars, 0) == FAIL) |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25330
diff
changeset
|
3818 return; |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25330
diff
changeset
|
3819 |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25330
diff
changeset
|
3820 name = argvars[0].vval.v_string; |
24697
a6e43da449af
patch 8.2.2887: crash when passing null string to fullcommand()
Bram Moolenaar <Bram@vim.org>
parents:
24665
diff
changeset
|
3821 if (name == NULL) |
a6e43da449af
patch 8.2.2887: crash when passing null string to fullcommand()
Bram Moolenaar <Bram@vim.org>
parents:
24665
diff
changeset
|
3822 return; |
a6e43da449af
patch 8.2.2887: crash when passing null string to fullcommand()
Bram Moolenaar <Bram@vim.org>
parents:
24665
diff
changeset
|
3823 |
a6e43da449af
patch 8.2.2887: crash when passing null string to fullcommand()
Bram Moolenaar <Bram@vim.org>
parents:
24665
diff
changeset
|
3824 while (*name != NUL && *name == ':') |
23853
a9ed31ab85c3
patch 8.2.2468: not easy to get the full command name from a shortened one
Bram Moolenaar <Bram@vim.org>
parents:
23823
diff
changeset
|
3825 name++; |
a9ed31ab85c3
patch 8.2.2468: not easy to get the full command name from a shortened one
Bram Moolenaar <Bram@vim.org>
parents:
23823
diff
changeset
|
3826 name = skip_range(name, TRUE, NULL); |
a9ed31ab85c3
patch 8.2.2468: not easy to get the full command name from a shortened one
Bram Moolenaar <Bram@vim.org>
parents:
23823
diff
changeset
|
3827 |
a9ed31ab85c3
patch 8.2.2468: not easy to get the full command name from a shortened one
Bram Moolenaar <Bram@vim.org>
parents:
23823
diff
changeset
|
3828 ea.cmd = (*name == '2' || *name == '3') ? name + 1 : name; |
a9ed31ab85c3
patch 8.2.2468: not easy to get the full command name from a shortened one
Bram Moolenaar <Bram@vim.org>
parents:
23823
diff
changeset
|
3829 ea.cmdidx = (cmdidx_T)0; |
24699
b19c8150ee9d
patch 8.2.2888: Vim9: "k" command recognized in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
24697
diff
changeset
|
3830 ea.addr_count = 0; |
23853
a9ed31ab85c3
patch 8.2.2468: not easy to get the full command name from a shortened one
Bram Moolenaar <Bram@vim.org>
parents:
23823
diff
changeset
|
3831 p = find_ex_command(&ea, NULL, NULL, NULL); |
a9ed31ab85c3
patch 8.2.2468: not easy to get the full command name from a shortened one
Bram Moolenaar <Bram@vim.org>
parents:
23823
diff
changeset
|
3832 if (p == NULL || ea.cmdidx == CMD_SIZE) |
a9ed31ab85c3
patch 8.2.2468: not easy to get the full command name from a shortened one
Bram Moolenaar <Bram@vim.org>
parents:
23823
diff
changeset
|
3833 return; |
24699
b19c8150ee9d
patch 8.2.2888: Vim9: "k" command recognized in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
24697
diff
changeset
|
3834 if (in_vim9script()) |
b19c8150ee9d
patch 8.2.2888: Vim9: "k" command recognized in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
24697
diff
changeset
|
3835 { |
b19c8150ee9d
patch 8.2.2888: Vim9: "k" command recognized in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
24697
diff
changeset
|
3836 int res; |
b19c8150ee9d
patch 8.2.2888: Vim9: "k" command recognized in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
24697
diff
changeset
|
3837 |
b19c8150ee9d
patch 8.2.2888: Vim9: "k" command recognized in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
24697
diff
changeset
|
3838 ++emsg_silent; |
b19c8150ee9d
patch 8.2.2888: Vim9: "k" command recognized in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
24697
diff
changeset
|
3839 res = not_in_vim9(&ea); |
b19c8150ee9d
patch 8.2.2888: Vim9: "k" command recognized in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
24697
diff
changeset
|
3840 --emsg_silent; |
b19c8150ee9d
patch 8.2.2888: Vim9: "k" command recognized in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
24697
diff
changeset
|
3841 |
b19c8150ee9d
patch 8.2.2888: Vim9: "k" command recognized in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
24697
diff
changeset
|
3842 if (res == FAIL) |
b19c8150ee9d
patch 8.2.2888: Vim9: "k" command recognized in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
24697
diff
changeset
|
3843 return; |
b19c8150ee9d
patch 8.2.2888: Vim9: "k" command recognized in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
24697
diff
changeset
|
3844 } |
23853
a9ed31ab85c3
patch 8.2.2468: not easy to get the full command name from a shortened one
Bram Moolenaar <Bram@vim.org>
parents:
23823
diff
changeset
|
3845 |
a9ed31ab85c3
patch 8.2.2468: not easy to get the full command name from a shortened one
Bram Moolenaar <Bram@vim.org>
parents:
23823
diff
changeset
|
3846 rettv->vval.v_string = vim_strsave(IS_USER_CMDIDX(ea.cmdidx) |
a9ed31ab85c3
patch 8.2.2468: not easy to get the full command name from a shortened one
Bram Moolenaar <Bram@vim.org>
parents:
23823
diff
changeset
|
3847 ? get_user_commands(NULL, ea.useridx) |
a9ed31ab85c3
patch 8.2.2468: not easy to get the full command name from a shortened one
Bram Moolenaar <Bram@vim.org>
parents:
23823
diff
changeset
|
3848 : cmdnames[ea.cmdidx].cmd_name); |
a9ed31ab85c3
patch 8.2.2468: not easy to get the full command name from a shortened one
Bram Moolenaar <Bram@vim.org>
parents:
23823
diff
changeset
|
3849 } |
7 | 3850 #endif |
3851 | |
17835
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17823
diff
changeset
|
3852 cmdidx_T |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17823
diff
changeset
|
3853 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
|
3854 { |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17823
diff
changeset
|
3855 cmdidx_T idx; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17823
diff
changeset
|
3856 |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17823
diff
changeset
|
3857 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
|
3858 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
|
3859 if (STRNCMP(cmdnames[(int)idx].cmd_name, cmd, (size_t)len) == 0) |
7 | 3860 break; |
3861 | |
17835
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17823
diff
changeset
|
3862 return idx; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17823
diff
changeset
|
3863 } |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17823
diff
changeset
|
3864 |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17823
diff
changeset
|
3865 long |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17823
diff
changeset
|
3866 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
|
3867 { |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17823
diff
changeset
|
3868 return (long)cmdnames[(int)idx].cmd_argt; |
7 | 3869 } |
3870 | |
3871 /* | |
14505
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3872 * Skip a range specifier of the form: addr [,addr] [;addr] .. |
7 | 3873 * |
3874 * Backslashed delimiters after / or ? will be skipped, and commands will | |
3875 * not be expanded between /'s and ?'s or after "'". | |
3876 * | |
20982
bb49b5090a9c
patch 8.2.1042: Vim9: cannot put an operator on the next line
Bram Moolenaar <Bram@vim.org>
parents:
20897
diff
changeset
|
3877 * Also skip white space and ":" characters after the range. |
7 | 3878 * Returns the "cmd" pointer advanced to beyond the range. |
3879 */ | |
3880 char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3881 skip_range( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3882 char_u *cmd, |
22260
d7c1e3efa88e
patch 8.2.1679: Vim9: ":*" is not recognized as a range
Bram Moolenaar <Bram@vim.org>
parents:
22208
diff
changeset
|
3883 int skip_star, // skip "*" used for Visual range |
d7c1e3efa88e
patch 8.2.1679: Vim9: ":*" is not recognized as a range
Bram Moolenaar <Bram@vim.org>
parents:
22208
diff
changeset
|
3884 int *ctx) // pointer to xp_context or NULL |
7 | 3885 { |
1872 | 3886 unsigned delim; |
7 | 3887 |
10817
cc8079703414
patch 8.0.0298: Ex command range with repeated search does not work
Christian Brabandt <cb@256bit.org>
parents:
10809
diff
changeset
|
3888 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
|
3889 { |
cc8079703414
patch 8.0.0298: Ex command range with repeated search does not work
Christian Brabandt <cb@256bit.org>
parents:
10809
diff
changeset
|
3890 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
|
3891 { |
cc8079703414
patch 8.0.0298: Ex command range with repeated search does not work
Christian Brabandt <cb@256bit.org>
parents:
10809
diff
changeset
|
3892 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
|
3893 ++cmd; |
cc8079703414
patch 8.0.0298: Ex command range with repeated search does not work
Christian Brabandt <cb@256bit.org>
parents:
10809
diff
changeset
|
3894 else |
cc8079703414
patch 8.0.0298: Ex command range with repeated search does not work
Christian Brabandt <cb@256bit.org>
parents:
10809
diff
changeset
|
3895 break; |
cc8079703414
patch 8.0.0298: Ex command range with repeated search does not work
Christian Brabandt <cb@256bit.org>
parents:
10809
diff
changeset
|
3896 } |
cc8079703414
patch 8.0.0298: Ex command range with repeated search does not work
Christian Brabandt <cb@256bit.org>
parents:
10809
diff
changeset
|
3897 else if (*cmd == '\'') |
7 | 3898 { |
3899 if (*++cmd == NUL && ctx != NULL) | |
3900 *ctx = EXPAND_NOTHING; | |
3901 } | |
3902 else if (*cmd == '/' || *cmd == '?') | |
3903 { | |
3904 delim = *cmd++; | |
3905 while (*cmd != NUL && *cmd != delim) | |
3906 if (*cmd++ == '\\' && *cmd != NUL) | |
3907 ++cmd; | |
3908 if (*cmd == NUL && ctx != NULL) | |
3909 *ctx = EXPAND_NOTHING; | |
3910 } | |
3911 if (*cmd != NUL) | |
3912 ++cmd; | |
3913 } | |
167 | 3914 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3915 // Skip ":" and white space. |
167 | 3916 while (*cmd == ':') |
3917 cmd = skipwhite(cmd + 1); | |
3918 | |
22260
d7c1e3efa88e
patch 8.2.1679: Vim9: ":*" is not recognized as a range
Bram Moolenaar <Bram@vim.org>
parents:
22208
diff
changeset
|
3919 // Skip "*" used for Visual range. |
d7c1e3efa88e
patch 8.2.1679: Vim9: ":*" is not recognized as a range
Bram Moolenaar <Bram@vim.org>
parents:
22208
diff
changeset
|
3920 if (skip_star && *cmd == '*' && vim_strchr(p_cpo, CPO_STAR) == NULL) |
d7c1e3efa88e
patch 8.2.1679: Vim9: ":*" is not recognized as a range
Bram Moolenaar <Bram@vim.org>
parents:
22208
diff
changeset
|
3921 cmd = skipwhite(cmd + 1); |
d7c1e3efa88e
patch 8.2.1679: Vim9: ":*" is not recognized as a range
Bram Moolenaar <Bram@vim.org>
parents:
22208
diff
changeset
|
3922 |
7 | 3923 return cmd; |
3924 } | |
3925 | |
17650
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
3926 static void |
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
3927 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
|
3928 { |
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
3929 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
|
3930 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
|
3931 else |
25064
8f2262c72178
patch 8.2.3069: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
24984
diff
changeset
|
3932 emsg(_(e_invalid_range)); |
17650
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
3933 } |
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
3934 |
7 | 3935 /* |
21939
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
3936 * Return the default address for an address type. |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
3937 */ |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
3938 static linenr_T |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
3939 default_address(exarg_T *eap) |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
3940 { |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
3941 linenr_T lnum = 0; |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
3942 |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
3943 switch (eap->addr_type) |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
3944 { |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
3945 case ADDR_LINES: |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
3946 case ADDR_OTHER: |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
3947 // Default is the cursor line number. Avoid using an invalid |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
3948 // line number though. |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
3949 if (curwin->w_cursor.lnum > curbuf->b_ml.ml_line_count) |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
3950 lnum = curbuf->b_ml.ml_line_count; |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
3951 else |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
3952 lnum = curwin->w_cursor.lnum; |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
3953 break; |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
3954 case ADDR_WINDOWS: |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
3955 lnum = CURRENT_WIN_NR; |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
3956 break; |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
3957 case ADDR_ARGUMENTS: |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
3958 lnum = curwin->w_arg_idx + 1; |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
3959 if (lnum > ARGCOUNT) |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
3960 lnum = ARGCOUNT; |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
3961 break; |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
3962 case ADDR_LOADED_BUFFERS: |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
3963 case ADDR_BUFFERS: |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
3964 lnum = curbuf->b_fnum; |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
3965 break; |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
3966 case ADDR_TABS: |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
3967 lnum = CURRENT_TAB_NR; |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
3968 break; |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
3969 case ADDR_TABS_RELATIVE: |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
3970 case ADDR_UNSIGNED: |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
3971 lnum = 1; |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
3972 break; |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
3973 case ADDR_QUICKFIX: |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
3974 #ifdef FEAT_QUICKFIX |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
3975 lnum = qf_get_cur_idx(eap); |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
3976 #endif |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
3977 break; |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
3978 case ADDR_QUICKFIX_VALID: |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
3979 #ifdef FEAT_QUICKFIX |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
3980 lnum = qf_get_cur_valid_idx(eap); |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
3981 #endif |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
3982 break; |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
3983 case ADDR_NONE: |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
3984 // Will give an error later if a range is found. |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
3985 break; |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
3986 } |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
3987 return lnum; |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
3988 } |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
3989 |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
3990 /* |
14677
7771a1ff8b99
patch 8.1.0351: 'incsearch' for :/foo/s//<Esc> changes last search pattern
Christian Brabandt <cb@256bit.org>
parents:
14648
diff
changeset
|
3991 * Get a single EX address. |
7 | 3992 * |
3993 * Set ptr to the next character after the part that was interpreted. | |
3994 * 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
|
3995 * This may set the last used search pattern. |
7 | 3996 * |
3997 * Return MAXLNUM when no Ex address was found. | |
3998 */ | |
3999 static linenr_T | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4000 get_address( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4001 exarg_T *eap UNUSED, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4002 char_u **ptr, |
18849
b77ef4b8af7c
patch 8.1.2411: function argument copied unnecessarily
Bram Moolenaar <Bram@vim.org>
parents:
18779
diff
changeset
|
4003 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
|
4004 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
|
4005 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
|
4006 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
|
4007 int address_count UNUSED) // 1 for first address, >1 after comma |
7 | 4008 { |
4009 int c; | |
4010 int i; | |
4011 long n; | |
4012 char_u *cmd; | |
4013 pos_T pos; | |
4014 pos_T *fp; | |
4015 linenr_T lnum; | |
6424 | 4016 buf_T *buf; |
7 | 4017 |
4018 cmd = skipwhite(*ptr); | |
4019 lnum = MAXLNUM; | |
4020 do | |
4021 { | |
4022 switch (*cmd) | |
4023 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4024 case '.': // '.' - Cursor position |
6398 | 4025 ++cmd; |
4026 switch (addr_type) | |
4027 { | |
4028 case ADDR_LINES: | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
4029 case ADDR_OTHER: |
7 | 4030 lnum = curwin->w_cursor.lnum; |
4031 break; | |
6398 | 4032 case ADDR_WINDOWS: |
6409 | 4033 lnum = CURRENT_WIN_NR; |
6398 | 4034 break; |
4035 case ADDR_ARGUMENTS: | |
4036 lnum = curwin->w_arg_idx + 1; | |
4037 break; | |
4038 case ADDR_LOADED_BUFFERS: | |
6424 | 4039 case ADDR_BUFFERS: |
6398 | 4040 lnum = curbuf->b_fnum; |
4041 break; | |
4042 case ADDR_TABS: | |
6409 | 4043 lnum = CURRENT_TAB_NR; |
6398 | 4044 break; |
17650
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
4045 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
|
4046 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
|
4047 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
|
4048 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
|
4049 cmd = NULL; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
4050 goto error; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
4051 break; |
16479
7dcf301d1432
patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents:
16475
diff
changeset
|
4052 case ADDR_QUICKFIX: |
7105
f4456e686406
commit https://github.com/vim/vim/commit/e906c502079770ae0e0071c74cefb802689ff193
Christian Brabandt <cb@256bit.org>
parents:
7092
diff
changeset
|
4053 #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
|
4054 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
|
4055 #endif |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
4056 break; |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
4057 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
|
4058 #ifdef FEAT_QUICKFIX |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
4059 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
|
4060 #endif |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
4061 break; |
6398 | 4062 } |
4063 break; | |
7 | 4064 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4065 case '$': // '$' - last line |
6398 | 4066 ++cmd; |
4067 switch (addr_type) | |
4068 { | |
4069 case ADDR_LINES: | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
4070 case ADDR_OTHER: |
7 | 4071 lnum = curbuf->b_ml.ml_line_count; |
4072 break; | |
6398 | 4073 case ADDR_WINDOWS: |
6409 | 4074 lnum = LAST_WIN_NR; |
6398 | 4075 break; |
4076 case ADDR_ARGUMENTS: | |
4077 lnum = ARGCOUNT; | |
4078 break; | |
4079 case ADDR_LOADED_BUFFERS: | |
6424 | 4080 buf = lastbuf; |
4081 while (buf->b_ml.ml_mfp == NULL) | |
4082 { | |
4083 if (buf->b_prev == NULL) | |
4084 break; | |
4085 buf = buf->b_prev; | |
4086 } | |
4087 lnum = buf->b_fnum; | |
4088 break; | |
4089 case ADDR_BUFFERS: | |
6398 | 4090 lnum = lastbuf->b_fnum; |
4091 break; | |
4092 case ADDR_TABS: | |
6409 | 4093 lnum = LAST_TAB_NR; |
6398 | 4094 break; |
17650
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
4095 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
|
4096 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
|
4097 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
|
4098 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
|
4099 cmd = NULL; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
4100 goto error; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
4101 break; |
16479
7dcf301d1432
patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents:
16475
diff
changeset
|
4102 case ADDR_QUICKFIX: |
7105
f4456e686406
commit https://github.com/vim/vim/commit/e906c502079770ae0e0071c74cefb802689ff193
Christian Brabandt <cb@256bit.org>
parents:
7092
diff
changeset
|
4103 #ifdef FEAT_QUICKFIX |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
4104 lnum = qf_get_size(eap); |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
4105 if (lnum == 0) |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
4106 lnum = 1; |
16479
7dcf301d1432
patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents:
16475
diff
changeset
|
4107 #endif |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
4108 break; |
16515
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
4109 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
|
4110 #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
|
4111 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
|
4112 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
|
4113 lnum = 1; |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
4114 #endif |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
4115 break; |
6398 | 4116 } |
4117 break; | |
7 | 4118 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4119 case '\'': // ''' - mark |
6398 | 4120 if (*++cmd == NUL) |
4121 { | |
4122 cmd = NULL; | |
4123 goto error; | |
4124 } | |
4125 if (addr_type != ADDR_LINES) | |
4126 { | |
17650
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
4127 addr_error(addr_type); |
6581 | 4128 cmd = NULL; |
6398 | 4129 goto error; |
4130 } | |
4131 if (skip) | |
4132 ++cmd; | |
4133 else | |
4134 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4135 // 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
|
4136 // used by itself: ":'M". |
6398 | 4137 fp = getmark(*cmd, to_other_file && cmd[1] == NUL); |
4138 ++cmd; | |
4139 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
|
4140 // Jumped to another file. |
6398 | 4141 lnum = curwin->w_cursor.lnum; |
4142 else | |
4143 { | |
4144 if (check_mark(fp) == FAIL) | |
7 | 4145 { |
4146 cmd = NULL; | |
4147 goto error; | |
4148 } | |
6398 | 4149 lnum = fp->lnum; |
4150 } | |
4151 } | |
4152 break; | |
7 | 4153 |
4154 case '/': | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4155 case '?': // '/' or '?' - search |
6398 | 4156 c = *cmd++; |
4157 if (addr_type != ADDR_LINES) | |
4158 { | |
17650
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
4159 addr_error(addr_type); |
6581 | 4160 cmd = NULL; |
6398 | 4161 goto error; |
4162 } | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4163 if (skip) // skip "/pat/" |
6398 | 4164 { |
23272
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
23239
diff
changeset
|
4165 cmd = skip_regexp(cmd, c, magic_isset()); |
6398 | 4166 if (*cmd == c) |
4167 ++cmd; | |
4168 } | |
4169 else | |
4170 { | |
14760
fd69edd2c67e
patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents:
14700
diff
changeset
|
4171 int flags; |
fd69edd2c67e
patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents:
14700
diff
changeset
|
4172 |
fd69edd2c67e
patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents:
14700
diff
changeset
|
4173 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
|
4174 |
fd69edd2c67e
patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents:
14700
diff
changeset
|
4175 // 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
|
4176 // there. |
6398 | 4177 if (lnum != MAXLNUM) |
4178 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
|
4179 |
fd69edd2c67e
patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents:
14700
diff
changeset
|
4180 // 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
|
4181 // 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
|
4182 // 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
|
4183 // 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
|
4184 // 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
|
4185 // next/previous line. |
13082
a80082fd1a1d
patch 8.0.1416: crash when searching for a sentence
Christian Brabandt <cb@256bit.org>
parents:
12824
diff
changeset
|
4186 if (c == '/' && curwin->w_cursor.lnum > 0) |
6398 | 4187 curwin->w_cursor.col = MAXCOL; |
4188 else | |
4189 curwin->w_cursor.col = 0; | |
4190 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
|
4191 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
|
4192 if (!do_search(NULL, c, c, cmd, 1L, flags, NULL)) |
6398 | 4193 { |
4194 curwin->w_cursor = pos; | |
4195 cmd = NULL; | |
4196 goto error; | |
4197 } | |
4198 lnum = curwin->w_cursor.lnum; | |
4199 curwin->w_cursor = pos; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4200 // adjust command string pointer |
6398 | 4201 cmd += searchcmdlen; |
4202 } | |
4203 break; | |
7 | 4204 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4205 case '\\': // "\?", "\/" or "\&", repeat search |
6398 | 4206 ++cmd; |
4207 if (addr_type != ADDR_LINES) | |
4208 { | |
17650
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
4209 addr_error(addr_type); |
6581 | 4210 cmd = NULL; |
6398 | 4211 goto error; |
4212 } | |
4213 if (*cmd == '&') | |
4214 i = RE_SUBST; | |
4215 else if (*cmd == '?' || *cmd == '/') | |
4216 i = RE_SEARCH; | |
4217 else | |
4218 { | |
25064
8f2262c72178
patch 8.2.3069: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
24984
diff
changeset
|
4219 emsg(_(e_backslash_should_be_followed_by)); |
6398 | 4220 cmd = NULL; |
4221 goto error; | |
4222 } | |
4223 | |
4224 if (!skip) | |
4225 { | |
4226 /* | |
4227 * When search follows another address, start from | |
4228 * there. | |
4229 */ | |
4230 if (lnum != MAXLNUM) | |
4231 pos.lnum = lnum; | |
4232 else | |
4233 pos.lnum = curwin->w_cursor.lnum; | |
4234 | |
4235 /* | |
4236 * Start the search just like for the above | |
4237 * do_search(). | |
4238 */ | |
4239 if (*cmd != '?') | |
4240 pos.col = MAXCOL; | |
4241 else | |
4242 pos.col = 0; | |
7007 | 4243 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
|
4244 if (searchit(curwin, curbuf, &pos, NULL, |
6398 | 4245 *cmd == '?' ? BACKWARD : FORWARD, |
18358
34d5cd432cac
patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents:
18297
diff
changeset
|
4246 (char_u *)"", 1L, SEARCH_MSG, i, NULL) != FAIL) |
6398 | 4247 lnum = pos.lnum; |
4248 else | |
4249 { | |
4250 cmd = NULL; | |
4251 goto error; | |
4252 } | |
4253 } | |
4254 ++cmd; | |
4255 break; | |
7 | 4256 |
4257 default: | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4258 if (VIM_ISDIGIT(*cmd)) // absolute line number |
6398 | 4259 lnum = getdigits(&cmd); |
7 | 4260 } |
4261 | |
4262 for (;;) | |
4263 { | |
4264 cmd = skipwhite(cmd); | |
4265 if (*cmd != '-' && *cmd != '+' && !VIM_ISDIGIT(*cmd)) | |
4266 break; | |
4267 | |
4268 if (lnum == MAXLNUM) | |
6398 | 4269 { |
4270 switch (addr_type) | |
4271 { | |
4272 case ADDR_LINES: | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
4273 case ADDR_OTHER: |
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
4274 // "+1" is same as ".+1" |
6409 | 4275 lnum = curwin->w_cursor.lnum; |
6398 | 4276 break; |
4277 case ADDR_WINDOWS: | |
6409 | 4278 lnum = CURRENT_WIN_NR; |
6398 | 4279 break; |
4280 case ADDR_ARGUMENTS: | |
4281 lnum = curwin->w_arg_idx + 1; | |
4282 break; | |
4283 case ADDR_LOADED_BUFFERS: | |
6424 | 4284 case ADDR_BUFFERS: |
6398 | 4285 lnum = curbuf->b_fnum; |
4286 break; | |
4287 case ADDR_TABS: | |
6409 | 4288 lnum = CURRENT_TAB_NR; |
6398 | 4289 break; |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
4290 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
|
4291 lnum = 1; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
4292 break; |
16479
7dcf301d1432
patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents:
16475
diff
changeset
|
4293 case ADDR_QUICKFIX: |
7105
f4456e686406
commit https://github.com/vim/vim/commit/e906c502079770ae0e0071c74cefb802689ff193
Christian Brabandt <cb@256bit.org>
parents:
7092
diff
changeset
|
4294 #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
|
4295 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
|
4296 #endif |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
4297 break; |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
4298 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
|
4299 #ifdef FEAT_QUICKFIX |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
4300 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
|
4301 #endif |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
4302 break; |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
4303 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
|
4304 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
|
4305 lnum = 0; |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
4306 break; |
6398 | 4307 } |
4308 } | |
4309 | |
7 | 4310 if (VIM_ISDIGIT(*cmd)) |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4311 i = '+'; // "number" is same as "+number" |
7 | 4312 else |
4313 i = *cmd++; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4314 if (!VIM_ISDIGIT(*cmd)) // '+' is '+1', but '+0' is not '+1' |
7 | 4315 n = 1; |
4316 else | |
4317 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
|
4318 |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
4319 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
|
4320 { |
25064
8f2262c72178
patch 8.2.3069: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
24984
diff
changeset
|
4321 emsg(_(e_invalid_range)); |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
4322 cmd = NULL; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
4323 goto error; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
4324 } |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
4325 else if (addr_type == ADDR_LOADED_BUFFERS |
6424 | 4326 || addr_type == ADDR_BUFFERS) |
6581 | 4327 lnum = compute_buffer_local_count( |
4328 addr_type, lnum, (i == '-') ? -1 * n : n); | |
7 | 4329 else |
10484
c7de1536780a
commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
10480
diff
changeset
|
4330 { |
c7de1536780a
commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
10480
diff
changeset
|
4331 #ifdef FEAT_FOLDING |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4332 // 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
|
4333 // 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
|
4334 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
|
4335 && address_count >= 2) |
c7de1536780a
commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
10480
diff
changeset
|
4336 (void)hasFolding(lnum, NULL, &lnum); |
c7de1536780a
commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
10480
diff
changeset
|
4337 #endif |
c7de1536780a
commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
10480
diff
changeset
|
4338 if (i == '-') |
c7de1536780a
commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
10480
diff
changeset
|
4339 lnum -= n; |
c7de1536780a
commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
10480
diff
changeset
|
4340 else |
c7de1536780a
commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
10480
diff
changeset
|
4341 lnum += n; |
c7de1536780a
commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
10480
diff
changeset
|
4342 } |
7 | 4343 } |
4344 } while (*cmd == '/' || *cmd == '?'); | |
4345 | |
4346 error: | |
4347 *ptr = cmd; | |
4348 return lnum; | |
4349 } | |
4350 | |
4351 /* | |
21939
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4352 * Set eap->line1 and eap->line2 to the whole range. |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4353 * Used for commands with the EX_DFLALL flag and no range given. |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4354 */ |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4355 static void |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4356 address_default_all(exarg_T *eap) |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4357 { |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4358 eap->line1 = 1; |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4359 switch (eap->addr_type) |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4360 { |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4361 case ADDR_LINES: |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4362 case ADDR_OTHER: |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4363 eap->line2 = curbuf->b_ml.ml_line_count; |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4364 break; |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4365 case ADDR_LOADED_BUFFERS: |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4366 { |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4367 buf_T *buf = firstbuf; |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4368 |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4369 while (buf->b_next != NULL && buf->b_ml.ml_mfp == NULL) |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4370 buf = buf->b_next; |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4371 eap->line1 = buf->b_fnum; |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4372 buf = lastbuf; |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4373 while (buf->b_prev != NULL && buf->b_ml.ml_mfp == NULL) |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4374 buf = buf->b_prev; |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4375 eap->line2 = buf->b_fnum; |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4376 } |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4377 break; |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4378 case ADDR_BUFFERS: |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4379 eap->line1 = firstbuf->b_fnum; |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4380 eap->line2 = lastbuf->b_fnum; |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4381 break; |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4382 case ADDR_WINDOWS: |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4383 eap->line2 = LAST_WIN_NR; |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4384 break; |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4385 case ADDR_TABS: |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4386 eap->line2 = LAST_TAB_NR; |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4387 break; |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4388 case ADDR_TABS_RELATIVE: |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4389 eap->line2 = 1; |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4390 break; |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4391 case ADDR_ARGUMENTS: |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4392 if (ARGCOUNT == 0) |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4393 eap->line1 = eap->line2 = 0; |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4394 else |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4395 eap->line2 = ARGCOUNT; |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4396 break; |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4397 case ADDR_QUICKFIX_VALID: |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4398 #ifdef FEAT_QUICKFIX |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4399 eap->line2 = qf_get_valid_size(eap); |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4400 if (eap->line2 == 0) |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4401 eap->line2 = 1; |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4402 #endif |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4403 break; |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4404 case ADDR_NONE: |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4405 case ADDR_UNSIGNED: |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4406 case ADDR_QUICKFIX: |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4407 iemsg(_("INTERNAL: Cannot use EX_DFLALL with ADDR_NONE, ADDR_UNSIGNED or ADDR_QUICKFIX")); |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4408 break; |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4409 } |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4410 } |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4411 |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4412 |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4413 /* |
167 | 4414 * Get flags from an Ex command argument. |
4415 */ | |
4416 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4417 get_flags(exarg_T *eap) |
167 | 4418 { |
4419 while (vim_strchr((char_u *)"lp#", *eap->arg) != NULL) | |
4420 { | |
4421 if (*eap->arg == 'l') | |
4422 eap->flags |= EXFLAG_LIST; | |
4423 else if (*eap->arg == 'p') | |
4424 eap->flags |= EXFLAG_PRINT; | |
4425 else | |
4426 eap->flags |= EXFLAG_NR; | |
4427 eap->arg = skipwhite(eap->arg + 1); | |
4428 } | |
4429 } | |
4430 | |
4431 /* | |
7 | 4432 * Function called for command which is Not Implemented. NI! |
4433 */ | |
4434 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4435 ex_ni(exarg_T *eap) |
7 | 4436 { |
4437 if (!eap->skip) | |
21459
a422bd80b434
patch 8.2.1280: Ex command error cannot contain an argument
Bram Moolenaar <Bram@vim.org>
parents:
21413
diff
changeset
|
4438 eap->errmsg = |
a422bd80b434
patch 8.2.1280: Ex command error cannot contain an argument
Bram Moolenaar <Bram@vim.org>
parents:
21413
diff
changeset
|
4439 _("E319: Sorry, the command is not available in this version"); |
7 | 4440 } |
4441 | |
1315 | 4442 #ifdef HAVE_EX_SCRIPT_NI |
7 | 4443 /* |
4444 * Function called for script command which is Not Implemented. NI! | |
4445 * Skips over ":perl <<EOF" constructs. | |
4446 */ | |
4447 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4448 ex_script_ni(exarg_T *eap) |
7 | 4449 { |
4450 if (!eap->skip) | |
4451 ex_ni(eap); | |
4452 else | |
4453 vim_free(script_get(eap, eap->arg)); | |
4454 } | |
4455 #endif | |
4456 | |
4457 /* | |
4458 * Check range in Ex command for validity. | |
4459 * Return NULL when valid, error message when invalid. | |
4460 */ | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
4461 static char * |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4462 invalid_range(exarg_T *eap) |
7 | 4463 { |
6472 | 4464 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
|
4465 |
7 | 4466 if ( eap->line1 < 0 |
4467 || eap->line2 < 0 | |
6472 | 4468 || eap->line1 > eap->line2) |
25064
8f2262c72178
patch 8.2.3069: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
24984
diff
changeset
|
4469 return _(e_invalid_range); |
6472 | 4470 |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
4471 if (eap->argt & EX_RANGE) |
6472 | 4472 { |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
4473 switch (eap->addr_type) |
6472 | 4474 { |
4475 case ADDR_LINES: | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
4476 if (eap->line2 > curbuf->b_ml.ml_line_count |
7 | 4477 #ifdef FEAT_DIFF |
6472 | 4478 + (eap->cmdidx == CMD_diffget) |
4479 #endif | |
4480 ) | |
25064
8f2262c72178
patch 8.2.3069: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
24984
diff
changeset
|
4481 return _(e_invalid_range); |
6472 | 4482 break; |
4483 case ADDR_ARGUMENTS: | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4484 // add 1 if ARGCOUNT is 0 |
6581 | 4485 if (eap->line2 > ARGCOUNT + (!ARGCOUNT)) |
25064
8f2262c72178
patch 8.2.3069: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
24984
diff
changeset
|
4486 return _(e_invalid_range); |
6472 | 4487 break; |
4488 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
|
4489 // 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
|
4490 // exist. |
7e6b7a4f13bc
patch 8.1.1908: every popup window consumes a buffer number
Bram Moolenaar <Bram@vim.org>
parents:
17817
diff
changeset
|
4491 if (eap->line1 < 1 || eap->line2 > get_highest_fnum()) |
25064
8f2262c72178
patch 8.2.3069: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
24984
diff
changeset
|
4492 return _(e_invalid_range); |
6472 | 4493 break; |
4494 case ADDR_LOADED_BUFFERS: | |
4495 buf = firstbuf; | |
4496 while (buf->b_ml.ml_mfp == NULL) | |
4497 { | |
4498 if (buf->b_next == NULL) | |
25064
8f2262c72178
patch 8.2.3069: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
24984
diff
changeset
|
4499 return _(e_invalid_range); |
6472 | 4500 buf = buf->b_next; |
4501 } | |
4502 if (eap->line1 < buf->b_fnum) | |
25064
8f2262c72178
patch 8.2.3069: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
24984
diff
changeset
|
4503 return _(e_invalid_range); |
6472 | 4504 buf = lastbuf; |
4505 while (buf->b_ml.ml_mfp == NULL) | |
4506 { | |
4507 if (buf->b_prev == NULL) | |
25064
8f2262c72178
patch 8.2.3069: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
24984
diff
changeset
|
4508 return _(e_invalid_range); |
6472 | 4509 buf = buf->b_prev; |
4510 } | |
4511 if (eap->line2 > buf->b_fnum) | |
25064
8f2262c72178
patch 8.2.3069: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
24984
diff
changeset
|
4512 return _(e_invalid_range); |
6472 | 4513 break; |
4514 case ADDR_WINDOWS: | |
6480 | 4515 if (eap->line2 > LAST_WIN_NR) |
25064
8f2262c72178
patch 8.2.3069: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
24984
diff
changeset
|
4516 return _(e_invalid_range); |
6472 | 4517 break; |
4518 case ADDR_TABS: | |
4519 if (eap->line2 > LAST_TAB_NR) | |
25064
8f2262c72178
patch 8.2.3069: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
24984
diff
changeset
|
4520 return _(e_invalid_range); |
6472 | 4521 break; |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
4522 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
|
4523 case ADDR_OTHER: |
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
4524 // 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
|
4525 break; |
16479
7dcf301d1432
patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents:
16475
diff
changeset
|
4526 case ADDR_QUICKFIX: |
7105
f4456e686406
commit https://github.com/vim/vim/commit/e906c502079770ae0e0071c74cefb802689ff193
Christian Brabandt <cb@256bit.org>
parents:
7092
diff
changeset
|
4527 #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
|
4528 // 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
|
4529 if (eap->line2 <= 0) |
25064
8f2262c72178
patch 8.2.3069: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
24984
diff
changeset
|
4530 return _(e_invalid_range); |
16479
7dcf301d1432
patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents:
16475
diff
changeset
|
4531 #endif |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
4532 break; |
16515
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
4533 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
|
4534 #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
|
4535 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
|
4536 || eap->line2 < 0) |
25064
8f2262c72178
patch 8.2.3069: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
24984
diff
changeset
|
4537 return _(e_invalid_range); |
16515
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
4538 #endif |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
4539 break; |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
4540 case ADDR_UNSIGNED: |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
4541 case ADDR_NONE: |
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
4542 // 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
|
4543 break; |
6472 | 4544 } |
4545 } | |
7 | 4546 return NULL; |
4547 } | |
4548 | |
4549 /* | |
4550 * Correct the range for zero line number, if required. | |
4551 */ | |
4552 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4553 correct_range(exarg_T *eap) |
7 | 4554 { |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
4555 if (!(eap->argt & EX_ZEROR)) // zero in range not allowed |
7 | 4556 { |
4557 if (eap->line1 == 0) | |
4558 eap->line1 = 1; | |
4559 if (eap->line2 == 0) | |
4560 eap->line2 = 1; | |
4561 } | |
4562 } | |
4563 | |
153 | 4564 #ifdef FEAT_QUICKFIX |
4565 /* | |
4566 * For a ":vimgrep" or ":vimgrepadd" command return a pointer past the | |
4567 * pattern. Otherwise return eap->arg. | |
4568 */ | |
4569 static char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4570 skip_grep_pat(exarg_T *eap) |
153 | 4571 { |
4572 char_u *p = eap->arg; | |
4573 | |
655 | 4574 if (*p != NUL && (eap->cmdidx == CMD_vimgrep || eap->cmdidx == CMD_lvimgrep |
4575 || eap->cmdidx == CMD_vimgrepadd | |
4576 || eap->cmdidx == CMD_lvimgrepadd | |
4577 || grep_internal(eap->cmdidx))) | |
153 | 4578 { |
170 | 4579 p = skip_vimgrep_pat(p, NULL, NULL); |
153 | 4580 if (p == NULL) |
4581 p = eap->arg; | |
4582 } | |
4583 return p; | |
4584 } | |
344 | 4585 |
4586 /* | |
4587 * For the ":make" and ":grep" commands insert the 'makeprg'/'grepprg' option | |
4588 * in the command line, so that things like % get expanded. | |
4589 */ | |
4590 static char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4591 replace_makeprg(exarg_T *eap, char_u *p, char_u **cmdlinep) |
344 | 4592 { |
4593 char_u *new_cmdline; | |
4594 char_u *program; | |
4595 char_u *pos; | |
4596 char_u *ptr; | |
4597 int len; | |
4598 int i; | |
4599 | |
4600 /* | |
4601 * Don't do it when ":vimgrep" is used for ":grep". | |
4602 */ | |
655 | 4603 if ((eap->cmdidx == CMD_make || eap->cmdidx == CMD_lmake |
4604 || eap->cmdidx == CMD_grep || eap->cmdidx == CMD_lgrep | |
4605 || eap->cmdidx == CMD_grepadd | |
4606 || eap->cmdidx == CMD_lgrepadd) | |
344 | 4607 && !grep_internal(eap->cmdidx)) |
4608 { | |
655 | 4609 if (eap->cmdidx == CMD_grep || eap->cmdidx == CMD_lgrep |
4610 || eap->cmdidx == CMD_grepadd || eap->cmdidx == CMD_lgrepadd) | |
344 | 4611 { |
4612 if (*curbuf->b_p_gp == NUL) | |
4613 program = p_gp; | |
4614 else | |
4615 program = curbuf->b_p_gp; | |
4616 } | |
4617 else | |
4618 { | |
4619 if (*curbuf->b_p_mp == NUL) | |
4620 program = p_mp; | |
4621 else | |
4622 program = curbuf->b_p_mp; | |
4623 } | |
4624 | |
4625 p = skipwhite(p); | |
4626 | |
4627 if ((pos = (char_u *)strstr((char *)program, "$*")) != NULL) | |
4628 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4629 // replace $* by given arguments |
344 | 4630 i = 1; |
4631 while ((pos = (char_u *)strstr((char *)pos + 2, "$*")) != NULL) | |
4632 ++i; | |
4633 len = (int)STRLEN(p); | |
16782
fc58fee685e2
patch 8.1.1393: unnecessary type casts
Bram Moolenaar <Bram@vim.org>
parents:
16780
diff
changeset
|
4634 new_cmdline = alloc(STRLEN(program) + i * (len - 2) + 1); |
344 | 4635 if (new_cmdline == NULL) |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4636 return NULL; // out of memory |
344 | 4637 ptr = new_cmdline; |
4638 while ((pos = (char_u *)strstr((char *)program, "$*")) != NULL) | |
4639 { | |
4640 i = (int)(pos - program); | |
4641 STRNCPY(ptr, program, i); | |
4642 STRCPY(ptr += i, p); | |
4643 ptr += len; | |
4644 program = pos + 2; | |
4645 } | |
4646 STRCPY(ptr, program); | |
4647 } | |
4648 else | |
4649 { | |
16782
fc58fee685e2
patch 8.1.1393: unnecessary type casts
Bram Moolenaar <Bram@vim.org>
parents:
16780
diff
changeset
|
4650 new_cmdline = alloc(STRLEN(program) + STRLEN(p) + 2); |
344 | 4651 if (new_cmdline == NULL) |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4652 return NULL; // out of memory |
344 | 4653 STRCPY(new_cmdline, program); |
4654 STRCAT(new_cmdline, " "); | |
4655 STRCAT(new_cmdline, p); | |
4656 } | |
4657 msg_make(p); | |
4658 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4659 // 'eap->cmd' is not set here, because it is not used at CMD_make |
344 | 4660 vim_free(*cmdlinep); |
4661 *cmdlinep = new_cmdline; | |
4662 p = new_cmdline; | |
4663 } | |
4664 return p; | |
4665 } | |
153 | 4666 #endif |
4667 | |
7 | 4668 /* |
4669 * 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
|
4670 * When an error is detected, "errormsgp" is set to a non-NULL pointer. |
7 | 4671 * Return FAIL for failure, OK otherwise. |
4672 */ | |
4673 int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4674 expand_filename( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4675 exarg_T *eap, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4676 char_u **cmdlinep, |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
4677 char **errormsgp) |
7 | 4678 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4679 int has_wildcards; // need to expand wildcards |
7 | 4680 char_u *repl; |
4681 int srclen; | |
4682 char_u *p; | |
4683 int n; | |
1098 | 4684 int escaped; |
7 | 4685 |
153 | 4686 #ifdef FEAT_QUICKFIX |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4687 // Skip a regexp pattern for ":vimgrep[add] pat file..." |
153 | 4688 p = skip_grep_pat(eap); |
4689 #else | |
4690 p = eap->arg; | |
4691 #endif | |
4692 | |
7 | 4693 /* |
4694 * Decide to expand wildcards *before* replacing '%', '#', etc. If | |
4695 * the file name contains a wildcard it should not cause expanding. | |
4696 * (it will be expanded anyway if there is a wildcard before replacing). | |
4697 */ | |
153 | 4698 has_wildcards = mch_has_wildcard(p); |
4699 while (*p != NUL) | |
7 | 4700 { |
9 | 4701 #ifdef FEAT_EVAL |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4702 // Skip over `=expr`, wildcards in it are not expanded. |
9 | 4703 if (p[0] == '`' && p[1] == '=') |
4704 { | |
4705 p += 2; | |
22685
80b4e604d1d5
patch 8.2.1891: Vim9: skipping over expression doesn't handle line breaks
Bram Moolenaar <Bram@vim.org>
parents:
22616
diff
changeset
|
4706 (void)skip_expr(&p, NULL); |
9 | 4707 if (*p == '`') |
4708 ++p; | |
4709 continue; | |
4710 } | |
4711 #endif | |
7 | 4712 /* |
4713 * Quick check if this cannot be the start of a special string. | |
4714 * Also removes backslash before '%', '#' and '<'. | |
4715 */ | |
4716 if (vim_strchr((char_u *)"%#<", *p) == NULL) | |
4717 { | |
4718 ++p; | |
4719 continue; | |
4720 } | |
4721 | |
4722 /* | |
4723 * Try to find a match at this position. | |
4724 */ | |
1098 | 4725 repl = eval_vars(p, eap->arg, &srclen, &(eap->do_ecmd_lnum), |
4726 errormsgp, &escaped); | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4727 if (*errormsgp != NULL) // error detected |
7 | 4728 return FAIL; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4729 if (repl == NULL) // no match found |
7 | 4730 { |
4731 p += srclen; | |
4732 continue; | |
4733 } | |
4734 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4735 // 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
|
4736 // literally. But do expand "~/file", "~user/file" and "$HOME/file". |
37 | 4737 if (vim_strchr(repl, '$') != NULL || vim_strchr(repl, '~') != NULL) |
4738 { | |
4739 char_u *l = repl; | |
4740 | |
4741 repl = expand_env_save(repl); | |
4742 vim_free(l); | |
4743 } | |
4744 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4745 // 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
|
4746 // Don't do this for: |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4747 // - 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
|
4748 // - 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
|
4749 // - 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
|
4750 // separate arguments then). |
7 | 4751 if (!eap->usefilter |
1098 | 4752 && !escaped |
7 | 4753 && eap->cmdidx != CMD_bang |
4754 && 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
|
4755 && eap->cmdidx != CMD_grepadd |
1c1cb1e9b7b3
patch 8.0.0785: wildcards are not expanded for :terminal
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
4756 && eap->cmdidx != CMD_hardcopy |
655 | 4757 && eap->cmdidx != CMD_lgrep |
4758 && 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
|
4759 && eap->cmdidx != CMD_lmake |
1c1cb1e9b7b3
patch 8.0.0785: wildcards are not expanded for :terminal
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
4760 && eap->cmdidx != CMD_make |
1c1cb1e9b7b3
patch 8.0.0785: wildcards are not expanded for :terminal
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
4761 && eap->cmdidx != CMD_terminal |
7 | 4762 #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
|
4763 && !(eap->argt & EX_NOSPC) |
7 | 4764 #endif |
4765 ) | |
4766 { | |
4767 char_u *l; | |
4768 #ifdef BACKSLASH_IN_FILENAME | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4769 // 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
|
4770 // remove it later. |
7 | 4771 static char_u *nobslash = (char_u *)" \t\"|"; |
4772 # define ESCAPE_CHARS nobslash | |
4773 #else | |
4774 # define ESCAPE_CHARS escape_chars | |
4775 #endif | |
4776 | |
4777 for (l = repl; *l; ++l) | |
4778 if (vim_strchr(ESCAPE_CHARS, *l) != NULL) | |
4779 { | |
4780 l = vim_strsave_escaped(repl, ESCAPE_CHARS); | |
4781 if (l != NULL) | |
4782 { | |
4783 vim_free(repl); | |
4784 repl = l; | |
4785 } | |
4786 break; | |
4787 } | |
4788 } | |
4789 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4790 // 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
|
4791 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
|
4792 || eap->cmdidx == CMD_terminal) |
5778 | 4793 && vim_strpbrk(repl, (char_u *)"!") != NULL) |
7 | 4794 { |
4795 char_u *l; | |
4796 | |
5778 | 4797 l = vim_strsave_escaped(repl, (char_u *)"!"); |
7 | 4798 if (l != NULL) |
4799 { | |
4800 vim_free(repl); | |
4801 repl = l; | |
4802 } | |
4803 } | |
4804 | |
4805 p = repl_cmdline(eap, p, srclen, repl, cmdlinep); | |
4806 vim_free(repl); | |
4807 if (p == NULL) | |
4808 return FAIL; | |
4809 } | |
4810 | |
4811 /* | |
4812 * One file argument: Expand wildcards. | |
4813 * Don't do this with ":r !command" or ":w !command". | |
4814 */ | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
4815 if ((eap->argt & EX_NOSPC) && !eap->usefilter) |
7 | 4816 { |
4817 /* | |
4818 * May do this twice: | |
4819 * 1. Replace environment variables. | |
4820 * 2. Replace any other wildcards, remove backslashes. | |
4821 */ | |
4822 for (n = 1; n <= 2; ++n) | |
4823 { | |
4824 if (n == 2) | |
4825 { | |
4826 /* | |
4827 * Halve the number of backslashes (this is Vi compatible). | |
4828 * For Unix and OS/2, when wildcards are expanded, this is | |
4829 * done by ExpandOne() below. | |
4830 */ | |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7262
diff
changeset
|
4831 #if defined(UNIX) |
7 | 4832 if (!has_wildcards) |
4833 #endif | |
4834 backslash_halve(eap->arg); | |
4835 } | |
4836 | |
4837 if (has_wildcards) | |
4838 { | |
4839 if (n == 1) | |
4840 { | |
4841 /* | |
4842 * First loop: May expand environment variables. This | |
4843 * can be done much faster with expand_env() than with | |
4844 * something else (e.g., calling a shell). | |
4845 * After expanding environment variables, check again | |
4846 * if there are still wildcards present. | |
4847 */ | |
4848 if (vim_strchr(eap->arg, '$') != NULL | |
4849 || vim_strchr(eap->arg, '~') != NULL) | |
4850 { | |
372 | 4851 expand_env_esc(eap->arg, NameBuff, MAXPATHL, |
1408 | 4852 TRUE, TRUE, NULL); |
7 | 4853 has_wildcards = mch_has_wildcard(NameBuff); |
4854 p = NameBuff; | |
4855 } | |
4856 else | |
4857 p = NULL; | |
4858 } | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4859 else // n == 2 |
7 | 4860 { |
4861 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
|
4862 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
|
4863 | WILD_NOERROR | WILD_ADD_SLASH; |
7 | 4864 |
4865 ExpandInit(&xpc); | |
4866 xpc.xp_context = EXPAND_FILES; | |
2652 | 4867 if (p_wic) |
4868 options += WILD_ICASE; | |
7 | 4869 p = ExpandOne(&xpc, eap->arg, NULL, |
2652 | 4870 options, WILD_EXPAND_FREE); |
7 | 4871 if (p == NULL) |
4872 return FAIL; | |
4873 } | |
4874 if (p != NULL) | |
4875 { | |
4876 (void)repl_cmdline(eap, eap->arg, (int)STRLEN(eap->arg), | |
4877 p, cmdlinep); | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4878 if (n == 2) // p came from ExpandOne() |
7 | 4879 vim_free(p); |
4880 } | |
4881 } | |
4882 } | |
4883 } | |
4884 return OK; | |
4885 } | |
4886 | |
4887 /* | |
4888 * Replace part of the command line, keeping eap->cmd, eap->arg and | |
4889 * eap->nextcmd correct. | |
4890 * "src" points to the part that is to be replaced, of length "srclen". | |
4891 * "repl" is the replacement string. | |
4892 * Returns a pointer to the character after the replaced string. | |
4893 * Returns NULL for failure. | |
4894 */ | |
4895 static char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4896 repl_cmdline( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4897 exarg_T *eap, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4898 char_u *src, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4899 int srclen, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4900 char_u *repl, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4901 char_u **cmdlinep) |
7 | 4902 { |
4903 int len; | |
4904 int i; | |
4905 char_u *new_cmdline; | |
4906 | |
4907 /* | |
4908 * The new command line is build in new_cmdline[]. | |
4909 * First allocate it. | |
4910 * Careful: a "+cmd" argument may have been NUL terminated. | |
4911 */ | |
4912 len = (int)STRLEN(repl); | |
4913 i = (int)(src - *cmdlinep) + (int)STRLEN(src + srclen) + len + 3; | |
698 | 4914 if (eap->nextcmd != NULL) |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4915 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
|
4916 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
|
4917 return NULL; // out of memory! |
7 | 4918 |
4919 /* | |
4920 * Copy the stuff before the expanded part. | |
4921 * Copy the expanded stuff. | |
4922 * Copy what came after the expanded part. | |
4923 * Copy the next commands, if there are any. | |
4924 */ | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4925 i = (int)(src - *cmdlinep); // length of part before match |
7 | 4926 mch_memmove(new_cmdline, *cmdlinep, (size_t)i); |
434 | 4927 |
7 | 4928 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
|
4929 i += len; // remember the end of the string |
7 | 4930 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
|
4931 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
|
4932 |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4933 if (eap->nextcmd != NULL) // append next command |
7 | 4934 { |
4935 i = (int)STRLEN(new_cmdline) + 1; | |
4936 STRCPY(new_cmdline + i, eap->nextcmd); | |
4937 eap->nextcmd = new_cmdline + i; | |
4938 } | |
4939 eap->cmd = new_cmdline + (eap->cmd - *cmdlinep); | |
4940 eap->arg = new_cmdline + (eap->arg - *cmdlinep); | |
4941 if (eap->do_ecmd_cmd != NULL && eap->do_ecmd_cmd != dollar_command) | |
4942 eap->do_ecmd_cmd = new_cmdline + (eap->do_ecmd_cmd - *cmdlinep); | |
4943 vim_free(*cmdlinep); | |
4944 *cmdlinep = new_cmdline; | |
4945 | |
4946 return src; | |
4947 } | |
4948 | |
4949 /* | |
4950 * Check for '|' to separate commands and '"' to start comments. | |
4951 */ | |
4952 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4953 separate_nextcmd(exarg_T *eap) |
7 | 4954 { |
4955 char_u *p; | |
4956 | |
153 | 4957 #ifdef FEAT_QUICKFIX |
4958 p = skip_grep_pat(eap); | |
4959 #else | |
41 | 4960 p = eap->arg; |
4961 #endif | |
4962 | |
11127
506f5d8b7d8b
patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11010
diff
changeset
|
4963 for ( ; *p; MB_PTR_ADV(p)) |
7 | 4964 { |
4965 if (*p == Ctrl_V) | |
4966 { | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
4967 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
|
4968 ++p; // skip CTRL-V and next char |
7 | 4969 else |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4970 // remove CTRL-V and skip next char |
1619 | 4971 STRMOVE(p, p + 1); |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4972 if (*p == NUL) // stop at NUL after CTRL-V |
7 | 4973 break; |
4974 } | |
9 | 4975 |
4976 #ifdef FEAT_EVAL | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4977 // 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
|
4978 else if (p[0] == '`' && p[1] == '=' && (eap->argt & EX_XFILE)) |
9 | 4979 { |
4980 p += 2; | |
22685
80b4e604d1d5
patch 8.2.1891: Vim9: skipping over expression doesn't handle line breaks
Bram Moolenaar <Bram@vim.org>
parents:
22616
diff
changeset
|
4981 (void)skip_expr(&p, NULL); |
22724
51bc501a13ca
patch 8.2.1910: reading past the end of the command line
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
4982 if (*p == NUL) // stop at NUL after CTRL-V |
51bc501a13ca
patch 8.2.1910: reading past the end of the command line
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
4983 break; |
9 | 4984 } |
4985 #endif | |
4986 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4987 // 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
|
4988 // :@" 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
|
4989 // :redir @" doesn't either. |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21335
diff
changeset
|
4990 else if ((*p == '"' |
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21335
diff
changeset
|
4991 #ifdef FEAT_EVAL |
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21335
diff
changeset
|
4992 && !in_vim9script() |
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21335
diff
changeset
|
4993 #endif |
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21335
diff
changeset
|
4994 && !(eap->argt & EX_NOTRLCOM) |
7 | 4995 && ((eap->cmdidx != CMD_at && eap->cmdidx != CMD_star) |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21335
diff
changeset
|
4996 || p != eap->arg) |
7 | 4997 && (eap->cmdidx != CMD_redir |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21335
diff
changeset
|
4998 || p != eap->arg + 1 || p[-1] != '@')) |
20079
336483164ca6
patch 8.2.0595: Vim9: not all commands using ends_excmd() tested
Bram Moolenaar <Bram@vim.org>
parents:
20075
diff
changeset
|
4999 #ifdef FEAT_EVAL |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21335
diff
changeset
|
5000 || (*p == '#' |
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21335
diff
changeset
|
5001 && in_vim9script() |
21893
f19ac9b8b011
patch 8.2.1496: Vim9: cannot use " #" in a mapping
Bram Moolenaar <Bram@vim.org>
parents:
21885
diff
changeset
|
5002 && !(eap->argt & EX_NOTRLCOM) |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21335
diff
changeset
|
5003 && p > eap->cmd && VIM_ISWHITE(p[-1])) |
20079
336483164ca6
patch 8.2.0595: Vim9: not all commands using ends_excmd() tested
Bram Moolenaar <Bram@vim.org>
parents:
20075
diff
changeset
|
5004 #endif |
7 | 5005 || *p == '|' || *p == '\n') |
5006 { | |
5007 /* | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
5008 * We remove the '\' before the '|', unless EX_CTRLV is used |
7 | 5009 * AND 'b' is present in 'cpoptions'. |
5010 */ | |
5011 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
|
5012 || !(eap->argt & EX_CTRLV)) && *(p - 1) == '\\') |
7 | 5013 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5014 STRMOVE(p - 1, p); // remove the '\' |
7 | 5015 --p; |
5016 } | |
5017 else | |
5018 { | |
5019 eap->nextcmd = check_nextcmd(p); | |
5020 *p = NUL; | |
5021 break; | |
5022 } | |
5023 } | |
41 | 5024 } |
5025 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5026 if (!(eap->argt & EX_NOTRLCOM)) // remove trailing spaces |
7 | 5027 del_trailing_spaces(eap->arg); |
5028 } | |
5029 | |
5030 /* | |
5031 * get + command from ex argument | |
5032 */ | |
5033 static char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5034 getargcmd(char_u **argp) |
7 | 5035 { |
5036 char_u *arg = *argp; | |
5037 char_u *command = NULL; | |
5038 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5039 if (*arg == '+') // +[command] |
7 | 5040 { |
5041 ++arg; | |
5790 | 5042 if (vim_isspace(*arg) || *arg == NUL) |
7 | 5043 command = dollar_command; |
5044 else | |
5045 { | |
5046 command = arg; | |
5047 arg = skip_cmd_arg(command, TRUE); | |
5048 if (*arg != NUL) | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5049 *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
|
5050 } |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5051 |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5052 arg = skipwhite(arg); // skip over spaces |
7 | 5053 *argp = arg; |
5054 } | |
5055 return command; | |
5056 } | |
5057 | |
5058 /* | |
5059 * Find end of "+command" argument. Skip over "\ " and "\\". | |
5060 */ | |
17835
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17823
diff
changeset
|
5061 char_u * |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5062 skip_cmd_arg( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5063 char_u *p, |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5064 int rembs) // TRUE to halve the number of backslashes |
7 | 5065 { |
5066 while (*p && !vim_isspace(*p)) | |
5067 { | |
5068 if (*p == '\\' && p[1] != NUL) | |
5069 { | |
5070 if (rembs) | |
1619 | 5071 STRMOVE(p, p + 1); |
7 | 5072 else |
5073 ++p; | |
5074 } | |
11127
506f5d8b7d8b
patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11010
diff
changeset
|
5075 MB_PTR_ADV(p); |
7 | 5076 } |
5077 return p; | |
5078 } | |
5079 | |
13575
4df23d9bad47
patch 8.0.1660: the terminal API "drop" command doesn't support options
Christian Brabandt <cb@256bit.org>
parents:
13553
diff
changeset
|
5080 int |
4df23d9bad47
patch 8.0.1660: the terminal API "drop" command doesn't support options
Christian Brabandt <cb@256bit.org>
parents:
13553
diff
changeset
|
5081 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
|
5082 { |
4df23d9bad47
patch 8.0.1660: the terminal API "drop" command doesn't support options
Christian Brabandt <cb@256bit.org>
parents:
13553
diff
changeset
|
5083 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
|
5084 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
|
5085 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
|
5086 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
|
5087 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
|
5088 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
|
5089 else |
c1ead25ed819
patch 8.1.0043: ++bad argument of :edit does not work properly
Christian Brabandt <cb@256bit.org>
parents:
14035
diff
changeset
|
5090 return FAIL; |
c1ead25ed819
patch 8.1.0043: ++bad argument of :edit does not work properly
Christian Brabandt <cb@256bit.org>
parents:
14035
diff
changeset
|
5091 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
|
5092 } |
4df23d9bad47
patch 8.0.1660: the terminal API "drop" command doesn't support options
Christian Brabandt <cb@256bit.org>
parents:
13553
diff
changeset
|
5093 |
7 | 5094 /* |
5095 * Get "++opt=arg" argument. | |
5096 * Return FAIL or OK. | |
5097 */ | |
5098 static int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5099 getargopt(exarg_T *eap) |
7 | 5100 { |
5101 char_u *arg = eap->arg + 2; | |
5102 int *pp = NULL; | |
2168 | 5103 int bad_char_idx; |
7 | 5104 char_u *p; |
5105 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5106 // ":edit ++[no]bin[ary] file" |
7 | 5107 if (STRNCMP(arg, "bin", 3) == 0 || STRNCMP(arg, "nobin", 5) == 0) |
5108 { | |
5109 if (*arg == 'n') | |
5110 { | |
5111 arg += 2; | |
5112 eap->force_bin = FORCE_NOBIN; | |
5113 } | |
5114 else | |
5115 eap->force_bin = FORCE_BIN; | |
5116 if (!checkforcmd(&arg, "binary", 3)) | |
5117 return FAIL; | |
5118 eap->arg = skipwhite(arg); | |
5119 return OK; | |
5120 } | |
5121 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5122 // ":read ++edit file" |
819 | 5123 if (STRNCMP(arg, "edit", 4) == 0) |
5124 { | |
5125 eap->read_edit = TRUE; | |
5126 eap->arg = skipwhite(arg + 4); | |
5127 return OK; | |
5128 } | |
5129 | |
7 | 5130 if (STRNCMP(arg, "ff", 2) == 0) |
5131 { | |
5132 arg += 2; | |
5133 pp = &eap->force_ff; | |
5134 } | |
5135 else if (STRNCMP(arg, "fileformat", 10) == 0) | |
5136 { | |
5137 arg += 10; | |
5138 pp = &eap->force_ff; | |
5139 } | |
5140 else if (STRNCMP(arg, "enc", 3) == 0) | |
5141 { | |
3208 | 5142 if (STRNCMP(arg, "encoding", 8) == 0) |
5143 arg += 8; | |
5144 else | |
5145 arg += 3; | |
7 | 5146 pp = &eap->force_enc; |
5147 } | |
595 | 5148 else if (STRNCMP(arg, "bad", 3) == 0) |
5149 { | |
5150 arg += 3; | |
2168 | 5151 pp = &bad_char_idx; |
595 | 5152 } |
7 | 5153 |
5154 if (pp == NULL || *arg != '=') | |
5155 return FAIL; | |
5156 | |
5157 ++arg; | |
5158 *pp = (int)(arg - eap->cmd); | |
5159 arg = skip_cmd_arg(arg, FALSE); | |
5160 eap->arg = skipwhite(arg); | |
5161 *arg = NUL; | |
5162 | |
5163 if (pp == &eap->force_ff) | |
5164 { | |
5165 if (check_ff_value(eap->cmd + eap->force_ff) == FAIL) | |
5166 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
|
5167 eap->force_ff = eap->cmd[eap->force_ff]; |
7 | 5168 } |
595 | 5169 else if (pp == &eap->force_enc) |
7 | 5170 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5171 // Make 'fileencoding' lower case. |
7 | 5172 for (p = eap->cmd + eap->force_enc; *p != NUL; ++p) |
5173 *p = TOLOWER_ASC(*p); | |
5174 } | |
595 | 5175 else |
5176 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5177 // 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
|
5178 // "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
|
5179 if (get_bad_opt(eap->cmd + bad_char_idx, eap) == FAIL) |
595 | 5180 return FAIL; |
5181 } | |
7 | 5182 |
5183 return OK; | |
5184 } | |
5185 | |
5186 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5187 ex_autocmd(exarg_T *eap) |
7 | 5188 { |
5189 /* | |
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
|
5190 * Disallow autocommands from .exrc and .vimrc in current |
7 | 5191 * directory for security reasons. |
5192 */ | |
5193 if (secure) | |
5194 { | |
5195 secure = 2; | |
25064
8f2262c72178
patch 8.2.3069: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
24984
diff
changeset
|
5196 eap->errmsg = |
8f2262c72178
patch 8.2.3069: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
24984
diff
changeset
|
5197 _(e_command_not_allowed_from_vimrc_in_current_dir_or_tag_search); |
7 | 5198 } |
5199 else if (eap->cmdidx == CMD_autocmd) | |
5200 do_autocmd(eap->arg, eap->forceit); | |
5201 else | |
5202 do_augroup(eap->arg, eap->forceit); | |
5203 } | |
5204 | |
5205 /* | |
5206 * ":doautocmd": Apply the automatic commands to the current buffer. | |
5207 */ | |
5208 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5209 ex_doautocmd(exarg_T *eap) |
7 | 5210 { |
3350 | 5211 char_u *arg = eap->arg; |
5212 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
|
5213 int did_aucmd; |
ac8180818504
commit https://github.com/vim/vim/commit/1610d052413e0ed664498853a47acc2d677a22d1
Christian Brabandt <cb@256bit.org>
parents:
9230
diff
changeset
|
5214 |
ac8180818504
commit https://github.com/vim/vim/commit/1610d052413e0ed664498853a47acc2d677a22d1
Christian Brabandt <cb@256bit.org>
parents:
9230
diff
changeset
|
5215 (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
|
5216 // 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
|
5217 if (call_do_modelines && did_aucmd) |
3350 | 5218 do_modelines(0); |
7 | 5219 } |
5220 | |
5221 /* | |
5222 * :[N]bunload[!] [N] [bufname] unload buffer | |
5223 * :[N]bdelete[!] [N] [bufname] delete buffer from buffer list | |
5224 * :[N]bwipeout[!] [N] [bufname] delete buffer really | |
5225 */ | |
5226 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5227 ex_bunload(exarg_T *eap) |
7 | 5228 { |
19271
ebeeb4b4a1fa
patch 8.2.0194: some commands can cause problems in terminal popup
Bram Moolenaar <Bram@vim.org>
parents:
19261
diff
changeset
|
5229 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
|
5230 return; |
7 | 5231 eap->errmsg = do_bufdel( |
5232 eap->cmdidx == CMD_bdelete ? DOBUF_DEL | |
5233 : eap->cmdidx == CMD_bwipeout ? DOBUF_WIPE | |
5234 : DOBUF_UNLOAD, eap->arg, | |
5235 eap->addr_count, (int)eap->line1, (int)eap->line2, eap->forceit); | |
5236 } | |
5237 | |
5238 /* | |
5239 * :[N]buffer [N] to buffer N | |
5240 * :[N]sbuffer [N] to buffer N | |
5241 */ | |
5242 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5243 ex_buffer(exarg_T *eap) |
7 | 5244 { |
19271
ebeeb4b4a1fa
patch 8.2.0194: some commands can cause problems in terminal popup
Bram Moolenaar <Bram@vim.org>
parents:
19261
diff
changeset
|
5245 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
|
5246 return; |
7 | 5247 if (*eap->arg) |
21459
a422bd80b434
patch 8.2.1280: Ex command error cannot contain an argument
Bram Moolenaar <Bram@vim.org>
parents:
21413
diff
changeset
|
5248 eap->errmsg = ex_errmsg(e_trailing_arg, eap->arg); |
7 | 5249 else |
5250 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5251 if (eap->addr_count == 0) // default is current buffer |
7 | 5252 goto_buffer(eap, DOBUF_CURRENT, FORWARD, 0); |
5253 else | |
5254 goto_buffer(eap, DOBUF_FIRST, FORWARD, (int)eap->line2); | |
6230 | 5255 if (eap->do_ecmd_cmd != NULL) |
23011
ec23d84a096d
patch 8.2.2052: Vim9: "edit +4 fname" gives an error
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
5256 do_cmd_argument(eap->do_ecmd_cmd); |
7 | 5257 } |
5258 } | |
5259 | |
5260 /* | |
5261 * :[N]bmodified [N] to next mod. buffer | |
5262 * :[N]sbmodified [N] to next mod. buffer | |
5263 */ | |
5264 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5265 ex_bmodified(exarg_T *eap) |
7 | 5266 { |
5267 goto_buffer(eap, DOBUF_MOD, FORWARD, (int)eap->line2); | |
6230 | 5268 if (eap->do_ecmd_cmd != NULL) |
23011
ec23d84a096d
patch 8.2.2052: Vim9: "edit +4 fname" gives an error
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
5269 do_cmd_argument(eap->do_ecmd_cmd); |
7 | 5270 } |
5271 | |
5272 /* | |
5273 * :[N]bnext [N] to next buffer | |
5274 * :[N]sbnext [N] split and to next buffer | |
5275 */ | |
5276 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5277 ex_bnext(exarg_T *eap) |
7 | 5278 { |
19271
ebeeb4b4a1fa
patch 8.2.0194: some commands can cause problems in terminal popup
Bram Moolenaar <Bram@vim.org>
parents:
19261
diff
changeset
|
5279 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
|
5280 return; |
17722555af22
patch 8.2.0127: some buffer commands work in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19131
diff
changeset
|
5281 |
7 | 5282 goto_buffer(eap, DOBUF_CURRENT, FORWARD, (int)eap->line2); |
6230 | 5283 if (eap->do_ecmd_cmd != NULL) |
23011
ec23d84a096d
patch 8.2.2052: Vim9: "edit +4 fname" gives an error
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
5284 do_cmd_argument(eap->do_ecmd_cmd); |
7 | 5285 } |
5286 | |
5287 /* | |
5288 * :[N]bNext [N] to previous buffer | |
5289 * :[N]bprevious [N] to previous buffer | |
5290 * :[N]sbNext [N] split and to previous buffer | |
5291 * :[N]sbprevious [N] split and to previous buffer | |
5292 */ | |
5293 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5294 ex_bprevious(exarg_T *eap) |
7 | 5295 { |
19271
ebeeb4b4a1fa
patch 8.2.0194: some commands can cause problems in terminal popup
Bram Moolenaar <Bram@vim.org>
parents:
19261
diff
changeset
|
5296 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
|
5297 return; |
17722555af22
patch 8.2.0127: some buffer commands work in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19131
diff
changeset
|
5298 |
7 | 5299 goto_buffer(eap, DOBUF_CURRENT, BACKWARD, (int)eap->line2); |
6230 | 5300 if (eap->do_ecmd_cmd != NULL) |
23011
ec23d84a096d
patch 8.2.2052: Vim9: "edit +4 fname" gives an error
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
5301 do_cmd_argument(eap->do_ecmd_cmd); |
7 | 5302 } |
5303 | |
5304 /* | |
5305 * :brewind to first buffer | |
5306 * :bfirst to first buffer | |
5307 * :sbrewind split and to first buffer | |
5308 * :sbfirst split and to first buffer | |
5309 */ | |
5310 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5311 ex_brewind(exarg_T *eap) |
7 | 5312 { |
19271
ebeeb4b4a1fa
patch 8.2.0194: some commands can cause problems in terminal popup
Bram Moolenaar <Bram@vim.org>
parents:
19261
diff
changeset
|
5313 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
|
5314 return; |
17722555af22
patch 8.2.0127: some buffer commands work in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19131
diff
changeset
|
5315 |
7 | 5316 goto_buffer(eap, DOBUF_FIRST, FORWARD, 0); |
6230 | 5317 if (eap->do_ecmd_cmd != NULL) |
23011
ec23d84a096d
patch 8.2.2052: Vim9: "edit +4 fname" gives an error
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
5318 do_cmd_argument(eap->do_ecmd_cmd); |
7 | 5319 } |
5320 | |
5321 /* | |
5322 * :blast to last buffer | |
5323 * :sblast split and to last buffer | |
5324 */ | |
5325 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5326 ex_blast(exarg_T *eap) |
7 | 5327 { |
19271
ebeeb4b4a1fa
patch 8.2.0194: some commands can cause problems in terminal popup
Bram Moolenaar <Bram@vim.org>
parents:
19261
diff
changeset
|
5328 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
|
5329 return; |
17722555af22
patch 8.2.0127: some buffer commands work in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19131
diff
changeset
|
5330 |
7 | 5331 goto_buffer(eap, DOBUF_LAST, BACKWARD, 0); |
6230 | 5332 if (eap->do_ecmd_cmd != NULL) |
23011
ec23d84a096d
patch 8.2.2052: Vim9: "edit +4 fname" gives an error
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
5333 do_cmd_argument(eap->do_ecmd_cmd); |
7 | 5334 } |
5335 | |
20059
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20027
diff
changeset
|
5336 /* |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20027
diff
changeset
|
5337 * Check if "c" ends an Ex command. |
23185
055fa9db6f39
patch 8.2.2138: Vim9: "exit_cb" causes Vim to exit
Bram Moolenaar <Bram@vim.org>
parents:
23179
diff
changeset
|
5338 * In Vim9 script does not check for white space before #. |
20059
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20027
diff
changeset
|
5339 */ |
7 | 5340 int |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5341 ends_excmd(int c) |
7 | 5342 { |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21335
diff
changeset
|
5343 int comment_char = '"'; |
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21335
diff
changeset
|
5344 |
20027
23a4aef4f923
patch 8.2.0569: build failure with tiny version
Bram Moolenaar <Bram@vim.org>
parents:
20023
diff
changeset
|
5345 #ifdef FEAT_EVAL |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21335
diff
changeset
|
5346 if (in_vim9script()) |
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21335
diff
changeset
|
5347 comment_char = '#'; |
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21335
diff
changeset
|
5348 #endif |
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21335
diff
changeset
|
5349 return (c == NUL || c == '|' || c == comment_char || c == '\n'); |
20059
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20027
diff
changeset
|
5350 } |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20027
diff
changeset
|
5351 |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20027
diff
changeset
|
5352 /* |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20027
diff
changeset
|
5353 * Like ends_excmd() but checks that a # in Vim9 script either has "cmd" equal |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20027
diff
changeset
|
5354 * to "cmd_start" or has a white space character before it. |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20027
diff
changeset
|
5355 */ |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20027
diff
changeset
|
5356 int |
20063
cc146cde0b4d
patch 8.2.0587: compiler warning for unused variable
Bram Moolenaar <Bram@vim.org>
parents:
20059
diff
changeset
|
5357 ends_excmd2(char_u *cmd_start UNUSED, char_u *cmd) |
20059
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20027
diff
changeset
|
5358 { |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20027
diff
changeset
|
5359 int c = *cmd; |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20027
diff
changeset
|
5360 |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21335
diff
changeset
|
5361 if (c == NUL || c == '|' || c == '\n') |
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21335
diff
changeset
|
5362 return TRUE; |
20059
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20027
diff
changeset
|
5363 #ifdef FEAT_EVAL |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21335
diff
changeset
|
5364 if (in_vim9script()) |
24176
12378fbc99bc
patch 8.2.2629: Vim9: error for #{{ is not desired
Bram Moolenaar <Bram@vim.org>
parents:
24174
diff
changeset
|
5365 // # starts a comment, #{ might be a mistake, #{{ can start a fold |
12378fbc99bc
patch 8.2.2629: Vim9: error for #{{ is not desired
Bram Moolenaar <Bram@vim.org>
parents:
24174
diff
changeset
|
5366 return c == '#' && (cmd[1] != '{' || cmd[2] == '{') |
24174
99bfaa4693db
patch 8.2.2628: Vim9: #{ can still be used at the script level
Bram Moolenaar <Bram@vim.org>
parents:
24124
diff
changeset
|
5367 && (cmd == cmd_start || VIM_ISWHITE(cmd[-1])); |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21335
diff
changeset
|
5368 #endif |
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21335
diff
changeset
|
5369 return c == '"'; |
7 | 5370 } |
5371 | |
5372 #if defined(FEAT_SYN_HL) || defined(FEAT_SEARCH_EXTRA) || defined(FEAT_EVAL) \ | |
5373 || defined(PROTO) | |
5374 /* | |
5375 * Return the next command, after the first '|' or '\n'. | |
5376 * Return NULL if not found. | |
5377 */ | |
5378 char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5379 find_nextcmd(char_u *p) |
7 | 5380 { |
5381 while (*p != '|' && *p != '\n') | |
5382 { | |
5383 if (*p == NUL) | |
5384 return NULL; | |
5385 ++p; | |
5386 } | |
5387 return (p + 1); | |
5388 } | |
5389 #endif | |
5390 | |
5391 /* | |
10383
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5392 * 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
|
5393 * Return NULL if it isn't, the following character if it is. |
7 | 5394 */ |
5395 char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5396 check_nextcmd(char_u *p) |
7 | 5397 { |
10383
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5398 char_u *s = skipwhite(p); |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5399 |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5400 if (*s == '|' || *s == '\n') |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5401 return (s + 1); |
7 | 5402 else |
5403 return NULL; | |
5404 } | |
5405 | |
5406 /* | |
5407 * - if there are more files to edit | |
5408 * - and this is the last window | |
5409 * - and forceit not used | |
5410 * - and not repeated twice on a row | |
5411 * return FAIL and give error message if 'message' TRUE | |
5412 * return OK otherwise | |
5413 */ | |
5414 static int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5415 check_more( |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5416 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
|
5417 int forceit) |
7 | 5418 { |
5419 int n = ARGCOUNT - curwin->w_arg_idx - 1; | |
5420 | |
672 | 5421 if (!forceit && only_one_window() |
21845
0e6ee11977b3
patch 8.2.1472: ":argdel" does not work like ":.argdel" as documented
Bram Moolenaar <Bram@vim.org>
parents:
21821
diff
changeset
|
5422 && ARGCOUNT > 1 && !arg_had_last && n > 0 && quitmore == 0) |
7 | 5423 { |
5424 if (message) | |
5425 { | |
5426 #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) | |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
5427 if ((p_confirm || (cmdmod.cmod_flags & CMOD_CONFIRM)) |
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
5428 && curbuf->b_fname != NULL) |
7 | 5429 { |
2770 | 5430 char_u buff[DIALOG_MSG_SIZE]; |
7 | 5431 |
14585
c8f07e8b273e
patch 8.1.0306: plural messages are not translated properly
Christian Brabandt <cb@256bit.org>
parents:
14550
diff
changeset
|
5432 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
|
5433 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
|
5434 "%d more files to edit. Quit anyway?", n), n); |
7 | 5435 if (vim_dialog_yesno(VIM_QUESTION, NULL, buff, 1) == VIM_YES) |
5436 return OK; | |
5437 return FAIL; | |
5438 } | |
5439 #endif | |
15490
98c35d312987
patch 8.1.0753: printf format not checked for semsg()
Bram Moolenaar <Bram@vim.org>
parents:
15488
diff
changeset
|
5440 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
|
5441 "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
|
5442 quitmore = 2; // next try to quit is allowed |
7 | 5443 } |
5444 return FAIL; | |
5445 } | |
5446 return OK; | |
5447 } | |
5448 | |
5449 /* | |
5450 * Function given to ExpandGeneric() to obtain the list of command names. | |
5451 */ | |
5452 char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5453 get_command_name(expand_T *xp UNUSED, int idx) |
7 | 5454 { |
5455 if (idx >= (int)CMD_SIZE) | |
5456 return get_user_command_name(idx); | |
5457 return cmdnames[idx].cmd_name; | |
5458 } | |
5459 | |
5460 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5461 ex_colorscheme(exarg_T *eap) |
7 | 5462 { |
2142
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
5463 if (*eap->arg == NUL) |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
5464 { |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
5465 #ifdef FEAT_EVAL |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
5466 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
|
5467 char_u *p = NULL; |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
5468 |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
5469 if (expr != NULL) |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
5470 { |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
5471 ++emsg_off; |
20996
3af71cbcfdbe
patch 8.2.1049: Vim9: leaking memory when using continuation line
Bram Moolenaar <Bram@vim.org>
parents:
20982
diff
changeset
|
5472 p = eval_to_string(expr, FALSE); |
2142
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
5473 --emsg_off; |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
5474 vim_free(expr); |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
5475 } |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
5476 if (p != NULL) |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
5477 { |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15510
diff
changeset
|
5478 msg((char *)p); |
2142
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
5479 vim_free(p); |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
5480 } |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
5481 else |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15510
diff
changeset
|
5482 msg("default"); |
2142
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
5483 #else |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15510
diff
changeset
|
5484 msg(_("unknown")); |
2142
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
5485 #endif |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
5486 } |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
5487 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
|
5488 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
|
5489 |
61448894376e
patch 8.1.0839: when using VTP wrong colors after a color scheme change
Bram Moolenaar <Bram@vim.org>
parents:
15643
diff
changeset
|
5490 #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
|
5491 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
|
5492 { |
61448894376e
patch 8.1.0839: when using VTP wrong colors after a color scheme change
Bram Moolenaar <Bram@vim.org>
parents:
15643
diff
changeset
|
5493 // 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
|
5494 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
|
5495 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
|
5496 } |
61448894376e
patch 8.1.0839: when using VTP wrong colors after a color scheme change
Bram Moolenaar <Bram@vim.org>
parents:
15643
diff
changeset
|
5497 #endif |
7 | 5498 } |
5499 | |
5500 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5501 ex_highlight(exarg_T *eap) |
7 | 5502 { |
5503 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
|
5504 msg(_("Greetings, Vim user!")); |
7 | 5505 do_highlight(eap->arg, eap->forceit, FALSE); |
5506 } | |
5507 | |
5508 | |
5509 /* | |
5510 * Call this function if we thought we were going to exit, but we won't | |
5511 * (because of an error). May need to restore the terminal mode. | |
5512 */ | |
5513 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5514 not_exiting(void) |
7 | 5515 { |
5516 exiting = FALSE; | |
5517 settmode(TMODE_RAW); | |
5518 } | |
5519 | |
24719
4ae10e6c3a9c
patch 8.2.2898: QuitPre and ExitPre not triggered when GUI window is closed
Bram Moolenaar <Bram@vim.org>
parents:
24699
diff
changeset
|
5520 int |
13442
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5521 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
|
5522 { |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5523 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
|
5524 |
18406
fa6efc49d71f
patch 8.1.2197: ExitPre autocommand may cause accessing freed memory
Bram Moolenaar <Bram@vim.org>
parents:
18402
diff
changeset
|
5525 // 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
|
5526 // 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
|
5527 // only happen in autocommands). |
13442
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5528 if (!win_valid(wp) |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5529 || curbuf_locked() |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5530 || (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
|
5531 return TRUE; |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5532 |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5533 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
|
5534 { |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5535 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
|
5536 // 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
|
5537 // 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
|
5538 // autocommands). |
fa6efc49d71f
patch 8.1.2197: ExitPre autocommand may cause accessing freed memory
Bram Moolenaar <Bram@vim.org>
parents:
18402
diff
changeset
|
5539 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
|
5540 || (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
|
5541 return TRUE; |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5542 } |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5543 |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5544 return FALSE; |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5545 } |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5546 |
7 | 5547 /* |
6409 | 5548 * ":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
|
5549 * ":{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
|
5550 * 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
|
5551 */ |
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
|
5552 void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5553 ex_quit(exarg_T *eap) |
7 | 5554 { |
6398 | 5555 win_T *wp; |
5556 | |
7 | 5557 #ifdef FEAT_CMDWIN |
5558 if (cmdwin_type != 0) | |
5559 { | |
5560 cmdwin_result = Ctrl_C; | |
5561 return; | |
5562 } | |
5563 #endif | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5564 // Don't quit while editing the command line. |
633 | 5565 if (text_locked()) |
5566 { | |
5567 text_locked_msg(); | |
631 | 5568 return; |
5569 } | |
6398 | 5570 if (eap->addr_count > 0) |
5571 { | |
6409 | 5572 int wnr = eap->line2; |
5573 | |
5574 for (wp = firstwin; wp->w_next != NULL; wp = wp->w_next) | |
5575 if (--wnr <= 0) | |
6398 | 5576 break; |
5577 } | |
5578 else | |
5579 wp = curwin; | |
6409 | 5580 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5581 // 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
|
5582 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
|
5583 return; |
13442
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5584 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5585 // 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
|
5586 if (before_quit_autocmds(wp, FALSE, eap->forceit)) |
819 | 5587 return; |
7 | 5588 |
5589 #ifdef FEAT_NETBEANS_INTG | |
5590 netbeansForcedQuit = eap->forceit; | |
5591 #endif | |
5592 | |
5593 /* | |
24719
4ae10e6c3a9c
patch 8.2.2898: QuitPre and ExitPre not triggered when GUI window is closed
Bram Moolenaar <Bram@vim.org>
parents:
24699
diff
changeset
|
5594 * If there is only one relevant window we will exit. |
7 | 5595 */ |
5596 if (check_more(FALSE, eap->forceit) == OK && only_one_window()) | |
5597 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
|
5598 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
|
5599 && check_changed(wp->w_buffer, (p_awa ? CCGD_AW : 0) |
5464 | 5600 | (eap->forceit ? CCGD_FORCEIT : 0) |
5601 | CCGD_EXCMD)) | |
7 | 5602 || 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
|
5603 || (only_one_window() && check_changed_any(eap->forceit, TRUE))) |
7 | 5604 { |
5605 not_exiting(); | |
5606 } | |
5607 else | |
5608 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5609 // quit last window |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5610 // 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
|
5611 // 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
|
5612 // specified. Example: |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5613 // :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
|
5614 // :h|wincmd w|q - quit |
10349
cf988222b150
commit https://github.com/vim/vim/commit/a1f4cb93ba50ea9e40cd4b1f5592b8a6d1398660
Christian Brabandt <cb@256bit.org>
parents:
10275
diff
changeset
|
5615 if (only_one_window() && (ONE_WINDOW || eap->addr_count == 0)) |
7 | 5616 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
|
5617 not_exiting(); |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5618 #ifdef FEAT_GUI |
7 | 5619 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
|
5620 #endif |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5621 // 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
|
5622 win_close(wp, !buf_hide(wp->w_buffer) || eap->forceit); |
7 | 5623 } |
5624 } | |
5625 | |
5626 /* | |
5627 * ":cquit". | |
5628 */ | |
5629 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5630 ex_cquit(exarg_T *eap UNUSED) |
7 | 5631 { |
19069
e14feba578f1
patch 8.2.0095: cannot specify exit code for :cquit
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
5632 // 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
|
5633 getout(eap->addr_count > 0 ? (int)eap->line2 : EXIT_FAILURE); |
7 | 5634 } |
5635 | |
5636 /* | |
5637 * ":qall": try to quit all windows | |
5638 */ | |
5639 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5640 ex_quit_all(exarg_T *eap) |
7 | 5641 { |
5642 # ifdef FEAT_CMDWIN | |
5643 if (cmdwin_type != 0) | |
5644 { | |
5645 if (eap->forceit) | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5646 cmdwin_result = K_XF1; // ex_window() takes care of this |
7 | 5647 else |
5648 cmdwin_result = K_XF2; | |
5649 return; | |
5650 } | |
5651 # endif | |
631 | 5652 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5653 // Don't quit while editing the command line. |
633 | 5654 if (text_locked()) |
5655 { | |
5656 text_locked_msg(); | |
631 | 5657 return; |
5658 } | |
13442
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5659 |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5660 if (before_quit_autocmds(curwin, TRUE, eap->forceit)) |
819 | 5661 return; |
631 | 5662 |
7 | 5663 exiting = TRUE; |
7469
15eefe1b0dad
commit https://github.com/vim/vim/commit/027387f70c671f62e3e08e0bdd09ec05b0232735
Christian Brabandt <cb@256bit.org>
parents:
7465
diff
changeset
|
5664 if (eap->forceit || !check_changed_any(FALSE, FALSE)) |
7 | 5665 getout(0); |
5666 not_exiting(); | |
5667 } | |
5668 | |
5669 /* | |
5670 * ":close": close current window, unless it is the last one | |
5671 */ | |
5672 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5673 ex_close(exarg_T *eap) |
7 | 5674 { |
6398 | 5675 win_T *win; |
5676 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
|
5677 #ifdef FEAT_CMDWIN |
7 | 5678 if (cmdwin_type != 0) |
2839 | 5679 cmdwin_result = Ctrl_C; |
7 | 5680 else |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5681 #endif |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
5682 if (!text_locked() && !curbuf_locked()) |
6398 | 5683 { |
5684 if (eap->addr_count == 0) | |
5685 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
|
5686 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
|
5687 { |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9538
diff
changeset
|
5688 FOR_ALL_WINDOWS(win) |
6398 | 5689 { |
5690 winnr++; | |
5691 if (winnr == eap->line2) | |
5692 break; | |
5693 } | |
5694 if (win == NULL) | |
5695 win = lastwin; | |
5696 ex_win_close(eap->forceit, win, NULL); | |
5697 } | |
5698 } | |
667 | 5699 } |
5700 | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5701 #ifdef FEAT_QUICKFIX |
667 | 5702 /* |
5703 * ":pclose": Close any preview window. | |
5704 */ | |
5705 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5706 ex_pclose(exarg_T *eap) |
667 | 5707 { |
5708 win_T *win; | |
5709 | |
17431
ce35cdbe9f74
patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
17336
diff
changeset
|
5710 // First close any normal window. |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9538
diff
changeset
|
5711 FOR_ALL_WINDOWS(win) |
667 | 5712 if (win->w_p_pvw) |
5713 { | |
671 | 5714 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
|
5715 return; |
ce35cdbe9f74
patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
17336
diff
changeset
|
5716 } |
18763
49b78d6465e5
patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents:
18715
diff
changeset
|
5717 # 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
|
5718 // 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
|
5719 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
|
5720 # endif |
667 | 5721 } |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5722 #endif |
667 | 5723 |
671 | 5724 /* |
5725 * Close window "win" and take care of handling closing the last window for a | |
5726 * modified buffer. | |
5727 */ | |
5728 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5729 ex_win_close( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5730 int forceit, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5731 win_T *win, |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5732 tabpage_T *tp) // NULL or the tab page "win" is in |
7 | 5733 { |
5734 int need_hide; | |
5735 buf_T *buf = win->w_buffer; | |
5736 | |
21016
0738c44504cb
patch 8.2.1059: crash when using :tabonly in an autocommand
Bram Moolenaar <Bram@vim.org>
parents:
20996
diff
changeset
|
5737 // Never close the autocommand window. |
0738c44504cb
patch 8.2.1059: crash when using :tabonly in an autocommand
Bram Moolenaar <Bram@vim.org>
parents:
20996
diff
changeset
|
5738 if (win == aucmd_win) |
0738c44504cb
patch 8.2.1059: crash when using :tabonly in an autocommand
Bram Moolenaar <Bram@vim.org>
parents:
20996
diff
changeset
|
5739 { |
0738c44504cb
patch 8.2.1059: crash when using :tabonly in an autocommand
Bram Moolenaar <Bram@vim.org>
parents:
20996
diff
changeset
|
5740 emsg(_(e_autocmd_close)); |
0738c44504cb
patch 8.2.1059: crash when using :tabonly in an autocommand
Bram Moolenaar <Bram@vim.org>
parents:
20996
diff
changeset
|
5741 return; |
0738c44504cb
patch 8.2.1059: crash when using :tabonly in an autocommand
Bram Moolenaar <Bram@vim.org>
parents:
20996
diff
changeset
|
5742 } |
0738c44504cb
patch 8.2.1059: crash when using :tabonly in an autocommand
Bram Moolenaar <Bram@vim.org>
parents:
20996
diff
changeset
|
5743 |
7 | 5744 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
|
5745 if (need_hide && !buf_hide(buf) && !forceit) |
7 | 5746 { |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5747 #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
5748 if ((p_confirm || (cmdmod.cmod_flags & CMOD_CONFIRM)) && p_write) |
7 | 5749 { |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9460
diff
changeset
|
5750 bufref_T bufref; |
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9460
diff
changeset
|
5751 |
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9460
diff
changeset
|
5752 set_bufref(&bufref, buf); |
7 | 5753 dialog_changed(buf, FALSE); |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9460
diff
changeset
|
5754 if (bufref_valid(&bufref) && bufIsChanged(buf)) |
7 | 5755 return; |
5756 need_hide = FALSE; | |
5757 } | |
5758 else | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5759 #endif |
7 | 5760 { |
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
|
5761 no_write_message(); |
7 | 5762 return; |
5763 } | |
5764 } | |
5765 | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5766 #ifdef FEAT_GUI |
7 | 5767 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
|
5768 #endif |
671 | 5769 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5770 // free buffer when not hiding it or when it's a scratch buffer |
671 | 5771 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
|
5772 win_close(win, !need_hide && !buf_hide(buf)); |
671 | 5773 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
|
5774 win_close_othertab(win, !need_hide && !buf_hide(buf), tp); |
671 | 5775 } |
5776 | |
5777 /* | |
10741
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5778 * 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
|
5779 * Returns a tabpage number. |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5780 * 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
|
5781 */ |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5782 static int |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5783 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
|
5784 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5785 int tab_number; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5786 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
|
5787 |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5788 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
|
5789 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5790 char_u *p = eap->arg; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5791 char_u *p_save; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5792 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
|
5793 // 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
|
5794 |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5795 if (*p == '-') |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5796 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5797 relative = -1; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5798 p++; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5799 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5800 else if (*p == '+') |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5801 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5802 relative = 1; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5803 p++; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5804 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5805 |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5806 p_save = p; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5807 tab_number = getdigits(&p); |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5808 |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5809 if (relative == 0) |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5810 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5811 if (STRCMP(p, "$") == 0) |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5812 tab_number = LAST_TAB_NR; |
21727
860cad58f557
patch 8.2.1413: previous tab page not usable from an Ex command
Bram Moolenaar <Bram@vim.org>
parents:
21664
diff
changeset
|
5813 else if (STRCMP(p, "#") == 0) |
860cad58f557
patch 8.2.1413: previous tab page not usable from an Ex command
Bram Moolenaar <Bram@vim.org>
parents:
21664
diff
changeset
|
5814 if (valid_tabpage(lastused_tabpage)) |
860cad58f557
patch 8.2.1413: previous tab page not usable from an Ex command
Bram Moolenaar <Bram@vim.org>
parents:
21664
diff
changeset
|
5815 tab_number = tabpage_index(lastused_tabpage); |
860cad58f557
patch 8.2.1413: previous tab page not usable from an Ex command
Bram Moolenaar <Bram@vim.org>
parents:
21664
diff
changeset
|
5816 else |
860cad58f557
patch 8.2.1413: previous tab page not usable from an Ex command
Bram Moolenaar <Bram@vim.org>
parents:
21664
diff
changeset
|
5817 { |
860cad58f557
patch 8.2.1413: previous tab page not usable from an Ex command
Bram Moolenaar <Bram@vim.org>
parents:
21664
diff
changeset
|
5818 eap->errmsg = ex_errmsg(e_invargval, eap->arg); |
860cad58f557
patch 8.2.1413: previous tab page not usable from an Ex command
Bram Moolenaar <Bram@vim.org>
parents:
21664
diff
changeset
|
5819 tab_number = 0; |
860cad58f557
patch 8.2.1413: previous tab page not usable from an Ex command
Bram Moolenaar <Bram@vim.org>
parents:
21664
diff
changeset
|
5820 goto theend; |
860cad58f557
patch 8.2.1413: previous tab page not usable from an Ex command
Bram Moolenaar <Bram@vim.org>
parents:
21664
diff
changeset
|
5821 } |
10741
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5822 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
|
5823 || tab_number > LAST_TAB_NR) |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5824 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5825 // No numbers as argument. |
21459
a422bd80b434
patch 8.2.1280: Ex command error cannot contain an argument
Bram Moolenaar <Bram@vim.org>
parents:
21413
diff
changeset
|
5826 eap->errmsg = ex_errmsg(e_invarg2, eap->arg); |
10741
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5827 goto theend; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5828 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5829 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5830 else |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5831 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5832 if (*p_save == NUL) |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5833 tab_number = 1; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5834 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
|
5835 || tab_number == 0) |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5836 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5837 // No numbers as argument. |
21459
a422bd80b434
patch 8.2.1280: Ex command error cannot contain an argument
Bram Moolenaar <Bram@vim.org>
parents:
21413
diff
changeset
|
5838 eap->errmsg = ex_errmsg(e_invarg2, eap->arg); |
10741
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5839 goto theend; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5840 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5841 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
|
5842 if (!unaccept_arg0 && relative == -1) |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5843 --tab_number; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5844 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5845 if (tab_number < unaccept_arg0 || tab_number > LAST_TAB_NR) |
21459
a422bd80b434
patch 8.2.1280: Ex command error cannot contain an argument
Bram Moolenaar <Bram@vim.org>
parents:
21413
diff
changeset
|
5846 eap->errmsg = ex_errmsg(e_invarg2, eap->arg); |
10741
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5847 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5848 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
|
5849 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5850 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
|
5851 { |
25064
8f2262c72178
patch 8.2.3069: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
24984
diff
changeset
|
5852 eap->errmsg = _(e_invalid_range); |
10753
4961e7acdd8c
patch 8.0.0266: compiler warning for using uninitialized variable
Christian Brabandt <cb@256bit.org>
parents:
10741
diff
changeset
|
5853 tab_number = 0; |
4961e7acdd8c
patch 8.0.0266: compiler warning for using uninitialized variable
Christian Brabandt <cb@256bit.org>
parents:
10741
diff
changeset
|
5854 } |
10741
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5855 else |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5856 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5857 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
|
5858 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
|
5859 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5860 --tab_number; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5861 if (tab_number < unaccept_arg0) |
25064
8f2262c72178
patch 8.2.3069: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
24984
diff
changeset
|
5862 eap->errmsg = _(e_invalid_range); |
10741
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5863 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5864 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5865 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5866 else |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5867 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5868 switch (eap->cmdidx) |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5869 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5870 case CMD_tabnext: |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5871 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
|
5872 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
|
5873 tab_number = 1; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5874 break; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5875 case CMD_tabmove: |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5876 tab_number = LAST_TAB_NR; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5877 break; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5878 default: |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5879 tab_number = tabpage_index(curtab); |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5880 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5881 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5882 |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5883 theend: |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5884 return tab_number; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5885 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5886 |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5887 /* |
671 | 5888 * ":tabclose": close current tab page, unless it is the last one. |
5889 * ":tabclose N": close tab page N. | |
667 | 5890 */ |
5891 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5892 ex_tabclose(exarg_T *eap) |
667 | 5893 { |
671 | 5894 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
|
5895 int tab_number; |
671 | 5896 |
667 | 5897 # ifdef FEAT_CMDWIN |
5898 if (cmdwin_type != 0) | |
5899 cmdwin_result = K_IGNORE; | |
5900 else | |
5901 # endif | |
671 | 5902 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
|
5903 emsg(_("E784: Cannot close last tab page")); |
671 | 5904 else |
5905 { | |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5906 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
|
5907 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
|
5908 { |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5909 tp = find_tabpage(tab_number); |
671 | 5910 if (tp == NULL) |
5911 { | |
5912 beep_flush(); | |
5913 return; | |
5914 } | |
674 | 5915 if (tp != curtab) |
671 | 5916 { |
5917 tabpage_close_other(tp, eap->forceit); | |
5918 return; | |
5919 } | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
5920 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
|
5921 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
|
5922 } |
671 | 5923 } |
672 | 5924 } |
5925 | |
5926 /* | |
5927 * ":tabonly": close all tab pages except the current one | |
5928 */ | |
5929 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5930 ex_tabonly(exarg_T *eap) |
672 | 5931 { |
5932 tabpage_T *tp; | |
5933 int done; | |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5934 int tab_number; |
672 | 5935 |
5936 # ifdef FEAT_CMDWIN | |
5937 if (cmdwin_type != 0) | |
5938 cmdwin_result = K_IGNORE; | |
5939 else | |
5940 # endif | |
5941 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
|
5942 msg(_("Already only one tab page")); |
672 | 5943 else |
5944 { | |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5945 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
|
5946 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
|
5947 { |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5948 goto_tabpage(tab_number); |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5949 // 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
|
5950 // 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
|
5951 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
|
5952 { |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5953 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
|
5954 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
|
5955 { |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5956 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
|
5957 // 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
|
5958 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
|
5959 done = 1000; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5960 // 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
|
5961 break; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5962 } |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5963 if (first_tabpage->tp_next == NULL) |
672 | 5964 break; |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5965 } |
672 | 5966 } |
5967 } | |
671 | 5968 } |
5969 | |
5970 /* | |
5971 * Close the current tab page. | |
5972 */ | |
5973 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5974 tabpage_close(int forceit) |
671 | 5975 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5976 // 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
|
5977 // 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
|
5978 if (!ONE_WINDOW) |
675 | 5979 close_others(TRUE, forceit); |
10357
59d01e335858
commit https://github.com/vim/vim/commit/459ca563128f2edb7e3bb190090bbb755a56dd55
Christian Brabandt <cb@256bit.org>
parents:
10349
diff
changeset
|
5980 if (ONE_WINDOW) |
671 | 5981 ex_win_close(forceit, curwin, NULL); |
5982 # ifdef FEAT_GUI | |
5983 need_mouse_correct = TRUE; | |
5984 # endif | |
5985 } | |
5986 | |
5987 /* | |
5988 * Close tab page "tp", which is not the current tab page. | |
5989 * Note that autocommands may make "tp" invalid. | |
971 | 5990 * Also takes care of the tab pages line disappearing when closing the |
5991 * last-but-one tab page. | |
671 | 5992 */ |
5993 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5994 tabpage_close_other(tabpage_T *tp, int forceit) |
671 | 5995 { |
5996 int done = 0; | |
672 | 5997 win_T *wp; |
971 | 5998 int h = tabline_height(); |
671 | 5999 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6000 // 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
|
6001 // one. OK, so I'm paranoid... |
671 | 6002 while (++done < 1000) |
6003 { | |
672 | 6004 wp = tp->tp_firstwin; |
6005 ex_win_close(forceit, wp, tp); | |
6006 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6007 // 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
|
6008 // fail to close a window with a modified buffer. |
672 | 6009 if (!valid_tabpage(tp) || tp->tp_firstwin == wp) |
671 | 6010 break; |
6011 } | |
971 | 6012 |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9538
diff
changeset
|
6013 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
|
6014 |
672 | 6015 redraw_tabline = TRUE; |
971 | 6016 if (h != tabline_height()) |
6017 shell_new_rows(); | |
667 | 6018 } |
7 | 6019 |
6020 /* | |
6021 * ":only". | |
6022 */ | |
6023 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6024 ex_only(exarg_T *eap) |
7 | 6025 { |
6398 | 6026 win_T *wp; |
6027 int wnr; | |
7 | 6028 # ifdef FEAT_GUI |
6029 need_mouse_correct = TRUE; | |
6030 # endif | |
6398 | 6031 if (eap->addr_count > 0) |
6032 { | |
6033 wnr = eap->line2; | |
6034 for (wp = firstwin; --wnr > 0; ) | |
6035 { | |
6036 if (wp->w_next == NULL) | |
6037 break; | |
6038 else | |
6039 wp = wp->w_next; | |
6040 } | |
6041 win_goto(wp); | |
6042 } | |
7 | 6043 close_others(TRUE, eap->forceit); |
6044 } | |
6045 | |
6046 static void | |
10492
b2cd5a71f4bb
commit https://github.com/vim/vim/commit/5e1e6d265d26ee2952c4a018a5ff72c950d2d700
Christian Brabandt <cb@256bit.org>
parents:
10490
diff
changeset
|
6047 ex_hide(exarg_T *eap UNUSED) |
7 | 6048 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6049 // ":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
|
6050 if (!eap->skip) |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
6051 { |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
6052 #ifdef FEAT_GUI |
10383
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
6053 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
|
6054 #endif |
10383
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
6055 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
|
6056 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
|
6057 else |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
6058 { |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
6059 int winnr = 0; |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
6060 win_T *win; |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
6061 |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
6062 FOR_ALL_WINDOWS(win) |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
6063 { |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
6064 winnr++; |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
6065 if (winnr == eap->line2) |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
6066 break; |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
6067 } |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
6068 if (win == NULL) |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
6069 win = lastwin; |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
6070 win_close(win, FALSE); |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
6071 } |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
6072 } |
7 | 6073 } |
6074 | |
6075 /* | |
6076 * ":stop" and ":suspend": Suspend Vim. | |
6077 */ | |
6078 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6079 ex_stop(exarg_T *eap) |
7 | 6080 { |
6081 /* | |
6082 * Disallow suspending for "rvim". | |
6083 */ | |
10264
c036c0f636d5
commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents:
10240
diff
changeset
|
6084 if (!check_restricted()) |
7 | 6085 { |
6086 if (!eap->forceit) | |
6087 autowrite_all(); | |
23165
a916fca16d4b
patch 8.2.2128: there is no way to do something on CTRL-Z
Bram Moolenaar <Bram@vim.org>
parents:
23062
diff
changeset
|
6088 apply_autocmds(EVENT_VIMSUSPEND, NULL, NULL, FALSE, NULL); |
7 | 6089 windgoto((int)Rows - 1, 0); |
6090 out_char('\n'); | |
6091 out_flush(); | |
6092 stoptermcap(); | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6093 out_flush(); // needed for SUN to restore xterm buffer |
7 | 6094 #ifdef FEAT_TITLE |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6095 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
|
6096 #endif |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6097 ui_suspend(); // call machine specific function |
7 | 6098 #ifdef FEAT_TITLE |
6099 maketitle(); | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6100 resettitle(); // force updating the title |
7 | 6101 #endif |
6102 starttermcap(); | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6103 scroll_start(); // scroll screen before redrawing |
7 | 6104 redraw_later_clear(); |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6105 shell_resized(); // may have resized window |
23165
a916fca16d4b
patch 8.2.2128: there is no way to do something on CTRL-Z
Bram Moolenaar <Bram@vim.org>
parents:
23062
diff
changeset
|
6106 apply_autocmds(EVENT_VIMRESUME, NULL, NULL, FALSE, NULL); |
7 | 6107 } |
6108 } | |
6109 | |
6110 /* | |
24723
5194fba32954
patch 8.2.2900: QuitPre is triggered before :wq writes the file
Bram Moolenaar <Bram@vim.org>
parents:
24719
diff
changeset
|
6111 * ":exit", ":xit" and ":wq": Write file and quit the current window. |
7 | 6112 */ |
6113 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6114 ex_exit(exarg_T *eap) |
7 | 6115 { |
21518
0b448762ebbd
patch 8.2.1309: build failure with tiny version
Bram Moolenaar <Bram@vim.org>
parents:
21516
diff
changeset
|
6116 #ifdef FEAT_EVAL |
21516
c7b2ce90c2de
patch 8.2.1308: Vim9: accidentally using "x" causes Vim to exit
Bram Moolenaar <Bram@vim.org>
parents:
21493
diff
changeset
|
6117 if (not_in_vim9(eap) == FAIL) |
c7b2ce90c2de
patch 8.2.1308: Vim9: accidentally using "x" causes Vim to exit
Bram Moolenaar <Bram@vim.org>
parents:
21493
diff
changeset
|
6118 return; |
21518
0b448762ebbd
patch 8.2.1309: build failure with tiny version
Bram Moolenaar <Bram@vim.org>
parents:
21516
diff
changeset
|
6119 #endif |
7 | 6120 #ifdef FEAT_CMDWIN |
6121 if (cmdwin_type != 0) | |
6122 { | |
6123 cmdwin_result = Ctrl_C; | |
6124 return; | |
6125 } | |
6126 #endif | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6127 // Don't quit while editing the command line. |
633 | 6128 if (text_locked()) |
6129 { | |
6130 text_locked_msg(); | |
631 | 6131 return; |
6132 } | |
13442
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
6133 |
7 | 6134 /* |
24723
5194fba32954
patch 8.2.2900: QuitPre is triggered before :wq writes the file
Bram Moolenaar <Bram@vim.org>
parents:
24719
diff
changeset
|
6135 * we plan to exit if there is only one relevant window |
7 | 6136 */ |
6137 if (check_more(FALSE, eap->forceit) == OK && only_one_window()) | |
6138 exiting = TRUE; | |
24723
5194fba32954
patch 8.2.2900: QuitPre is triggered before :wq writes the file
Bram Moolenaar <Bram@vim.org>
parents:
24719
diff
changeset
|
6139 |
5194fba32954
patch 8.2.2900: QuitPre is triggered before :wq writes the file
Bram Moolenaar <Bram@vim.org>
parents:
24719
diff
changeset
|
6140 // Write the buffer for ":wq" or when it was changed. |
5194fba32954
patch 8.2.2900: QuitPre is triggered before :wq writes the file
Bram Moolenaar <Bram@vim.org>
parents:
24719
diff
changeset
|
6141 // Trigger QuitPre and ExitPre. |
5194fba32954
patch 8.2.2900: QuitPre is triggered before :wq writes the file
Bram Moolenaar <Bram@vim.org>
parents:
24719
diff
changeset
|
6142 // Check if we can exit now, after autocommands have changed things. |
5194fba32954
patch 8.2.2900: QuitPre is triggered before :wq writes the file
Bram Moolenaar <Bram@vim.org>
parents:
24719
diff
changeset
|
6143 if (((eap->cmdidx == CMD_wq || curbufIsChanged()) && do_write(eap) == FAIL) |
5194fba32954
patch 8.2.2900: QuitPre is triggered before :wq writes the file
Bram Moolenaar <Bram@vim.org>
parents:
24719
diff
changeset
|
6144 || before_quit_autocmds(curwin, FALSE, eap->forceit) |
7 | 6145 || 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
|
6146 || (only_one_window() && check_changed_any(eap->forceit, FALSE))) |
7 | 6147 { |
6148 not_exiting(); | |
6149 } | |
6150 else | |
6151 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6152 if (only_one_window()) // quit last window, exit Vim |
7 | 6153 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
|
6154 not_exiting(); |
7 | 6155 # ifdef FEAT_GUI |
6156 need_mouse_correct = TRUE; | |
6157 # endif | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6158 // 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
|
6159 win_close(curwin, !buf_hide(curwin->w_buffer)); |
7 | 6160 } |
6161 } | |
6162 | |
6163 /* | |
6164 * ":print", ":list", ":number". | |
6165 */ | |
6166 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6167 ex_print(exarg_T *eap) |
7 | 6168 { |
167 | 6169 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
|
6170 emsg(_(e_emptybuf)); |
167 | 6171 else |
6172 { | |
6173 for ( ;!got_int; ui_breakcheck()) | |
6174 { | |
6175 print_line(eap->line1, | |
6176 (eap->cmdidx == CMD_number || eap->cmdidx == CMD_pound | |
6177 || (eap->flags & EXFLAG_NR)), | |
6178 eap->cmdidx == CMD_list || (eap->flags & EXFLAG_LIST)); | |
6179 if (++eap->line1 > eap->line2) | |
6180 break; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6181 out_flush(); // show one line at a time |
167 | 6182 } |
6183 setpcmark(); | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6184 // put cursor at last line |
167 | 6185 curwin->w_cursor.lnum = eap->line2; |
6186 beginline(BL_SOL | BL_FIX); | |
6187 } | |
7 | 6188 |
6189 ex_no_reprint = TRUE; | |
6190 } | |
6191 | |
6192 #ifdef FEAT_BYTEOFF | |
6193 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6194 ex_goto(exarg_T *eap) |
7 | 6195 { |
6196 goto_byte(eap->line2); | |
6197 } | |
6198 #endif | |
6199 | |
6200 /* | |
6201 * ":shell". | |
6202 */ | |
6203 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6204 ex_shell(exarg_T *eap UNUSED) |
7 | 6205 { |
6206 do_shell(NULL, 0); | |
6207 } | |
6208 | |
14428
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6209 #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
|
6210 |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6211 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
|
6212 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
|
6213 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
|
6214 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
|
6215 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
|
6216 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
|
6217 |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6218 static void |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6219 handle_drop_internal(void) |
7 | 6220 { |
6221 exarg_T ea; | |
6222 int save_msg_scroll = msg_scroll; | |
6223 | |
14428
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6224 // 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
|
6225 // 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
|
6226 drop_busy = TRUE; |
7 | 6227 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6228 // 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
|
6229 // 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
|
6230 // 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
|
6231 // 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
|
6232 if (!buf_hide(curbuf) && !drop_split) |
7 | 6233 { |
6234 ++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
|
6235 drop_split = check_changed(curbuf, CCGD_AW); |
7 | 6236 --emsg_off; |
6237 } | |
14428
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6238 if (drop_split) |
7 | 6239 { |
6240 if (win_split(0, 0) == FAIL) | |
6241 return; | |
2583 | 6242 RESET_BINDING(curwin); |
7 | 6243 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6244 // 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
|
6245 // existing one is overwritten. |
7 | 6246 alist_unlink(curwin->w_alist); |
6247 alist_new(); | |
6248 } | |
6249 | |
6250 /* | |
6251 * Set up the new argument list. | |
6252 */ | |
14428
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6253 alist_set(ALIST(curwin), drop_filec, drop_filev, FALSE, NULL, 0); |
7 | 6254 |
6255 /* | |
6256 * Move to the first file. | |
6257 */ | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6258 // 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
|
6259 CLEAR_FIELD(ea); |
7 | 6260 ea.cmd = (char_u *)"next"; |
6261 do_argfile(&ea, 0); | |
6262 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6263 // 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
|
6264 // mode that is not needed here. |
7 | 6265 need_start_insertmode = FALSE; |
6266 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6267 // 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
|
6268 // 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
|
6269 // msg_scroll being set by displaying a message is irrelevant. |
7 | 6270 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
|
6271 |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6272 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
|
6273 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
|
6274 |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6275 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
|
6276 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
|
6277 } |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6278 |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6279 /* |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6280 * 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
|
6281 * :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
|
6282 * 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
|
6283 * 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
|
6284 * 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
|
6285 * |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6286 * 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
|
6287 * 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
|
6288 * list. |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6289 */ |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6290 void |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6291 handle_drop( |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6292 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
|
6293 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
|
6294 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
|
6295 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
|
6296 // list |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6297 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
|
6298 { |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6299 // 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
|
6300 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
|
6301 { |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6302 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
|
6303 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
|
6304 return; |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6305 } |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6306 |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6307 // 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
|
6308 // one. |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6309 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
|
6310 { |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6311 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
|
6312 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
|
6313 } |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6314 |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6315 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
|
6316 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
|
6317 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
|
6318 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
|
6319 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
|
6320 |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6321 // 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
|
6322 // - 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
|
6323 // - 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
|
6324 // - 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
|
6325 // 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
|
6326 // 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
|
6327 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
|
6328 return; |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6329 |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6330 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
|
6331 } |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6332 |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6333 /* |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6334 * 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
|
6335 * 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
|
6336 */ |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6337 void |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6338 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
|
6339 { |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6340 if (!drop_busy && drop_filev != NULL |
20229
06a1dd50463e
patch 8.2.0670: cannot change window when evaluating 'completefunc'
Bram Moolenaar <Bram@vim.org>
parents:
20185
diff
changeset
|
6341 && !text_locked() && !curbuf_locked() && !updating_screen) |
14428
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6342 handle_drop_internal(); |
7 | 6343 } |
6344 #endif | |
6345 | |
6346 /* | |
6347 * ":preserve". | |
6348 */ | |
6349 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6350 ex_preserve(exarg_T *eap UNUSED) |
7 | 6351 { |
164 | 6352 curbuf->b_flags |= BF_PRESERVED; |
7 | 6353 ml_preserve(curbuf, TRUE); |
6354 } | |
6355 | |
6356 /* | |
6357 * ":recover". | |
6358 */ | |
6359 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6360 ex_recover(exarg_T *eap) |
7 | 6361 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6362 // Set recoverymode right away to avoid the ATTENTION prompt. |
7 | 6363 recoverymode = TRUE; |
5464 | 6364 if (!check_changed(curbuf, (p_awa ? CCGD_AW : 0) |
6365 | CCGD_MULTWIN | |
6366 | (eap->forceit ? CCGD_FORCEIT : 0) | |
6367 | CCGD_EXCMD) | |
6368 | |
7 | 6369 && (*eap->arg == NUL |
6370 || 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
|
6371 ml_recover(TRUE); |
7 | 6372 recoverymode = FALSE; |
6373 } | |
6374 | |
6375 /* | |
6376 * Command modifier used in a wrong way. | |
6377 */ | |
6378 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6379 ex_wrongmodifier(exarg_T *eap) |
7 | 6380 { |
21821
0deb6f96a5a3
patch 8.2.1460: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
21789
diff
changeset
|
6381 eap->errmsg = _(e_invalid_command); |
7 | 6382 } |
6383 | |
6384 /* | |
6385 * :sview [+command] file split window with new file, read-only | |
6386 * :split [[+command] file] split window with current or new file | |
6387 * :vsplit [[+command] file] split window vertically with current or new file | |
6388 * :new [[+command] file] split window with no or new file | |
6389 * :vnew [[+command] file] split vertically window with no or new file | |
6390 * :sfind [+command] file split window with file in 'path' | |
675 | 6391 * |
6392 * :tabedit open new Tab page with empty window | |
6393 * :tabedit [+command] file open new Tab page and edit "file" | |
6394 * :tabnew [[+command] file] just like :tabedit | |
6395 * :tabfind [+command] file open new Tab page and find "file" | |
7 | 6396 */ |
6397 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6398 ex_splitview(exarg_T *eap) |
7 | 6399 { |
675 | 6400 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
|
6401 #if defined(FEAT_SEARCHPATH) || defined(FEAT_BROWSE) |
7 | 6402 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
|
6403 #endif |
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
6404 #ifdef FEAT_BROWSE |
22588
050cff1294ab
patch 8.2.1842: crash when USE_FNAME_CASE is defined and using :browse
Bram Moolenaar <Bram@vim.org>
parents:
22559
diff
changeset
|
6405 char_u dot_path[] = "."; |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
6406 int save_cmod_flags = cmdmod.cmod_flags; |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
6407 #endif |
14155
da09e29e59d9
patch 8.1.0095: dialog for ":browse tabnew" says "new window"
Christian Brabandt <cb@256bit.org>
parents:
14059
diff
changeset
|
6408 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
|
6409 || 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
|
6410 || 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
|
6411 |
19271
ebeeb4b4a1fa
patch 8.2.0194: some commands can cause problems in terminal popup
Bram Moolenaar <Bram@vim.org>
parents:
19261
diff
changeset
|
6412 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
|
6413 return; |
da5f5836e90c
patch 8.1.1438: some commands cause trouble in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
6414 |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
6415 #ifdef FEAT_GUI |
7 | 6416 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
|
6417 #endif |
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
6418 |
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
6419 #ifdef FEAT_QUICKFIX |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6420 // 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
|
6421 // quickfix windows. But it's OK when doing ":tab split". |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
6422 if (bt_quickfix(curbuf) && cmdmod.cmod_tab == 0) |
7 | 6423 { |
6424 if (eap->cmdidx == CMD_split) | |
6425 eap->cmdidx = CMD_new; | |
6426 if (eap->cmdidx == CMD_vsplit) | |
6427 eap->cmdidx = CMD_vnew; | |
667 | 6428 } |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
6429 #endif |
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
6430 |
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
6431 #ifdef FEAT_SEARCHPATH |
675 | 6432 if (eap->cmdidx == CMD_sfind || eap->cmdidx == CMD_tabfind) |
7 | 6433 { |
6434 fname = find_file_in_path(eap->arg, (int)STRLEN(eap->arg), | |
6435 FNAME_MESS, TRUE, curbuf->b_ffname); | |
6436 if (fname == NULL) | |
6437 goto theend; | |
6438 eap->arg = fname; | |
6439 } | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
6440 # ifdef FEAT_BROWSE |
7 | 6441 else |
6442 # endif | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
6443 #endif |
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
6444 #ifdef FEAT_BROWSE |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
6445 if ((cmdmod.cmod_flags & CMOD_BROWSE) |
7 | 6446 && eap->cmdidx != CMD_vnew |
6447 && eap->cmdidx != CMD_new) | |
6448 { | |
461 | 6449 if ( |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
6450 # ifdef FEAT_GUI |
461 | 6451 !gui.in_use && |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
6452 # endif |
461 | 6453 au_has_group((char_u *)"FileExplorer")) |
6454 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6455 // 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
|
6456 // Edit the directory. |
461 | 6457 if (*eap->arg == NUL || !mch_isdir(eap->arg)) |
22588
050cff1294ab
patch 8.2.1842: crash when USE_FNAME_CASE is defined and using :browse
Bram Moolenaar <Bram@vim.org>
parents:
22559
diff
changeset
|
6458 eap->arg = dot_path; |
461 | 6459 } |
6460 else | |
6461 { | |
14155
da09e29e59d9
patch 8.1.0095: dialog for ":browse tabnew" says "new window"
Christian Brabandt <cb@256bit.org>
parents:
14059
diff
changeset
|
6462 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
|
6463 ? _("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
|
6464 : _("Edit File in new window")), |
7 | 6465 eap->arg, NULL, NULL, NULL, curbuf); |
461 | 6466 if (fname == NULL) |
6467 goto theend; | |
6468 eap->arg = fname; | |
6469 } | |
7 | 6470 } |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
6471 cmdmod.cmod_flags &= ~CMOD_BROWSE; // 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
|
6472 #endif |
7 | 6473 |
675 | 6474 /* |
6475 * Either open new tab page or split the window. | |
6476 */ | |
14155
da09e29e59d9
patch 8.1.0095: dialog for ":browse tabnew" says "new window"
Christian Brabandt <cb@256bit.org>
parents:
14059
diff
changeset
|
6477 if (use_tab) |
675 | 6478 { |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
6479 if (win_new_tabpage(cmdmod.cmod_tab != 0 ? cmdmod.cmod_tab |
820 | 6480 : eap->addr_count == 0 ? 0 |
6481 : (int)eap->line2 + 1) != FAIL) | |
675 | 6482 { |
1498 | 6483 do_exedit(eap, old_curwin); |
675 | 6484 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6485 // set the alternate buffer for the window we came from |
675 | 6486 if (curwin != old_curwin |
6487 && win_valid(old_curwin) | |
6488 && old_curwin->w_buffer != curbuf | |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
6489 && (cmdmod.cmod_flags & CMOD_KEEPALT) == 0) |
675 | 6490 old_curwin->w_alt_fnum = curbuf->b_fnum; |
6491 } | |
6492 } | |
6493 else if (win_split(eap->addr_count > 0 ? (int)eap->line2 : 0, | |
7 | 6494 *eap->cmd == 'v' ? WSP_VERT : 0) != FAIL) |
6495 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6496 // 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
|
6497 // doing ":split" without arguments. |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
6498 if (*eap->arg != NUL) |
2583 | 6499 RESET_BINDING(curwin); |
7 | 6500 else |
6501 do_check_scrollbind(FALSE); | |
6502 do_exedit(eap, old_curwin); | |
6503 } | |
6504 | |
667 | 6505 # ifdef FEAT_BROWSE |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
6506 cmdmod.cmod_flags = save_cmod_flags; |
667 | 6507 # endif |
6508 | |
6509 # if defined(FEAT_SEARCHPATH) || defined(FEAT_BROWSE) | |
7 | 6510 theend: |
6511 vim_free(fname); | |
667 | 6512 # endif |
6513 } | |
6514 | |
6515 /* | |
682 | 6516 * Open a new tab page. |
667 | 6517 */ |
6518 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6519 tabpage_new(void) |
682 | 6520 { |
6521 exarg_T ea; | |
6522 | |
20007
aadd1cae2ff5
patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
6523 CLEAR_FIELD(ea); |
682 | 6524 ea.cmdidx = CMD_tabnew; |
6525 ea.cmd = (char_u *)"tabn"; | |
6526 ea.arg = (char_u *)""; | |
6527 ex_splitview(&ea); | |
6528 } | |
6529 | |
6530 /* | |
6531 * :tabnext command | |
6532 */ | |
6533 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6534 ex_tabnext(exarg_T *eap) |
682 | 6535 { |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6536 int tab_number; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6537 |
17111
af861fccc309
patch 8.1.1555: NOT_IN_POPUP_WINDOW is confusing
Bram Moolenaar <Bram@vim.org>
parents:
17095
diff
changeset
|
6538 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
|
6539 return; |
685 | 6540 switch (eap->cmdidx) |
6541 { | |
6542 case CMD_tabfirst: | |
6543 case CMD_tabrewind: | |
6544 goto_tabpage(1); | |
6545 break; | |
6546 case CMD_tablast: | |
6547 goto_tabpage(9999); | |
6548 break; | |
6549 case CMD_tabprevious: | |
6550 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
|
6551 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
|
6552 { |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6553 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
|
6554 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
|
6555 |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6556 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
|
6557 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
|
6558 || tab_number == 0) |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6559 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6560 // No numbers as argument. |
21459
a422bd80b434
patch 8.2.1280: Ex command error cannot contain an argument
Bram Moolenaar <Bram@vim.org>
parents:
21413
diff
changeset
|
6561 eap->errmsg = ex_errmsg(e_invarg2, eap->arg); |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6562 return; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6563 } |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6564 } |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6565 else |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6566 { |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6567 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
|
6568 tab_number = 1; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6569 else |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6570 { |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6571 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
|
6572 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
|
6573 { |
25064
8f2262c72178
patch 8.2.3069: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
24984
diff
changeset
|
6574 eap->errmsg = _(e_invalid_range); |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6575 return; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6576 } |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6577 } |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6578 } |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6579 goto_tabpage(-tab_number); |
685 | 6580 break; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6581 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
|
6582 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
|
6583 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
|
6584 goto_tabpage(tab_number); |
685 | 6585 break; |
6586 } | |
682 | 6587 } |
6588 | |
6589 /* | |
6590 * :tabmove command | |
6591 */ | |
6592 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6593 ex_tabmove(exarg_T *eap) |
682 | 6594 { |
6775 | 6595 int tab_number; |
3662 | 6596 |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6597 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
|
6598 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
|
6599 tabpage_move(tab_number); |
667 | 6600 } |
6601 | |
6602 /* | |
6603 * :tabs command: List tabs and their contents. | |
6604 */ | |
6605 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6606 ex_tabs(exarg_T *eap UNUSED) |
667 | 6607 { |
6608 tabpage_T *tp; | |
6609 win_T *wp; | |
6610 int tabcount = 1; | |
6611 | |
6612 msg_start(); | |
6613 msg_scroll = TRUE; | |
6614 for (tp = first_tabpage; tp != NULL && !got_int; tp = tp->tp_next) | |
6615 { | |
6616 msg_putchar('\n'); | |
6617 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
|
6618 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
|
6619 out_flush(); // output one line at a time |
667 | 6620 ui_breakcheck(); |
6621 | |
678 | 6622 if (tp == curtab) |
667 | 6623 wp = firstwin; |
6624 else | |
6625 wp = tp->tp_firstwin; | |
6626 for ( ; wp != NULL && !got_int; wp = wp->w_next) | |
6627 { | |
682 | 6628 msg_putchar('\n'); |
6629 msg_putchar(wp == curwin ? '>' : ' '); | |
6630 msg_putchar(' '); | |
672 | 6631 msg_putchar(bufIsChanged(wp->w_buffer) ? '+' : ' '); |
6632 msg_putchar(' '); | |
667 | 6633 if (buf_spname(wp->w_buffer) != NULL) |
3839 | 6634 vim_strncpy(IObuff, buf_spname(wp->w_buffer), IOSIZE - 1); |
667 | 6635 else |
6636 home_replace(wp->w_buffer, wp->w_buffer->b_fname, | |
6637 IObuff, IOSIZE, TRUE); | |
6638 msg_outtrans(IObuff); | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6639 out_flush(); // output one line at a time |
667 | 6640 ui_breakcheck(); |
6641 } | |
6642 } | |
6643 } | |
6644 | |
7 | 6645 /* |
6646 * ":mode": Set screen mode. | |
6647 * If no argument given, just get the screen size and redraw. | |
6648 */ | |
6649 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6650 ex_mode(exarg_T *eap) |
7 | 6651 { |
6652 if (*eap->arg == NUL) | |
6653 shell_resized(); | |
6654 else | |
19131
1fe99999625c
patch 8.2.0125: :mode no longer works for any system
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
6655 emsg(_(e_screenmode)); |
7 | 6656 } |
6657 | |
6658 /* | |
6659 * ":resize". | |
6660 * set, increment or decrement current window height | |
6661 */ | |
6662 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6663 ex_resize(exarg_T *eap) |
7 | 6664 { |
6665 int n; | |
6666 win_T *wp = curwin; | |
6667 | |
6668 if (eap->addr_count > 0) | |
6669 { | |
6670 n = eap->line2; | |
6671 for (wp = firstwin; wp->w_next != NULL && --n > 0; wp = wp->w_next) | |
6672 ; | |
6673 } | |
6674 | |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8577
diff
changeset
|
6675 # ifdef FEAT_GUI |
7 | 6676 need_mouse_correct = TRUE; |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8577
diff
changeset
|
6677 # endif |
7 | 6678 n = atol((char *)eap->arg); |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
6679 if (cmdmod.cmod_split & WSP_VERT) |
7 | 6680 { |
6681 if (*eap->arg == '-' || *eap->arg == '+') | |
22616
f773ac13c093
patch 8.2.1856: "2resize" uses size of current window
Bram Moolenaar <Bram@vim.org>
parents:
22610
diff
changeset
|
6682 n += wp->w_width; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6683 else if (n == 0 && eap->arg[0] == NUL) // default is very wide |
7 | 6684 n = 9999; |
6685 win_setwidth_win((int)n, wp); | |
6686 } | |
6687 else | |
6688 { | |
6689 if (*eap->arg == '-' || *eap->arg == '+') | |
22616
f773ac13c093
patch 8.2.1856: "2resize" uses size of current window
Bram Moolenaar <Bram@vim.org>
parents:
22610
diff
changeset
|
6690 n += wp->w_height; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6691 else if (n == 0 && eap->arg[0] == NUL) // default is very high |
7 | 6692 n = 9999; |
6693 win_setheight_win((int)n, wp); | |
6694 } | |
6695 } | |
6696 | |
6697 /* | |
6698 * ":find [+command] <file>" command. | |
6699 */ | |
6700 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6701 ex_find(exarg_T *eap) |
7 | 6702 { |
6703 #ifdef FEAT_SEARCHPATH | |
6704 char_u *fname; | |
6705 int count; | |
6706 | |
6707 fname = find_file_in_path(eap->arg, (int)STRLEN(eap->arg), FNAME_MESS, | |
6708 TRUE, curbuf->b_ffname); | |
6709 if (eap->addr_count > 0) | |
6710 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6711 // 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
|
6712 // appears several times in the path. |
7 | 6713 count = eap->line2; |
6714 while (fname != NULL && --count > 0) | |
6715 { | |
6716 vim_free(fname); | |
6717 fname = find_file_in_path(NULL, 0, FNAME_MESS, | |
6718 FALSE, curbuf->b_ffname); | |
6719 } | |
6720 } | |
6721 | |
6722 if (fname != NULL) | |
6723 { | |
6724 eap->arg = fname; | |
6725 #endif | |
6726 do_exedit(eap, NULL); | |
6727 #ifdef FEAT_SEARCHPATH | |
6728 vim_free(fname); | |
6729 } | |
6730 #endif | |
6731 } | |
6732 | |
6733 /* | |
167 | 6734 * ":open" simulation: for now just work like ":visual". |
6735 */ | |
6736 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6737 ex_open(exarg_T *eap) |
167 | 6738 { |
6739 regmatch_T regmatch; | |
6740 char_u *p; | |
6741 | |
24114
291c57cf4731
patch 8.2.2598: Vim9: :open does not need to be supported
Bram Moolenaar <Bram@vim.org>
parents:
24049
diff
changeset
|
6742 #ifdef FEAT_EVAL |
291c57cf4731
patch 8.2.2598: Vim9: :open does not need to be supported
Bram Moolenaar <Bram@vim.org>
parents:
24049
diff
changeset
|
6743 if (not_in_vim9(eap) == FAIL) |
291c57cf4731
patch 8.2.2598: Vim9: :open does not need to be supported
Bram Moolenaar <Bram@vim.org>
parents:
24049
diff
changeset
|
6744 return; |
291c57cf4731
patch 8.2.2598: Vim9: :open does not need to be supported
Bram Moolenaar <Bram@vim.org>
parents:
24049
diff
changeset
|
6745 #endif |
167 | 6746 curwin->w_cursor.lnum = eap->line2; |
6747 beginline(BL_SOL | BL_FIX); | |
6748 if (*eap->arg == '/') | |
6749 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6750 // ":open /pattern/": put cursor in column found with pattern |
167 | 6751 ++eap->arg; |
23272
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
23239
diff
changeset
|
6752 p = skip_regexp(eap->arg, '/', magic_isset()); |
167 | 6753 *p = NUL; |
23272
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
23239
diff
changeset
|
6754 regmatch.regprog = vim_regcomp(eap->arg, magic_isset() ? RE_MAGIC : 0); |
167 | 6755 if (regmatch.regprog != NULL) |
6756 { | |
6757 regmatch.rm_ic = p_ic; | |
6758 p = ml_get_curline(); | |
6759 if (vim_regexec(®match, p, (colnr_T)0)) | |
835 | 6760 curwin->w_cursor.col = (colnr_T)(regmatch.startp[0] - p); |
167 | 6761 else |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
6762 emsg(_(e_nomatch)); |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4803
diff
changeset
|
6763 vim_regfree(regmatch.regprog); |
167 | 6764 } |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6765 // Move to the NUL, ignore any other arguments. |
167 | 6766 eap->arg += STRLEN(eap->arg); |
6767 } | |
6768 check_cursor(); | |
6769 | |
6770 eap->cmdidx = CMD_visual; | |
6771 do_exedit(eap, NULL); | |
6772 } | |
6773 | |
6774 /* | |
22840
7c1e2e3f2d8d
patch 8.2.1967: the session file does not restore the alternate file
Bram Moolenaar <Bram@vim.org>
parents:
22790
diff
changeset
|
6775 * ":edit", ":badd", ":balt", ":visual". |
7 | 6776 */ |
6777 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6778 ex_edit(exarg_T *eap) |
7 | 6779 { |
6780 do_exedit(eap, NULL); | |
6781 } | |
6782 | |
6783 /* | |
19195
2ef19eed524a
patch 8.2.0156: various typos in source files and tests
Bram Moolenaar <Bram@vim.org>
parents:
19191
diff
changeset
|
6784 * ":edit <file>" command and alike. |
7 | 6785 */ |
6786 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6787 do_exedit( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6788 exarg_T *eap, |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6789 win_T *old_curwin) // curwin before doing a split or NULL |
7 | 6790 { |
6791 int n; | |
6792 int need_hide; | |
167 | 6793 int exmode_was = exmode_active; |
7 | 6794 |
19271
ebeeb4b4a1fa
patch 8.2.0194: some commands can cause problems in terminal popup
Bram Moolenaar <Bram@vim.org>
parents:
19261
diff
changeset
|
6795 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
|
6796 || 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
|
6797 return; |
7 | 6798 /* |
6799 * ":vi" command ends Ex mode. | |
6800 */ | |
6801 if (exmode_active && (eap->cmdidx == CMD_visual | |
6802 || eap->cmdidx == CMD_view)) | |
6803 { | |
6804 exmode_active = FALSE; | |
20897
213fb059e02e
patch 8.2.1000: get error when leaving Ex mode with :visual
Bram Moolenaar <Bram@vim.org>
parents:
20711
diff
changeset
|
6805 ex_pressedreturn = FALSE; |
7 | 6806 if (*eap->arg == NUL) |
167 | 6807 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6808 // Special case: ":global/pat/visual\NLvi-commands" |
167 | 6809 if (global_busy) |
6810 { | |
6811 int rd = RedrawingDisabled; | |
6812 int nwr = no_wait_return; | |
6813 int ms = msg_scroll; | |
6814 #ifdef FEAT_GUI | |
6815 int he = hold_gui_events; | |
6816 #endif | |
6817 | |
6818 if (eap->nextcmd != NULL) | |
6819 { | |
6820 stuffReadbuff(eap->nextcmd); | |
6821 eap->nextcmd = NULL; | |
6822 } | |
6823 | |
6824 if (exmode_was != EXMODE_VIM) | |
6825 settmode(TMODE_RAW); | |
6826 RedrawingDisabled = 0; | |
6827 no_wait_return = 0; | |
6828 need_wait_return = FALSE; | |
6829 msg_scroll = 0; | |
6830 #ifdef FEAT_GUI | |
6831 hold_gui_events = 0; | |
6832 #endif | |
6833 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
|
6834 pending_exmode_active = TRUE; |
167 | 6835 |
6836 main_loop(FALSE, TRUE); | |
6837 | |
19433
af9d5585cfbf
patch 8.2.0274: hang with combination of feedkeys(), Ex mode and :global
Bram Moolenaar <Bram@vim.org>
parents:
19415
diff
changeset
|
6838 pending_exmode_active = FALSE; |
167 | 6839 RedrawingDisabled = rd; |
6840 no_wait_return = nwr; | |
6841 msg_scroll = ms; | |
6842 #ifdef FEAT_GUI | |
6843 hold_gui_events = he; | |
6844 #endif | |
6845 } | |
7 | 6846 return; |
167 | 6847 } |
7 | 6848 } |
6849 | |
6850 if ((eap->cmdidx == CMD_new | |
675 | 6851 || eap->cmdidx == CMD_tabnew |
6852 || 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
|
6853 || eap->cmdidx == CMD_vnew) && *eap->arg == NUL) |
7 | 6854 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6855 // ":new" or ":tabnew" without argument: edit an new empty buffer |
7 | 6856 setpcmark(); |
6857 (void)do_ecmd(0, NULL, NULL, eap, ECMD_ONE, | |
1743 | 6858 ECMD_HIDE + (eap->forceit ? ECMD_FORCEIT : 0), |
6859 old_curwin == NULL ? curwin : NULL); | |
7 | 6860 } |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
6861 else if ((eap->cmdidx != CMD_split && eap->cmdidx != CMD_vsplit) |
7 | 6862 || *eap->arg != NUL |
6863 #ifdef FEAT_BROWSE | |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
6864 || (cmdmod.cmod_flags & CMOD_BROWSE) |
7 | 6865 #endif |
6866 ) | |
6867 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6868 // 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
|
6869 // can bring us here, others are stopped earlier. |
822 | 6870 if (*eap->arg != NUL && curbuf_locked()) |
6871 return; | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
6872 |
7 | 6873 n = readonlymode; |
6874 if (eap->cmdidx == CMD_view || eap->cmdidx == CMD_sview) | |
6875 readonlymode = TRUE; | |
6876 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
|
6877 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
|
6878 // empty buffer |
23023
4384c44c031a
patch 8.2.2058: using mkview/loadview changes the jumplist
Bram Moolenaar <Bram@vim.org>
parents:
23011
diff
changeset
|
6879 if (eap->cmdidx != CMD_balt && eap->cmdidx != CMD_badd) |
4384c44c031a
patch 8.2.2058: using mkview/loadview changes the jumplist
Bram Moolenaar <Bram@vim.org>
parents:
23011
diff
changeset
|
6880 setpcmark(); |
7 | 6881 if (do_ecmd(0, (eap->cmdidx == CMD_enew ? NULL : eap->arg), |
6882 NULL, eap, | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6883 // ":edit" goes to first line if Vi compatible |
7 | 6884 (*eap->arg == NUL && eap->do_ecmd_lnum == 0 |
6885 && vim_strchr(p_cpo, CPO_GOTO1) != NULL) | |
6886 ? 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
|
6887 (buf_hide(curbuf) ? ECMD_HIDE : 0) |
7 | 6888 + (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
|
6889 // after a split we can use an existing buffer |
5741 | 6890 + (old_curwin != NULL ? ECMD_OLDBUF : 0) |
22840
7c1e2e3f2d8d
patch 8.2.1967: the session file does not restore the alternate file
Bram Moolenaar <Bram@vim.org>
parents:
22790
diff
changeset
|
6891 + (eap->cmdidx == CMD_badd ? ECMD_ADDBUF : 0) |
7c1e2e3f2d8d
patch 8.2.1967: the session file does not restore the alternate file
Bram Moolenaar <Bram@vim.org>
parents:
22790
diff
changeset
|
6892 + (eap->cmdidx == CMD_balt ? ECMD_ALTBUF : 0) |
1743 | 6893 , old_curwin == NULL ? curwin : NULL) == FAIL) |
7 | 6894 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6895 // Editing the file failed. If the window was split, close it. |
7 | 6896 if (old_curwin != NULL) |
6897 { | |
6898 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
|
6899 if (!need_hide || buf_hide(curbuf)) |
7 | 6900 { |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
6901 #if defined(FEAT_EVAL) |
24 | 6902 cleanup_T cs; |
6903 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6904 // 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
|
6905 // aborting() returns FALSE when closing a window. |
24 | 6906 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
|
6907 #endif |
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
6908 #ifdef FEAT_GUI |
7 | 6909 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
|
6910 #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
|
6911 win_close(curwin, !need_hide && !buf_hide(curbuf)); |
24 | 6912 |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
6913 #if defined(FEAT_EVAL) |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6914 // 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
|
6915 // 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
|
6916 // uncaught exception. |
24 | 6917 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
|
6918 #endif |
7 | 6919 } |
6920 } | |
6921 } | |
6922 else if (readonlymode && curbuf->b_nwindows == 1) | |
6923 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6924 // 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
|
6925 // 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
|
6926 // 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
|
6927 // editing the same buffer. |
7 | 6928 curbuf->b_p_ro = TRUE; |
6929 } | |
6930 readonlymode = n; | |
6931 } | |
6932 else | |
6933 { | |
6934 if (eap->do_ecmd_cmd != NULL) | |
23011
ec23d84a096d
patch 8.2.2052: Vim9: "edit +4 fname" gives an error
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
6935 do_cmd_argument(eap->do_ecmd_cmd); |
7 | 6936 #ifdef FEAT_TITLE |
6937 n = curwin->w_arg_idx_invalid; | |
6938 #endif | |
6939 check_arg_idx(curwin); | |
6940 #ifdef FEAT_TITLE | |
6941 if (n != curwin->w_arg_idx_invalid) | |
6942 maketitle(); | |
6943 #endif | |
6944 } | |
6945 | |
6946 /* | |
6947 * if ":split file" worked, set alternate file name in old window to new | |
6948 * file | |
6949 */ | |
6950 if (old_curwin != NULL | |
6951 && *eap->arg != NUL | |
6952 && curwin != old_curwin | |
6953 && win_valid(old_curwin) | |
22 | 6954 && old_curwin->w_buffer != curbuf |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
6955 && (cmdmod.cmod_flags & CMOD_KEEPALT) == 0) |
7 | 6956 old_curwin->w_alt_fnum = curbuf->b_fnum; |
6957 | |
6958 ex_no_reprint = TRUE; | |
6959 } | |
6960 | |
6961 #ifndef FEAT_GUI | |
6962 /* | |
6963 * ":gui" and ":gvim" when there is no GUI. | |
6964 */ | |
6965 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6966 ex_nogui(exarg_T *eap) |
7 | 6967 { |
25306
078edc1821bf
patch 8.2.3190: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
25304
diff
changeset
|
6968 eap->errmsg = _(e_gui_cannot_be_used_not_enabled_at_compile_time); |
7 | 6969 } |
6970 #endif | |
6971 | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15866
diff
changeset
|
6972 #if defined(FEAT_GUI_MSWIN) && defined(FEAT_MENU) && defined(FEAT_TEAROFF) |
7 | 6973 static void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6974 ex_tearoff(exarg_T *eap) |
7 | 6975 { |
6976 gui_make_tearoff(eap->arg); | |
6977 } | |
6978 #endif | |
6979 | |
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
|
6980 #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
|
6981 || defined(FEAT_TERM_POPUP_MENU)) && defined(FEAT_MENU) |
7 | 6982 static void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6983 ex_popup(exarg_T *eap) |
7 | 6984 { |
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
|
6985 # 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
|
6986 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
|
6987 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
|
6988 # 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
|
6989 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
|
6990 # 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
|
6991 # 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
|
6992 # 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
|
6993 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
|
6994 # endif |
7 | 6995 } |
6996 #endif | |
6997 | |
6998 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6999 ex_swapname(exarg_T *eap UNUSED) |
7 | 7000 { |
7001 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
|
7002 msg(_("No swap file")); |
7 | 7003 else |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15510
diff
changeset
|
7004 msg((char *)curbuf->b_ml.ml_mfp->mf_fname); |
7 | 7005 } |
7006 | |
7007 /* | |
7008 * ":syncbind" forces all 'scrollbind' windows to have the same relative | |
7009 * offset. | |
7010 * (1998-11-02 16:21:01 R. Edward Ralston <eralston@computer.org>) | |
7011 */ | |
7012 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7013 ex_syncbind(exarg_T *eap UNUSED) |
7 | 7014 { |
7015 win_T *wp; | |
5566 | 7016 win_T *save_curwin = curwin; |
7017 buf_T *save_curbuf = curbuf; | |
7 | 7018 long topline; |
7019 long y; | |
7020 linenr_T old_linenr = curwin->w_cursor.lnum; | |
7021 | |
7022 setpcmark(); | |
7023 | |
7024 /* | |
7025 * determine max topline | |
7026 */ | |
7027 if (curwin->w_p_scb) | |
7028 { | |
7029 topline = curwin->w_topline; | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9538
diff
changeset
|
7030 FOR_ALL_WINDOWS(wp) |
7 | 7031 { |
7032 if (wp->w_p_scb && wp->w_buffer) | |
7033 { | |
15713
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15663
diff
changeset
|
7034 y = wp->w_buffer->b_ml.ml_line_count - get_scrolloff_value(); |
7 | 7035 if (topline > y) |
7036 topline = y; | |
7037 } | |
7038 } | |
7039 if (topline < 1) | |
7040 topline = 1; | |
7041 } | |
7042 else | |
7043 { | |
7044 topline = 1; | |
7045 } | |
7046 | |
7047 | |
7048 /* | |
5566 | 7049 * Set all scrollbind windows to the same topline. |
7 | 7050 */ |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9538
diff
changeset
|
7051 FOR_ALL_WINDOWS(curwin) |
7 | 7052 { |
7053 if (curwin->w_p_scb) | |
7054 { | |
5566 | 7055 curbuf = curwin->w_buffer; |
7 | 7056 y = topline - curwin->w_topline; |
7057 if (y > 0) | |
7058 scrollup(y, TRUE); | |
7059 else | |
7060 scrolldown(-y, TRUE); | |
7061 curwin->w_scbind_pos = topline; | |
7062 redraw_later(VALID); | |
7063 cursor_correct(); | |
7064 curwin->w_redr_status = TRUE; | |
7065 } | |
7066 } | |
5566 | 7067 curwin = save_curwin; |
7068 curbuf = save_curbuf; | |
7 | 7069 if (curwin->w_p_scb) |
7070 { | |
7071 did_syncbind = TRUE; | |
7072 checkpcmark(); | |
7073 if (old_linenr != curwin->w_cursor.lnum) | |
7074 { | |
7075 char_u ctrl_o[2]; | |
7076 | |
7077 ctrl_o[0] = Ctrl_O; | |
7078 ctrl_o[1] = 0; | |
7079 ins_typebuf(ctrl_o, REMAP_NONE, 0, TRUE, FALSE); | |
7080 } | |
7081 } | |
7082 } | |
7083 | |
7084 | |
7085 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7086 ex_read(exarg_T *eap) |
7 | 7087 { |
167 | 7088 int i; |
7089 int empty = (curbuf->b_ml.ml_flags & ML_EMPTY); | |
7090 linenr_T lnum; | |
7 | 7091 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7092 if (eap->usefilter) // :r!cmd |
7 | 7093 do_bang(1, eap, FALSE, FALSE, TRUE); |
7094 else | |
7095 { | |
7096 if (u_save(eap->line2, (linenr_T)(eap->line2 + 1)) == FAIL) | |
7097 return; | |
7098 | |
7099 #ifdef FEAT_BROWSE | |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
7100 if (cmdmod.cmod_flags & CMOD_BROWSE) |
7 | 7101 { |
7102 char_u *browseFile; | |
7103 | |
28 | 7104 browseFile = do_browse(0, (char_u *)_("Append File"), eap->arg, |
7 | 7105 NULL, NULL, NULL, curbuf); |
7106 if (browseFile != NULL) | |
7107 { | |
7108 i = readfile(browseFile, NULL, | |
7109 eap->line2, (linenr_T)0, (linenr_T)MAXLNUM, eap, 0); | |
7110 vim_free(browseFile); | |
7111 } | |
7112 else | |
7113 i = OK; | |
7114 } | |
7115 else | |
7116 #endif | |
7117 if (*eap->arg == NUL) | |
7118 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7119 if (check_fname() == FAIL) // check for no file name |
7 | 7120 return; |
7121 i = readfile(curbuf->b_ffname, curbuf->b_fname, | |
7122 eap->line2, (linenr_T)0, (linenr_T)MAXLNUM, eap, 0); | |
7123 } | |
7124 else | |
7125 { | |
7126 if (vim_strchr(p_cpo, CPO_ALTREAD) != NULL) | |
7127 (void)setaltfname(eap->arg, eap->arg, (linenr_T)1); | |
7128 i = readfile(eap->arg, NULL, | |
7129 eap->line2, (linenr_T)0, (linenr_T)MAXLNUM, eap, 0); | |
7130 | |
7131 } | |
10575
01a5f64a7a20
patch 8.0.0177: BufEnter autocommand not fired for a directory
Christian Brabandt <cb@256bit.org>
parents:
10520
diff
changeset
|
7132 if (i != OK) |
7 | 7133 { |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
7134 #if defined(FEAT_EVAL) |
7 | 7135 if (!aborting()) |
7136 #endif | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7137 semsg(_(e_notopen), eap->arg); |
7 | 7138 } |
7139 else | |
167 | 7140 { |
7141 if (empty && exmode_active) | |
7142 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7143 // 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
|
7144 // this but vi doesn't. |
167 | 7145 if (eap->line2 == 0) |
7146 lnum = curbuf->b_ml.ml_line_count; | |
7147 else | |
7148 lnum = 1; | |
573 | 7149 if (*ml_get(lnum) == NUL && u_savedel(lnum, 1L) == OK) |
167 | 7150 { |
20599
d571231175b4
patch 8.2.0853: ml_delete() often called with FALSE argument
Bram Moolenaar <Bram@vim.org>
parents:
20575
diff
changeset
|
7151 ml_delete(lnum); |
573 | 7152 if (curwin->w_cursor.lnum > 1 |
7153 && curwin->w_cursor.lnum >= lnum) | |
167 | 7154 --curwin->w_cursor.lnum; |
1929 | 7155 deleted_lines_mark(lnum, 1L); |
167 | 7156 } |
7157 } | |
7 | 7158 redraw_curbuf_later(VALID); |
167 | 7159 } |
7 | 7160 } |
7161 } | |
7162 | |
358 | 7163 static char_u *prev_dir = NULL; |
7164 | |
7165 #if defined(EXITFREE) || defined(PROTO) | |
7166 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7167 free_cd_dir(void) |
358 | 7168 { |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13221
diff
changeset
|
7169 VIM_CLEAR(prev_dir); |
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13221
diff
changeset
|
7170 VIM_CLEAR(globaldir); |
358 | 7171 } |
7172 #endif | |
7173 | |
4704
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
7174 /* |
20711
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
7175 * Get the previous directory for the given chdir scope. |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
7176 */ |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
7177 static char_u * |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
7178 get_prevdir(cdscope_T scope) |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
7179 { |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
7180 if (scope == CDSCOPE_WINDOW) |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
7181 return curwin->w_prevdir; |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
7182 else if (scope == CDSCOPE_TABPAGE) |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
7183 return curtab->tp_prevdir; |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
7184 return prev_dir; |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
7185 } |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
7186 |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
7187 /* |
4704
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
7188 * 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
|
7189 * 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
|
7190 * 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
|
7191 */ |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
7192 void |
16576
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7193 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
|
7194 { |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7195 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
|
7196 // 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
|
7197 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
|
7198 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
|
7199 if (scope != CDSCOPE_GLOBAL) |
4704
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
7200 { |
20711
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
7201 char_u *pdir = get_prevdir(scope); |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
7202 |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
7203 // If still in the global directory, need to remember current |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
7204 // directory as the global directory. |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
7205 if (globaldir == NULL && pdir != NULL) |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
7206 globaldir = vim_strsave(pdir); |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
7207 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7208 // Remember this local directory for the window. |
4704
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
7209 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
|
7210 { |
16576
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7211 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
|
7212 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
|
7213 else |
8c3a1bd270bb
patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents:
16411
diff
changeset
|
7214 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
|
7215 } |
4704
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
7216 } |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
7217 else |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
7218 { |
20711
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
7219 // We are now in the global directory, no need to remember its name. |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13221
diff
changeset
|
7220 VIM_CLEAR(globaldir); |
4704
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
7221 } |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
7222 |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
7223 shorten_fnames(TRUE); |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
7224 } |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
7225 |
16576
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7226 /* |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7227 * Change directory function used by :cd/:tcd/:lcd Ex commands and the |
20645
b60bb094af52
patch 8.2.0876: :pwd does not give a hint about the scope of the directory
Bram Moolenaar <Bram@vim.org>
parents:
20599
diff
changeset
|
7228 * chdir() function. |
b60bb094af52
patch 8.2.0876: :pwd does not give a hint about the scope of the directory
Bram Moolenaar <Bram@vim.org>
parents:
20599
diff
changeset
|
7229 * scope == CDSCOPE_WINDOW: changes the window-local directory |
b60bb094af52
patch 8.2.0876: :pwd does not give a hint about the scope of the directory
Bram Moolenaar <Bram@vim.org>
parents:
20599
diff
changeset
|
7230 * scope == CDSCOPE_TABPAGE: changes the tab-local directory |
b60bb094af52
patch 8.2.0876: :pwd does not give a hint about the scope of the directory
Bram Moolenaar <Bram@vim.org>
parents:
20599
diff
changeset
|
7231 * Otherwise: changes the global directory |
16576
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7232 * 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
|
7233 */ |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7234 int |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7235 changedir_func( |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7236 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
|
7237 int forceit, |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7238 cdscope_T scope) |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7239 { |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7240 char_u *tofree; |
20711
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
7241 char_u *pdir = NULL; |
16576
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7242 int dir_differs; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7243 int retval = FALSE; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7244 |
19261
a20c66f13a6e
patch 8.2.0189: cd() with NULL argument crashes
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
7245 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
|
7246 return FALSE; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7247 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7248 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
|
7249 { |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7250 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
|
7251 return FALSE; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7252 } |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7253 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7254 // ":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
|
7255 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
|
7256 { |
20711
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
7257 pdir = get_prevdir(scope); |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
7258 if (pdir == NULL) |
16576
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7259 { |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7260 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
|
7261 return FALSE; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7262 } |
20711
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
7263 new_dir = pdir; |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
7264 } |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
7265 |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
7266 // Free the previous directory |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
7267 tofree = get_prevdir(scope); |
16576
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7268 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7269 // 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
|
7270 if (mch_dirname(NameBuff, MAXPATHL) == OK) |
20711
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
7271 pdir = vim_strsave(NameBuff); |
16576
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7272 else |
20711
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
7273 pdir = NULL; |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
7274 if (scope == CDSCOPE_WINDOW) |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
7275 curwin->w_prevdir = pdir; |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
7276 else if (scope == CDSCOPE_TABPAGE) |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
7277 curtab->tp_prevdir = pdir; |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
7278 else |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
7279 prev_dir = pdir; |
16576
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7280 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7281 #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
|
7282 // 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
|
7283 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
|
7284 { |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7285 // 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
|
7286 # ifdef VMS |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7287 char_u *p; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7288 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7289 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
|
7290 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
|
7291 NameBuff[0] = NUL; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7292 else |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7293 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
|
7294 # else |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7295 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
|
7296 # endif |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7297 new_dir = NameBuff; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7298 } |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7299 #endif |
20711
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
7300 dir_differs = new_dir == NULL || pdir == NULL |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
7301 || pathcmp((char *)pdir, (char *)new_dir, -1) != 0; |
16576
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7302 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
|
7303 emsg(_(e_failed)); |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7304 else |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7305 { |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7306 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
|
7307 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7308 post_chdir(scope); |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7309 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7310 if (dir_differs) |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7311 { |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7312 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
|
7313 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
|
7314 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
|
7315 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
|
7316 else |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7317 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
|
7318 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
|
7319 curbuf); |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7320 } |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7321 retval = TRUE; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7322 } |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7323 vim_free(tofree); |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7324 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7325 return retval; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7326 } |
358 | 7327 |
7 | 7328 /* |
16427
8c3a1bd270bb
patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents:
16411
diff
changeset
|
7329 * ":cd", ":tcd", ":lcd", ":chdir" ":tchdir" and ":lchdir". |
7 | 7330 */ |
1411 | 7331 void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7332 ex_cd(exarg_T *eap) |
7 | 7333 { |
15184
90ab2d3ce11d
patch 8.1.0602: DirChanged is also triggered when directory didn't change
Bram Moolenaar <Bram@vim.org>
parents:
15152
diff
changeset
|
7334 char_u *new_dir; |
7 | 7335 |
7336 new_dir = eap->arg; | |
7337 #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
|
7338 // for non-UNIX ":cd" means: print current directory |
7 | 7339 if (*new_dir == NUL) |
7340 ex_pwd(NULL); | |
7341 else | |
7342 #endif | |
7343 { | |
16576
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7344 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
|
7345 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7346 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
|
7347 scope = CDSCOPE_WINDOW; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7348 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
|
7349 scope = CDSCOPE_TABPAGE; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7350 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7351 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
|
7352 { |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7353 // Echo the new current directory if the command was typed. |
1930 | 7354 if (KeyTyped || p_verbose >= 5) |
7 | 7355 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
|
7356 } |
7 | 7357 } |
7358 } | |
7359 | |
7360 /* | |
7361 * ":pwd". | |
7362 */ | |
7363 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7364 ex_pwd(exarg_T *eap UNUSED) |
7 | 7365 { |
7366 if (mch_dirname(NameBuff, MAXPATHL) == OK) | |
7367 { | |
7368 #ifdef BACKSLASH_IN_FILENAME | |
7369 slash_adjust(NameBuff); | |
7370 #endif | |
20645
b60bb094af52
patch 8.2.0876: :pwd does not give a hint about the scope of the directory
Bram Moolenaar <Bram@vim.org>
parents:
20599
diff
changeset
|
7371 if (p_verbose > 0) |
b60bb094af52
patch 8.2.0876: :pwd does not give a hint about the scope of the directory
Bram Moolenaar <Bram@vim.org>
parents:
20599
diff
changeset
|
7372 { |
b60bb094af52
patch 8.2.0876: :pwd does not give a hint about the scope of the directory
Bram Moolenaar <Bram@vim.org>
parents:
20599
diff
changeset
|
7373 char *context = "global"; |
b60bb094af52
patch 8.2.0876: :pwd does not give a hint about the scope of the directory
Bram Moolenaar <Bram@vim.org>
parents:
20599
diff
changeset
|
7374 |
b60bb094af52
patch 8.2.0876: :pwd does not give a hint about the scope of the directory
Bram Moolenaar <Bram@vim.org>
parents:
20599
diff
changeset
|
7375 if (curwin->w_localdir != NULL) |
b60bb094af52
patch 8.2.0876: :pwd does not give a hint about the scope of the directory
Bram Moolenaar <Bram@vim.org>
parents:
20599
diff
changeset
|
7376 context = "window"; |
b60bb094af52
patch 8.2.0876: :pwd does not give a hint about the scope of the directory
Bram Moolenaar <Bram@vim.org>
parents:
20599
diff
changeset
|
7377 else if (curtab->tp_localdir != NULL) |
b60bb094af52
patch 8.2.0876: :pwd does not give a hint about the scope of the directory
Bram Moolenaar <Bram@vim.org>
parents:
20599
diff
changeset
|
7378 context = "tabpage"; |
b60bb094af52
patch 8.2.0876: :pwd does not give a hint about the scope of the directory
Bram Moolenaar <Bram@vim.org>
parents:
20599
diff
changeset
|
7379 smsg("[%s] %s", context, (char *)NameBuff); |
b60bb094af52
patch 8.2.0876: :pwd does not give a hint about the scope of the directory
Bram Moolenaar <Bram@vim.org>
parents:
20599
diff
changeset
|
7380 } |
b60bb094af52
patch 8.2.0876: :pwd does not give a hint about the scope of the directory
Bram Moolenaar <Bram@vim.org>
parents:
20599
diff
changeset
|
7381 else |
b60bb094af52
patch 8.2.0876: :pwd does not give a hint about the scope of the directory
Bram Moolenaar <Bram@vim.org>
parents:
20599
diff
changeset
|
7382 msg((char *)NameBuff); |
7 | 7383 } |
7384 else | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7385 emsg(_("E187: Unknown")); |
7 | 7386 } |
7387 | |
7388 /* | |
7389 * ":=". | |
7390 */ | |
7391 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7392 ex_equal(exarg_T *eap) |
7 | 7393 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7394 smsg("%ld", (long)eap->line2); |
167 | 7395 ex_may_print(eap); |
7 | 7396 } |
7397 | |
7398 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7399 ex_sleep(exarg_T *eap) |
7 | 7400 { |
236 | 7401 int n; |
7402 long len; | |
7 | 7403 |
7404 if (cursor_valid()) | |
7405 { | |
7406 n = W_WINROW(curwin) + curwin->w_wrow - msg_scrolled; | |
7407 if (n >= 0) | |
12513
3ca08bf99396
patch 8.0.1135: W_WINCOL() is always the same
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
7408 windgoto((int)n, curwin->w_wincol + curwin->w_wcol); |
7 | 7409 } |
236 | 7410 |
7411 len = eap->line2; | |
7412 switch (*eap->arg) | |
7413 { | |
7414 case 'm': break; | |
7415 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
|
7416 default: semsg(_(e_invarg2), eap->arg); return; |
236 | 7417 } |
23648
b7d3c79075c5
patch 8.2.2366: when using ":sleep" the cursor is always displayed
Bram Moolenaar <Bram@vim.org>
parents:
23616
diff
changeset
|
7418 |
b7d3c79075c5
patch 8.2.2366: when using ":sleep" the cursor is always displayed
Bram Moolenaar <Bram@vim.org>
parents:
23616
diff
changeset
|
7419 // Hide the cursor if invoked with ! |
b7d3c79075c5
patch 8.2.2366: when using ":sleep" the cursor is always displayed
Bram Moolenaar <Bram@vim.org>
parents:
23616
diff
changeset
|
7420 do_sleep(len, eap->forceit); |
7 | 7421 } |
7422 | |
7423 /* | |
7424 * Sleep for "msec" milliseconds, but keep checking for a CTRL-C every second. | |
23648
b7d3c79075c5
patch 8.2.2366: when using ":sleep" the cursor is always displayed
Bram Moolenaar <Bram@vim.org>
parents:
23616
diff
changeset
|
7425 * Hide the cursor if "hide_cursor" is TRUE. |
7 | 7426 */ |
7427 void | |
23648
b7d3c79075c5
patch 8.2.2366: when using ":sleep" the cursor is always displayed
Bram Moolenaar <Bram@vim.org>
parents:
23616
diff
changeset
|
7428 do_sleep(long msec, int hide_cursor) |
7 | 7429 { |
17712
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
7430 long done = 0; |
8577
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
7431 long wait_now; |
17712
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
7432 # ifdef ELAPSED_FUNC |
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
7433 elapsed_T start_tv; |
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
7434 |
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
7435 // 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
|
7436 // 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
|
7437 ELAPSED_INIT(start_tv); |
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
7438 # endif |
7 | 7439 |
23648
b7d3c79075c5
patch 8.2.2366: when using ":sleep" the cursor is always displayed
Bram Moolenaar <Bram@vim.org>
parents:
23616
diff
changeset
|
7440 if (hide_cursor) |
24428
9299d21d1d5d
patch 8.2.2754: :sleep! does not always hide the cursor
Bram Moolenaar <Bram@vim.org>
parents:
24369
diff
changeset
|
7441 cursor_sleep(); |
23648
b7d3c79075c5
patch 8.2.2366: when using ":sleep" the cursor is always displayed
Bram Moolenaar <Bram@vim.org>
parents:
23616
diff
changeset
|
7442 else |
b7d3c79075c5
patch 8.2.2366: when using ":sleep" the cursor is always displayed
Bram Moolenaar <Bram@vim.org>
parents:
23616
diff
changeset
|
7443 cursor_on(); |
b7d3c79075c5
patch 8.2.2366: when using ":sleep" the cursor is always displayed
Bram Moolenaar <Bram@vim.org>
parents:
23616
diff
changeset
|
7444 |
14860
ac5d0d27aef9
patch 8.1.0442: GUI: cursor not drawn after ":redraw | sleep"
Christian Brabandt <cb@256bit.org>
parents:
14760
diff
changeset
|
7445 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
|
7446 while (!got_int && done < msec) |
8577
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
7447 { |
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
7448 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
|
7449 #ifdef FEAT_TIMERS |
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
7450 { |
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
7451 long due_time = check_due_timer(); |
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
7452 |
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
7453 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
|
7454 wait_now = due_time; |
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
7455 } |
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
7456 #endif |
10240
175b1116f96a
commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents:
10184
diff
changeset
|
7457 #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
|
7458 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
|
7459 wait_now = 20L; |
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17652
diff
changeset
|
7460 #endif |
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17652
diff
changeset
|
7461 #ifdef FEAT_SOUND |
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17652
diff
changeset
|
7462 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
|
7463 wait_now = 20L; |
10240
175b1116f96a
commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents:
10184
diff
changeset
|
7464 #endif |
8577
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
7465 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
|
7466 |
10240
175b1116f96a
commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents:
10184
diff
changeset
|
7467 #ifdef FEAT_JOB_CHANNEL |
175b1116f96a
commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents:
10184
diff
changeset
|
7468 if (has_any_channel()) |
175b1116f96a
commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents:
10184
diff
changeset
|
7469 ui_breakcheck_force(TRUE); |
175b1116f96a
commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents:
10184
diff
changeset
|
7470 else |
175b1116f96a
commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents:
10184
diff
changeset
|
7471 #endif |
175b1116f96a
commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents:
10184
diff
changeset
|
7472 ui_breakcheck(); |
7109
fa95595fbc52
commit https://github.com/vim/vim/commit/93c88e0f6a4a8f7634ed84721daf4af46fc0d5db
Christian Brabandt <cb@256bit.org>
parents:
7105
diff
changeset
|
7473 #ifdef MESSAGE_QUEUE |
17712
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
7474 // 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
|
7475 // 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
|
7476 // 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
|
7477 parse_queued_messages(); |
3151 | 7478 #endif |
17712
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
7479 |
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
7480 # ifdef ELAPSED_FUNC |
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
7481 // actual time passed |
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
7482 done = ELAPSED_FUNC(start_tv); |
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
7483 # else |
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
7484 // 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
|
7485 done += wait_now; |
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
7486 # endif |
7 | 7487 } |
14284
7cd8298c4c04
patch 8.1.0158: GUI: input() fails if CTRL-C was pressed before
Christian Brabandt <cb@256bit.org>
parents:
14266
diff
changeset
|
7488 |
7cd8298c4c04
patch 8.1.0158: GUI: input() fails if CTRL-C was pressed before
Christian Brabandt <cb@256bit.org>
parents:
14266
diff
changeset
|
7489 // 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
|
7490 // 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
|
7491 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
|
7492 (void)vpeekc(); |
24428
9299d21d1d5d
patch 8.2.2754: :sleep! does not always hide the cursor
Bram Moolenaar <Bram@vim.org>
parents:
24369
diff
changeset
|
7493 |
9299d21d1d5d
patch 8.2.2754: :sleep! does not always hide the cursor
Bram Moolenaar <Bram@vim.org>
parents:
24369
diff
changeset
|
7494 if (hide_cursor) |
9299d21d1d5d
patch 8.2.2754: :sleep! does not always hide the cursor
Bram Moolenaar <Bram@vim.org>
parents:
24369
diff
changeset
|
7495 cursor_unsleep(); |
7 | 7496 } |
7497 | |
7498 /* | |
7499 * ":winsize" command (obsolete). | |
7500 */ | |
7501 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7502 ex_winsize(exarg_T *eap) |
7 | 7503 { |
7504 int w, h; | |
7505 char_u *arg = eap->arg; | |
7506 char_u *p; | |
7507 | |
23855
a7098bc3810e
patch 8.2.2469: confusing error if :winsize has a wrong argument
Bram Moolenaar <Bram@vim.org>
parents:
23853
diff
changeset
|
7508 if (!isdigit(*arg)) |
a7098bc3810e
patch 8.2.2469: confusing error if :winsize has a wrong argument
Bram Moolenaar <Bram@vim.org>
parents:
23853
diff
changeset
|
7509 { |
a7098bc3810e
patch 8.2.2469: confusing error if :winsize has a wrong argument
Bram Moolenaar <Bram@vim.org>
parents:
23853
diff
changeset
|
7510 semsg(_(e_invarg2), arg); |
a7098bc3810e
patch 8.2.2469: confusing error if :winsize has a wrong argument
Bram Moolenaar <Bram@vim.org>
parents:
23853
diff
changeset
|
7511 return; |
a7098bc3810e
patch 8.2.2469: confusing error if :winsize has a wrong argument
Bram Moolenaar <Bram@vim.org>
parents:
23853
diff
changeset
|
7512 } |
7 | 7513 w = getdigits(&arg); |
7514 arg = skipwhite(arg); | |
7515 p = arg; | |
7516 h = getdigits(&arg); | |
7517 if (*p != NUL && *arg == NUL) | |
7518 set_shellsize(w, h, TRUE); | |
7519 else | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7520 emsg(_("E465: :winsize requires two number arguments")); |
7 | 7521 } |
7522 | |
7523 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7524 ex_wincmd(exarg_T *eap) |
7 | 7525 { |
7526 int xchar = NUL; | |
7527 char_u *p; | |
7528 | |
7529 if (*eap->arg == 'g' || *eap->arg == Ctrl_G) | |
7530 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7531 // CTRL-W g and CTRL-W CTRL-G have an extra command character |
7 | 7532 if (eap->arg[1] == NUL) |
7533 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7534 emsg(_(e_invarg)); |
7 | 7535 return; |
7536 } | |
7537 xchar = eap->arg[1]; | |
7538 p = eap->arg + 2; | |
7539 } | |
7540 else | |
7541 p = eap->arg + 1; | |
7542 | |
7543 eap->nextcmd = check_nextcmd(p); | |
7544 p = skipwhite(p); | |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21335
diff
changeset
|
7545 if (*p != NUL && *p != ( |
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21335
diff
changeset
|
7546 #ifdef FEAT_EVAL |
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21335
diff
changeset
|
7547 in_vim9script() ? '#' : |
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21335
diff
changeset
|
7548 #endif |
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21335
diff
changeset
|
7549 '"') |
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21335
diff
changeset
|
7550 && eap->nextcmd == NULL) |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7551 emsg(_(e_invarg)); |
2887 | 7552 else if (!eap->skip) |
7 | 7553 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7554 // Pass flags on for ":vertical wincmd ]". |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
7555 postponed_split_flags = cmdmod.cmod_split; |
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
7556 postponed_split_tab = cmdmod.cmod_tab; |
7 | 7557 do_window(*eap->arg, eap->addr_count > 0 ? eap->line2 : 0L, xchar); |
7558 postponed_split_flags = 0; | |
1090 | 7559 postponed_split_tab = 0; |
7 | 7560 } |
7561 } | |
7562 | |
11 | 7563 #if defined(FEAT_GUI) || defined(UNIX) || defined(VMS) || defined(MSWIN) |
7 | 7564 /* |
7565 * ":winpos". | |
7566 */ | |
7567 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7568 ex_winpos(exarg_T *eap) |
7 | 7569 { |
7570 int x, y; | |
7571 char_u *arg = eap->arg; | |
7572 char_u *p; | |
7573 | |
7574 if (*arg == NUL) | |
7575 { | |
11 | 7576 # 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
|
7577 # 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
|
7578 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
|
7579 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
|
7580 # elif defined(FEAT_GUI) |
7 | 7581 if (gui.in_use && gui_mch_get_winpos(&x, &y) != FAIL) |
11 | 7582 # else |
7583 if (mch_get_winpos(&x, &y) != FAIL) | |
7584 # endif | |
7 | 7585 { |
7586 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
|
7587 msg((char *)IObuff); |
7 | 7588 } |
7589 else | |
7590 # endif | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7591 emsg(_("E188: Obtaining window position not implemented for this platform")); |
7 | 7592 } |
7593 else | |
7594 { | |
7595 x = getdigits(&arg); | |
7596 arg = skipwhite(arg); | |
7597 p = arg; | |
7598 y = getdigits(&arg); | |
7599 if (*p == NUL || *arg != NUL) | |
7600 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7601 emsg(_("E466: :winpos requires two number arguments")); |
7 | 7602 return; |
7603 } | |
7604 # ifdef FEAT_GUI | |
7605 if (gui.in_use) | |
7606 gui_mch_set_winpos(x, y); | |
7607 else if (gui.starting) | |
7608 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7609 // Remember the coordinates for when the window is opened. |
7 | 7610 gui_win_x = x; |
7611 gui_win_y = y; | |
7612 } | |
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
|
7613 # if defined(HAVE_TGETENT) || defined(VIMDLL) |
7 | 7614 else |
7615 # 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
|
7616 # 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
|
7617 # if defined(MSWIN) && (!defined(FEAT_GUI) || defined(VIMDLL)) |
11 | 7618 mch_set_winpos(x, y); |
7 | 7619 # endif |
7620 # ifdef HAVE_TGETENT | |
7621 if (*T_CWP) | |
7622 term_set_winpos(x, y); | |
7623 # endif | |
7624 } | |
7625 } | |
7626 #endif | |
7627 | |
7628 /* | |
7629 * Handle command that work like operators: ":delete", ":yank", ":>" and ":<". | |
7630 */ | |
7631 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7632 ex_operators(exarg_T *eap) |
7 | 7633 { |
7634 oparg_T oa; | |
7635 | |
7636 clear_oparg(&oa); | |
7637 oa.regname = eap->regname; | |
7638 oa.start.lnum = eap->line1; | |
7639 oa.end.lnum = eap->line2; | |
7640 oa.line_count = eap->line2 - eap->line1 + 1; | |
7641 oa.motion_type = MLINE; | |
7642 virtual_op = FALSE; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7643 if (eap->cmdidx != CMD_yank) // position cursor for undo |
7 | 7644 { |
7645 setpcmark(); | |
7646 curwin->w_cursor.lnum = eap->line1; | |
7647 beginline(BL_SOL | BL_FIX); | |
7648 } | |
7649 | |
5498 | 7650 if (VIsual_active) |
7651 end_visual_mode(); | |
7652 | |
7 | 7653 switch (eap->cmdidx) |
7654 { | |
7655 case CMD_delete: | |
7656 oa.op_type = OP_DELETE; | |
7657 op_delete(&oa); | |
7658 break; | |
7659 | |
7660 case CMD_yank: | |
7661 oa.op_type = OP_YANK; | |
7662 (void)op_yank(&oa, FALSE, TRUE); | |
7663 break; | |
7664 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7665 default: // CMD_rshift or CMD_lshift |
4889
25d64a4edc0b
updated for version 7.3.1190
Bram Moolenaar <bram@vim.org>
parents:
4857
diff
changeset
|
7666 if ( |
7 | 7667 #ifdef FEAT_RIGHTLEFT |
4889
25d64a4edc0b
updated for version 7.3.1190
Bram Moolenaar <bram@vim.org>
parents:
4857
diff
changeset
|
7668 (eap->cmdidx == CMD_rshift) ^ curwin->w_p_rl |
25d64a4edc0b
updated for version 7.3.1190
Bram Moolenaar <bram@vim.org>
parents:
4857
diff
changeset
|
7669 #else |
25d64a4edc0b
updated for version 7.3.1190
Bram Moolenaar <bram@vim.org>
parents:
4857
diff
changeset
|
7670 eap->cmdidx == CMD_rshift |
25d64a4edc0b
updated for version 7.3.1190
Bram Moolenaar <bram@vim.org>
parents:
4857
diff
changeset
|
7671 #endif |
25d64a4edc0b
updated for version 7.3.1190
Bram Moolenaar <bram@vim.org>
parents:
4857
diff
changeset
|
7672 ) |
7 | 7673 oa.op_type = OP_RSHIFT; |
7674 else | |
7675 oa.op_type = OP_LSHIFT; | |
7676 op_shift(&oa, FALSE, eap->amount); | |
7677 break; | |
7678 } | |
7679 virtual_op = MAYBE; | |
167 | 7680 ex_may_print(eap); |
7 | 7681 } |
7682 | |
7683 /* | |
7684 * ":put". | |
7685 */ | |
7686 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7687 ex_put(exarg_T *eap) |
7 | 7688 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7689 // ":0put" works like ":1put!". |
7 | 7690 if (eap->line2 == 0) |
7691 { | |
7692 eap->line2 = 1; | |
7693 eap->forceit = TRUE; | |
7694 } | |
7695 curwin->w_cursor.lnum = eap->line2; | |
22176
6941d3205be9
patch 8.2.1637: Vim9: :put ={expr} does not work inside :def function
Bram Moolenaar <Bram@vim.org>
parents:
21939
diff
changeset
|
7696 do_put(eap->regname, NULL, eap->forceit ? BACKWARD : FORWARD, 1L, |
167 | 7697 PUT_LINE|PUT_CURSLINE); |
7 | 7698 } |
7699 | |
7700 /* | |
7701 * Handle ":copy" and ":move". | |
7702 */ | |
7703 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7704 ex_copymove(exarg_T *eap) |
7 | 7705 { |
7706 long n; | |
7707 | |
21592
7d721e95dc51
patch 8.2.1346: small build fails
Bram Moolenaar <Bram@vim.org>
parents:
21584
diff
changeset
|
7708 #ifdef FEAT_EVAL |
21584
d0c76ce48326
patch 8.2.1342: Vim9: accidentally using "t" gives a confusing error
Bram Moolenaar <Bram@vim.org>
parents:
21544
diff
changeset
|
7709 if (not_in_vim9(eap) == FAIL) |
d0c76ce48326
patch 8.2.1342: Vim9: accidentally using "t" gives a confusing error
Bram Moolenaar <Bram@vim.org>
parents:
21544
diff
changeset
|
7710 return; |
21592
7d721e95dc51
patch 8.2.1346: small build fails
Bram Moolenaar <Bram@vim.org>
parents:
21584
diff
changeset
|
7711 #endif |
14760
fd69edd2c67e
patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents:
14700
diff
changeset
|
7712 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
|
7713 if (eap->arg == NULL) // error detected |
7 | 7714 { |
7715 eap->nextcmd = NULL; | |
7716 return; | |
7717 } | |
167 | 7718 get_flags(eap); |
7 | 7719 |
7720 /* | |
7721 * move or copy lines from 'eap->line1'-'eap->line2' to below line 'n' | |
7722 */ | |
7723 if (n == MAXLNUM || n < 0 || n > curbuf->b_ml.ml_line_count) | |
7724 { | |
25064
8f2262c72178
patch 8.2.3069: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
24984
diff
changeset
|
7725 emsg(_(e_invalid_range)); |
7 | 7726 return; |
7727 } | |
7728 | |
7729 if (eap->cmdidx == CMD_move) | |
7730 { | |
7731 if (do_move(eap->line1, eap->line2, n) == FAIL) | |
7732 return; | |
7733 } | |
7734 else | |
7735 ex_copy(eap->line1, eap->line2, n); | |
7736 u_clearline(); | |
7737 beginline(BL_SOL | BL_FIX); | |
167 | 7738 ex_may_print(eap); |
7739 } | |
7740 | |
7741 /* | |
7742 * Print the current line if flags were given to the Ex command. | |
7743 */ | |
5776 | 7744 void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7745 ex_may_print(exarg_T *eap) |
167 | 7746 { |
7747 if (eap->flags != 0) | |
7748 { | |
7749 print_line(curwin->w_cursor.lnum, (eap->flags & EXFLAG_NR), | |
7750 (eap->flags & EXFLAG_LIST)); | |
7751 ex_no_reprint = TRUE; | |
7752 } | |
7 | 7753 } |
7754 | |
7755 /* | |
7756 * ":smagic" and ":snomagic". | |
7757 */ | |
7758 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7759 ex_submagic(exarg_T *eap) |
7 | 7760 { |
23505
bb29b09902d5
patch 8.2.2295: incsearch does not detect empty pattern properly
Bram Moolenaar <Bram@vim.org>
parents:
23398
diff
changeset
|
7761 optmagic_T saved = magic_overruled; |
bb29b09902d5
patch 8.2.2295: incsearch does not detect empty pattern properly
Bram Moolenaar <Bram@vim.org>
parents:
23398
diff
changeset
|
7762 |
bb29b09902d5
patch 8.2.2295: incsearch does not detect empty pattern properly
Bram Moolenaar <Bram@vim.org>
parents:
23398
diff
changeset
|
7763 magic_overruled = eap->cmdidx == CMD_smagic |
bb29b09902d5
patch 8.2.2295: incsearch does not detect empty pattern properly
Bram Moolenaar <Bram@vim.org>
parents:
23398
diff
changeset
|
7764 ? OPTION_MAGIC_ON : OPTION_MAGIC_OFF; |
21773
2f2e528c5782
patch 8.2.1436: function implementing :substitute has unexpected name
Bram Moolenaar <Bram@vim.org>
parents:
21727
diff
changeset
|
7765 ex_substitute(eap); |
23272
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
23239
diff
changeset
|
7766 magic_overruled = saved; |
7 | 7767 } |
7768 | |
7769 /* | |
7770 * ":join". | |
7771 */ | |
7772 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7773 ex_join(exarg_T *eap) |
7 | 7774 { |
7775 curwin->w_cursor.lnum = eap->line1; | |
7776 if (eap->line1 == eap->line2) | |
7777 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7778 if (eap->addr_count >= 2) // :2,2join does nothing |
7 | 7779 return; |
7780 if (eap->line2 == curbuf->b_ml.ml_line_count) | |
7781 { | |
7782 beep_flush(); | |
7783 return; | |
7784 } | |
7785 ++eap->line2; | |
7786 } | |
5848 | 7787 (void)do_join(eap->line2 - eap->line1 + 1, !eap->forceit, TRUE, TRUE, TRUE); |
7 | 7788 beginline(BL_WHITE | BL_FIX); |
167 | 7789 ex_may_print(eap); |
7 | 7790 } |
7791 | |
7792 /* | |
7793 * ":[addr]@r" or ":[addr]*r": execute register | |
7794 */ | |
7795 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7796 ex_at(exarg_T *eap) |
7 | 7797 { |
7798 int c; | |
1973 | 7799 int prev_len = typebuf.tb_len; |
7 | 7800 |
7801 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
|
7802 check_cursor_col(); |
7 | 7803 |
7804 #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
|
7805 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
|
7806 #endif |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7807 |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7808 // get the register name. No name means to use the previous one |
7 | 7809 c = *eap->arg; |
7810 if (c == NUL || (c == '*' && *eap->cmd == '*')) | |
7811 c = '@'; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7812 // Put the register in the typeahead buffer with the "silent" flag. |
1034 | 7813 if (do_execreg(c, TRUE, vim_strchr(p_cpo, CPO_EXECBUF) != NULL, TRUE) |
7814 == FAIL) | |
167 | 7815 { |
7 | 7816 beep_flush(); |
167 | 7817 } |
7 | 7818 else |
7819 { | |
7820 int save_efr = exec_from_reg; | |
7821 | |
7822 exec_from_reg = TRUE; | |
7823 | |
7824 /* | |
7825 * Execute from the typeahead buffer. | |
1973 | 7826 * Continue until the stuff buffer is empty and all added characters |
7827 * have been consumed. | |
7 | 7828 */ |
1973 | 7829 while (!stuff_empty() || typebuf.tb_len > prev_len) |
7 | 7830 (void)do_cmdline(NULL, getexline, NULL, DOCMD_NOWAIT|DOCMD_VERBOSE); |
7831 | |
7832 exec_from_reg = save_efr; | |
7833 } | |
7834 } | |
7835 | |
7836 /* | |
7837 * ":!". | |
7838 */ | |
7839 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7840 ex_bang(exarg_T *eap) |
7 | 7841 { |
7842 do_bang(eap->addr_count, eap, eap->forceit, TRUE, TRUE); | |
7843 } | |
7844 | |
7845 /* | |
7846 * ":undo". | |
7847 */ | |
7848 static void | |
8368
db2a07b710ed
commit https://github.com/vim/vim/commit/f1d2501ebe33e148886c2914acd33140e20ee222
Christian Brabandt <cb@256bit.org>
parents:
8281
diff
changeset
|
7849 ex_undo(exarg_T *eap) |
7 | 7850 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7851 if (eap->addr_count == 1) // :undo 123 |
2281
e41433ea71df
Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents:
2276
diff
changeset
|
7852 undo_time(eap->line2, FALSE, FALSE, TRUE); |
771 | 7853 else |
7854 u_undo(1); | |
7 | 7855 } |
7856 | |
2214
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
7857 #ifdef FEAT_PERSISTENT_UNDO |
2340
99c1eba60b2d
Make automatic prototype generation work with more interfaces.
Bram Moolenaar <bram@vim.org>
parents:
2333
diff
changeset
|
7858 static void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7859 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
|
7860 { |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
7861 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
|
7862 |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
7863 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
|
7864 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
|
7865 } |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
7866 |
2340
99c1eba60b2d
Make automatic prototype generation work with more interfaces.
Bram Moolenaar <bram@vim.org>
parents:
2333
diff
changeset
|
7867 static void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7868 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
|
7869 { |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
7870 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
|
7871 |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
7872 u_compute_hash(hash); |
2238
3d0a7beb0d75
Made reading/writing undo info a bit more robust.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
7873 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
|
7874 } |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
7875 #endif |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
7876 |
7 | 7877 /* |
7878 * ":redo". | |
7879 */ | |
7880 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7881 ex_redo(exarg_T *eap UNUSED) |
7 | 7882 { |
7883 u_redo(1); | |
7884 } | |
7885 | |
7886 /* | |
756 | 7887 * ":earlier" and ":later". |
7888 */ | |
7889 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7890 ex_later(exarg_T *eap) |
756 | 7891 { |
7892 long count = 0; | |
7893 int sec = FALSE; | |
2281
e41433ea71df
Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents:
2276
diff
changeset
|
7894 int file = FALSE; |
756 | 7895 char_u *p = eap->arg; |
7896 | |
7897 if (*p == NUL) | |
7898 count = 1; | |
7899 else if (isdigit(*p)) | |
7900 { | |
7901 count = getdigits(&p); | |
7902 switch (*p) | |
7903 { | |
7904 case 's': ++p; sec = TRUE; break; | |
7905 case 'm': ++p; sec = TRUE; count *= 60; break; | |
7906 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
|
7907 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
|
7908 case 'f': ++p; file = TRUE; break; |
756 | 7909 } |
7910 } | |
7911 | |
7912 if (*p != NUL) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7913 semsg(_(e_invarg2), eap->arg); |
756 | 7914 else |
2281
e41433ea71df
Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents:
2276
diff
changeset
|
7915 undo_time(eap->cmdidx == CMD_earlier ? -count : count, |
e41433ea71df
Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents:
2276
diff
changeset
|
7916 sec, file, FALSE); |
756 | 7917 } |
7918 | |
7919 /* | |
7 | 7920 * ":redir": start/stop redirection. |
7921 */ | |
7922 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7923 ex_redir(exarg_T *eap) |
7 | 7924 { |
7925 char *mode; | |
7926 char_u *fname; | |
122 | 7927 char_u *arg = eap->arg; |
7 | 7928 |
9440
73c0d07cc15e
commit https://github.com/vim/vim/commit/ba768495c2e6bae74e49d22d489fbf211ecad55e
Christian Brabandt <cb@256bit.org>
parents:
9438
diff
changeset
|
7929 #ifdef FEAT_EVAL |
9454
9da0cb39cbee
commit https://github.com/vim/vim/commit/79815f1ec77406f2f21a618c053e5793b597db7a
Christian Brabandt <cb@256bit.org>
parents:
9440
diff
changeset
|
7930 if (redir_execute) |
9da0cb39cbee
commit https://github.com/vim/vim/commit/79815f1ec77406f2f21a618c053e5793b597db7a
Christian Brabandt <cb@256bit.org>
parents:
9440
diff
changeset
|
7931 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7932 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
|
7933 return; |
7897b1e4f3e7
commit https://github.com/vim/vim/commit/245a7cb6d33e556415c9fcaa874b784a6d8f0ef3
Christian Brabandt <cb@256bit.org>
parents:
9432
diff
changeset
|
7934 } |
9440
73c0d07cc15e
commit https://github.com/vim/vim/commit/ba768495c2e6bae74e49d22d489fbf211ecad55e
Christian Brabandt <cb@256bit.org>
parents:
9438
diff
changeset
|
7935 #endif |
9438
7897b1e4f3e7
commit https://github.com/vim/vim/commit/245a7cb6d33e556415c9fcaa874b784a6d8f0ef3
Christian Brabandt <cb@256bit.org>
parents:
9432
diff
changeset
|
7936 |
7 | 7937 if (STRICMP(eap->arg, "END") == 0) |
7938 close_redir(); | |
7939 else | |
7940 { | |
122 | 7941 if (*arg == '>') |
7942 { | |
7943 ++arg; | |
7944 if (*arg == '>') | |
7945 { | |
7946 ++arg; | |
7 | 7947 mode = "a"; |
7948 } | |
7949 else | |
7950 mode = "w"; | |
122 | 7951 arg = skipwhite(arg); |
7 | 7952 |
7953 close_redir(); | |
7954 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7955 // Expand environment variables and "~/". |
122 | 7956 fname = expand_env_save(arg); |
7 | 7957 if (fname == NULL) |
7958 return; | |
7959 #ifdef FEAT_BROWSE | |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
7960 if (cmdmod.cmod_flags & CMOD_BROWSE) |
7 | 7961 { |
7962 char_u *browseFile; | |
7963 | |
28 | 7964 browseFile = do_browse(BROWSE_SAVE, |
7965 (char_u *)_("Save Redirection"), | |
13802
378f9f8e6d8f
patch 8.0.1773: dialog messages are not translated
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
7966 fname, NULL, NULL, |
378f9f8e6d8f
patch 8.0.1773: dialog messages are not translated
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
7967 (char_u *)_(BROWSE_FILTER_ALL_FILES), curbuf); |
7 | 7968 if (browseFile == NULL) |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7969 return; // operation cancelled |
7 | 7970 vim_free(fname); |
7971 fname = browseFile; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7972 eap->forceit = TRUE; // since dialog already asked |
7 | 7973 } |
7974 #endif | |
7975 | |
7976 redir_fd = open_exfile(fname, eap->forceit, mode); | |
7977 vim_free(fname); | |
7978 } | |
7979 #ifdef FEAT_EVAL | |
122 | 7980 else if (*arg == '@') |
7 | 7981 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7982 // redirect to a register a-z (resp. A-Z for appending) |
7 | 7983 close_redir(); |
122 | 7984 ++arg; |
7985 if (ASCII_ISALPHA(*arg) | |
7 | 7986 # ifdef FEAT_CLIPBOARD |
122 | 7987 || *arg == '*' |
1038 | 7988 || *arg == '+' |
7 | 7989 # endif |
122 | 7990 || *arg == '"') |
7991 { | |
7992 redir_reg = *arg++; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7993 if (*arg == '>' && arg[1] == '>') // append |
268 | 7994 arg += 2; |
1427 | 7995 else |
7 | 7996 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7997 // Can use both "@a" and "@a>". |
296 | 7998 if (*arg == '>') |
7999 arg++; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8000 // 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
|
8001 // command is valid. |
1427 | 8002 if (*arg == NUL && !isupper(redir_reg)) |
8003 write_reg_contents(redir_reg, (char_u *)"", -1, FALSE); | |
7 | 8004 } |
167 | 8005 } |
8006 if (*arg != NUL) | |
8007 { | |
268 | 8008 redir_reg = 0; |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8009 semsg(_(e_invarg2), eap->arg); |
167 | 8010 } |
8011 } | |
8012 else if (*arg == '=' && arg[1] == '>') | |
8013 { | |
8014 int append; | |
8015 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8016 // redirect to a variable |
167 | 8017 close_redir(); |
8018 arg += 2; | |
8019 | |
8020 if (*arg == '>') | |
8021 { | |
8022 ++arg; | |
8023 append = TRUE; | |
7 | 8024 } |
8025 else | |
167 | 8026 append = FALSE; |
8027 | |
8028 if (var_redir_start(skipwhite(arg), append) == OK) | |
8029 redir_vname = 1; | |
7 | 8030 } |
8031 #endif | |
8032 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8033 // TODO: redirect to a buffer |
7 | 8034 |
8035 else | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8036 semsg(_(e_invarg2), eap->arg); |
7 | 8037 } |
972 | 8038 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8039 // 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
|
8040 // that indirectly invokes a command to catch its output. |
972 | 8041 if (redir_fd != NULL |
8042 #ifdef FEAT_EVAL | |
8043 || redir_reg || redir_vname | |
8044 #endif | |
8045 ) | |
8046 redir_off = FALSE; | |
7 | 8047 } |
8048 | |
8049 /* | |
8050 * ":redraw": force redraw | |
8051 */ | |
7864
6b0891de44a9
commit https://github.com/vim/vim/commit/fb1f62691eae7c79a28b3b17a60e72ce198c71a2
Christian Brabandt <cb@256bit.org>
parents:
7850
diff
changeset
|
8052 void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8053 ex_redraw(exarg_T *eap) |
7 | 8054 { |
8055 int r = RedrawingDisabled; | |
8056 int p = p_lz; | |
8057 | |
8058 RedrawingDisabled = 0; | |
8059 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
|
8060 validate_cursor(); |
7 | 8061 update_topline(); |
5735 | 8062 update_screen(eap->forceit ? CLEAR : VIsual_active ? INVERTED : 0); |
7 | 8063 #ifdef FEAT_TITLE |
8064 if (need_maketitle) | |
8065 maketitle(); | |
8066 #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
|
8067 #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
|
8068 # 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
|
8069 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
|
8070 # 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
|
8071 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
|
8072 #endif |
7 | 8073 RedrawingDisabled = r; |
8074 p_lz = p; | |
8075 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8076 // Reset msg_didout, so that a message that's there is overwritten. |
7 | 8077 msg_didout = FALSE; |
8078 msg_col = 0; | |
8079 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8080 // 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
|
8081 need_wait_return = FALSE; |
1b89e3f916c5
updated for version 7.4a.025
Bram Moolenaar <bram@vim.org>
parents:
4928
diff
changeset
|
8082 |
7 | 8083 out_flush(); |
8084 } | |
8085 | |
8086 /* | |
8087 * ":redrawstatus": force redraw of status line(s) | |
8088 */ | |
8089 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8090 ex_redrawstatus(exarg_T *eap UNUSED) |
7 | 8091 { |
8092 int r = RedrawingDisabled; | |
8093 int p = p_lz; | |
8094 | |
8095 RedrawingDisabled = 0; | |
8096 p_lz = FALSE; | |
8097 if (eap->forceit) | |
8098 status_redraw_all(); | |
8099 else | |
8100 status_redraw_curbuf(); | |
5735 | 8101 update_screen(VIsual_active ? INVERTED : 0); |
7 | 8102 RedrawingDisabled = r; |
8103 p_lz = p; | |
8104 out_flush(); | |
8105 } | |
8106 | |
15396
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
8107 /* |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
8108 * ":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
|
8109 */ |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
8110 static void |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
8111 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
|
8112 { |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
8113 int r = RedrawingDisabled; |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
8114 int p = p_lz; |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
8115 |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
8116 RedrawingDisabled = 0; |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
8117 p_lz = FALSE; |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
8118 |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
8119 draw_tabline(); |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
8120 |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
8121 RedrawingDisabled = r; |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
8122 p_lz = p; |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
8123 out_flush(); |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
8124 } |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
8125 |
7 | 8126 static void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8127 close_redir(void) |
7 | 8128 { |
8129 if (redir_fd != NULL) | |
8130 { | |
8131 fclose(redir_fd); | |
8132 redir_fd = NULL; | |
8133 } | |
8134 #ifdef FEAT_EVAL | |
8135 redir_reg = 0; | |
167 | 8136 if (redir_vname) |
8137 { | |
8138 var_redir_stop(); | |
8139 redir_vname = 0; | |
8140 } | |
7 | 8141 #endif |
8142 } | |
8143 | |
17539
554240b9574b
patch 8.1.1767: FEAT_SESSION defined separately
Bram Moolenaar <Bram@vim.org>
parents:
17536
diff
changeset
|
8144 #if (defined(FEAT_SESSION) || defined(FEAT_EVAL)) || defined(PROTO) |
167 | 8145 int |
18139
59bc3cd42cf5
patch 8.1.2064: MS-Windows: compiler warnings for unused arguments
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
8146 vim_mkdir_emsg(char_u *name, int prot UNUSED) |
167 | 8147 { |
8148 if (vim_mkdir(name, prot) != 0) | |
8149 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8150 semsg(_("E739: Cannot create directory: %s"), name); |
167 | 8151 return FAIL; |
8152 } | |
8153 return OK; | |
8154 } | |
8155 #endif | |
8156 | |
7 | 8157 /* |
8158 * Open a file for writing for an Ex command, with some checks. | |
8159 * Return file descriptor, or NULL on failure. | |
8160 */ | |
8161 FILE * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8162 open_exfile( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8163 char_u *fname, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8164 int forceit, |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8165 char *mode) // "w" for create new file or "a" for append |
7 | 8166 { |
8167 FILE *fd; | |
8168 | |
8169 #ifdef UNIX | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8170 // with Unix it is possible to open a directory |
7 | 8171 if (mch_isdir(fname)) |
8172 { | |
25064
8f2262c72178
patch 8.2.3069: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
24984
diff
changeset
|
8173 semsg(_(e_src_is_directory), fname); |
7 | 8174 return NULL; |
8175 } | |
8176 #endif | |
8177 if (!forceit && *mode != 'a' && vim_fexists(fname)) | |
8178 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8179 semsg(_("E189: \"%s\" exists (add ! to override)"), fname); |
7 | 8180 return NULL; |
8181 } | |
8182 | |
8183 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
|
8184 semsg(_("E190: Cannot open \"%s\" for writing"), fname); |
7 | 8185 |
8186 return fd; | |
8187 } | |
8188 | |
8189 /* | |
8190 * ":mark" and ":k". | |
8191 */ | |
8192 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8193 ex_mark(exarg_T *eap) |
7 | 8194 { |
8195 pos_T pos; | |
8196 | |
23978
54b2aa1f0d42
patch 8.2.2531: Vim9: the :k command is obscure
Bram Moolenaar <Bram@vim.org>
parents:
23974
diff
changeset
|
8197 #ifdef FEAT_EVAL |
54b2aa1f0d42
patch 8.2.2531: Vim9: the :k command is obscure
Bram Moolenaar <Bram@vim.org>
parents:
23974
diff
changeset
|
8198 if (not_in_vim9(eap) == FAIL) |
54b2aa1f0d42
patch 8.2.2531: Vim9: the :k command is obscure
Bram Moolenaar <Bram@vim.org>
parents:
23974
diff
changeset
|
8199 return; |
54b2aa1f0d42
patch 8.2.2531: Vim9: the :k command is obscure
Bram Moolenaar <Bram@vim.org>
parents:
23974
diff
changeset
|
8200 #endif |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8201 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
|
8202 emsg(_(e_argreq)); |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8203 else if (eap->arg[1] != NUL) // more than one character? |
21461
4dfd00f481fb
patch 8.2.1281: the "trailing characters" error can be hard to understand
Bram Moolenaar <Bram@vim.org>
parents:
21459
diff
changeset
|
8204 semsg(_(e_trailing_arg), eap->arg); |
7 | 8205 else |
8206 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8207 pos = curwin->w_cursor; // save curwin->w_cursor |
7 | 8208 curwin->w_cursor.lnum = eap->line2; |
8209 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
|
8210 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
|
8211 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
|
8212 curwin->w_cursor = pos; // restore curwin->w_cursor |
7 | 8213 } |
8214 } | |
8215 | |
8216 /* | |
8217 * Update w_topline, w_leftcol and the cursor position. | |
8218 */ | |
8219 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8220 update_topline_cursor(void) |
7 | 8221 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8222 check_cursor(); // put cursor on valid line |
7 | 8223 update_topline(); |
8224 if (!curwin->w_p_wrap) | |
8225 validate_cursor(); | |
8226 update_curswant(); | |
8227 } | |
8228 | |
8229 /* | |
12521
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8230 * 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
|
8231 * 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
|
8232 */ |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8233 int |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8234 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
|
8235 { |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8236 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
|
8237 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
|
8238 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
|
8239 sst->save_State = State; |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8240 sst->save_insertmode = p_im; |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8241 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
|
8242 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
|
8243 sst->save_reg_executing = reg_executing; |
23056
57b6427c18e4
patch 8.2.2074: Vim9: using :normal from Vim9 script can't handle range
Bram Moolenaar <Bram@vim.org>
parents:
23050
diff
changeset
|
8244 |
57b6427c18e4
patch 8.2.2074: Vim9: using :normal from Vim9 script can't handle range
Bram Moolenaar <Bram@vim.org>
parents:
23050
diff
changeset
|
8245 msg_scroll = FALSE; // no msg scrolling in Normal mode |
57b6427c18e4
patch 8.2.2074: Vim9: using :normal from Vim9 script can't handle range
Bram Moolenaar <Bram@vim.org>
parents:
23050
diff
changeset
|
8246 restart_edit = 0; // don't go to Insert mode |
57b6427c18e4
patch 8.2.2074: Vim9: using :normal from Vim9 script can't handle range
Bram Moolenaar <Bram@vim.org>
parents:
23050
diff
changeset
|
8247 p_im = FALSE; // don't use 'insertmode' |
23390
9a5f12b36273
patch 8.2.2238: Vim9: cannot load a Vim9 script without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
23378
diff
changeset
|
8248 |
23062
fa87b0d1277b
patch 8.2.2077: build failure with small features
Bram Moolenaar <Bram@vim.org>
parents:
23056
diff
changeset
|
8249 sst->save_script_version = current_sctx.sc_version; |
23056
57b6427c18e4
patch 8.2.2074: Vim9: using :normal from Vim9 script can't handle range
Bram Moolenaar <Bram@vim.org>
parents:
23050
diff
changeset
|
8250 current_sctx.sc_version = 1; // not in Vim9 script |
12521
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8251 |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8252 /* |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8253 * 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
|
8254 * 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
|
8255 * ends with half a command. |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8256 */ |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8257 save_typeahead(&sst->tabuf); |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8258 return sst->tabuf.typebuf_valid; |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8259 } |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8260 |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8261 void |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8262 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
|
8263 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8264 // Restore the previous typeahead. |
24846
fdc6a7769045
patch 8.2.2961: keys typed during a :normal command are discarded
Bram Moolenaar <Bram@vim.org>
parents:
24834
diff
changeset
|
8265 restore_typeahead(&sst->tabuf, FALSE); |
12521
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8266 |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8267 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
|
8268 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
|
8269 p_im = sst->save_insertmode; |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8270 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
|
8271 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
|
8272 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
|
8273 msg_didout |= sst->save_msg_didout; // don't reset msg_didout now |
23056
57b6427c18e4
patch 8.2.2074: Vim9: using :normal from Vim9 script can't handle range
Bram Moolenaar <Bram@vim.org>
parents:
23050
diff
changeset
|
8274 current_sctx.sc_version = sst->save_script_version; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8275 |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8276 // 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
|
8277 // '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
|
8278 State = sst->save_State; |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8279 #ifdef CURSOR_SHAPE |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8280 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
|
8281 #endif |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8282 } |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8283 |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8284 /* |
7 | 8285 * ":normal[!] {commands}": Execute normal mode commands. |
8286 */ | |
7840
28f569c7dab9
commit https://github.com/vim/vim/commit/20fb9f346497daca4d19402fdfa5de7958642477
Christian Brabandt <cb@256bit.org>
parents:
7819
diff
changeset
|
8287 void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8288 ex_normal(exarg_T *eap) |
7 | 8289 { |
12521
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8290 save_state_T save_state; |
7 | 8291 char_u *arg = NULL; |
8292 int l; | |
8293 char_u *p; | |
8294 | |
856 | 8295 if (ex_normal_lock > 0) |
8296 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8297 emsg(_(e_secure)); |
856 | 8298 return; |
8299 } | |
7 | 8300 if (ex_normal_busy >= p_mmd) |
8301 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8302 emsg(_("E192: Recursive use of :normal too deep")); |
7 | 8303 return; |
8304 } | |
8305 | |
8306 /* | |
8307 * vgetc() expects a CSI and K_SPECIAL to have been escaped. Don't do | |
8308 * this for the K_SPECIAL leading byte, otherwise special keys will not | |
8309 * work. | |
8310 */ | |
8311 if (has_mbyte) | |
8312 { | |
8313 int len = 0; | |
8314 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8315 // Count the number of characters to be escaped. |
7 | 8316 for (p = eap->arg; *p != NUL; ++p) |
8317 { | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
8318 #ifdef FEAT_GUI |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8319 if (*p == CSI) // leadbyte CSI |
7 | 8320 len += 2; |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
8321 #endif |
474 | 8322 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
|
8323 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
|
8324 #ifdef FEAT_GUI |
7 | 8325 || *p == CSI |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
8326 #endif |
7 | 8327 ) |
8328 len += 2; | |
8329 } | |
8330 if (len > 0) | |
8331 { | |
16764
ef00b6bc186b
patch 8.1.1384: using "int" for alloc() often results in compiler warnings
Bram Moolenaar <Bram@vim.org>
parents:
16738
diff
changeset
|
8332 arg = alloc(STRLEN(eap->arg) + len + 1); |
7 | 8333 if (arg != NULL) |
8334 { | |
8335 len = 0; | |
8336 for (p = eap->arg; *p != NUL; ++p) | |
8337 { | |
8338 arg[len++] = *p; | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
8339 #ifdef FEAT_GUI |
7 | 8340 if (*p == CSI) |
8341 { | |
8342 arg[len++] = KS_EXTRA; | |
8343 arg[len++] = (int)KE_CSI; | |
8344 } | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
8345 #endif |
474 | 8346 for (l = (*mb_ptr2len)(p) - 1; l > 0; --l) |
7 | 8347 { |
8348 arg[len++] = *++p; | |
8349 if (*p == K_SPECIAL) | |
8350 { | |
8351 arg[len++] = KS_SPECIAL; | |
8352 arg[len++] = KE_FILLER; | |
8353 } | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
8354 #ifdef FEAT_GUI |
7 | 8355 else if (*p == CSI) |
8356 { | |
8357 arg[len++] = KS_EXTRA; | |
8358 arg[len++] = (int)KE_CSI; | |
8359 } | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
8360 #endif |
7 | 8361 } |
8362 arg[len] = NUL; | |
8363 } | |
8364 } | |
8365 } | |
8366 } | |
8367 | |
12521
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8368 ++ex_normal_busy; |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8369 if (save_current_state(&save_state)) |
7 | 8370 { |
8371 /* | |
8372 * Repeat the :normal command for each line in the range. When no | |
8373 * range given, execute it just once, without positioning the cursor | |
8374 * first. | |
8375 */ | |
8376 do | |
8377 { | |
8378 if (eap->addr_count != 0) | |
8379 { | |
8380 curwin->w_cursor.lnum = eap->line1++; | |
8381 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
|
8382 check_cursor_moved(curwin); |
7 | 8383 } |
8384 | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
8385 exec_normal_cmd(arg != NULL |
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
8386 ? arg |
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
8387 : eap->arg, eap->forceit ? REMAP_NONE : REMAP_YES, FALSE); |
7 | 8388 } |
8389 while (eap->addr_count > 0 && eap->line1 <= eap->line2 && !got_int); | |
8390 } | |
8391 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8392 // Might not return to the main loop when in an event handler. |
7 | 8393 update_topline_cursor(); |
8394 | |
12521
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8395 restore_current_state(&save_state); |
7 | 8396 --ex_normal_busy; |
6322 | 8397 setmouse(); |
8398 #ifdef CURSOR_SHAPE | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8399 ui_cursor_shape(); // may show different cursor shape |
6322 | 8400 #endif |
8401 | |
7 | 8402 vim_free(arg); |
8403 } | |
8404 | |
8405 /* | |
598 | 8406 * ":startinsert", ":startreplace" and ":startgreplace" |
7 | 8407 */ |
8408 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8409 ex_startinsert(exarg_T *eap) |
7 | 8410 { |
98 | 8411 if (eap->forceit) |
8412 { | |
17984
2ea47dee7ddd
patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
8413 // 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
|
8414 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
|
8415 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
|
8416 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
|
8417 } |
20097
165ec447ca77
patch 8.2.0604: :startinsert in a terminal window used later
Bram Moolenaar <Bram@vim.org>
parents:
20079
diff
changeset
|
8418 #ifdef FEAT_TERMINAL |
165ec447ca77
patch 8.2.0604: :startinsert in a terminal window used later
Bram Moolenaar <Bram@vim.org>
parents:
20079
diff
changeset
|
8419 // Ignore this when running in an active terminal. |
165ec447ca77
patch 8.2.0604: :startinsert in a terminal window used later
Bram Moolenaar <Bram@vim.org>
parents:
20079
diff
changeset
|
8420 if (term_job_running(curbuf->b_term)) |
165ec447ca77
patch 8.2.0604: :startinsert in a terminal window used later
Bram Moolenaar <Bram@vim.org>
parents:
20079
diff
changeset
|
8421 return; |
165ec447ca77
patch 8.2.0604: :startinsert in a terminal window used later
Bram Moolenaar <Bram@vim.org>
parents:
20079
diff
changeset
|
8422 #endif |
17984
2ea47dee7ddd
patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
8423 |
2ea47dee7ddd
patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
8424 // 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
|
8425 // expression register that invokes a function can do this. |
89 | 8426 if (State & INSERT) |
8427 return; | |
8428 | |
598 | 8429 if (eap->cmdidx == CMD_startinsert) |
8430 restart_edit = 'a'; | |
8431 else if (eap->cmdidx == CMD_startreplace) | |
8432 restart_edit = 'R'; | |
7 | 8433 else |
598 | 8434 restart_edit = 'V'; |
8435 | |
8436 if (!eap->forceit) | |
7 | 8437 { |
14 | 8438 if (eap->cmdidx == CMD_startinsert) |
8439 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
|
8440 curwin->w_curswant = 0; // avoid MAXCOL |
7 | 8441 } |
22862
6d50182e7e24
patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents:
22840
diff
changeset
|
8442 |
6d50182e7e24
patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents:
22840
diff
changeset
|
8443 if (VIsual_active) |
6d50182e7e24
patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents:
22840
diff
changeset
|
8444 showmode(); |
7 | 8445 } |
8446 | |
8447 /* | |
8448 * ":stopinsert" | |
8449 */ | |
8450 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8451 ex_stopinsert(exarg_T *eap UNUSED) |
7 | 8452 { |
8453 restart_edit = 0; | |
8454 stop_insert_mode = TRUE; | |
8817
b7eb7bbd71d0
commit https://github.com/vim/vim/commit/fd773e9e88add7d1ffef890fb9f3a00d613b4326
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
8455 clearmode(); |
7 | 8456 } |
7850
10f17a228661
commit https://github.com/vim/vim/commit/e2c3810c2ae290bbc2cba18eb47cc2d44e4b9797
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
8457 |
36 | 8458 /* |
8459 * Execute normal mode command "cmd". | |
8460 * "remap" can be REMAP_NONE or REMAP_YES. | |
8461 */ | |
8462 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8463 exec_normal_cmd(char_u *cmd, int remap, int silent) |
36 | 8464 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8465 // 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
|
8466 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
|
8467 exec_normal(FALSE, FALSE, FALSE); |
7703
39251e981d1f
commit https://github.com/vim/vim/commit/25281634cda03ce302aaf9f906a9520b5f81f91e
Christian Brabandt <cb@256bit.org>
parents:
7549
diff
changeset
|
8468 } |
7850
10f17a228661
commit https://github.com/vim/vim/commit/e2c3810c2ae290bbc2cba18eb47cc2d44e4b9797
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
8469 |
7703
39251e981d1f
commit https://github.com/vim/vim/commit/25281634cda03ce302aaf9f906a9520b5f81f91e
Christian Brabandt <cb@256bit.org>
parents:
7549
diff
changeset
|
8470 /* |
39251e981d1f
commit https://github.com/vim/vim/commit/25281634cda03ce302aaf9f906a9520b5f81f91e
Christian Brabandt <cb@256bit.org>
parents:
7549
diff
changeset
|
8471 * 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
|
8472 * 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
|
8473 */ |
39251e981d1f
commit https://github.com/vim/vim/commit/25281634cda03ce302aaf9f906a9520b5f81f91e
Christian Brabandt <cb@256bit.org>
parents:
7549
diff
changeset
|
8474 void |
14871
f20df682c8af
patch 8.1.0447: GUI scrollbar test fails with Athena and Motif
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
8475 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
|
8476 { |
36 | 8477 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
|
8478 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
|
8479 |
d3377393e3d9
patch 8.1.1136: decoding of mouse click escape sequence is not tested
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
8480 // 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
|
8481 // is nothing to get, so also check for Ctrl_C. |
36 | 8482 clear_oparg(&oa); |
8483 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
|
8484 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
|
8485 || ((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
|
8486 || (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
|
8487 && !got_int) |
36 | 8488 { |
8489 update_topline_cursor(); | |
13829
044337cbf854
patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents:
13802
diff
changeset
|
8490 #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
|
8491 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
|
8492 && 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
|
8493 && !VIsual_active) |
044337cbf854
patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents:
13802
diff
changeset
|
8494 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8495 // 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
|
8496 // 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
|
8497 // 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
|
8498 if (terminal_loop(TRUE) == OK) |
044337cbf854
patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents:
13802
diff
changeset
|
8499 normal_cmd(&oa, TRUE); |
044337cbf854
patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents:
13802
diff
changeset
|
8500 } |
044337cbf854
patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents:
13802
diff
changeset
|
8501 else |
044337cbf854
patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents:
13802
diff
changeset
|
8502 #endif |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8503 // execute a Normal mode cmd |
13829
044337cbf854
patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents:
13802
diff
changeset
|
8504 normal_cmd(&oa, TRUE); |
36 | 8505 } |
8506 } | |
8507 | |
7 | 8508 #ifdef FEAT_FIND_ID |
8509 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8510 ex_checkpath(exarg_T *eap) |
7 | 8511 { |
8512 find_pattern_in_path(NULL, 0, 0, FALSE, FALSE, CHECK_PATH, 1L, | |
8513 eap->forceit ? ACTION_SHOW_ALL : ACTION_SHOW, | |
8514 (linenr_T)1, (linenr_T)MAXLNUM); | |
8515 } | |
8516 | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
8517 #if defined(FEAT_QUICKFIX) |
7 | 8518 /* |
8519 * ":psearch" | |
8520 */ | |
8521 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8522 ex_psearch(exarg_T *eap) |
7 | 8523 { |
8524 g_do_tagpreview = p_pvh; | |
8525 ex_findpat(eap); | |
8526 g_do_tagpreview = 0; | |
8527 } | |
8528 #endif | |
8529 | |
8530 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8531 ex_findpat(exarg_T *eap) |
7 | 8532 { |
8533 int whole = TRUE; | |
8534 long n; | |
8535 char_u *p; | |
8536 int action; | |
8537 | |
8538 switch (cmdnames[eap->cmdidx].cmd_name[2]) | |
8539 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8540 case 'e': // ":psearch", ":isearch" and ":dsearch" |
7 | 8541 if (cmdnames[eap->cmdidx].cmd_name[0] == 'p') |
8542 action = ACTION_GOTO; | |
8543 else | |
8544 action = ACTION_SHOW; | |
8545 break; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8546 case 'i': // ":ilist" and ":dlist" |
7 | 8547 action = ACTION_SHOW_ALL; |
8548 break; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8549 case 'u': // ":ijump" and ":djump" |
7 | 8550 action = ACTION_GOTO; |
8551 break; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8552 default: // ":isplit" and ":dsplit" |
7 | 8553 action = ACTION_SPLIT; |
8554 break; | |
8555 } | |
8556 | |
8557 n = 1; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8558 if (vim_isdigit(*eap->arg)) // get count |
7 | 8559 { |
8560 n = getdigits(&eap->arg); | |
8561 eap->arg = skipwhite(eap->arg); | |
8562 } | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8563 if (*eap->arg == '/') // Match regexp, not just whole words |
7 | 8564 { |
8565 whole = FALSE; | |
8566 ++eap->arg; | |
23272
a84e7abb0c92
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents:
23239
diff
changeset
|
8567 p = skip_regexp(eap->arg, '/', magic_isset()); |
7 | 8568 if (*p) |
8569 { | |
8570 *p++ = NUL; | |
8571 p = skipwhite(p); | |
8572 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8573 // Check for trailing illegal characters |
20111
f40231487a49
patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20097
diff
changeset
|
8574 if (!ends_excmd2(eap->arg, p)) |
21459
a422bd80b434
patch 8.2.1280: Ex command error cannot contain an argument
Bram Moolenaar <Bram@vim.org>
parents:
21413
diff
changeset
|
8575 eap->errmsg = ex_errmsg(e_trailing_arg, p); |
7 | 8576 else |
8577 eap->nextcmd = check_nextcmd(p); | |
8578 } | |
8579 } | |
8580 if (!eap->skip) | |
8581 find_pattern_in_path(eap->arg, 0, (int)STRLEN(eap->arg), | |
8582 whole, !eap->forceit, | |
8583 *eap->cmd == 'd' ? FIND_DEFINE : FIND_ANY, | |
8584 n, action, eap->line1, eap->line2); | |
8585 } | |
8586 #endif | |
8587 | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
8588 |
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
8589 #ifdef FEAT_QUICKFIX |
7 | 8590 /* |
8591 * ":ptag", ":ptselect", ":ptjump", ":ptnext", etc. | |
8592 */ | |
8593 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8594 ex_ptag(exarg_T *eap) |
7 | 8595 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8596 g_do_tagpreview = p_pvh; // will be reset to 0 in ex_tag_cmd() |
7 | 8597 ex_tag_cmd(eap, cmdnames[eap->cmdidx].cmd_name + 1); |
8598 } | |
8599 | |
8600 /* | |
8601 * ":pedit" | |
8602 */ | |
8603 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8604 ex_pedit(exarg_T *eap) |
7 | 8605 { |
8606 win_T *curwin_save = curwin; | |
8607 | |
19621
0d677257e35d
patch 8.2.0367: can use :pedit in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19575
diff
changeset
|
8608 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
|
8609 return; |
0d677257e35d
patch 8.2.0367: can use :pedit in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19575
diff
changeset
|
8610 |
17746
a4e488a6655c
patch 8.1.1870: using :pedit from a help file sets help filetype
Bram Moolenaar <Bram@vim.org>
parents:
17744
diff
changeset
|
8611 // Open the preview window or popup and make it the current window. |
7 | 8612 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
|
8613 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
|
8614 |
17746
a4e488a6655c
patch 8.1.1870: using :pedit from a help file sets help filetype
Bram Moolenaar <Bram@vim.org>
parents:
17744
diff
changeset
|
8615 // Edit the file. |
7 | 8616 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
|
8617 |
7 | 8618 if (curwin != curwin_save && win_valid(curwin_save)) |
8619 { | |
17746
a4e488a6655c
patch 8.1.1870: using :pedit from a help file sets help filetype
Bram Moolenaar <Bram@vim.org>
parents:
17744
diff
changeset
|
8620 // Return cursor to where we were |
7 | 8621 validate_cursor(); |
8622 redraw_later(VALID); | |
8623 win_enter(curwin_save, TRUE); | |
8624 } | |
18763
49b78d6465e5
patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents:
18715
diff
changeset
|
8625 # 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
|
8626 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
|
8627 { |
daa1dea1c1b3
patch 8.1.1819: :pedit does not work with a popup preview window
Bram Moolenaar <Bram@vim.org>
parents:
17622
diff
changeset
|
8628 // 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
|
8629 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
|
8630 } |
daa1dea1c1b3
patch 8.1.1819: :pedit does not work with a popup preview window
Bram Moolenaar <Bram@vim.org>
parents:
17622
diff
changeset
|
8631 # endif |
7 | 8632 g_do_tagpreview = 0; |
8633 } | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
8634 #endif |
7 | 8635 |
8636 /* | |
8637 * ":stag", ":stselect" and ":stjump". | |
8638 */ | |
8639 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8640 ex_stag(exarg_T *eap) |
7 | 8641 { |
8642 postponed_split = -1; | |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
8643 postponed_split_flags = cmdmod.cmod_split; |
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
22697
diff
changeset
|
8644 postponed_split_tab = cmdmod.cmod_tab; |
7 | 8645 ex_tag_cmd(eap, cmdnames[eap->cmdidx].cmd_name + 1); |
8646 postponed_split_flags = 0; | |
1090 | 8647 postponed_split_tab = 0; |
7 | 8648 } |
8649 | |
8650 /* | |
8651 * ":tag", ":tselect", ":tjump", ":tnext", etc. | |
8652 */ | |
8653 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8654 ex_tag(exarg_T *eap) |
7 | 8655 { |
8656 ex_tag_cmd(eap, cmdnames[eap->cmdidx].cmd_name); | |
8657 } | |
8658 | |
8659 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8660 ex_tag_cmd(exarg_T *eap, char_u *name) |
7 | 8661 { |
8662 int cmd; | |
8663 | |
8664 switch (name[1]) | |
8665 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8666 case 'j': cmd = DT_JUMP; // ":tjump" |
7 | 8667 break; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8668 case 's': cmd = DT_SELECT; // ":tselect" |
7 | 8669 break; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8670 case 'p': cmd = DT_PREV; // ":tprevious" |
7 | 8671 break; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8672 case 'N': cmd = DT_PREV; // ":tNext" |
7 | 8673 break; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8674 case 'n': cmd = DT_NEXT; // ":tnext" |
7 | 8675 break; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8676 case 'o': cmd = DT_POP; // ":pop" |
7 | 8677 break; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8678 case 'f': // ":tfirst" |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8679 case 'r': cmd = DT_FIRST; // ":trewind" |
7 | 8680 break; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8681 case 'l': cmd = DT_LAST; // ":tlast" |
7 | 8682 break; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8683 default: // ":tag" |
7 | 8684 #ifdef FEAT_CSCOPE |
1603 | 8685 if (p_cst && *eap->arg != NUL) |
7 | 8686 { |
10373
bd674706408a
commit https://github.com/vim/vim/commit/d4db7719bdfbc54df396eac08d8cbb2389feacf4
Christian Brabandt <cb@256bit.org>
parents:
10361
diff
changeset
|
8687 ex_cstag(eap); |
7 | 8688 return; |
8689 } | |
8690 #endif | |
8691 cmd = DT_TAG; | |
8692 break; | |
8693 } | |
8694 | |
649 | 8695 if (name[0] == 'l') |
8696 { | |
8697 #ifndef FEAT_QUICKFIX | |
8698 ex_ni(eap); | |
8699 return; | |
8700 #else | |
8701 cmd = DT_LTAG; | |
8702 #endif | |
8703 } | |
8704 | |
7 | 8705 do_tag(eap->arg, cmd, eap->addr_count > 0 ? (int)eap->line2 : 1, |
8706 eap->forceit, TRUE); | |
8707 } | |
8708 | |
8709 /* | |
1661 | 8710 * Check "str" for starting with a special cmdline variable. |
8711 * If found return one of the SPEC_ values and set "*usedlen" to the length of | |
8712 * the variable. Otherwise return -1 and "*usedlen" is unchanged. | |
8713 */ | |
8714 int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8715 find_cmdline_var(char_u *src, int *usedlen) |
1661 | 8716 { |
8717 int len; | |
8718 int i; | |
1879 | 8719 static char *(spec_str[]) = { |
1661 | 8720 "%", |
8721 #define SPEC_PERC 0 | |
8722 "#", | |
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
|
8723 #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
|
8724 "<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
|
8725 #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
|
8726 "<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
|
8727 #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
|
8728 "<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
|
8729 #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
|
8730 "<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
|
8731 #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
|
8732 "<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
|
8733 #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
|
8734 "<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
|
8735 #define SPEC_SLNUM (SPEC_SFILE + 1) |
21493
7449921216bc
patch 8.2.1297: when a test fails it's often not easy to see where
Bram Moolenaar <Bram@vim.org>
parents:
21487
diff
changeset
|
8736 "<stack>", // call stack |
7449921216bc
patch 8.2.1297: when a test fails it's often not easy to see where
Bram Moolenaar <Bram@vim.org>
parents:
21487
diff
changeset
|
8737 #define SPEC_STACK (SPEC_SLNUM + 1) |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8738 "<afile>", // autocommand file name |
21493
7449921216bc
patch 8.2.1297: when a test fails it's often not easy to see where
Bram Moolenaar <Bram@vim.org>
parents:
21487
diff
changeset
|
8739 #define SPEC_AFILE (SPEC_STACK + 1) |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8740 "<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
|
8741 #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
|
8742 "<amatch>", // autocommand match name |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
8743 #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
|
8744 "<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
|
8745 #define SPEC_SFLNUM (SPEC_AMATCH + 1) |
21594
5daca8504c63
patch 8.2.1347: cannot easily get the script ID
Bram Moolenaar <Bram@vim.org>
parents:
21592
diff
changeset
|
8746 "<SID>", // script ID: <SNR>123_ |
5daca8504c63
patch 8.2.1347: cannot easily get the script ID
Bram Moolenaar <Bram@vim.org>
parents:
21592
diff
changeset
|
8747 #define SPEC_SID (SPEC_SFLNUM + 1) |
1661 | 8748 #ifdef FEAT_CLIENTSERVER |
8749 "<client>" | |
21594
5daca8504c63
patch 8.2.1347: cannot easily get the script ID
Bram Moolenaar <Bram@vim.org>
parents:
21592
diff
changeset
|
8750 # define SPEC_CLIENT (SPEC_SID + 1) |
1661 | 8751 #endif |
8752 }; | |
1872 | 8753 |
24768
7334bf933510
patch 8.2.2922: computing array length is done in various ways
Bram Moolenaar <Bram@vim.org>
parents:
24723
diff
changeset
|
8754 for (i = 0; i < (int)ARRAY_LENGTH(spec_str); ++i) |
1661 | 8755 { |
8756 len = (int)STRLEN(spec_str[i]); | |
8757 if (STRNCMP(src, spec_str[i], len) == 0) | |
8758 { | |
8759 *usedlen = len; | |
8760 return i; | |
8761 } | |
8762 } | |
8763 return -1; | |
8764 } | |
8765 | |
8766 /* | |
7 | 8767 * Evaluate cmdline variables. |
8768 * | |
23370
622e90acea5d
patch 8.2.2228: Vim9: cannot use ":e #" because # starts a comment
Bram Moolenaar <Bram@vim.org>
parents:
23358
diff
changeset
|
8769 * change "%" to curbuf->b_ffname |
622e90acea5d
patch 8.2.2228: Vim9: cannot use ":e #" because # starts a comment
Bram Moolenaar <Bram@vim.org>
parents:
23358
diff
changeset
|
8770 * "#" to curwin->w_alt_fnum |
622e90acea5d
patch 8.2.2228: Vim9: cannot use ":e #" because # starts a comment
Bram Moolenaar <Bram@vim.org>
parents:
23358
diff
changeset
|
8771 * "%%" to curwin->w_alt_fnum in Vim9 script |
622e90acea5d
patch 8.2.2228: Vim9: cannot use ":e #" because # starts a comment
Bram Moolenaar <Bram@vim.org>
parents:
23358
diff
changeset
|
8772 * "<cword>" to word under the cursor |
622e90acea5d
patch 8.2.2228: Vim9: cannot use ":e #" because # starts a comment
Bram Moolenaar <Bram@vim.org>
parents:
23358
diff
changeset
|
8773 * "<cWORD>" to WORD under the cursor |
622e90acea5d
patch 8.2.2228: Vim9: cannot use ":e #" because # starts a comment
Bram Moolenaar <Bram@vim.org>
parents:
23358
diff
changeset
|
8774 * "<cexpr>" to C-expression under the cursor |
622e90acea5d
patch 8.2.2228: Vim9: cannot use ":e #" because # starts a comment
Bram Moolenaar <Bram@vim.org>
parents:
23358
diff
changeset
|
8775 * "<cfile>" to path name under the cursor |
622e90acea5d
patch 8.2.2228: Vim9: cannot use ":e #" because # starts a comment
Bram Moolenaar <Bram@vim.org>
parents:
23358
diff
changeset
|
8776 * "<sfile>" to sourced file name |
622e90acea5d
patch 8.2.2228: Vim9: cannot use ":e #" because # starts a comment
Bram Moolenaar <Bram@vim.org>
parents:
23358
diff
changeset
|
8777 * "<stack>" to call stack |
622e90acea5d
patch 8.2.2228: Vim9: cannot use ":e #" because # starts a comment
Bram Moolenaar <Bram@vim.org>
parents:
23358
diff
changeset
|
8778 * "<slnum>" to sourced file line number |
622e90acea5d
patch 8.2.2228: Vim9: cannot use ":e #" because # starts a comment
Bram Moolenaar <Bram@vim.org>
parents:
23358
diff
changeset
|
8779 * "<afile>" to file name for autocommand |
622e90acea5d
patch 8.2.2228: Vim9: cannot use ":e #" because # starts a comment
Bram Moolenaar <Bram@vim.org>
parents:
23358
diff
changeset
|
8780 * "<abuf>" to buffer number for autocommand |
622e90acea5d
patch 8.2.2228: Vim9: cannot use ":e #" because # starts a comment
Bram Moolenaar <Bram@vim.org>
parents:
23358
diff
changeset
|
8781 * "<amatch>" to matching name for autocommand |
7 | 8782 * |
8783 * When an error is detected, "errormsg" is set to a non-NULL pointer (may be | |
8784 * "" for error without a message) and NULL is returned. | |
8785 * Returns an allocated string if a valid match was found. | |
8786 * Returns NULL if no match was found. "usedlen" then still contains the | |
8787 * number of characters to skip. | |
8788 */ | |
8789 char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8790 eval_vars( |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8791 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
|
8792 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
|
8793 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
|
8794 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
|
8795 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
|
8796 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
|
8797 // be NULL) |
7 | 8798 { |
8799 int i; | |
8800 char_u *s; | |
8801 char_u *result; | |
8802 char_u *resultbuf = NULL; | |
8803 int resultlen; | |
8804 buf_T *buf; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8805 int valid = VALID_HEAD + VALID_PATH; // assume valid result |
7 | 8806 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
|
8807 int tilde_file = FALSE; |
7 | 8808 int skip_mod = FALSE; |
8809 char_u strbuf[30]; | |
8810 | |
8811 *errormsg = NULL; | |
1098 | 8812 if (escaped != NULL) |
8813 *escaped = FALSE; | |
7 | 8814 |
8815 /* | |
8816 * Check if there is something to do. | |
8817 */ | |
1661 | 8818 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
|
8819 if (spec_idx < 0) // no match |
7 | 8820 { |
8821 *usedlen = 1; | |
8822 return NULL; | |
8823 } | |
8824 | |
8825 /* | |
8826 * Skip when preceded with a backslash "\%" and "\#". | |
8827 * Note: In "\\%" the % is also not recognized! | |
8828 */ | |
8829 if (src > srcstart && src[-1] == '\\') | |
8830 { | |
8831 *usedlen = 0; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8832 STRMOVE(src - 1, src); // remove backslash |
7 | 8833 return NULL; |
8834 } | |
8835 | |
8836 /* | |
8837 * word or WORD under cursor | |
8838 */ | |
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
|
8839 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
|
8840 || 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
|
8841 { |
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
|
8842 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
|
8843 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
|
8844 : 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
|
8845 : FIND_STRING); |
7 | 8846 if (resultlen == 0) |
8847 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8848 *errormsg = ""; |
7 | 8849 return NULL; |
8850 } | |
8851 } | |
8852 | |
8853 /* | |
8854 * '#': Alternate file name | |
8855 * '%': Current file name | |
8856 * File name under the cursor | |
8857 * File name for autocommand | |
8858 * and following modifiers | |
8859 */ | |
8860 else | |
8861 { | |
23370
622e90acea5d
patch 8.2.2228: Vim9: cannot use ":e #" because # starts a comment
Bram Moolenaar <Bram@vim.org>
parents:
23358
diff
changeset
|
8862 int off = 0; |
622e90acea5d
patch 8.2.2228: Vim9: cannot use ":e #" because # starts a comment
Bram Moolenaar <Bram@vim.org>
parents:
23358
diff
changeset
|
8863 |
7 | 8864 switch (spec_idx) |
8865 { | |
23370
622e90acea5d
patch 8.2.2228: Vim9: cannot use ":e #" because # starts a comment
Bram Moolenaar <Bram@vim.org>
parents:
23358
diff
changeset
|
8866 case SPEC_PERC: |
23372
86d155b29dd7
patch 8.2.2229: build failure without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
23370
diff
changeset
|
8867 #ifdef FEAT_EVAL |
23370
622e90acea5d
patch 8.2.2228: Vim9: cannot use ":e #" because # starts a comment
Bram Moolenaar <Bram@vim.org>
parents:
23358
diff
changeset
|
8868 if (!in_vim9script() || src[1] != '%') |
23372
86d155b29dd7
patch 8.2.2229: build failure without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
23370
diff
changeset
|
8869 #endif |
7 | 8870 { |
23370
622e90acea5d
patch 8.2.2228: Vim9: cannot use ":e #" because # starts a comment
Bram Moolenaar <Bram@vim.org>
parents:
23358
diff
changeset
|
8871 // '%': current file |
622e90acea5d
patch 8.2.2228: Vim9: cannot use ":e #" because # starts a comment
Bram Moolenaar <Bram@vim.org>
parents:
23358
diff
changeset
|
8872 if (curbuf->b_fname == NULL) |
622e90acea5d
patch 8.2.2228: Vim9: cannot use ":e #" because # starts a comment
Bram Moolenaar <Bram@vim.org>
parents:
23358
diff
changeset
|
8873 { |
622e90acea5d
patch 8.2.2228: Vim9: cannot use ":e #" because # starts a comment
Bram Moolenaar <Bram@vim.org>
parents:
23358
diff
changeset
|
8874 result = (char_u *)""; |
622e90acea5d
patch 8.2.2228: Vim9: cannot use ":e #" because # starts a comment
Bram Moolenaar <Bram@vim.org>
parents:
23358
diff
changeset
|
8875 valid = 0; // Must have ":p:h" to be valid |
622e90acea5d
patch 8.2.2228: Vim9: cannot use ":e #" because # starts a comment
Bram Moolenaar <Bram@vim.org>
parents:
23358
diff
changeset
|
8876 } |
622e90acea5d
patch 8.2.2228: Vim9: cannot use ":e #" because # starts a comment
Bram Moolenaar <Bram@vim.org>
parents:
23358
diff
changeset
|
8877 else |
622e90acea5d
patch 8.2.2228: Vim9: cannot use ":e #" because # starts a comment
Bram Moolenaar <Bram@vim.org>
parents:
23358
diff
changeset
|
8878 { |
622e90acea5d
patch 8.2.2228: Vim9: cannot use ":e #" because # starts a comment
Bram Moolenaar <Bram@vim.org>
parents:
23358
diff
changeset
|
8879 result = curbuf->b_fname; |
622e90acea5d
patch 8.2.2228: Vim9: cannot use ":e #" because # starts a comment
Bram Moolenaar <Bram@vim.org>
parents:
23358
diff
changeset
|
8880 tilde_file = STRCMP(result, "~") == 0; |
622e90acea5d
patch 8.2.2228: Vim9: cannot use ":e #" because # starts a comment
Bram Moolenaar <Bram@vim.org>
parents:
23358
diff
changeset
|
8881 } |
622e90acea5d
patch 8.2.2228: Vim9: cannot use ":e #" because # starts a comment
Bram Moolenaar <Bram@vim.org>
parents:
23358
diff
changeset
|
8882 break; |
7 | 8883 } |
23372
86d155b29dd7
patch 8.2.2229: build failure without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents:
23370
diff
changeset
|
8884 #ifdef FEAT_EVAL |
23370
622e90acea5d
patch 8.2.2228: Vim9: cannot use ":e #" because # starts a comment
Bram Moolenaar <Bram@vim.org>
parents:
23358
diff
changeset
|
8885 // "%%" alternate file |
622e90acea5d
patch 8.2.2228: Vim9: cannot use ":e #" because # starts a comment
Bram Moolenaar <Bram@vim.org>
parents:
23358
diff
changeset
|
8886 off = 1; |
23378
8e956ea07bb2
patch 8.2.2232: compiler error for falling through into next case
Bram Moolenaar <Bram@vim.org>
parents:
23372
diff
changeset
|
8887 #endif |
23370
622e90acea5d
patch 8.2.2228: Vim9: cannot use ":e #" because # starts a comment
Bram Moolenaar <Bram@vim.org>
parents:
23358
diff
changeset
|
8888 // FALLTHROUGH |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8889 case SPEC_HASH: // '#' or "#99": alternate file |
23370
622e90acea5d
patch 8.2.2228: Vim9: cannot use ":e #" because # starts a comment
Bram Moolenaar <Bram@vim.org>
parents:
23358
diff
changeset
|
8890 if (off == 0 ? src[1] == '#' : src[2] == '%') |
7 | 8891 { |
23370
622e90acea5d
patch 8.2.2228: Vim9: cannot use ":e #" because # starts a comment
Bram Moolenaar <Bram@vim.org>
parents:
23358
diff
changeset
|
8892 // "##" or "%%%": the argument list |
7 | 8893 result = arg_all(); |
8894 resultbuf = result; | |
23370
622e90acea5d
patch 8.2.2228: Vim9: cannot use ":e #" because # starts a comment
Bram Moolenaar <Bram@vim.org>
parents:
23358
diff
changeset
|
8895 *usedlen = off + 2; |
1098 | 8896 if (escaped != NULL) |
8897 *escaped = TRUE; | |
7 | 8898 skip_mod = TRUE; |
8899 break; | |
8900 } | |
23370
622e90acea5d
patch 8.2.2228: Vim9: cannot use ":e #" because # starts a comment
Bram Moolenaar <Bram@vim.org>
parents:
23358
diff
changeset
|
8901 s = src + off + 1; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8902 if (*s == '<') // "#<99" uses v:oldfiles |
1733 | 8903 ++s; |
7 | 8904 i = (int)getdigits(&s); |
23370
622e90acea5d
patch 8.2.2228: Vim9: cannot use ":e #" because # starts a comment
Bram Moolenaar <Bram@vim.org>
parents:
23358
diff
changeset
|
8905 if (s == src + off + 2 && src[off + 1] == '-') |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8906 // 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
|
8907 s--; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8908 *usedlen = (int)(s - src); // length of what we expand |
7 | 8909 |
23370
622e90acea5d
patch 8.2.2228: Vim9: cannot use ":e #" because # starts a comment
Bram Moolenaar <Bram@vim.org>
parents:
23358
diff
changeset
|
8910 if (src[off + 1] == '<' && i != 0) |
7 | 8911 { |
23370
622e90acea5d
patch 8.2.2228: Vim9: cannot use ":e #" because # starts a comment
Bram Moolenaar <Bram@vim.org>
parents:
23358
diff
changeset
|
8912 if (*usedlen < off + 2) |
1733 | 8913 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8914 // Should we give an error message for #<text? |
23370
622e90acea5d
patch 8.2.2228: Vim9: cannot use ":e #" because # starts a comment
Bram Moolenaar <Bram@vim.org>
parents:
23358
diff
changeset
|
8915 *usedlen = off + 1; |
1733 | 8916 return NULL; |
8917 } | |
8918 #ifdef FEAT_EVAL | |
8919 result = list_find_str(get_vim_var_list(VV_OLDFILES), | |
8920 (long)i); | |
8921 if (result == NULL) | |
8922 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8923 *errormsg = ""; |
1733 | 8924 return NULL; |
8925 } | |
8926 #else | |
15488
da8b98c008bf
patch 8.1.0752: one more compiler warning for signed/unsigned string
Bram Moolenaar <Bram@vim.org>
parents:
15474
diff
changeset
|
8927 *errormsg = _("E809: #< is not available without the +eval feature"); |
7 | 8928 return NULL; |
1733 | 8929 #endif |
7 | 8930 } |
8931 else | |
1733 | 8932 { |
23370
622e90acea5d
patch 8.2.2228: Vim9: cannot use ":e #" because # starts a comment
Bram Moolenaar <Bram@vim.org>
parents:
23358
diff
changeset
|
8933 if (i == 0 && src[off + 1] == '<' && *usedlen > off + 1) |
622e90acea5d
patch 8.2.2228: Vim9: cannot use ":e #" because # starts a comment
Bram Moolenaar <Bram@vim.org>
parents:
23358
diff
changeset
|
8934 *usedlen = off + 1; |
1733 | 8935 buf = buflist_findnr(i); |
8936 if (buf == NULL) | |
8937 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8938 *errormsg = _("E194: No alternate file name to substitute for '#'"); |
1733 | 8939 return NULL; |
8940 } | |
8941 if (lnump != NULL) | |
8942 *lnump = ECMD_LAST; | |
8943 if (buf->b_fname == NULL) | |
8944 { | |
8945 result = (char_u *)""; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8946 valid = 0; // Must have ":p:h" to be valid |
1733 | 8947 } |
8948 else | |
14393
c62601adad69
patch 8.1.0211: expanding a file name "~" results in $HOME
Christian Brabandt <cb@256bit.org>
parents:
14286
diff
changeset
|
8949 { |
1733 | 8950 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
|
8951 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
|
8952 } |
1733 | 8953 } |
7 | 8954 break; |
8955 | |
8956 #ifdef FEAT_SEARCHPATH | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8957 case SPEC_CFILE: // file name under cursor |
681 | 8958 result = file_name_at_cursor(FNAME_MESS|FNAME_HYP, 1L, NULL); |
7 | 8959 if (result == NULL) |
8960 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8961 *errormsg = ""; |
7 | 8962 return NULL; |
8963 } | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8964 resultbuf = result; // remember allocated string |
7 | 8965 break; |
8966 #endif | |
8967 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8968 case SPEC_AFILE: // file name for autocommand |
7 | 8969 result = autocmd_fname; |
1723 | 8970 if (result != NULL && !autocmd_fname_full) |
8971 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8972 // 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
|
8973 // postponed to avoid a delay when <afile> is not used. |
1723 | 8974 autocmd_fname_full = TRUE; |
8975 result = FullName_save(autocmd_fname, FALSE); | |
8976 vim_free(autocmd_fname); | |
8977 autocmd_fname = result; | |
8978 } | |
7 | 8979 if (result == NULL) |
8980 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8981 *errormsg = _("E495: no autocommand file name to substitute for \"<afile>\""); |
7 | 8982 return NULL; |
8983 } | |
1471 | 8984 result = shorten_fname1(result); |
7 | 8985 break; |
8986 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8987 case SPEC_ABUF: // buffer number for autocommand |
7 | 8988 if (autocmd_bufnr <= 0) |
8989 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8990 *errormsg = _("E496: no autocommand buffer number to substitute for \"<abuf>\""); |
7 | 8991 return NULL; |
8992 } | |
8993 sprintf((char *)strbuf, "%d", autocmd_bufnr); | |
8994 result = strbuf; | |
8995 break; | |
8996 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8997 case SPEC_AMATCH: // match name for autocommand |
7 | 8998 result = autocmd_match; |
8999 if (result == NULL) | |
9000 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
9001 *errormsg = _("E497: no autocommand match name to substitute for \"<amatch>\""); |
7 | 9002 return NULL; |
9003 } | |
9004 break; | |
9005 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
9006 case SPEC_SFILE: // file name for ":so" command |
21493
7449921216bc
patch 8.2.1297: when a test fails it's often not easy to see where
Bram Moolenaar <Bram@vim.org>
parents:
21487
diff
changeset
|
9007 case SPEC_STACK: // call stack |
22208
a607f02fd17a
patch 8.2.1653: expand('<stack>') does not include the final line number
Bram Moolenaar <Bram@vim.org>
parents:
22176
diff
changeset
|
9008 result = estack_sfile(spec_idx == SPEC_SFILE |
a607f02fd17a
patch 8.2.1653: expand('<stack>') does not include the final line number
Bram Moolenaar <Bram@vim.org>
parents:
22176
diff
changeset
|
9009 ? ESTACK_SFILE : ESTACK_STACK); |
7 | 9010 if (result == NULL) |
9011 { | |
21493
7449921216bc
patch 8.2.1297: when a test fails it's often not easy to see where
Bram Moolenaar <Bram@vim.org>
parents:
21487
diff
changeset
|
9012 *errormsg = spec_idx == SPEC_SFILE |
7449921216bc
patch 8.2.1297: when a test fails it's often not easy to see where
Bram Moolenaar <Bram@vim.org>
parents:
21487
diff
changeset
|
9013 ? _("E498: no :source file name to substitute for \"<sfile>\"") |
7449921216bc
patch 8.2.1297: when a test fails it's often not easy to see where
Bram Moolenaar <Bram@vim.org>
parents:
21487
diff
changeset
|
9014 : _("E489: no call stack to substitute for \"<stack>\""); |
7 | 9015 return NULL; |
9016 } | |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18904
diff
changeset
|
9017 resultbuf = result; // remember allocated string |
7 | 9018 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
|
9019 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
9020 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
|
9021 if (SOURCING_NAME == NULL || SOURCING_LNUM == 0) |
2645 | 9022 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
9023 *errormsg = _("E842: no line number to use for \"<slnum>\""); |
2645 | 9024 return NULL; |
9025 } | |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18904
diff
changeset
|
9026 sprintf((char *)strbuf, "%ld", SOURCING_LNUM); |
2645 | 9027 result = strbuf; |
9028 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
|
9029 |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14677
diff
changeset
|
9030 #ifdef FEAT_EVAL |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
9031 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
|
9032 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
|
9033 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
9034 *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
|
9035 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
|
9036 } |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14677
diff
changeset
|
9037 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
|
9038 (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
|
9039 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
|
9040 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
|
9041 |
21594
5daca8504c63
patch 8.2.1347: cannot easily get the script ID
Bram Moolenaar <Bram@vim.org>
parents:
21592
diff
changeset
|
9042 case SPEC_SID: |
5daca8504c63
patch 8.2.1347: cannot easily get the script ID
Bram Moolenaar <Bram@vim.org>
parents:
21592
diff
changeset
|
9043 if (current_sctx.sc_sid <= 0) |
5daca8504c63
patch 8.2.1347: cannot easily get the script ID
Bram Moolenaar <Bram@vim.org>
parents:
21592
diff
changeset
|
9044 { |
5daca8504c63
patch 8.2.1347: cannot easily get the script ID
Bram Moolenaar <Bram@vim.org>
parents:
21592
diff
changeset
|
9045 *errormsg = _(e_usingsid); |
5daca8504c63
patch 8.2.1347: cannot easily get the script ID
Bram Moolenaar <Bram@vim.org>
parents:
21592
diff
changeset
|
9046 return NULL; |
5daca8504c63
patch 8.2.1347: cannot easily get the script ID
Bram Moolenaar <Bram@vim.org>
parents:
21592
diff
changeset
|
9047 } |
5daca8504c63
patch 8.2.1347: cannot easily get the script ID
Bram Moolenaar <Bram@vim.org>
parents:
21592
diff
changeset
|
9048 sprintf((char *)strbuf, "<SNR>%d_", current_sctx.sc_sid); |
5daca8504c63
patch 8.2.1347: cannot easily get the script ID
Bram Moolenaar <Bram@vim.org>
parents:
21592
diff
changeset
|
9049 result = strbuf; |
5daca8504c63
patch 8.2.1347: cannot easily get the script ID
Bram Moolenaar <Bram@vim.org>
parents:
21592
diff
changeset
|
9050 break; |
21596
c18d00494b60
patch 8.2.1348: build failure without the eval feature
Bram Moolenaar <Bram@vim.org>
parents:
21594
diff
changeset
|
9051 #endif |
21594
5daca8504c63
patch 8.2.1347: cannot easily get the script ID
Bram Moolenaar <Bram@vim.org>
parents:
21592
diff
changeset
|
9052 |
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
|
9053 #ifdef FEAT_CLIENTSERVER |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
9054 case SPEC_CLIENT: // Source of last submitted input |
840 | 9055 sprintf((char *)strbuf, PRINTF_HEX_LONG_U, |
9056 (long_u)clientWindow); | |
7 | 9057 result = strbuf; |
9058 break; | |
9059 #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
|
9060 |
11428
346168f2a6cb
patch 8.0.0598: building with gcc 7.1 yields new warnings
Christian Brabandt <cb@256bit.org>
parents:
11374
diff
changeset
|
9061 default: |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
9062 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
|
9063 break; |
7 | 9064 } |
9065 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
9066 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
|
9067 if (src[*usedlen] == '<') // remove the file name extension |
7 | 9068 { |
9069 ++*usedlen; | |
9070 if ((s = vim_strrchr(result, '.')) != NULL && s >= gettail(result)) | |
9071 resultlen = (int)(s - result); | |
9072 } | |
9073 else if (!skip_mod) | |
9074 { | |
14393
c62601adad69
patch 8.1.0211: expanding a file name "~" results in $HOME
Christian Brabandt <cb@256bit.org>
parents:
14286
diff
changeset
|
9075 valid |= modify_fname(src, tilde_file, usedlen, &result, &resultbuf, |
7 | 9076 &resultlen); |
9077 if (result == NULL) | |
9078 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
9079 *errormsg = ""; |
7 | 9080 return NULL; |
9081 } | |
9082 } | |
9083 } | |
9084 | |
9085 if (resultlen == 0 || valid != VALID_HEAD + VALID_PATH) | |
9086 { | |
9087 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
|
9088 // 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
|
9089 *errormsg = _("E499: Empty file name for '%' or '#', only works with \":p:h\""); |
7 | 9090 else |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
9091 *errormsg = _("E500: Evaluates to an empty string"); |
7 | 9092 result = NULL; |
9093 } | |
9094 else | |
9095 result = vim_strnsave(result, resultlen); | |
9096 vim_free(resultbuf); | |
9097 return result; | |
9098 } | |
9099 | |
9100 /* | |
9101 * Expand the <sfile> string in "arg". | |
9102 * | |
9103 * Returns an allocated string, or NULL for any error. | |
9104 */ | |
9105 char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
9106 expand_sfile(char_u *arg) |
7 | 9107 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
9108 char *errormsg; |
7 | 9109 int len; |
9110 char_u *result; | |
9111 char_u *newres; | |
9112 char_u *repl; | |
9113 int srclen; | |
9114 char_u *p; | |
9115 | |
9116 result = vim_strsave(arg); | |
9117 if (result == NULL) | |
9118 return NULL; | |
9119 | |
9120 for (p = result; *p; ) | |
9121 { | |
9122 if (STRNCMP(p, "<sfile>", 7) != 0) | |
9123 ++p; | |
9124 else | |
9125 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
9126 // replace "<sfile>" with the sourced file name, and do ":" stuff |
1098 | 9127 repl = eval_vars(p, result, &srclen, NULL, &errormsg, NULL); |
7 | 9128 if (errormsg != NULL) |
9129 { | |
9130 if (*errormsg) | |
9131 emsg(errormsg); | |
9132 vim_free(result); | |
9133 return NULL; | |
9134 } | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
9135 if (repl == NULL) // no match (cannot happen) |
7 | 9136 { |
9137 p += srclen; | |
9138 continue; | |
9139 } | |
9140 len = (int)STRLEN(result) - srclen + (int)STRLEN(repl) + 1; | |
9141 newres = alloc(len); | |
9142 if (newres == NULL) | |
9143 { | |
9144 vim_free(repl); | |
9145 vim_free(result); | |
9146 return NULL; | |
9147 } | |
9148 mch_memmove(newres, result, (size_t)(p - result)); | |
9149 STRCPY(newres + (p - result), repl); | |
9150 len = (int)STRLEN(newres); | |
9151 STRCAT(newres, p + srclen); | |
9152 vim_free(repl); | |
9153 vim_free(result); | |
9154 result = newres; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
9155 p = newres + len; // continue after the match |
7 | 9156 } |
9157 } | |
9158 | |
9159 return result; | |
9160 } | |
9161 | |
9162 #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) || defined(PROTO) | |
272 | 9163 /* |
2770 | 9164 * Make a dialog message in "buff[DIALOG_MSG_SIZE]". |
310 | 9165 * "format" must contain "%s". |
272 | 9166 */ |
7 | 9167 void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
9168 dialog_msg(char_u *buff, char *format, char_u *fname) |
7 | 9169 { |
9170 if (fname == NULL) | |
9171 fname = (char_u *)_("Untitled"); | |
2770 | 9172 vim_snprintf((char *)buff, DIALOG_MSG_SIZE, format, fname); |
7 | 9173 } |
9174 #endif | |
9175 | |
9176 /* | |
9177 * ":behave {mswin,xterm}" | |
9178 */ | |
9179 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
9180 ex_behave(exarg_T *eap) |
7 | 9181 { |
9182 if (STRCMP(eap->arg, "mswin") == 0) | |
9183 { | |
9184 set_option_value((char_u *)"selection", 0L, (char_u *)"exclusive", 0); | |
9185 set_option_value((char_u *)"selectmode", 0L, (char_u *)"mouse,key", 0); | |
9186 set_option_value((char_u *)"mousemodel", 0L, (char_u *)"popup", 0); | |
9187 set_option_value((char_u *)"keymodel", 0L, | |
9188 (char_u *)"startsel,stopsel", 0); | |
9189 } | |
9190 else if (STRCMP(eap->arg, "xterm") == 0) | |
9191 { | |
9192 set_option_value((char_u *)"selection", 0L, (char_u *)"inclusive", 0); | |
9193 set_option_value((char_u *)"selectmode", 0L, (char_u *)"", 0); | |
9194 set_option_value((char_u *)"mousemodel", 0L, (char_u *)"extend", 0); | |
9195 set_option_value((char_u *)"keymodel", 0L, (char_u *)"", 0); | |
9196 } | |
9197 else | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
9198 semsg(_(e_invarg2), eap->arg); |
7 | 9199 } |
9200 | |
9201 static int filetype_detect = FALSE; | |
9202 static int filetype_plugin = FALSE; | |
9203 static int filetype_indent = FALSE; | |
9204 | |
9205 /* | |
9206 * ":filetype [plugin] [indent] {on,off,detect}" | |
9207 * on: Load the filetype.vim file to install autocommands for file types. | |
9208 * off: Load the ftoff.vim file to remove all autocommands for file types. | |
9209 * plugin on: load filetype.vim and ftplugin.vim | |
9210 * plugin off: load ftplugof.vim | |
9211 * indent on: load filetype.vim and indent.vim | |
9212 * indent off: load indoff.vim | |
9213 */ | |
9214 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
9215 ex_filetype(exarg_T *eap) |
7 | 9216 { |
9217 char_u *arg = eap->arg; | |
9218 int plugin = FALSE; | |
9219 int indent = FALSE; | |
9220 | |
9221 if (*eap->arg == NUL) | |
9222 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
9223 // Print current status. |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
9224 smsg("filetype detection:%s plugin:%s indent:%s", |
7 | 9225 filetype_detect ? "ON" : "OFF", |
9226 filetype_plugin ? (filetype_detect ? "ON" : "(on)") : "OFF", | |
9227 filetype_indent ? (filetype_detect ? "ON" : "(on)") : "OFF"); | |
9228 return; | |
9229 } | |
9230 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
9231 // Accept "plugin" and "indent" in any order. |
7 | 9232 for (;;) |
9233 { | |
9234 if (STRNCMP(arg, "plugin", 6) == 0) | |
9235 { | |
9236 plugin = TRUE; | |
9237 arg = skipwhite(arg + 6); | |
9238 continue; | |
9239 } | |
9240 if (STRNCMP(arg, "indent", 6) == 0) | |
9241 { | |
9242 indent = TRUE; | |
9243 arg = skipwhite(arg + 6); | |
9244 continue; | |
9245 } | |
9246 break; | |
9247 } | |
9248 if (STRCMP(arg, "on") == 0 || STRCMP(arg, "detect") == 0) | |
9249 { | |
9250 if (*arg == 'o' || !filetype_detect) | |
9251 { | |
8524
2f57bbe870ea
commit https://github.com/vim/vim/commit/7f8989dd8a627af2185df381195351a913f3777f
Christian Brabandt <cb@256bit.org>
parents:
8402
diff
changeset
|
9252 source_runtime((char_u *)FILETYPE_FILE, DIP_ALL); |
7 | 9253 filetype_detect = TRUE; |
9254 if (plugin) | |
9255 { | |
8524
2f57bbe870ea
commit https://github.com/vim/vim/commit/7f8989dd8a627af2185df381195351a913f3777f
Christian Brabandt <cb@256bit.org>
parents:
8402
diff
changeset
|
9256 source_runtime((char_u *)FTPLUGIN_FILE, DIP_ALL); |
7 | 9257 filetype_plugin = TRUE; |
9258 } | |
9259 if (indent) | |
9260 { | |
8524
2f57bbe870ea
commit https://github.com/vim/vim/commit/7f8989dd8a627af2185df381195351a913f3777f
Christian Brabandt <cb@256bit.org>
parents:
8402
diff
changeset
|
9261 source_runtime((char_u *)INDENT_FILE, DIP_ALL); |
7 | 9262 filetype_indent = TRUE; |
9263 } | |
9264 } | |
9265 if (*arg == 'd') | |
9266 { | |
9260
ac8180818504
commit https://github.com/vim/vim/commit/1610d052413e0ed664498853a47acc2d677a22d1
Christian Brabandt <cb@256bit.org>
parents:
9230
diff
changeset
|
9267 (void)do_doautocmd((char_u *)"filetypedetect BufRead", TRUE, NULL); |
717 | 9268 do_modelines(0); |
7 | 9269 } |
9270 } | |
9271 else if (STRCMP(arg, "off") == 0) | |
9272 { | |
9273 if (plugin || indent) | |
9274 { | |
9275 if (plugin) | |
9276 { | |
8524
2f57bbe870ea
commit https://github.com/vim/vim/commit/7f8989dd8a627af2185df381195351a913f3777f
Christian Brabandt <cb@256bit.org>
parents:
8402
diff
changeset
|
9277 source_runtime((char_u *)FTPLUGOF_FILE, DIP_ALL); |
7 | 9278 filetype_plugin = FALSE; |
9279 } | |
9280 if (indent) | |
9281 { | |
8524
2f57bbe870ea
commit https://github.com/vim/vim/commit/7f8989dd8a627af2185df381195351a913f3777f
Christian Brabandt <cb@256bit.org>
parents:
8402
diff
changeset
|
9282 source_runtime((char_u *)INDOFF_FILE, DIP_ALL); |
7 | 9283 filetype_indent = FALSE; |
9284 } | |
9285 } | |
9286 else | |
9287 { | |
8524
2f57bbe870ea
commit https://github.com/vim/vim/commit/7f8989dd8a627af2185df381195351a913f3777f
Christian Brabandt <cb@256bit.org>
parents:
8402
diff
changeset
|
9288 source_runtime((char_u *)FTOFF_FILE, DIP_ALL); |
7 | 9289 filetype_detect = FALSE; |
9290 } | |
9291 } | |
9292 else | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
9293 semsg(_(e_invarg2), arg); |
7 | 9294 } |
9295 | |
9296 /* | |
11459
561b76ed9d12
patch 8.0.0613: the conf filetype is used before ftdetect from packages
Christian Brabandt <cb@256bit.org>
parents:
11428
diff
changeset
|
9297 * ":setfiletype [FALLBACK] {name}" |
7 | 9298 */ |
9299 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
9300 ex_setfiletype(exarg_T *eap) |
7 | 9301 { |
9302 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
|
9303 { |
561b76ed9d12
patch 8.0.0613: the conf filetype is used before ftdetect from packages
Christian Brabandt <cb@256bit.org>
parents:
11428
diff
changeset
|
9304 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
|
9305 |
561b76ed9d12
patch 8.0.0613: the conf filetype is used before ftdetect from packages
Christian Brabandt <cb@256bit.org>
parents:
11428
diff
changeset
|
9306 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
|
9307 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
|
9308 |
561b76ed9d12
patch 8.0.0613: the conf filetype is used before ftdetect from packages
Christian Brabandt <cb@256bit.org>
parents:
11428
diff
changeset
|
9309 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
|
9310 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
|
9311 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
|
9312 } |
7 | 9313 } |
9314 | |
9315 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
9316 ex_digraphs(exarg_T *eap UNUSED) |
7 | 9317 { |
9318 #ifdef FEAT_DIGRAPHS | |
9319 if (*eap->arg != NUL) | |
9320 putdigraph(eap->arg); | |
9321 else | |
15152
1ef429366fd4
patch 8.1.0586: :digraph output is not easy to read
Bram Moolenaar <Bram@vim.org>
parents:
15125
diff
changeset
|
9322 listdigraphs(eap->forceit); |
7 | 9323 #else |
25294
c626fd34b66f
patch 8.2.3184: cannot add a digraph with a leading space
Bram Moolenaar <Bram@vim.org>
parents:
25064
diff
changeset
|
9324 emsg(_(e_no_digraphs_version)); |
7 | 9325 #endif |
9326 } | |
9327 | |
13792
0e9b2971d7c3
patch 8.0.1768: SET_NO_HLSEARCH() used in a wrong way
Christian Brabandt <cb@256bit.org>
parents:
13581
diff
changeset
|
9328 #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
|
9329 void |
0e9b2971d7c3
patch 8.0.1768: SET_NO_HLSEARCH() used in a wrong way
Christian Brabandt <cb@256bit.org>
parents:
13581
diff
changeset
|
9330 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
|
9331 { |
0e9b2971d7c3
patch 8.0.1768: SET_NO_HLSEARCH() used in a wrong way
Christian Brabandt <cb@256bit.org>
parents:
13581
diff
changeset
|
9332 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
|
9333 # 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
|
9334 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
|
9335 # endif |
0e9b2971d7c3
patch 8.0.1768: SET_NO_HLSEARCH() used in a wrong way
Christian Brabandt <cb@256bit.org>
parents:
13581
diff
changeset
|
9336 } |
0e9b2971d7c3
patch 8.0.1768: SET_NO_HLSEARCH() used in a wrong way
Christian Brabandt <cb@256bit.org>
parents:
13581
diff
changeset
|
9337 |
7 | 9338 /* |
9339 * ":nohlsearch" | |
9340 */ | |
9341 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
9342 ex_nohlsearch(exarg_T *eap UNUSED) |
7 | 9343 { |
13792
0e9b2971d7c3
patch 8.0.1768: SET_NO_HLSEARCH() used in a wrong way
Christian Brabandt <cb@256bit.org>
parents:
13581
diff
changeset
|
9344 set_no_hlsearch(TRUE); |
737 | 9345 redraw_all_later(SOME_VALID); |
7 | 9346 } |
9347 #endif | |
9348 | |
9349 #ifdef FEAT_CRYPT | |
9350 /* | |
9351 * ":X": Get crypt key | |
9352 */ | |
9353 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
9354 ex_X(exarg_T *eap UNUSED) |
7 | 9355 { |
6353 | 9356 crypt_check_current_method(); |
6122 | 9357 (void)crypt_get_key(TRUE, TRUE); |
7 | 9358 } |
9359 #endif | |
9360 | |
9361 #ifdef FEAT_FOLDING | |
9362 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
9363 ex_fold(exarg_T *eap) |
7 | 9364 { |
9365 if (foldManualAllowed(TRUE)) | |
9366 foldCreate(eap->line1, eap->line2); | |
9367 } | |
9368 | |
9369 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
9370 ex_foldopen(exarg_T *eap) |
7 | 9371 { |
9372 opFoldRange(eap->line1, eap->line2, eap->cmdidx == CMD_foldopen, | |
9373 eap->forceit, FALSE); | |
9374 } | |
9375 | |
9376 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
9377 ex_folddo(exarg_T *eap) |
7 | 9378 { |
9379 linenr_T lnum; | |
9380 | |
18297
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
9381 # ifdef FEAT_CLIPBOARD |
6116 | 9382 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
|
9383 # endif |
6116 | 9384 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
9385 // First set the marks for all lines closed/open. |
7 | 9386 for (lnum = eap->line1; lnum <= eap->line2; ++lnum) |
9387 if (hasFolding(lnum, NULL, NULL) == (eap->cmdidx == CMD_folddoclosed)) | |
9388 ml_setmarked(lnum); | |
9389 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
9390 // Execute the command on the marked lines. |
7 | 9391 global_exe(eap->arg); |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
9392 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
|
9393 # ifdef FEAT_CLIPBOARD |
6116 | 9394 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
|
9395 # endif |
6116 | 9396 } |
9397 #endif | |
12459
937356f8f8d6
patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents:
12457
diff
changeset
|
9398 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
9399 #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
|
9400 /* |
60b9b6196644
patch 8.1.0288: quickfix code uses cmdidx too often
Christian Brabandt <cb@256bit.org>
parents:
14538
diff
changeset
|
9401 * 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
|
9402 * 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
|
9403 */ |
60b9b6196644
patch 8.1.0288: quickfix code uses cmdidx too often
Christian Brabandt <cb@256bit.org>
parents:
14538
diff
changeset
|
9404 int |
60b9b6196644
patch 8.1.0288: quickfix code uses cmdidx too often
Christian Brabandt <cb@256bit.org>
parents:
14538
diff
changeset
|
9405 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
|
9406 { |
14621
89cc3e7ecb68
patch 8.1.0324: off-by-one error in cmdidx check
Christian Brabandt <cb@256bit.org>
parents:
14591
diff
changeset
|
9407 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
|
9408 return FALSE; |
60b9b6196644
patch 8.1.0288: quickfix code uses cmdidx too often
Christian Brabandt <cb@256bit.org>
parents:
14538
diff
changeset
|
9409 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
|
9410 } |
60b9b6196644
patch 8.1.0288: quickfix code uses cmdidx too often
Christian Brabandt <cb@256bit.org>
parents:
14538
diff
changeset
|
9411 #endif |
60b9b6196644
patch 8.1.0288: quickfix code uses cmdidx too often
Christian Brabandt <cb@256bit.org>
parents:
14538
diff
changeset
|
9412 |
18297
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
9413 #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
|
9414 int |
937356f8f8d6
patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents:
12457
diff
changeset
|
9415 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
|
9416 { |
937356f8f8d6
patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents:
12457
diff
changeset
|
9417 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
|
9418 } |
937356f8f8d6
patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents:
12457
diff
changeset
|
9419 |
937356f8f8d6
patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents:
12457
diff
changeset
|
9420 void |
937356f8f8d6
patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents:
12457
diff
changeset
|
9421 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
|
9422 { |
937356f8f8d6
patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents:
12457
diff
changeset
|
9423 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
|
9424 } |
937356f8f8d6
patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents:
12457
diff
changeset
|
9425 #endif |