Mercurial > vim
annotate src/ex_docmd.c @ 22240:88927d5f275d v8.2.1669
patch 8.2.1669: Vim9: memory leak when storing a value fails
Commit: https://github.com/vim/vim/commit/b0fa5e17c587d9c71596bd10836918af713ffff6
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Sep 12 19:51:42 2020 +0200
patch 8.2.1669: Vim9: memory leak when storing a value fails
Problem: Vim9: memory leak when storing a value fails.
Solution: Free the value when not storing it.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 12 Sep 2020 20:00:04 +0200 |
parents | a607f02fd17a |
children | d7c1e3efa88e |
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 |
17622
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
266 # define ex_break ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
267 # define ex_breakadd ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
268 # define ex_breakdel ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
269 # define ex_breaklist ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
270 # define ex_call ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
271 # define ex_catch ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
272 # define ex_compiler ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
273 # define ex_continue ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
274 # define ex_debug ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
275 # define ex_debuggreedy ex_ni |
20528
489cb75c76b6
patch 8.2.0818: Vim9: using a discovery phase doesn't work well
Bram Moolenaar <Bram@vim.org>
parents:
20474
diff
changeset
|
276 # define ex_def ex_ni |
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 |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
283 # define ex_endfunction ex_ni |
7 | 284 # 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
|
285 # define ex_endtry ex_ni |
7 | 286 # 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
|
287 # define ex_eval ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
288 # define ex_execute ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
289 # define ex_finally ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
290 # define ex_finish ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
291 # define ex_function ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
292 # define ex_if ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
293 # define ex_let ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
294 # define ex_lockvar ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
295 # define ex_oldfiles ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
296 # define ex_options ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
297 # define ex_packadd ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
298 # define ex_packloadall ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
299 # define ex_return ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
300 # define ex_scriptnames ex_ni |
7 | 301 # define ex_throw ex_ni |
302 # define ex_try ex_ni | |
303 # define ex_unlet ex_ni | |
146 | 304 # define ex_unlockvar ex_ni |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
305 # define ex_vim9script ex_ni |
17622
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
306 # 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
|
307 # 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
|
308 # define ex_export ex_ni |
7 | 309 #endif |
17536
e00d12c085a5
patch 8.1.1766: code for writing session file is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17496
diff
changeset
|
310 #ifndef FEAT_SESSION |
7 | 311 # define ex_loadview ex_ni |
312 #endif | |
17458
cfdef48743ed
patch 8.1.1727: code for viminfo support is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17431
diff
changeset
|
313 #ifndef FEAT_VIMINFO |
7 | 314 # define ex_viminfo ex_ni |
315 #endif | |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
316 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
|
317 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
|
318 static void ex_setfiletype(exarg_T *eap); |
7 | 319 #ifndef FEAT_DIFF |
16 | 320 # define ex_diffoff ex_ni |
7 | 321 # define ex_diffpatch ex_ni |
322 # define ex_diffgetput ex_ni | |
323 # define ex_diffsplit ex_ni | |
324 # define ex_diffthis ex_ni | |
325 # define ex_diffupdate ex_ni | |
326 #endif | |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
327 static void ex_digraphs(exarg_T *eap); |
7 | 328 #ifdef FEAT_SEARCH_EXTRA |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
329 static void ex_nohlsearch(exarg_T *eap); |
7 | 330 #else |
331 # define ex_nohlsearch ex_ni | |
332 # define ex_match ex_ni | |
333 #endif | |
334 #ifdef FEAT_CRYPT | |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
335 static void ex_X(exarg_T *eap); |
7 | 336 #else |
337 # define ex_X ex_ni | |
338 #endif | |
339 #ifdef FEAT_FOLDING | |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
340 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
|
341 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
|
342 static void ex_folddo(exarg_T *eap); |
7 | 343 #else |
344 # define ex_fold ex_ni | |
345 # define ex_foldopen ex_ni | |
346 # define ex_folddo ex_ni | |
347 #endif | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
348 #if !(defined(HAVE_LOCALE_H) || defined(X_LOCALE)) |
7 | 349 # define ex_language ex_ni |
350 #endif | |
351 #ifndef FEAT_SIGNS | |
352 # define ex_sign ex_ni | |
353 #endif | |
33 | 354 #ifndef FEAT_NETBEANS_INTG |
2210 | 355 # define ex_nbclose ex_ni |
33 | 356 # define ex_nbkey ex_ni |
2210 | 357 # define ex_nbstart ex_ni |
33 | 358 #endif |
7 | 359 |
360 #ifndef FEAT_JUMPLIST | |
361 # define ex_jumps ex_ni | |
9284
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
9260
diff
changeset
|
362 # define ex_clearjumps ex_ni |
7 | 363 # define ex_changes ex_ni |
364 #endif | |
365 | |
170 | 366 #ifndef FEAT_PROFILE |
367 # define ex_profile ex_ni | |
368 #endif | |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
11547
diff
changeset
|
369 #ifndef FEAT_TERMINAL |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
11547
diff
changeset
|
370 # define ex_terminal ex_ni |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
11547
diff
changeset
|
371 #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
|
372 #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
|
373 # 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
|
374 #endif |
18763
49b78d6465e5
patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents:
18715
diff
changeset
|
375 #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
|
376 # define ex_popupclear ex_ni |
491c01280a5d
patch 8.1.1392: build failure in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
377 #endif |
170 | 378 |
7 | 379 /* |
380 * Declare cmdnames[]. | |
381 */ | |
382 #define DO_DECLARE_EXCMD | |
383 #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
|
384 #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
|
385 |
7 | 386 static char_u dollar_command[2] = {'$', 0}; |
387 | |
388 | |
389 #ifdef FEAT_EVAL | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
390 // Struct for storing a line inside a while/for loop |
7 | 391 typedef struct |
392 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
393 char_u *line; // command line |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
394 linenr_T lnum; // sourcing_lnum of the line |
7 | 395 } wcmd_T; |
396 | |
397 /* | |
72 | 398 * Structure used to store info for line position in a while or for loop. |
7 | 399 * This is required, because do_one_cmd() may invoke ex_function(), which |
72 | 400 * reads more lines that may come from the while/for loop. |
401 */ | |
402 struct loop_cookie | |
7 | 403 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
404 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
|
405 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
|
406 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
|
407 // 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
|
408 char_u *(*getline)(int, void *, int, getline_opt_T); |
7 | 409 void *cookie; |
410 }; | |
411 | |
21885
72525eabfe61
patch 8.2.1492: build failures
Bram Moolenaar <Bram@vim.org>
parents:
21883
diff
changeset
|
412 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
|
413 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
|
414 static void free_cmdlines(garray_T *gap); |
8 | 415 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
416 // Struct to save a few things while debugging. Used in do_cmdline() only. |
8 | 417 struct dbg_stuff |
418 { | |
419 int trylevel; | |
420 int force_abort; | |
421 except_T *caught_stack; | |
422 char_u *vv_exception; | |
423 char_u *vv_throwpoint; | |
424 int did_emsg; | |
425 int got_int; | |
426 int did_throw; | |
427 int need_rethrow; | |
428 int check_cstack; | |
429 except_T *current_exception; | |
430 }; | |
431 | |
432 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
433 save_dbg_stuff(struct dbg_stuff *dsp) |
8 | 434 { |
435 dsp->trylevel = trylevel; trylevel = 0; | |
436 dsp->force_abort = force_abort; force_abort = FALSE; | |
437 dsp->caught_stack = caught_stack; caught_stack = NULL; | |
438 dsp->vv_exception = v_exception(NULL); | |
439 dsp->vv_throwpoint = v_throwpoint(NULL); | |
440 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
441 // Necessary for debugging an inactive ":catch", ":finally", ":endtry" |
8 | 442 dsp->did_emsg = did_emsg; did_emsg = FALSE; |
443 dsp->got_int = got_int; got_int = FALSE; | |
444 dsp->did_throw = did_throw; did_throw = FALSE; | |
445 dsp->need_rethrow = need_rethrow; need_rethrow = FALSE; | |
446 dsp->check_cstack = check_cstack; check_cstack = FALSE; | |
447 dsp->current_exception = current_exception; current_exception = NULL; | |
448 } | |
449 | |
450 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
451 restore_dbg_stuff(struct dbg_stuff *dsp) |
8 | 452 { |
453 suppress_errthrow = FALSE; | |
454 trylevel = dsp->trylevel; | |
455 force_abort = dsp->force_abort; | |
456 caught_stack = dsp->caught_stack; | |
457 (void)v_exception(dsp->vv_exception); | |
458 (void)v_throwpoint(dsp->vv_throwpoint); | |
459 did_emsg = dsp->did_emsg; | |
460 got_int = dsp->got_int; | |
461 did_throw = dsp->did_throw; | |
462 need_rethrow = dsp->need_rethrow; | |
463 check_cstack = dsp->check_cstack; | |
464 current_exception = dsp->current_exception; | |
465 } | |
7 | 466 #endif |
467 | |
468 /* | |
469 * do_exmode(): Repeatedly get commands for the "Ex" mode, until the ":vi" | |
470 * command is given. | |
471 */ | |
472 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
473 do_exmode( |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
474 int improved) // TRUE for "improved Ex" mode |
7 | 475 { |
476 int save_msg_scroll; | |
477 int prev_msg_row; | |
478 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
|
479 varnumber_T changedtick; |
167 | 480 |
481 if (improved) | |
482 exmode_active = EXMODE_VIM; | |
483 else | |
484 exmode_active = EXMODE_NORMAL; | |
485 State = NORMAL; | |
486 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
487 // 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
|
488 // the :global command. |
167 | 489 if (global_busy) |
490 return; | |
7 | 491 |
492 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
|
493 ++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
|
494 ++no_wait_return; // don't wait for return |
7 | 495 #ifdef FEAT_GUI |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
496 // Ignore scrollbar and mouse events in Ex mode |
7 | 497 ++hold_gui_events; |
498 #endif | |
499 | |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15510
diff
changeset
|
500 msg(_("Entering Ex mode. Type \"visual\" to go to Normal mode.")); |
7 | 501 while (exmode_active) |
502 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
503 // Check for a ":normal" command and no more characters left. |
161 | 504 if (ex_normal_busy > 0 && typebuf.tb_len == 0) |
505 { | |
506 exmode_active = FALSE; | |
507 break; | |
508 } | |
7 | 509 msg_scroll = TRUE; |
510 need_wait_return = FALSE; | |
511 ex_pressedreturn = FALSE; | |
512 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
|
513 changedtick = CHANGEDTICK(curbuf); |
7 | 514 prev_msg_row = msg_row; |
515 prev_line = curwin->w_cursor.lnum; | |
516 if (improved) | |
517 { | |
518 cmdline_row = msg_row; | |
519 do_cmdline(NULL, getexline, NULL, 0); | |
520 } | |
521 else | |
522 do_cmdline(NULL, getexmodeline, NULL, DOCMD_NOWAIT); | |
523 lines_left = Rows - 1; | |
524 | |
167 | 525 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
|
526 || changedtick != CHANGEDTICK(curbuf)) && !ex_no_reprint) |
167 | 527 { |
528 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
|
529 emsg(_(e_emptybuf)); |
167 | 530 else |
531 { | |
532 if (ex_pressedreturn) | |
533 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
534 // 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
|
535 // output doesn't contain empty lines. |
167 | 536 msg_row = prev_msg_row; |
537 if (prev_msg_row == Rows - 1) | |
538 msg_row--; | |
539 } | |
540 msg_col = 0; | |
541 print_line_no_prefix(curwin->w_cursor.lnum, FALSE, FALSE); | |
542 msg_clr_eos(); | |
543 } | |
544 } | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
545 else if (ex_pressedreturn && !ex_no_reprint) // must be at EOF |
167 | 546 { |
547 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
|
548 emsg(_(e_emptybuf)); |
167 | 549 else |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
550 emsg(_("E501: At end-of-file")); |
167 | 551 } |
7 | 552 } |
553 | |
554 #ifdef FEAT_GUI | |
555 --hold_gui_events; | |
556 #endif | |
557 --RedrawingDisabled; | |
558 --no_wait_return; | |
559 update_screen(CLEAR); | |
560 need_wait_return = FALSE; | |
561 msg_scroll = save_msg_scroll; | |
562 } | |
563 | |
564 /* | |
18297
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
565 * 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
|
566 * 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
|
567 */ |
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
568 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
|
569 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
|
570 { |
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
571 ++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
|
572 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
|
573 |
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
574 if (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
|
575 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
|
576 else |
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(_("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
|
578 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
|
579 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
|
580 |
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
581 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
|
582 --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
|
583 } |
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
584 |
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
585 /* |
7 | 586 * Execute a simple command line. Used for translated commands like "*". |
587 */ | |
588 int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
589 do_cmdline_cmd(char_u *cmd) |
7 | 590 { |
591 return do_cmdline(cmd, NULL, NULL, | |
592 DOCMD_VERBOSE|DOCMD_NOWAIT|DOCMD_KEYTYPED); | |
593 } | |
594 | |
595 /* | |
596 * do_cmdline(): execute one Ex command line | |
597 * | |
598 * 1. Execute "cmdline" when it is not NULL. | |
2635 | 599 * If "cmdline" is NULL, or more lines are needed, fgetline() is used. |
7 | 600 * 2. Split up in parts separated with '|'. |
601 * | |
602 * This function can be called recursively! | |
603 * | |
604 * flags: | |
605 * DOCMD_VERBOSE - The command will be included in the error message. | |
606 * DOCMD_NOWAIT - Don't call wait_return() and friends. | |
2635 | 607 * DOCMD_REPEAT - Repeat execution until fgetline() returns NULL. |
7 | 608 * DOCMD_KEYTYPED - Don't reset KeyTyped. |
609 * DOCMD_EXCRESET - Reset the exception environment (used for debugging). | |
610 * DOCMD_KEEPLINE - Store first typed line (for repeating with "."). | |
611 * | |
612 * return FAIL if cmdline could not be executed, OK otherwise | |
613 */ | |
614 int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
615 do_cmdline( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
616 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
|
617 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
|
618 void *cookie, // argument for fgetline() |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
619 int flags) |
7 | 620 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
621 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
|
622 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
|
623 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
|
624 static int recursive = 0; // recursive depth |
7 | 625 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
|
626 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
|
627 int did_inc = FALSE; // incremented RedrawingDisabled |
7 | 628 int retval = OK; |
629 #ifdef FEAT_EVAL | |
18904
2bdc2e1f6e1f
patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents:
18849
diff
changeset
|
630 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
|
631 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
|
632 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
|
633 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
|
634 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
|
635 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
|
636 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
|
637 struct dbg_stuff debug_saved; // saved things for debug mode |
7 | 638 int initial_trylevel; |
20538
9f921ba86d05
patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents:
20536
diff
changeset
|
639 msglist_T **saved_msg_list = NULL; |
9f921ba86d05
patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents:
20536
diff
changeset
|
640 msglist_T *private_msg_list; |
7 | 641 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
642 // "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
|
643 char_u *(*cmd_getline)(int, void *, int, getline_opt_T); |
7 | 644 void *cmd_cookie; |
72 | 645 struct loop_cookie cmd_loop_cookie; |
7 | 646 void *real_cookie; |
170 | 647 int getline_is_func; |
7 | 648 #else |
2635 | 649 # define cmd_getline fgetline |
7 | 650 # define cmd_cookie cookie |
651 #endif | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
652 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
|
653 #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
|
654 ESTACK_CHECK_DECLARATION |
7 | 655 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
656 // 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
|
657 // 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
|
658 // 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
|
659 // 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
|
660 // 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
|
661 // BufWritePost autocommands are executed after a write error. |
7 | 662 saved_msg_list = msg_list; |
663 msg_list = &private_msg_list; | |
664 private_msg_list = NULL; | |
665 #endif | |
666 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
667 // 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
|
668 // 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
|
669 // 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
|
670 if (call_depth >= 200 |
8f2191b56d52
commit https://github.com/vim/vim/commit/b094ff4b2be4d8b7364c566a1cc7e27aa4452a50
Christian Brabandt <cb@256bit.org>
parents:
10488
diff
changeset
|
671 #ifdef FEAT_EVAL |
8f2191b56d52
commit https://github.com/vim/vim/commit/b094ff4b2be4d8b7364c566a1cc7e27aa4452a50
Christian Brabandt <cb@256bit.org>
parents:
10488
diff
changeset
|
672 && call_depth >= p_mfd |
8f2191b56d52
commit https://github.com/vim/vim/commit/b094ff4b2be4d8b7364c566a1cc7e27aa4452a50
Christian Brabandt <cb@256bit.org>
parents:
10488
diff
changeset
|
673 #endif |
8f2191b56d52
commit https://github.com/vim/vim/commit/b094ff4b2be4d8b7364c566a1cc7e27aa4452a50
Christian Brabandt <cb@256bit.org>
parents:
10488
diff
changeset
|
674 ) |
7 | 675 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
676 emsg(_("E169: Command too recursive")); |
7 | 677 #ifdef FEAT_EVAL |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
678 // 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
|
679 // 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
|
680 do_errthrow((cstack_T *)NULL, (char_u *)NULL); |
7 | 681 msg_list = saved_msg_list; |
682 #endif | |
683 return FAIL; | |
684 } | |
685 ++call_depth; | |
686 | |
687 #ifdef FEAT_EVAL | |
688 cstack.cs_idx = -1; | |
72 | 689 cstack.cs_looplevel = 0; |
7 | 690 cstack.cs_trylevel = 0; |
691 cstack.cs_emsg_silent_list = NULL; | |
72 | 692 cstack.cs_lflags = 0; |
7 | 693 ga_init2(&lines_ga, (int)sizeof(wcmd_T), 10); |
694 | |
2635 | 695 real_cookie = getline_cookie(fgetline, cookie); |
7 | 696 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
697 // Inside a function use a higher nesting level. |
2635 | 698 getline_is_func = getline_equal(fgetline, cookie, get_func_line); |
170 | 699 if (getline_is_func && ex_nesting_level == func_level(real_cookie)) |
7 | 700 ++ex_nesting_level; |
701 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
702 // 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
|
703 // line and the debug tick for a function or script are stored. |
170 | 704 if (getline_is_func) |
7 | 705 { |
706 fname = func_name(real_cookie); | |
707 breakpoint = func_breakpoint(real_cookie); | |
708 dbg_tick = func_dbg_tick(real_cookie); | |
709 } | |
2635 | 710 else if (getline_equal(fgetline, cookie, getsourceline)) |
7 | 711 { |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18904
diff
changeset
|
712 fname = SOURCING_NAME; |
7 | 713 breakpoint = source_breakpoint(real_cookie); |
714 dbg_tick = source_dbg_tick(real_cookie); | |
715 } | |
716 | |
717 /* | |
718 * Initialize "force_abort" and "suppress_errthrow" at the top level. | |
719 */ | |
720 if (!recursive) | |
721 { | |
722 force_abort = FALSE; | |
723 suppress_errthrow = FALSE; | |
724 } | |
725 | |
726 /* | |
727 * If requested, store and reset the global values controlling the | |
944 | 728 * exception handling (used when debugging). Otherwise clear it to avoid |
729 * a bogus compiler warning when the optimizer uses inline functions... | |
7 | 730 */ |
878 | 731 if (flags & DOCMD_EXCRESET) |
8 | 732 save_dbg_stuff(&debug_saved); |
944 | 733 else |
20007
aadd1cae2ff5
patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
734 CLEAR_FIELD(debug_saved); |
7 | 735 |
736 initial_trylevel = trylevel; | |
737 | |
738 /* | |
739 * "did_throw" will be set to TRUE when an exception is being thrown. | |
740 */ | |
741 did_throw = FALSE; | |
742 #endif | |
743 /* | |
744 * "did_emsg" will be set to TRUE when emsg() is used, in which case we | |
72 | 745 * cancel the whole command line, and any if/endif or loop. |
7 | 746 * If force_abort is set, we cancel everything. |
747 */ | |
748 did_emsg = FALSE; | |
749 | |
750 /* | |
751 * KeyTyped is only set when calling vgetc(). Reset it here when not | |
752 * calling vgetc() (sourced command lines). | |
753 */ | |
2635 | 754 if (!(flags & DOCMD_KEYTYPED) |
755 && !getline_equal(fgetline, cookie, getexline)) | |
7 | 756 KeyTyped = FALSE; |
757 | |
758 /* | |
759 * Continue executing command lines: | |
72 | 760 * - when inside an ":if", ":while" or ":for" |
7 | 761 * - for multiple commands on one line, separated with '|' |
762 * - when repeating until there are no more lines (for ":source") | |
763 */ | |
764 next_cmdline = cmdline; | |
765 do | |
766 { | |
170 | 767 #ifdef FEAT_EVAL |
2635 | 768 getline_is_func = getline_equal(fgetline, cookie, get_func_line); |
170 | 769 #endif |
770 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
771 // stop skipping cmds for an error msg after all endif/while/for |
7 | 772 if (next_cmdline == NULL |
773 #ifdef FEAT_EVAL | |
774 && !force_abort | |
775 && cstack.cs_idx < 0 | |
170 | 776 && !(getline_is_func && func_has_abort(real_cookie)) |
7 | 777 #endif |
778 ) | |
779 did_emsg = FALSE; | |
780 | |
781 /* | |
72 | 782 * 1. If repeating a line in a loop, get a line from lines_ga. |
2635 | 783 * 2. If no line given: Get an allocated line with fgetline(). |
7 | 784 * 3. If a line is given: Make a copy, so we can mess with it. |
785 */ | |
786 | |
787 #ifdef FEAT_EVAL | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
788 // 1. If repeating, get a previous line from lines_ga. |
72 | 789 if (cstack.cs_looplevel > 0 && current_line < lines_ga.ga_len) |
7 | 790 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
791 // 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
|
792 // 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
|
793 VIM_CLEAR(cmdline_copy); |
7 | 794 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
795 // 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
|
796 // try conditional, aborted. |
170 | 797 if (getline_is_func) |
798 { | |
799 # ifdef FEAT_PROFILE | |
788 | 800 if (do_profiling == PROF_YES) |
170 | 801 func_line_end(real_cookie); |
802 # endif | |
803 if (func_has_ended(real_cookie)) | |
804 { | |
805 retval = FAIL; | |
806 break; | |
807 } | |
808 } | |
809 #ifdef FEAT_PROFILE | |
788 | 810 else if (do_profiling == PROF_YES |
2635 | 811 && getline_equal(fgetline, cookie, getsourceline)) |
170 | 812 script_line_end(); |
813 #endif | |
7 | 814 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
815 // Check if a sourced file hit a ":finish" command. |
2635 | 816 if (source_finished(fgetline, cookie)) |
7 | 817 { |
818 retval = FAIL; | |
819 break; | |
820 } | |
821 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
822 // If breakpoints have been added/deleted need to check for it. |
7 | 823 if (breakpoint != NULL && dbg_tick != NULL |
824 && *dbg_tick != debug_tick) | |
825 { | |
826 *breakpoint = dbg_find_breakpoint( | |
2635 | 827 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
|
828 fname, SOURCING_LNUM); |
7 | 829 *dbg_tick = debug_tick; |
830 } | |
831 | |
832 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
|
833 SOURCING_LNUM = ((wcmd_T *)(lines_ga.ga_data))[current_line].lnum; |
7 | 834 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
835 // Did we encounter a breakpoint? |
7 | 836 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
|
837 && *breakpoint <= SOURCING_LNUM) |
7 | 838 { |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18904
diff
changeset
|
839 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
|
840 // Find next breakpoint. |
7 | 841 *breakpoint = dbg_find_breakpoint( |
2635 | 842 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
|
843 fname, SOURCING_LNUM); |
7 | 844 *dbg_tick = debug_tick; |
845 } | |
170 | 846 # ifdef FEAT_PROFILE |
788 | 847 if (do_profiling == PROF_YES) |
170 | 848 { |
849 if (getline_is_func) | |
850 func_line_start(real_cookie); | |
2635 | 851 else if (getline_equal(fgetline, cookie, getsourceline)) |
170 | 852 script_line_start(); |
853 } | |
854 # endif | |
7 | 855 } |
856 #endif | |
857 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
858 // 2. If no line given, get an allocated line with fgetline(). |
7 | 859 if (next_cmdline == NULL) |
860 { | |
861 /* | |
862 * Need to set msg_didout for the first line after an ":if", | |
863 * otherwise the ":if" will be overwritten. | |
864 */ | |
2635 | 865 if (count == 1 && getline_equal(fgetline, cookie, getexline)) |
7 | 866 msg_didout = TRUE; |
2635 | 867 if (fgetline == NULL || (next_cmdline = fgetline(':', cookie, |
7 | 868 #ifdef FEAT_EVAL |
869 cstack.cs_idx < 0 ? 0 : (cstack.cs_idx + 1) * 2 | |
870 #else | |
871 0 | |
872 #endif | |
17178
40c4cb095d53
patch 8.1.1588: in :let-heredoc line continuation is recognized
Bram Moolenaar <Bram@vim.org>
parents:
17111
diff
changeset
|
873 , TRUE)) == NULL) |
7 | 874 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
875 // 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
|
876 // 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
|
877 // doesn't do this. |
7 | 878 if (KeyTyped && !(flags & DOCMD_REPEAT)) |
879 need_wait_return = FALSE; | |
880 retval = FAIL; | |
881 break; | |
882 } | |
883 used_getline = TRUE; | |
884 | |
885 /* | |
886 * Keep the first typed line. Clear it when more lines are typed. | |
887 */ | |
888 if (flags & DOCMD_KEEPLINE) | |
889 { | |
890 vim_free(repeat_cmdline); | |
891 if (count == 0) | |
892 repeat_cmdline = vim_strsave(next_cmdline); | |
893 else | |
894 repeat_cmdline = NULL; | |
895 } | |
896 } | |
897 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
898 // 3. Make a copy of the command so we can mess with it. |
7 | 899 else if (cmdline_copy == NULL) |
900 { | |
901 next_cmdline = vim_strsave(next_cmdline); | |
902 if (next_cmdline == NULL) | |
903 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
904 emsg(_(e_outofmem)); |
7 | 905 retval = FAIL; |
906 break; | |
907 } | |
908 } | |
909 cmdline_copy = next_cmdline; | |
910 | |
911 #ifdef FEAT_EVAL | |
912 /* | |
21056
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
913 * 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
|
914 * 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
|
915 * looping. |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
916 * |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
917 * 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
|
918 * because we need to be able to jump back to it from an |
72 | 919 * :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
|
920 * |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
921 * 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
|
922 * 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
|
923 * 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
|
924 * line continuation. |
7 | 925 */ |
21056
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
926 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
|
927 { |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
928 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
|
929 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
|
930 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
|
931 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
|
932 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
|
933 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
|
934 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
|
935 |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
936 // 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
|
937 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
|
938 && store_loop_line(&lines_ga, next_cmdline) == FAIL) |
7 | 939 { |
940 retval = FAIL; | |
941 break; | |
942 } | |
21056
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
943 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
|
944 } |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
945 else |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
946 { |
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_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
|
948 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
|
949 } |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
950 |
7 | 951 did_endif = FALSE; |
952 #endif | |
953 | |
954 if (count++ == 0) | |
955 { | |
956 /* | |
957 * All output from the commands is put below each other, without | |
958 * waiting for a return. Don't do this when executing commands | |
959 * from a script or when being called recursive (e.g. for ":e | |
960 * +command file"). | |
961 */ | |
962 if (!(flags & DOCMD_NOWAIT) && !recursive) | |
963 { | |
964 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
|
965 msg_didany = FALSE; // no output yet |
7 | 966 msg_start(); |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
967 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
|
968 ++no_wait_return; // don't wait for return until finished |
7 | 969 ++RedrawingDisabled; |
970 did_inc = TRUE; | |
971 } | |
972 } | |
973 | |
20575
501b72481d0a
patch 8.2.0841: 'verbose' value 16 causes duplicate output
Bram Moolenaar <Bram@vim.org>
parents:
20538
diff
changeset
|
974 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
|
975 msg_verbose_cmd(SOURCING_LNUM, cmdline_copy); |
7 | 976 |
977 /* | |
978 * 2. Execute one '|' separated command. | |
979 * do_one_cmd() will return NULL if there is no trailing '|'. | |
980 * "cmdline_copy" can change, e.g. for '%' and '#' expansion. | |
981 */ | |
982 ++recursive; | |
983 next_cmdline = do_one_cmd(&cmdline_copy, flags & DOCMD_VERBOSE, | |
984 #ifdef FEAT_EVAL | |
985 &cstack, | |
986 #endif | |
987 cmd_getline, cmd_cookie); | |
988 --recursive; | |
989 | |
990 #ifdef FEAT_EVAL | |
72 | 991 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
|
992 // 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
|
993 // incremented when defining a function. |
72 | 994 current_line = cmd_loop_cookie.current_line; |
7 | 995 #endif |
996 | |
997 if (next_cmdline == NULL) | |
998 { | |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13221
diff
changeset
|
999 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
|
1000 |
7 | 1001 /* |
1002 * If the command was typed, remember it for the ':' register. | |
1003 * Do this AFTER executing the command to make :@: work. | |
1004 */ | |
2635 | 1005 if (getline_equal(fgetline, cookie, getexline) |
7 | 1006 && new_last_cmdline != NULL) |
1007 { | |
1008 vim_free(last_cmdline); | |
1009 last_cmdline = new_last_cmdline; | |
1010 new_last_cmdline = NULL; | |
1011 } | |
1012 } | |
1013 else | |
1014 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1015 // 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
|
1016 // next do_one_cmd() |
1619 | 1017 STRMOVE(cmdline_copy, next_cmdline); |
7 | 1018 next_cmdline = cmdline_copy; |
1019 } | |
1020 | |
1021 | |
1022 #ifdef FEAT_EVAL | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1023 // reset did_emsg for a function that is not aborted by an error |
7 | 1024 if (did_emsg && !force_abort |
2635 | 1025 && getline_equal(fgetline, cookie, get_func_line) |
7 | 1026 && !func_has_abort(real_cookie)) |
1027 did_emsg = FALSE; | |
1028 | |
72 | 1029 if (cstack.cs_looplevel > 0) |
7 | 1030 { |
1031 ++current_line; | |
1032 | |
1033 /* | |
72 | 1034 * An ":endwhile", ":endfor" and ":continue" is handled here. |
1035 * If we were executing commands, jump back to the ":while" or | |
1036 * ":for". | |
1037 * If we were not executing commands, decrement cs_looplevel. | |
7 | 1038 */ |
72 | 1039 if (cstack.cs_lflags & (CSL_HAD_CONT | CSL_HAD_ENDLOOP)) |
1040 { | |
1041 cstack.cs_lflags &= ~(CSL_HAD_CONT | CSL_HAD_ENDLOOP); | |
1042 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1043 // 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
|
1044 // 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
|
1045 // 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
|
1046 // cause a crash. |
7 | 1047 if (!did_emsg && !got_int && !did_throw |
1048 && cstack.cs_idx >= 0 | |
72 | 1049 && (cstack.cs_flags[cstack.cs_idx] |
1050 & (CSF_WHILE | CSF_FOR)) | |
7 | 1051 && cstack.cs_line[cstack.cs_idx] >= 0 |
1052 && (cstack.cs_flags[cstack.cs_idx] & CSF_ACTIVE)) | |
1053 { | |
1054 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
|
1055 // remember we jumped there |
72 | 1056 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
|
1057 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
|
1058 |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1059 // 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
|
1060 // or ":for". |
7 | 1061 if (breakpoint != NULL) |
1062 { | |
1063 *breakpoint = dbg_find_breakpoint( | |
2635 | 1064 getline_equal(fgetline, cookie, getsourceline), |
7 | 1065 fname, |
1066 ((wcmd_T *)lines_ga.ga_data)[current_line].lnum-1); | |
1067 *dbg_tick = debug_tick; | |
1068 } | |
1069 } | |
72 | 1070 else |
7 | 1071 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1072 // can only get here with ":endwhile" or ":endfor" |
7 | 1073 if (cstack.cs_idx >= 0) |
77 | 1074 rewind_conditionals(&cstack, cstack.cs_idx - 1, |
1075 CSF_WHILE | CSF_FOR, &cstack.cs_looplevel); | |
7 | 1076 } |
1077 } | |
1078 | |
1079 /* | |
72 | 1080 * For a ":while" or ":for" we need to remember the line number. |
7 | 1081 */ |
72 | 1082 else if (cstack.cs_lflags & CSL_HAD_LOOP) |
1083 { | |
1084 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
|
1085 cstack.cs_line[cstack.cs_idx] = current_line_before; |
7 | 1086 } |
1087 } | |
1088 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1089 // 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
|
1090 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
|
1091 { |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18904
diff
changeset
|
1092 *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
|
1093 *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
|
1094 } |
69278c25429d
patch 8.0.1505: debugger can't break on a condition
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
1095 |
7 | 1096 /* |
1097 * When not inside any ":while" loop, clear remembered lines. | |
1098 */ | |
72 | 1099 if (cstack.cs_looplevel == 0) |
7 | 1100 { |
1101 if (lines_ga.ga_len > 0) | |
1102 { | |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18904
diff
changeset
|
1103 SOURCING_LNUM = |
7 | 1104 ((wcmd_T *)lines_ga.ga_data)[lines_ga.ga_len - 1].lnum; |
1105 free_cmdlines(&lines_ga); | |
1106 } | |
1107 current_line = 0; | |
1108 } | |
1109 | |
1110 /* | |
72 | 1111 * A ":finally" makes did_emsg, got_int, and did_throw pending for |
1112 * being restored at the ":endtry". Reset them here and set the | |
1113 * ACTIVE and FINALLY flags, so that the finally clause gets executed. | |
1114 * This includes the case where a missing ":endif", ":endwhile" or | |
1115 * ":endfor" was detected by the ":finally" itself. | |
7 | 1116 */ |
72 | 1117 if (cstack.cs_lflags & CSL_HAD_FINA) |
1118 { | |
1119 cstack.cs_lflags &= ~CSL_HAD_FINA; | |
1120 report_make_pending(cstack.cs_pending[cstack.cs_idx] | |
1121 & (CSTP_ERROR | CSTP_INTERRUPT | CSTP_THROW), | |
7 | 1122 did_throw ? (void *)current_exception : NULL); |
1123 did_emsg = got_int = did_throw = FALSE; | |
1124 cstack.cs_flags[cstack.cs_idx] |= CSF_ACTIVE | CSF_FINALLY; | |
1125 } | |
1126 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1127 // 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
|
1128 // within this loop. |
7 | 1129 trylevel = initial_trylevel + cstack.cs_trylevel; |
1130 | |
1131 /* | |
1190 | 1132 * If the outermost try conditional (across function calls and sourced |
7 | 1133 * files) is aborted because of an error, an interrupt, or an uncaught |
1134 * exception, cancel everything. If it is left normally, reset | |
1135 * force_abort to get the non-EH compatible abortion behavior for | |
1136 * the rest of the script. | |
1137 */ | |
1138 if (trylevel == 0 && !did_emsg && !got_int && !did_throw) | |
1139 force_abort = FALSE; | |
1140 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1141 // Convert an interrupt to an exception if appropriate. |
7 | 1142 (void)do_intthrow(&cstack); |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1143 #endif // FEAT_EVAL |
7 | 1144 |
1145 } | |
1146 /* | |
1147 * Continue executing command lines when: | |
1148 * - no CTRL-C typed, no aborting error, no exception thrown or try | |
1149 * conditionals need to be checked for executing finally clauses or | |
1150 * catching an interrupt exception | |
1151 * - didn't get an error message or lines are not typed | |
72 | 1152 * - there is a command after '|', inside a :if, :while, :for or :try, or |
7 | 1153 * looping for ":source" command or function call. |
1154 */ | |
1155 while (!((got_int | |
1156 #ifdef FEAT_EVAL | |
1157 || (did_emsg && force_abort) || did_throw | |
1158 #endif | |
1159 ) | |
1160 #ifdef FEAT_EVAL | |
1161 && cstack.cs_trylevel == 0 | |
1162 #endif | |
1163 ) | |
3757 | 1164 && !(did_emsg |
1165 #ifdef FEAT_EVAL | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1166 // 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
|
1167 // 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
|
1168 // the :endtry to be missed. |
3757 | 1169 && (cstack.cs_trylevel == 0 || did_emsg_syntax) |
1170 #endif | |
1171 && used_getline | |
2635 | 1172 && (getline_equal(fgetline, cookie, getexmodeline) |
1173 || getline_equal(fgetline, cookie, getexline))) | |
7 | 1174 && (next_cmdline != NULL |
1175 #ifdef FEAT_EVAL | |
1176 || cstack.cs_idx >= 0 | |
1177 #endif | |
1178 || (flags & DOCMD_REPEAT))); | |
1179 | |
1180 vim_free(cmdline_copy); | |
3757 | 1181 did_emsg_syntax = FALSE; |
7 | 1182 #ifdef FEAT_EVAL |
1183 free_cmdlines(&lines_ga); | |
1184 ga_clear(&lines_ga); | |
1185 | |
1186 if (cstack.cs_idx >= 0) | |
1187 { | |
1188 /* | |
1189 * If a sourced file or executed function ran to its end, report the | |
1190 * unclosed conditional. | |
1191 */ | |
1192 if (!got_int && !did_throw | |
2635 | 1193 && ((getline_equal(fgetline, cookie, getsourceline) |
1194 && !source_finished(fgetline, cookie)) | |
1195 || (getline_equal(fgetline, cookie, get_func_line) | |
7 | 1196 && !func_has_ended(real_cookie)))) |
1197 { | |
1198 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
|
1199 emsg(_(e_endtry)); |
7 | 1200 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
|
1201 emsg(_(e_endwhile)); |
72 | 1202 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
|
1203 emsg(_(e_endfor)); |
7 | 1204 else |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
1205 emsg(_(e_endif)); |
7 | 1206 } |
1207 | |
1208 /* | |
1209 * Reset "trylevel" in case of a ":finish" or ":return" or a missing | |
1210 * ":endtry" in a sourced file or executed function. If the try | |
1211 * conditional is in its finally clause, ignore anything pending. | |
1212 * If it is in a catch clause, finish the caught exception. | |
77 | 1213 * Also cleanup any "cs_forinfo" structures. |
7 | 1214 */ |
1215 do | |
77 | 1216 { |
1217 int idx = cleanup_conditionals(&cstack, 0, TRUE); | |
1218 | |
111 | 1219 if (idx >= 0) |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1220 --idx; // remove try block not in its finally clause |
77 | 1221 rewind_conditionals(&cstack, idx, CSF_WHILE | CSF_FOR, |
1222 &cstack.cs_looplevel); | |
1223 } | |
1224 while (cstack.cs_idx >= 0); | |
7 | 1225 trylevel = initial_trylevel; |
1226 } | |
1227 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1228 // 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
|
1229 // 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
|
1230 // exception, do this now after rewinding the cstack. |
2635 | 1231 do_errthrow(&cstack, getline_equal(fgetline, cookie, get_func_line) |
7 | 1232 ? (char_u *)"endfunction" : (char_u *)NULL); |
1233 | |
1234 if (trylevel == 0) | |
1235 { | |
1236 /* | |
1237 * When an exception is being thrown out of the outermost try | |
1238 * conditional, discard the uncaught exception, disable the conversion | |
1239 * of interrupts or errors to exceptions, and ensure that no more | |
1240 * commands are executed. | |
1241 */ | |
1242 if (did_throw) | |
1243 { | |
1244 void *p = NULL; | |
20538
9f921ba86d05
patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents:
20536
diff
changeset
|
1245 msglist_T *messages = NULL, *next; |
7 | 1246 |
1247 /* | |
1248 * If the uncaught exception is a user exception, report it as an | |
1249 * error. If it is an error exception, display the saved error | |
1250 * message now. For an interrupt exception, do nothing; the | |
1251 * interrupt message is given elsewhere. | |
1252 */ | |
1253 switch (current_exception->type) | |
1254 { | |
1255 case ET_USER: | |
272 | 1256 vim_snprintf((char *)IObuff, IOSIZE, |
1257 _("E605: Exception not caught: %s"), | |
7 | 1258 current_exception->value); |
1259 p = vim_strsave(IObuff); | |
1260 break; | |
1261 case ET_ERROR: | |
1262 messages = current_exception->messages; | |
1263 current_exception->messages = NULL; | |
1264 break; | |
1265 case ET_INTERRUPT: | |
1266 break; | |
1267 } | |
1268 | |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18904
diff
changeset
|
1269 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
|
1270 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
|
1271 ESTACK_CHECK_SETUP |
7 | 1272 current_exception->throw_name = NULL; |
1273 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1274 discard_current_exception(); // uses IObuff if 'verbose' |
7 | 1275 suppress_errthrow = TRUE; |
1276 force_abort = TRUE; | |
1277 | |
1278 if (messages != NULL) | |
1279 { | |
1280 do | |
1281 { | |
1282 next = messages->next; | |
1283 emsg(messages->msg); | |
1284 vim_free(messages->msg); | |
20659
3437bf2ce2d4
patch 8.2.0883: memory leak in test 49
Bram Moolenaar <Bram@vim.org>
parents:
20645
diff
changeset
|
1285 vim_free(messages->sfile); |
7 | 1286 vim_free(messages); |
1287 messages = next; | |
1288 } | |
1289 while (messages != NULL); | |
1290 } | |
1291 else if (p != NULL) | |
1292 { | |
15490
98c35d312987
patch 8.1.0753: printf format not checked for semsg()
Bram Moolenaar <Bram@vim.org>
parents:
15488
diff
changeset
|
1293 emsg(p); |
7 | 1294 vim_free(p); |
1295 } | |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18904
diff
changeset
|
1296 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
|
1297 ESTACK_CHECK_NOW |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18904
diff
changeset
|
1298 estack_pop(); |
7 | 1299 } |
1300 | |
1301 /* | |
1302 * On an interrupt or an aborting error not converted to an exception, | |
1303 * 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
|
1304 * converted anymore, here.) This enables also the interrupt message |
7 | 1305 * when force_abort is set and did_emsg unset in case of an interrupt |
1306 * from a finally clause after an error. | |
1307 */ | |
1308 else if (got_int || (did_emsg && force_abort)) | |
1309 suppress_errthrow = TRUE; | |
1310 } | |
1311 | |
1312 /* | |
1313 * The current cstack will be freed when do_cmdline() returns. An uncaught | |
1314 * exception will have to be rethrown in the previous cstack. If a function | |
1315 * has just returned or a script file was just finished and the previous | |
1316 * cstack belongs to the same function or, respectively, script file, it | |
1317 * will have to be checked for finally clauses to be executed due to the | |
1318 * ":return" or ":finish". This is done in do_one_cmd(). | |
1319 */ | |
1320 if (did_throw) | |
1321 need_rethrow = TRUE; | |
2635 | 1322 if ((getline_equal(fgetline, cookie, getsourceline) |
7 | 1323 && ex_nesting_level > source_level(real_cookie)) |
2635 | 1324 || (getline_equal(fgetline, cookie, get_func_line) |
7 | 1325 && ex_nesting_level > func_level(real_cookie) + 1)) |
1326 { | |
1327 if (!did_throw) | |
1328 check_cstack = TRUE; | |
1329 } | |
1330 else | |
1331 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1332 // When leaving a function, reduce nesting level. |
2635 | 1333 if (getline_equal(fgetline, cookie, get_func_line)) |
7 | 1334 --ex_nesting_level; |
1335 /* | |
1336 * Go to debug mode when returning from a function in which we are | |
1337 * single-stepping. | |
1338 */ | |
2635 | 1339 if ((getline_equal(fgetline, cookie, getsourceline) |
1340 || getline_equal(fgetline, cookie, get_func_line)) | |
7 | 1341 && ex_nesting_level + 1 <= debug_break_level) |
2635 | 1342 do_debug(getline_equal(fgetline, cookie, getsourceline) |
7 | 1343 ? (char_u *)_("End of sourced file") |
1344 : (char_u *)_("End of function")); | |
1345 } | |
1346 | |
1347 /* | |
1348 * Restore the exception environment (done after returning from the | |
1349 * debugger). | |
1350 */ | |
1351 if (flags & DOCMD_EXCRESET) | |
8 | 1352 restore_dbg_stuff(&debug_saved); |
7 | 1353 |
1354 msg_list = saved_msg_list; | |
19685
d64f403289db
patch 8.2.0399: various memory leaks
Bram Moolenaar <Bram@vim.org>
parents:
19621
diff
changeset
|
1355 |
d64f403289db
patch 8.2.0399: various memory leaks
Bram Moolenaar <Bram@vim.org>
parents:
19621
diff
changeset
|
1356 // Cleanup if "cs_emsg_silent_list" remains. |
d64f403289db
patch 8.2.0399: various memory leaks
Bram Moolenaar <Bram@vim.org>
parents:
19621
diff
changeset
|
1357 if (cstack.cs_emsg_silent_list != NULL) |
d64f403289db
patch 8.2.0399: various memory leaks
Bram Moolenaar <Bram@vim.org>
parents:
19621
diff
changeset
|
1358 { |
d64f403289db
patch 8.2.0399: various memory leaks
Bram Moolenaar <Bram@vim.org>
parents:
19621
diff
changeset
|
1359 eslist_T *elem, *temp; |
d64f403289db
patch 8.2.0399: various memory leaks
Bram Moolenaar <Bram@vim.org>
parents:
19621
diff
changeset
|
1360 |
d64f403289db
patch 8.2.0399: various memory leaks
Bram Moolenaar <Bram@vim.org>
parents:
19621
diff
changeset
|
1361 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
|
1362 { |
d64f403289db
patch 8.2.0399: various memory leaks
Bram Moolenaar <Bram@vim.org>
parents:
19621
diff
changeset
|
1363 temp = elem->next; |
d64f403289db
patch 8.2.0399: various memory leaks
Bram Moolenaar <Bram@vim.org>
parents:
19621
diff
changeset
|
1364 vim_free(elem); |
d64f403289db
patch 8.2.0399: various memory leaks
Bram Moolenaar <Bram@vim.org>
parents:
19621
diff
changeset
|
1365 } |
d64f403289db
patch 8.2.0399: various memory leaks
Bram Moolenaar <Bram@vim.org>
parents:
19621
diff
changeset
|
1366 } |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1367 #endif // FEAT_EVAL |
7 | 1368 |
1369 /* | |
1370 * If there was too much output to fit on the command line, ask the user to | |
1371 * hit return before redrawing the screen. With the ":global" command we do | |
1372 * this only once after the command is finished. | |
1373 */ | |
1374 if (did_inc) | |
1375 { | |
1376 --RedrawingDisabled; | |
1377 --no_wait_return; | |
1378 msg_scroll = FALSE; | |
1379 | |
1380 /* | |
1381 * When just finished an ":if"-":else" which was typed, no need to | |
1382 * wait for hit-return. Also for an error situation. | |
1383 */ | |
1384 if (retval == FAIL | |
1385 #ifdef FEAT_EVAL | |
1386 || (did_endif && KeyTyped && !did_emsg) | |
1387 #endif | |
1388 ) | |
1389 { | |
1390 need_wait_return = FALSE; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1391 msg_didany = FALSE; // don't wait when restarting edit |
7 | 1392 } |
1393 else if (need_wait_return) | |
1394 { | |
1395 /* | |
1396 * The msg_start() above clears msg_didout. The wait_return we do | |
1397 * here should not overwrite the command that may be shown before | |
1398 * doing that. | |
1399 */ | |
1400 msg_didout |= msg_didout_before_start; | |
1401 wait_return(FALSE); | |
1402 } | |
1403 } | |
1404 | |
3976 | 1405 #ifdef FEAT_EVAL |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1406 did_endif = FALSE; // in case do_cmdline used recursively |
3976 | 1407 #else |
7 | 1408 /* |
1409 * Reset if_level, in case a sourced script file contains more ":if" than | |
1410 * ":endif" (could be ":if x | foo | endif"). | |
1411 */ | |
1412 if_level = 0; | |
3972 | 1413 #endif |
3963 | 1414 |
7 | 1415 --call_depth; |
1416 return retval; | |
1417 } | |
1418 | |
1419 #ifdef FEAT_EVAL | |
1420 /* | |
72 | 1421 * Obtain a line when inside a ":while" or ":for" loop. |
7 | 1422 */ |
1423 static char_u * | |
21885
72525eabfe61
patch 8.2.1492: build failures
Bram Moolenaar <Bram@vim.org>
parents:
21883
diff
changeset
|
1424 get_loop_line(int c, void *cookie, int indent, getline_opt_T options) |
7 | 1425 { |
72 | 1426 struct loop_cookie *cp = (struct loop_cookie *)cookie; |
7 | 1427 wcmd_T *wp; |
1428 char_u *line; | |
1429 | |
1430 if (cp->current_line + 1 >= cp->lines_gap->ga_len) | |
1431 { | |
1432 if (cp->repeating) | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1433 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
|
1434 |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1435 // First time inside the ":while"/":for": get line normally. |
7 | 1436 if (cp->getline == NULL) |
21885
72525eabfe61
patch 8.2.1492: build failures
Bram Moolenaar <Bram@vim.org>
parents:
21883
diff
changeset
|
1437 line = getcmdline(c, 0L, indent, options); |
7 | 1438 else |
21885
72525eabfe61
patch 8.2.1492: build failures
Bram Moolenaar <Bram@vim.org>
parents:
21883
diff
changeset
|
1439 line = cp->getline(c, cp->cookie, indent, options); |
857 | 1440 if (line != NULL && store_loop_line(cp->lines_gap, line) == OK) |
7 | 1441 ++cp->current_line; |
1442 | |
1443 return line; | |
1444 } | |
1445 | |
1446 KeyTyped = FALSE; | |
1447 ++cp->current_line; | |
1448 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
|
1449 SOURCING_LNUM = wp->lnum; |
7 | 1450 return vim_strsave(wp->line); |
1451 } | |
1452 | |
1453 /* | |
1454 * Store a line in "gap" so that a ":while" loop can execute it again. | |
1455 */ | |
1456 static int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
1457 store_loop_line(garray_T *gap, char_u *line) |
7 | 1458 { |
1459 if (ga_grow(gap, 1) == FAIL) | |
1460 return FAIL; | |
1461 ((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
|
1462 ((wcmd_T *)(gap->ga_data))[gap->ga_len].lnum = SOURCING_LNUM; |
7 | 1463 ++gap->ga_len; |
1464 return OK; | |
1465 } | |
1466 | |
1467 /* | |
72 | 1468 * Free the lines stored for a ":while" or ":for" loop. |
7 | 1469 */ |
1470 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
1471 free_cmdlines(garray_T *gap) |
7 | 1472 { |
1473 while (gap->ga_len > 0) | |
1474 { | |
1475 vim_free(((wcmd_T *)(gap->ga_data))[gap->ga_len - 1].line); | |
1476 --gap->ga_len; | |
1477 } | |
1478 } | |
1479 #endif | |
1480 | |
1481 /* | |
944 | 1482 * If "fgetline" is get_loop_line(), return TRUE if the getline it uses equals |
1483 * "func". * Otherwise return TRUE when "fgetline" equals "func". | |
7 | 1484 */ |
1485 int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
1486 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
|
1487 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
|
1488 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
|
1489 char_u *(*func)(int, void *, int, getline_opt_T)) |
7 | 1490 { |
1491 #ifdef FEAT_EVAL | |
21885
72525eabfe61
patch 8.2.1492: build failures
Bram Moolenaar <Bram@vim.org>
parents:
21883
diff
changeset
|
1492 char_u *(*gp)(int, void *, int, getline_opt_T); |
72 | 1493 struct loop_cookie *cp; |
1494 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1495 // 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
|
1496 // 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
|
1497 // nested several levels. |
944 | 1498 gp = fgetline; |
72 | 1499 cp = (struct loop_cookie *)cookie; |
1500 while (gp == get_loop_line) | |
7 | 1501 { |
1502 gp = cp->getline; | |
1503 cp = cp->cookie; | |
1504 } | |
1505 return gp == func; | |
1506 #else | |
944 | 1507 return fgetline == func; |
7 | 1508 #endif |
1509 } | |
1510 | |
1511 /* | |
944 | 1512 * If "fgetline" is get_loop_line(), return the cookie used by the original |
7 | 1513 * getline function. Otherwise return "cookie". |
1514 */ | |
1515 void * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
1516 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
|
1517 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
|
1518 void *cookie) // argument for fgetline() |
7 | 1519 { |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
1520 #ifdef FEAT_EVAL |
21885
72525eabfe61
patch 8.2.1492: build failures
Bram Moolenaar <Bram@vim.org>
parents:
21883
diff
changeset
|
1521 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
|
1522 struct loop_cookie *cp; |
72 | 1523 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1524 // 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
|
1525 // 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
|
1526 // several levels. |
944 | 1527 gp = fgetline; |
72 | 1528 cp = (struct loop_cookie *)cookie; |
1529 while (gp == get_loop_line) | |
7 | 1530 { |
1531 gp = cp->getline; | |
1532 cp = cp->cookie; | |
1533 } | |
1534 return cp; | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
1535 #else |
7 | 1536 return cookie; |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
1537 #endif |
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
1538 } |
7 | 1539 |
21056
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1540 #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
|
1541 /* |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1542 * 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
|
1543 */ |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1544 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
|
1545 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
|
1546 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
|
1547 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
|
1548 { |
21885
72525eabfe61
patch 8.2.1492: build failures
Bram Moolenaar <Bram@vim.org>
parents:
21883
diff
changeset
|
1549 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
|
1550 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
|
1551 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
|
1552 |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1553 // 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
|
1554 // 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
|
1555 // 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
|
1556 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
|
1557 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
|
1558 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
|
1559 { |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1560 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
|
1561 { |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1562 // 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
|
1563 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
|
1564 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
|
1565 } |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1566 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
|
1567 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
|
1568 } |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1569 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
|
1570 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
|
1571 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
|
1572 } |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1573 #endif |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1574 |
6398 | 1575 |
1576 /* | |
1577 * Helper function to apply an offset for buffer commands, i.e. ":bdelete", | |
1578 * ":bwipeout", etc. | |
1579 * Returns the buffer number. | |
1580 */ | |
1581 static int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
1582 compute_buffer_local_count(int addr_type, int lnum, int offset) |
6398 | 1583 { |
1584 buf_T *buf; | |
6417 | 1585 buf_T *nextbuf; |
6398 | 1586 int count = offset; |
1587 | |
1588 buf = firstbuf; | |
1589 while (buf->b_next != NULL && buf->b_fnum < lnum) | |
1590 buf = buf->b_next; | |
1591 while (count != 0) | |
1592 { | |
6417 | 1593 count += (offset < 0) ? 1 : -1; |
1594 nextbuf = (offset < 0) ? buf->b_prev : buf->b_next; | |
1595 if (nextbuf == NULL) | |
6398 | 1596 break; |
6417 | 1597 buf = nextbuf; |
6398 | 1598 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
|
1599 // skip over unloaded buffers |
6417 | 1600 while (buf->b_ml.ml_mfp == NULL) |
1601 { | |
1602 nextbuf = (offset < 0) ? buf->b_prev : buf->b_next; | |
1603 if (nextbuf == NULL) | |
1604 break; | |
1605 buf = nextbuf; | |
1606 } | |
1607 } | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1608 // we might have gone too far, last buffer is not loadedd |
6417 | 1609 if (addr_type == ADDR_LOADED_BUFFERS) |
1610 while (buf->b_ml.ml_mfp == NULL) | |
1611 { | |
1612 nextbuf = (offset >= 0) ? buf->b_prev : buf->b_next; | |
1613 if (nextbuf == NULL) | |
1614 break; | |
1615 buf = nextbuf; | |
1616 } | |
6398 | 1617 return buf->b_fnum; |
1618 } | |
1619 | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
1620 /* |
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
1621 * 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
|
1622 * 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
|
1623 */ |
6409 | 1624 static int |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
1625 current_win_nr(win_T *win) |
6409 | 1626 { |
1627 win_T *wp; | |
1628 int nr = 0; | |
1629 | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9538
diff
changeset
|
1630 FOR_ALL_WINDOWS(wp) |
6409 | 1631 { |
1632 ++nr; | |
1633 if (wp == win) | |
1634 break; | |
1635 } | |
1636 return nr; | |
1637 } | |
1638 | |
1639 static int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
1640 current_tab_nr(tabpage_T *tab) |
6409 | 1641 { |
1642 tabpage_T *tp; | |
1643 int nr = 0; | |
1644 | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9538
diff
changeset
|
1645 FOR_ALL_TABPAGES(tp) |
6409 | 1646 { |
1647 ++nr; | |
1648 if (tp == tab) | |
1649 break; | |
1650 } | |
1651 return nr; | |
1652 } | |
1653 | |
21357
72bf1b368cfe
patch 8.2.1229: build error without the eval feature
Bram Moolenaar <Bram@vim.org>
parents:
21353
diff
changeset
|
1654 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
|
1655 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
|
1656 { |
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21335
diff
changeset
|
1657 #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
|
1658 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
|
1659 return p[0] == '#' && p[1] != '{' && !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
|
1660 #endif |
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21335
diff
changeset
|
1661 return *p == '"'; |
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21335
diff
changeset
|
1662 } |
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21335
diff
changeset
|
1663 |
6409 | 1664 # define CURRENT_WIN_NR current_win_nr(curwin) |
1665 # define LAST_WIN_NR current_win_nr(NULL) | |
1666 # define CURRENT_TAB_NR current_tab_nr(curtab) | |
1667 # define LAST_TAB_NR current_tab_nr(NULL) | |
6398 | 1668 |
7 | 1669 /* |
1670 * Execute one Ex command. | |
1671 * | |
1672 * If 'sourcing' is TRUE, the command will be included in the error message. | |
1673 * | |
1674 * 1. skip comment lines and leading space | |
1675 * 2. handle command modifiers | |
6400 | 1676 * 3. find the command |
6398 | 1677 * 4. parse range |
6400 | 1678 * 5. Parse the command. |
6398 | 1679 * 6. parse arguments |
1680 * 7. switch on command name | |
7 | 1681 * |
944 | 1682 * Note: "fgetline" can be NULL. |
7 | 1683 * |
1684 * This function may be called recursively! | |
1685 */ | |
1686 #if (_MSC_VER == 1200) | |
1687 /* | |
8 | 1688 * Avoid optimisation bug in VC++ version 6.0 |
7 | 1689 */ |
128 | 1690 #pragma optimize( "g", off ) |
7 | 1691 #endif |
1692 static char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
1693 do_one_cmd( |
18904
2bdc2e1f6e1f
patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents:
18849
diff
changeset
|
1694 char_u **cmdlinep, |
2bdc2e1f6e1f
patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents:
18849
diff
changeset
|
1695 int sourcing, |
7 | 1696 #ifdef FEAT_EVAL |
18904
2bdc2e1f6e1f
patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents:
18849
diff
changeset
|
1697 cstack_T *cstack, |
2bdc2e1f6e1f
patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents:
18849
diff
changeset
|
1698 #endif |
21885
72525eabfe61
patch 8.2.1492: build failures
Bram Moolenaar <Bram@vim.org>
parents:
21883
diff
changeset
|
1699 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
|
1700 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
|
1701 { |
2bdc2e1f6e1f
patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents:
18849
diff
changeset
|
1702 char_u *p; |
2bdc2e1f6e1f
patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents:
18849
diff
changeset
|
1703 linenr_T lnum; |
2bdc2e1f6e1f
patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents:
18849
diff
changeset
|
1704 long n; |
2bdc2e1f6e1f
patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents:
18849
diff
changeset
|
1705 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
|
1706 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
|
1707 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
|
1708 int save_msg_scroll = msg_scroll; |
2bdc2e1f6e1f
patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents:
18849
diff
changeset
|
1709 cmdmod_T save_cmdmod; |
2bdc2e1f6e1f
patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents:
18849
diff
changeset
|
1710 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
|
1711 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
|
1712 char_u *cmd; |
21357
72bf1b368cfe
patch 8.2.1229: build error without the eval feature
Bram Moolenaar <Bram@vim.org>
parents:
21353
diff
changeset
|
1713 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
|
1714 #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
|
1715 int may_have_range; |
21335
af3663df42bf
patch 8.2.1218: Vim9: cannot use 'text'->func()
Bram Moolenaar <Bram@vim.org>
parents:
21279
diff
changeset
|
1716 int vim9script = in_vim9script(); |
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
|
1717 #endif |
7 | 1718 |
20007
aadd1cae2ff5
patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
1719 CLEAR_FIELD(ea); |
7 | 1720 ea.line1 = 1; |
1721 ea.line2 = 1; | |
1722 #ifdef FEAT_EVAL | |
1723 ++ex_nesting_level; | |
1724 #endif | |
1725 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1726 // When the last file has not been edited :q has to be typed twice. |
7 | 1727 if (quitmore |
1728 #ifdef FEAT_EVAL | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1729 // avoid that a function call in 'statusline' does this |
944 | 1730 && !getline_equal(fgetline, cookie, get_func_line) |
4133 | 1731 #endif |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1732 // 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
|
1733 && !getline_equal(fgetline, cookie, getnextac)) |
7 | 1734 --quitmore; |
1735 | |
1736 /* | |
1737 * Reset browse, confirm, etc.. They are restored when returning, for | |
1738 * recursive calls. | |
1739 */ | |
1740 save_cmdmod = cmdmod; | |
1741 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1742 // "#!anything" is handled like a comment. |
930 | 1743 if ((*cmdlinep)[0] == '#' && (*cmdlinep)[1] == '!') |
1744 goto doend; | |
1745 | |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
1746 /* |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
1747 * 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
|
1748 * 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
|
1749 */ |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
1750 // The "ea" structure holds the arguments that can be used. |
7 | 1751 ea.cmd = *cmdlinep; |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
1752 ea.cmdlinep = cmdlinep; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
1753 ea.getline = fgetline; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
1754 ea.cookie = cookie; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
1755 #ifdef FEAT_EVAL |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
1756 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
|
1757 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
|
1758 #endif |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
1759 if (parse_command_modifiers(&ea, &errormsg, FALSE) == FAIL) |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
1760 goto doend; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
1761 |
9941
e975914c17e9
commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
9927
diff
changeset
|
1762 after_modifier = ea.cmd; |
7 | 1763 |
1764 #ifdef FEAT_EVAL | |
1765 ea.skip = did_emsg || got_int || did_throw || (cstack->cs_idx >= 0 | |
1766 && !(cstack->cs_flags[cstack->cs_idx] & CSF_ACTIVE)); | |
1767 #else | |
1768 ea.skip = (if_level > 0); | |
1769 #endif | |
1770 | |
1771 /* | |
6398 | 1772 * 3. Skip over the range to find the command. Let "p" point to after it. |
1773 * | |
1774 * We need the command to know what kind of range it uses. | |
1775 */ | |
1776 cmd = ea.cmd; | |
21335
af3663df42bf
patch 8.2.1218: Vim9: cannot use 'text'->func()
Bram Moolenaar <Bram@vim.org>
parents:
21279
diff
changeset
|
1777 #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
|
1778 // In Vim9 script a colon is required before the range. |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
1779 may_have_range = !vim9script || starts_with_colon; |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
1780 if (may_have_range) |
21335
af3663df42bf
patch 8.2.1218: Vim9: cannot use 'text'->func()
Bram Moolenaar <Bram@vim.org>
parents:
21279
diff
changeset
|
1781 #endif |
af3663df42bf
patch 8.2.1218: Vim9: cannot use 'text'->func()
Bram Moolenaar <Bram@vim.org>
parents:
21279
diff
changeset
|
1782 ea.cmd = skip_range(ea.cmd, NULL); |
6398 | 1783 if (*ea.cmd == '*' && vim_strchr(p_cpo, CPO_STAR) == NULL) |
1784 ea.cmd = skipwhite(ea.cmd + 1); | |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
1785 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
1786 #ifdef FEAT_EVAL |
21335
af3663df42bf
patch 8.2.1218: Vim9: cannot use 'text'->func()
Bram Moolenaar <Bram@vim.org>
parents:
21279
diff
changeset
|
1787 if (vim9script && !starts_with_colon) |
20982
bb49b5090a9c
patch 8.2.1042: Vim9: cannot put an operator on the next line
Bram Moolenaar <Bram@vim.org>
parents:
20897
diff
changeset
|
1788 { |
21526
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
1789 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
|
1790 // 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
|
1791 --ea.cmd; |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
1792 else if (ea.cmd > cmd) |
20982
bb49b5090a9c
patch 8.2.1042: Vim9: cannot put an operator on the next line
Bram Moolenaar <Bram@vim.org>
parents:
20897
diff
changeset
|
1793 { |
21789
f84625b961a8
patch 8.2.1444: error messages are spread out and names can be confusing
Bram Moolenaar <Bram@vim.org>
parents:
21773
diff
changeset
|
1794 emsg(_(e_colon_required_before_a_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
|
1795 goto doend; |
bb49b5090a9c
patch 8.2.1042: Vim9: cannot put an operator on the next line
Bram Moolenaar <Bram@vim.org>
parents:
20897
diff
changeset
|
1796 } |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
1797 p = find_ex_command(&ea, NULL, lookup_scriptvar, NULL); |
20982
bb49b5090a9c
patch 8.2.1042: Vim9: cannot put an operator on the next line
Bram Moolenaar <Bram@vim.org>
parents:
20897
diff
changeset
|
1798 } |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
1799 else |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
1800 #endif |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
1801 p = find_ex_command(&ea, NULL, NULL, NULL); |
6398 | 1802 |
14591
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1803 #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
|
1804 # 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
|
1805 // 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
|
1806 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
|
1807 && (!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
|
1808 && (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
|
1809 { |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1810 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
|
1811 |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1812 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
|
1813 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
|
1814 && (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
|
1815 && !(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
|
1816 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
|
1817 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
|
1818 && !(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
|
1819 & (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
|
1820 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
|
1821 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
|
1822 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
|
1823 && 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
|
1824 && 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
|
1825 && 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
|
1826 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
|
1827 |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1828 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
|
1829 { |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1830 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
|
1831 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
|
1832 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
|
1833 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
|
1834 } |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1835 } |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1836 # endif |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1837 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1838 // 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
|
1839 // 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
|
1840 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
|
1841 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
|
1842 { |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1843 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
|
1844 (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
|
1845 } |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1846 #endif |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1847 |
6398 | 1848 /* |
1849 * 4. parse a range specifier of the form: addr [,addr] [;addr] .. | |
7 | 1850 * |
1851 * where 'addr' is: | |
1852 * | |
1853 * % (entire file) | |
1854 * $ [+-NUM] | |
1855 * 'x [+-NUM] (where x denotes a currently defined mark) | |
1856 * . [+-NUM] | |
1857 * [+-NUM].. | |
1858 * NUM | |
1859 * | |
1860 * The ea.cmd pointer is updated to point to the first character following the | |
1861 * range spec. If an initial address is found, but no second, the upper bound | |
1862 * is equal to the lower. | |
1863 */ | |
1864 | |
16515
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
1865 // ea.addr_type for user commands is set by find_ucmd |
6489 | 1866 if (!IS_USER_CMDIDX(ea.cmdidx)) |
1867 { | |
1868 if (ea.cmdidx != CMD_SIZE) | |
1869 ea.addr_type = cmdnames[(int)ea.cmdidx].cmd_addr_type; | |
1870 else | |
1871 ea.addr_type = ADDR_LINES; | |
1872 | |
16515
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
1873 // :wincmd range depends on the argument. |
6506 | 1874 if (ea.cmdidx == CMD_wincmd && p != NULL) |
1875 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
|
1876 #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
|
1877 // :.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
|
1878 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
|
1879 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
|
1880 #endif |
6489 | 1881 } |
6398 | 1882 |
6489 | 1883 ea.cmd = cmd; |
21335
af3663df42bf
patch 8.2.1218: Vim9: cannot use 'text'->func()
Bram Moolenaar <Bram@vim.org>
parents:
21279
diff
changeset
|
1884 #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
|
1885 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
|
1886 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
|
1887 else |
21335
af3663df42bf
patch 8.2.1218: Vim9: cannot use 'text'->func()
Bram Moolenaar <Bram@vim.org>
parents:
21279
diff
changeset
|
1888 #endif |
af3663df42bf
patch 8.2.1218: Vim9: cannot use 'text'->func()
Bram Moolenaar <Bram@vim.org>
parents:
21279
diff
changeset
|
1889 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
|
1890 goto doend; |
7 | 1891 |
1892 /* | |
6398 | 1893 * 5. Parse the command. |
7 | 1894 */ |
1895 | |
1896 /* | |
1897 * Skip ':' and any white space | |
1898 */ | |
1899 ea.cmd = skipwhite(ea.cmd); | |
1900 while (*ea.cmd == ':') | |
1901 ea.cmd = skipwhite(ea.cmd + 1); | |
1902 | |
1903 /* | |
1904 * If we got a line, but no command, then go to the line. | |
1905 * If we find a '|' or '\n' we set ea.nextcmd. | |
1906 */ | |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21335
diff
changeset
|
1907 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
|
1908 || (ea.nextcmd = check_nextcmd(ea.cmd)) != NULL) |
7 | 1909 { |
1910 /* | |
1911 * strange vi behaviour: | |
1912 * ":3" jumps to line 3 | |
1913 * ":3|..." prints line 3 | |
1914 * ":|" prints current line | |
1915 */ | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1916 if (ea.skip) // skip this if inside :if |
7 | 1917 goto doend; |
167 | 1918 if (*ea.cmd == '|' || (exmode_active && ea.line1 != ea.line2)) |
7 | 1919 { |
1920 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
|
1921 ea.argt = EX_RANGE+EX_COUNT+EX_TRLBAR; |
7 | 1922 if ((errormsg = invalid_range(&ea)) == NULL) |
1923 { | |
1924 correct_range(&ea); | |
1925 ex_print(&ea); | |
1926 } | |
1927 } | |
1928 else if (ea.addr_count != 0) | |
1929 { | |
631 | 1930 if (ea.line2 > curbuf->b_ml.ml_line_count) |
1931 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1932 // 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
|
1933 // error, otherwise put it at the end of the file. |
631 | 1934 if (vim_strchr(p_cpo, CPO_MINUS) != NULL) |
1935 ea.line2 = -1; | |
1936 else | |
1937 ea.line2 = curbuf->b_ml.ml_line_count; | |
1938 } | |
1939 | |
1940 if (ea.line2 < 0) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
1941 errormsg = _(e_invrange); |
7 | 1942 else |
1943 { | |
1944 if (ea.line2 == 0) | |
1945 curwin->w_cursor.lnum = 1; | |
1946 else | |
1947 curwin->w_cursor.lnum = ea.line2; | |
1948 beginline(BL_SOL | BL_FIX); | |
1949 } | |
1950 } | |
1951 goto doend; | |
1952 } | |
1953 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1954 // 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
|
1955 // autocommands defined, trigger the matching autocommands. |
6154 | 1956 if (p != NULL && ea.cmdidx == CMD_SIZE && !ea.skip |
1957 && ASCII_ISUPPER(*ea.cmd) | |
1958 && has_cmdundefined()) | |
1959 { | |
1960 int ret; | |
1961 | |
6156 | 1962 p = ea.cmd; |
6154 | 1963 while (ASCII_ISALNUM(*p)) |
1964 ++p; | |
20897
213fb059e02e
patch 8.2.1000: get error when leaving Ex mode with :visual
Bram Moolenaar <Bram@vim.org>
parents:
20711
diff
changeset
|
1965 p = vim_strnsave(ea.cmd, p - ea.cmd); |
6154 | 1966 ret = apply_autocmds(EVENT_CMDUNDEFINED, p, p, TRUE, NULL); |
1967 vim_free(p); | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1968 // 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
|
1969 // finding the command again. |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
1970 p = (ret |
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
1971 #ifdef FEAT_EVAL |
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
1972 && !aborting() |
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
1973 #endif |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
1974 ) ? 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
|
1975 } |
6154 | 1976 |
7 | 1977 if (p == NULL) |
1978 { | |
1979 if (!ea.skip) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
1980 errormsg = _("E464: Ambiguous use of user-defined command"); |
7 | 1981 goto doend; |
1982 } | |
16411
5b5c5daf57de
patch 8.1.1210: support for user commands is spread out
Bram Moolenaar <Bram@vim.org>
parents:
16399
diff
changeset
|
1983 // 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
|
1984 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
|
1985 && !IS_USER_CMDIDX(ea.cmdidx)) |
7 | 1986 { |
1987 errormsg = uc_fun_cmd(); | |
1988 goto doend; | |
1989 } | |
16411
5b5c5daf57de
patch 8.1.1210: support for user commands is spread out
Bram Moolenaar <Bram@vim.org>
parents:
16399
diff
changeset
|
1990 |
7 | 1991 if (ea.cmdidx == CMD_SIZE) |
1992 { | |
1993 if (!ea.skip) | |
1994 { | |
1995 STRCPY(IObuff, _("E492: Not an editor command")); | |
1996 if (!sourcing) | |
9941
e975914c17e9
commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
9927
diff
changeset
|
1997 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1998 // 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
|
1999 // following command |
9941
e975914c17e9
commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
9927
diff
changeset
|
2000 if (after_modifier != NULL) |
e975914c17e9
commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
9927
diff
changeset
|
2001 append_command(after_modifier); |
e975914c17e9
commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
9927
diff
changeset
|
2002 else |
e975914c17e9
commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
9927
diff
changeset
|
2003 append_command(*cmdlinep); |
e975914c17e9
commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
9927
diff
changeset
|
2004 } |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2005 errormsg = (char *)IObuff; |
3757 | 2006 did_emsg_syntax = TRUE; |
7 | 2007 } |
2008 goto doend; | |
2009 } | |
2010 | |
6305 | 2011 ni = (!IS_USER_CMDIDX(ea.cmdidx) |
2012 && (cmdnames[ea.cmdidx].cmd_func == ex_ni | |
1315 | 2013 #ifdef HAVE_EX_SCRIPT_NI |
2014 || cmdnames[ea.cmdidx].cmd_func == ex_script_ni | |
2015 #endif | |
2016 )); | |
7 | 2017 |
2018 #ifndef FEAT_EVAL | |
2019 /* | |
2020 * When the expression evaluation is disabled, recognize the ":if" and | |
2021 * ":endif" commands and ignore everything in between it. | |
2022 */ | |
2023 if (ea.cmdidx == CMD_if) | |
2024 ++if_level; | |
2025 if (if_level) | |
2026 { | |
2027 if (ea.cmdidx == CMD_endif) | |
2028 --if_level; | |
2029 goto doend; | |
2030 } | |
2031 | |
2032 #endif | |
2033 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2034 // forced commands |
1613 | 2035 if (*p == '!' && ea.cmdidx != CMD_substitute |
2036 && ea.cmdidx != CMD_smagic && ea.cmdidx != CMD_snomagic) | |
7 | 2037 { |
2038 ++p; | |
2039 ea.forceit = TRUE; | |
2040 } | |
2041 else | |
2042 ea.forceit = FALSE; | |
2043 | |
2044 /* | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
2045 * 6. Parse arguments. Then check for errors. |
7 | 2046 */ |
6305 | 2047 if (!IS_USER_CMDIDX(ea.cmdidx)) |
835 | 2048 ea.argt = (long)cmdnames[(int)ea.cmdidx].cmd_argt; |
7 | 2049 |
2050 if (!ea.skip) | |
2051 { | |
2052 #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
|
2053 if (sandbox != 0 && !(ea.argt & EX_SBOXOK)) |
7 | 2054 { |
15748
93b78c4a7cd5
patch 8.1.0881: can execute shell commands in rvim through interfaces
Bram Moolenaar <Bram@vim.org>
parents:
15713
diff
changeset
|
2055 // Command not allowed in sandbox. |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2056 errormsg = _(e_sandbox); |
7 | 2057 goto doend; |
2058 } | |
2059 #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
|
2060 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
|
2061 { |
93b78c4a7cd5
patch 8.1.0881: can execute shell commands in rvim through interfaces
Bram Moolenaar <Bram@vim.org>
parents:
15713
diff
changeset
|
2062 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
|
2063 goto doend; |
93b78c4a7cd5
patch 8.1.0881: can execute shell commands in rvim through interfaces
Bram Moolenaar <Bram@vim.org>
parents:
15713
diff
changeset
|
2064 } |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2065 if (!curbuf->b_p_ma && (ea.argt & EX_MODIFY)) |
7 | 2066 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2067 // Command not allowed in non-'modifiable' buffer |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2068 errormsg = _(e_modifiable); |
7 | 2069 goto doend; |
2070 } | |
631 | 2071 |
21487
5c92877092f9
patch 8.2.1294: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents:
21475
diff
changeset
|
2072 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
|
2073 { |
5c92877092f9
patch 8.2.1294: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents:
21475
diff
changeset
|
2074 #ifdef FEAT_CMDWIN |
5c92877092f9
patch 8.2.1294: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents:
21475
diff
changeset
|
2075 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
|
2076 { |
5c92877092f9
patch 8.2.1294: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents:
21475
diff
changeset
|
2077 // Command not allowed in the command line window |
5c92877092f9
patch 8.2.1294: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents:
21475
diff
changeset
|
2078 errormsg = _(e_cmdwin); |
5c92877092f9
patch 8.2.1294: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents:
21475
diff
changeset
|
2079 goto doend; |
5c92877092f9
patch 8.2.1294: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents:
21475
diff
changeset
|
2080 } |
5c92877092f9
patch 8.2.1294: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents:
21475
diff
changeset
|
2081 #endif |
5c92877092f9
patch 8.2.1294: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents:
21475
diff
changeset
|
2082 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
|
2083 { |
5c92877092f9
patch 8.2.1294: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents:
21475
diff
changeset
|
2084 // 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
|
2085 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
|
2086 goto doend; |
5c92877092f9
patch 8.2.1294: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents:
21475
diff
changeset
|
2087 } |
7 | 2088 } |
14648
c3222a7342ab
patch 8.1.0337: :file fails in quickfix command
Christian Brabandt <cb@256bit.org>
parents:
14640
diff
changeset
|
2089 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2090 // 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
|
2091 // 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
|
2092 // 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
|
2093 // 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
|
2094 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
|
2095 && ea.cmdidx != CMD_checktime |
822 | 2096 && ea.cmdidx != CMD_edit |
14648
c3222a7342ab
patch 8.1.0337: :file fails in quickfix command
Christian Brabandt <cb@256bit.org>
parents:
14640
diff
changeset
|
2097 && ea.cmdidx != CMD_file |
6305 | 2098 && !IS_USER_CMDIDX(ea.cmdidx) |
819 | 2099 && curbuf_locked()) |
2100 goto doend; | |
7 | 2101 |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2102 if (!ni && !(ea.argt & EX_RANGE) && ea.addr_count > 0) |
7 | 2103 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2104 // no range allowed |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2105 errormsg = _(e_norange); |
7 | 2106 goto doend; |
2107 } | |
2108 } | |
2109 | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2110 if (!ni && !(ea.argt & EX_BANG) && ea.forceit) // no <!> allowed |
7 | 2111 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2112 errormsg = _(e_nobang); |
7 | 2113 goto doend; |
2114 } | |
2115 | |
2116 /* | |
2117 * Don't complain about the range if it is not used | |
2118 * (could happen if line_count is accidentally set to 0). | |
2119 */ | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2120 if (!ea.skip && !ni && (ea.argt & EX_RANGE)) |
7 | 2121 { |
2122 /* | |
2123 * If the range is backwards, ask for confirmation and, if given, swap | |
2124 * ea.line1 & ea.line2 so it's forwards again. | |
2125 * When global command is busy, don't ask, will fail below. | |
2126 */ | |
2127 if (!global_busy && ea.line1 > ea.line2) | |
2128 { | |
557 | 2129 if (msg_silent == 0) |
2130 { | |
2131 if (sourcing || exmode_active) | |
2132 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2133 errormsg = _("E493: Backwards range given"); |
557 | 2134 goto doend; |
2135 } | |
7 | 2136 if (ask_yesno((char_u *) |
2137 _("Backwards range given, OK to swap"), FALSE) != 'y') | |
557 | 2138 goto doend; |
7 | 2139 } |
2140 lnum = ea.line1; | |
2141 ea.line1 = ea.line2; | |
2142 ea.line2 = lnum; | |
2143 } | |
2144 if ((errormsg = invalid_range(&ea)) != NULL) | |
2145 goto doend; | |
2146 } | |
2147 | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
2148 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
|
2149 // default is 1, not cursor |
7 | 2150 ea.line2 = 1; |
2151 | |
2152 correct_range(&ea); | |
2153 | |
2154 #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
|
2155 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
|
2156 && ea.addr_type == ADDR_LINES) |
7 | 2157 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2158 // 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
|
2159 // at the end of a closed fold. |
7 | 2160 (void)hasFolding(ea.line1, &ea.line1, NULL); |
2161 (void)hasFolding(ea.line2, NULL, &ea.line2); | |
2162 } | |
2163 #endif | |
2164 | |
2165 #ifdef FEAT_QUICKFIX | |
2166 /* | |
41 | 2167 * For the ":make" and ":grep" commands we insert the 'makeprg'/'grepprg' |
7 | 2168 * option here, so things like % get expanded. |
2169 */ | |
344 | 2170 p = replace_makeprg(&ea, p, cmdlinep); |
2171 if (p == NULL) | |
2172 goto doend; | |
7 | 2173 #endif |
2174 | |
2175 /* | |
2176 * Skip to start of argument. | |
2177 * Don't do this for the ":!" command, because ":!! -l" needs the space. | |
2178 */ | |
2179 if (ea.cmdidx == CMD_bang) | |
2180 ea.arg = p; | |
2181 else | |
2182 ea.arg = skipwhite(p); | |
2183 | |
14648
c3222a7342ab
patch 8.1.0337: :file fails in quickfix command
Christian Brabandt <cb@256bit.org>
parents:
14640
diff
changeset
|
2184 // ":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
|
2185 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
|
2186 goto doend; |
c3222a7342ab
patch 8.1.0337: :file fails in quickfix command
Christian Brabandt <cb@256bit.org>
parents:
14640
diff
changeset
|
2187 |
7 | 2188 /* |
2189 * Check for "++opt=val" argument. | |
2190 * Must be first, allow ":w ++enc=utf8 !cmd" | |
2191 */ | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2192 if (ea.argt & EX_ARGOPT) |
7 | 2193 while (ea.arg[0] == '+' && ea.arg[1] == '+') |
2194 if (getargopt(&ea) == FAIL && !ni) | |
2195 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2196 errormsg = _(e_invarg); |
7 | 2197 goto doend; |
2198 } | |
2199 | |
2200 if (ea.cmdidx == CMD_write || ea.cmdidx == CMD_update) | |
2201 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2202 if (*ea.arg == '>') // append |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2203 { |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2204 if (*++ea.arg != '>') // typed wrong |
7 | 2205 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2206 errormsg = _("E494: Use w or w>>"); |
7 | 2207 goto doend; |
2208 } | |
2209 ea.arg = skipwhite(ea.arg + 1); | |
2210 ea.append = TRUE; | |
2211 } | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2212 else if (*ea.arg == '!' && ea.cmdidx == CMD_write) // :w !filter |
7 | 2213 { |
2214 ++ea.arg; | |
2215 ea.usefilter = TRUE; | |
2216 } | |
2217 } | |
2218 | |
2219 if (ea.cmdidx == CMD_read) | |
2220 { | |
2221 if (ea.forceit) | |
2222 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2223 ea.usefilter = TRUE; // :r! filter if ea.forceit |
7 | 2224 ea.forceit = FALSE; |
2225 } | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2226 else if (*ea.arg == '!') // :r !filter |
7 | 2227 { |
2228 ++ea.arg; | |
2229 ea.usefilter = TRUE; | |
2230 } | |
2231 } | |
2232 | |
2233 if (ea.cmdidx == CMD_lshift || ea.cmdidx == CMD_rshift) | |
2234 { | |
2235 ea.amount = 1; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2236 while (*ea.arg == *ea.cmd) // count number of '>' or '<' |
7 | 2237 { |
2238 ++ea.arg; | |
2239 ++ea.amount; | |
2240 } | |
2241 ea.arg = skipwhite(ea.arg); | |
2242 } | |
2243 | |
2244 /* | |
2245 * Check for "+command" argument, before checking for next command. | |
2246 * Don't do this for ":read !cmd" and ":write !cmd". | |
2247 */ | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2248 if ((ea.argt & EX_CMDARG) && !ea.usefilter) |
7 | 2249 ea.do_ecmd_cmd = getargcmd(&ea.arg); |
2250 | |
2251 /* | |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21335
diff
changeset
|
2252 * Check for '|' to separate commands and '"' or '#' to start comments. |
7 | 2253 * Don't do this for ":read !cmd" and ":write !cmd". |
2254 */ | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2255 if ((ea.argt & EX_TRLBAR) && !ea.usefilter) |
7 | 2256 separate_nextcmd(&ea); |
2257 | |
2258 /* | |
2259 * Check for <newline> to end a shell command. | |
167 | 2260 * Also do this for ":read !cmd", ":write !cmd" and ":global". |
2261 * Any others? | |
7 | 2262 */ |
167 | 2263 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
|
2264 || ea.cmdidx == CMD_terminal |
167 | 2265 || ea.cmdidx == CMD_global |
2266 || ea.cmdidx == CMD_vglobal | |
2267 || ea.usefilter) | |
7 | 2268 { |
2269 for (p = ea.arg; *p; ++p) | |
2270 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2271 // 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
|
2272 // 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
|
2273 // 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
|
2274 // 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
|
2275 // 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
|
2276 // versions. |
7 | 2277 if (*p == '\\' && p[1] == '\n') |
1619 | 2278 STRMOVE(p, p + 1); |
7 | 2279 else if (*p == '\n') |
2280 { | |
2281 ea.nextcmd = p + 1; | |
2282 *p = NUL; | |
2283 break; | |
2284 } | |
2285 } | |
2286 } | |
2287 | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2288 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
|
2289 address_default_all(&ea); |
7 | 2290 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2291 // 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
|
2292 if ( (ea.argt & EX_REGSTR) |
7 | 2293 && *ea.arg != NUL |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2294 // Do not allow register = for user commands |
6305 | 2295 && (!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
|
2296 && !((ea.argt & EX_COUNT) && VIM_ISDIGIT(*ea.arg))) |
7 | 2297 { |
2791 | 2298 #ifndef FEAT_CLIPBOARD |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2299 // check these explicitly for a more specific error message |
2791 | 2300 if (*ea.arg == '*' || *ea.arg == '+') |
2301 { | |
15474
79e3dcc5aa50
patch 8.1.0745: compiler warnings for signed/unsigned string
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
2302 errormsg = _(e_invalidreg); |
2791 | 2303 goto doend; |
2304 } | |
2305 #endif | |
6305 | 2306 if (valid_yank_reg(*ea.arg, (ea.cmdidx != CMD_put |
2307 && !IS_USER_CMDIDX(ea.cmdidx)))) | |
2791 | 2308 { |
2309 ea.regname = *ea.arg++; | |
7 | 2310 #ifdef FEAT_EVAL |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2311 // for '=' register: accept the rest of the line as an expression |
2791 | 2312 if (ea.arg[-1] == '=' && ea.arg[0] != NUL) |
2313 { | |
2314 set_expr_line(vim_strsave(ea.arg)); | |
2315 ea.arg += STRLEN(ea.arg); | |
2316 } | |
2317 #endif | |
2318 ea.arg = skipwhite(ea.arg); | |
2319 } | |
7 | 2320 } |
2321 | |
2322 /* | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2323 * Check for a count. When accepting a EX_BUFNAME, don't use "123foo" as a |
7 | 2324 * count, it's a buffer name. |
2325 */ | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2326 if ((ea.argt & EX_COUNT) && VIM_ISDIGIT(*ea.arg) |
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2327 && (!(ea.argt & EX_BUFNAME) || *(p = skipdigits(ea.arg)) == NUL |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
2328 || VIM_ISWHITE(*p))) |
7 | 2329 { |
2330 n = getdigits(&ea.arg); | |
2331 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
|
2332 if (n <= 0 && !ni && (ea.argt & EX_ZEROR) == 0) |
7 | 2333 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2334 errormsg = _(e_zerocount); |
7 | 2335 goto doend; |
2336 } | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
2337 if (ea.addr_type != ADDR_LINES) // e.g. :buffer 2, :sleep 3 |
7 | 2338 { |
2339 ea.line2 = n; | |
2340 if (ea.addr_count == 0) | |
2341 ea.addr_count = 1; | |
2342 } | |
2343 else | |
2344 { | |
2345 ea.line1 = ea.line2; | |
2346 ea.line2 += n - 1; | |
2347 ++ea.addr_count; | |
2348 /* | |
2349 * Be vi compatible: no error message for out of range. | |
2350 */ | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
2351 if (ea.line2 > curbuf->b_ml.ml_line_count) |
7 | 2352 ea.line2 = curbuf->b_ml.ml_line_count; |
2353 } | |
2354 } | |
167 | 2355 |
2356 /* | |
2357 * Check for flags: 'l', 'p' and '#'. | |
2358 */ | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2359 if (ea.argt & EX_FLAGS) |
167 | 2360 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
|
2361 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
|
2362 && *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
|
2363 { |
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2364 // 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
|
2365 errormsg = ex_errmsg(e_trailing_arg, ea.arg); |
7 | 2366 goto doend; |
2367 } | |
2368 | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2369 if (!ni && (ea.argt & EX_NEEDARG) && *ea.arg == NUL) |
7 | 2370 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2371 errormsg = _(e_argreq); |
7 | 2372 goto doend; |
2373 } | |
2374 | |
2375 #ifdef FEAT_EVAL | |
2376 /* | |
2377 * Skip the command when it's not going to be executed. | |
2378 * The commands like :if, :endif, etc. always need to be executed. | |
2379 * Also make an exception for commands that handle a trailing command | |
2380 * themselves. | |
2381 */ | |
2382 if (ea.skip) | |
2383 { | |
2384 switch (ea.cmdidx) | |
2385 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2386 // commands that need evaluation |
7 | 2387 case CMD_while: |
2388 case CMD_endwhile: | |
72 | 2389 case CMD_for: |
2390 case CMD_endfor: | |
7 | 2391 case CMD_if: |
2392 case CMD_elseif: | |
2393 case CMD_else: | |
2394 case CMD_endif: | |
2395 case CMD_try: | |
2396 case CMD_catch: | |
2397 case CMD_finally: | |
2398 case CMD_endtry: | |
2399 case CMD_function: | |
19575
3c0de44077cd
patch 8.2.0344: ":def" not skipped properly
Bram Moolenaar <Bram@vim.org>
parents:
19497
diff
changeset
|
2400 case CMD_def: |
7 | 2401 break; |
2402 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2403 // 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
|
2404 // 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
|
2405 // the list at ":help :bar". |
7 | 2406 case CMD_aboveleft: |
2407 case CMD_and: | |
2408 case CMD_belowright: | |
2409 case CMD_botright: | |
2410 case CMD_browse: | |
2411 case CMD_call: | |
2412 case CMD_confirm: | |
18713
baf890fa1621
patch 8.1.2348: :const cannot be followed by "| endif"
Bram Moolenaar <Bram@vim.org>
parents:
18406
diff
changeset
|
2413 case CMD_const: |
7 | 2414 case CMD_delfunction: |
2415 case CMD_djump: | |
2416 case CMD_dlist: | |
2417 case CMD_dsearch: | |
2418 case CMD_dsplit: | |
2419 case CMD_echo: | |
2420 case CMD_echoerr: | |
2421 case CMD_echomsg: | |
2422 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
|
2423 case CMD_eval: |
7 | 2424 case CMD_execute: |
9941
e975914c17e9
commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
9927
diff
changeset
|
2425 case CMD_filter: |
7 | 2426 case CMD_help: |
2427 case CMD_hide: | |
2428 case CMD_ijump: | |
2429 case CMD_ilist: | |
2430 case CMD_isearch: | |
2431 case CMD_isplit: | |
22 | 2432 case CMD_keepalt: |
7 | 2433 case CMD_keepjumps: |
2434 case CMD_keepmarks: | |
5467 | 2435 case CMD_keeppatterns: |
7 | 2436 case CMD_leftabove: |
2437 case CMD_let: | |
2438 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
|
2439 case CMD_lockvar: |
2320
966a5609669e
Added Lua interfae. (Luis Carvalho)
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
2440 case CMD_lua: |
7 | 2441 case CMD_match: |
14 | 2442 case CMD_mzscheme: |
5737 | 2443 case CMD_noautocmd: |
2444 case CMD_noswapfile: | |
7 | 2445 case CMD_perl: |
2446 case CMD_psearch: | |
2447 case CMD_python: | |
2350
06feaf4fe36a
Rename some "python3" symbols to "py3", as the command name.
Bram Moolenaar <bram@vim.org>
parents:
2340
diff
changeset
|
2448 case CMD_py3: |
2366
7a57fe6a5157
Fix that :py3file was not working.
Bram Moolenaar <bram@vim.org>
parents:
2360
diff
changeset
|
2449 case CMD_python3: |
7 | 2450 case CMD_return: |
2451 case CMD_rightbelow: | |
2452 case CMD_ruby: | |
2453 case CMD_silent: | |
2454 case CMD_smagic: | |
2455 case CMD_snomagic: | |
2456 case CMD_substitute: | |
2457 case CMD_syntax: | |
690 | 2458 case CMD_tab: |
7 | 2459 case CMD_tcl: |
2460 case CMD_throw: | |
2461 case CMD_tilde: | |
2462 case CMD_topleft: | |
2463 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
|
2464 case CMD_unlockvar: |
7 | 2465 case CMD_verbose: |
2466 case CMD_vertical: | |
2887 | 2467 case CMD_wincmd: |
7 | 2468 break; |
2469 | |
2470 default: goto doend; | |
2471 } | |
2472 } | |
2473 #endif | |
2474 | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2475 if (ea.argt & EX_XFILE) |
7 | 2476 { |
2477 if (expand_filename(&ea, cmdlinep, &errormsg) == FAIL) | |
2478 goto doend; | |
2479 } | |
2480 | |
2481 /* | |
2482 * Accept buffer name. Cannot be used at the same time with a buffer | |
2483 * number. Don't do this for a user command. | |
2484 */ | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2485 if ((ea.argt & EX_BUFNAME) && *ea.arg != NUL && ea.addr_count == 0 |
6305 | 2486 && !IS_USER_CMDIDX(ea.cmdidx)) |
7 | 2487 { |
2488 /* | |
2489 * :bdelete, :bwipeout and :bunload take several arguments, separated | |
2490 * by spaces: find next space (skipping over escaped characters). | |
2491 * The others take one argument: ignore trailing spaces. | |
2492 */ | |
2493 if (ea.cmdidx == CMD_bdelete || ea.cmdidx == CMD_bwipeout | |
2494 || ea.cmdidx == CMD_bunload) | |
2495 p = skiptowhite_esc(ea.arg); | |
2496 else | |
2497 { | |
2498 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
|
2499 while (p > ea.arg && VIM_ISWHITE(p[-1])) |
7 | 2500 --p; |
2501 } | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2502 ea.line2 = buflist_findpat(ea.arg, p, (ea.argt & EX_BUFUNL) != 0, |
4236 | 2503 FALSE, FALSE); |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2504 if (ea.line2 < 0) // failed |
7 | 2505 goto doend; |
2506 ea.addr_count = 1; | |
2507 ea.arg = skipwhite(p); | |
2508 } | |
2509 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2510 // 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
|
2511 // ":silent! try" was used, it should only apply to :try itself. |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2512 if (ea.cmdidx == CMD_try && ea.did_esilent > 0) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2513 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2514 emsg_silent -= ea.did_esilent; |
13288
530943a23d3f
patch 8.0.1518: error messages suppressed after ":silent! try"
Christian Brabandt <cb@256bit.org>
parents:
13268
diff
changeset
|
2515 if (emsg_silent < 0) |
530943a23d3f
patch 8.0.1518: error messages suppressed after ":silent! try"
Christian Brabandt <cb@256bit.org>
parents:
13268
diff
changeset
|
2516 emsg_silent = 0; |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2517 ea.did_esilent = 0; |
13288
530943a23d3f
patch 8.0.1518: error messages suppressed after ":silent! try"
Christian Brabandt <cb@256bit.org>
parents:
13268
diff
changeset
|
2518 } |
530943a23d3f
patch 8.0.1518: error messages suppressed after ":silent! try"
Christian Brabandt <cb@256bit.org>
parents:
13268
diff
changeset
|
2519 |
530943a23d3f
patch 8.0.1518: error messages suppressed after ":silent! try"
Christian Brabandt <cb@256bit.org>
parents:
13268
diff
changeset
|
2520 /* |
530943a23d3f
patch 8.0.1518: error messages suppressed after ":silent! try"
Christian Brabandt <cb@256bit.org>
parents:
13268
diff
changeset
|
2521 * 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
|
2522 */ |
7 | 2523 |
6305 | 2524 if (IS_USER_CMDIDX(ea.cmdidx)) |
7 | 2525 { |
2526 /* | |
2527 * Execute a user-defined command. | |
2528 */ | |
2529 do_ucmd(&ea); | |
2530 } | |
2531 else | |
2532 { | |
2533 /* | |
16411
5b5c5daf57de
patch 8.1.1210: support for user commands is spread out
Bram Moolenaar <Bram@vim.org>
parents:
16399
diff
changeset
|
2534 * Call the function to execute the builtin command. |
7 | 2535 */ |
2536 ea.errmsg = NULL; | |
2537 (cmdnames[ea.cmdidx].cmd_func)(&ea); | |
2538 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
|
2539 errormsg = ea.errmsg; |
7 | 2540 } |
2541 | |
2542 #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
|
2543 // Set flag that any command was executed, used by ex_vim9script(). |
19348
b6da81589f8c
patch 8.2.0232: the :compiler command causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
19271
diff
changeset
|
2544 if (getline_equal(ea.getline, ea.cookie, getsourceline) |
b6da81589f8c
patch 8.2.0232: the :compiler command causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
19271
diff
changeset
|
2545 && current_sctx.sc_sid > 0) |
19191
133ef7ba4e4e
patch 8.2.0154: reallocating the list of scripts is inefficient
Bram Moolenaar <Bram@vim.org>
parents:
19181
diff
changeset
|
2546 SCRIPT_ITEM(current_sctx.sc_sid)->sn_had_command = TRUE; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
2547 |
7 | 2548 /* |
2549 * If the command just executed called do_cmdline(), any throw or ":return" | |
2550 * or ":finish" encountered there must also check the cstack of the still | |
2551 * active do_cmdline() that called this do_one_cmd(). Rethrow an uncaught | |
2552 * exception, or reanimate a returned function or finished script file and | |
2553 * return or finish it again. | |
2554 */ | |
2555 if (need_rethrow) | |
2556 do_throw(cstack); | |
2557 else if (check_cstack) | |
2558 { | |
944 | 2559 if (source_finished(fgetline, cookie)) |
7 | 2560 do_finish(&ea, TRUE); |
944 | 2561 else if (getline_equal(fgetline, cookie, get_func_line) |
7 | 2562 && current_func_returned()) |
2563 do_return(&ea, TRUE, FALSE, NULL); | |
2564 } | |
2565 need_rethrow = check_cstack = FALSE; | |
2566 #endif | |
2567 | |
2568 doend: | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2569 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
|
2570 { |
7 | 2571 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
|
2572 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
|
2573 } |
7 | 2574 |
2575 if (errormsg != NULL && *errormsg != NUL && !did_emsg) | |
2576 { | |
2577 if (sourcing) | |
2578 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2579 if (errormsg != (char *)IObuff) |
7 | 2580 { |
2581 STRCPY(IObuff, errormsg); | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2582 errormsg = (char *)IObuff; |
7 | 2583 } |
3097 | 2584 append_command(*cmdlinep); |
7 | 2585 } |
2586 emsg(errormsg); | |
2587 } | |
2588 #ifdef FEAT_EVAL | |
2589 do_errthrow(cstack, | |
6305 | 2590 (ea.cmdidx != CMD_SIZE && !IS_USER_CMDIDX(ea.cmdidx)) |
2591 ? cmdnames[(int)ea.cmdidx].cmd_name : (char_u *)NULL); | |
7 | 2592 #endif |
2593 | |
21172
96ae8622cfb6
patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents:
21130
diff
changeset
|
2594 undo_cmdmod(&ea, save_msg_scroll); |
7 | 2595 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
|
2596 reg_executing = save_reg_executing; |
7 | 2597 |
28 | 2598 #ifdef HAVE_SANDBOX |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2599 if (ea.did_sandbox) |
28 | 2600 --sandbox; |
2601 #endif | |
2602 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2603 if (ea.nextcmd && *ea.nextcmd == NUL) // not really a next command |
7 | 2604 ea.nextcmd = NULL; |
2605 | |
2606 #ifdef FEAT_EVAL | |
2607 --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
|
2608 vim_free(ea.cmdline_tofree); |
7 | 2609 #endif |
2610 | |
2611 return ea.nextcmd; | |
2612 } | |
2613 #if (_MSC_VER == 1200) | |
128 | 2614 #pragma optimize( "", on ) |
7 | 2615 #endif |
2616 | |
21459
a422bd80b434
patch 8.2.1280: Ex command error cannot contain an argument
Bram Moolenaar <Bram@vim.org>
parents:
21413
diff
changeset
|
2617 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
|
2618 |
a422bd80b434
patch 8.2.1280: Ex command error cannot contain an argument
Bram Moolenaar <Bram@vim.org>
parents:
21413
diff
changeset
|
2619 /* |
a422bd80b434
patch 8.2.1280: Ex command error cannot contain an argument
Bram Moolenaar <Bram@vim.org>
parents:
21413
diff
changeset
|
2620 * 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
|
2621 * 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
|
2622 * "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
|
2623 */ |
a422bd80b434
patch 8.2.1280: Ex command error cannot contain an argument
Bram Moolenaar <Bram@vim.org>
parents:
21413
diff
changeset
|
2624 char * |
a422bd80b434
patch 8.2.1280: Ex command error cannot contain an argument
Bram Moolenaar <Bram@vim.org>
parents:
21413
diff
changeset
|
2625 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
|
2626 { |
a422bd80b434
patch 8.2.1280: Ex command error cannot contain an argument
Bram Moolenaar <Bram@vim.org>
parents:
21413
diff
changeset
|
2627 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
|
2628 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
|
2629 } |
a422bd80b434
patch 8.2.1280: Ex command error cannot contain an argument
Bram Moolenaar <Bram@vim.org>
parents:
21413
diff
changeset
|
2630 |
7 | 2631 /* |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2632 * 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
|
2633 * - update eap->cmd |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2634 * - store flags in "cmdmod". |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2635 * - Set ex_pressedreturn for an empty command line. |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2636 * - set msg_silent for ":silent" |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2637 * - 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
|
2638 * - set p_verbose for ":verbose" |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2639 * - Increment "sandbox" for ":sandbox" |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2640 * 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
|
2641 * "cmdmod". |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2642 * 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
|
2643 * 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
|
2644 */ |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2645 int |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2646 parse_command_modifiers(exarg_T *eap, char **errormsg, int skip_only) |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2647 { |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21335
diff
changeset
|
2648 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
|
2649 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
|
2650 |
20007
aadd1cae2ff5
patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
2651 CLEAR_FIELD(cmdmod); |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2652 eap->verbose_save = -1; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2653 eap->save_msg_silent = -1; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2654 |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2655 // 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
|
2656 for (;;) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2657 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2658 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
|
2659 { |
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21335
diff
changeset
|
2660 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
|
2661 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
|
2662 ++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
|
2663 } |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2664 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2665 // 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
|
2666 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
|
2667 && (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
|
2668 || 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
|
2669 && 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
|
2670 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2671 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
|
2672 if (!skip_only) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2673 ex_pressedreturn = TRUE; |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2674 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2675 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2676 // 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
|
2677 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
|
2678 return FAIL; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2679 if (*eap->cmd == NUL) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2680 { |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2681 if (!skip_only) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2682 ex_pressedreturn = TRUE; |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2683 return FAIL; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2684 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2685 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2686 p = skip_range(eap->cmd, NULL); |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2687 switch (*p) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2688 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2689 // When adding an entry, also modify cmd_exists(). |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2690 case 'a': if (!checkforcmd(&eap->cmd, "aboveleft", 3)) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2691 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2692 cmdmod.split |= WSP_ABOVE; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2693 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2694 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2695 case 'b': if (checkforcmd(&eap->cmd, "belowright", 3)) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2696 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2697 cmdmod.split |= WSP_BELOW; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2698 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2699 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2700 if (checkforcmd(&eap->cmd, "browse", 3)) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2701 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2702 #ifdef FEAT_BROWSE_CMD |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2703 cmdmod.browse = TRUE; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2704 #endif |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2705 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2706 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2707 if (!checkforcmd(&eap->cmd, "botright", 2)) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2708 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2709 cmdmod.split |= WSP_BOT; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2710 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2711 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2712 case 'c': if (!checkforcmd(&eap->cmd, "confirm", 4)) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2713 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2714 #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2715 cmdmod.confirm = TRUE; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2716 #endif |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2717 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2718 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2719 case 'k': if (checkforcmd(&eap->cmd, "keepmarks", 3)) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2720 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2721 cmdmod.keepmarks = TRUE; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2722 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2723 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2724 if (checkforcmd(&eap->cmd, "keepalt", 5)) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2725 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2726 cmdmod.keepalt = TRUE; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2727 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2728 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2729 if (checkforcmd(&eap->cmd, "keeppatterns", 5)) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2730 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2731 cmdmod.keeppatterns = TRUE; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2732 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2733 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2734 if (!checkforcmd(&eap->cmd, "keepjumps", 5)) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2735 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2736 cmdmod.keepjumps = TRUE; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2737 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2738 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2739 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
|
2740 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2741 char_u *reg_pat; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2742 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2743 if (!checkforcmd(&p, "filter", 4) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2744 || *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
|
2745 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2746 if (*p == '!') |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2747 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2748 cmdmod.filter_force = TRUE; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2749 p = skipwhite(p + 1); |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2750 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
|
2751 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2752 } |
21259
ee0e2ada88c0
patch 8.2.1180: build failure in small version
Bram Moolenaar <Bram@vim.org>
parents:
21255
diff
changeset
|
2753 #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
|
2754 // Avoid that "filter(arg)" is recognized. |
4be91a7eafb2
patch 8.2.1178: Vim9: filter function recognized as command modifier
Bram Moolenaar <Bram@vim.org>
parents:
21212
diff
changeset
|
2755 if (in_vim9script() && !VIM_ISWHITE(*p)) |
4be91a7eafb2
patch 8.2.1178: Vim9: filter function recognized as command modifier
Bram Moolenaar <Bram@vim.org>
parents:
21212
diff
changeset
|
2756 break; |
21259
ee0e2ada88c0
patch 8.2.1180: build failure in small version
Bram Moolenaar <Bram@vim.org>
parents:
21255
diff
changeset
|
2757 #endif |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2758 if (skip_only) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2759 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
|
2760 else |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2761 // NOTE: This puts a NUL after the pattern. |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2762 p = skip_vimgrep_pat(p, ®_pat, NULL); |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2763 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
|
2764 break; |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2765 if (!skip_only) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2766 { |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2767 cmdmod.filter_regmatch.regprog = |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2768 vim_regcomp(reg_pat, RE_MAGIC); |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2769 if (cmdmod.filter_regmatch.regprog == NULL) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2770 break; |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2771 } |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2772 eap->cmd = p; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2773 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2774 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2775 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2776 // ":hide" and ":hide | cmd" are not modifiers |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2777 case 'h': if (p != eap->cmd || !checkforcmd(&p, "hide", 3) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2778 || *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
|
2779 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2780 eap->cmd = p; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2781 cmdmod.hide = TRUE; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2782 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2783 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2784 case 'l': if (checkforcmd(&eap->cmd, "lockmarks", 3)) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2785 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2786 cmdmod.lockmarks = TRUE; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2787 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2788 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2789 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2790 if (!checkforcmd(&eap->cmd, "leftabove", 5)) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2791 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2792 cmdmod.split |= WSP_ABOVE; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2793 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2794 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2795 case 'n': if (checkforcmd(&eap->cmd, "noautocmd", 3)) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2796 { |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2797 if (cmdmod.save_ei == NULL && !skip_only) |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2798 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2799 // Set 'eventignore' to "all". Restore the |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2800 // existing option value later. |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2801 cmdmod.save_ei = vim_strsave(p_ei); |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2802 set_string_option_direct((char_u *)"ei", -1, |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2803 (char_u *)"all", OPT_FREE, SID_NONE); |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2804 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2805 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2806 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2807 if (!checkforcmd(&eap->cmd, "noswapfile", 3)) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2808 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2809 cmdmod.noswapfile = TRUE; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2810 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2811 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2812 case 'r': if (!checkforcmd(&eap->cmd, "rightbelow", 6)) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2813 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2814 cmdmod.split |= WSP_BELOW; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2815 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2816 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2817 case 's': if (checkforcmd(&eap->cmd, "sandbox", 3)) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2818 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2819 #ifdef HAVE_SANDBOX |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2820 if (!skip_only) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2821 { |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2822 if (!eap->did_sandbox) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2823 ++sandbox; |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2824 eap->did_sandbox = TRUE; |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2825 } |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2826 #endif |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2827 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2828 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2829 if (!checkforcmd(&eap->cmd, "silent", 3)) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2830 break; |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2831 if (!skip_only) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2832 { |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2833 if (eap->save_msg_silent == -1) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2834 eap->save_msg_silent = msg_silent; |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2835 ++msg_silent; |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2836 } |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2837 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
|
2838 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2839 // ":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
|
2840 eap->cmd = skipwhite(eap->cmd + 1); |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2841 if (!skip_only) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2842 { |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2843 ++emsg_silent; |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2844 ++eap->did_esilent; |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2845 } |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2846 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2847 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2848 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2849 case 't': if (checkforcmd(&p, "tab", 3)) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2850 { |
15263
ad065b8123e8
patch 8.1.0640: get E14 while typing command :tab with 'incsearch' set
Bram Moolenaar <Bram@vim.org>
parents:
15239
diff
changeset
|
2851 if (!skip_only) |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2852 { |
15263
ad065b8123e8
patch 8.1.0640: get E14 while typing command :tab with 'incsearch' set
Bram Moolenaar <Bram@vim.org>
parents:
15239
diff
changeset
|
2853 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
|
2854 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
|
2855 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
|
2856 if (tabnr == MAXLNUM) |
ad065b8123e8
patch 8.1.0640: get E14 while typing command :tab with 'incsearch' set
Bram Moolenaar <Bram@vim.org>
parents:
15239
diff
changeset
|
2857 cmdmod.tab = tabpage_index(curtab) + 1; |
ad065b8123e8
patch 8.1.0640: get E14 while typing command :tab with 'incsearch' set
Bram Moolenaar <Bram@vim.org>
parents:
15239
diff
changeset
|
2858 else |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2859 { |
15263
ad065b8123e8
patch 8.1.0640: get E14 while typing command :tab with 'incsearch' set
Bram Moolenaar <Bram@vim.org>
parents:
15239
diff
changeset
|
2860 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
|
2861 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2862 *errormsg = _(e_invrange); |
15263
ad065b8123e8
patch 8.1.0640: get E14 while typing command :tab with 'incsearch' set
Bram Moolenaar <Bram@vim.org>
parents:
15239
diff
changeset
|
2863 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
|
2864 } |
ad065b8123e8
patch 8.1.0640: get E14 while typing command :tab with 'incsearch' set
Bram Moolenaar <Bram@vim.org>
parents:
15239
diff
changeset
|
2865 cmdmod.tab = tabnr + 1; |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2866 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2867 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2868 eap->cmd = p; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2869 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2870 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2871 if (!checkforcmd(&eap->cmd, "topleft", 2)) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2872 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2873 cmdmod.split |= WSP_TOP; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2874 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2875 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2876 case 'u': if (!checkforcmd(&eap->cmd, "unsilent", 3)) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2877 break; |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2878 if (!skip_only) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2879 { |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2880 if (eap->save_msg_silent == -1) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2881 eap->save_msg_silent = msg_silent; |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2882 msg_silent = 0; |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2883 } |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2884 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2885 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2886 case 'v': if (checkforcmd(&eap->cmd, "vertical", 4)) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2887 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2888 cmdmod.split |= WSP_VERT; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2889 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2890 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2891 if (!checkforcmd(&p, "verbose", 4)) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2892 break; |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2893 if (!skip_only) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2894 { |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2895 if (eap->verbose_save < 0) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2896 eap->verbose_save = p_verbose; |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2897 if (vim_isdigit(*eap->cmd)) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2898 p_verbose = atoi((char *)eap->cmd); |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2899 else |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2900 p_verbose = 1; |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2901 } |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2902 eap->cmd = p; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2903 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2904 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2905 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2906 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2907 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2908 return OK; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2909 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2910 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2911 /* |
21255
4be91a7eafb2
patch 8.2.1178: Vim9: filter function recognized as command modifier
Bram Moolenaar <Bram@vim.org>
parents:
21212
diff
changeset
|
2912 * Undo and free contents of "cmdmod". |
21172
96ae8622cfb6
patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents:
21130
diff
changeset
|
2913 */ |
96ae8622cfb6
patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents:
21130
diff
changeset
|
2914 void |
96ae8622cfb6
patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents:
21130
diff
changeset
|
2915 undo_cmdmod(exarg_T *eap, int save_msg_scroll) |
96ae8622cfb6
patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents:
21130
diff
changeset
|
2916 { |
96ae8622cfb6
patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents:
21130
diff
changeset
|
2917 if (eap->verbose_save >= 0) |
96ae8622cfb6
patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents:
21130
diff
changeset
|
2918 p_verbose = eap->verbose_save; |
96ae8622cfb6
patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents:
21130
diff
changeset
|
2919 |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2920 if (cmdmod.save_ei != NULL) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2921 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2922 // Restore 'eventignore' to the value before ":noautocmd". |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2923 set_string_option_direct((char_u *)"ei", -1, cmdmod.save_ei, |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2924 OPT_FREE, SID_NONE); |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2925 free_string_option(cmdmod.save_ei); |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2926 } |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2927 |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2928 if (cmdmod.filter_regmatch.regprog != NULL) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2929 vim_regfree(cmdmod.filter_regmatch.regprog); |
21172
96ae8622cfb6
patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents:
21130
diff
changeset
|
2930 |
96ae8622cfb6
patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents:
21130
diff
changeset
|
2931 if (eap->save_msg_silent != -1) |
96ae8622cfb6
patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents:
21130
diff
changeset
|
2932 { |
96ae8622cfb6
patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents:
21130
diff
changeset
|
2933 // 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
|
2934 // counters don't become negative |
96ae8622cfb6
patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents:
21130
diff
changeset
|
2935 if (!did_emsg || msg_silent > eap->save_msg_silent) |
96ae8622cfb6
patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents:
21130
diff
changeset
|
2936 msg_silent = eap->save_msg_silent; |
96ae8622cfb6
patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents:
21130
diff
changeset
|
2937 emsg_silent -= eap->did_esilent; |
96ae8622cfb6
patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents:
21130
diff
changeset
|
2938 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
|
2939 emsg_silent = 0; |
96ae8622cfb6
patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents:
21130
diff
changeset
|
2940 // 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
|
2941 // message is actually displayed. |
96ae8622cfb6
patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents:
21130
diff
changeset
|
2942 msg_scroll = save_msg_scroll; |
96ae8622cfb6
patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents:
21130
diff
changeset
|
2943 |
96ae8622cfb6
patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents:
21130
diff
changeset
|
2944 // "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
|
2945 // 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
|
2946 if (redirecting()) |
96ae8622cfb6
patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents:
21130
diff
changeset
|
2947 msg_col = 0; |
96ae8622cfb6
patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents:
21130
diff
changeset
|
2948 } |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2949 } |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2950 |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2951 /* |
14505
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2952 * 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
|
2953 * 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
|
2954 * 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
|
2955 */ |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2956 int |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2957 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
|
2958 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2959 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
|
2960 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
|
2961 |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2962 // 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
|
2963 for (;;) |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2964 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2965 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
|
2966 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
|
2967 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
|
2968 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
|
2969 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
|
2970 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
|
2971 return FAIL; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2972 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
|
2973 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2974 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
|
2975 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2976 ++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
|
2977 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
|
2978 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2979 case ADDR_LINES: |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
2980 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
|
2981 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
|
2982 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
|
2983 break; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2984 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
|
2985 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2986 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
|
2987 |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2988 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
|
2989 && 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
|
2990 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
|
2991 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
|
2992 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
|
2993 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
|
2994 && 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
|
2995 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
|
2996 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
|
2997 break; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2998 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2999 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
|
3000 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
|
3001 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
|
3002 break; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3003 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
|
3004 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
|
3005 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
|
3006 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3007 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
|
3008 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
|
3009 ? 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
|
3010 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3011 else |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3012 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3013 // 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
|
3014 // ADDR_WINDOWS or ADDR_TABS |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
3015 *errormsg = _(e_invrange); |
14505
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3016 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
|
3017 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3018 break; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3019 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
|
3020 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
|
3021 case ADDR_QUICKFIX: |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
3022 *errormsg = _(e_invrange); |
14505
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3023 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
|
3024 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
|
3025 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
|
3026 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
|
3027 else |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3028 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3029 eap->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
|
3030 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
|
3031 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3032 break; |
16515
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
3033 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
|
3034 #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
|
3035 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
|
3036 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
|
3037 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
|
3038 eap->line2 = 1; |
16479
7dcf301d1432
patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents:
16475
diff
changeset
|
3039 #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
|
3040 break; |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
3041 case ADDR_NONE: |
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
3042 // 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
|
3043 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
|
3044 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3045 ++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
|
3046 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3047 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
|
3048 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3049 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
|
3050 |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3051 // '*' - 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
|
3052 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
|
3053 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
3054 *errormsg = _(e_invrange); |
14505
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3055 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
|
3056 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3057 |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3058 ++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
|
3059 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
|
3060 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3061 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
|
3062 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
|
3063 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
|
3064 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
|
3065 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
|
3066 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
|
3067 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
|
3068 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
|
3069 ++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
|
3070 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3071 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3072 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3073 else |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3074 eap->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
|
3075 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
|
3076 |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3077 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
|
3078 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3079 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
|
3080 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3081 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
|
3082 // 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
|
3083 // 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
|
3084 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
|
3085 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
|
3086 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3087 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3088 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
|
3089 break; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3090 ++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
|
3091 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3092 |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3093 // 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
|
3094 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
|
3095 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3096 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
|
3097 // ... 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
|
3098 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
|
3099 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
|
3100 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3101 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
|
3102 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3103 |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3104 /* |
93 | 3105 * Check for an Ex command with optional tail. |
7 | 3106 * If there is a match advance "pp" to the argument and return TRUE. |
3107 */ | |
93 | 3108 int |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3109 checkforcmd( |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3110 char_u **pp, // start of command |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3111 char *cmd, // name of command |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3112 int len) // required length |
7 | 3113 { |
3114 int i; | |
3115 | |
3116 for (i = 0; cmd[i] != NUL; ++i) | |
1872 | 3117 if (((char_u *)cmd)[i] != (*pp)[i]) |
7 | 3118 break; |
3119 if (i >= len && !isalpha((*pp)[i])) | |
3120 { | |
3121 *pp = skipwhite(*pp + i); | |
3122 return TRUE; | |
3123 } | |
3124 return FALSE; | |
3125 } | |
3126 | |
3127 /* | |
3097 | 3128 * Append "cmd" to the error message in IObuff. |
3129 * Takes care of limiting the length and handling 0xa0, which would be | |
3130 * invisible otherwise. | |
3131 */ | |
3132 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3133 append_command(char_u *cmd) |
3097 | 3134 { |
3135 char_u *s = cmd; | |
3136 char_u *d; | |
3137 | |
3138 STRCAT(IObuff, ": "); | |
3139 d = IObuff + STRLEN(IObuff); | |
3140 while (*s != NUL && d - IObuff < IOSIZE - 7) | |
3141 { | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
3142 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
|
3143 { |
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
3144 s += enc_utf8 ? 2 : 1; |
3097 | 3145 STRCPY(d, "<a0>"); |
3146 d += 4; | |
3147 } | |
3148 else | |
3149 MB_COPY_CHAR(s, d); | |
3150 } | |
3151 *d = NUL; | |
3152 } | |
3153 | |
3154 /* | |
21937
b931df03adcc
patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents:
21893
diff
changeset
|
3155 * 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
|
3156 * 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
|
3157 */ |
b931df03adcc
patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents:
21893
diff
changeset
|
3158 char_u * |
b931df03adcc
patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents:
21893
diff
changeset
|
3159 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
|
3160 { |
b931df03adcc
patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents:
21893
diff
changeset
|
3161 char_u *name = start; |
b931df03adcc
patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents:
21893
diff
changeset
|
3162 |
b931df03adcc
patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents:
21893
diff
changeset
|
3163 if (*start == '&') |
b931df03adcc
patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents:
21893
diff
changeset
|
3164 { |
b931df03adcc
patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents:
21893
diff
changeset
|
3165 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
|
3166 name += 3; |
b931df03adcc
patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents:
21893
diff
changeset
|
3167 else |
b931df03adcc
patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents:
21893
diff
changeset
|
3168 name += 1; |
b931df03adcc
patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents:
21893
diff
changeset
|
3169 } |
b931df03adcc
patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents:
21893
diff
changeset
|
3170 else if (*start == '$') |
b931df03adcc
patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents:
21893
diff
changeset
|
3171 name += 1; |
b931df03adcc
patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents:
21893
diff
changeset
|
3172 return name; |
b931df03adcc
patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents:
21893
diff
changeset
|
3173 } |
b931df03adcc
patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents:
21893
diff
changeset
|
3174 |
b931df03adcc
patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents:
21893
diff
changeset
|
3175 /* |
7 | 3176 * Find an Ex command by its name, either built-in or user. |
184 | 3177 * 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
|
3178 * Sets eap->cmdidx and returns a pointer to char after the command name. |
184 | 3179 * "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
|
3180 * |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3181 * 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
|
3182 * 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
|
3183 * "eap->cmd". |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3184 * |
7 | 3185 * Returns NULL for an ambiguous user command. |
3186 */ | |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3187 char_u * |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3188 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
|
3189 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
|
3190 int *full UNUSED, |
20239
2135b4641680
patch 8.2.0675: Vim9: no support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
3191 void *(*lookup)(char_u *, size_t, 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
|
3192 cctx_T *cctx UNUSED) |
7 | 3193 { |
3194 int len; | |
3195 char_u *p; | |
167 | 3196 int i; |
7 | 3197 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3198 #ifdef FEAT_EVAL |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3199 /* |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3200 * 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
|
3201 * "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
|
3202 */ |
19481
c27837cbe922
patch 8.2.0298: Vim9 script: cannot start command with a string constant
Bram Moolenaar <Bram@vim.org>
parents:
19475
diff
changeset
|
3203 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
|
3204 if (lookup != NULL) |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3205 { |
21937
b931df03adcc
patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents:
21893
diff
changeset
|
3206 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
|
3207 |
9ab43576a13b
patch 8.2.1359: Vim9: cannot assign to / register in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
21596
diff
changeset
|
3208 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
|
3209 || ((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
|
3210 { |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3211 int oplen; |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3212 int heredoc; |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3213 |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3214 if ( |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3215 // "(..." is an expression. |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3216 // "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
|
3217 *p == '(' |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3218 || (p == eap->cmd |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3219 ? ( |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3220 // "{..." is an dict expression. |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3221 *eap->cmd == '{' |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3222 // "'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
|
3223 || *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
|
3224 // '"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
|
3225 || *eap->cmd == '"' |
21526
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3226 // "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
|
3227 || eap->cmd[1] == ':' |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3228 ) |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3229 : ( |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3230 // "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
|
3231 *p == '[' |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3232 // "varname->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
|
3233 || (*p == '-' && p[1] == '>') |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3234 // "varname.expr" is an expression. |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3235 || (*p == '.' && ASCII_ISALPHA(p[1])) |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3236 ))) |
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
|
3237 { |
8992d4f63761
patch 8.2.1257: Vim9: list unpack doesn't work at the script level
Bram Moolenaar <Bram@vim.org>
parents:
21357
diff
changeset
|
3238 eap->cmdidx = CMD_eval; |
8992d4f63761
patch 8.2.1257: Vim9: list unpack doesn't work at the script level
Bram Moolenaar <Bram@vim.org>
parents:
21357
diff
changeset
|
3239 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
|
3240 } |
21526
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3241 |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3242 // "[...]->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
|
3243 // an assignment. |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3244 // 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
|
3245 // 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
|
3246 // follows. |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3247 // 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
|
3248 // 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
|
3249 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
|
3250 { |
21526
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3251 p = to_name_const_end(eap->cmd); |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3252 if (p == eap->cmd || *skipwhite(p) != '=') |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3253 { |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3254 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
|
3255 return eap->cmd; |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3256 } |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3257 if (p > eap->cmd && *skipwhite(p) == '=') |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3258 { |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3259 eap->cmdidx = CMD_let; |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3260 return eap->cmd; |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3261 } |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3262 } |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3263 |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3264 // 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
|
3265 // "g:var = expr" |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3266 // "var = expr" where "var" is a local var name. |
21618
9ab43576a13b
patch 8.2.1359: Vim9: cannot assign to / register in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
21596
diff
changeset
|
3267 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
|
3268 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
|
3269 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
|
3270 if (oplen > 0) |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3271 { |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3272 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
|
3273 || *eap->cmd == '&' |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3274 || *eap->cmd == '$' |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3275 || *eap->cmd == '@' |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3276 || lookup(eap->cmd, p - eap->cmd, cctx) != NULL) |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3277 { |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3278 eap->cmdidx = CMD_let; |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3279 return eap->cmd; |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3280 } |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3281 } |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3282 |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3283 // 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
|
3284 // "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
|
3285 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
|
3286 { |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21518
diff
changeset
|
3287 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
|
3288 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
|
3289 } |
21130
4a1e8086759b
patch 8.2.1116: Vim9: parsing command checks for list twice
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
3290 } |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3291 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3292 #endif |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3293 |
7 | 3294 /* |
3295 * Isolate the command and search for it in the command table. | |
1441 | 3296 * Exceptions: |
7 | 3297 * - the 'k' command can directly be followed by any character. |
3298 * - the 's' command can be followed directly by 'c', 'g', 'i', 'I' or 'r' | |
6472 | 3299 * but :sre[wind] is another command, as are :scr[iptnames], |
7 | 3300 * :scs[cope], :sim[alt], :sig[ns] and :sil[ent]. |
167 | 3301 * - the "d" command can directly be followed by 'l' or 'p' flag. |
7 | 3302 */ |
3303 p = eap->cmd; | |
3304 if (*p == 'k') | |
3305 { | |
3306 eap->cmdidx = CMD_k; | |
3307 ++p; | |
3308 } | |
3309 else if (p[0] == 's' | |
6987 | 3310 && ((p[1] == 'c' && (p[2] == NUL || (p[2] != 's' && p[2] != 'r' |
3311 && (p[3] == NUL || (p[3] != 'i' && p[4] != 'p'))))) | |
7 | 3312 || p[1] == 'g' |
3313 || (p[1] == 'i' && p[2] != 'm' && p[2] != 'l' && p[2] != 'g') | |
3314 || p[1] == 'I' | |
3315 || (p[1] == 'r' && p[2] != 'e'))) | |
3316 { | |
3317 eap->cmdidx = CMD_substitute; | |
3318 ++p; | |
3319 } | |
3320 else | |
3321 { | |
3322 while (ASCII_ISALPHA(*p)) | |
3323 ++p; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3324 // for python 3.x support ":py3", ":python3", ":py3file", etc. |
2330 | 3325 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
|
3326 { |
2366
7a57fe6a5157
Fix that :py3file was not working.
Bram Moolenaar <bram@vim.org>
parents:
2360
diff
changeset
|
3327 while (ASCII_ISALNUM(*p)) |
7a57fe6a5157
Fix that :py3file was not working.
Bram Moolenaar <bram@vim.org>
parents:
2360
diff
changeset
|
3328 ++p; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3329 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3330 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
|
3331 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3332 // include "9" for "vim9script" |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3333 ++p; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3334 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
|
3335 ++p; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3336 } |
2329
ad2889f48843
Added support for Python 3. (Roland Puntaier)
Bram Moolenaar <bram@vim.org>
parents:
2320
diff
changeset
|
3337 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3338 // check for non-alpha command |
7 | 3339 if (p == eap->cmd && vim_strchr((char_u *)"@*!=><&~#", *p) != NULL) |
3340 ++p; | |
3341 len = (int)(p - eap->cmd); | |
167 | 3342 if (*eap->cmd == 'd' && (p[-1] == 'l' || p[-1] == 'p')) |
3343 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3344 // 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
|
3345 // :delete with the 'l' flag. Same for 'p'. |
167 | 3346 for (i = 0; i < len; ++i) |
1872 | 3347 if (eap->cmd[i] != ((char_u *)"delete")[i]) |
167 | 3348 break; |
3349 if (i == len - 1) | |
3350 { | |
3351 --len; | |
3352 if (p[-1] == 'l') | |
3353 eap->flags |= EXFLAG_LIST; | |
3354 else | |
3355 eap->flags |= EXFLAG_PRINT; | |
3356 } | |
3357 } | |
7 | 3358 |
11236
62c96fee518e
patch 8.0.0504: looking up an Ex command is a bit slow
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
3359 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
|
3360 { |
11240
06307d812ca7
patch 8.0.0506: can't build with ANSI C
Christian Brabandt <cb@256bit.org>
parents:
11236
diff
changeset
|
3361 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
|
3362 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
|
3363 |
11236
62c96fee518e
patch 8.0.0504: looking up an Ex command is a bit slow
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
3364 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
|
3365 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
3366 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
|
3367 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
|
3368 } |
62c96fee518e
patch 8.0.0504: looking up an Ex command is a bit slow
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
3369 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3370 // 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
|
3371 // 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
|
3372 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
|
3373 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
|
3374 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
|
3375 } |
20075
516b10943fdb
patch 8.2.0593: finding a user command is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
20063
diff
changeset
|
3376 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
|
3377 eap->cmdidx = CMD_Next; |
7 | 3378 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
|
3379 eap->cmdidx = CMD_bang; |
7 | 3380 |
3381 for ( ; (int)eap->cmdidx < (int)CMD_SIZE; | |
3382 eap->cmdidx = (cmdidx_T)((int)eap->cmdidx + 1)) | |
3383 if (STRNCMP(cmdnames[(int)eap->cmdidx].cmd_name, (char *)eap->cmd, | |
3384 (size_t)len) == 0) | |
3385 { | |
3386 #ifdef FEAT_EVAL | |
3387 if (full != NULL | |
3388 && cmdnames[(int)eap->cmdidx].cmd_name[len] == NUL) | |
3389 *full = TRUE; | |
3390 #endif | |
3391 break; | |
3392 } | |
3393 | |
16411
5b5c5daf57de
patch 8.1.1210: support for user commands is spread out
Bram Moolenaar <Bram@vim.org>
parents:
16399
diff
changeset
|
3394 // 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
|
3395 // overruled by a user defined command. |
2633 | 3396 if ((eap->cmdidx == CMD_SIZE || eap->cmdidx == CMD_Print) |
3397 && *eap->cmd >= 'A' && *eap->cmd <= 'Z') | |
7 | 3398 { |
16411
5b5c5daf57de
patch 8.1.1210: support for user commands is spread out
Bram Moolenaar <Bram@vim.org>
parents:
16399
diff
changeset
|
3399 // User defined commands may contain digits. |
7 | 3400 while (ASCII_ISALNUM(*p)) |
3401 ++p; | |
184 | 3402 p = find_ucmd(eap, p, full, NULL, NULL); |
3403 } | |
3404 if (p == eap->cmd) | |
7 | 3405 eap->cmdidx = CMD_SIZE; |
3406 } | |
3407 | |
3408 return p; | |
3409 } | |
3410 | |
3411 #if defined(FEAT_EVAL) || defined(PROTO) | |
1447 | 3412 static struct cmdmod |
3413 { | |
3414 char *name; | |
3415 int minlen; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3416 int has_count; // :123verbose :3tab |
1447 | 3417 } cmdmods[] = { |
3418 {"aboveleft", 3, FALSE}, | |
3419 {"belowright", 3, FALSE}, | |
3420 {"botright", 2, FALSE}, | |
3421 {"browse", 3, FALSE}, | |
3422 {"confirm", 4, FALSE}, | |
9941
e975914c17e9
commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
9927
diff
changeset
|
3423 {"filter", 4, FALSE}, |
1447 | 3424 {"hide", 3, FALSE}, |
3425 {"keepalt", 5, FALSE}, | |
3426 {"keepjumps", 5, FALSE}, | |
3427 {"keepmarks", 3, FALSE}, | |
5467 | 3428 {"keeppatterns", 5, FALSE}, |
1447 | 3429 {"leftabove", 5, FALSE}, |
3430 {"lockmarks", 3, FALSE}, | |
1721 | 3431 {"noautocmd", 3, FALSE}, |
5737 | 3432 {"noswapfile", 3, FALSE}, |
1447 | 3433 {"rightbelow", 6, FALSE}, |
3434 {"sandbox", 3, FALSE}, | |
3435 {"silent", 3, FALSE}, | |
3436 {"tab", 3, TRUE}, | |
3437 {"topleft", 2, FALSE}, | |
1926 | 3438 {"unsilent", 3, FALSE}, |
1447 | 3439 {"verbose", 4, TRUE}, |
3440 {"vertical", 4, FALSE}, | |
3441 }; | |
3442 | |
3443 /* | |
3444 * Return length of a command modifier (including optional count). | |
3445 * Return zero when it's not a modifier. | |
3446 */ | |
3447 int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3448 modifier_len(char_u *cmd) |
1447 | 3449 { |
3450 int i, j; | |
3451 char_u *p = cmd; | |
3452 | |
3453 if (VIM_ISDIGIT(*cmd)) | |
3454 p = skipwhite(skipdigits(cmd)); | |
1880 | 3455 for (i = 0; i < (int)(sizeof(cmdmods) / sizeof(struct cmdmod)); ++i) |
1447 | 3456 { |
3457 for (j = 0; p[j] != NUL; ++j) | |
3458 if (p[j] != cmdmods[i].name[j]) | |
3459 break; | |
4857
84a8d1ba81c3
updated for version 7.3.1175
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3460 if (!ASCII_ISALPHA(p[j]) && j >= cmdmods[i].minlen |
1447 | 3461 && (p == cmd || cmdmods[i].has_count)) |
1570 | 3462 return j + (int)(p - cmd); |
1447 | 3463 } |
3464 return 0; | |
3465 } | |
3466 | |
7 | 3467 /* |
3468 * Return > 0 if an Ex command "name" exists. | |
3469 * Return 2 if there is an exact match. | |
3470 * Return 3 if there is an ambiguous match. | |
3471 */ | |
3472 int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3473 cmd_exists(char_u *name) |
7 | 3474 { |
3475 exarg_T ea; | |
3476 int full = FALSE; | |
3477 int i; | |
3478 int j; | |
866 | 3479 char_u *p; |
7 | 3480 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3481 // Check command modifiers. |
1880 | 3482 for (i = 0; i < (int)(sizeof(cmdmods) / sizeof(struct cmdmod)); ++i) |
7 | 3483 { |
3484 for (j = 0; name[j] != NUL; ++j) | |
3485 if (name[j] != cmdmods[i].name[j]) | |
3486 break; | |
3487 if (name[j] == NUL && j >= cmdmods[i].minlen) | |
3488 return (cmdmods[i].name[j] == NUL ? 2 : 1); | |
3489 } | |
3490 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3491 // 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
|
3492 // For ":2match" and ":3match" we need to skip the number. |
862 | 3493 ea.cmd = (*name == '2' || *name == '3') ? name + 1 : name; |
7 | 3494 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
|
3495 p = find_ex_command(&ea, &full, NULL, NULL); |
866 | 3496 if (p == NULL) |
7 | 3497 return 3; |
862 | 3498 if (vim_isdigit(*name) && ea.cmdidx != CMD_match) |
3499 return 0; | |
866 | 3500 if (*skipwhite(p) != NUL) |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3501 return 0; // trailing garbage |
7 | 3502 return (ea.cmdidx == CMD_SIZE ? 0 : (full ? 2 : 1)); |
3503 } | |
3504 #endif | |
3505 | |
17835
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17823
diff
changeset
|
3506 cmdidx_T |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17823
diff
changeset
|
3507 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
|
3508 { |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17823
diff
changeset
|
3509 cmdidx_T idx; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17823
diff
changeset
|
3510 |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17823
diff
changeset
|
3511 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
|
3512 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
|
3513 if (STRNCMP(cmdnames[(int)idx].cmd_name, cmd, (size_t)len) == 0) |
7 | 3514 break; |
3515 | |
17835
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17823
diff
changeset
|
3516 return idx; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17823
diff
changeset
|
3517 } |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17823
diff
changeset
|
3518 |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17823
diff
changeset
|
3519 long |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17823
diff
changeset
|
3520 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
|
3521 { |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17823
diff
changeset
|
3522 return (long)cmdnames[(int)idx].cmd_argt; |
7 | 3523 } |
3524 | |
3525 /* | |
14505
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3526 * Skip a range specifier of the form: addr [,addr] [;addr] .. |
7 | 3527 * |
3528 * Backslashed delimiters after / or ? will be skipped, and commands will | |
3529 * not be expanded between /'s and ?'s or after "'". | |
3530 * | |
20982
bb49b5090a9c
patch 8.2.1042: Vim9: cannot put an operator on the next line
Bram Moolenaar <Bram@vim.org>
parents:
20897
diff
changeset
|
3531 * Also skip white space and ":" characters after the range. |
7 | 3532 * Returns the "cmd" pointer advanced to beyond the range. |
3533 */ | |
3534 char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3535 skip_range( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3536 char_u *cmd, |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3537 int *ctx) // pointer to xp_context or NULL |
7 | 3538 { |
1872 | 3539 unsigned delim; |
7 | 3540 |
10817
cc8079703414
patch 8.0.0298: Ex command range with repeated search does not work
Christian Brabandt <cb@256bit.org>
parents:
10809
diff
changeset
|
3541 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
|
3542 { |
cc8079703414
patch 8.0.0298: Ex command range with repeated search does not work
Christian Brabandt <cb@256bit.org>
parents:
10809
diff
changeset
|
3543 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
|
3544 { |
cc8079703414
patch 8.0.0298: Ex command range with repeated search does not work
Christian Brabandt <cb@256bit.org>
parents:
10809
diff
changeset
|
3545 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
|
3546 ++cmd; |
cc8079703414
patch 8.0.0298: Ex command range with repeated search does not work
Christian Brabandt <cb@256bit.org>
parents:
10809
diff
changeset
|
3547 else |
cc8079703414
patch 8.0.0298: Ex command range with repeated search does not work
Christian Brabandt <cb@256bit.org>
parents:
10809
diff
changeset
|
3548 break; |
cc8079703414
patch 8.0.0298: Ex command range with repeated search does not work
Christian Brabandt <cb@256bit.org>
parents:
10809
diff
changeset
|
3549 } |
cc8079703414
patch 8.0.0298: Ex command range with repeated search does not work
Christian Brabandt <cb@256bit.org>
parents:
10809
diff
changeset
|
3550 else if (*cmd == '\'') |
7 | 3551 { |
3552 if (*++cmd == NUL && ctx != NULL) | |
3553 *ctx = EXPAND_NOTHING; | |
3554 } | |
3555 else if (*cmd == '/' || *cmd == '?') | |
3556 { | |
3557 delim = *cmd++; | |
3558 while (*cmd != NUL && *cmd != delim) | |
3559 if (*cmd++ == '\\' && *cmd != NUL) | |
3560 ++cmd; | |
3561 if (*cmd == NUL && ctx != NULL) | |
3562 *ctx = EXPAND_NOTHING; | |
3563 } | |
3564 if (*cmd != NUL) | |
3565 ++cmd; | |
3566 } | |
167 | 3567 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3568 // Skip ":" and white space. |
167 | 3569 while (*cmd == ':') |
3570 cmd = skipwhite(cmd + 1); | |
3571 | |
7 | 3572 return cmd; |
3573 } | |
3574 | |
17650
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
3575 static void |
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
3576 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
|
3577 { |
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
3578 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
|
3579 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
|
3580 else |
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
3581 emsg(_(e_invrange)); |
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
3582 } |
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
3583 |
7 | 3584 /* |
21939
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
3585 * 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
|
3586 */ |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
3587 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
|
3588 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
|
3589 { |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
3590 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
|
3591 |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
3592 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
|
3593 { |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
3594 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
|
3595 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
|
3596 // 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
|
3597 // 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
|
3598 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
|
3599 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
|
3600 else |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
3601 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
|
3602 break; |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
3603 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
|
3604 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
|
3605 break; |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
3606 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
|
3607 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
|
3608 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
|
3609 lnum = ARGCOUNT; |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
3610 break; |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
3611 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
|
3612 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
|
3613 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
|
3614 break; |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
3615 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
|
3616 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
|
3617 break; |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
3618 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
|
3619 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
|
3620 lnum = 1; |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
3621 break; |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
3622 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
|
3623 #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
|
3624 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
|
3625 #endif |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
3626 break; |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
3627 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
|
3628 #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
|
3629 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
|
3630 #endif |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
3631 break; |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
3632 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
|
3633 // 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
|
3634 break; |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
3635 } |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
3636 return lnum; |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
3637 } |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
3638 |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
3639 /* |
14677
7771a1ff8b99
patch 8.1.0351: 'incsearch' for :/foo/s//<Esc> changes last search pattern
Christian Brabandt <cb@256bit.org>
parents:
14648
diff
changeset
|
3640 * Get a single EX address. |
7 | 3641 * |
3642 * Set ptr to the next character after the part that was interpreted. | |
3643 * 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
|
3644 * This may set the last used search pattern. |
7 | 3645 * |
3646 * Return MAXLNUM when no Ex address was found. | |
3647 */ | |
3648 static linenr_T | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3649 get_address( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3650 exarg_T *eap UNUSED, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3651 char_u **ptr, |
18849
b77ef4b8af7c
patch 8.1.2411: function argument copied unnecessarily
Bram Moolenaar <Bram@vim.org>
parents:
18779
diff
changeset
|
3652 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
|
3653 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
|
3654 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
|
3655 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
|
3656 int address_count UNUSED) // 1 for first address, >1 after comma |
7 | 3657 { |
3658 int c; | |
3659 int i; | |
3660 long n; | |
3661 char_u *cmd; | |
3662 pos_T pos; | |
3663 pos_T *fp; | |
3664 linenr_T lnum; | |
6424 | 3665 buf_T *buf; |
7 | 3666 |
3667 cmd = skipwhite(*ptr); | |
3668 lnum = MAXLNUM; | |
3669 do | |
3670 { | |
3671 switch (*cmd) | |
3672 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3673 case '.': // '.' - Cursor position |
6398 | 3674 ++cmd; |
3675 switch (addr_type) | |
3676 { | |
3677 case ADDR_LINES: | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
3678 case ADDR_OTHER: |
7 | 3679 lnum = curwin->w_cursor.lnum; |
3680 break; | |
6398 | 3681 case ADDR_WINDOWS: |
6409 | 3682 lnum = CURRENT_WIN_NR; |
6398 | 3683 break; |
3684 case ADDR_ARGUMENTS: | |
3685 lnum = curwin->w_arg_idx + 1; | |
3686 break; | |
3687 case ADDR_LOADED_BUFFERS: | |
6424 | 3688 case ADDR_BUFFERS: |
6398 | 3689 lnum = curbuf->b_fnum; |
3690 break; | |
3691 case ADDR_TABS: | |
6409 | 3692 lnum = CURRENT_TAB_NR; |
6398 | 3693 break; |
17650
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
3694 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
|
3695 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
|
3696 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
|
3697 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
|
3698 cmd = NULL; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
3699 goto error; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
3700 break; |
16479
7dcf301d1432
patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents:
16475
diff
changeset
|
3701 case ADDR_QUICKFIX: |
7105
f4456e686406
commit https://github.com/vim/vim/commit/e906c502079770ae0e0071c74cefb802689ff193
Christian Brabandt <cb@256bit.org>
parents:
7092
diff
changeset
|
3702 #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
|
3703 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
|
3704 #endif |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
3705 break; |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
3706 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
|
3707 #ifdef FEAT_QUICKFIX |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
3708 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
|
3709 #endif |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
3710 break; |
6398 | 3711 } |
3712 break; | |
7 | 3713 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3714 case '$': // '$' - last line |
6398 | 3715 ++cmd; |
3716 switch (addr_type) | |
3717 { | |
3718 case ADDR_LINES: | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
3719 case ADDR_OTHER: |
7 | 3720 lnum = curbuf->b_ml.ml_line_count; |
3721 break; | |
6398 | 3722 case ADDR_WINDOWS: |
6409 | 3723 lnum = LAST_WIN_NR; |
6398 | 3724 break; |
3725 case ADDR_ARGUMENTS: | |
3726 lnum = ARGCOUNT; | |
3727 break; | |
3728 case ADDR_LOADED_BUFFERS: | |
6424 | 3729 buf = lastbuf; |
3730 while (buf->b_ml.ml_mfp == NULL) | |
3731 { | |
3732 if (buf->b_prev == NULL) | |
3733 break; | |
3734 buf = buf->b_prev; | |
3735 } | |
3736 lnum = buf->b_fnum; | |
3737 break; | |
3738 case ADDR_BUFFERS: | |
6398 | 3739 lnum = lastbuf->b_fnum; |
3740 break; | |
3741 case ADDR_TABS: | |
6409 | 3742 lnum = LAST_TAB_NR; |
6398 | 3743 break; |
17650
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
3744 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
|
3745 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
|
3746 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
|
3747 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
|
3748 cmd = NULL; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
3749 goto error; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
3750 break; |
16479
7dcf301d1432
patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents:
16475
diff
changeset
|
3751 case ADDR_QUICKFIX: |
7105
f4456e686406
commit https://github.com/vim/vim/commit/e906c502079770ae0e0071c74cefb802689ff193
Christian Brabandt <cb@256bit.org>
parents:
7092
diff
changeset
|
3752 #ifdef FEAT_QUICKFIX |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
3753 lnum = qf_get_size(eap); |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
3754 if (lnum == 0) |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
3755 lnum = 1; |
16479
7dcf301d1432
patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents:
16475
diff
changeset
|
3756 #endif |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
3757 break; |
16515
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
3758 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
|
3759 #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
|
3760 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
|
3761 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
|
3762 lnum = 1; |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
3763 #endif |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
3764 break; |
6398 | 3765 } |
3766 break; | |
7 | 3767 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3768 case '\'': // ''' - mark |
6398 | 3769 if (*++cmd == NUL) |
3770 { | |
3771 cmd = NULL; | |
3772 goto error; | |
3773 } | |
3774 if (addr_type != ADDR_LINES) | |
3775 { | |
17650
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
3776 addr_error(addr_type); |
6581 | 3777 cmd = NULL; |
6398 | 3778 goto error; |
3779 } | |
3780 if (skip) | |
3781 ++cmd; | |
3782 else | |
3783 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3784 // 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
|
3785 // used by itself: ":'M". |
6398 | 3786 fp = getmark(*cmd, to_other_file && cmd[1] == NUL); |
3787 ++cmd; | |
3788 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
|
3789 // Jumped to another file. |
6398 | 3790 lnum = curwin->w_cursor.lnum; |
3791 else | |
3792 { | |
3793 if (check_mark(fp) == FAIL) | |
7 | 3794 { |
3795 cmd = NULL; | |
3796 goto error; | |
3797 } | |
6398 | 3798 lnum = fp->lnum; |
3799 } | |
3800 } | |
3801 break; | |
7 | 3802 |
3803 case '/': | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3804 case '?': // '/' or '?' - search |
6398 | 3805 c = *cmd++; |
3806 if (addr_type != ADDR_LINES) | |
3807 { | |
17650
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
3808 addr_error(addr_type); |
6581 | 3809 cmd = NULL; |
6398 | 3810 goto error; |
3811 } | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3812 if (skip) // skip "/pat/" |
6398 | 3813 { |
19892
5feb426d2ea1
patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19685
diff
changeset
|
3814 cmd = skip_regexp(cmd, c, (int)p_magic); |
6398 | 3815 if (*cmd == c) |
3816 ++cmd; | |
3817 } | |
3818 else | |
3819 { | |
14760
fd69edd2c67e
patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents:
14700
diff
changeset
|
3820 int flags; |
fd69edd2c67e
patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents:
14700
diff
changeset
|
3821 |
fd69edd2c67e
patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents:
14700
diff
changeset
|
3822 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
|
3823 |
fd69edd2c67e
patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents:
14700
diff
changeset
|
3824 // 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
|
3825 // there. |
6398 | 3826 if (lnum != MAXLNUM) |
3827 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
|
3828 |
fd69edd2c67e
patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents:
14700
diff
changeset
|
3829 // 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
|
3830 // 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
|
3831 // 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
|
3832 // 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
|
3833 // 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
|
3834 // next/previous line. |
13082
a80082fd1a1d
patch 8.0.1416: crash when searching for a sentence
Christian Brabandt <cb@256bit.org>
parents:
12824
diff
changeset
|
3835 if (c == '/' && curwin->w_cursor.lnum > 0) |
6398 | 3836 curwin->w_cursor.col = MAXCOL; |
3837 else | |
3838 curwin->w_cursor.col = 0; | |
3839 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
|
3840 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
|
3841 if (!do_search(NULL, c, c, cmd, 1L, flags, NULL)) |
6398 | 3842 { |
3843 curwin->w_cursor = pos; | |
3844 cmd = NULL; | |
3845 goto error; | |
3846 } | |
3847 lnum = curwin->w_cursor.lnum; | |
3848 curwin->w_cursor = pos; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3849 // adjust command string pointer |
6398 | 3850 cmd += searchcmdlen; |
3851 } | |
3852 break; | |
7 | 3853 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3854 case '\\': // "\?", "\/" or "\&", repeat search |
6398 | 3855 ++cmd; |
3856 if (addr_type != ADDR_LINES) | |
3857 { | |
17650
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
3858 addr_error(addr_type); |
6581 | 3859 cmd = NULL; |
6398 | 3860 goto error; |
3861 } | |
3862 if (*cmd == '&') | |
3863 i = RE_SUBST; | |
3864 else if (*cmd == '?' || *cmd == '/') | |
3865 i = RE_SEARCH; | |
3866 else | |
3867 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
3868 emsg(_(e_backslash)); |
6398 | 3869 cmd = NULL; |
3870 goto error; | |
3871 } | |
3872 | |
3873 if (!skip) | |
3874 { | |
3875 /* | |
3876 * When search follows another address, start from | |
3877 * there. | |
3878 */ | |
3879 if (lnum != MAXLNUM) | |
3880 pos.lnum = lnum; | |
3881 else | |
3882 pos.lnum = curwin->w_cursor.lnum; | |
3883 | |
3884 /* | |
3885 * Start the search just like for the above | |
3886 * do_search(). | |
3887 */ | |
3888 if (*cmd != '?') | |
3889 pos.col = MAXCOL; | |
3890 else | |
3891 pos.col = 0; | |
7007 | 3892 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
|
3893 if (searchit(curwin, curbuf, &pos, NULL, |
6398 | 3894 *cmd == '?' ? BACKWARD : FORWARD, |
18358
34d5cd432cac
patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents:
18297
diff
changeset
|
3895 (char_u *)"", 1L, SEARCH_MSG, i, NULL) != FAIL) |
6398 | 3896 lnum = pos.lnum; |
3897 else | |
3898 { | |
3899 cmd = NULL; | |
3900 goto error; | |
3901 } | |
3902 } | |
3903 ++cmd; | |
3904 break; | |
7 | 3905 |
3906 default: | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3907 if (VIM_ISDIGIT(*cmd)) // absolute line number |
6398 | 3908 lnum = getdigits(&cmd); |
7 | 3909 } |
3910 | |
3911 for (;;) | |
3912 { | |
3913 cmd = skipwhite(cmd); | |
3914 if (*cmd != '-' && *cmd != '+' && !VIM_ISDIGIT(*cmd)) | |
3915 break; | |
3916 | |
3917 if (lnum == MAXLNUM) | |
6398 | 3918 { |
3919 switch (addr_type) | |
3920 { | |
3921 case ADDR_LINES: | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
3922 case ADDR_OTHER: |
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
3923 // "+1" is same as ".+1" |
6409 | 3924 lnum = curwin->w_cursor.lnum; |
6398 | 3925 break; |
3926 case ADDR_WINDOWS: | |
6409 | 3927 lnum = CURRENT_WIN_NR; |
6398 | 3928 break; |
3929 case ADDR_ARGUMENTS: | |
3930 lnum = curwin->w_arg_idx + 1; | |
3931 break; | |
3932 case ADDR_LOADED_BUFFERS: | |
6424 | 3933 case ADDR_BUFFERS: |
6398 | 3934 lnum = curbuf->b_fnum; |
3935 break; | |
3936 case ADDR_TABS: | |
6409 | 3937 lnum = CURRENT_TAB_NR; |
6398 | 3938 break; |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
3939 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
|
3940 lnum = 1; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
3941 break; |
16479
7dcf301d1432
patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents:
16475
diff
changeset
|
3942 case ADDR_QUICKFIX: |
7105
f4456e686406
commit https://github.com/vim/vim/commit/e906c502079770ae0e0071c74cefb802689ff193
Christian Brabandt <cb@256bit.org>
parents:
7092
diff
changeset
|
3943 #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
|
3944 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
|
3945 #endif |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
3946 break; |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
3947 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
|
3948 #ifdef FEAT_QUICKFIX |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
3949 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
|
3950 #endif |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
3951 break; |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
3952 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
|
3953 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
|
3954 lnum = 0; |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
3955 break; |
6398 | 3956 } |
3957 } | |
3958 | |
7 | 3959 if (VIM_ISDIGIT(*cmd)) |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3960 i = '+'; // "number" is same as "+number" |
7 | 3961 else |
3962 i = *cmd++; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3963 if (!VIM_ISDIGIT(*cmd)) // '+' is '+1', but '+0' is not '+1' |
7 | 3964 n = 1; |
3965 else | |
3966 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
|
3967 |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
3968 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
|
3969 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
3970 emsg(_(e_invrange)); |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
3971 cmd = NULL; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
3972 goto error; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
3973 } |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
3974 else if (addr_type == ADDR_LOADED_BUFFERS |
6424 | 3975 || addr_type == ADDR_BUFFERS) |
6581 | 3976 lnum = compute_buffer_local_count( |
3977 addr_type, lnum, (i == '-') ? -1 * n : n); | |
7 | 3978 else |
10484
c7de1536780a
commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
10480
diff
changeset
|
3979 { |
c7de1536780a
commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
10480
diff
changeset
|
3980 #ifdef FEAT_FOLDING |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3981 // 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
|
3982 // 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
|
3983 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
|
3984 && address_count >= 2) |
c7de1536780a
commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
10480
diff
changeset
|
3985 (void)hasFolding(lnum, NULL, &lnum); |
c7de1536780a
commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
10480
diff
changeset
|
3986 #endif |
c7de1536780a
commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
10480
diff
changeset
|
3987 if (i == '-') |
c7de1536780a
commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
10480
diff
changeset
|
3988 lnum -= n; |
c7de1536780a
commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
10480
diff
changeset
|
3989 else |
c7de1536780a
commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
10480
diff
changeset
|
3990 lnum += n; |
c7de1536780a
commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
10480
diff
changeset
|
3991 } |
7 | 3992 } |
3993 } while (*cmd == '/' || *cmd == '?'); | |
3994 | |
3995 error: | |
3996 *ptr = cmd; | |
3997 return lnum; | |
3998 } | |
3999 | |
4000 /* | |
21939
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4001 * 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
|
4002 * 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
|
4003 */ |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4004 static void |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4005 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
|
4006 { |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4007 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
|
4008 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
|
4009 { |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4010 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
|
4011 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
|
4012 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
|
4013 break; |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4014 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
|
4015 { |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4016 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
|
4017 |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4018 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
|
4019 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
|
4020 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
|
4021 buf = lastbuf; |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4022 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
|
4023 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
|
4024 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
|
4025 } |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4026 break; |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4027 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
|
4028 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
|
4029 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
|
4030 break; |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4031 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
|
4032 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
|
4033 break; |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4034 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
|
4035 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
|
4036 break; |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4037 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
|
4038 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
|
4039 break; |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4040 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
|
4041 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
|
4042 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
|
4043 else |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4044 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
|
4045 break; |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4046 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
|
4047 #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
|
4048 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
|
4049 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
|
4050 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
|
4051 #endif |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4052 break; |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4053 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
|
4054 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
|
4055 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
|
4056 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
|
4057 break; |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4058 } |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4059 } |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4060 |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4061 |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
4062 /* |
167 | 4063 * Get flags from an Ex command argument. |
4064 */ | |
4065 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4066 get_flags(exarg_T *eap) |
167 | 4067 { |
4068 while (vim_strchr((char_u *)"lp#", *eap->arg) != NULL) | |
4069 { | |
4070 if (*eap->arg == 'l') | |
4071 eap->flags |= EXFLAG_LIST; | |
4072 else if (*eap->arg == 'p') | |
4073 eap->flags |= EXFLAG_PRINT; | |
4074 else | |
4075 eap->flags |= EXFLAG_NR; | |
4076 eap->arg = skipwhite(eap->arg + 1); | |
4077 } | |
4078 } | |
4079 | |
4080 /* | |
7 | 4081 * Function called for command which is Not Implemented. NI! |
4082 */ | |
4083 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4084 ex_ni(exarg_T *eap) |
7 | 4085 { |
4086 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
|
4087 eap->errmsg = |
a422bd80b434
patch 8.2.1280: Ex command error cannot contain an argument
Bram Moolenaar <Bram@vim.org>
parents:
21413
diff
changeset
|
4088 _("E319: Sorry, the command is not available in this version"); |
7 | 4089 } |
4090 | |
1315 | 4091 #ifdef HAVE_EX_SCRIPT_NI |
7 | 4092 /* |
4093 * Function called for script command which is Not Implemented. NI! | |
4094 * Skips over ":perl <<EOF" constructs. | |
4095 */ | |
4096 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4097 ex_script_ni(exarg_T *eap) |
7 | 4098 { |
4099 if (!eap->skip) | |
4100 ex_ni(eap); | |
4101 else | |
4102 vim_free(script_get(eap, eap->arg)); | |
4103 } | |
4104 #endif | |
4105 | |
4106 /* | |
4107 * Check range in Ex command for validity. | |
4108 * Return NULL when valid, error message when invalid. | |
4109 */ | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
4110 static char * |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4111 invalid_range(exarg_T *eap) |
7 | 4112 { |
6472 | 4113 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
|
4114 |
7 | 4115 if ( eap->line1 < 0 |
4116 || eap->line2 < 0 | |
6472 | 4117 || eap->line1 > eap->line2) |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
4118 return _(e_invrange); |
6472 | 4119 |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
4120 if (eap->argt & EX_RANGE) |
6472 | 4121 { |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
4122 switch (eap->addr_type) |
6472 | 4123 { |
4124 case ADDR_LINES: | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
4125 if (eap->line2 > curbuf->b_ml.ml_line_count |
7 | 4126 #ifdef FEAT_DIFF |
6472 | 4127 + (eap->cmdidx == CMD_diffget) |
4128 #endif | |
4129 ) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
4130 return _(e_invrange); |
6472 | 4131 break; |
4132 case ADDR_ARGUMENTS: | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4133 // add 1 if ARGCOUNT is 0 |
6581 | 4134 if (eap->line2 > ARGCOUNT + (!ARGCOUNT)) |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
4135 return _(e_invrange); |
6472 | 4136 break; |
4137 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
|
4138 // 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
|
4139 // exist. |
7e6b7a4f13bc
patch 8.1.1908: every popup window consumes a buffer number
Bram Moolenaar <Bram@vim.org>
parents:
17817
diff
changeset
|
4140 if (eap->line1 < 1 || eap->line2 > get_highest_fnum()) |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
4141 return _(e_invrange); |
6472 | 4142 break; |
4143 case ADDR_LOADED_BUFFERS: | |
4144 buf = firstbuf; | |
4145 while (buf->b_ml.ml_mfp == NULL) | |
4146 { | |
4147 if (buf->b_next == NULL) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
4148 return _(e_invrange); |
6472 | 4149 buf = buf->b_next; |
4150 } | |
4151 if (eap->line1 < buf->b_fnum) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
4152 return _(e_invrange); |
6472 | 4153 buf = lastbuf; |
4154 while (buf->b_ml.ml_mfp == NULL) | |
4155 { | |
4156 if (buf->b_prev == NULL) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
4157 return _(e_invrange); |
6472 | 4158 buf = buf->b_prev; |
4159 } | |
4160 if (eap->line2 > buf->b_fnum) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
4161 return _(e_invrange); |
6472 | 4162 break; |
4163 case ADDR_WINDOWS: | |
6480 | 4164 if (eap->line2 > LAST_WIN_NR) |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
4165 return _(e_invrange); |
6472 | 4166 break; |
4167 case ADDR_TABS: | |
4168 if (eap->line2 > LAST_TAB_NR) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
4169 return _(e_invrange); |
6472 | 4170 break; |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
4171 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
|
4172 case ADDR_OTHER: |
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
4173 // 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
|
4174 break; |
16479
7dcf301d1432
patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents:
16475
diff
changeset
|
4175 case ADDR_QUICKFIX: |
7105
f4456e686406
commit https://github.com/vim/vim/commit/e906c502079770ae0e0071c74cefb802689ff193
Christian Brabandt <cb@256bit.org>
parents:
7092
diff
changeset
|
4176 #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
|
4177 // 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
|
4178 if (eap->line2 <= 0) |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
4179 return _(e_invrange); |
16479
7dcf301d1432
patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents:
16475
diff
changeset
|
4180 #endif |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
4181 break; |
16515
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
4182 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
|
4183 #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
|
4184 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
|
4185 || eap->line2 < 0) |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
4186 return _(e_invrange); |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
4187 #endif |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
4188 break; |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
4189 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
|
4190 if (eap->line2 < 0) |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
4191 return _(e_invrange); |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
4192 break; |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
4193 case ADDR_NONE: |
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
4194 // 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
|
4195 break; |
6472 | 4196 } |
4197 } | |
7 | 4198 return NULL; |
4199 } | |
4200 | |
4201 /* | |
4202 * Correct the range for zero line number, if required. | |
4203 */ | |
4204 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4205 correct_range(exarg_T *eap) |
7 | 4206 { |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
4207 if (!(eap->argt & EX_ZEROR)) // zero in range not allowed |
7 | 4208 { |
4209 if (eap->line1 == 0) | |
4210 eap->line1 = 1; | |
4211 if (eap->line2 == 0) | |
4212 eap->line2 = 1; | |
4213 } | |
4214 } | |
4215 | |
153 | 4216 #ifdef FEAT_QUICKFIX |
4217 /* | |
4218 * For a ":vimgrep" or ":vimgrepadd" command return a pointer past the | |
4219 * pattern. Otherwise return eap->arg. | |
4220 */ | |
4221 static char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4222 skip_grep_pat(exarg_T *eap) |
153 | 4223 { |
4224 char_u *p = eap->arg; | |
4225 | |
655 | 4226 if (*p != NUL && (eap->cmdidx == CMD_vimgrep || eap->cmdidx == CMD_lvimgrep |
4227 || eap->cmdidx == CMD_vimgrepadd | |
4228 || eap->cmdidx == CMD_lvimgrepadd | |
4229 || grep_internal(eap->cmdidx))) | |
153 | 4230 { |
170 | 4231 p = skip_vimgrep_pat(p, NULL, NULL); |
153 | 4232 if (p == NULL) |
4233 p = eap->arg; | |
4234 } | |
4235 return p; | |
4236 } | |
344 | 4237 |
4238 /* | |
4239 * For the ":make" and ":grep" commands insert the 'makeprg'/'grepprg' option | |
4240 * in the command line, so that things like % get expanded. | |
4241 */ | |
4242 static char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4243 replace_makeprg(exarg_T *eap, char_u *p, char_u **cmdlinep) |
344 | 4244 { |
4245 char_u *new_cmdline; | |
4246 char_u *program; | |
4247 char_u *pos; | |
4248 char_u *ptr; | |
4249 int len; | |
4250 int i; | |
4251 | |
4252 /* | |
4253 * Don't do it when ":vimgrep" is used for ":grep". | |
4254 */ | |
655 | 4255 if ((eap->cmdidx == CMD_make || eap->cmdidx == CMD_lmake |
4256 || eap->cmdidx == CMD_grep || eap->cmdidx == CMD_lgrep | |
4257 || eap->cmdidx == CMD_grepadd | |
4258 || eap->cmdidx == CMD_lgrepadd) | |
344 | 4259 && !grep_internal(eap->cmdidx)) |
4260 { | |
655 | 4261 if (eap->cmdidx == CMD_grep || eap->cmdidx == CMD_lgrep |
4262 || eap->cmdidx == CMD_grepadd || eap->cmdidx == CMD_lgrepadd) | |
344 | 4263 { |
4264 if (*curbuf->b_p_gp == NUL) | |
4265 program = p_gp; | |
4266 else | |
4267 program = curbuf->b_p_gp; | |
4268 } | |
4269 else | |
4270 { | |
4271 if (*curbuf->b_p_mp == NUL) | |
4272 program = p_mp; | |
4273 else | |
4274 program = curbuf->b_p_mp; | |
4275 } | |
4276 | |
4277 p = skipwhite(p); | |
4278 | |
4279 if ((pos = (char_u *)strstr((char *)program, "$*")) != NULL) | |
4280 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4281 // replace $* by given arguments |
344 | 4282 i = 1; |
4283 while ((pos = (char_u *)strstr((char *)pos + 2, "$*")) != NULL) | |
4284 ++i; | |
4285 len = (int)STRLEN(p); | |
16782
fc58fee685e2
patch 8.1.1393: unnecessary type casts
Bram Moolenaar <Bram@vim.org>
parents:
16780
diff
changeset
|
4286 new_cmdline = alloc(STRLEN(program) + i * (len - 2) + 1); |
344 | 4287 if (new_cmdline == NULL) |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4288 return NULL; // out of memory |
344 | 4289 ptr = new_cmdline; |
4290 while ((pos = (char_u *)strstr((char *)program, "$*")) != NULL) | |
4291 { | |
4292 i = (int)(pos - program); | |
4293 STRNCPY(ptr, program, i); | |
4294 STRCPY(ptr += i, p); | |
4295 ptr += len; | |
4296 program = pos + 2; | |
4297 } | |
4298 STRCPY(ptr, program); | |
4299 } | |
4300 else | |
4301 { | |
16782
fc58fee685e2
patch 8.1.1393: unnecessary type casts
Bram Moolenaar <Bram@vim.org>
parents:
16780
diff
changeset
|
4302 new_cmdline = alloc(STRLEN(program) + STRLEN(p) + 2); |
344 | 4303 if (new_cmdline == NULL) |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4304 return NULL; // out of memory |
344 | 4305 STRCPY(new_cmdline, program); |
4306 STRCAT(new_cmdline, " "); | |
4307 STRCAT(new_cmdline, p); | |
4308 } | |
4309 msg_make(p); | |
4310 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4311 // 'eap->cmd' is not set here, because it is not used at CMD_make |
344 | 4312 vim_free(*cmdlinep); |
4313 *cmdlinep = new_cmdline; | |
4314 p = new_cmdline; | |
4315 } | |
4316 return p; | |
4317 } | |
153 | 4318 #endif |
4319 | |
7 | 4320 /* |
4321 * 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
|
4322 * When an error is detected, "errormsgp" is set to a non-NULL pointer. |
7 | 4323 * Return FAIL for failure, OK otherwise. |
4324 */ | |
4325 int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4326 expand_filename( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4327 exarg_T *eap, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4328 char_u **cmdlinep, |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
4329 char **errormsgp) |
7 | 4330 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4331 int has_wildcards; // need to expand wildcards |
7 | 4332 char_u *repl; |
4333 int srclen; | |
4334 char_u *p; | |
4335 int n; | |
1098 | 4336 int escaped; |
7 | 4337 |
153 | 4338 #ifdef FEAT_QUICKFIX |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4339 // Skip a regexp pattern for ":vimgrep[add] pat file..." |
153 | 4340 p = skip_grep_pat(eap); |
4341 #else | |
4342 p = eap->arg; | |
4343 #endif | |
4344 | |
7 | 4345 /* |
4346 * Decide to expand wildcards *before* replacing '%', '#', etc. If | |
4347 * the file name contains a wildcard it should not cause expanding. | |
4348 * (it will be expanded anyway if there is a wildcard before replacing). | |
4349 */ | |
153 | 4350 has_wildcards = mch_has_wildcard(p); |
4351 while (*p != NUL) | |
7 | 4352 { |
9 | 4353 #ifdef FEAT_EVAL |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4354 // Skip over `=expr`, wildcards in it are not expanded. |
9 | 4355 if (p[0] == '`' && p[1] == '=') |
4356 { | |
4357 p += 2; | |
4358 (void)skip_expr(&p); | |
4359 if (*p == '`') | |
4360 ++p; | |
4361 continue; | |
4362 } | |
4363 #endif | |
7 | 4364 /* |
4365 * Quick check if this cannot be the start of a special string. | |
4366 * Also removes backslash before '%', '#' and '<'. | |
4367 */ | |
4368 if (vim_strchr((char_u *)"%#<", *p) == NULL) | |
4369 { | |
4370 ++p; | |
4371 continue; | |
4372 } | |
4373 | |
4374 /* | |
4375 * Try to find a match at this position. | |
4376 */ | |
1098 | 4377 repl = eval_vars(p, eap->arg, &srclen, &(eap->do_ecmd_lnum), |
4378 errormsgp, &escaped); | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4379 if (*errormsgp != NULL) // error detected |
7 | 4380 return FAIL; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4381 if (repl == NULL) // no match found |
7 | 4382 { |
4383 p += srclen; | |
4384 continue; | |
4385 } | |
4386 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4387 // 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
|
4388 // literally. But do expand "~/file", "~user/file" and "$HOME/file". |
37 | 4389 if (vim_strchr(repl, '$') != NULL || vim_strchr(repl, '~') != NULL) |
4390 { | |
4391 char_u *l = repl; | |
4392 | |
4393 repl = expand_env_save(repl); | |
4394 vim_free(l); | |
4395 } | |
4396 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4397 // 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
|
4398 // Don't do this for: |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4399 // - 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
|
4400 // - 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
|
4401 // - 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
|
4402 // separate arguments then). |
7 | 4403 if (!eap->usefilter |
1098 | 4404 && !escaped |
7 | 4405 && eap->cmdidx != CMD_bang |
4406 && 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
|
4407 && eap->cmdidx != CMD_grepadd |
1c1cb1e9b7b3
patch 8.0.0785: wildcards are not expanded for :terminal
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
4408 && eap->cmdidx != CMD_hardcopy |
655 | 4409 && eap->cmdidx != CMD_lgrep |
4410 && 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
|
4411 && eap->cmdidx != CMD_lmake |
1c1cb1e9b7b3
patch 8.0.0785: wildcards are not expanded for :terminal
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
4412 && eap->cmdidx != CMD_make |
1c1cb1e9b7b3
patch 8.0.0785: wildcards are not expanded for :terminal
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
4413 && eap->cmdidx != CMD_terminal |
7 | 4414 #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
|
4415 && !(eap->argt & EX_NOSPC) |
7 | 4416 #endif |
4417 ) | |
4418 { | |
4419 char_u *l; | |
4420 #ifdef BACKSLASH_IN_FILENAME | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4421 // 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
|
4422 // remove it later. |
7 | 4423 static char_u *nobslash = (char_u *)" \t\"|"; |
4424 # define ESCAPE_CHARS nobslash | |
4425 #else | |
4426 # define ESCAPE_CHARS escape_chars | |
4427 #endif | |
4428 | |
4429 for (l = repl; *l; ++l) | |
4430 if (vim_strchr(ESCAPE_CHARS, *l) != NULL) | |
4431 { | |
4432 l = vim_strsave_escaped(repl, ESCAPE_CHARS); | |
4433 if (l != NULL) | |
4434 { | |
4435 vim_free(repl); | |
4436 repl = l; | |
4437 } | |
4438 break; | |
4439 } | |
4440 } | |
4441 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4442 // 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
|
4443 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
|
4444 || eap->cmdidx == CMD_terminal) |
5778 | 4445 && vim_strpbrk(repl, (char_u *)"!") != NULL) |
7 | 4446 { |
4447 char_u *l; | |
4448 | |
5778 | 4449 l = vim_strsave_escaped(repl, (char_u *)"!"); |
7 | 4450 if (l != NULL) |
4451 { | |
4452 vim_free(repl); | |
4453 repl = l; | |
4454 } | |
4455 } | |
4456 | |
4457 p = repl_cmdline(eap, p, srclen, repl, cmdlinep); | |
4458 vim_free(repl); | |
4459 if (p == NULL) | |
4460 return FAIL; | |
4461 } | |
4462 | |
4463 /* | |
4464 * One file argument: Expand wildcards. | |
4465 * Don't do this with ":r !command" or ":w !command". | |
4466 */ | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
4467 if ((eap->argt & EX_NOSPC) && !eap->usefilter) |
7 | 4468 { |
4469 /* | |
4470 * May do this twice: | |
4471 * 1. Replace environment variables. | |
4472 * 2. Replace any other wildcards, remove backslashes. | |
4473 */ | |
4474 for (n = 1; n <= 2; ++n) | |
4475 { | |
4476 if (n == 2) | |
4477 { | |
4478 /* | |
4479 * Halve the number of backslashes (this is Vi compatible). | |
4480 * For Unix and OS/2, when wildcards are expanded, this is | |
4481 * done by ExpandOne() below. | |
4482 */ | |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7262
diff
changeset
|
4483 #if defined(UNIX) |
7 | 4484 if (!has_wildcards) |
4485 #endif | |
4486 backslash_halve(eap->arg); | |
4487 } | |
4488 | |
4489 if (has_wildcards) | |
4490 { | |
4491 if (n == 1) | |
4492 { | |
4493 /* | |
4494 * First loop: May expand environment variables. This | |
4495 * can be done much faster with expand_env() than with | |
4496 * something else (e.g., calling a shell). | |
4497 * After expanding environment variables, check again | |
4498 * if there are still wildcards present. | |
4499 */ | |
4500 if (vim_strchr(eap->arg, '$') != NULL | |
4501 || vim_strchr(eap->arg, '~') != NULL) | |
4502 { | |
372 | 4503 expand_env_esc(eap->arg, NameBuff, MAXPATHL, |
1408 | 4504 TRUE, TRUE, NULL); |
7 | 4505 has_wildcards = mch_has_wildcard(NameBuff); |
4506 p = NameBuff; | |
4507 } | |
4508 else | |
4509 p = NULL; | |
4510 } | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4511 else // n == 2 |
7 | 4512 { |
4513 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
|
4514 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
|
4515 | WILD_NOERROR | WILD_ADD_SLASH; |
7 | 4516 |
4517 ExpandInit(&xpc); | |
4518 xpc.xp_context = EXPAND_FILES; | |
2652 | 4519 if (p_wic) |
4520 options += WILD_ICASE; | |
7 | 4521 p = ExpandOne(&xpc, eap->arg, NULL, |
2652 | 4522 options, WILD_EXPAND_FREE); |
7 | 4523 if (p == NULL) |
4524 return FAIL; | |
4525 } | |
4526 if (p != NULL) | |
4527 { | |
4528 (void)repl_cmdline(eap, eap->arg, (int)STRLEN(eap->arg), | |
4529 p, cmdlinep); | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4530 if (n == 2) // p came from ExpandOne() |
7 | 4531 vim_free(p); |
4532 } | |
4533 } | |
4534 } | |
4535 } | |
4536 return OK; | |
4537 } | |
4538 | |
4539 /* | |
4540 * Replace part of the command line, keeping eap->cmd, eap->arg and | |
4541 * eap->nextcmd correct. | |
4542 * "src" points to the part that is to be replaced, of length "srclen". | |
4543 * "repl" is the replacement string. | |
4544 * Returns a pointer to the character after the replaced string. | |
4545 * Returns NULL for failure. | |
4546 */ | |
4547 static char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4548 repl_cmdline( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4549 exarg_T *eap, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4550 char_u *src, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4551 int srclen, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4552 char_u *repl, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4553 char_u **cmdlinep) |
7 | 4554 { |
4555 int len; | |
4556 int i; | |
4557 char_u *new_cmdline; | |
4558 | |
4559 /* | |
4560 * The new command line is build in new_cmdline[]. | |
4561 * First allocate it. | |
4562 * Careful: a "+cmd" argument may have been NUL terminated. | |
4563 */ | |
4564 len = (int)STRLEN(repl); | |
4565 i = (int)(src - *cmdlinep) + (int)STRLEN(src + srclen) + len + 3; | |
698 | 4566 if (eap->nextcmd != NULL) |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4567 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
|
4568 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
|
4569 return NULL; // out of memory! |
7 | 4570 |
4571 /* | |
4572 * Copy the stuff before the expanded part. | |
4573 * Copy the expanded stuff. | |
4574 * Copy what came after the expanded part. | |
4575 * Copy the next commands, if there are any. | |
4576 */ | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4577 i = (int)(src - *cmdlinep); // length of part before match |
7 | 4578 mch_memmove(new_cmdline, *cmdlinep, (size_t)i); |
434 | 4579 |
7 | 4580 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
|
4581 i += len; // remember the end of the string |
7 | 4582 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
|
4583 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
|
4584 |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4585 if (eap->nextcmd != NULL) // append next command |
7 | 4586 { |
4587 i = (int)STRLEN(new_cmdline) + 1; | |
4588 STRCPY(new_cmdline + i, eap->nextcmd); | |
4589 eap->nextcmd = new_cmdline + i; | |
4590 } | |
4591 eap->cmd = new_cmdline + (eap->cmd - *cmdlinep); | |
4592 eap->arg = new_cmdline + (eap->arg - *cmdlinep); | |
4593 if (eap->do_ecmd_cmd != NULL && eap->do_ecmd_cmd != dollar_command) | |
4594 eap->do_ecmd_cmd = new_cmdline + (eap->do_ecmd_cmd - *cmdlinep); | |
4595 vim_free(*cmdlinep); | |
4596 *cmdlinep = new_cmdline; | |
4597 | |
4598 return src; | |
4599 } | |
4600 | |
4601 /* | |
4602 * Check for '|' to separate commands and '"' to start comments. | |
4603 */ | |
4604 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4605 separate_nextcmd(exarg_T *eap) |
7 | 4606 { |
4607 char_u *p; | |
4608 | |
153 | 4609 #ifdef FEAT_QUICKFIX |
4610 p = skip_grep_pat(eap); | |
4611 #else | |
41 | 4612 p = eap->arg; |
4613 #endif | |
4614 | |
11127
506f5d8b7d8b
patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11010
diff
changeset
|
4615 for ( ; *p; MB_PTR_ADV(p)) |
7 | 4616 { |
4617 if (*p == Ctrl_V) | |
4618 { | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
4619 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
|
4620 ++p; // skip CTRL-V and next char |
7 | 4621 else |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4622 // remove CTRL-V and skip next char |
1619 | 4623 STRMOVE(p, p + 1); |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4624 if (*p == NUL) // stop at NUL after CTRL-V |
7 | 4625 break; |
4626 } | |
9 | 4627 |
4628 #ifdef FEAT_EVAL | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4629 // 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
|
4630 else if (p[0] == '`' && p[1] == '=' && (eap->argt & EX_XFILE)) |
9 | 4631 { |
4632 p += 2; | |
4633 (void)skip_expr(&p); | |
4634 } | |
4635 #endif | |
4636 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4637 // 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
|
4638 // :@" 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
|
4639 // :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
|
4640 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
|
4641 #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
|
4642 && !in_vim9script() |
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21335
diff
changeset
|
4643 #endif |
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21335
diff
changeset
|
4644 && !(eap->argt & EX_NOTRLCOM) |
7 | 4645 && ((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
|
4646 || p != eap->arg) |
7 | 4647 && (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
|
4648 || 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
|
4649 #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
|
4650 || (*p == '#' |
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21335
diff
changeset
|
4651 && in_vim9script() |
21893
f19ac9b8b011
patch 8.2.1496: Vim9: cannot use " #" in a mapping
Bram Moolenaar <Bram@vim.org>
parents:
21885
diff
changeset
|
4652 && !(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
|
4653 && p[1] != '{' |
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21335
diff
changeset
|
4654 && 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
|
4655 #endif |
7 | 4656 || *p == '|' || *p == '\n') |
4657 { | |
4658 /* | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
4659 * We remove the '\' before the '|', unless EX_CTRLV is used |
7 | 4660 * AND 'b' is present in 'cpoptions'. |
4661 */ | |
4662 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
|
4663 || !(eap->argt & EX_CTRLV)) && *(p - 1) == '\\') |
7 | 4664 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4665 STRMOVE(p - 1, p); // remove the '\' |
7 | 4666 --p; |
4667 } | |
4668 else | |
4669 { | |
4670 eap->nextcmd = check_nextcmd(p); | |
4671 *p = NUL; | |
4672 break; | |
4673 } | |
4674 } | |
41 | 4675 } |
4676 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4677 if (!(eap->argt & EX_NOTRLCOM)) // remove trailing spaces |
7 | 4678 del_trailing_spaces(eap->arg); |
4679 } | |
4680 | |
4681 /* | |
4682 * get + command from ex argument | |
4683 */ | |
4684 static char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4685 getargcmd(char_u **argp) |
7 | 4686 { |
4687 char_u *arg = *argp; | |
4688 char_u *command = NULL; | |
4689 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4690 if (*arg == '+') // +[command] |
7 | 4691 { |
4692 ++arg; | |
5790 | 4693 if (vim_isspace(*arg) || *arg == NUL) |
7 | 4694 command = dollar_command; |
4695 else | |
4696 { | |
4697 command = arg; | |
4698 arg = skip_cmd_arg(command, TRUE); | |
4699 if (*arg != NUL) | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4700 *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
|
4701 } |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4702 |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4703 arg = skipwhite(arg); // skip over spaces |
7 | 4704 *argp = arg; |
4705 } | |
4706 return command; | |
4707 } | |
4708 | |
4709 /* | |
4710 * Find end of "+command" argument. Skip over "\ " and "\\". | |
4711 */ | |
17835
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17823
diff
changeset
|
4712 char_u * |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4713 skip_cmd_arg( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4714 char_u *p, |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4715 int rembs) // TRUE to halve the number of backslashes |
7 | 4716 { |
4717 while (*p && !vim_isspace(*p)) | |
4718 { | |
4719 if (*p == '\\' && p[1] != NUL) | |
4720 { | |
4721 if (rembs) | |
1619 | 4722 STRMOVE(p, p + 1); |
7 | 4723 else |
4724 ++p; | |
4725 } | |
11127
506f5d8b7d8b
patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11010
diff
changeset
|
4726 MB_PTR_ADV(p); |
7 | 4727 } |
4728 return p; | |
4729 } | |
4730 | |
13575
4df23d9bad47
patch 8.0.1660: the terminal API "drop" command doesn't support options
Christian Brabandt <cb@256bit.org>
parents:
13553
diff
changeset
|
4731 int |
4df23d9bad47
patch 8.0.1660: the terminal API "drop" command doesn't support options
Christian Brabandt <cb@256bit.org>
parents:
13553
diff
changeset
|
4732 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
|
4733 { |
4df23d9bad47
patch 8.0.1660: the terminal API "drop" command doesn't support options
Christian Brabandt <cb@256bit.org>
parents:
13553
diff
changeset
|
4734 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
|
4735 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
|
4736 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
|
4737 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
|
4738 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
|
4739 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
|
4740 else |
c1ead25ed819
patch 8.1.0043: ++bad argument of :edit does not work properly
Christian Brabandt <cb@256bit.org>
parents:
14035
diff
changeset
|
4741 return FAIL; |
c1ead25ed819
patch 8.1.0043: ++bad argument of :edit does not work properly
Christian Brabandt <cb@256bit.org>
parents:
14035
diff
changeset
|
4742 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
|
4743 } |
4df23d9bad47
patch 8.0.1660: the terminal API "drop" command doesn't support options
Christian Brabandt <cb@256bit.org>
parents:
13553
diff
changeset
|
4744 |
7 | 4745 /* |
4746 * Get "++opt=arg" argument. | |
4747 * Return FAIL or OK. | |
4748 */ | |
4749 static int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4750 getargopt(exarg_T *eap) |
7 | 4751 { |
4752 char_u *arg = eap->arg + 2; | |
4753 int *pp = NULL; | |
2168 | 4754 int bad_char_idx; |
7 | 4755 char_u *p; |
4756 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4757 // ":edit ++[no]bin[ary] file" |
7 | 4758 if (STRNCMP(arg, "bin", 3) == 0 || STRNCMP(arg, "nobin", 5) == 0) |
4759 { | |
4760 if (*arg == 'n') | |
4761 { | |
4762 arg += 2; | |
4763 eap->force_bin = FORCE_NOBIN; | |
4764 } | |
4765 else | |
4766 eap->force_bin = FORCE_BIN; | |
4767 if (!checkforcmd(&arg, "binary", 3)) | |
4768 return FAIL; | |
4769 eap->arg = skipwhite(arg); | |
4770 return OK; | |
4771 } | |
4772 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4773 // ":read ++edit file" |
819 | 4774 if (STRNCMP(arg, "edit", 4) == 0) |
4775 { | |
4776 eap->read_edit = TRUE; | |
4777 eap->arg = skipwhite(arg + 4); | |
4778 return OK; | |
4779 } | |
4780 | |
7 | 4781 if (STRNCMP(arg, "ff", 2) == 0) |
4782 { | |
4783 arg += 2; | |
4784 pp = &eap->force_ff; | |
4785 } | |
4786 else if (STRNCMP(arg, "fileformat", 10) == 0) | |
4787 { | |
4788 arg += 10; | |
4789 pp = &eap->force_ff; | |
4790 } | |
4791 else if (STRNCMP(arg, "enc", 3) == 0) | |
4792 { | |
3208 | 4793 if (STRNCMP(arg, "encoding", 8) == 0) |
4794 arg += 8; | |
4795 else | |
4796 arg += 3; | |
7 | 4797 pp = &eap->force_enc; |
4798 } | |
595 | 4799 else if (STRNCMP(arg, "bad", 3) == 0) |
4800 { | |
4801 arg += 3; | |
2168 | 4802 pp = &bad_char_idx; |
595 | 4803 } |
7 | 4804 |
4805 if (pp == NULL || *arg != '=') | |
4806 return FAIL; | |
4807 | |
4808 ++arg; | |
4809 *pp = (int)(arg - eap->cmd); | |
4810 arg = skip_cmd_arg(arg, FALSE); | |
4811 eap->arg = skipwhite(arg); | |
4812 *arg = NUL; | |
4813 | |
4814 if (pp == &eap->force_ff) | |
4815 { | |
4816 if (check_ff_value(eap->cmd + eap->force_ff) == FAIL) | |
4817 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
|
4818 eap->force_ff = eap->cmd[eap->force_ff]; |
7 | 4819 } |
595 | 4820 else if (pp == &eap->force_enc) |
7 | 4821 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4822 // Make 'fileencoding' lower case. |
7 | 4823 for (p = eap->cmd + eap->force_enc; *p != NUL; ++p) |
4824 *p = TOLOWER_ASC(*p); | |
4825 } | |
595 | 4826 else |
4827 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4828 // 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
|
4829 // "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
|
4830 if (get_bad_opt(eap->cmd + bad_char_idx, eap) == FAIL) |
595 | 4831 return FAIL; |
4832 } | |
7 | 4833 |
4834 return OK; | |
4835 } | |
4836 | |
4837 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4838 ex_autocmd(exarg_T *eap) |
7 | 4839 { |
4840 /* | |
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
|
4841 * Disallow autocommands from .exrc and .vimrc in current |
7 | 4842 * directory for security reasons. |
4843 */ | |
4844 if (secure) | |
4845 { | |
4846 secure = 2; | |
21459
a422bd80b434
patch 8.2.1280: Ex command error cannot contain an argument
Bram Moolenaar <Bram@vim.org>
parents:
21413
diff
changeset
|
4847 eap->errmsg = _(e_curdir); |
7 | 4848 } |
4849 else if (eap->cmdidx == CMD_autocmd) | |
4850 do_autocmd(eap->arg, eap->forceit); | |
4851 else | |
4852 do_augroup(eap->arg, eap->forceit); | |
4853 } | |
4854 | |
4855 /* | |
4856 * ":doautocmd": Apply the automatic commands to the current buffer. | |
4857 */ | |
4858 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4859 ex_doautocmd(exarg_T *eap) |
7 | 4860 { |
3350 | 4861 char_u *arg = eap->arg; |
4862 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
|
4863 int did_aucmd; |
ac8180818504
commit https://github.com/vim/vim/commit/1610d052413e0ed664498853a47acc2d677a22d1
Christian Brabandt <cb@256bit.org>
parents:
9230
diff
changeset
|
4864 |
ac8180818504
commit https://github.com/vim/vim/commit/1610d052413e0ed664498853a47acc2d677a22d1
Christian Brabandt <cb@256bit.org>
parents:
9230
diff
changeset
|
4865 (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
|
4866 // 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
|
4867 if (call_do_modelines && did_aucmd) |
3350 | 4868 do_modelines(0); |
7 | 4869 } |
4870 | |
4871 /* | |
4872 * :[N]bunload[!] [N] [bufname] unload buffer | |
4873 * :[N]bdelete[!] [N] [bufname] delete buffer from buffer list | |
4874 * :[N]bwipeout[!] [N] [bufname] delete buffer really | |
4875 */ | |
4876 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4877 ex_bunload(exarg_T *eap) |
7 | 4878 { |
19271
ebeeb4b4a1fa
patch 8.2.0194: some commands can cause problems in terminal popup
Bram Moolenaar <Bram@vim.org>
parents:
19261
diff
changeset
|
4879 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
|
4880 return; |
7 | 4881 eap->errmsg = do_bufdel( |
4882 eap->cmdidx == CMD_bdelete ? DOBUF_DEL | |
4883 : eap->cmdidx == CMD_bwipeout ? DOBUF_WIPE | |
4884 : DOBUF_UNLOAD, eap->arg, | |
4885 eap->addr_count, (int)eap->line1, (int)eap->line2, eap->forceit); | |
4886 } | |
4887 | |
4888 /* | |
4889 * :[N]buffer [N] to buffer N | |
4890 * :[N]sbuffer [N] to buffer N | |
4891 */ | |
4892 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4893 ex_buffer(exarg_T *eap) |
7 | 4894 { |
19271
ebeeb4b4a1fa
patch 8.2.0194: some commands can cause problems in terminal popup
Bram Moolenaar <Bram@vim.org>
parents:
19261
diff
changeset
|
4895 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
|
4896 return; |
7 | 4897 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
|
4898 eap->errmsg = ex_errmsg(e_trailing_arg, eap->arg); |
7 | 4899 else |
4900 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4901 if (eap->addr_count == 0) // default is current buffer |
7 | 4902 goto_buffer(eap, DOBUF_CURRENT, FORWARD, 0); |
4903 else | |
4904 goto_buffer(eap, DOBUF_FIRST, FORWARD, (int)eap->line2); | |
6230 | 4905 if (eap->do_ecmd_cmd != NULL) |
4906 do_cmdline_cmd(eap->do_ecmd_cmd); | |
7 | 4907 } |
4908 } | |
4909 | |
4910 /* | |
4911 * :[N]bmodified [N] to next mod. buffer | |
4912 * :[N]sbmodified [N] to next mod. buffer | |
4913 */ | |
4914 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4915 ex_bmodified(exarg_T *eap) |
7 | 4916 { |
4917 goto_buffer(eap, DOBUF_MOD, FORWARD, (int)eap->line2); | |
6230 | 4918 if (eap->do_ecmd_cmd != NULL) |
4919 do_cmdline_cmd(eap->do_ecmd_cmd); | |
7 | 4920 } |
4921 | |
4922 /* | |
4923 * :[N]bnext [N] to next buffer | |
4924 * :[N]sbnext [N] split and to next buffer | |
4925 */ | |
4926 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4927 ex_bnext(exarg_T *eap) |
7 | 4928 { |
19271
ebeeb4b4a1fa
patch 8.2.0194: some commands can cause problems in terminal popup
Bram Moolenaar <Bram@vim.org>
parents:
19261
diff
changeset
|
4929 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
|
4930 return; |
17722555af22
patch 8.2.0127: some buffer commands work in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19131
diff
changeset
|
4931 |
7 | 4932 goto_buffer(eap, DOBUF_CURRENT, FORWARD, (int)eap->line2); |
6230 | 4933 if (eap->do_ecmd_cmd != NULL) |
4934 do_cmdline_cmd(eap->do_ecmd_cmd); | |
7 | 4935 } |
4936 | |
4937 /* | |
4938 * :[N]bNext [N] to previous buffer | |
4939 * :[N]bprevious [N] to previous buffer | |
4940 * :[N]sbNext [N] split and to previous buffer | |
4941 * :[N]sbprevious [N] split and to previous buffer | |
4942 */ | |
4943 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4944 ex_bprevious(exarg_T *eap) |
7 | 4945 { |
19271
ebeeb4b4a1fa
patch 8.2.0194: some commands can cause problems in terminal popup
Bram Moolenaar <Bram@vim.org>
parents:
19261
diff
changeset
|
4946 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
|
4947 return; |
17722555af22
patch 8.2.0127: some buffer commands work in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19131
diff
changeset
|
4948 |
7 | 4949 goto_buffer(eap, DOBUF_CURRENT, BACKWARD, (int)eap->line2); |
6230 | 4950 if (eap->do_ecmd_cmd != NULL) |
4951 do_cmdline_cmd(eap->do_ecmd_cmd); | |
7 | 4952 } |
4953 | |
4954 /* | |
4955 * :brewind to first buffer | |
4956 * :bfirst to first buffer | |
4957 * :sbrewind split and to first buffer | |
4958 * :sbfirst split and to first buffer | |
4959 */ | |
4960 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4961 ex_brewind(exarg_T *eap) |
7 | 4962 { |
19271
ebeeb4b4a1fa
patch 8.2.0194: some commands can cause problems in terminal popup
Bram Moolenaar <Bram@vim.org>
parents:
19261
diff
changeset
|
4963 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
|
4964 return; |
17722555af22
patch 8.2.0127: some buffer commands work in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19131
diff
changeset
|
4965 |
7 | 4966 goto_buffer(eap, DOBUF_FIRST, FORWARD, 0); |
6230 | 4967 if (eap->do_ecmd_cmd != NULL) |
4968 do_cmdline_cmd(eap->do_ecmd_cmd); | |
7 | 4969 } |
4970 | |
4971 /* | |
4972 * :blast to last buffer | |
4973 * :sblast split and to last buffer | |
4974 */ | |
4975 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4976 ex_blast(exarg_T *eap) |
7 | 4977 { |
19271
ebeeb4b4a1fa
patch 8.2.0194: some commands can cause problems in terminal popup
Bram Moolenaar <Bram@vim.org>
parents:
19261
diff
changeset
|
4978 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
|
4979 return; |
17722555af22
patch 8.2.0127: some buffer commands work in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19131
diff
changeset
|
4980 |
7 | 4981 goto_buffer(eap, DOBUF_LAST, BACKWARD, 0); |
6230 | 4982 if (eap->do_ecmd_cmd != NULL) |
4983 do_cmdline_cmd(eap->do_ecmd_cmd); | |
7 | 4984 } |
4985 | |
20059
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20027
diff
changeset
|
4986 /* |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20027
diff
changeset
|
4987 * Check if "c" ends an Ex command. |
20075
516b10943fdb
patch 8.2.0593: finding a user command is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
20063
diff
changeset
|
4988 * In Vim9 script does not check for white space before # or #{. |
20059
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20027
diff
changeset
|
4989 */ |
7 | 4990 int |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4991 ends_excmd(int c) |
7 | 4992 { |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21335
diff
changeset
|
4993 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
|
4994 |
20027
23a4aef4f923
patch 8.2.0569: build failure with tiny version
Bram Moolenaar <Bram@vim.org>
parents:
20023
diff
changeset
|
4995 #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
|
4996 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
|
4997 comment_char = '#'; |
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21335
diff
changeset
|
4998 #endif |
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21335
diff
changeset
|
4999 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
|
5000 } |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20027
diff
changeset
|
5001 |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20027
diff
changeset
|
5002 /* |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20027
diff
changeset
|
5003 * 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
|
5004 * 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
|
5005 */ |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20027
diff
changeset
|
5006 int |
20063
cc146cde0b4d
patch 8.2.0587: compiler warning for unused variable
Bram Moolenaar <Bram@vim.org>
parents:
20059
diff
changeset
|
5007 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
|
5008 { |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20027
diff
changeset
|
5009 int c = *cmd; |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20027
diff
changeset
|
5010 |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21335
diff
changeset
|
5011 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
|
5012 return TRUE; |
20059
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20027
diff
changeset
|
5013 #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
|
5014 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
|
5015 return c == '#' && cmd[1] != '{' |
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21335
diff
changeset
|
5016 && (cmd == cmd_start || VIM_ISWHITE(cmd[-1])); |
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21335
diff
changeset
|
5017 #endif |
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21335
diff
changeset
|
5018 return c == '"'; |
7 | 5019 } |
5020 | |
5021 #if defined(FEAT_SYN_HL) || defined(FEAT_SEARCH_EXTRA) || defined(FEAT_EVAL) \ | |
5022 || defined(PROTO) | |
5023 /* | |
5024 * Return the next command, after the first '|' or '\n'. | |
5025 * Return NULL if not found. | |
5026 */ | |
5027 char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5028 find_nextcmd(char_u *p) |
7 | 5029 { |
5030 while (*p != '|' && *p != '\n') | |
5031 { | |
5032 if (*p == NUL) | |
5033 return NULL; | |
5034 ++p; | |
5035 } | |
5036 return (p + 1); | |
5037 } | |
5038 #endif | |
5039 | |
5040 /* | |
10383
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5041 * 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
|
5042 * Return NULL if it isn't, the following character if it is. |
7 | 5043 */ |
5044 char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5045 check_nextcmd(char_u *p) |
7 | 5046 { |
10383
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5047 char_u *s = skipwhite(p); |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5048 |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5049 if (*s == '|' || *s == '\n') |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5050 return (s + 1); |
7 | 5051 else |
5052 return NULL; | |
5053 } | |
5054 | |
5055 /* | |
5056 * - if there are more files to edit | |
5057 * - and this is the last window | |
5058 * - and forceit not used | |
5059 * - and not repeated twice on a row | |
5060 * return FAIL and give error message if 'message' TRUE | |
5061 * return OK otherwise | |
5062 */ | |
5063 static int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5064 check_more( |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5065 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
|
5066 int forceit) |
7 | 5067 { |
5068 int n = ARGCOUNT - curwin->w_arg_idx - 1; | |
5069 | |
672 | 5070 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
|
5071 && ARGCOUNT > 1 && !arg_had_last && n > 0 && quitmore == 0) |
7 | 5072 { |
5073 if (message) | |
5074 { | |
5075 #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) | |
5076 if ((p_confirm || cmdmod.confirm) && curbuf->b_fname != NULL) | |
5077 { | |
2770 | 5078 char_u buff[DIALOG_MSG_SIZE]; |
7 | 5079 |
14585
c8f07e8b273e
patch 8.1.0306: plural messages are not translated properly
Christian Brabandt <cb@256bit.org>
parents:
14550
diff
changeset
|
5080 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
|
5081 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
|
5082 "%d more files to edit. Quit anyway?", n), n); |
7 | 5083 if (vim_dialog_yesno(VIM_QUESTION, NULL, buff, 1) == VIM_YES) |
5084 return OK; | |
5085 return FAIL; | |
5086 } | |
5087 #endif | |
15490
98c35d312987
patch 8.1.0753: printf format not checked for semsg()
Bram Moolenaar <Bram@vim.org>
parents:
15488
diff
changeset
|
5088 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
|
5089 "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
|
5090 quitmore = 2; // next try to quit is allowed |
7 | 5091 } |
5092 return FAIL; | |
5093 } | |
5094 return OK; | |
5095 } | |
5096 | |
5097 /* | |
5098 * Function given to ExpandGeneric() to obtain the list of command names. | |
5099 */ | |
5100 char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5101 get_command_name(expand_T *xp UNUSED, int idx) |
7 | 5102 { |
5103 if (idx >= (int)CMD_SIZE) | |
5104 return get_user_command_name(idx); | |
5105 return cmdnames[idx].cmd_name; | |
5106 } | |
5107 | |
5108 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5109 ex_colorscheme(exarg_T *eap) |
7 | 5110 { |
2142
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
5111 if (*eap->arg == NUL) |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
5112 { |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
5113 #ifdef FEAT_EVAL |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
5114 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
|
5115 char_u *p = NULL; |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
5116 |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
5117 if (expr != NULL) |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
5118 { |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
5119 ++emsg_off; |
20996
3af71cbcfdbe
patch 8.2.1049: Vim9: leaking memory when using continuation line
Bram Moolenaar <Bram@vim.org>
parents:
20982
diff
changeset
|
5120 p = eval_to_string(expr, FALSE); |
2142
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
5121 --emsg_off; |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
5122 vim_free(expr); |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
5123 } |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
5124 if (p != NULL) |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
5125 { |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15510
diff
changeset
|
5126 msg((char *)p); |
2142
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
5127 vim_free(p); |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
5128 } |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
5129 else |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15510
diff
changeset
|
5130 msg("default"); |
2142
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
5131 #else |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15510
diff
changeset
|
5132 msg(_("unknown")); |
2142
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
5133 #endif |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
5134 } |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
5135 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
|
5136 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
|
5137 |
61448894376e
patch 8.1.0839: when using VTP wrong colors after a color scheme change
Bram Moolenaar <Bram@vim.org>
parents:
15643
diff
changeset
|
5138 #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
|
5139 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
|
5140 { |
61448894376e
patch 8.1.0839: when using VTP wrong colors after a color scheme change
Bram Moolenaar <Bram@vim.org>
parents:
15643
diff
changeset
|
5141 // 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
|
5142 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
|
5143 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
|
5144 } |
61448894376e
patch 8.1.0839: when using VTP wrong colors after a color scheme change
Bram Moolenaar <Bram@vim.org>
parents:
15643
diff
changeset
|
5145 #endif |
7 | 5146 } |
5147 | |
5148 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5149 ex_highlight(exarg_T *eap) |
7 | 5150 { |
5151 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
|
5152 msg(_("Greetings, Vim user!")); |
7 | 5153 do_highlight(eap->arg, eap->forceit, FALSE); |
5154 } | |
5155 | |
5156 | |
5157 /* | |
5158 * Call this function if we thought we were going to exit, but we won't | |
5159 * (because of an error). May need to restore the terminal mode. | |
5160 */ | |
5161 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5162 not_exiting(void) |
7 | 5163 { |
5164 exiting = FALSE; | |
5165 settmode(TMODE_RAW); | |
5166 } | |
5167 | |
13442
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5168 static int |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5169 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
|
5170 { |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5171 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
|
5172 |
18406
fa6efc49d71f
patch 8.1.2197: ExitPre autocommand may cause accessing freed memory
Bram Moolenaar <Bram@vim.org>
parents:
18402
diff
changeset
|
5173 // 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
|
5174 // 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
|
5175 // only happen in autocommands). |
13442
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5176 if (!win_valid(wp) |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5177 || curbuf_locked() |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5178 || (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
|
5179 return TRUE; |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5180 |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5181 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
|
5182 { |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5183 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
|
5184 // 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
|
5185 // 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
|
5186 // autocommands). |
fa6efc49d71f
patch 8.1.2197: ExitPre autocommand may cause accessing freed memory
Bram Moolenaar <Bram@vim.org>
parents:
18402
diff
changeset
|
5187 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
|
5188 || (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
|
5189 return TRUE; |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5190 } |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5191 |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5192 return FALSE; |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5193 } |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5194 |
7 | 5195 /* |
6409 | 5196 * ":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
|
5197 * ":{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
|
5198 * 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
|
5199 */ |
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
|
5200 void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5201 ex_quit(exarg_T *eap) |
7 | 5202 { |
6398 | 5203 win_T *wp; |
5204 | |
7 | 5205 #ifdef FEAT_CMDWIN |
5206 if (cmdwin_type != 0) | |
5207 { | |
5208 cmdwin_result = Ctrl_C; | |
5209 return; | |
5210 } | |
5211 #endif | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5212 // Don't quit while editing the command line. |
633 | 5213 if (text_locked()) |
5214 { | |
5215 text_locked_msg(); | |
631 | 5216 return; |
5217 } | |
6398 | 5218 if (eap->addr_count > 0) |
5219 { | |
6409 | 5220 int wnr = eap->line2; |
5221 | |
5222 for (wp = firstwin; wp->w_next != NULL; wp = wp->w_next) | |
5223 if (--wnr <= 0) | |
6398 | 5224 break; |
5225 } | |
5226 else | |
5227 wp = curwin; | |
6409 | 5228 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5229 // 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
|
5230 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
|
5231 return; |
13442
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5232 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5233 // 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
|
5234 if (before_quit_autocmds(wp, FALSE, eap->forceit)) |
819 | 5235 return; |
7 | 5236 |
5237 #ifdef FEAT_NETBEANS_INTG | |
5238 netbeansForcedQuit = eap->forceit; | |
5239 #endif | |
5240 | |
5241 /* | |
5242 * If there are more files or windows we won't exit. | |
5243 */ | |
5244 if (check_more(FALSE, eap->forceit) == OK && only_one_window()) | |
5245 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
|
5246 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
|
5247 && check_changed(wp->w_buffer, (p_awa ? CCGD_AW : 0) |
5464 | 5248 | (eap->forceit ? CCGD_FORCEIT : 0) |
5249 | CCGD_EXCMD)) | |
7 | 5250 || 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
|
5251 || (only_one_window() && check_changed_any(eap->forceit, TRUE))) |
7 | 5252 { |
5253 not_exiting(); | |
5254 } | |
5255 else | |
5256 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5257 // quit last window |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5258 // 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
|
5259 // 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
|
5260 // specified. Example: |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5261 // :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
|
5262 // :h|wincmd w|q - quit |
10349
cf988222b150
commit https://github.com/vim/vim/commit/a1f4cb93ba50ea9e40cd4b1f5592b8a6d1398660
Christian Brabandt <cb@256bit.org>
parents:
10275
diff
changeset
|
5263 if (only_one_window() && (ONE_WINDOW || eap->addr_count == 0)) |
7 | 5264 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
|
5265 not_exiting(); |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5266 #ifdef FEAT_GUI |
7 | 5267 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
|
5268 #endif |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5269 // 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
|
5270 win_close(wp, !buf_hide(wp->w_buffer) || eap->forceit); |
7 | 5271 } |
5272 } | |
5273 | |
5274 /* | |
5275 * ":cquit". | |
5276 */ | |
5277 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5278 ex_cquit(exarg_T *eap UNUSED) |
7 | 5279 { |
19069
e14feba578f1
patch 8.2.0095: cannot specify exit code for :cquit
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
5280 // 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
|
5281 getout(eap->addr_count > 0 ? (int)eap->line2 : EXIT_FAILURE); |
7 | 5282 } |
5283 | |
5284 /* | |
5285 * ":qall": try to quit all windows | |
5286 */ | |
5287 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5288 ex_quit_all(exarg_T *eap) |
7 | 5289 { |
5290 # ifdef FEAT_CMDWIN | |
5291 if (cmdwin_type != 0) | |
5292 { | |
5293 if (eap->forceit) | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5294 cmdwin_result = K_XF1; // ex_window() takes care of this |
7 | 5295 else |
5296 cmdwin_result = K_XF2; | |
5297 return; | |
5298 } | |
5299 # endif | |
631 | 5300 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5301 // Don't quit while editing the command line. |
633 | 5302 if (text_locked()) |
5303 { | |
5304 text_locked_msg(); | |
631 | 5305 return; |
5306 } | |
13442
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5307 |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5308 if (before_quit_autocmds(curwin, TRUE, eap->forceit)) |
819 | 5309 return; |
631 | 5310 |
7 | 5311 exiting = TRUE; |
7469
15eefe1b0dad
commit https://github.com/vim/vim/commit/027387f70c671f62e3e08e0bdd09ec05b0232735
Christian Brabandt <cb@256bit.org>
parents:
7465
diff
changeset
|
5312 if (eap->forceit || !check_changed_any(FALSE, FALSE)) |
7 | 5313 getout(0); |
5314 not_exiting(); | |
5315 } | |
5316 | |
5317 /* | |
5318 * ":close": close current window, unless it is the last one | |
5319 */ | |
5320 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5321 ex_close(exarg_T *eap) |
7 | 5322 { |
6398 | 5323 win_T *win; |
5324 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
|
5325 #ifdef FEAT_CMDWIN |
7 | 5326 if (cmdwin_type != 0) |
2839 | 5327 cmdwin_result = Ctrl_C; |
7 | 5328 else |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5329 #endif |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
5330 if (!text_locked() && !curbuf_locked()) |
6398 | 5331 { |
5332 if (eap->addr_count == 0) | |
5333 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
|
5334 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
|
5335 { |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9538
diff
changeset
|
5336 FOR_ALL_WINDOWS(win) |
6398 | 5337 { |
5338 winnr++; | |
5339 if (winnr == eap->line2) | |
5340 break; | |
5341 } | |
5342 if (win == NULL) | |
5343 win = lastwin; | |
5344 ex_win_close(eap->forceit, win, NULL); | |
5345 } | |
5346 } | |
667 | 5347 } |
5348 | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5349 #ifdef FEAT_QUICKFIX |
667 | 5350 /* |
5351 * ":pclose": Close any preview window. | |
5352 */ | |
5353 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5354 ex_pclose(exarg_T *eap) |
667 | 5355 { |
5356 win_T *win; | |
5357 | |
17431
ce35cdbe9f74
patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
17336
diff
changeset
|
5358 // First close any normal window. |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9538
diff
changeset
|
5359 FOR_ALL_WINDOWS(win) |
667 | 5360 if (win->w_p_pvw) |
5361 { | |
671 | 5362 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
|
5363 return; |
ce35cdbe9f74
patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
17336
diff
changeset
|
5364 } |
18763
49b78d6465e5
patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents:
18715
diff
changeset
|
5365 # 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
|
5366 // 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
|
5367 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
|
5368 # endif |
667 | 5369 } |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5370 #endif |
667 | 5371 |
671 | 5372 /* |
5373 * Close window "win" and take care of handling closing the last window for a | |
5374 * modified buffer. | |
5375 */ | |
5376 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5377 ex_win_close( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5378 int forceit, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5379 win_T *win, |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5380 tabpage_T *tp) // NULL or the tab page "win" is in |
7 | 5381 { |
5382 int need_hide; | |
5383 buf_T *buf = win->w_buffer; | |
5384 | |
21016
0738c44504cb
patch 8.2.1059: crash when using :tabonly in an autocommand
Bram Moolenaar <Bram@vim.org>
parents:
20996
diff
changeset
|
5385 // 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
|
5386 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
|
5387 { |
0738c44504cb
patch 8.2.1059: crash when using :tabonly in an autocommand
Bram Moolenaar <Bram@vim.org>
parents:
20996
diff
changeset
|
5388 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
|
5389 return; |
0738c44504cb
patch 8.2.1059: crash when using :tabonly in an autocommand
Bram Moolenaar <Bram@vim.org>
parents:
20996
diff
changeset
|
5390 } |
0738c44504cb
patch 8.2.1059: crash when using :tabonly in an autocommand
Bram Moolenaar <Bram@vim.org>
parents:
20996
diff
changeset
|
5391 |
7 | 5392 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
|
5393 if (need_hide && !buf_hide(buf) && !forceit) |
7 | 5394 { |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5395 #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) |
7 | 5396 if ((p_confirm || cmdmod.confirm) && p_write) |
5397 { | |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9460
diff
changeset
|
5398 bufref_T bufref; |
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9460
diff
changeset
|
5399 |
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9460
diff
changeset
|
5400 set_bufref(&bufref, buf); |
7 | 5401 dialog_changed(buf, FALSE); |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9460
diff
changeset
|
5402 if (bufref_valid(&bufref) && bufIsChanged(buf)) |
7 | 5403 return; |
5404 need_hide = FALSE; | |
5405 } | |
5406 else | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5407 #endif |
7 | 5408 { |
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
|
5409 no_write_message(); |
7 | 5410 return; |
5411 } | |
5412 } | |
5413 | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5414 #ifdef FEAT_GUI |
7 | 5415 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
|
5416 #endif |
671 | 5417 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5418 // free buffer when not hiding it or when it's a scratch buffer |
671 | 5419 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
|
5420 win_close(win, !need_hide && !buf_hide(buf)); |
671 | 5421 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
|
5422 win_close_othertab(win, !need_hide && !buf_hide(buf), tp); |
671 | 5423 } |
5424 | |
5425 /* | |
10741
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5426 * 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
|
5427 * Returns a tabpage number. |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5428 * 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
|
5429 */ |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5430 static int |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5431 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
|
5432 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5433 int tab_number; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5434 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
|
5435 |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5436 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
|
5437 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5438 char_u *p = eap->arg; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5439 char_u *p_save; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5440 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
|
5441 // 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
|
5442 |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5443 if (*p == '-') |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5444 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5445 relative = -1; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5446 p++; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5447 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5448 else if (*p == '+') |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5449 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5450 relative = 1; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5451 p++; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5452 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5453 |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5454 p_save = p; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5455 tab_number = getdigits(&p); |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5456 |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5457 if (relative == 0) |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5458 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5459 if (STRCMP(p, "$") == 0) |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5460 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
|
5461 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
|
5462 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
|
5463 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
|
5464 else |
860cad58f557
patch 8.2.1413: previous tab page not usable from an Ex command
Bram Moolenaar <Bram@vim.org>
parents:
21664
diff
changeset
|
5465 { |
860cad58f557
patch 8.2.1413: previous tab page not usable from an Ex command
Bram Moolenaar <Bram@vim.org>
parents:
21664
diff
changeset
|
5466 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
|
5467 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
|
5468 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
|
5469 } |
10741
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5470 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
|
5471 || tab_number > LAST_TAB_NR) |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5472 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5473 // 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
|
5474 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
|
5475 goto theend; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5476 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5477 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5478 else |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5479 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5480 if (*p_save == NUL) |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5481 tab_number = 1; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5482 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
|
5483 || tab_number == 0) |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5484 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5485 // 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
|
5486 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
|
5487 goto theend; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5488 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5489 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
|
5490 if (!unaccept_arg0 && relative == -1) |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5491 --tab_number; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5492 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5493 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
|
5494 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
|
5495 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5496 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
|
5497 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5498 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
|
5499 { |
21459
a422bd80b434
patch 8.2.1280: Ex command error cannot contain an argument
Bram Moolenaar <Bram@vim.org>
parents:
21413
diff
changeset
|
5500 eap->errmsg = _(e_invrange); |
10753
4961e7acdd8c
patch 8.0.0266: compiler warning for using uninitialized variable
Christian Brabandt <cb@256bit.org>
parents:
10741
diff
changeset
|
5501 tab_number = 0; |
4961e7acdd8c
patch 8.0.0266: compiler warning for using uninitialized variable
Christian Brabandt <cb@256bit.org>
parents:
10741
diff
changeset
|
5502 } |
10741
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5503 else |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5504 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5505 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
|
5506 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
|
5507 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5508 --tab_number; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5509 if (tab_number < unaccept_arg0) |
21459
a422bd80b434
patch 8.2.1280: Ex command error cannot contain an argument
Bram Moolenaar <Bram@vim.org>
parents:
21413
diff
changeset
|
5510 eap->errmsg = _(e_invrange); |
10741
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5511 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5512 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5513 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5514 else |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5515 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5516 switch (eap->cmdidx) |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5517 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5518 case CMD_tabnext: |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5519 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
|
5520 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
|
5521 tab_number = 1; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5522 break; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5523 case CMD_tabmove: |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5524 tab_number = LAST_TAB_NR; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5525 break; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5526 default: |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5527 tab_number = tabpage_index(curtab); |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5528 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5529 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5530 |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5531 theend: |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5532 return tab_number; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5533 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5534 |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5535 /* |
671 | 5536 * ":tabclose": close current tab page, unless it is the last one. |
5537 * ":tabclose N": close tab page N. | |
667 | 5538 */ |
5539 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5540 ex_tabclose(exarg_T *eap) |
667 | 5541 { |
671 | 5542 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
|
5543 int tab_number; |
671 | 5544 |
667 | 5545 # ifdef FEAT_CMDWIN |
5546 if (cmdwin_type != 0) | |
5547 cmdwin_result = K_IGNORE; | |
5548 else | |
5549 # endif | |
671 | 5550 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
|
5551 emsg(_("E784: Cannot close last tab page")); |
671 | 5552 else |
5553 { | |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5554 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
|
5555 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
|
5556 { |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5557 tp = find_tabpage(tab_number); |
671 | 5558 if (tp == NULL) |
5559 { | |
5560 beep_flush(); | |
5561 return; | |
5562 } | |
674 | 5563 if (tp != curtab) |
671 | 5564 { |
5565 tabpage_close_other(tp, eap->forceit); | |
5566 return; | |
5567 } | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
5568 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
|
5569 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
|
5570 } |
671 | 5571 } |
672 | 5572 } |
5573 | |
5574 /* | |
5575 * ":tabonly": close all tab pages except the current one | |
5576 */ | |
5577 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5578 ex_tabonly(exarg_T *eap) |
672 | 5579 { |
5580 tabpage_T *tp; | |
5581 int done; | |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5582 int tab_number; |
672 | 5583 |
5584 # ifdef FEAT_CMDWIN | |
5585 if (cmdwin_type != 0) | |
5586 cmdwin_result = K_IGNORE; | |
5587 else | |
5588 # endif | |
5589 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
|
5590 msg(_("Already only one tab page")); |
672 | 5591 else |
5592 { | |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5593 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
|
5594 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
|
5595 { |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5596 goto_tabpage(tab_number); |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5597 // 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
|
5598 // 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
|
5599 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
|
5600 { |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5601 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
|
5602 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
|
5603 { |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5604 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
|
5605 // 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
|
5606 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
|
5607 done = 1000; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5608 // 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
|
5609 break; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5610 } |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5611 if (first_tabpage->tp_next == NULL) |
672 | 5612 break; |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5613 } |
672 | 5614 } |
5615 } | |
671 | 5616 } |
5617 | |
5618 /* | |
5619 * Close the current tab page. | |
5620 */ | |
5621 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5622 tabpage_close(int forceit) |
671 | 5623 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5624 // 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
|
5625 // 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
|
5626 if (!ONE_WINDOW) |
675 | 5627 close_others(TRUE, forceit); |
10357
59d01e335858
commit https://github.com/vim/vim/commit/459ca563128f2edb7e3bb190090bbb755a56dd55
Christian Brabandt <cb@256bit.org>
parents:
10349
diff
changeset
|
5628 if (ONE_WINDOW) |
671 | 5629 ex_win_close(forceit, curwin, NULL); |
5630 # ifdef FEAT_GUI | |
5631 need_mouse_correct = TRUE; | |
5632 # endif | |
5633 } | |
5634 | |
5635 /* | |
5636 * Close tab page "tp", which is not the current tab page. | |
5637 * Note that autocommands may make "tp" invalid. | |
971 | 5638 * Also takes care of the tab pages line disappearing when closing the |
5639 * last-but-one tab page. | |
671 | 5640 */ |
5641 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5642 tabpage_close_other(tabpage_T *tp, int forceit) |
671 | 5643 { |
5644 int done = 0; | |
672 | 5645 win_T *wp; |
971 | 5646 int h = tabline_height(); |
671 | 5647 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5648 // 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
|
5649 // one. OK, so I'm paranoid... |
671 | 5650 while (++done < 1000) |
5651 { | |
672 | 5652 wp = tp->tp_firstwin; |
5653 ex_win_close(forceit, wp, tp); | |
5654 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5655 // 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
|
5656 // fail to close a window with a modified buffer. |
672 | 5657 if (!valid_tabpage(tp) || tp->tp_firstwin == wp) |
671 | 5658 break; |
5659 } | |
971 | 5660 |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9538
diff
changeset
|
5661 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
|
5662 |
672 | 5663 redraw_tabline = TRUE; |
971 | 5664 if (h != tabline_height()) |
5665 shell_new_rows(); | |
667 | 5666 } |
7 | 5667 |
5668 /* | |
5669 * ":only". | |
5670 */ | |
5671 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5672 ex_only(exarg_T *eap) |
7 | 5673 { |
6398 | 5674 win_T *wp; |
5675 int wnr; | |
7 | 5676 # ifdef FEAT_GUI |
5677 need_mouse_correct = TRUE; | |
5678 # endif | |
6398 | 5679 if (eap->addr_count > 0) |
5680 { | |
5681 wnr = eap->line2; | |
5682 for (wp = firstwin; --wnr > 0; ) | |
5683 { | |
5684 if (wp->w_next == NULL) | |
5685 break; | |
5686 else | |
5687 wp = wp->w_next; | |
5688 } | |
5689 win_goto(wp); | |
5690 } | |
7 | 5691 close_others(TRUE, eap->forceit); |
5692 } | |
5693 | |
5694 static void | |
10492
b2cd5a71f4bb
commit https://github.com/vim/vim/commit/5e1e6d265d26ee2952c4a018a5ff72c950d2d700
Christian Brabandt <cb@256bit.org>
parents:
10490
diff
changeset
|
5695 ex_hide(exarg_T *eap UNUSED) |
7 | 5696 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5697 // ":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
|
5698 if (!eap->skip) |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5699 { |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5700 #ifdef FEAT_GUI |
10383
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5701 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
|
5702 #endif |
10383
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5703 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
|
5704 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
|
5705 else |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5706 { |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5707 int winnr = 0; |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5708 win_T *win; |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5709 |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5710 FOR_ALL_WINDOWS(win) |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5711 { |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5712 winnr++; |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5713 if (winnr == eap->line2) |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5714 break; |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5715 } |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5716 if (win == NULL) |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5717 win = lastwin; |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5718 win_close(win, FALSE); |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5719 } |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5720 } |
7 | 5721 } |
5722 | |
5723 /* | |
5724 * ":stop" and ":suspend": Suspend Vim. | |
5725 */ | |
5726 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5727 ex_stop(exarg_T *eap) |
7 | 5728 { |
5729 /* | |
5730 * Disallow suspending for "rvim". | |
5731 */ | |
10264
c036c0f636d5
commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents:
10240
diff
changeset
|
5732 if (!check_restricted()) |
7 | 5733 { |
5734 if (!eap->forceit) | |
5735 autowrite_all(); | |
5736 windgoto((int)Rows - 1, 0); | |
5737 out_char('\n'); | |
5738 out_flush(); | |
5739 stoptermcap(); | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5740 out_flush(); // needed for SUN to restore xterm buffer |
7 | 5741 #ifdef FEAT_TITLE |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5742 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
|
5743 #endif |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5744 ui_suspend(); // call machine specific function |
7 | 5745 #ifdef FEAT_TITLE |
5746 maketitle(); | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5747 resettitle(); // force updating the title |
7 | 5748 #endif |
5749 starttermcap(); | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5750 scroll_start(); // scroll screen before redrawing |
7 | 5751 redraw_later_clear(); |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5752 shell_resized(); // may have resized window |
7 | 5753 } |
5754 } | |
5755 | |
5756 /* | |
13442
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5757 * ":exit", ":xit" and ":wq": Write file and quite the current window. |
7 | 5758 */ |
5759 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5760 ex_exit(exarg_T *eap) |
7 | 5761 { |
21518
0b448762ebbd
patch 8.2.1309: build failure with tiny version
Bram Moolenaar <Bram@vim.org>
parents:
21516
diff
changeset
|
5762 #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
|
5763 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
|
5764 return; |
21518
0b448762ebbd
patch 8.2.1309: build failure with tiny version
Bram Moolenaar <Bram@vim.org>
parents:
21516
diff
changeset
|
5765 #endif |
7 | 5766 #ifdef FEAT_CMDWIN |
5767 if (cmdwin_type != 0) | |
5768 { | |
5769 cmdwin_result = Ctrl_C; | |
5770 return; | |
5771 } | |
5772 #endif | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5773 // Don't quit while editing the command line. |
633 | 5774 if (text_locked()) |
5775 { | |
5776 text_locked_msg(); | |
631 | 5777 return; |
5778 } | |
13442
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5779 |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5780 if (before_quit_autocmds(curwin, FALSE, eap->forceit)) |
819 | 5781 return; |
7 | 5782 |
5783 /* | |
5784 * if more files or windows we won't exit | |
5785 */ | |
5786 if (check_more(FALSE, eap->forceit) == OK && only_one_window()) | |
5787 exiting = TRUE; | |
5788 if ( ((eap->cmdidx == CMD_wq | |
5789 || curbufIsChanged()) | |
5790 && do_write(eap) == FAIL) | |
5791 || 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
|
5792 || (only_one_window() && check_changed_any(eap->forceit, FALSE))) |
7 | 5793 { |
5794 not_exiting(); | |
5795 } | |
5796 else | |
5797 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5798 if (only_one_window()) // quit last window, exit Vim |
7 | 5799 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
|
5800 not_exiting(); |
7 | 5801 # ifdef FEAT_GUI |
5802 need_mouse_correct = TRUE; | |
5803 # endif | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5804 // 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
|
5805 win_close(curwin, !buf_hide(curwin->w_buffer)); |
7 | 5806 } |
5807 } | |
5808 | |
5809 /* | |
5810 * ":print", ":list", ":number". | |
5811 */ | |
5812 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5813 ex_print(exarg_T *eap) |
7 | 5814 { |
167 | 5815 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
|
5816 emsg(_(e_emptybuf)); |
167 | 5817 else |
5818 { | |
5819 for ( ;!got_int; ui_breakcheck()) | |
5820 { | |
5821 print_line(eap->line1, | |
5822 (eap->cmdidx == CMD_number || eap->cmdidx == CMD_pound | |
5823 || (eap->flags & EXFLAG_NR)), | |
5824 eap->cmdidx == CMD_list || (eap->flags & EXFLAG_LIST)); | |
5825 if (++eap->line1 > eap->line2) | |
5826 break; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5827 out_flush(); // show one line at a time |
167 | 5828 } |
5829 setpcmark(); | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5830 // put cursor at last line |
167 | 5831 curwin->w_cursor.lnum = eap->line2; |
5832 beginline(BL_SOL | BL_FIX); | |
5833 } | |
7 | 5834 |
5835 ex_no_reprint = TRUE; | |
5836 } | |
5837 | |
5838 #ifdef FEAT_BYTEOFF | |
5839 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5840 ex_goto(exarg_T *eap) |
7 | 5841 { |
5842 goto_byte(eap->line2); | |
5843 } | |
5844 #endif | |
5845 | |
5846 /* | |
5847 * ":shell". | |
5848 */ | |
5849 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5850 ex_shell(exarg_T *eap UNUSED) |
7 | 5851 { |
5852 do_shell(NULL, 0); | |
5853 } | |
5854 | |
14428
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5855 #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
|
5856 |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5857 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
|
5858 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
|
5859 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
|
5860 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
|
5861 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
|
5862 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
|
5863 |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5864 static void |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5865 handle_drop_internal(void) |
7 | 5866 { |
5867 exarg_T ea; | |
5868 int save_msg_scroll = msg_scroll; | |
5869 | |
14428
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5870 // 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
|
5871 // 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
|
5872 drop_busy = TRUE; |
7 | 5873 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5874 // 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
|
5875 // 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
|
5876 // 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
|
5877 // 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
|
5878 if (!buf_hide(curbuf) && !drop_split) |
7 | 5879 { |
5880 ++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
|
5881 drop_split = check_changed(curbuf, CCGD_AW); |
7 | 5882 --emsg_off; |
5883 } | |
14428
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5884 if (drop_split) |
7 | 5885 { |
5886 if (win_split(0, 0) == FAIL) | |
5887 return; | |
2583 | 5888 RESET_BINDING(curwin); |
7 | 5889 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5890 // 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
|
5891 // existing one is overwritten. |
7 | 5892 alist_unlink(curwin->w_alist); |
5893 alist_new(); | |
5894 } | |
5895 | |
5896 /* | |
5897 * Set up the new argument list. | |
5898 */ | |
14428
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5899 alist_set(ALIST(curwin), drop_filec, drop_filev, FALSE, NULL, 0); |
7 | 5900 |
5901 /* | |
5902 * Move to the first file. | |
5903 */ | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5904 // 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
|
5905 CLEAR_FIELD(ea); |
7 | 5906 ea.cmd = (char_u *)"next"; |
5907 do_argfile(&ea, 0); | |
5908 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5909 // 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
|
5910 // mode that is not needed here. |
7 | 5911 need_start_insertmode = FALSE; |
5912 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5913 // 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
|
5914 // 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
|
5915 // msg_scroll being set by displaying a message is irrelevant. |
7 | 5916 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
|
5917 |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5918 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
|
5919 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
|
5920 |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5921 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
|
5922 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
|
5923 } |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5924 |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5925 /* |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5926 * 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
|
5927 * :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
|
5928 * 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
|
5929 * 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
|
5930 * 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
|
5931 * |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5932 * 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
|
5933 * 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
|
5934 * list. |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5935 */ |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5936 void |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5937 handle_drop( |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5938 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
|
5939 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
|
5940 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
|
5941 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
|
5942 // list |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5943 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
|
5944 { |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5945 // 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
|
5946 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
|
5947 { |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5948 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
|
5949 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
|
5950 return; |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5951 } |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5952 |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5953 // 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
|
5954 // one. |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5955 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
|
5956 { |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5957 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
|
5958 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
|
5959 } |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5960 |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5961 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
|
5962 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
|
5963 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
|
5964 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
|
5965 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
|
5966 |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5967 // 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
|
5968 // - 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
|
5969 // - 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
|
5970 // - 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
|
5971 // 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
|
5972 // 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
|
5973 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
|
5974 return; |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5975 |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5976 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
|
5977 } |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5978 |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5979 /* |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5980 * 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
|
5981 * 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
|
5982 */ |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5983 void |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5984 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
|
5985 { |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5986 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
|
5987 && !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
|
5988 handle_drop_internal(); |
7 | 5989 } |
5990 #endif | |
5991 | |
5992 /* | |
5993 * ":preserve". | |
5994 */ | |
5995 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5996 ex_preserve(exarg_T *eap UNUSED) |
7 | 5997 { |
164 | 5998 curbuf->b_flags |= BF_PRESERVED; |
7 | 5999 ml_preserve(curbuf, TRUE); |
6000 } | |
6001 | |
6002 /* | |
6003 * ":recover". | |
6004 */ | |
6005 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6006 ex_recover(exarg_T *eap) |
7 | 6007 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6008 // Set recoverymode right away to avoid the ATTENTION prompt. |
7 | 6009 recoverymode = TRUE; |
5464 | 6010 if (!check_changed(curbuf, (p_awa ? CCGD_AW : 0) |
6011 | CCGD_MULTWIN | |
6012 | (eap->forceit ? CCGD_FORCEIT : 0) | |
6013 | CCGD_EXCMD) | |
6014 | |
7 | 6015 && (*eap->arg == NUL |
6016 || 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
|
6017 ml_recover(TRUE); |
7 | 6018 recoverymode = FALSE; |
6019 } | |
6020 | |
6021 /* | |
6022 * Command modifier used in a wrong way. | |
6023 */ | |
6024 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6025 ex_wrongmodifier(exarg_T *eap) |
7 | 6026 { |
21821
0deb6f96a5a3
patch 8.2.1460: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
21789
diff
changeset
|
6027 eap->errmsg = _(e_invalid_command); |
7 | 6028 } |
6029 | |
6030 /* | |
6031 * :sview [+command] file split window with new file, read-only | |
6032 * :split [[+command] file] split window with current or new file | |
6033 * :vsplit [[+command] file] split window vertically with current or new file | |
6034 * :new [[+command] file] split window with no or new file | |
6035 * :vnew [[+command] file] split vertically window with no or new file | |
6036 * :sfind [+command] file split window with file in 'path' | |
675 | 6037 * |
6038 * :tabedit open new Tab page with empty window | |
6039 * :tabedit [+command] file open new Tab page and edit "file" | |
6040 * :tabnew [[+command] file] just like :tabedit | |
6041 * :tabfind [+command] file open new Tab page and find "file" | |
7 | 6042 */ |
6043 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6044 ex_splitview(exarg_T *eap) |
7 | 6045 { |
675 | 6046 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
|
6047 #if defined(FEAT_SEARCHPATH) || defined(FEAT_BROWSE) |
7 | 6048 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
|
6049 #endif |
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
6050 #ifdef FEAT_BROWSE |
7 | 6051 int browse_flag = cmdmod.browse; |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
6052 #endif |
14155
da09e29e59d9
patch 8.1.0095: dialog for ":browse tabnew" says "new window"
Christian Brabandt <cb@256bit.org>
parents:
14059
diff
changeset
|
6053 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
|
6054 || 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
|
6055 || 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
|
6056 |
19271
ebeeb4b4a1fa
patch 8.2.0194: some commands can cause problems in terminal popup
Bram Moolenaar <Bram@vim.org>
parents:
19261
diff
changeset
|
6057 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
|
6058 return; |
da5f5836e90c
patch 8.1.1438: some commands cause trouble in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
6059 |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
6060 #ifdef FEAT_GUI |
7 | 6061 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
|
6062 #endif |
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
6063 |
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
6064 #ifdef FEAT_QUICKFIX |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6065 // 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
|
6066 // quickfix windows. But it's OK when doing ":tab split". |
1661 | 6067 if (bt_quickfix(curbuf) && cmdmod.tab == 0) |
7 | 6068 { |
6069 if (eap->cmdidx == CMD_split) | |
6070 eap->cmdidx = CMD_new; | |
6071 if (eap->cmdidx == CMD_vsplit) | |
6072 eap->cmdidx = CMD_vnew; | |
667 | 6073 } |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
6074 #endif |
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
6075 |
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
6076 #ifdef FEAT_SEARCHPATH |
675 | 6077 if (eap->cmdidx == CMD_sfind || eap->cmdidx == CMD_tabfind) |
7 | 6078 { |
6079 fname = find_file_in_path(eap->arg, (int)STRLEN(eap->arg), | |
6080 FNAME_MESS, TRUE, curbuf->b_ffname); | |
6081 if (fname == NULL) | |
6082 goto theend; | |
6083 eap->arg = fname; | |
6084 } | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
6085 # ifdef FEAT_BROWSE |
7 | 6086 else |
6087 # endif | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
6088 #endif |
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
6089 #ifdef FEAT_BROWSE |
7 | 6090 if (cmdmod.browse |
6091 && eap->cmdidx != CMD_vnew | |
6092 && eap->cmdidx != CMD_new) | |
6093 { | |
461 | 6094 if ( |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
6095 # ifdef FEAT_GUI |
461 | 6096 !gui.in_use && |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
6097 # endif |
461 | 6098 au_has_group((char_u *)"FileExplorer")) |
6099 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6100 // 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
|
6101 // Edit the directory. |
461 | 6102 if (*eap->arg == NUL || !mch_isdir(eap->arg)) |
6103 eap->arg = (char_u *)"."; | |
6104 } | |
6105 else | |
6106 { | |
14155
da09e29e59d9
patch 8.1.0095: dialog for ":browse tabnew" says "new window"
Christian Brabandt <cb@256bit.org>
parents:
14059
diff
changeset
|
6107 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
|
6108 ? _("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
|
6109 : _("Edit File in new window")), |
7 | 6110 eap->arg, NULL, NULL, NULL, curbuf); |
461 | 6111 if (fname == NULL) |
6112 goto theend; | |
6113 eap->arg = fname; | |
6114 } | |
7 | 6115 } |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6116 cmdmod.browse = FALSE; // Don't browse again in do_ecmd(). |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
6117 #endif |
7 | 6118 |
675 | 6119 /* |
6120 * Either open new tab page or split the window. | |
6121 */ | |
14155
da09e29e59d9
patch 8.1.0095: dialog for ":browse tabnew" says "new window"
Christian Brabandt <cb@256bit.org>
parents:
14059
diff
changeset
|
6122 if (use_tab) |
675 | 6123 { |
820 | 6124 if (win_new_tabpage(cmdmod.tab != 0 ? cmdmod.tab |
6125 : eap->addr_count == 0 ? 0 | |
6126 : (int)eap->line2 + 1) != FAIL) | |
675 | 6127 { |
1498 | 6128 do_exedit(eap, old_curwin); |
675 | 6129 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6130 // set the alternate buffer for the window we came from |
675 | 6131 if (curwin != old_curwin |
6132 && win_valid(old_curwin) | |
6133 && old_curwin->w_buffer != curbuf | |
6134 && !cmdmod.keepalt) | |
6135 old_curwin->w_alt_fnum = curbuf->b_fnum; | |
6136 } | |
6137 } | |
6138 else if (win_split(eap->addr_count > 0 ? (int)eap->line2 : 0, | |
7 | 6139 *eap->cmd == 'v' ? WSP_VERT : 0) != FAIL) |
6140 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6141 // 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
|
6142 // doing ":split" without arguments. |
7 | 6143 if (*eap->arg != NUL |
13384
6740c499de13
patch 8.0.1566: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13380
diff
changeset
|
6144 # ifdef FEAT_BROWSE |
7 | 6145 || cmdmod.browse |
13384
6740c499de13
patch 8.0.1566: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13380
diff
changeset
|
6146 # endif |
7 | 6147 ) |
2583 | 6148 RESET_BINDING(curwin); |
7 | 6149 else |
6150 do_check_scrollbind(FALSE); | |
6151 do_exedit(eap, old_curwin); | |
6152 } | |
6153 | |
667 | 6154 # ifdef FEAT_BROWSE |
7 | 6155 cmdmod.browse = browse_flag; |
667 | 6156 # endif |
6157 | |
6158 # if defined(FEAT_SEARCHPATH) || defined(FEAT_BROWSE) | |
7 | 6159 theend: |
6160 vim_free(fname); | |
667 | 6161 # endif |
6162 } | |
6163 | |
6164 /* | |
682 | 6165 * Open a new tab page. |
667 | 6166 */ |
6167 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6168 tabpage_new(void) |
682 | 6169 { |
6170 exarg_T ea; | |
6171 | |
20007
aadd1cae2ff5
patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
6172 CLEAR_FIELD(ea); |
682 | 6173 ea.cmdidx = CMD_tabnew; |
6174 ea.cmd = (char_u *)"tabn"; | |
6175 ea.arg = (char_u *)""; | |
6176 ex_splitview(&ea); | |
6177 } | |
6178 | |
6179 /* | |
6180 * :tabnext command | |
6181 */ | |
6182 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6183 ex_tabnext(exarg_T *eap) |
682 | 6184 { |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6185 int tab_number; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6186 |
17111
af861fccc309
patch 8.1.1555: NOT_IN_POPUP_WINDOW is confusing
Bram Moolenaar <Bram@vim.org>
parents:
17095
diff
changeset
|
6187 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
|
6188 return; |
685 | 6189 switch (eap->cmdidx) |
6190 { | |
6191 case CMD_tabfirst: | |
6192 case CMD_tabrewind: | |
6193 goto_tabpage(1); | |
6194 break; | |
6195 case CMD_tablast: | |
6196 goto_tabpage(9999); | |
6197 break; | |
6198 case CMD_tabprevious: | |
6199 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
|
6200 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
|
6201 { |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6202 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
|
6203 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
|
6204 |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6205 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
|
6206 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
|
6207 || tab_number == 0) |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6208 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6209 // 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
|
6210 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
|
6211 return; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6212 } |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6213 } |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6214 else |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6215 { |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6216 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
|
6217 tab_number = 1; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6218 else |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6219 { |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6220 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
|
6221 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
|
6222 { |
21459
a422bd80b434
patch 8.2.1280: Ex command error cannot contain an argument
Bram Moolenaar <Bram@vim.org>
parents:
21413
diff
changeset
|
6223 eap->errmsg = _(e_invrange); |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6224 return; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6225 } |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6226 } |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6227 } |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6228 goto_tabpage(-tab_number); |
685 | 6229 break; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6230 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
|
6231 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
|
6232 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
|
6233 goto_tabpage(tab_number); |
685 | 6234 break; |
6235 } | |
682 | 6236 } |
6237 | |
6238 /* | |
6239 * :tabmove command | |
6240 */ | |
6241 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6242 ex_tabmove(exarg_T *eap) |
682 | 6243 { |
6775 | 6244 int tab_number; |
3662 | 6245 |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6246 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
|
6247 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
|
6248 tabpage_move(tab_number); |
667 | 6249 } |
6250 | |
6251 /* | |
6252 * :tabs command: List tabs and their contents. | |
6253 */ | |
6254 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6255 ex_tabs(exarg_T *eap UNUSED) |
667 | 6256 { |
6257 tabpage_T *tp; | |
6258 win_T *wp; | |
6259 int tabcount = 1; | |
6260 | |
6261 msg_start(); | |
6262 msg_scroll = TRUE; | |
6263 for (tp = first_tabpage; tp != NULL && !got_int; tp = tp->tp_next) | |
6264 { | |
6265 msg_putchar('\n'); | |
6266 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
|
6267 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
|
6268 out_flush(); // output one line at a time |
667 | 6269 ui_breakcheck(); |
6270 | |
678 | 6271 if (tp == curtab) |
667 | 6272 wp = firstwin; |
6273 else | |
6274 wp = tp->tp_firstwin; | |
6275 for ( ; wp != NULL && !got_int; wp = wp->w_next) | |
6276 { | |
682 | 6277 msg_putchar('\n'); |
6278 msg_putchar(wp == curwin ? '>' : ' '); | |
6279 msg_putchar(' '); | |
672 | 6280 msg_putchar(bufIsChanged(wp->w_buffer) ? '+' : ' '); |
6281 msg_putchar(' '); | |
667 | 6282 if (buf_spname(wp->w_buffer) != NULL) |
3839 | 6283 vim_strncpy(IObuff, buf_spname(wp->w_buffer), IOSIZE - 1); |
667 | 6284 else |
6285 home_replace(wp->w_buffer, wp->w_buffer->b_fname, | |
6286 IObuff, IOSIZE, TRUE); | |
6287 msg_outtrans(IObuff); | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6288 out_flush(); // output one line at a time |
667 | 6289 ui_breakcheck(); |
6290 } | |
6291 } | |
6292 } | |
6293 | |
7 | 6294 /* |
6295 * ":mode": Set screen mode. | |
6296 * If no argument given, just get the screen size and redraw. | |
6297 */ | |
6298 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6299 ex_mode(exarg_T *eap) |
7 | 6300 { |
6301 if (*eap->arg == NUL) | |
6302 shell_resized(); | |
6303 else | |
19131
1fe99999625c
patch 8.2.0125: :mode no longer works for any system
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
6304 emsg(_(e_screenmode)); |
7 | 6305 } |
6306 | |
6307 /* | |
6308 * ":resize". | |
6309 * set, increment or decrement current window height | |
6310 */ | |
6311 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6312 ex_resize(exarg_T *eap) |
7 | 6313 { |
6314 int n; | |
6315 win_T *wp = curwin; | |
6316 | |
6317 if (eap->addr_count > 0) | |
6318 { | |
6319 n = eap->line2; | |
6320 for (wp = firstwin; wp->w_next != NULL && --n > 0; wp = wp->w_next) | |
6321 ; | |
6322 } | |
6323 | |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8577
diff
changeset
|
6324 # ifdef FEAT_GUI |
7 | 6325 need_mouse_correct = TRUE; |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8577
diff
changeset
|
6326 # endif |
7 | 6327 n = atol((char *)eap->arg); |
6328 if (cmdmod.split & WSP_VERT) | |
6329 { | |
6330 if (*eap->arg == '-' || *eap->arg == '+') | |
12515
972ea22c946f
patch 8.0.1136: W_WIDTH() is always the same
Christian Brabandt <cb@256bit.org>
parents:
12513
diff
changeset
|
6331 n += curwin->w_width; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6332 else if (n == 0 && eap->arg[0] == NUL) // default is very wide |
7 | 6333 n = 9999; |
6334 win_setwidth_win((int)n, wp); | |
6335 } | |
6336 else | |
6337 { | |
6338 if (*eap->arg == '-' || *eap->arg == '+') | |
6339 n += curwin->w_height; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6340 else if (n == 0 && eap->arg[0] == NUL) // default is very high |
7 | 6341 n = 9999; |
6342 win_setheight_win((int)n, wp); | |
6343 } | |
6344 } | |
6345 | |
6346 /* | |
6347 * ":find [+command] <file>" command. | |
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_find(exarg_T *eap) |
7 | 6351 { |
6352 #ifdef FEAT_SEARCHPATH | |
6353 char_u *fname; | |
6354 int count; | |
6355 | |
6356 fname = find_file_in_path(eap->arg, (int)STRLEN(eap->arg), FNAME_MESS, | |
6357 TRUE, curbuf->b_ffname); | |
6358 if (eap->addr_count > 0) | |
6359 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6360 // 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
|
6361 // appears several times in the path. |
7 | 6362 count = eap->line2; |
6363 while (fname != NULL && --count > 0) | |
6364 { | |
6365 vim_free(fname); | |
6366 fname = find_file_in_path(NULL, 0, FNAME_MESS, | |
6367 FALSE, curbuf->b_ffname); | |
6368 } | |
6369 } | |
6370 | |
6371 if (fname != NULL) | |
6372 { | |
6373 eap->arg = fname; | |
6374 #endif | |
6375 do_exedit(eap, NULL); | |
6376 #ifdef FEAT_SEARCHPATH | |
6377 vim_free(fname); | |
6378 } | |
6379 #endif | |
6380 } | |
6381 | |
6382 /* | |
167 | 6383 * ":open" simulation: for now just work like ":visual". |
6384 */ | |
6385 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6386 ex_open(exarg_T *eap) |
167 | 6387 { |
6388 regmatch_T regmatch; | |
6389 char_u *p; | |
6390 | |
6391 curwin->w_cursor.lnum = eap->line2; | |
6392 beginline(BL_SOL | BL_FIX); | |
6393 if (*eap->arg == '/') | |
6394 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6395 // ":open /pattern/": put cursor in column found with pattern |
167 | 6396 ++eap->arg; |
19892
5feb426d2ea1
patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19685
diff
changeset
|
6397 p = skip_regexp(eap->arg, '/', p_magic); |
167 | 6398 *p = NUL; |
6399 regmatch.regprog = vim_regcomp(eap->arg, p_magic ? RE_MAGIC : 0); | |
6400 if (regmatch.regprog != NULL) | |
6401 { | |
6402 regmatch.rm_ic = p_ic; | |
6403 p = ml_get_curline(); | |
6404 if (vim_regexec(®match, p, (colnr_T)0)) | |
835 | 6405 curwin->w_cursor.col = (colnr_T)(regmatch.startp[0] - p); |
167 | 6406 else |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
6407 emsg(_(e_nomatch)); |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4803
diff
changeset
|
6408 vim_regfree(regmatch.regprog); |
167 | 6409 } |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6410 // Move to the NUL, ignore any other arguments. |
167 | 6411 eap->arg += STRLEN(eap->arg); |
6412 } | |
6413 check_cursor(); | |
6414 | |
6415 eap->cmdidx = CMD_visual; | |
6416 do_exedit(eap, NULL); | |
6417 } | |
6418 | |
6419 /* | |
6420 * ":edit", ":badd", ":visual". | |
7 | 6421 */ |
6422 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6423 ex_edit(exarg_T *eap) |
7 | 6424 { |
6425 do_exedit(eap, NULL); | |
6426 } | |
6427 | |
6428 /* | |
19195
2ef19eed524a
patch 8.2.0156: various typos in source files and tests
Bram Moolenaar <Bram@vim.org>
parents:
19191
diff
changeset
|
6429 * ":edit <file>" command and alike. |
7 | 6430 */ |
6431 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6432 do_exedit( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6433 exarg_T *eap, |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6434 win_T *old_curwin) // curwin before doing a split or NULL |
7 | 6435 { |
6436 int n; | |
6437 int need_hide; | |
167 | 6438 int exmode_was = exmode_active; |
7 | 6439 |
19271
ebeeb4b4a1fa
patch 8.2.0194: some commands can cause problems in terminal popup
Bram Moolenaar <Bram@vim.org>
parents:
19261
diff
changeset
|
6440 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
|
6441 || 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
|
6442 return; |
7 | 6443 /* |
6444 * ":vi" command ends Ex mode. | |
6445 */ | |
6446 if (exmode_active && (eap->cmdidx == CMD_visual | |
6447 || eap->cmdidx == CMD_view)) | |
6448 { | |
6449 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
|
6450 ex_pressedreturn = FALSE; |
7 | 6451 if (*eap->arg == NUL) |
167 | 6452 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6453 // Special case: ":global/pat/visual\NLvi-commands" |
167 | 6454 if (global_busy) |
6455 { | |
6456 int rd = RedrawingDisabled; | |
6457 int nwr = no_wait_return; | |
6458 int ms = msg_scroll; | |
6459 #ifdef FEAT_GUI | |
6460 int he = hold_gui_events; | |
6461 #endif | |
6462 | |
6463 if (eap->nextcmd != NULL) | |
6464 { | |
6465 stuffReadbuff(eap->nextcmd); | |
6466 eap->nextcmd = NULL; | |
6467 } | |
6468 | |
6469 if (exmode_was != EXMODE_VIM) | |
6470 settmode(TMODE_RAW); | |
6471 RedrawingDisabled = 0; | |
6472 no_wait_return = 0; | |
6473 need_wait_return = FALSE; | |
6474 msg_scroll = 0; | |
6475 #ifdef FEAT_GUI | |
6476 hold_gui_events = 0; | |
6477 #endif | |
6478 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
|
6479 pending_exmode_active = TRUE; |
167 | 6480 |
6481 main_loop(FALSE, TRUE); | |
6482 | |
19433
af9d5585cfbf
patch 8.2.0274: hang with combination of feedkeys(), Ex mode and :global
Bram Moolenaar <Bram@vim.org>
parents:
19415
diff
changeset
|
6483 pending_exmode_active = FALSE; |
167 | 6484 RedrawingDisabled = rd; |
6485 no_wait_return = nwr; | |
6486 msg_scroll = ms; | |
6487 #ifdef FEAT_GUI | |
6488 hold_gui_events = he; | |
6489 #endif | |
6490 } | |
7 | 6491 return; |
167 | 6492 } |
7 | 6493 } |
6494 | |
6495 if ((eap->cmdidx == CMD_new | |
675 | 6496 || eap->cmdidx == CMD_tabnew |
6497 || 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
|
6498 || eap->cmdidx == CMD_vnew) && *eap->arg == NUL) |
7 | 6499 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6500 // ":new" or ":tabnew" without argument: edit an new empty buffer |
7 | 6501 setpcmark(); |
6502 (void)do_ecmd(0, NULL, NULL, eap, ECMD_ONE, | |
1743 | 6503 ECMD_HIDE + (eap->forceit ? ECMD_FORCEIT : 0), |
6504 old_curwin == NULL ? curwin : NULL); | |
7 | 6505 } |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
6506 else if ((eap->cmdidx != CMD_split && eap->cmdidx != CMD_vsplit) |
7 | 6507 || *eap->arg != NUL |
6508 #ifdef FEAT_BROWSE | |
6509 || cmdmod.browse | |
6510 #endif | |
6511 ) | |
6512 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6513 // 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
|
6514 // can bring us here, others are stopped earlier. |
822 | 6515 if (*eap->arg != NUL && curbuf_locked()) |
6516 return; | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
6517 |
7 | 6518 n = readonlymode; |
6519 if (eap->cmdidx == CMD_view || eap->cmdidx == CMD_sview) | |
6520 readonlymode = TRUE; | |
6521 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
|
6522 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
|
6523 // empty buffer |
7 | 6524 setpcmark(); |
6525 if (do_ecmd(0, (eap->cmdidx == CMD_enew ? NULL : eap->arg), | |
6526 NULL, eap, | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6527 // ":edit" goes to first line if Vi compatible |
7 | 6528 (*eap->arg == NUL && eap->do_ecmd_lnum == 0 |
6529 && vim_strchr(p_cpo, CPO_GOTO1) != NULL) | |
6530 ? 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
|
6531 (buf_hide(curbuf) ? ECMD_HIDE : 0) |
7 | 6532 + (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
|
6533 // after a split we can use an existing buffer |
5741 | 6534 + (old_curwin != NULL ? ECMD_OLDBUF : 0) |
7 | 6535 + (eap->cmdidx == CMD_badd ? ECMD_ADDBUF : 0 ) |
1743 | 6536 , old_curwin == NULL ? curwin : NULL) == FAIL) |
7 | 6537 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6538 // Editing the file failed. If the window was split, close it. |
7 | 6539 if (old_curwin != NULL) |
6540 { | |
6541 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
|
6542 if (!need_hide || buf_hide(curbuf)) |
7 | 6543 { |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
6544 #if defined(FEAT_EVAL) |
24 | 6545 cleanup_T cs; |
6546 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6547 // 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
|
6548 // aborting() returns FALSE when closing a window. |
24 | 6549 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
|
6550 #endif |
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
6551 #ifdef FEAT_GUI |
7 | 6552 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
|
6553 #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
|
6554 win_close(curwin, !need_hide && !buf_hide(curbuf)); |
24 | 6555 |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
6556 #if defined(FEAT_EVAL) |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6557 // 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
|
6558 // 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
|
6559 // uncaught exception. |
24 | 6560 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
|
6561 #endif |
7 | 6562 } |
6563 } | |
6564 } | |
6565 else if (readonlymode && curbuf->b_nwindows == 1) | |
6566 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6567 // 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
|
6568 // 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
|
6569 // 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
|
6570 // editing the same buffer. |
7 | 6571 curbuf->b_p_ro = TRUE; |
6572 } | |
6573 readonlymode = n; | |
6574 } | |
6575 else | |
6576 { | |
6577 if (eap->do_ecmd_cmd != NULL) | |
6578 do_cmdline_cmd(eap->do_ecmd_cmd); | |
6579 #ifdef FEAT_TITLE | |
6580 n = curwin->w_arg_idx_invalid; | |
6581 #endif | |
6582 check_arg_idx(curwin); | |
6583 #ifdef FEAT_TITLE | |
6584 if (n != curwin->w_arg_idx_invalid) | |
6585 maketitle(); | |
6586 #endif | |
6587 } | |
6588 | |
6589 /* | |
6590 * if ":split file" worked, set alternate file name in old window to new | |
6591 * file | |
6592 */ | |
6593 if (old_curwin != NULL | |
6594 && *eap->arg != NUL | |
6595 && curwin != old_curwin | |
6596 && win_valid(old_curwin) | |
22 | 6597 && old_curwin->w_buffer != curbuf |
6598 && !cmdmod.keepalt) | |
7 | 6599 old_curwin->w_alt_fnum = curbuf->b_fnum; |
6600 | |
6601 ex_no_reprint = TRUE; | |
6602 } | |
6603 | |
6604 #ifndef FEAT_GUI | |
6605 /* | |
6606 * ":gui" and ":gvim" when there is no GUI. | |
6607 */ | |
6608 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6609 ex_nogui(exarg_T *eap) |
7 | 6610 { |
21459
a422bd80b434
patch 8.2.1280: Ex command error cannot contain an argument
Bram Moolenaar <Bram@vim.org>
parents:
21413
diff
changeset
|
6611 eap->errmsg = _(e_nogvim); |
7 | 6612 } |
6613 #endif | |
6614 | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15866
diff
changeset
|
6615 #if defined(FEAT_GUI_MSWIN) && defined(FEAT_MENU) && defined(FEAT_TEAROFF) |
7 | 6616 static void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6617 ex_tearoff(exarg_T *eap) |
7 | 6618 { |
6619 gui_make_tearoff(eap->arg); | |
6620 } | |
6621 #endif | |
6622 | |
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
|
6623 #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
|
6624 || defined(FEAT_TERM_POPUP_MENU)) && defined(FEAT_MENU) |
7 | 6625 static void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6626 ex_popup(exarg_T *eap) |
7 | 6627 { |
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
|
6628 # 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
|
6629 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
|
6630 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
|
6631 # 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
|
6632 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
|
6633 # 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
|
6634 # 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
|
6635 # 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
|
6636 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
|
6637 # endif |
7 | 6638 } |
6639 #endif | |
6640 | |
6641 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6642 ex_swapname(exarg_T *eap UNUSED) |
7 | 6643 { |
6644 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
|
6645 msg(_("No swap file")); |
7 | 6646 else |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15510
diff
changeset
|
6647 msg((char *)curbuf->b_ml.ml_mfp->mf_fname); |
7 | 6648 } |
6649 | |
6650 /* | |
6651 * ":syncbind" forces all 'scrollbind' windows to have the same relative | |
6652 * offset. | |
6653 * (1998-11-02 16:21:01 R. Edward Ralston <eralston@computer.org>) | |
6654 */ | |
6655 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6656 ex_syncbind(exarg_T *eap UNUSED) |
7 | 6657 { |
6658 win_T *wp; | |
5566 | 6659 win_T *save_curwin = curwin; |
6660 buf_T *save_curbuf = curbuf; | |
7 | 6661 long topline; |
6662 long y; | |
6663 linenr_T old_linenr = curwin->w_cursor.lnum; | |
6664 | |
6665 setpcmark(); | |
6666 | |
6667 /* | |
6668 * determine max topline | |
6669 */ | |
6670 if (curwin->w_p_scb) | |
6671 { | |
6672 topline = curwin->w_topline; | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9538
diff
changeset
|
6673 FOR_ALL_WINDOWS(wp) |
7 | 6674 { |
6675 if (wp->w_p_scb && wp->w_buffer) | |
6676 { | |
15713
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15663
diff
changeset
|
6677 y = wp->w_buffer->b_ml.ml_line_count - get_scrolloff_value(); |
7 | 6678 if (topline > y) |
6679 topline = y; | |
6680 } | |
6681 } | |
6682 if (topline < 1) | |
6683 topline = 1; | |
6684 } | |
6685 else | |
6686 { | |
6687 topline = 1; | |
6688 } | |
6689 | |
6690 | |
6691 /* | |
5566 | 6692 * Set all scrollbind windows to the same topline. |
7 | 6693 */ |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9538
diff
changeset
|
6694 FOR_ALL_WINDOWS(curwin) |
7 | 6695 { |
6696 if (curwin->w_p_scb) | |
6697 { | |
5566 | 6698 curbuf = curwin->w_buffer; |
7 | 6699 y = topline - curwin->w_topline; |
6700 if (y > 0) | |
6701 scrollup(y, TRUE); | |
6702 else | |
6703 scrolldown(-y, TRUE); | |
6704 curwin->w_scbind_pos = topline; | |
6705 redraw_later(VALID); | |
6706 cursor_correct(); | |
6707 curwin->w_redr_status = TRUE; | |
6708 } | |
6709 } | |
5566 | 6710 curwin = save_curwin; |
6711 curbuf = save_curbuf; | |
7 | 6712 if (curwin->w_p_scb) |
6713 { | |
6714 did_syncbind = TRUE; | |
6715 checkpcmark(); | |
6716 if (old_linenr != curwin->w_cursor.lnum) | |
6717 { | |
6718 char_u ctrl_o[2]; | |
6719 | |
6720 ctrl_o[0] = Ctrl_O; | |
6721 ctrl_o[1] = 0; | |
6722 ins_typebuf(ctrl_o, REMAP_NONE, 0, TRUE, FALSE); | |
6723 } | |
6724 } | |
6725 } | |
6726 | |
6727 | |
6728 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6729 ex_read(exarg_T *eap) |
7 | 6730 { |
167 | 6731 int i; |
6732 int empty = (curbuf->b_ml.ml_flags & ML_EMPTY); | |
6733 linenr_T lnum; | |
7 | 6734 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6735 if (eap->usefilter) // :r!cmd |
7 | 6736 do_bang(1, eap, FALSE, FALSE, TRUE); |
6737 else | |
6738 { | |
6739 if (u_save(eap->line2, (linenr_T)(eap->line2 + 1)) == FAIL) | |
6740 return; | |
6741 | |
6742 #ifdef FEAT_BROWSE | |
6743 if (cmdmod.browse) | |
6744 { | |
6745 char_u *browseFile; | |
6746 | |
28 | 6747 browseFile = do_browse(0, (char_u *)_("Append File"), eap->arg, |
7 | 6748 NULL, NULL, NULL, curbuf); |
6749 if (browseFile != NULL) | |
6750 { | |
6751 i = readfile(browseFile, NULL, | |
6752 eap->line2, (linenr_T)0, (linenr_T)MAXLNUM, eap, 0); | |
6753 vim_free(browseFile); | |
6754 } | |
6755 else | |
6756 i = OK; | |
6757 } | |
6758 else | |
6759 #endif | |
6760 if (*eap->arg == NUL) | |
6761 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6762 if (check_fname() == FAIL) // check for no file name |
7 | 6763 return; |
6764 i = readfile(curbuf->b_ffname, curbuf->b_fname, | |
6765 eap->line2, (linenr_T)0, (linenr_T)MAXLNUM, eap, 0); | |
6766 } | |
6767 else | |
6768 { | |
6769 if (vim_strchr(p_cpo, CPO_ALTREAD) != NULL) | |
6770 (void)setaltfname(eap->arg, eap->arg, (linenr_T)1); | |
6771 i = readfile(eap->arg, NULL, | |
6772 eap->line2, (linenr_T)0, (linenr_T)MAXLNUM, eap, 0); | |
6773 | |
6774 } | |
10575
01a5f64a7a20
patch 8.0.0177: BufEnter autocommand not fired for a directory
Christian Brabandt <cb@256bit.org>
parents:
10520
diff
changeset
|
6775 if (i != OK) |
7 | 6776 { |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
6777 #if defined(FEAT_EVAL) |
7 | 6778 if (!aborting()) |
6779 #endif | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
6780 semsg(_(e_notopen), eap->arg); |
7 | 6781 } |
6782 else | |
167 | 6783 { |
6784 if (empty && exmode_active) | |
6785 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6786 // 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
|
6787 // this but vi doesn't. |
167 | 6788 if (eap->line2 == 0) |
6789 lnum = curbuf->b_ml.ml_line_count; | |
6790 else | |
6791 lnum = 1; | |
573 | 6792 if (*ml_get(lnum) == NUL && u_savedel(lnum, 1L) == OK) |
167 | 6793 { |
20599
d571231175b4
patch 8.2.0853: ml_delete() often called with FALSE argument
Bram Moolenaar <Bram@vim.org>
parents:
20575
diff
changeset
|
6794 ml_delete(lnum); |
573 | 6795 if (curwin->w_cursor.lnum > 1 |
6796 && curwin->w_cursor.lnum >= lnum) | |
167 | 6797 --curwin->w_cursor.lnum; |
1929 | 6798 deleted_lines_mark(lnum, 1L); |
167 | 6799 } |
6800 } | |
7 | 6801 redraw_curbuf_later(VALID); |
167 | 6802 } |
7 | 6803 } |
6804 } | |
6805 | |
358 | 6806 static char_u *prev_dir = NULL; |
6807 | |
6808 #if defined(EXITFREE) || defined(PROTO) | |
6809 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6810 free_cd_dir(void) |
358 | 6811 { |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13221
diff
changeset
|
6812 VIM_CLEAR(prev_dir); |
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13221
diff
changeset
|
6813 VIM_CLEAR(globaldir); |
358 | 6814 } |
6815 #endif | |
6816 | |
4704
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
6817 /* |
20711
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
6818 * 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
|
6819 */ |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
6820 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
|
6821 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
|
6822 { |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
6823 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
|
6824 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
|
6825 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
|
6826 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
|
6827 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
|
6828 } |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
6829 |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
6830 /* |
4704
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
6831 * 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
|
6832 * 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
|
6833 * 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
|
6834 */ |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
6835 void |
16576
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6836 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
|
6837 { |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6838 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
|
6839 // 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
|
6840 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
|
6841 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
|
6842 if (scope != CDSCOPE_GLOBAL) |
4704
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
6843 { |
20711
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
6844 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
|
6845 |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
6846 // 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
|
6847 // 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
|
6848 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
|
6849 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
|
6850 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6851 // Remember this local directory for the window. |
4704
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
6852 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
|
6853 { |
16576
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6854 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
|
6855 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
|
6856 else |
8c3a1bd270bb
patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents:
16411
diff
changeset
|
6857 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
|
6858 } |
4704
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
6859 } |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
6860 else |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
6861 { |
20711
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
6862 // 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
|
6863 VIM_CLEAR(globaldir); |
4704
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
6864 } |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
6865 |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
6866 shorten_fnames(TRUE); |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
6867 } |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
6868 |
16576
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6869 /* |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6870 * 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
|
6871 * 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
|
6872 * 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
|
6873 * 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
|
6874 * 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
|
6875 * 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
|
6876 */ |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6877 int |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6878 changedir_func( |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6879 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
|
6880 int forceit, |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6881 cdscope_T scope) |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6882 { |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6883 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
|
6884 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
|
6885 int dir_differs; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6886 int retval = FALSE; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6887 |
19261
a20c66f13a6e
patch 8.2.0189: cd() with NULL argument crashes
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
6888 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
|
6889 return FALSE; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6890 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6891 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
|
6892 { |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6893 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
|
6894 return FALSE; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6895 } |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6896 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6897 // ":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
|
6898 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
|
6899 { |
20711
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
6900 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
|
6901 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
|
6902 { |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6903 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
|
6904 return FALSE; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6905 } |
20711
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
6906 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
|
6907 } |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
6908 |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
6909 // 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
|
6910 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
|
6911 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6912 // 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
|
6913 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
|
6914 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
|
6915 else |
20711
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
6916 pdir = NULL; |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
6917 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
|
6918 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
|
6919 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
|
6920 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
|
6921 else |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
6922 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
|
6923 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6924 #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
|
6925 // 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
|
6926 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
|
6927 { |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6928 // 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
|
6929 # ifdef VMS |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6930 char_u *p; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6931 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6932 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
|
6933 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
|
6934 NameBuff[0] = NUL; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6935 else |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6936 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
|
6937 # else |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6938 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
|
6939 # endif |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6940 new_dir = NameBuff; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6941 } |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6942 #endif |
20711
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
6943 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
|
6944 || 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
|
6945 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
|
6946 emsg(_(e_failed)); |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6947 else |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6948 { |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6949 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
|
6950 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6951 post_chdir(scope); |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6952 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6953 if (dir_differs) |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6954 { |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6955 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
|
6956 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
|
6957 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
|
6958 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
|
6959 else |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6960 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
|
6961 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
|
6962 curbuf); |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6963 } |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6964 retval = TRUE; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6965 } |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6966 vim_free(tofree); |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6967 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6968 return retval; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6969 } |
358 | 6970 |
7 | 6971 /* |
16427
8c3a1bd270bb
patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents:
16411
diff
changeset
|
6972 * ":cd", ":tcd", ":lcd", ":chdir" ":tchdir" and ":lchdir". |
7 | 6973 */ |
1411 | 6974 void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6975 ex_cd(exarg_T *eap) |
7 | 6976 { |
15184
90ab2d3ce11d
patch 8.1.0602: DirChanged is also triggered when directory didn't change
Bram Moolenaar <Bram@vim.org>
parents:
15152
diff
changeset
|
6977 char_u *new_dir; |
7 | 6978 |
6979 new_dir = eap->arg; | |
6980 #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
|
6981 // for non-UNIX ":cd" means: print current directory |
7 | 6982 if (*new_dir == NUL) |
6983 ex_pwd(NULL); | |
6984 else | |
6985 #endif | |
6986 { | |
16576
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6987 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
|
6988 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6989 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
|
6990 scope = CDSCOPE_WINDOW; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6991 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
|
6992 scope = CDSCOPE_TABPAGE; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6993 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6994 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
|
6995 { |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6996 // Echo the new current directory if the command was typed. |
1930 | 6997 if (KeyTyped || p_verbose >= 5) |
7 | 6998 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
|
6999 } |
7 | 7000 } |
7001 } | |
7002 | |
7003 /* | |
7004 * ":pwd". | |
7005 */ | |
7006 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7007 ex_pwd(exarg_T *eap UNUSED) |
7 | 7008 { |
7009 if (mch_dirname(NameBuff, MAXPATHL) == OK) | |
7010 { | |
7011 #ifdef BACKSLASH_IN_FILENAME | |
7012 slash_adjust(NameBuff); | |
7013 #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
|
7014 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
|
7015 { |
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
|
7016 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
|
7017 |
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
|
7018 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
|
7019 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
|
7020 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
|
7021 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
|
7022 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
|
7023 } |
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
|
7024 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
|
7025 msg((char *)NameBuff); |
7 | 7026 } |
7027 else | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7028 emsg(_("E187: Unknown")); |
7 | 7029 } |
7030 | |
7031 /* | |
7032 * ":=". | |
7033 */ | |
7034 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7035 ex_equal(exarg_T *eap) |
7 | 7036 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7037 smsg("%ld", (long)eap->line2); |
167 | 7038 ex_may_print(eap); |
7 | 7039 } |
7040 | |
7041 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7042 ex_sleep(exarg_T *eap) |
7 | 7043 { |
236 | 7044 int n; |
7045 long len; | |
7 | 7046 |
7047 if (cursor_valid()) | |
7048 { | |
7049 n = W_WINROW(curwin) + curwin->w_wrow - msg_scrolled; | |
7050 if (n >= 0) | |
12513
3ca08bf99396
patch 8.0.1135: W_WINCOL() is always the same
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
7051 windgoto((int)n, curwin->w_wincol + curwin->w_wcol); |
7 | 7052 } |
236 | 7053 |
7054 len = eap->line2; | |
7055 switch (*eap->arg) | |
7056 { | |
7057 case 'm': break; | |
7058 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
|
7059 default: semsg(_(e_invarg2), eap->arg); return; |
236 | 7060 } |
7061 do_sleep(len); | |
7 | 7062 } |
7063 | |
7064 /* | |
7065 * Sleep for "msec" milliseconds, but keep checking for a CTRL-C every second. | |
7066 */ | |
7067 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7068 do_sleep(long msec) |
7 | 7069 { |
17712
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
7070 long done = 0; |
8577
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
7071 long wait_now; |
17712
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
7072 # ifdef ELAPSED_FUNC |
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
7073 elapsed_T start_tv; |
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
7074 |
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
7075 // 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
|
7076 // 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
|
7077 ELAPSED_INIT(start_tv); |
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
7078 # endif |
7 | 7079 |
7080 cursor_on(); | |
14860
ac5d0d27aef9
patch 8.1.0442: GUI: cursor not drawn after ":redraw | sleep"
Christian Brabandt <cb@256bit.org>
parents:
14760
diff
changeset
|
7081 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
|
7082 while (!got_int && done < msec) |
8577
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
7083 { |
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
7084 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
|
7085 #ifdef FEAT_TIMERS |
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
7086 { |
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
7087 long due_time = check_due_timer(); |
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
7088 |
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
7089 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
|
7090 wait_now = due_time; |
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
7091 } |
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
7092 #endif |
10240
175b1116f96a
commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents:
10184
diff
changeset
|
7093 #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
|
7094 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
|
7095 wait_now = 20L; |
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17652
diff
changeset
|
7096 #endif |
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17652
diff
changeset
|
7097 #ifdef FEAT_SOUND |
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17652
diff
changeset
|
7098 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
|
7099 wait_now = 20L; |
10240
175b1116f96a
commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents:
10184
diff
changeset
|
7100 #endif |
8577
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
7101 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
|
7102 |
10240
175b1116f96a
commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents:
10184
diff
changeset
|
7103 #ifdef FEAT_JOB_CHANNEL |
175b1116f96a
commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents:
10184
diff
changeset
|
7104 if (has_any_channel()) |
175b1116f96a
commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents:
10184
diff
changeset
|
7105 ui_breakcheck_force(TRUE); |
175b1116f96a
commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents:
10184
diff
changeset
|
7106 else |
175b1116f96a
commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents:
10184
diff
changeset
|
7107 #endif |
175b1116f96a
commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents:
10184
diff
changeset
|
7108 ui_breakcheck(); |
7109
fa95595fbc52
commit https://github.com/vim/vim/commit/93c88e0f6a4a8f7634ed84721daf4af46fc0d5db
Christian Brabandt <cb@256bit.org>
parents:
7105
diff
changeset
|
7109 #ifdef MESSAGE_QUEUE |
17712
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
7110 // 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
|
7111 // 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
|
7112 // 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
|
7113 parse_queued_messages(); |
3151 | 7114 #endif |
17712
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
7115 |
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
7116 # ifdef ELAPSED_FUNC |
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
7117 // actual time passed |
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
7118 done = ELAPSED_FUNC(start_tv); |
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
7119 # else |
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
7120 // 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
|
7121 done += wait_now; |
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
7122 # endif |
7 | 7123 } |
14284
7cd8298c4c04
patch 8.1.0158: GUI: input() fails if CTRL-C was pressed before
Christian Brabandt <cb@256bit.org>
parents:
14266
diff
changeset
|
7124 |
7cd8298c4c04
patch 8.1.0158: GUI: input() fails if CTRL-C was pressed before
Christian Brabandt <cb@256bit.org>
parents:
14266
diff
changeset
|
7125 // 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
|
7126 // 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
|
7127 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
|
7128 (void)vpeekc(); |
7 | 7129 } |
7130 | |
7131 /* | |
7132 * ":winsize" command (obsolete). | |
7133 */ | |
7134 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7135 ex_winsize(exarg_T *eap) |
7 | 7136 { |
7137 int w, h; | |
7138 char_u *arg = eap->arg; | |
7139 char_u *p; | |
7140 | |
7141 w = getdigits(&arg); | |
7142 arg = skipwhite(arg); | |
7143 p = arg; | |
7144 h = getdigits(&arg); | |
7145 if (*p != NUL && *arg == NUL) | |
7146 set_shellsize(w, h, TRUE); | |
7147 else | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7148 emsg(_("E465: :winsize requires two number arguments")); |
7 | 7149 } |
7150 | |
7151 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7152 ex_wincmd(exarg_T *eap) |
7 | 7153 { |
7154 int xchar = NUL; | |
7155 char_u *p; | |
7156 | |
7157 if (*eap->arg == 'g' || *eap->arg == Ctrl_G) | |
7158 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7159 // CTRL-W g and CTRL-W CTRL-G have an extra command character |
7 | 7160 if (eap->arg[1] == NUL) |
7161 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7162 emsg(_(e_invarg)); |
7 | 7163 return; |
7164 } | |
7165 xchar = eap->arg[1]; | |
7166 p = eap->arg + 2; | |
7167 } | |
7168 else | |
7169 p = eap->arg + 1; | |
7170 | |
7171 eap->nextcmd = check_nextcmd(p); | |
7172 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
|
7173 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
|
7174 #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
|
7175 in_vim9script() ? '#' : |
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21335
diff
changeset
|
7176 #endif |
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21335
diff
changeset
|
7177 '"') |
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21335
diff
changeset
|
7178 && eap->nextcmd == NULL) |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7179 emsg(_(e_invarg)); |
2887 | 7180 else if (!eap->skip) |
7 | 7181 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7182 // Pass flags on for ":vertical wincmd ]". |
7 | 7183 postponed_split_flags = cmdmod.split; |
1090 | 7184 postponed_split_tab = cmdmod.tab; |
7 | 7185 do_window(*eap->arg, eap->addr_count > 0 ? eap->line2 : 0L, xchar); |
7186 postponed_split_flags = 0; | |
1090 | 7187 postponed_split_tab = 0; |
7 | 7188 } |
7189 } | |
7190 | |
11 | 7191 #if defined(FEAT_GUI) || defined(UNIX) || defined(VMS) || defined(MSWIN) |
7 | 7192 /* |
7193 * ":winpos". | |
7194 */ | |
7195 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7196 ex_winpos(exarg_T *eap) |
7 | 7197 { |
7198 int x, y; | |
7199 char_u *arg = eap->arg; | |
7200 char_u *p; | |
7201 | |
7202 if (*arg == NUL) | |
7203 { | |
11 | 7204 # 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
|
7205 # 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
|
7206 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
|
7207 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
|
7208 # elif defined(FEAT_GUI) |
7 | 7209 if (gui.in_use && gui_mch_get_winpos(&x, &y) != FAIL) |
11 | 7210 # else |
7211 if (mch_get_winpos(&x, &y) != FAIL) | |
7212 # endif | |
7 | 7213 { |
7214 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
|
7215 msg((char *)IObuff); |
7 | 7216 } |
7217 else | |
7218 # endif | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7219 emsg(_("E188: Obtaining window position not implemented for this platform")); |
7 | 7220 } |
7221 else | |
7222 { | |
7223 x = getdigits(&arg); | |
7224 arg = skipwhite(arg); | |
7225 p = arg; | |
7226 y = getdigits(&arg); | |
7227 if (*p == NUL || *arg != NUL) | |
7228 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7229 emsg(_("E466: :winpos requires two number arguments")); |
7 | 7230 return; |
7231 } | |
7232 # ifdef FEAT_GUI | |
7233 if (gui.in_use) | |
7234 gui_mch_set_winpos(x, y); | |
7235 else if (gui.starting) | |
7236 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7237 // Remember the coordinates for when the window is opened. |
7 | 7238 gui_win_x = x; |
7239 gui_win_y = y; | |
7240 } | |
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
|
7241 # if defined(HAVE_TGETENT) || defined(VIMDLL) |
7 | 7242 else |
7243 # 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
|
7244 # 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
|
7245 # if defined(MSWIN) && (!defined(FEAT_GUI) || defined(VIMDLL)) |
11 | 7246 mch_set_winpos(x, y); |
7 | 7247 # endif |
7248 # ifdef HAVE_TGETENT | |
7249 if (*T_CWP) | |
7250 term_set_winpos(x, y); | |
7251 # endif | |
7252 } | |
7253 } | |
7254 #endif | |
7255 | |
7256 /* | |
7257 * Handle command that work like operators: ":delete", ":yank", ":>" and ":<". | |
7258 */ | |
7259 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7260 ex_operators(exarg_T *eap) |
7 | 7261 { |
7262 oparg_T oa; | |
7263 | |
7264 clear_oparg(&oa); | |
7265 oa.regname = eap->regname; | |
7266 oa.start.lnum = eap->line1; | |
7267 oa.end.lnum = eap->line2; | |
7268 oa.line_count = eap->line2 - eap->line1 + 1; | |
7269 oa.motion_type = MLINE; | |
7270 virtual_op = FALSE; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7271 if (eap->cmdidx != CMD_yank) // position cursor for undo |
7 | 7272 { |
7273 setpcmark(); | |
7274 curwin->w_cursor.lnum = eap->line1; | |
7275 beginline(BL_SOL | BL_FIX); | |
7276 } | |
7277 | |
5498 | 7278 if (VIsual_active) |
7279 end_visual_mode(); | |
7280 | |
7 | 7281 switch (eap->cmdidx) |
7282 { | |
7283 case CMD_delete: | |
7284 oa.op_type = OP_DELETE; | |
7285 op_delete(&oa); | |
7286 break; | |
7287 | |
7288 case CMD_yank: | |
7289 oa.op_type = OP_YANK; | |
7290 (void)op_yank(&oa, FALSE, TRUE); | |
7291 break; | |
7292 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7293 default: // CMD_rshift or CMD_lshift |
4889
25d64a4edc0b
updated for version 7.3.1190
Bram Moolenaar <bram@vim.org>
parents:
4857
diff
changeset
|
7294 if ( |
7 | 7295 #ifdef FEAT_RIGHTLEFT |
4889
25d64a4edc0b
updated for version 7.3.1190
Bram Moolenaar <bram@vim.org>
parents:
4857
diff
changeset
|
7296 (eap->cmdidx == CMD_rshift) ^ curwin->w_p_rl |
25d64a4edc0b
updated for version 7.3.1190
Bram Moolenaar <bram@vim.org>
parents:
4857
diff
changeset
|
7297 #else |
25d64a4edc0b
updated for version 7.3.1190
Bram Moolenaar <bram@vim.org>
parents:
4857
diff
changeset
|
7298 eap->cmdidx == CMD_rshift |
25d64a4edc0b
updated for version 7.3.1190
Bram Moolenaar <bram@vim.org>
parents:
4857
diff
changeset
|
7299 #endif |
25d64a4edc0b
updated for version 7.3.1190
Bram Moolenaar <bram@vim.org>
parents:
4857
diff
changeset
|
7300 ) |
7 | 7301 oa.op_type = OP_RSHIFT; |
7302 else | |
7303 oa.op_type = OP_LSHIFT; | |
7304 op_shift(&oa, FALSE, eap->amount); | |
7305 break; | |
7306 } | |
7307 virtual_op = MAYBE; | |
167 | 7308 ex_may_print(eap); |
7 | 7309 } |
7310 | |
7311 /* | |
7312 * ":put". | |
7313 */ | |
7314 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7315 ex_put(exarg_T *eap) |
7 | 7316 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7317 // ":0put" works like ":1put!". |
7 | 7318 if (eap->line2 == 0) |
7319 { | |
7320 eap->line2 = 1; | |
7321 eap->forceit = TRUE; | |
7322 } | |
7323 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
|
7324 do_put(eap->regname, NULL, eap->forceit ? BACKWARD : FORWARD, 1L, |
167 | 7325 PUT_LINE|PUT_CURSLINE); |
7 | 7326 } |
7327 | |
7328 /* | |
7329 * Handle ":copy" and ":move". | |
7330 */ | |
7331 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7332 ex_copymove(exarg_T *eap) |
7 | 7333 { |
7334 long n; | |
7335 | |
21592
7d721e95dc51
patch 8.2.1346: small build fails
Bram Moolenaar <Bram@vim.org>
parents:
21584
diff
changeset
|
7336 #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
|
7337 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
|
7338 return; |
21592
7d721e95dc51
patch 8.2.1346: small build fails
Bram Moolenaar <Bram@vim.org>
parents:
21584
diff
changeset
|
7339 #endif |
14760
fd69edd2c67e
patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents:
14700
diff
changeset
|
7340 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
|
7341 if (eap->arg == NULL) // error detected |
7 | 7342 { |
7343 eap->nextcmd = NULL; | |
7344 return; | |
7345 } | |
167 | 7346 get_flags(eap); |
7 | 7347 |
7348 /* | |
7349 * move or copy lines from 'eap->line1'-'eap->line2' to below line 'n' | |
7350 */ | |
7351 if (n == MAXLNUM || n < 0 || n > curbuf->b_ml.ml_line_count) | |
7352 { | |
17650
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
7353 emsg(_(e_invrange)); |
7 | 7354 return; |
7355 } | |
7356 | |
7357 if (eap->cmdidx == CMD_move) | |
7358 { | |
7359 if (do_move(eap->line1, eap->line2, n) == FAIL) | |
7360 return; | |
7361 } | |
7362 else | |
7363 ex_copy(eap->line1, eap->line2, n); | |
7364 u_clearline(); | |
7365 beginline(BL_SOL | BL_FIX); | |
167 | 7366 ex_may_print(eap); |
7367 } | |
7368 | |
7369 /* | |
7370 * Print the current line if flags were given to the Ex command. | |
7371 */ | |
5776 | 7372 void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7373 ex_may_print(exarg_T *eap) |
167 | 7374 { |
7375 if (eap->flags != 0) | |
7376 { | |
7377 print_line(curwin->w_cursor.lnum, (eap->flags & EXFLAG_NR), | |
7378 (eap->flags & EXFLAG_LIST)); | |
7379 ex_no_reprint = TRUE; | |
7380 } | |
7 | 7381 } |
7382 | |
7383 /* | |
7384 * ":smagic" and ":snomagic". | |
7385 */ | |
7386 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7387 ex_submagic(exarg_T *eap) |
7 | 7388 { |
7389 int magic_save = p_magic; | |
7390 | |
7391 p_magic = (eap->cmdidx == CMD_smagic); | |
21773
2f2e528c5782
patch 8.2.1436: function implementing :substitute has unexpected name
Bram Moolenaar <Bram@vim.org>
parents:
21727
diff
changeset
|
7392 ex_substitute(eap); |
7 | 7393 p_magic = magic_save; |
7394 } | |
7395 | |
7396 /* | |
7397 * ":join". | |
7398 */ | |
7399 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7400 ex_join(exarg_T *eap) |
7 | 7401 { |
7402 curwin->w_cursor.lnum = eap->line1; | |
7403 if (eap->line1 == eap->line2) | |
7404 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7405 if (eap->addr_count >= 2) // :2,2join does nothing |
7 | 7406 return; |
7407 if (eap->line2 == curbuf->b_ml.ml_line_count) | |
7408 { | |
7409 beep_flush(); | |
7410 return; | |
7411 } | |
7412 ++eap->line2; | |
7413 } | |
5848 | 7414 (void)do_join(eap->line2 - eap->line1 + 1, !eap->forceit, TRUE, TRUE, TRUE); |
7 | 7415 beginline(BL_WHITE | BL_FIX); |
167 | 7416 ex_may_print(eap); |
7 | 7417 } |
7418 | |
7419 /* | |
7420 * ":[addr]@r" or ":[addr]*r": execute register | |
7421 */ | |
7422 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7423 ex_at(exarg_T *eap) |
7 | 7424 { |
7425 int c; | |
1973 | 7426 int prev_len = typebuf.tb_len; |
7 | 7427 |
7428 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
|
7429 check_cursor_col(); |
7 | 7430 |
7431 #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
|
7432 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
|
7433 #endif |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7434 |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7435 // get the register name. No name means to use the previous one |
7 | 7436 c = *eap->arg; |
7437 if (c == NUL || (c == '*' && *eap->cmd == '*')) | |
7438 c = '@'; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7439 // Put the register in the typeahead buffer with the "silent" flag. |
1034 | 7440 if (do_execreg(c, TRUE, vim_strchr(p_cpo, CPO_EXECBUF) != NULL, TRUE) |
7441 == FAIL) | |
167 | 7442 { |
7 | 7443 beep_flush(); |
167 | 7444 } |
7 | 7445 else |
7446 { | |
7447 int save_efr = exec_from_reg; | |
7448 | |
7449 exec_from_reg = TRUE; | |
7450 | |
7451 /* | |
7452 * Execute from the typeahead buffer. | |
1973 | 7453 * Continue until the stuff buffer is empty and all added characters |
7454 * have been consumed. | |
7 | 7455 */ |
1973 | 7456 while (!stuff_empty() || typebuf.tb_len > prev_len) |
7 | 7457 (void)do_cmdline(NULL, getexline, NULL, DOCMD_NOWAIT|DOCMD_VERBOSE); |
7458 | |
7459 exec_from_reg = save_efr; | |
7460 } | |
7461 } | |
7462 | |
7463 /* | |
7464 * ":!". | |
7465 */ | |
7466 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7467 ex_bang(exarg_T *eap) |
7 | 7468 { |
7469 do_bang(eap->addr_count, eap, eap->forceit, TRUE, TRUE); | |
7470 } | |
7471 | |
7472 /* | |
7473 * ":undo". | |
7474 */ | |
7475 static void | |
8368
db2a07b710ed
commit https://github.com/vim/vim/commit/f1d2501ebe33e148886c2914acd33140e20ee222
Christian Brabandt <cb@256bit.org>
parents:
8281
diff
changeset
|
7476 ex_undo(exarg_T *eap) |
7 | 7477 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7478 if (eap->addr_count == 1) // :undo 123 |
2281
e41433ea71df
Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents:
2276
diff
changeset
|
7479 undo_time(eap->line2, FALSE, FALSE, TRUE); |
771 | 7480 else |
7481 u_undo(1); | |
7 | 7482 } |
7483 | |
2214
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
7484 #ifdef FEAT_PERSISTENT_UNDO |
2340
99c1eba60b2d
Make automatic prototype generation work with more interfaces.
Bram Moolenaar <bram@vim.org>
parents:
2333
diff
changeset
|
7485 static void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7486 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
|
7487 { |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
7488 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
|
7489 |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
7490 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
|
7491 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
|
7492 } |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
7493 |
2340
99c1eba60b2d
Make automatic prototype generation work with more interfaces.
Bram Moolenaar <bram@vim.org>
parents:
2333
diff
changeset
|
7494 static void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7495 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
|
7496 { |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
7497 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
|
7498 |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
7499 u_compute_hash(hash); |
2238
3d0a7beb0d75
Made reading/writing undo info a bit more robust.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
7500 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
|
7501 } |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
7502 #endif |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
7503 |
7 | 7504 /* |
7505 * ":redo". | |
7506 */ | |
7507 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7508 ex_redo(exarg_T *eap UNUSED) |
7 | 7509 { |
7510 u_redo(1); | |
7511 } | |
7512 | |
7513 /* | |
756 | 7514 * ":earlier" and ":later". |
7515 */ | |
7516 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7517 ex_later(exarg_T *eap) |
756 | 7518 { |
7519 long count = 0; | |
7520 int sec = FALSE; | |
2281
e41433ea71df
Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents:
2276
diff
changeset
|
7521 int file = FALSE; |
756 | 7522 char_u *p = eap->arg; |
7523 | |
7524 if (*p == NUL) | |
7525 count = 1; | |
7526 else if (isdigit(*p)) | |
7527 { | |
7528 count = getdigits(&p); | |
7529 switch (*p) | |
7530 { | |
7531 case 's': ++p; sec = TRUE; break; | |
7532 case 'm': ++p; sec = TRUE; count *= 60; break; | |
7533 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
|
7534 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
|
7535 case 'f': ++p; file = TRUE; break; |
756 | 7536 } |
7537 } | |
7538 | |
7539 if (*p != NUL) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7540 semsg(_(e_invarg2), eap->arg); |
756 | 7541 else |
2281
e41433ea71df
Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents:
2276
diff
changeset
|
7542 undo_time(eap->cmdidx == CMD_earlier ? -count : count, |
e41433ea71df
Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents:
2276
diff
changeset
|
7543 sec, file, FALSE); |
756 | 7544 } |
7545 | |
7546 /* | |
7 | 7547 * ":redir": start/stop redirection. |
7548 */ | |
7549 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7550 ex_redir(exarg_T *eap) |
7 | 7551 { |
7552 char *mode; | |
7553 char_u *fname; | |
122 | 7554 char_u *arg = eap->arg; |
7 | 7555 |
9440
73c0d07cc15e
commit https://github.com/vim/vim/commit/ba768495c2e6bae74e49d22d489fbf211ecad55e
Christian Brabandt <cb@256bit.org>
parents:
9438
diff
changeset
|
7556 #ifdef FEAT_EVAL |
9454
9da0cb39cbee
commit https://github.com/vim/vim/commit/79815f1ec77406f2f21a618c053e5793b597db7a
Christian Brabandt <cb@256bit.org>
parents:
9440
diff
changeset
|
7557 if (redir_execute) |
9da0cb39cbee
commit https://github.com/vim/vim/commit/79815f1ec77406f2f21a618c053e5793b597db7a
Christian Brabandt <cb@256bit.org>
parents:
9440
diff
changeset
|
7558 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7559 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
|
7560 return; |
7897b1e4f3e7
commit https://github.com/vim/vim/commit/245a7cb6d33e556415c9fcaa874b784a6d8f0ef3
Christian Brabandt <cb@256bit.org>
parents:
9432
diff
changeset
|
7561 } |
9440
73c0d07cc15e
commit https://github.com/vim/vim/commit/ba768495c2e6bae74e49d22d489fbf211ecad55e
Christian Brabandt <cb@256bit.org>
parents:
9438
diff
changeset
|
7562 #endif |
9438
7897b1e4f3e7
commit https://github.com/vim/vim/commit/245a7cb6d33e556415c9fcaa874b784a6d8f0ef3
Christian Brabandt <cb@256bit.org>
parents:
9432
diff
changeset
|
7563 |
7 | 7564 if (STRICMP(eap->arg, "END") == 0) |
7565 close_redir(); | |
7566 else | |
7567 { | |
122 | 7568 if (*arg == '>') |
7569 { | |
7570 ++arg; | |
7571 if (*arg == '>') | |
7572 { | |
7573 ++arg; | |
7 | 7574 mode = "a"; |
7575 } | |
7576 else | |
7577 mode = "w"; | |
122 | 7578 arg = skipwhite(arg); |
7 | 7579 |
7580 close_redir(); | |
7581 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7582 // Expand environment variables and "~/". |
122 | 7583 fname = expand_env_save(arg); |
7 | 7584 if (fname == NULL) |
7585 return; | |
7586 #ifdef FEAT_BROWSE | |
7587 if (cmdmod.browse) | |
7588 { | |
7589 char_u *browseFile; | |
7590 | |
28 | 7591 browseFile = do_browse(BROWSE_SAVE, |
7592 (char_u *)_("Save Redirection"), | |
13802
378f9f8e6d8f
patch 8.0.1773: dialog messages are not translated
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
7593 fname, NULL, NULL, |
378f9f8e6d8f
patch 8.0.1773: dialog messages are not translated
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
7594 (char_u *)_(BROWSE_FILTER_ALL_FILES), curbuf); |
7 | 7595 if (browseFile == NULL) |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7596 return; // operation cancelled |
7 | 7597 vim_free(fname); |
7598 fname = browseFile; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7599 eap->forceit = TRUE; // since dialog already asked |
7 | 7600 } |
7601 #endif | |
7602 | |
7603 redir_fd = open_exfile(fname, eap->forceit, mode); | |
7604 vim_free(fname); | |
7605 } | |
7606 #ifdef FEAT_EVAL | |
122 | 7607 else if (*arg == '@') |
7 | 7608 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7609 // redirect to a register a-z (resp. A-Z for appending) |
7 | 7610 close_redir(); |
122 | 7611 ++arg; |
7612 if (ASCII_ISALPHA(*arg) | |
7 | 7613 # ifdef FEAT_CLIPBOARD |
122 | 7614 || *arg == '*' |
1038 | 7615 || *arg == '+' |
7 | 7616 # endif |
122 | 7617 || *arg == '"') |
7618 { | |
7619 redir_reg = *arg++; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7620 if (*arg == '>' && arg[1] == '>') // append |
268 | 7621 arg += 2; |
1427 | 7622 else |
7 | 7623 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7624 // Can use both "@a" and "@a>". |
296 | 7625 if (*arg == '>') |
7626 arg++; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7627 // 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
|
7628 // command is valid. |
1427 | 7629 if (*arg == NUL && !isupper(redir_reg)) |
7630 write_reg_contents(redir_reg, (char_u *)"", -1, FALSE); | |
7 | 7631 } |
167 | 7632 } |
7633 if (*arg != NUL) | |
7634 { | |
268 | 7635 redir_reg = 0; |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7636 semsg(_(e_invarg2), eap->arg); |
167 | 7637 } |
7638 } | |
7639 else if (*arg == '=' && arg[1] == '>') | |
7640 { | |
7641 int append; | |
7642 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7643 // redirect to a variable |
167 | 7644 close_redir(); |
7645 arg += 2; | |
7646 | |
7647 if (*arg == '>') | |
7648 { | |
7649 ++arg; | |
7650 append = TRUE; | |
7 | 7651 } |
7652 else | |
167 | 7653 append = FALSE; |
7654 | |
7655 if (var_redir_start(skipwhite(arg), append) == OK) | |
7656 redir_vname = 1; | |
7 | 7657 } |
7658 #endif | |
7659 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7660 // TODO: redirect to a buffer |
7 | 7661 |
7662 else | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7663 semsg(_(e_invarg2), eap->arg); |
7 | 7664 } |
972 | 7665 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7666 // 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
|
7667 // that indirectly invokes a command to catch its output. |
972 | 7668 if (redir_fd != NULL |
7669 #ifdef FEAT_EVAL | |
7670 || redir_reg || redir_vname | |
7671 #endif | |
7672 ) | |
7673 redir_off = FALSE; | |
7 | 7674 } |
7675 | |
7676 /* | |
7677 * ":redraw": force redraw | |
7678 */ | |
7864
6b0891de44a9
commit https://github.com/vim/vim/commit/fb1f62691eae7c79a28b3b17a60e72ce198c71a2
Christian Brabandt <cb@256bit.org>
parents:
7850
diff
changeset
|
7679 void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7680 ex_redraw(exarg_T *eap) |
7 | 7681 { |
7682 int r = RedrawingDisabled; | |
7683 int p = p_lz; | |
7684 | |
7685 RedrawingDisabled = 0; | |
7686 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
|
7687 validate_cursor(); |
7 | 7688 update_topline(); |
5735 | 7689 update_screen(eap->forceit ? CLEAR : VIsual_active ? INVERTED : 0); |
7 | 7690 #ifdef FEAT_TITLE |
7691 if (need_maketitle) | |
7692 maketitle(); | |
7693 #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
|
7694 #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
|
7695 # 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
|
7696 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
|
7697 # 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
|
7698 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
|
7699 #endif |
7 | 7700 RedrawingDisabled = r; |
7701 p_lz = p; | |
7702 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7703 // Reset msg_didout, so that a message that's there is overwritten. |
7 | 7704 msg_didout = FALSE; |
7705 msg_col = 0; | |
7706 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7707 // 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
|
7708 need_wait_return = FALSE; |
1b89e3f916c5
updated for version 7.4a.025
Bram Moolenaar <bram@vim.org>
parents:
4928
diff
changeset
|
7709 |
7 | 7710 out_flush(); |
7711 } | |
7712 | |
7713 /* | |
7714 * ":redrawstatus": force redraw of status line(s) | |
7715 */ | |
7716 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7717 ex_redrawstatus(exarg_T *eap UNUSED) |
7 | 7718 { |
7719 int r = RedrawingDisabled; | |
7720 int p = p_lz; | |
7721 | |
7722 RedrawingDisabled = 0; | |
7723 p_lz = FALSE; | |
7724 if (eap->forceit) | |
7725 status_redraw_all(); | |
7726 else | |
7727 status_redraw_curbuf(); | |
5735 | 7728 update_screen(VIsual_active ? INVERTED : 0); |
7 | 7729 RedrawingDisabled = r; |
7730 p_lz = p; | |
7731 out_flush(); | |
7732 } | |
7733 | |
15396
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7734 /* |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7735 * ":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
|
7736 */ |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7737 static void |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7738 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
|
7739 { |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7740 int r = RedrawingDisabled; |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7741 int p = p_lz; |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7742 |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7743 RedrawingDisabled = 0; |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7744 p_lz = FALSE; |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7745 |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7746 draw_tabline(); |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7747 |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7748 RedrawingDisabled = r; |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7749 p_lz = p; |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7750 out_flush(); |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7751 } |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7752 |
7 | 7753 static void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7754 close_redir(void) |
7 | 7755 { |
7756 if (redir_fd != NULL) | |
7757 { | |
7758 fclose(redir_fd); | |
7759 redir_fd = NULL; | |
7760 } | |
7761 #ifdef FEAT_EVAL | |
7762 redir_reg = 0; | |
167 | 7763 if (redir_vname) |
7764 { | |
7765 var_redir_stop(); | |
7766 redir_vname = 0; | |
7767 } | |
7 | 7768 #endif |
7769 } | |
7770 | |
17539
554240b9574b
patch 8.1.1767: FEAT_SESSION defined separately
Bram Moolenaar <Bram@vim.org>
parents:
17536
diff
changeset
|
7771 #if (defined(FEAT_SESSION) || defined(FEAT_EVAL)) || defined(PROTO) |
167 | 7772 int |
18139
59bc3cd42cf5
patch 8.1.2064: MS-Windows: compiler warnings for unused arguments
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
7773 vim_mkdir_emsg(char_u *name, int prot UNUSED) |
167 | 7774 { |
7775 if (vim_mkdir(name, prot) != 0) | |
7776 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7777 semsg(_("E739: Cannot create directory: %s"), name); |
167 | 7778 return FAIL; |
7779 } | |
7780 return OK; | |
7781 } | |
7782 #endif | |
7783 | |
7 | 7784 /* |
7785 * Open a file for writing for an Ex command, with some checks. | |
7786 * Return file descriptor, or NULL on failure. | |
7787 */ | |
7788 FILE * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7789 open_exfile( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7790 char_u *fname, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7791 int forceit, |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7792 char *mode) // "w" for create new file or "a" for append |
7 | 7793 { |
7794 FILE *fd; | |
7795 | |
7796 #ifdef UNIX | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7797 // with Unix it is possible to open a directory |
7 | 7798 if (mch_isdir(fname)) |
7799 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7800 semsg(_(e_isadir2), fname); |
7 | 7801 return NULL; |
7802 } | |
7803 #endif | |
7804 if (!forceit && *mode != 'a' && vim_fexists(fname)) | |
7805 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7806 semsg(_("E189: \"%s\" exists (add ! to override)"), fname); |
7 | 7807 return NULL; |
7808 } | |
7809 | |
7810 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
|
7811 semsg(_("E190: Cannot open \"%s\" for writing"), fname); |
7 | 7812 |
7813 return fd; | |
7814 } | |
7815 | |
7816 /* | |
7817 * ":mark" and ":k". | |
7818 */ | |
7819 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7820 ex_mark(exarg_T *eap) |
7 | 7821 { |
7822 pos_T pos; | |
7823 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7824 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
|
7825 emsg(_(e_argreq)); |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7826 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
|
7827 semsg(_(e_trailing_arg), eap->arg); |
7 | 7828 else |
7829 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7830 pos = curwin->w_cursor; // save curwin->w_cursor |
7 | 7831 curwin->w_cursor.lnum = eap->line2; |
7832 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
|
7833 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
|
7834 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
|
7835 curwin->w_cursor = pos; // restore curwin->w_cursor |
7 | 7836 } |
7837 } | |
7838 | |
7839 /* | |
7840 * Update w_topline, w_leftcol and the cursor position. | |
7841 */ | |
7842 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7843 update_topline_cursor(void) |
7 | 7844 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7845 check_cursor(); // put cursor on valid line |
7 | 7846 update_topline(); |
7847 if (!curwin->w_p_wrap) | |
7848 validate_cursor(); | |
7849 update_curswant(); | |
7850 } | |
7851 | |
7852 /* | |
12521
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7853 * 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
|
7854 * 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
|
7855 */ |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7856 int |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7857 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
|
7858 { |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7859 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
|
7860 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
|
7861 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
|
7862 sst->save_State = State; |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7863 sst->save_insertmode = p_im; |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7864 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
|
7865 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
|
7866 sst->save_reg_executing = reg_executing; |
12521
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7867 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7868 msg_scroll = FALSE; // no msg scrolling in Normal mode |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7869 restart_edit = 0; // don't go to Insert mode |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7870 p_im = FALSE; // don't use 'insertmode' |
12521
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7871 |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7872 /* |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7873 * 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
|
7874 * 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
|
7875 * ends with half a command. |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7876 */ |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7877 save_typeahead(&sst->tabuf); |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7878 return sst->tabuf.typebuf_valid; |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7879 } |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7880 |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7881 void |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7882 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
|
7883 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7884 // Restore the previous typeahead. |
12521
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7885 restore_typeahead(&sst->tabuf); |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7886 |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7887 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
|
7888 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
|
7889 p_im = sst->save_insertmode; |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7890 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
|
7891 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
|
7892 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
|
7893 msg_didout |= sst->save_msg_didout; // don't reset msg_didout now |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7894 |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7895 // 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
|
7896 // '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
|
7897 State = sst->save_State; |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7898 #ifdef CURSOR_SHAPE |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7899 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
|
7900 #endif |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7901 } |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7902 |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7903 /* |
7 | 7904 * ":normal[!] {commands}": Execute normal mode commands. |
7905 */ | |
7840
28f569c7dab9
commit https://github.com/vim/vim/commit/20fb9f346497daca4d19402fdfa5de7958642477
Christian Brabandt <cb@256bit.org>
parents:
7819
diff
changeset
|
7906 void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7907 ex_normal(exarg_T *eap) |
7 | 7908 { |
12521
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7909 save_state_T save_state; |
7 | 7910 char_u *arg = NULL; |
7911 int l; | |
7912 char_u *p; | |
7913 | |
856 | 7914 if (ex_normal_lock > 0) |
7915 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7916 emsg(_(e_secure)); |
856 | 7917 return; |
7918 } | |
7 | 7919 if (ex_normal_busy >= p_mmd) |
7920 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7921 emsg(_("E192: Recursive use of :normal too deep")); |
7 | 7922 return; |
7923 } | |
7924 | |
7925 /* | |
7926 * vgetc() expects a CSI and K_SPECIAL to have been escaped. Don't do | |
7927 * this for the K_SPECIAL leading byte, otherwise special keys will not | |
7928 * work. | |
7929 */ | |
7930 if (has_mbyte) | |
7931 { | |
7932 int len = 0; | |
7933 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7934 // Count the number of characters to be escaped. |
7 | 7935 for (p = eap->arg; *p != NUL; ++p) |
7936 { | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
7937 #ifdef FEAT_GUI |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7938 if (*p == CSI) // leadbyte CSI |
7 | 7939 len += 2; |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
7940 #endif |
474 | 7941 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
|
7942 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
|
7943 #ifdef FEAT_GUI |
7 | 7944 || *p == CSI |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
7945 #endif |
7 | 7946 ) |
7947 len += 2; | |
7948 } | |
7949 if (len > 0) | |
7950 { | |
16764
ef00b6bc186b
patch 8.1.1384: using "int" for alloc() often results in compiler warnings
Bram Moolenaar <Bram@vim.org>
parents:
16738
diff
changeset
|
7951 arg = alloc(STRLEN(eap->arg) + len + 1); |
7 | 7952 if (arg != NULL) |
7953 { | |
7954 len = 0; | |
7955 for (p = eap->arg; *p != NUL; ++p) | |
7956 { | |
7957 arg[len++] = *p; | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
7958 #ifdef FEAT_GUI |
7 | 7959 if (*p == CSI) |
7960 { | |
7961 arg[len++] = KS_EXTRA; | |
7962 arg[len++] = (int)KE_CSI; | |
7963 } | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
7964 #endif |
474 | 7965 for (l = (*mb_ptr2len)(p) - 1; l > 0; --l) |
7 | 7966 { |
7967 arg[len++] = *++p; | |
7968 if (*p == K_SPECIAL) | |
7969 { | |
7970 arg[len++] = KS_SPECIAL; | |
7971 arg[len++] = KE_FILLER; | |
7972 } | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
7973 #ifdef FEAT_GUI |
7 | 7974 else if (*p == CSI) |
7975 { | |
7976 arg[len++] = KS_EXTRA; | |
7977 arg[len++] = (int)KE_CSI; | |
7978 } | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
7979 #endif |
7 | 7980 } |
7981 arg[len] = NUL; | |
7982 } | |
7983 } | |
7984 } | |
7985 } | |
7986 | |
12521
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7987 ++ex_normal_busy; |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7988 if (save_current_state(&save_state)) |
7 | 7989 { |
7990 /* | |
7991 * Repeat the :normal command for each line in the range. When no | |
7992 * range given, execute it just once, without positioning the cursor | |
7993 * first. | |
7994 */ | |
7995 do | |
7996 { | |
7997 if (eap->addr_count != 0) | |
7998 { | |
7999 curwin->w_cursor.lnum = eap->line1++; | |
8000 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
|
8001 check_cursor_moved(curwin); |
7 | 8002 } |
8003 | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
8004 exec_normal_cmd(arg != NULL |
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
8005 ? arg |
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
8006 : eap->arg, eap->forceit ? REMAP_NONE : REMAP_YES, FALSE); |
7 | 8007 } |
8008 while (eap->addr_count > 0 && eap->line1 <= eap->line2 && !got_int); | |
8009 } | |
8010 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8011 // Might not return to the main loop when in an event handler. |
7 | 8012 update_topline_cursor(); |
8013 | |
12521
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8014 restore_current_state(&save_state); |
7 | 8015 --ex_normal_busy; |
6322 | 8016 setmouse(); |
8017 #ifdef CURSOR_SHAPE | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8018 ui_cursor_shape(); // may show different cursor shape |
6322 | 8019 #endif |
8020 | |
7 | 8021 vim_free(arg); |
8022 } | |
8023 | |
8024 /* | |
598 | 8025 * ":startinsert", ":startreplace" and ":startgreplace" |
7 | 8026 */ |
8027 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8028 ex_startinsert(exarg_T *eap) |
7 | 8029 { |
98 | 8030 if (eap->forceit) |
8031 { | |
17984
2ea47dee7ddd
patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
8032 // 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
|
8033 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
|
8034 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
|
8035 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
|
8036 } |
20097
165ec447ca77
patch 8.2.0604: :startinsert in a terminal window used later
Bram Moolenaar <Bram@vim.org>
parents:
20079
diff
changeset
|
8037 #ifdef FEAT_TERMINAL |
165ec447ca77
patch 8.2.0604: :startinsert in a terminal window used later
Bram Moolenaar <Bram@vim.org>
parents:
20079
diff
changeset
|
8038 // 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
|
8039 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
|
8040 return; |
165ec447ca77
patch 8.2.0604: :startinsert in a terminal window used later
Bram Moolenaar <Bram@vim.org>
parents:
20079
diff
changeset
|
8041 #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
|
8042 |
2ea47dee7ddd
patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
8043 // 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
|
8044 // expression register that invokes a function can do this. |
89 | 8045 if (State & INSERT) |
8046 return; | |
8047 | |
598 | 8048 if (eap->cmdidx == CMD_startinsert) |
8049 restart_edit = 'a'; | |
8050 else if (eap->cmdidx == CMD_startreplace) | |
8051 restart_edit = 'R'; | |
7 | 8052 else |
598 | 8053 restart_edit = 'V'; |
8054 | |
8055 if (!eap->forceit) | |
7 | 8056 { |
14 | 8057 if (eap->cmdidx == CMD_startinsert) |
8058 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
|
8059 curwin->w_curswant = 0; // avoid MAXCOL |
7 | 8060 } |
8061 } | |
8062 | |
8063 /* | |
8064 * ":stopinsert" | |
8065 */ | |
8066 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8067 ex_stopinsert(exarg_T *eap UNUSED) |
7 | 8068 { |
8069 restart_edit = 0; | |
8070 stop_insert_mode = TRUE; | |
8817
b7eb7bbd71d0
commit https://github.com/vim/vim/commit/fd773e9e88add7d1ffef890fb9f3a00d613b4326
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
8071 clearmode(); |
7 | 8072 } |
7850
10f17a228661
commit https://github.com/vim/vim/commit/e2c3810c2ae290bbc2cba18eb47cc2d44e4b9797
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
8073 |
36 | 8074 /* |
8075 * Execute normal mode command "cmd". | |
8076 * "remap" can be REMAP_NONE or REMAP_YES. | |
8077 */ | |
8078 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8079 exec_normal_cmd(char_u *cmd, int remap, int silent) |
36 | 8080 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8081 // 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
|
8082 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
|
8083 exec_normal(FALSE, FALSE, FALSE); |
7703
39251e981d1f
commit https://github.com/vim/vim/commit/25281634cda03ce302aaf9f906a9520b5f81f91e
Christian Brabandt <cb@256bit.org>
parents:
7549
diff
changeset
|
8084 } |
7850
10f17a228661
commit https://github.com/vim/vim/commit/e2c3810c2ae290bbc2cba18eb47cc2d44e4b9797
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
8085 |
7703
39251e981d1f
commit https://github.com/vim/vim/commit/25281634cda03ce302aaf9f906a9520b5f81f91e
Christian Brabandt <cb@256bit.org>
parents:
7549
diff
changeset
|
8086 /* |
39251e981d1f
commit https://github.com/vim/vim/commit/25281634cda03ce302aaf9f906a9520b5f81f91e
Christian Brabandt <cb@256bit.org>
parents:
7549
diff
changeset
|
8087 * 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
|
8088 * 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
|
8089 */ |
39251e981d1f
commit https://github.com/vim/vim/commit/25281634cda03ce302aaf9f906a9520b5f81f91e
Christian Brabandt <cb@256bit.org>
parents:
7549
diff
changeset
|
8090 void |
14871
f20df682c8af
patch 8.1.0447: GUI scrollbar test fails with Athena and Motif
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
8091 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
|
8092 { |
36 | 8093 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
|
8094 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
|
8095 |
d3377393e3d9
patch 8.1.1136: decoding of mouse click escape sequence is not tested
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
8096 // 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
|
8097 // is nothing to get, so also check for Ctrl_C. |
36 | 8098 clear_oparg(&oa); |
8099 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
|
8100 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
|
8101 || ((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
|
8102 || (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
|
8103 && !got_int) |
36 | 8104 { |
8105 update_topline_cursor(); | |
13829
044337cbf854
patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents:
13802
diff
changeset
|
8106 #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
|
8107 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
|
8108 && 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
|
8109 && !VIsual_active) |
044337cbf854
patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents:
13802
diff
changeset
|
8110 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8111 // 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
|
8112 // 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
|
8113 // 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
|
8114 if (terminal_loop(TRUE) == OK) |
044337cbf854
patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents:
13802
diff
changeset
|
8115 normal_cmd(&oa, TRUE); |
044337cbf854
patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents:
13802
diff
changeset
|
8116 } |
044337cbf854
patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents:
13802
diff
changeset
|
8117 else |
044337cbf854
patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents:
13802
diff
changeset
|
8118 #endif |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8119 // execute a Normal mode cmd |
13829
044337cbf854
patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents:
13802
diff
changeset
|
8120 normal_cmd(&oa, TRUE); |
36 | 8121 } |
8122 } | |
8123 | |
7 | 8124 #ifdef FEAT_FIND_ID |
8125 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8126 ex_checkpath(exarg_T *eap) |
7 | 8127 { |
8128 find_pattern_in_path(NULL, 0, 0, FALSE, FALSE, CHECK_PATH, 1L, | |
8129 eap->forceit ? ACTION_SHOW_ALL : ACTION_SHOW, | |
8130 (linenr_T)1, (linenr_T)MAXLNUM); | |
8131 } | |
8132 | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
8133 #if defined(FEAT_QUICKFIX) |
7 | 8134 /* |
8135 * ":psearch" | |
8136 */ | |
8137 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8138 ex_psearch(exarg_T *eap) |
7 | 8139 { |
8140 g_do_tagpreview = p_pvh; | |
8141 ex_findpat(eap); | |
8142 g_do_tagpreview = 0; | |
8143 } | |
8144 #endif | |
8145 | |
8146 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8147 ex_findpat(exarg_T *eap) |
7 | 8148 { |
8149 int whole = TRUE; | |
8150 long n; | |
8151 char_u *p; | |
8152 int action; | |
8153 | |
8154 switch (cmdnames[eap->cmdidx].cmd_name[2]) | |
8155 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8156 case 'e': // ":psearch", ":isearch" and ":dsearch" |
7 | 8157 if (cmdnames[eap->cmdidx].cmd_name[0] == 'p') |
8158 action = ACTION_GOTO; | |
8159 else | |
8160 action = ACTION_SHOW; | |
8161 break; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8162 case 'i': // ":ilist" and ":dlist" |
7 | 8163 action = ACTION_SHOW_ALL; |
8164 break; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8165 case 'u': // ":ijump" and ":djump" |
7 | 8166 action = ACTION_GOTO; |
8167 break; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8168 default: // ":isplit" and ":dsplit" |
7 | 8169 action = ACTION_SPLIT; |
8170 break; | |
8171 } | |
8172 | |
8173 n = 1; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8174 if (vim_isdigit(*eap->arg)) // get count |
7 | 8175 { |
8176 n = getdigits(&eap->arg); | |
8177 eap->arg = skipwhite(eap->arg); | |
8178 } | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8179 if (*eap->arg == '/') // Match regexp, not just whole words |
7 | 8180 { |
8181 whole = FALSE; | |
8182 ++eap->arg; | |
19892
5feb426d2ea1
patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19685
diff
changeset
|
8183 p = skip_regexp(eap->arg, '/', p_magic); |
7 | 8184 if (*p) |
8185 { | |
8186 *p++ = NUL; | |
8187 p = skipwhite(p); | |
8188 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8189 // 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
|
8190 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
|
8191 eap->errmsg = ex_errmsg(e_trailing_arg, p); |
7 | 8192 else |
8193 eap->nextcmd = check_nextcmd(p); | |
8194 } | |
8195 } | |
8196 if (!eap->skip) | |
8197 find_pattern_in_path(eap->arg, 0, (int)STRLEN(eap->arg), | |
8198 whole, !eap->forceit, | |
8199 *eap->cmd == 'd' ? FIND_DEFINE : FIND_ANY, | |
8200 n, action, eap->line1, eap->line2); | |
8201 } | |
8202 #endif | |
8203 | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
8204 |
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
8205 #ifdef FEAT_QUICKFIX |
7 | 8206 /* |
8207 * ":ptag", ":ptselect", ":ptjump", ":ptnext", etc. | |
8208 */ | |
8209 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8210 ex_ptag(exarg_T *eap) |
7 | 8211 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8212 g_do_tagpreview = p_pvh; // will be reset to 0 in ex_tag_cmd() |
7 | 8213 ex_tag_cmd(eap, cmdnames[eap->cmdidx].cmd_name + 1); |
8214 } | |
8215 | |
8216 /* | |
8217 * ":pedit" | |
8218 */ | |
8219 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8220 ex_pedit(exarg_T *eap) |
7 | 8221 { |
8222 win_T *curwin_save = curwin; | |
8223 | |
19621
0d677257e35d
patch 8.2.0367: can use :pedit in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19575
diff
changeset
|
8224 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
|
8225 return; |
0d677257e35d
patch 8.2.0367: can use :pedit in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19575
diff
changeset
|
8226 |
17746
a4e488a6655c
patch 8.1.1870: using :pedit from a help file sets help filetype
Bram Moolenaar <Bram@vim.org>
parents:
17744
diff
changeset
|
8227 // Open the preview window or popup and make it the current window. |
7 | 8228 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
|
8229 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
|
8230 |
17746
a4e488a6655c
patch 8.1.1870: using :pedit from a help file sets help filetype
Bram Moolenaar <Bram@vim.org>
parents:
17744
diff
changeset
|
8231 // Edit the file. |
7 | 8232 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
|
8233 |
7 | 8234 if (curwin != curwin_save && win_valid(curwin_save)) |
8235 { | |
17746
a4e488a6655c
patch 8.1.1870: using :pedit from a help file sets help filetype
Bram Moolenaar <Bram@vim.org>
parents:
17744
diff
changeset
|
8236 // Return cursor to where we were |
7 | 8237 validate_cursor(); |
8238 redraw_later(VALID); | |
8239 win_enter(curwin_save, TRUE); | |
8240 } | |
18763
49b78d6465e5
patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents:
18715
diff
changeset
|
8241 # 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
|
8242 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
|
8243 { |
daa1dea1c1b3
patch 8.1.1819: :pedit does not work with a popup preview window
Bram Moolenaar <Bram@vim.org>
parents:
17622
diff
changeset
|
8244 // 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
|
8245 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
|
8246 } |
daa1dea1c1b3
patch 8.1.1819: :pedit does not work with a popup preview window
Bram Moolenaar <Bram@vim.org>
parents:
17622
diff
changeset
|
8247 # endif |
7 | 8248 g_do_tagpreview = 0; |
8249 } | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
8250 #endif |
7 | 8251 |
8252 /* | |
8253 * ":stag", ":stselect" and ":stjump". | |
8254 */ | |
8255 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8256 ex_stag(exarg_T *eap) |
7 | 8257 { |
8258 postponed_split = -1; | |
8259 postponed_split_flags = cmdmod.split; | |
1090 | 8260 postponed_split_tab = cmdmod.tab; |
7 | 8261 ex_tag_cmd(eap, cmdnames[eap->cmdidx].cmd_name + 1); |
8262 postponed_split_flags = 0; | |
1090 | 8263 postponed_split_tab = 0; |
7 | 8264 } |
8265 | |
8266 /* | |
8267 * ":tag", ":tselect", ":tjump", ":tnext", etc. | |
8268 */ | |
8269 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8270 ex_tag(exarg_T *eap) |
7 | 8271 { |
8272 ex_tag_cmd(eap, cmdnames[eap->cmdidx].cmd_name); | |
8273 } | |
8274 | |
8275 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8276 ex_tag_cmd(exarg_T *eap, char_u *name) |
7 | 8277 { |
8278 int cmd; | |
8279 | |
8280 switch (name[1]) | |
8281 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8282 case 'j': cmd = DT_JUMP; // ":tjump" |
7 | 8283 break; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8284 case 's': cmd = DT_SELECT; // ":tselect" |
7 | 8285 break; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8286 case 'p': cmd = DT_PREV; // ":tprevious" |
7 | 8287 break; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8288 case 'N': cmd = DT_PREV; // ":tNext" |
7 | 8289 break; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8290 case 'n': cmd = DT_NEXT; // ":tnext" |
7 | 8291 break; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8292 case 'o': cmd = DT_POP; // ":pop" |
7 | 8293 break; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8294 case 'f': // ":tfirst" |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8295 case 'r': cmd = DT_FIRST; // ":trewind" |
7 | 8296 break; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8297 case 'l': cmd = DT_LAST; // ":tlast" |
7 | 8298 break; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8299 default: // ":tag" |
7 | 8300 #ifdef FEAT_CSCOPE |
1603 | 8301 if (p_cst && *eap->arg != NUL) |
7 | 8302 { |
10373
bd674706408a
commit https://github.com/vim/vim/commit/d4db7719bdfbc54df396eac08d8cbb2389feacf4
Christian Brabandt <cb@256bit.org>
parents:
10361
diff
changeset
|
8303 ex_cstag(eap); |
7 | 8304 return; |
8305 } | |
8306 #endif | |
8307 cmd = DT_TAG; | |
8308 break; | |
8309 } | |
8310 | |
649 | 8311 if (name[0] == 'l') |
8312 { | |
8313 #ifndef FEAT_QUICKFIX | |
8314 ex_ni(eap); | |
8315 return; | |
8316 #else | |
8317 cmd = DT_LTAG; | |
8318 #endif | |
8319 } | |
8320 | |
7 | 8321 do_tag(eap->arg, cmd, eap->addr_count > 0 ? (int)eap->line2 : 1, |
8322 eap->forceit, TRUE); | |
8323 } | |
8324 | |
8325 /* | |
1661 | 8326 * Check "str" for starting with a special cmdline variable. |
8327 * If found return one of the SPEC_ values and set "*usedlen" to the length of | |
8328 * the variable. Otherwise return -1 and "*usedlen" is unchanged. | |
8329 */ | |
8330 int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8331 find_cmdline_var(char_u *src, int *usedlen) |
1661 | 8332 { |
8333 int len; | |
8334 int i; | |
1879 | 8335 static char *(spec_str[]) = { |
1661 | 8336 "%", |
8337 #define SPEC_PERC 0 | |
8338 "#", | |
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
|
8339 #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
|
8340 "<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
|
8341 #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
|
8342 "<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
|
8343 #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
|
8344 "<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
|
8345 #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
|
8346 "<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
|
8347 #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
|
8348 "<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
|
8349 #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
|
8350 "<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
|
8351 #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
|
8352 "<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
|
8353 #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
|
8354 "<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
|
8355 #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
|
8356 "<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
|
8357 #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
|
8358 "<amatch>", // autocommand match name |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
8359 #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
|
8360 "<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
|
8361 #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
|
8362 "<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
|
8363 #define SPEC_SID (SPEC_SFLNUM + 1) |
1661 | 8364 #ifdef FEAT_CLIENTSERVER |
8365 "<client>" | |
21594
5daca8504c63
patch 8.2.1347: cannot easily get the script ID
Bram Moolenaar <Bram@vim.org>
parents:
21592
diff
changeset
|
8366 # define SPEC_CLIENT (SPEC_SID + 1) |
1661 | 8367 #endif |
8368 }; | |
1872 | 8369 |
8370 for (i = 0; i < (int)(sizeof(spec_str) / sizeof(char *)); ++i) | |
1661 | 8371 { |
8372 len = (int)STRLEN(spec_str[i]); | |
8373 if (STRNCMP(src, spec_str[i], len) == 0) | |
8374 { | |
8375 *usedlen = len; | |
8376 return i; | |
8377 } | |
8378 } | |
8379 return -1; | |
8380 } | |
8381 | |
8382 /* | |
7 | 8383 * Evaluate cmdline variables. |
8384 * | |
8385 * change '%' to curbuf->b_ffname | |
8386 * '#' to curwin->w_altfile | |
8387 * '<cword>' to word under the cursor | |
8388 * '<cWORD>' to WORD under the cursor | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
8389 * '<cexpr>' to C-expression under the cursor |
7 | 8390 * '<cfile>' to path name under the cursor |
8391 * '<sfile>' to sourced file name | |
22208
a607f02fd17a
patch 8.2.1653: expand('<stack>') does not include the final line number
Bram Moolenaar <Bram@vim.org>
parents:
22176
diff
changeset
|
8392 * '<stack>' to call stack |
2645 | 8393 * '<slnum>' to sourced file line number |
7 | 8394 * '<afile>' to file name for autocommand |
8395 * '<abuf>' to buffer number for autocommand | |
8396 * '<amatch>' to matching name for autocommand | |
8397 * | |
8398 * When an error is detected, "errormsg" is set to a non-NULL pointer (may be | |
8399 * "" for error without a message) and NULL is returned. | |
8400 * Returns an allocated string if a valid match was found. | |
8401 * Returns NULL if no match was found. "usedlen" then still contains the | |
8402 * number of characters to skip. | |
8403 */ | |
8404 char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8405 eval_vars( |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8406 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
|
8407 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
|
8408 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
|
8409 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
|
8410 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
|
8411 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
|
8412 // be NULL) |
7 | 8413 { |
8414 int i; | |
8415 char_u *s; | |
8416 char_u *result; | |
8417 char_u *resultbuf = NULL; | |
8418 int resultlen; | |
8419 buf_T *buf; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8420 int valid = VALID_HEAD + VALID_PATH; // assume valid result |
7 | 8421 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
|
8422 int tilde_file = FALSE; |
7 | 8423 int skip_mod = FALSE; |
8424 char_u strbuf[30]; | |
8425 | |
8426 *errormsg = NULL; | |
1098 | 8427 if (escaped != NULL) |
8428 *escaped = FALSE; | |
7 | 8429 |
8430 /* | |
8431 * Check if there is something to do. | |
8432 */ | |
1661 | 8433 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
|
8434 if (spec_idx < 0) // no match |
7 | 8435 { |
8436 *usedlen = 1; | |
8437 return NULL; | |
8438 } | |
8439 | |
8440 /* | |
8441 * Skip when preceded with a backslash "\%" and "\#". | |
8442 * Note: In "\\%" the % is also not recognized! | |
8443 */ | |
8444 if (src > srcstart && src[-1] == '\\') | |
8445 { | |
8446 *usedlen = 0; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8447 STRMOVE(src - 1, src); // remove backslash |
7 | 8448 return NULL; |
8449 } | |
8450 | |
8451 /* | |
8452 * word or WORD under cursor | |
8453 */ | |
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
|
8454 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
|
8455 || 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
|
8456 { |
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
|
8457 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
|
8458 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
|
8459 : 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
|
8460 : FIND_STRING); |
7 | 8461 if (resultlen == 0) |
8462 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8463 *errormsg = ""; |
7 | 8464 return NULL; |
8465 } | |
8466 } | |
8467 | |
8468 /* | |
8469 * '#': Alternate file name | |
8470 * '%': Current file name | |
8471 * File name under the cursor | |
8472 * File name for autocommand | |
8473 * and following modifiers | |
8474 */ | |
8475 else | |
8476 { | |
8477 switch (spec_idx) | |
8478 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8479 case SPEC_PERC: // '%': current file |
7 | 8480 if (curbuf->b_fname == NULL) |
8481 { | |
8482 result = (char_u *)""; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8483 valid = 0; // Must have ":p:h" to be valid |
7 | 8484 } |
8485 else | |
14393
c62601adad69
patch 8.1.0211: expanding a file name "~" results in $HOME
Christian Brabandt <cb@256bit.org>
parents:
14286
diff
changeset
|
8486 { |
7 | 8487 result = curbuf->b_fname; |
14393
c62601adad69
patch 8.1.0211: expanding a file name "~" results in $HOME
Christian Brabandt <cb@256bit.org>
parents:
14286
diff
changeset
|
8488 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
|
8489 } |
7 | 8490 break; |
8491 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8492 case SPEC_HASH: // '#' or "#99": alternate file |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8493 if (src[1] == '#') // "##": the argument list |
7 | 8494 { |
8495 result = arg_all(); | |
8496 resultbuf = result; | |
8497 *usedlen = 2; | |
1098 | 8498 if (escaped != NULL) |
8499 *escaped = TRUE; | |
7 | 8500 skip_mod = TRUE; |
8501 break; | |
8502 } | |
8503 s = src + 1; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8504 if (*s == '<') // "#<99" uses v:oldfiles |
1733 | 8505 ++s; |
7 | 8506 i = (int)getdigits(&s); |
12706
9b882316aa63
patch 8.0.1231: expanding file name drops dash
Christian Brabandt <cb@256bit.org>
parents:
12674
diff
changeset
|
8507 if (s == src + 2 && src[1] == '-') |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8508 // 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
|
8509 s--; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8510 *usedlen = (int)(s - src); // length of what we expand |
7 | 8511 |
12706
9b882316aa63
patch 8.0.1231: expanding file name drops dash
Christian Brabandt <cb@256bit.org>
parents:
12674
diff
changeset
|
8512 if (src[1] == '<' && i != 0) |
7 | 8513 { |
1733 | 8514 if (*usedlen < 2) |
8515 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8516 // Should we give an error message for #<text? |
1733 | 8517 *usedlen = 1; |
8518 return NULL; | |
8519 } | |
8520 #ifdef FEAT_EVAL | |
8521 result = list_find_str(get_vim_var_list(VV_OLDFILES), | |
8522 (long)i); | |
8523 if (result == NULL) | |
8524 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8525 *errormsg = ""; |
1733 | 8526 return NULL; |
8527 } | |
8528 #else | |
15488
da8b98c008bf
patch 8.1.0752: one more compiler warning for signed/unsigned string
Bram Moolenaar <Bram@vim.org>
parents:
15474
diff
changeset
|
8529 *errormsg = _("E809: #< is not available without the +eval feature"); |
7 | 8530 return NULL; |
1733 | 8531 #endif |
7 | 8532 } |
8533 else | |
1733 | 8534 { |
12706
9b882316aa63
patch 8.0.1231: expanding file name drops dash
Christian Brabandt <cb@256bit.org>
parents:
12674
diff
changeset
|
8535 if (i == 0 && src[1] == '<' && *usedlen > 1) |
9b882316aa63
patch 8.0.1231: expanding file name drops dash
Christian Brabandt <cb@256bit.org>
parents:
12674
diff
changeset
|
8536 *usedlen = 1; |
1733 | 8537 buf = buflist_findnr(i); |
8538 if (buf == NULL) | |
8539 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8540 *errormsg = _("E194: No alternate file name to substitute for '#'"); |
1733 | 8541 return NULL; |
8542 } | |
8543 if (lnump != NULL) | |
8544 *lnump = ECMD_LAST; | |
8545 if (buf->b_fname == NULL) | |
8546 { | |
8547 result = (char_u *)""; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8548 valid = 0; // Must have ":p:h" to be valid |
1733 | 8549 } |
8550 else | |
14393
c62601adad69
patch 8.1.0211: expanding a file name "~" results in $HOME
Christian Brabandt <cb@256bit.org>
parents:
14286
diff
changeset
|
8551 { |
1733 | 8552 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
|
8553 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
|
8554 } |
1733 | 8555 } |
7 | 8556 break; |
8557 | |
8558 #ifdef FEAT_SEARCHPATH | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8559 case SPEC_CFILE: // file name under cursor |
681 | 8560 result = file_name_at_cursor(FNAME_MESS|FNAME_HYP, 1L, NULL); |
7 | 8561 if (result == NULL) |
8562 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8563 *errormsg = ""; |
7 | 8564 return NULL; |
8565 } | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8566 resultbuf = result; // remember allocated string |
7 | 8567 break; |
8568 #endif | |
8569 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8570 case SPEC_AFILE: // file name for autocommand |
7 | 8571 result = autocmd_fname; |
1723 | 8572 if (result != NULL && !autocmd_fname_full) |
8573 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8574 // 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
|
8575 // postponed to avoid a delay when <afile> is not used. |
1723 | 8576 autocmd_fname_full = TRUE; |
8577 result = FullName_save(autocmd_fname, FALSE); | |
8578 vim_free(autocmd_fname); | |
8579 autocmd_fname = result; | |
8580 } | |
7 | 8581 if (result == NULL) |
8582 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8583 *errormsg = _("E495: no autocommand file name to substitute for \"<afile>\""); |
7 | 8584 return NULL; |
8585 } | |
1471 | 8586 result = shorten_fname1(result); |
7 | 8587 break; |
8588 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8589 case SPEC_ABUF: // buffer number for autocommand |
7 | 8590 if (autocmd_bufnr <= 0) |
8591 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8592 *errormsg = _("E496: no autocommand buffer number to substitute for \"<abuf>\""); |
7 | 8593 return NULL; |
8594 } | |
8595 sprintf((char *)strbuf, "%d", autocmd_bufnr); | |
8596 result = strbuf; | |
8597 break; | |
8598 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8599 case SPEC_AMATCH: // match name for autocommand |
7 | 8600 result = autocmd_match; |
8601 if (result == NULL) | |
8602 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8603 *errormsg = _("E497: no autocommand match name to substitute for \"<amatch>\""); |
7 | 8604 return NULL; |
8605 } | |
8606 break; | |
8607 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8608 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
|
8609 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
|
8610 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
|
8611 ? ESTACK_SFILE : ESTACK_STACK); |
7 | 8612 if (result == NULL) |
8613 { | |
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
|
8614 *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
|
8615 ? _("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
|
8616 : _("E489: no call stack to substitute for \"<stack>\""); |
7 | 8617 return NULL; |
8618 } | |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18904
diff
changeset
|
8619 resultbuf = result; // remember allocated string |
7 | 8620 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
|
8621 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8622 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
|
8623 if (SOURCING_NAME == NULL || SOURCING_LNUM == 0) |
2645 | 8624 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8625 *errormsg = _("E842: no line number to use for \"<slnum>\""); |
2645 | 8626 return NULL; |
8627 } | |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18904
diff
changeset
|
8628 sprintf((char *)strbuf, "%ld", SOURCING_LNUM); |
2645 | 8629 result = strbuf; |
8630 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
|
8631 |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14677
diff
changeset
|
8632 #ifdef FEAT_EVAL |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8633 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
|
8634 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
|
8635 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8636 *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
|
8637 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
|
8638 } |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14677
diff
changeset
|
8639 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
|
8640 (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
|
8641 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
|
8642 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
|
8643 |
21594
5daca8504c63
patch 8.2.1347: cannot easily get the script ID
Bram Moolenaar <Bram@vim.org>
parents:
21592
diff
changeset
|
8644 case SPEC_SID: |
5daca8504c63
patch 8.2.1347: cannot easily get the script ID
Bram Moolenaar <Bram@vim.org>
parents:
21592
diff
changeset
|
8645 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
|
8646 { |
5daca8504c63
patch 8.2.1347: cannot easily get the script ID
Bram Moolenaar <Bram@vim.org>
parents:
21592
diff
changeset
|
8647 *errormsg = _(e_usingsid); |
5daca8504c63
patch 8.2.1347: cannot easily get the script ID
Bram Moolenaar <Bram@vim.org>
parents:
21592
diff
changeset
|
8648 return NULL; |
5daca8504c63
patch 8.2.1347: cannot easily get the script ID
Bram Moolenaar <Bram@vim.org>
parents:
21592
diff
changeset
|
8649 } |
5daca8504c63
patch 8.2.1347: cannot easily get the script ID
Bram Moolenaar <Bram@vim.org>
parents:
21592
diff
changeset
|
8650 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
|
8651 result = strbuf; |
5daca8504c63
patch 8.2.1347: cannot easily get the script ID
Bram Moolenaar <Bram@vim.org>
parents:
21592
diff
changeset
|
8652 break; |
21596
c18d00494b60
patch 8.2.1348: build failure without the eval feature
Bram Moolenaar <Bram@vim.org>
parents:
21594
diff
changeset
|
8653 #endif |
21594
5daca8504c63
patch 8.2.1347: cannot easily get the script ID
Bram Moolenaar <Bram@vim.org>
parents:
21592
diff
changeset
|
8654 |
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
|
8655 #ifdef FEAT_CLIENTSERVER |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8656 case SPEC_CLIENT: // Source of last submitted input |
840 | 8657 sprintf((char *)strbuf, PRINTF_HEX_LONG_U, |
8658 (long_u)clientWindow); | |
7 | 8659 result = strbuf; |
8660 break; | |
8661 #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
|
8662 |
11428
346168f2a6cb
patch 8.0.0598: building with gcc 7.1 yields new warnings
Christian Brabandt <cb@256bit.org>
parents:
11374
diff
changeset
|
8663 default: |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8664 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
|
8665 break; |
7 | 8666 } |
8667 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8668 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
|
8669 if (src[*usedlen] == '<') // remove the file name extension |
7 | 8670 { |
8671 ++*usedlen; | |
8672 if ((s = vim_strrchr(result, '.')) != NULL && s >= gettail(result)) | |
8673 resultlen = (int)(s - result); | |
8674 } | |
8675 else if (!skip_mod) | |
8676 { | |
14393
c62601adad69
patch 8.1.0211: expanding a file name "~" results in $HOME
Christian Brabandt <cb@256bit.org>
parents:
14286
diff
changeset
|
8677 valid |= modify_fname(src, tilde_file, usedlen, &result, &resultbuf, |
7 | 8678 &resultlen); |
8679 if (result == NULL) | |
8680 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8681 *errormsg = ""; |
7 | 8682 return NULL; |
8683 } | |
8684 } | |
8685 } | |
8686 | |
8687 if (resultlen == 0 || valid != VALID_HEAD + VALID_PATH) | |
8688 { | |
8689 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
|
8690 // 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
|
8691 *errormsg = _("E499: Empty file name for '%' or '#', only works with \":p:h\""); |
7 | 8692 else |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8693 *errormsg = _("E500: Evaluates to an empty string"); |
7 | 8694 result = NULL; |
8695 } | |
8696 else | |
8697 result = vim_strnsave(result, resultlen); | |
8698 vim_free(resultbuf); | |
8699 return result; | |
8700 } | |
8701 | |
8702 /* | |
8703 * Expand the <sfile> string in "arg". | |
8704 * | |
8705 * Returns an allocated string, or NULL for any error. | |
8706 */ | |
8707 char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8708 expand_sfile(char_u *arg) |
7 | 8709 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8710 char *errormsg; |
7 | 8711 int len; |
8712 char_u *result; | |
8713 char_u *newres; | |
8714 char_u *repl; | |
8715 int srclen; | |
8716 char_u *p; | |
8717 | |
8718 result = vim_strsave(arg); | |
8719 if (result == NULL) | |
8720 return NULL; | |
8721 | |
8722 for (p = result; *p; ) | |
8723 { | |
8724 if (STRNCMP(p, "<sfile>", 7) != 0) | |
8725 ++p; | |
8726 else | |
8727 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8728 // replace "<sfile>" with the sourced file name, and do ":" stuff |
1098 | 8729 repl = eval_vars(p, result, &srclen, NULL, &errormsg, NULL); |
7 | 8730 if (errormsg != NULL) |
8731 { | |
8732 if (*errormsg) | |
8733 emsg(errormsg); | |
8734 vim_free(result); | |
8735 return NULL; | |
8736 } | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8737 if (repl == NULL) // no match (cannot happen) |
7 | 8738 { |
8739 p += srclen; | |
8740 continue; | |
8741 } | |
8742 len = (int)STRLEN(result) - srclen + (int)STRLEN(repl) + 1; | |
8743 newres = alloc(len); | |
8744 if (newres == NULL) | |
8745 { | |
8746 vim_free(repl); | |
8747 vim_free(result); | |
8748 return NULL; | |
8749 } | |
8750 mch_memmove(newres, result, (size_t)(p - result)); | |
8751 STRCPY(newres + (p - result), repl); | |
8752 len = (int)STRLEN(newres); | |
8753 STRCAT(newres, p + srclen); | |
8754 vim_free(repl); | |
8755 vim_free(result); | |
8756 result = newres; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8757 p = newres + len; // continue after the match |
7 | 8758 } |
8759 } | |
8760 | |
8761 return result; | |
8762 } | |
8763 | |
8764 #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) || defined(PROTO) | |
272 | 8765 /* |
2770 | 8766 * Make a dialog message in "buff[DIALOG_MSG_SIZE]". |
310 | 8767 * "format" must contain "%s". |
272 | 8768 */ |
7 | 8769 void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8770 dialog_msg(char_u *buff, char *format, char_u *fname) |
7 | 8771 { |
8772 if (fname == NULL) | |
8773 fname = (char_u *)_("Untitled"); | |
2770 | 8774 vim_snprintf((char *)buff, DIALOG_MSG_SIZE, format, fname); |
7 | 8775 } |
8776 #endif | |
8777 | |
8778 /* | |
8779 * ":behave {mswin,xterm}" | |
8780 */ | |
8781 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8782 ex_behave(exarg_T *eap) |
7 | 8783 { |
8784 if (STRCMP(eap->arg, "mswin") == 0) | |
8785 { | |
8786 set_option_value((char_u *)"selection", 0L, (char_u *)"exclusive", 0); | |
8787 set_option_value((char_u *)"selectmode", 0L, (char_u *)"mouse,key", 0); | |
8788 set_option_value((char_u *)"mousemodel", 0L, (char_u *)"popup", 0); | |
8789 set_option_value((char_u *)"keymodel", 0L, | |
8790 (char_u *)"startsel,stopsel", 0); | |
8791 } | |
8792 else if (STRCMP(eap->arg, "xterm") == 0) | |
8793 { | |
8794 set_option_value((char_u *)"selection", 0L, (char_u *)"inclusive", 0); | |
8795 set_option_value((char_u *)"selectmode", 0L, (char_u *)"", 0); | |
8796 set_option_value((char_u *)"mousemodel", 0L, (char_u *)"extend", 0); | |
8797 set_option_value((char_u *)"keymodel", 0L, (char_u *)"", 0); | |
8798 } | |
8799 else | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8800 semsg(_(e_invarg2), eap->arg); |
7 | 8801 } |
8802 | |
8803 static int filetype_detect = FALSE; | |
8804 static int filetype_plugin = FALSE; | |
8805 static int filetype_indent = FALSE; | |
8806 | |
8807 /* | |
8808 * ":filetype [plugin] [indent] {on,off,detect}" | |
8809 * on: Load the filetype.vim file to install autocommands for file types. | |
8810 * off: Load the ftoff.vim file to remove all autocommands for file types. | |
8811 * plugin on: load filetype.vim and ftplugin.vim | |
8812 * plugin off: load ftplugof.vim | |
8813 * indent on: load filetype.vim and indent.vim | |
8814 * indent off: load indoff.vim | |
8815 */ | |
8816 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8817 ex_filetype(exarg_T *eap) |
7 | 8818 { |
8819 char_u *arg = eap->arg; | |
8820 int plugin = FALSE; | |
8821 int indent = FALSE; | |
8822 | |
8823 if (*eap->arg == NUL) | |
8824 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8825 // Print current status. |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8826 smsg("filetype detection:%s plugin:%s indent:%s", |
7 | 8827 filetype_detect ? "ON" : "OFF", |
8828 filetype_plugin ? (filetype_detect ? "ON" : "(on)") : "OFF", | |
8829 filetype_indent ? (filetype_detect ? "ON" : "(on)") : "OFF"); | |
8830 return; | |
8831 } | |
8832 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8833 // Accept "plugin" and "indent" in any order. |
7 | 8834 for (;;) |
8835 { | |
8836 if (STRNCMP(arg, "plugin", 6) == 0) | |
8837 { | |
8838 plugin = TRUE; | |
8839 arg = skipwhite(arg + 6); | |
8840 continue; | |
8841 } | |
8842 if (STRNCMP(arg, "indent", 6) == 0) | |
8843 { | |
8844 indent = TRUE; | |
8845 arg = skipwhite(arg + 6); | |
8846 continue; | |
8847 } | |
8848 break; | |
8849 } | |
8850 if (STRCMP(arg, "on") == 0 || STRCMP(arg, "detect") == 0) | |
8851 { | |
8852 if (*arg == 'o' || !filetype_detect) | |
8853 { | |
8524
2f57bbe870ea
commit https://github.com/vim/vim/commit/7f8989dd8a627af2185df381195351a913f3777f
Christian Brabandt <cb@256bit.org>
parents:
8402
diff
changeset
|
8854 source_runtime((char_u *)FILETYPE_FILE, DIP_ALL); |
7 | 8855 filetype_detect = TRUE; |
8856 if (plugin) | |
8857 { | |
8524
2f57bbe870ea
commit https://github.com/vim/vim/commit/7f8989dd8a627af2185df381195351a913f3777f
Christian Brabandt <cb@256bit.org>
parents:
8402
diff
changeset
|
8858 source_runtime((char_u *)FTPLUGIN_FILE, DIP_ALL); |
7 | 8859 filetype_plugin = TRUE; |
8860 } | |
8861 if (indent) | |
8862 { | |
8524
2f57bbe870ea
commit https://github.com/vim/vim/commit/7f8989dd8a627af2185df381195351a913f3777f
Christian Brabandt <cb@256bit.org>
parents:
8402
diff
changeset
|
8863 source_runtime((char_u *)INDENT_FILE, DIP_ALL); |
7 | 8864 filetype_indent = TRUE; |
8865 } | |
8866 } | |
8867 if (*arg == 'd') | |
8868 { | |
9260
ac8180818504
commit https://github.com/vim/vim/commit/1610d052413e0ed664498853a47acc2d677a22d1
Christian Brabandt <cb@256bit.org>
parents:
9230
diff
changeset
|
8869 (void)do_doautocmd((char_u *)"filetypedetect BufRead", TRUE, NULL); |
717 | 8870 do_modelines(0); |
7 | 8871 } |
8872 } | |
8873 else if (STRCMP(arg, "off") == 0) | |
8874 { | |
8875 if (plugin || indent) | |
8876 { | |
8877 if (plugin) | |
8878 { | |
8524
2f57bbe870ea
commit https://github.com/vim/vim/commit/7f8989dd8a627af2185df381195351a913f3777f
Christian Brabandt <cb@256bit.org>
parents:
8402
diff
changeset
|
8879 source_runtime((char_u *)FTPLUGOF_FILE, DIP_ALL); |
7 | 8880 filetype_plugin = FALSE; |
8881 } | |
8882 if (indent) | |
8883 { | |
8524
2f57bbe870ea
commit https://github.com/vim/vim/commit/7f8989dd8a627af2185df381195351a913f3777f
Christian Brabandt <cb@256bit.org>
parents:
8402
diff
changeset
|
8884 source_runtime((char_u *)INDOFF_FILE, DIP_ALL); |
7 | 8885 filetype_indent = FALSE; |
8886 } | |
8887 } | |
8888 else | |
8889 { | |
8524
2f57bbe870ea
commit https://github.com/vim/vim/commit/7f8989dd8a627af2185df381195351a913f3777f
Christian Brabandt <cb@256bit.org>
parents:
8402
diff
changeset
|
8890 source_runtime((char_u *)FTOFF_FILE, DIP_ALL); |
7 | 8891 filetype_detect = FALSE; |
8892 } | |
8893 } | |
8894 else | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8895 semsg(_(e_invarg2), arg); |
7 | 8896 } |
8897 | |
8898 /* | |
11459
561b76ed9d12
patch 8.0.0613: the conf filetype is used before ftdetect from packages
Christian Brabandt <cb@256bit.org>
parents:
11428
diff
changeset
|
8899 * ":setfiletype [FALLBACK] {name}" |
7 | 8900 */ |
8901 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8902 ex_setfiletype(exarg_T *eap) |
7 | 8903 { |
8904 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
|
8905 { |
561b76ed9d12
patch 8.0.0613: the conf filetype is used before ftdetect from packages
Christian Brabandt <cb@256bit.org>
parents:
11428
diff
changeset
|
8906 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
|
8907 |
561b76ed9d12
patch 8.0.0613: the conf filetype is used before ftdetect from packages
Christian Brabandt <cb@256bit.org>
parents:
11428
diff
changeset
|
8908 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
|
8909 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
|
8910 |
561b76ed9d12
patch 8.0.0613: the conf filetype is used before ftdetect from packages
Christian Brabandt <cb@256bit.org>
parents:
11428
diff
changeset
|
8911 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
|
8912 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
|
8913 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
|
8914 } |
7 | 8915 } |
8916 | |
8917 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8918 ex_digraphs(exarg_T *eap UNUSED) |
7 | 8919 { |
8920 #ifdef FEAT_DIGRAPHS | |
8921 if (*eap->arg != NUL) | |
8922 putdigraph(eap->arg); | |
8923 else | |
15152
1ef429366fd4
patch 8.1.0586: :digraph output is not easy to read
Bram Moolenaar <Bram@vim.org>
parents:
15125
diff
changeset
|
8924 listdigraphs(eap->forceit); |
7 | 8925 #else |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8926 emsg(_("E196: No digraphs in this version")); |
7 | 8927 #endif |
8928 } | |
8929 | |
13792
0e9b2971d7c3
patch 8.0.1768: SET_NO_HLSEARCH() used in a wrong way
Christian Brabandt <cb@256bit.org>
parents:
13581
diff
changeset
|
8930 #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
|
8931 void |
0e9b2971d7c3
patch 8.0.1768: SET_NO_HLSEARCH() used in a wrong way
Christian Brabandt <cb@256bit.org>
parents:
13581
diff
changeset
|
8932 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
|
8933 { |
0e9b2971d7c3
patch 8.0.1768: SET_NO_HLSEARCH() used in a wrong way
Christian Brabandt <cb@256bit.org>
parents:
13581
diff
changeset
|
8934 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
|
8935 # 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
|
8936 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
|
8937 # endif |
0e9b2971d7c3
patch 8.0.1768: SET_NO_HLSEARCH() used in a wrong way
Christian Brabandt <cb@256bit.org>
parents:
13581
diff
changeset
|
8938 } |
0e9b2971d7c3
patch 8.0.1768: SET_NO_HLSEARCH() used in a wrong way
Christian Brabandt <cb@256bit.org>
parents:
13581
diff
changeset
|
8939 |
7 | 8940 /* |
8941 * ":nohlsearch" | |
8942 */ | |
8943 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8944 ex_nohlsearch(exarg_T *eap UNUSED) |
7 | 8945 { |
13792
0e9b2971d7c3
patch 8.0.1768: SET_NO_HLSEARCH() used in a wrong way
Christian Brabandt <cb@256bit.org>
parents:
13581
diff
changeset
|
8946 set_no_hlsearch(TRUE); |
737 | 8947 redraw_all_later(SOME_VALID); |
7 | 8948 } |
8949 #endif | |
8950 | |
8951 #ifdef FEAT_CRYPT | |
8952 /* | |
8953 * ":X": Get crypt key | |
8954 */ | |
8955 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8956 ex_X(exarg_T *eap UNUSED) |
7 | 8957 { |
6353 | 8958 crypt_check_current_method(); |
6122 | 8959 (void)crypt_get_key(TRUE, TRUE); |
7 | 8960 } |
8961 #endif | |
8962 | |
8963 #ifdef FEAT_FOLDING | |
8964 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8965 ex_fold(exarg_T *eap) |
7 | 8966 { |
8967 if (foldManualAllowed(TRUE)) | |
8968 foldCreate(eap->line1, eap->line2); | |
8969 } | |
8970 | |
8971 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8972 ex_foldopen(exarg_T *eap) |
7 | 8973 { |
8974 opFoldRange(eap->line1, eap->line2, eap->cmdidx == CMD_foldopen, | |
8975 eap->forceit, FALSE); | |
8976 } | |
8977 | |
8978 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8979 ex_folddo(exarg_T *eap) |
7 | 8980 { |
8981 linenr_T lnum; | |
8982 | |
18297
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
8983 # ifdef FEAT_CLIPBOARD |
6116 | 8984 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
|
8985 # endif |
6116 | 8986 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8987 // First set the marks for all lines closed/open. |
7 | 8988 for (lnum = eap->line1; lnum <= eap->line2; ++lnum) |
8989 if (hasFolding(lnum, NULL, NULL) == (eap->cmdidx == CMD_folddoclosed)) | |
8990 ml_setmarked(lnum); | |
8991 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8992 // Execute the command on the marked lines. |
7 | 8993 global_exe(eap->arg); |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8994 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
|
8995 # ifdef FEAT_CLIPBOARD |
6116 | 8996 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
|
8997 # endif |
6116 | 8998 } |
8999 #endif | |
12459
937356f8f8d6
patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents:
12457
diff
changeset
|
9000 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
9001 #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
|
9002 /* |
60b9b6196644
patch 8.1.0288: quickfix code uses cmdidx too often
Christian Brabandt <cb@256bit.org>
parents:
14538
diff
changeset
|
9003 * 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
|
9004 * 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
|
9005 */ |
60b9b6196644
patch 8.1.0288: quickfix code uses cmdidx too often
Christian Brabandt <cb@256bit.org>
parents:
14538
diff
changeset
|
9006 int |
60b9b6196644
patch 8.1.0288: quickfix code uses cmdidx too often
Christian Brabandt <cb@256bit.org>
parents:
14538
diff
changeset
|
9007 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
|
9008 { |
14621
89cc3e7ecb68
patch 8.1.0324: off-by-one error in cmdidx check
Christian Brabandt <cb@256bit.org>
parents:
14591
diff
changeset
|
9009 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
|
9010 return FALSE; |
60b9b6196644
patch 8.1.0288: quickfix code uses cmdidx too often
Christian Brabandt <cb@256bit.org>
parents:
14538
diff
changeset
|
9011 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
|
9012 } |
60b9b6196644
patch 8.1.0288: quickfix code uses cmdidx too often
Christian Brabandt <cb@256bit.org>
parents:
14538
diff
changeset
|
9013 #endif |
60b9b6196644
patch 8.1.0288: quickfix code uses cmdidx too often
Christian Brabandt <cb@256bit.org>
parents:
14538
diff
changeset
|
9014 |
18297
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
9015 #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
|
9016 int |
937356f8f8d6
patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents:
12457
diff
changeset
|
9017 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
|
9018 { |
937356f8f8d6
patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents:
12457
diff
changeset
|
9019 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
|
9020 } |
937356f8f8d6
patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents:
12457
diff
changeset
|
9021 |
937356f8f8d6
patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents:
12457
diff
changeset
|
9022 void |
937356f8f8d6
patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents:
12457
diff
changeset
|
9023 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
|
9024 { |
937356f8f8d6
patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents:
12457
diff
changeset
|
9025 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
|
9026 } |
937356f8f8d6
patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents:
12457
diff
changeset
|
9027 #endif |