Mercurial > vim
annotate src/ex_docmd.c @ 20532:cb4831fa7e25 v8.2.0820
patch 8.2.0820: Vim9: function type isn't set until compiled
Commit: https://github.com/vim/vim/commit/6ff71d8b7fbdf667a2f119a2487302e240961816
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun May 24 23:45:24 2020 +0200
patch 8.2.0820: Vim9: function type isn't set until compiled
Problem: Vim9: function type isn't set until compiled.
Solution: Set function type early.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 25 May 2020 00:00:04 +0200 |
parents | 489cb75c76b6 |
children | 8fa783f2c69c |
rev | line source |
---|---|
10042
4aead6a9b7a9
commit https://github.com/vim/vim/commit/edf3f97ae2af024708ebb4ac614227327033ca47
Christian Brabandt <cb@256bit.org>
parents:
9980
diff
changeset
|
1 /* vi:set ts=8 sts=4 sw=4 noet: |
7 | 2 * |
3 * VIM - Vi IMproved by Bram Moolenaar | |
4 * | |
5 * Do ":help uganda" in Vim to read copying and usage conditions. | |
6 * Do ":help credits" in Vim to see a list of people who contributed. | |
7 * See README.txt for an overview of the Vim source code. | |
8 */ | |
9 | |
10 /* | |
11 * ex_docmd.c: functions for executing an Ex command line. | |
12 */ | |
13 | |
14 #include "vim.h" | |
15 | |
16 static int quitmore = 0; | |
17 static int ex_pressedreturn = FALSE; | |
18 #ifndef FEAT_PRINTER | |
19 # define ex_hardcopy ex_ni | |
20 #endif | |
21 | |
22 #ifdef FEAT_EVAL | |
18904
2bdc2e1f6e1f
patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents:
18849
diff
changeset
|
23 static char_u *do_one_cmd(char_u **, int, cstack_T *, char_u *(*fgetline)(int, void *, int, int), void *cookie); |
7 | 24 #else |
17178
40c4cb095d53
patch 8.1.1588: in :let-heredoc line continuation is recognized
Bram Moolenaar <Bram@vim.org>
parents:
17111
diff
changeset
|
25 static char_u *do_one_cmd(char_u **, int, char_u *(*fgetline)(int, void *, int, int), void *cookie); |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
26 static int if_level = 0; // depth in :if |
7 | 27 #endif |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
28 static void free_cmdmod(void); |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
29 static void append_command(char_u *cmd); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
30 |
7 | 31 #ifndef FEAT_MENU |
32 # define ex_emenu ex_ni | |
33 # define ex_menu ex_ni | |
34 # define ex_menutranslate ex_ni | |
35 #endif | |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
36 static void ex_autocmd(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
37 static void ex_doautocmd(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
38 static void ex_bunload(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
39 static void ex_buffer(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
40 static void ex_bmodified(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
41 static void ex_bnext(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
42 static void ex_bprevious(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
43 static void ex_brewind(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
44 static void ex_blast(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
45 static char_u *getargcmd(char_u **); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
46 static int getargopt(exarg_T *eap); |
7 | 47 #ifndef FEAT_QUICKFIX |
48 # define ex_make ex_ni | |
41 | 49 # define ex_cbuffer ex_ni |
7 | 50 # define ex_cc ex_ni |
51 # define ex_cnext ex_ni | |
16505
28e3ba82d8c8
patch 8.1.1256: cannot navigate through errors relative to the cursor
Bram Moolenaar <Bram@vim.org>
parents:
16479
diff
changeset
|
52 # define ex_cbelow ex_ni |
7 | 53 # define ex_cfile ex_ni |
54 # define qf_list ex_ni | |
55 # define qf_age ex_ni | |
9538
26da1efa9e46
commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
56 # define qf_history ex_ni |
7 | 57 # define ex_helpgrep ex_ni |
41 | 58 # define ex_vimgrep ex_ni |
7 | 59 #endif |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
60 #if !defined(FEAT_QUICKFIX) |
7 | 61 # define ex_cclose ex_ni |
62 # define ex_copen ex_ni | |
63 # define ex_cwindow ex_ni | |
9432
abb72f0b9e06
commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents:
9284
diff
changeset
|
64 # define ex_cbottom ex_ni |
7 | 65 #endif |
532 | 66 #if !defined(FEAT_QUICKFIX) || !defined(FEAT_EVAL) |
67 # define ex_cexpr ex_ni | |
68 #endif | |
7 | 69 |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
70 static linenr_T get_address(exarg_T *, char_u **, cmd_addr_T addr_type, int skip, int silent, int to_other_file, int address_count); |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
71 static void get_flags(exarg_T *eap); |
2333
aee7e1e5e0ce
Build problem when using all interfaces except Lua.
Bram Moolenaar <bram@vim.org>
parents:
2330
diff
changeset
|
72 #if !defined(FEAT_PERL) \ |
aee7e1e5e0ce
Build problem when using all interfaces except Lua.
Bram Moolenaar <bram@vim.org>
parents:
2330
diff
changeset
|
73 || !defined(FEAT_PYTHON) || !defined(FEAT_PYTHON3) \ |
aee7e1e5e0ce
Build problem when using all interfaces except Lua.
Bram Moolenaar <bram@vim.org>
parents:
2330
diff
changeset
|
74 || !defined(FEAT_TCL) \ |
aee7e1e5e0ce
Build problem when using all interfaces except Lua.
Bram Moolenaar <bram@vim.org>
parents:
2330
diff
changeset
|
75 || !defined(FEAT_RUBY) \ |
aee7e1e5e0ce
Build problem when using all interfaces except Lua.
Bram Moolenaar <bram@vim.org>
parents:
2330
diff
changeset
|
76 || !defined(FEAT_LUA) \ |
aee7e1e5e0ce
Build problem when using all interfaces except Lua.
Bram Moolenaar <bram@vim.org>
parents:
2330
diff
changeset
|
77 || !defined(FEAT_MZSCHEME) |
1315 | 78 # define HAVE_EX_SCRIPT_NI |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
79 static void ex_script_ni(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
80 #endif |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
81 static char *invalid_range(exarg_T *eap); |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
82 static void correct_range(exarg_T *eap); |
344 | 83 #ifdef FEAT_QUICKFIX |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
84 static char_u *replace_makeprg(exarg_T *eap, char_u *p, char_u **cmdlinep); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
85 #endif |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
86 static char_u *repl_cmdline(exarg_T *eap, char_u *src, int srclen, char_u *repl, char_u **cmdlinep); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
87 static void ex_highlight(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
88 static void ex_colorscheme(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
89 static void ex_cquit(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
90 static void ex_quit_all(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
91 static void ex_close(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
92 static void ex_win_close(int forceit, win_T *win, tabpage_T *tp); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
93 static void ex_only(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
94 static void ex_resize(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
95 static void ex_stag(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
96 static void ex_tabclose(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
97 static void ex_tabonly(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
98 static void ex_tabnext(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
99 static void ex_tabmove(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
100 static void ex_tabs(exarg_T *eap); |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
101 #if defined(FEAT_QUICKFIX) |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
102 static void ex_pclose(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
103 static void ex_ptag(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
104 static void ex_pedit(exarg_T *eap); |
7 | 105 #else |
106 # define ex_pclose ex_ni | |
107 # define ex_ptag ex_ni | |
108 # define ex_pedit ex_ni | |
109 #endif | |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
110 static void ex_hide(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
111 static void ex_stop(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
112 static void ex_exit(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
113 static void ex_print(exarg_T *eap); |
7 | 114 #ifdef FEAT_BYTEOFF |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
115 static void ex_goto(exarg_T *eap); |
7 | 116 #else |
117 # define ex_goto ex_ni | |
118 #endif | |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
119 static void ex_shell(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
120 static void ex_preserve(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
121 static void ex_recover(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
122 static void ex_mode(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
123 static void ex_wrongmodifier(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
124 static void ex_find(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
125 static void ex_open(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
126 static void ex_edit(exarg_T *eap); |
7 | 127 #ifndef FEAT_GUI |
128 # define ex_gui ex_nogui | |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
129 static void ex_nogui(exarg_T *eap); |
7 | 130 #endif |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15866
diff
changeset
|
131 #if defined(FEAT_GUI_MSWIN) && defined(FEAT_MENU) && defined(FEAT_TEAROFF) |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
132 static void ex_tearoff(exarg_T *eap); |
7 | 133 #else |
134 # define ex_tearoff ex_ni | |
135 #endif | |
13392
d5347779fb20
patch 8.0.1570: can't use :popup for a menu in the terminal
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
136 #if (defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_GTK) \ |
d5347779fb20
patch 8.0.1570: can't use :popup for a menu in the terminal
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
137 || defined(FEAT_TERM_POPUP_MENU)) && defined(FEAT_MENU) |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
138 static void ex_popup(exarg_T *eap); |
7 | 139 #else |
140 # define ex_popup ex_ni | |
141 #endif | |
142 #ifndef FEAT_GUI_MSWIN | |
143 # define ex_simalt ex_ni | |
144 #endif | |
573 | 145 #if !defined(FEAT_GUI_MSWIN) && !defined(FEAT_GUI_GTK) && !defined(FEAT_GUI_MOTIF) |
7 | 146 # define gui_mch_find_dialog ex_ni |
147 # define gui_mch_replace_dialog ex_ni | |
148 #endif | |
573 | 149 #if !defined(FEAT_GUI_GTK) |
7 | 150 # define ex_helpfind ex_ni |
151 #endif | |
152 #ifndef FEAT_CSCOPE | |
10373
bd674706408a
commit https://github.com/vim/vim/commit/d4db7719bdfbc54df396eac08d8cbb2389feacf4
Christian Brabandt <cb@256bit.org>
parents:
10361
diff
changeset
|
153 # define ex_cscope ex_ni |
bd674706408a
commit https://github.com/vim/vim/commit/d4db7719bdfbc54df396eac08d8cbb2389feacf4
Christian Brabandt <cb@256bit.org>
parents:
10361
diff
changeset
|
154 # define ex_scscope ex_ni |
bd674706408a
commit https://github.com/vim/vim/commit/d4db7719bdfbc54df396eac08d8cbb2389feacf4
Christian Brabandt <cb@256bit.org>
parents:
10361
diff
changeset
|
155 # define ex_cstag ex_ni |
7 | 156 #endif |
157 #ifndef FEAT_SYN_HL | |
158 # define ex_syntax ex_ni | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2238
diff
changeset
|
159 # define ex_ownsyntax ex_ni |
737 | 160 #endif |
4766
ec24ff78a79c
updated for version 7.3.1130
Bram Moolenaar <bram@vim.org>
parents:
4764
diff
changeset
|
161 #if !defined(FEAT_SYN_HL) || !defined(FEAT_PROFILE) |
4764
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4710
diff
changeset
|
162 # define ex_syntime ex_ni |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4710
diff
changeset
|
163 #endif |
737 | 164 #ifndef FEAT_SPELL |
310 | 165 # define ex_spell ex_ni |
236 | 166 # define ex_mkspell ex_ni |
351 | 167 # define ex_spelldump ex_ni |
714 | 168 # define ex_spellinfo ex_ni |
372 | 169 # define ex_spellrepall ex_ni |
236 | 170 #endif |
2214
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
171 #ifndef FEAT_PERSISTENT_UNDO |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
172 # define ex_rundo ex_ni |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
173 # define ex_wundo ex_ni |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
174 #endif |
2320
966a5609669e
Added Lua interfae. (Luis Carvalho)
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
175 #ifndef FEAT_LUA |
966a5609669e
Added Lua interfae. (Luis Carvalho)
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
176 # define ex_lua ex_script_ni |
966a5609669e
Added Lua interfae. (Luis Carvalho)
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
177 # define ex_luado ex_ni |
966a5609669e
Added Lua interfae. (Luis Carvalho)
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
178 # define ex_luafile ex_ni |
966a5609669e
Added Lua interfae. (Luis Carvalho)
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
179 #endif |
14 | 180 #ifndef FEAT_MZSCHEME |
181 # define ex_mzscheme ex_script_ni | |
182 # define ex_mzfile ex_ni | |
183 #endif | |
7 | 184 #ifndef FEAT_PERL |
185 # define ex_perl ex_script_ni | |
186 # define ex_perldo ex_ni | |
187 #endif | |
188 #ifndef FEAT_PYTHON | |
189 # define ex_python ex_script_ni | |
4435 | 190 # define ex_pydo ex_ni |
7 | 191 # define ex_pyfile ex_ni |
192 #endif | |
2329
ad2889f48843
Added support for Python 3. (Roland Puntaier)
Bram Moolenaar <bram@vim.org>
parents:
2320
diff
changeset
|
193 #ifndef FEAT_PYTHON3 |
2350
06feaf4fe36a
Rename some "python3" symbols to "py3", as the command name.
Bram Moolenaar <bram@vim.org>
parents:
2340
diff
changeset
|
194 # define ex_py3 ex_script_ni |
4417 | 195 # define ex_py3do ex_ni |
2329
ad2889f48843
Added support for Python 3. (Roland Puntaier)
Bram Moolenaar <bram@vim.org>
parents:
2320
diff
changeset
|
196 # define ex_py3file ex_ni |
ad2889f48843
Added support for Python 3. (Roland Puntaier)
Bram Moolenaar <bram@vim.org>
parents:
2320
diff
changeset
|
197 #endif |
10722
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10656
diff
changeset
|
198 #if !defined(FEAT_PYTHON) && !defined(FEAT_PYTHON3) |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10656
diff
changeset
|
199 # define ex_pyx ex_script_ni |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10656
diff
changeset
|
200 # define ex_pyxdo ex_ni |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10656
diff
changeset
|
201 # define ex_pyxfile ex_ni |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10656
diff
changeset
|
202 #endif |
7 | 203 #ifndef FEAT_TCL |
204 # define ex_tcl ex_script_ni | |
205 # define ex_tcldo ex_ni | |
206 # define ex_tclfile ex_ni | |
207 #endif | |
208 #ifndef FEAT_RUBY | |
209 # define ex_ruby ex_script_ni | |
210 # define ex_rubydo ex_ni | |
211 # define ex_rubyfile ex_ni | |
212 #endif | |
213 #ifndef FEAT_KEYMAP | |
214 # define ex_loadkeymap ex_ni | |
215 #endif | |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
216 static void ex_swapname(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
217 static void ex_syncbind(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
218 static void ex_read(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
219 static void ex_pwd(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
220 static void ex_equal(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
221 static void ex_sleep(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
222 static void ex_winsize(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
223 static void ex_wincmd(exarg_T *eap); |
11 | 224 #if defined(FEAT_GUI) || defined(UNIX) || defined(VMS) || defined(MSWIN) |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
225 static void ex_winpos(exarg_T *eap); |
7 | 226 #else |
227 # define ex_winpos ex_ni | |
228 #endif | |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
229 static void ex_operators(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
230 static void ex_put(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
231 static void ex_copymove(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
232 static void ex_submagic(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
233 static void ex_join(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
234 static void ex_at(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
235 static void ex_bang(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
236 static void ex_undo(exarg_T *eap); |
2214
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
237 #ifdef FEAT_PERSISTENT_UNDO |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
238 static void ex_wundo(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
239 static void ex_rundo(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
240 #endif |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
241 static void ex_redo(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
242 static void ex_later(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
243 static void ex_redir(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
244 static void ex_redrawstatus(exarg_T *eap); |
15396
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
245 static void ex_redrawtabline(exarg_T *eap); |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
246 static void close_redir(void); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
247 static void ex_mark(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
248 static void ex_startinsert(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
249 static void ex_stopinsert(exarg_T *eap); |
7 | 250 #ifdef FEAT_FIND_ID |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
251 static void ex_checkpath(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
252 static void ex_findpat(exarg_T *eap); |
7 | 253 #else |
254 # define ex_findpat ex_ni | |
255 # define ex_checkpath ex_ni | |
256 #endif | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
257 #if defined(FEAT_FIND_ID) && defined(FEAT_QUICKFIX) |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
258 static void ex_psearch(exarg_T *eap); |
7 | 259 #else |
260 # define ex_psearch ex_ni | |
261 #endif | |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
262 static void ex_tag(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
263 static void ex_tag_cmd(exarg_T *eap, char_u *name); |
7 | 264 #ifndef FEAT_EVAL |
17622
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
265 # define ex_break ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
266 # define ex_breakadd ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
267 # define ex_breakdel ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
268 # define ex_breaklist ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
269 # define ex_call ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
270 # define ex_catch ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
271 # define ex_compiler ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
272 # define ex_const ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
273 # define ex_continue ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
274 # define ex_debug ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
275 # define ex_debuggreedy ex_ni |
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 |
17178
40c4cb095d53
patch 8.1.1588: in :let-heredoc line continuation is recognized
Bram Moolenaar <Bram@vim.org>
parents:
17111
diff
changeset
|
408 char_u *(*getline)(int, void *, int, int); |
7 | 409 void *cookie; |
410 }; | |
411 | |
17178
40c4cb095d53
patch 8.1.1588: in :let-heredoc line continuation is recognized
Bram Moolenaar <Bram@vim.org>
parents:
17111
diff
changeset
|
412 static char_u *get_loop_line(int c, void *cookie, int indent, int do_concat); |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
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, |
17178
40c4cb095d53
patch 8.1.1588: in :let-heredoc line continuation is recognized
Bram Moolenaar <Bram@vim.org>
parents:
17111
diff
changeset
|
617 char_u *(*fgetline)(int, void *, int, int), |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
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 |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
633 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
|
634 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
|
635 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
|
636 struct dbg_stuff debug_saved; // saved things for debug mode |
7 | 637 int initial_trylevel; |
638 struct msglist **saved_msg_list = NULL; | |
639 struct msglist *private_msg_list; | |
640 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
641 // "fgetline" and "cookie" passed to do_one_cmd() |
17178
40c4cb095d53
patch 8.1.1588: in :let-heredoc line continuation is recognized
Bram Moolenaar <Bram@vim.org>
parents:
17111
diff
changeset
|
642 char_u *(*cmd_getline)(int, void *, int, int); |
7 | 643 void *cmd_cookie; |
72 | 644 struct loop_cookie cmd_loop_cookie; |
7 | 645 void *real_cookie; |
170 | 646 int getline_is_func; |
7 | 647 #else |
2635 | 648 # define cmd_getline fgetline |
7 | 649 # define cmd_cookie cookie |
650 #endif | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
651 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
|
652 #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
|
653 ESTACK_CHECK_DECLARATION |
7 | 654 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
655 // 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
|
656 // 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
|
657 // 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
|
658 // 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
|
659 // 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
|
660 // BufWritePost autocommands are executed after a write error. |
7 | 661 saved_msg_list = msg_list; |
662 msg_list = &private_msg_list; | |
663 private_msg_list = NULL; | |
664 #endif | |
665 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
666 // 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
|
667 // 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
|
668 // 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
|
669 if (call_depth >= 200 |
8f2191b56d52
commit https://github.com/vim/vim/commit/b094ff4b2be4d8b7364c566a1cc7e27aa4452a50
Christian Brabandt <cb@256bit.org>
parents:
10488
diff
changeset
|
670 #ifdef FEAT_EVAL |
8f2191b56d52
commit https://github.com/vim/vim/commit/b094ff4b2be4d8b7364c566a1cc7e27aa4452a50
Christian Brabandt <cb@256bit.org>
parents:
10488
diff
changeset
|
671 && call_depth >= p_mfd |
8f2191b56d52
commit https://github.com/vim/vim/commit/b094ff4b2be4d8b7364c566a1cc7e27aa4452a50
Christian Brabandt <cb@256bit.org>
parents:
10488
diff
changeset
|
672 #endif |
8f2191b56d52
commit https://github.com/vim/vim/commit/b094ff4b2be4d8b7364c566a1cc7e27aa4452a50
Christian Brabandt <cb@256bit.org>
parents:
10488
diff
changeset
|
673 ) |
7 | 674 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
675 emsg(_("E169: Command too recursive")); |
7 | 676 #ifdef FEAT_EVAL |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
677 // 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
|
678 // 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
|
679 do_errthrow((cstack_T *)NULL, (char_u *)NULL); |
7 | 680 msg_list = saved_msg_list; |
681 #endif | |
682 return FAIL; | |
683 } | |
684 ++call_depth; | |
685 | |
686 #ifdef FEAT_EVAL | |
687 cstack.cs_idx = -1; | |
72 | 688 cstack.cs_looplevel = 0; |
7 | 689 cstack.cs_trylevel = 0; |
690 cstack.cs_emsg_silent_list = NULL; | |
72 | 691 cstack.cs_lflags = 0; |
7 | 692 ga_init2(&lines_ga, (int)sizeof(wcmd_T), 10); |
693 | |
2635 | 694 real_cookie = getline_cookie(fgetline, cookie); |
7 | 695 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
696 // Inside a function use a higher nesting level. |
2635 | 697 getline_is_func = getline_equal(fgetline, cookie, get_func_line); |
170 | 698 if (getline_is_func && ex_nesting_level == func_level(real_cookie)) |
7 | 699 ++ex_nesting_level; |
700 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
701 // 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
|
702 // line and the debug tick for a function or script are stored. |
170 | 703 if (getline_is_func) |
7 | 704 { |
705 fname = func_name(real_cookie); | |
706 breakpoint = func_breakpoint(real_cookie); | |
707 dbg_tick = func_dbg_tick(real_cookie); | |
708 } | |
2635 | 709 else if (getline_equal(fgetline, cookie, getsourceline)) |
7 | 710 { |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18904
diff
changeset
|
711 fname = SOURCING_NAME; |
7 | 712 breakpoint = source_breakpoint(real_cookie); |
713 dbg_tick = source_dbg_tick(real_cookie); | |
714 } | |
715 | |
716 /* | |
717 * Initialize "force_abort" and "suppress_errthrow" at the top level. | |
718 */ | |
719 if (!recursive) | |
720 { | |
721 force_abort = FALSE; | |
722 suppress_errthrow = FALSE; | |
723 } | |
724 | |
725 /* | |
726 * If requested, store and reset the global values controlling the | |
944 | 727 * exception handling (used when debugging). Otherwise clear it to avoid |
728 * a bogus compiler warning when the optimizer uses inline functions... | |
7 | 729 */ |
878 | 730 if (flags & DOCMD_EXCRESET) |
8 | 731 save_dbg_stuff(&debug_saved); |
944 | 732 else |
20007
aadd1cae2ff5
patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
733 CLEAR_FIELD(debug_saved); |
7 | 734 |
735 initial_trylevel = trylevel; | |
736 | |
737 /* | |
738 * "did_throw" will be set to TRUE when an exception is being thrown. | |
739 */ | |
740 did_throw = FALSE; | |
741 #endif | |
742 /* | |
743 * "did_emsg" will be set to TRUE when emsg() is used, in which case we | |
72 | 744 * cancel the whole command line, and any if/endif or loop. |
7 | 745 * If force_abort is set, we cancel everything. |
746 */ | |
747 did_emsg = FALSE; | |
748 | |
749 /* | |
750 * KeyTyped is only set when calling vgetc(). Reset it here when not | |
751 * calling vgetc() (sourced command lines). | |
752 */ | |
2635 | 753 if (!(flags & DOCMD_KEYTYPED) |
754 && !getline_equal(fgetline, cookie, getexline)) | |
7 | 755 KeyTyped = FALSE; |
756 | |
757 /* | |
758 * Continue executing command lines: | |
72 | 759 * - when inside an ":if", ":while" or ":for" |
7 | 760 * - for multiple commands on one line, separated with '|' |
761 * - when repeating until there are no more lines (for ":source") | |
762 */ | |
763 next_cmdline = cmdline; | |
764 do | |
765 { | |
170 | 766 #ifdef FEAT_EVAL |
2635 | 767 getline_is_func = getline_equal(fgetline, cookie, get_func_line); |
170 | 768 #endif |
769 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
770 // stop skipping cmds for an error msg after all endif/while/for |
7 | 771 if (next_cmdline == NULL |
772 #ifdef FEAT_EVAL | |
773 && !force_abort | |
774 && cstack.cs_idx < 0 | |
170 | 775 && !(getline_is_func && func_has_abort(real_cookie)) |
7 | 776 #endif |
777 ) | |
778 did_emsg = FALSE; | |
779 | |
780 /* | |
72 | 781 * 1. If repeating a line in a loop, get a line from lines_ga. |
2635 | 782 * 2. If no line given: Get an allocated line with fgetline(). |
7 | 783 * 3. If a line is given: Make a copy, so we can mess with it. |
784 */ | |
785 | |
786 #ifdef FEAT_EVAL | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
787 // 1. If repeating, get a previous line from lines_ga. |
72 | 788 if (cstack.cs_looplevel > 0 && current_line < lines_ga.ga_len) |
7 | 789 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
790 // 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
|
791 // 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
|
792 VIM_CLEAR(cmdline_copy); |
7 | 793 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
794 // 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
|
795 // try conditional, aborted. |
170 | 796 if (getline_is_func) |
797 { | |
798 # ifdef FEAT_PROFILE | |
788 | 799 if (do_profiling == PROF_YES) |
170 | 800 func_line_end(real_cookie); |
801 # endif | |
802 if (func_has_ended(real_cookie)) | |
803 { | |
804 retval = FAIL; | |
805 break; | |
806 } | |
807 } | |
808 #ifdef FEAT_PROFILE | |
788 | 809 else if (do_profiling == PROF_YES |
2635 | 810 && getline_equal(fgetline, cookie, getsourceline)) |
170 | 811 script_line_end(); |
812 #endif | |
7 | 813 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
814 // Check if a sourced file hit a ":finish" command. |
2635 | 815 if (source_finished(fgetline, cookie)) |
7 | 816 { |
817 retval = FAIL; | |
818 break; | |
819 } | |
820 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
821 // If breakpoints have been added/deleted need to check for it. |
7 | 822 if (breakpoint != NULL && dbg_tick != NULL |
823 && *dbg_tick != debug_tick) | |
824 { | |
825 *breakpoint = dbg_find_breakpoint( | |
2635 | 826 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
|
827 fname, SOURCING_LNUM); |
7 | 828 *dbg_tick = debug_tick; |
829 } | |
830 | |
831 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
|
832 SOURCING_LNUM = ((wcmd_T *)(lines_ga.ga_data))[current_line].lnum; |
7 | 833 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
834 // Did we encounter a breakpoint? |
7 | 835 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
|
836 && *breakpoint <= SOURCING_LNUM) |
7 | 837 { |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18904
diff
changeset
|
838 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
|
839 // Find next breakpoint. |
7 | 840 *breakpoint = dbg_find_breakpoint( |
2635 | 841 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
|
842 fname, SOURCING_LNUM); |
7 | 843 *dbg_tick = debug_tick; |
844 } | |
170 | 845 # ifdef FEAT_PROFILE |
788 | 846 if (do_profiling == PROF_YES) |
170 | 847 { |
848 if (getline_is_func) | |
849 func_line_start(real_cookie); | |
2635 | 850 else if (getline_equal(fgetline, cookie, getsourceline)) |
170 | 851 script_line_start(); |
852 } | |
853 # endif | |
7 | 854 } |
855 | |
72 | 856 if (cstack.cs_looplevel > 0) |
857 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
858 // Inside a while/for loop we need to store the lines and use them |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
859 // again. Pass a different "fgetline" function to do_one_cmd() |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
860 // below, so that it stores lines in or reads them from |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
861 // "lines_ga". Makes it possible to define a function inside a |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
862 // while/for loop. |
72 | 863 cmd_getline = get_loop_line; |
864 cmd_cookie = (void *)&cmd_loop_cookie; | |
865 cmd_loop_cookie.lines_gap = &lines_ga; | |
866 cmd_loop_cookie.current_line = current_line; | |
2635 | 867 cmd_loop_cookie.getline = fgetline; |
72 | 868 cmd_loop_cookie.cookie = cookie; |
869 cmd_loop_cookie.repeating = (current_line < lines_ga.ga_len); | |
7 | 870 } |
871 else | |
872 { | |
2635 | 873 cmd_getline = fgetline; |
7 | 874 cmd_cookie = cookie; |
875 } | |
876 #endif | |
877 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
878 // 2. If no line given, get an allocated line with fgetline(). |
7 | 879 if (next_cmdline == NULL) |
880 { | |
881 /* | |
882 * Need to set msg_didout for the first line after an ":if", | |
883 * otherwise the ":if" will be overwritten. | |
884 */ | |
2635 | 885 if (count == 1 && getline_equal(fgetline, cookie, getexline)) |
7 | 886 msg_didout = TRUE; |
2635 | 887 if (fgetline == NULL || (next_cmdline = fgetline(':', cookie, |
7 | 888 #ifdef FEAT_EVAL |
889 cstack.cs_idx < 0 ? 0 : (cstack.cs_idx + 1) * 2 | |
890 #else | |
891 0 | |
892 #endif | |
17178
40c4cb095d53
patch 8.1.1588: in :let-heredoc line continuation is recognized
Bram Moolenaar <Bram@vim.org>
parents:
17111
diff
changeset
|
893 , TRUE)) == NULL) |
7 | 894 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
895 // 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
|
896 // 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
|
897 // doesn't do this. |
7 | 898 if (KeyTyped && !(flags & DOCMD_REPEAT)) |
899 need_wait_return = FALSE; | |
900 retval = FAIL; | |
901 break; | |
902 } | |
903 used_getline = TRUE; | |
904 | |
905 /* | |
906 * Keep the first typed line. Clear it when more lines are typed. | |
907 */ | |
908 if (flags & DOCMD_KEEPLINE) | |
909 { | |
910 vim_free(repeat_cmdline); | |
911 if (count == 0) | |
912 repeat_cmdline = vim_strsave(next_cmdline); | |
913 else | |
914 repeat_cmdline = NULL; | |
915 } | |
916 } | |
917 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
918 // 3. Make a copy of the command so we can mess with it. |
7 | 919 else if (cmdline_copy == NULL) |
920 { | |
921 next_cmdline = vim_strsave(next_cmdline); | |
922 if (next_cmdline == NULL) | |
923 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
924 emsg(_(e_outofmem)); |
7 | 925 retval = FAIL; |
926 break; | |
927 } | |
928 } | |
929 cmdline_copy = next_cmdline; | |
930 | |
931 #ifdef FEAT_EVAL | |
932 /* | |
72 | 933 * Save the current line when inside a ":while" or ":for", and when |
934 * the command looks like a ":while" or ":for", because we may need it | |
935 * later. When there is a '|' and another command, it is stored | |
936 * separately, because we need to be able to jump back to it from an | |
937 * :endwhile/:endfor. | |
7 | 938 */ |
72 | 939 if (current_line == lines_ga.ga_len |
940 && (cstack.cs_looplevel || has_loop_cmd(next_cmdline))) | |
941 { | |
942 if (store_loop_line(&lines_ga, next_cmdline) == FAIL) | |
7 | 943 { |
944 retval = FAIL; | |
945 break; | |
946 } | |
947 } | |
948 did_endif = FALSE; | |
949 #endif | |
950 | |
951 if (count++ == 0) | |
952 { | |
953 /* | |
954 * All output from the commands is put below each other, without | |
955 * waiting for a return. Don't do this when executing commands | |
956 * from a script or when being called recursive (e.g. for ":e | |
957 * +command file"). | |
958 */ | |
959 if (!(flags & DOCMD_NOWAIT) && !recursive) | |
960 { | |
961 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
|
962 msg_didany = FALSE; // no output yet |
7 | 963 msg_start(); |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
964 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
|
965 ++no_wait_return; // don't wait for return until finished |
7 | 966 ++RedrawingDisabled; |
967 did_inc = TRUE; | |
968 } | |
969 } | |
970 | |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18904
diff
changeset
|
971 if (p_verbose >= 15 && SOURCING_NAME != NULL) |
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18904
diff
changeset
|
972 msg_verbose_cmd(SOURCING_LNUM, cmdline_copy); |
7 | 973 |
974 /* | |
975 * 2. Execute one '|' separated command. | |
976 * do_one_cmd() will return NULL if there is no trailing '|'. | |
977 * "cmdline_copy" can change, e.g. for '%' and '#' expansion. | |
978 */ | |
979 ++recursive; | |
980 next_cmdline = do_one_cmd(&cmdline_copy, flags & DOCMD_VERBOSE, | |
981 #ifdef FEAT_EVAL | |
982 &cstack, | |
983 #endif | |
984 cmd_getline, cmd_cookie); | |
985 --recursive; | |
986 | |
987 #ifdef FEAT_EVAL | |
72 | 988 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
|
989 // 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
|
990 // incremented when defining a function. |
72 | 991 current_line = cmd_loop_cookie.current_line; |
7 | 992 #endif |
993 | |
994 if (next_cmdline == NULL) | |
995 { | |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13221
diff
changeset
|
996 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
|
997 |
7 | 998 /* |
999 * If the command was typed, remember it for the ':' register. | |
1000 * Do this AFTER executing the command to make :@: work. | |
1001 */ | |
2635 | 1002 if (getline_equal(fgetline, cookie, getexline) |
7 | 1003 && new_last_cmdline != NULL) |
1004 { | |
1005 vim_free(last_cmdline); | |
1006 last_cmdline = new_last_cmdline; | |
1007 new_last_cmdline = NULL; | |
1008 } | |
1009 } | |
1010 else | |
1011 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1012 // 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
|
1013 // next do_one_cmd() |
1619 | 1014 STRMOVE(cmdline_copy, next_cmdline); |
7 | 1015 next_cmdline = cmdline_copy; |
1016 } | |
1017 | |
1018 | |
1019 #ifdef FEAT_EVAL | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1020 // reset did_emsg for a function that is not aborted by an error |
7 | 1021 if (did_emsg && !force_abort |
2635 | 1022 && getline_equal(fgetline, cookie, get_func_line) |
7 | 1023 && !func_has_abort(real_cookie)) |
1024 did_emsg = FALSE; | |
1025 | |
72 | 1026 if (cstack.cs_looplevel > 0) |
7 | 1027 { |
1028 ++current_line; | |
1029 | |
1030 /* | |
72 | 1031 * An ":endwhile", ":endfor" and ":continue" is handled here. |
1032 * If we were executing commands, jump back to the ":while" or | |
1033 * ":for". | |
1034 * If we were not executing commands, decrement cs_looplevel. | |
7 | 1035 */ |
72 | 1036 if (cstack.cs_lflags & (CSL_HAD_CONT | CSL_HAD_ENDLOOP)) |
1037 { | |
1038 cstack.cs_lflags &= ~(CSL_HAD_CONT | CSL_HAD_ENDLOOP); | |
1039 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1040 // 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
|
1041 // 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
|
1042 // 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
|
1043 // cause a crash. |
7 | 1044 if (!did_emsg && !got_int && !did_throw |
1045 && cstack.cs_idx >= 0 | |
72 | 1046 && (cstack.cs_flags[cstack.cs_idx] |
1047 & (CSF_WHILE | CSF_FOR)) | |
7 | 1048 && cstack.cs_line[cstack.cs_idx] >= 0 |
1049 && (cstack.cs_flags[cstack.cs_idx] & CSF_ACTIVE)) | |
1050 { | |
1051 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
|
1052 // remember we jumped there |
72 | 1053 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
|
1054 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
|
1055 |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1056 // 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
|
1057 // or ":for". |
7 | 1058 if (breakpoint != NULL) |
1059 { | |
1060 *breakpoint = dbg_find_breakpoint( | |
2635 | 1061 getline_equal(fgetline, cookie, getsourceline), |
7 | 1062 fname, |
1063 ((wcmd_T *)lines_ga.ga_data)[current_line].lnum-1); | |
1064 *dbg_tick = debug_tick; | |
1065 } | |
1066 } | |
72 | 1067 else |
7 | 1068 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1069 // can only get here with ":endwhile" or ":endfor" |
7 | 1070 if (cstack.cs_idx >= 0) |
77 | 1071 rewind_conditionals(&cstack, cstack.cs_idx - 1, |
1072 CSF_WHILE | CSF_FOR, &cstack.cs_looplevel); | |
7 | 1073 } |
1074 } | |
1075 | |
1076 /* | |
72 | 1077 * For a ":while" or ":for" we need to remember the line number. |
7 | 1078 */ |
72 | 1079 else if (cstack.cs_lflags & CSL_HAD_LOOP) |
1080 { | |
1081 cstack.cs_lflags &= ~CSL_HAD_LOOP; | |
7 | 1082 cstack.cs_line[cstack.cs_idx] = current_line - 1; |
1083 } | |
1084 } | |
1085 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1086 // 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
|
1087 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
|
1088 { |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18904
diff
changeset
|
1089 *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
|
1090 *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
|
1091 } |
69278c25429d
patch 8.0.1505: debugger can't break on a condition
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
1092 |
7 | 1093 /* |
1094 * When not inside any ":while" loop, clear remembered lines. | |
1095 */ | |
72 | 1096 if (cstack.cs_looplevel == 0) |
7 | 1097 { |
1098 if (lines_ga.ga_len > 0) | |
1099 { | |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18904
diff
changeset
|
1100 SOURCING_LNUM = |
7 | 1101 ((wcmd_T *)lines_ga.ga_data)[lines_ga.ga_len - 1].lnum; |
1102 free_cmdlines(&lines_ga); | |
1103 } | |
1104 current_line = 0; | |
1105 } | |
1106 | |
1107 /* | |
72 | 1108 * A ":finally" makes did_emsg, got_int, and did_throw pending for |
1109 * being restored at the ":endtry". Reset them here and set the | |
1110 * ACTIVE and FINALLY flags, so that the finally clause gets executed. | |
1111 * This includes the case where a missing ":endif", ":endwhile" or | |
1112 * ":endfor" was detected by the ":finally" itself. | |
7 | 1113 */ |
72 | 1114 if (cstack.cs_lflags & CSL_HAD_FINA) |
1115 { | |
1116 cstack.cs_lflags &= ~CSL_HAD_FINA; | |
1117 report_make_pending(cstack.cs_pending[cstack.cs_idx] | |
1118 & (CSTP_ERROR | CSTP_INTERRUPT | CSTP_THROW), | |
7 | 1119 did_throw ? (void *)current_exception : NULL); |
1120 did_emsg = got_int = did_throw = FALSE; | |
1121 cstack.cs_flags[cstack.cs_idx] |= CSF_ACTIVE | CSF_FINALLY; | |
1122 } | |
1123 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1124 // 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
|
1125 // within this loop. |
7 | 1126 trylevel = initial_trylevel + cstack.cs_trylevel; |
1127 | |
1128 /* | |
1190 | 1129 * If the outermost try conditional (across function calls and sourced |
7 | 1130 * files) is aborted because of an error, an interrupt, or an uncaught |
1131 * exception, cancel everything. If it is left normally, reset | |
1132 * force_abort to get the non-EH compatible abortion behavior for | |
1133 * the rest of the script. | |
1134 */ | |
1135 if (trylevel == 0 && !did_emsg && !got_int && !did_throw) | |
1136 force_abort = FALSE; | |
1137 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1138 // Convert an interrupt to an exception if appropriate. |
7 | 1139 (void)do_intthrow(&cstack); |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1140 #endif // FEAT_EVAL |
7 | 1141 |
1142 } | |
1143 /* | |
1144 * Continue executing command lines when: | |
1145 * - no CTRL-C typed, no aborting error, no exception thrown or try | |
1146 * conditionals need to be checked for executing finally clauses or | |
1147 * catching an interrupt exception | |
1148 * - didn't get an error message or lines are not typed | |
72 | 1149 * - there is a command after '|', inside a :if, :while, :for or :try, or |
7 | 1150 * looping for ":source" command or function call. |
1151 */ | |
1152 while (!((got_int | |
1153 #ifdef FEAT_EVAL | |
1154 || (did_emsg && force_abort) || did_throw | |
1155 #endif | |
1156 ) | |
1157 #ifdef FEAT_EVAL | |
1158 && cstack.cs_trylevel == 0 | |
1159 #endif | |
1160 ) | |
3757 | 1161 && !(did_emsg |
1162 #ifdef FEAT_EVAL | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1163 // 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
|
1164 // 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
|
1165 // the :endtry to be missed. |
3757 | 1166 && (cstack.cs_trylevel == 0 || did_emsg_syntax) |
1167 #endif | |
1168 && used_getline | |
2635 | 1169 && (getline_equal(fgetline, cookie, getexmodeline) |
1170 || getline_equal(fgetline, cookie, getexline))) | |
7 | 1171 && (next_cmdline != NULL |
1172 #ifdef FEAT_EVAL | |
1173 || cstack.cs_idx >= 0 | |
1174 #endif | |
1175 || (flags & DOCMD_REPEAT))); | |
1176 | |
1177 vim_free(cmdline_copy); | |
3757 | 1178 did_emsg_syntax = FALSE; |
7 | 1179 #ifdef FEAT_EVAL |
1180 free_cmdlines(&lines_ga); | |
1181 ga_clear(&lines_ga); | |
1182 | |
1183 if (cstack.cs_idx >= 0) | |
1184 { | |
1185 /* | |
1186 * If a sourced file or executed function ran to its end, report the | |
1187 * unclosed conditional. | |
1188 */ | |
1189 if (!got_int && !did_throw | |
2635 | 1190 && ((getline_equal(fgetline, cookie, getsourceline) |
1191 && !source_finished(fgetline, cookie)) | |
1192 || (getline_equal(fgetline, cookie, get_func_line) | |
7 | 1193 && !func_has_ended(real_cookie)))) |
1194 { | |
1195 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
|
1196 emsg(_(e_endtry)); |
7 | 1197 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
|
1198 emsg(_(e_endwhile)); |
72 | 1199 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
|
1200 emsg(_(e_endfor)); |
7 | 1201 else |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
1202 emsg(_(e_endif)); |
7 | 1203 } |
1204 | |
1205 /* | |
1206 * Reset "trylevel" in case of a ":finish" or ":return" or a missing | |
1207 * ":endtry" in a sourced file or executed function. If the try | |
1208 * conditional is in its finally clause, ignore anything pending. | |
1209 * If it is in a catch clause, finish the caught exception. | |
77 | 1210 * Also cleanup any "cs_forinfo" structures. |
7 | 1211 */ |
1212 do | |
77 | 1213 { |
1214 int idx = cleanup_conditionals(&cstack, 0, TRUE); | |
1215 | |
111 | 1216 if (idx >= 0) |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1217 --idx; // remove try block not in its finally clause |
77 | 1218 rewind_conditionals(&cstack, idx, CSF_WHILE | CSF_FOR, |
1219 &cstack.cs_looplevel); | |
1220 } | |
1221 while (cstack.cs_idx >= 0); | |
7 | 1222 trylevel = initial_trylevel; |
1223 } | |
1224 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1225 // 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
|
1226 // 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
|
1227 // exception, do this now after rewinding the cstack. |
2635 | 1228 do_errthrow(&cstack, getline_equal(fgetline, cookie, get_func_line) |
7 | 1229 ? (char_u *)"endfunction" : (char_u *)NULL); |
1230 | |
1231 if (trylevel == 0) | |
1232 { | |
1233 /* | |
1234 * When an exception is being thrown out of the outermost try | |
1235 * conditional, discard the uncaught exception, disable the conversion | |
1236 * of interrupts or errors to exceptions, and ensure that no more | |
1237 * commands are executed. | |
1238 */ | |
1239 if (did_throw) | |
1240 { | |
1241 void *p = NULL; | |
1242 struct msglist *messages = NULL, *next; | |
1243 | |
1244 /* | |
1245 * If the uncaught exception is a user exception, report it as an | |
1246 * error. If it is an error exception, display the saved error | |
1247 * message now. For an interrupt exception, do nothing; the | |
1248 * interrupt message is given elsewhere. | |
1249 */ | |
1250 switch (current_exception->type) | |
1251 { | |
1252 case ET_USER: | |
272 | 1253 vim_snprintf((char *)IObuff, IOSIZE, |
1254 _("E605: Exception not caught: %s"), | |
7 | 1255 current_exception->value); |
1256 p = vim_strsave(IObuff); | |
1257 break; | |
1258 case ET_ERROR: | |
1259 messages = current_exception->messages; | |
1260 current_exception->messages = NULL; | |
1261 break; | |
1262 case ET_INTERRUPT: | |
1263 break; | |
1264 } | |
1265 | |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18904
diff
changeset
|
1266 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
|
1267 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
|
1268 ESTACK_CHECK_SETUP |
7 | 1269 current_exception->throw_name = NULL; |
1270 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1271 discard_current_exception(); // uses IObuff if 'verbose' |
7 | 1272 suppress_errthrow = TRUE; |
1273 force_abort = TRUE; | |
1274 | |
1275 if (messages != NULL) | |
1276 { | |
1277 do | |
1278 { | |
1279 next = messages->next; | |
1280 emsg(messages->msg); | |
1281 vim_free(messages->msg); | |
1282 vim_free(messages); | |
1283 messages = next; | |
1284 } | |
1285 while (messages != NULL); | |
1286 } | |
1287 else if (p != NULL) | |
1288 { | |
15490
98c35d312987
patch 8.1.0753: printf format not checked for semsg()
Bram Moolenaar <Bram@vim.org>
parents:
15488
diff
changeset
|
1289 emsg(p); |
7 | 1290 vim_free(p); |
1291 } | |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18904
diff
changeset
|
1292 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
|
1293 ESTACK_CHECK_NOW |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18904
diff
changeset
|
1294 estack_pop(); |
7 | 1295 } |
1296 | |
1297 /* | |
1298 * On an interrupt or an aborting error not converted to an exception, | |
1299 * 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
|
1300 * converted anymore, here.) This enables also the interrupt message |
7 | 1301 * when force_abort is set and did_emsg unset in case of an interrupt |
1302 * from a finally clause after an error. | |
1303 */ | |
1304 else if (got_int || (did_emsg && force_abort)) | |
1305 suppress_errthrow = TRUE; | |
1306 } | |
1307 | |
1308 /* | |
1309 * The current cstack will be freed when do_cmdline() returns. An uncaught | |
1310 * exception will have to be rethrown in the previous cstack. If a function | |
1311 * has just returned or a script file was just finished and the previous | |
1312 * cstack belongs to the same function or, respectively, script file, it | |
1313 * will have to be checked for finally clauses to be executed due to the | |
1314 * ":return" or ":finish". This is done in do_one_cmd(). | |
1315 */ | |
1316 if (did_throw) | |
1317 need_rethrow = TRUE; | |
2635 | 1318 if ((getline_equal(fgetline, cookie, getsourceline) |
7 | 1319 && ex_nesting_level > source_level(real_cookie)) |
2635 | 1320 || (getline_equal(fgetline, cookie, get_func_line) |
7 | 1321 && ex_nesting_level > func_level(real_cookie) + 1)) |
1322 { | |
1323 if (!did_throw) | |
1324 check_cstack = TRUE; | |
1325 } | |
1326 else | |
1327 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1328 // When leaving a function, reduce nesting level. |
2635 | 1329 if (getline_equal(fgetline, cookie, get_func_line)) |
7 | 1330 --ex_nesting_level; |
1331 /* | |
1332 * Go to debug mode when returning from a function in which we are | |
1333 * single-stepping. | |
1334 */ | |
2635 | 1335 if ((getline_equal(fgetline, cookie, getsourceline) |
1336 || getline_equal(fgetline, cookie, get_func_line)) | |
7 | 1337 && ex_nesting_level + 1 <= debug_break_level) |
2635 | 1338 do_debug(getline_equal(fgetline, cookie, getsourceline) |
7 | 1339 ? (char_u *)_("End of sourced file") |
1340 : (char_u *)_("End of function")); | |
1341 } | |
1342 | |
1343 /* | |
1344 * Restore the exception environment (done after returning from the | |
1345 * debugger). | |
1346 */ | |
1347 if (flags & DOCMD_EXCRESET) | |
8 | 1348 restore_dbg_stuff(&debug_saved); |
7 | 1349 |
1350 msg_list = saved_msg_list; | |
19685
d64f403289db
patch 8.2.0399: various memory leaks
Bram Moolenaar <Bram@vim.org>
parents:
19621
diff
changeset
|
1351 |
d64f403289db
patch 8.2.0399: various memory leaks
Bram Moolenaar <Bram@vim.org>
parents:
19621
diff
changeset
|
1352 // Cleanup if "cs_emsg_silent_list" remains. |
d64f403289db
patch 8.2.0399: various memory leaks
Bram Moolenaar <Bram@vim.org>
parents:
19621
diff
changeset
|
1353 if (cstack.cs_emsg_silent_list != NULL) |
d64f403289db
patch 8.2.0399: various memory leaks
Bram Moolenaar <Bram@vim.org>
parents:
19621
diff
changeset
|
1354 { |
d64f403289db
patch 8.2.0399: various memory leaks
Bram Moolenaar <Bram@vim.org>
parents:
19621
diff
changeset
|
1355 eslist_T *elem, *temp; |
d64f403289db
patch 8.2.0399: various memory leaks
Bram Moolenaar <Bram@vim.org>
parents:
19621
diff
changeset
|
1356 |
d64f403289db
patch 8.2.0399: various memory leaks
Bram Moolenaar <Bram@vim.org>
parents:
19621
diff
changeset
|
1357 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
|
1358 { |
d64f403289db
patch 8.2.0399: various memory leaks
Bram Moolenaar <Bram@vim.org>
parents:
19621
diff
changeset
|
1359 temp = elem->next; |
d64f403289db
patch 8.2.0399: various memory leaks
Bram Moolenaar <Bram@vim.org>
parents:
19621
diff
changeset
|
1360 vim_free(elem); |
d64f403289db
patch 8.2.0399: various memory leaks
Bram Moolenaar <Bram@vim.org>
parents:
19621
diff
changeset
|
1361 } |
d64f403289db
patch 8.2.0399: various memory leaks
Bram Moolenaar <Bram@vim.org>
parents:
19621
diff
changeset
|
1362 } |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1363 #endif // FEAT_EVAL |
7 | 1364 |
1365 /* | |
1366 * If there was too much output to fit on the command line, ask the user to | |
1367 * hit return before redrawing the screen. With the ":global" command we do | |
1368 * this only once after the command is finished. | |
1369 */ | |
1370 if (did_inc) | |
1371 { | |
1372 --RedrawingDisabled; | |
1373 --no_wait_return; | |
1374 msg_scroll = FALSE; | |
1375 | |
1376 /* | |
1377 * When just finished an ":if"-":else" which was typed, no need to | |
1378 * wait for hit-return. Also for an error situation. | |
1379 */ | |
1380 if (retval == FAIL | |
1381 #ifdef FEAT_EVAL | |
1382 || (did_endif && KeyTyped && !did_emsg) | |
1383 #endif | |
1384 ) | |
1385 { | |
1386 need_wait_return = FALSE; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1387 msg_didany = FALSE; // don't wait when restarting edit |
7 | 1388 } |
1389 else if (need_wait_return) | |
1390 { | |
1391 /* | |
1392 * The msg_start() above clears msg_didout. The wait_return we do | |
1393 * here should not overwrite the command that may be shown before | |
1394 * doing that. | |
1395 */ | |
1396 msg_didout |= msg_didout_before_start; | |
1397 wait_return(FALSE); | |
1398 } | |
1399 } | |
1400 | |
3976 | 1401 #ifdef FEAT_EVAL |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1402 did_endif = FALSE; // in case do_cmdline used recursively |
3976 | 1403 #else |
7 | 1404 /* |
1405 * Reset if_level, in case a sourced script file contains more ":if" than | |
1406 * ":endif" (could be ":if x | foo | endif"). | |
1407 */ | |
1408 if_level = 0; | |
3972 | 1409 #endif |
3963 | 1410 |
7 | 1411 --call_depth; |
1412 return retval; | |
1413 } | |
1414 | |
1415 #ifdef FEAT_EVAL | |
1416 /* | |
72 | 1417 * Obtain a line when inside a ":while" or ":for" loop. |
7 | 1418 */ |
1419 static char_u * | |
17178
40c4cb095d53
patch 8.1.1588: in :let-heredoc line continuation is recognized
Bram Moolenaar <Bram@vim.org>
parents:
17111
diff
changeset
|
1420 get_loop_line(int c, void *cookie, int indent, int do_concat) |
7 | 1421 { |
72 | 1422 struct loop_cookie *cp = (struct loop_cookie *)cookie; |
7 | 1423 wcmd_T *wp; |
1424 char_u *line; | |
1425 | |
1426 if (cp->current_line + 1 >= cp->lines_gap->ga_len) | |
1427 { | |
1428 if (cp->repeating) | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1429 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
|
1430 |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1431 // First time inside the ":while"/":for": get line normally. |
7 | 1432 if (cp->getline == NULL) |
17178
40c4cb095d53
patch 8.1.1588: in :let-heredoc line continuation is recognized
Bram Moolenaar <Bram@vim.org>
parents:
17111
diff
changeset
|
1433 line = getcmdline(c, 0L, indent, do_concat); |
7 | 1434 else |
17178
40c4cb095d53
patch 8.1.1588: in :let-heredoc line continuation is recognized
Bram Moolenaar <Bram@vim.org>
parents:
17111
diff
changeset
|
1435 line = cp->getline(c, cp->cookie, indent, do_concat); |
857 | 1436 if (line != NULL && store_loop_line(cp->lines_gap, line) == OK) |
7 | 1437 ++cp->current_line; |
1438 | |
1439 return line; | |
1440 } | |
1441 | |
1442 KeyTyped = FALSE; | |
1443 ++cp->current_line; | |
1444 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
|
1445 SOURCING_LNUM = wp->lnum; |
7 | 1446 return vim_strsave(wp->line); |
1447 } | |
1448 | |
1449 /* | |
1450 * Store a line in "gap" so that a ":while" loop can execute it again. | |
1451 */ | |
1452 static int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
1453 store_loop_line(garray_T *gap, char_u *line) |
7 | 1454 { |
1455 if (ga_grow(gap, 1) == FAIL) | |
1456 return FAIL; | |
1457 ((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
|
1458 ((wcmd_T *)(gap->ga_data))[gap->ga_len].lnum = SOURCING_LNUM; |
7 | 1459 ++gap->ga_len; |
1460 return OK; | |
1461 } | |
1462 | |
1463 /* | |
72 | 1464 * Free the lines stored for a ":while" or ":for" loop. |
7 | 1465 */ |
1466 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
1467 free_cmdlines(garray_T *gap) |
7 | 1468 { |
1469 while (gap->ga_len > 0) | |
1470 { | |
1471 vim_free(((wcmd_T *)(gap->ga_data))[gap->ga_len - 1].line); | |
1472 --gap->ga_len; | |
1473 } | |
1474 } | |
1475 #endif | |
1476 | |
1477 /* | |
944 | 1478 * If "fgetline" is get_loop_line(), return TRUE if the getline it uses equals |
1479 * "func". * Otherwise return TRUE when "fgetline" equals "func". | |
7 | 1480 */ |
1481 int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
1482 getline_equal( |
17178
40c4cb095d53
patch 8.1.1588: in :let-heredoc line continuation is recognized
Bram Moolenaar <Bram@vim.org>
parents:
17111
diff
changeset
|
1483 char_u *(*fgetline)(int, void *, int, int), |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1484 void *cookie UNUSED, // argument for fgetline() |
17178
40c4cb095d53
patch 8.1.1588: in :let-heredoc line continuation is recognized
Bram Moolenaar <Bram@vim.org>
parents:
17111
diff
changeset
|
1485 char_u *(*func)(int, void *, int, int)) |
7 | 1486 { |
1487 #ifdef FEAT_EVAL | |
17178
40c4cb095d53
patch 8.1.1588: in :let-heredoc line continuation is recognized
Bram Moolenaar <Bram@vim.org>
parents:
17111
diff
changeset
|
1488 char_u *(*gp)(int, void *, int, int); |
72 | 1489 struct loop_cookie *cp; |
1490 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1491 // 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
|
1492 // 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
|
1493 // nested several levels. |
944 | 1494 gp = fgetline; |
72 | 1495 cp = (struct loop_cookie *)cookie; |
1496 while (gp == get_loop_line) | |
7 | 1497 { |
1498 gp = cp->getline; | |
1499 cp = cp->cookie; | |
1500 } | |
1501 return gp == func; | |
1502 #else | |
944 | 1503 return fgetline == func; |
7 | 1504 #endif |
1505 } | |
1506 | |
1507 /* | |
944 | 1508 * If "fgetline" is get_loop_line(), return the cookie used by the original |
7 | 1509 * getline function. Otherwise return "cookie". |
1510 */ | |
1511 void * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
1512 getline_cookie( |
17178
40c4cb095d53
patch 8.1.1588: in :let-heredoc line continuation is recognized
Bram Moolenaar <Bram@vim.org>
parents:
17111
diff
changeset
|
1513 char_u *(*fgetline)(int, void *, int, int) UNUSED, |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1514 void *cookie) // argument for fgetline() |
7 | 1515 { |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
1516 #ifdef FEAT_EVAL |
17178
40c4cb095d53
patch 8.1.1588: in :let-heredoc line continuation is recognized
Bram Moolenaar <Bram@vim.org>
parents:
17111
diff
changeset
|
1517 char_u *(*gp)(int, void *, int, int); |
72 | 1518 struct loop_cookie *cp; |
1519 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1520 // 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
|
1521 // 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
|
1522 // several levels. |
944 | 1523 gp = fgetline; |
72 | 1524 cp = (struct loop_cookie *)cookie; |
1525 while (gp == get_loop_line) | |
7 | 1526 { |
1527 gp = cp->getline; | |
1528 cp = cp->cookie; | |
1529 } | |
1530 return cp; | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
1531 #else |
7 | 1532 return cookie; |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
1533 #endif |
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
1534 } |
7 | 1535 |
6398 | 1536 |
1537 /* | |
1538 * Helper function to apply an offset for buffer commands, i.e. ":bdelete", | |
1539 * ":bwipeout", etc. | |
1540 * Returns the buffer number. | |
1541 */ | |
1542 static int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
1543 compute_buffer_local_count(int addr_type, int lnum, int offset) |
6398 | 1544 { |
1545 buf_T *buf; | |
6417 | 1546 buf_T *nextbuf; |
6398 | 1547 int count = offset; |
1548 | |
1549 buf = firstbuf; | |
1550 while (buf->b_next != NULL && buf->b_fnum < lnum) | |
1551 buf = buf->b_next; | |
1552 while (count != 0) | |
1553 { | |
6417 | 1554 count += (offset < 0) ? 1 : -1; |
1555 nextbuf = (offset < 0) ? buf->b_prev : buf->b_next; | |
1556 if (nextbuf == NULL) | |
6398 | 1557 break; |
6417 | 1558 buf = nextbuf; |
6398 | 1559 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
|
1560 // skip over unloaded buffers |
6417 | 1561 while (buf->b_ml.ml_mfp == NULL) |
1562 { | |
1563 nextbuf = (offset < 0) ? buf->b_prev : buf->b_next; | |
1564 if (nextbuf == NULL) | |
1565 break; | |
1566 buf = nextbuf; | |
1567 } | |
1568 } | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1569 // we might have gone too far, last buffer is not loadedd |
6417 | 1570 if (addr_type == ADDR_LOADED_BUFFERS) |
1571 while (buf->b_ml.ml_mfp == NULL) | |
1572 { | |
1573 nextbuf = (offset >= 0) ? buf->b_prev : buf->b_next; | |
1574 if (nextbuf == NULL) | |
1575 break; | |
1576 buf = nextbuf; | |
1577 } | |
6398 | 1578 return buf->b_fnum; |
1579 } | |
1580 | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
1581 /* |
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
1582 * 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
|
1583 * 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
|
1584 */ |
6409 | 1585 static int |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
1586 current_win_nr(win_T *win) |
6409 | 1587 { |
1588 win_T *wp; | |
1589 int nr = 0; | |
1590 | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9538
diff
changeset
|
1591 FOR_ALL_WINDOWS(wp) |
6409 | 1592 { |
1593 ++nr; | |
1594 if (wp == win) | |
1595 break; | |
1596 } | |
1597 return nr; | |
1598 } | |
1599 | |
1600 static int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
1601 current_tab_nr(tabpage_T *tab) |
6409 | 1602 { |
1603 tabpage_T *tp; | |
1604 int nr = 0; | |
1605 | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9538
diff
changeset
|
1606 FOR_ALL_TABPAGES(tp) |
6409 | 1607 { |
1608 ++nr; | |
1609 if (tp == tab) | |
1610 break; | |
1611 } | |
1612 return nr; | |
1613 } | |
1614 | |
1615 # define CURRENT_WIN_NR current_win_nr(curwin) | |
1616 # define LAST_WIN_NR current_win_nr(NULL) | |
1617 # define CURRENT_TAB_NR current_tab_nr(curtab) | |
1618 # define LAST_TAB_NR current_tab_nr(NULL) | |
6398 | 1619 |
7 | 1620 /* |
1621 * Execute one Ex command. | |
1622 * | |
1623 * If 'sourcing' is TRUE, the command will be included in the error message. | |
1624 * | |
1625 * 1. skip comment lines and leading space | |
1626 * 2. handle command modifiers | |
6400 | 1627 * 3. find the command |
6398 | 1628 * 4. parse range |
6400 | 1629 * 5. Parse the command. |
6398 | 1630 * 6. parse arguments |
1631 * 7. switch on command name | |
7 | 1632 * |
944 | 1633 * Note: "fgetline" can be NULL. |
7 | 1634 * |
1635 * This function may be called recursively! | |
1636 */ | |
1637 #if (_MSC_VER == 1200) | |
1638 /* | |
8 | 1639 * Avoid optimisation bug in VC++ version 6.0 |
7 | 1640 */ |
128 | 1641 #pragma optimize( "g", off ) |
7 | 1642 #endif |
1643 static char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
1644 do_one_cmd( |
18904
2bdc2e1f6e1f
patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents:
18849
diff
changeset
|
1645 char_u **cmdlinep, |
2bdc2e1f6e1f
patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents:
18849
diff
changeset
|
1646 int sourcing, |
7 | 1647 #ifdef FEAT_EVAL |
18904
2bdc2e1f6e1f
patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents:
18849
diff
changeset
|
1648 cstack_T *cstack, |
2bdc2e1f6e1f
patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents:
18849
diff
changeset
|
1649 #endif |
2bdc2e1f6e1f
patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents:
18849
diff
changeset
|
1650 char_u *(*fgetline)(int, void *, int, int), |
2bdc2e1f6e1f
patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents:
18849
diff
changeset
|
1651 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
|
1652 { |
2bdc2e1f6e1f
patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents:
18849
diff
changeset
|
1653 char_u *p; |
2bdc2e1f6e1f
patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents:
18849
diff
changeset
|
1654 linenr_T lnum; |
2bdc2e1f6e1f
patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents:
18849
diff
changeset
|
1655 long n; |
2bdc2e1f6e1f
patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents:
18849
diff
changeset
|
1656 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
|
1657 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
|
1658 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
|
1659 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
|
1660 cmdmod_T save_cmdmod; |
2bdc2e1f6e1f
patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents:
18849
diff
changeset
|
1661 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
|
1662 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
|
1663 char_u *cmd; |
19497
639b1d672757
patch 8.2.0306: Vim9: :substitute(pat(repl does not work in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
19481
diff
changeset
|
1664 #ifdef FEAT_EVAL |
639b1d672757
patch 8.2.0306: Vim9: :substitute(pat(repl does not work in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
19481
diff
changeset
|
1665 int starts_with_colon; |
639b1d672757
patch 8.2.0306: Vim9: :substitute(pat(repl does not work in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
19481
diff
changeset
|
1666 #endif |
7 | 1667 |
20007
aadd1cae2ff5
patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
1668 CLEAR_FIELD(ea); |
7 | 1669 ea.line1 = 1; |
1670 ea.line2 = 1; | |
1671 #ifdef FEAT_EVAL | |
1672 ++ex_nesting_level; | |
1673 #endif | |
1674 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1675 // When the last file has not been edited :q has to be typed twice. |
7 | 1676 if (quitmore |
1677 #ifdef FEAT_EVAL | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1678 // avoid that a function call in 'statusline' does this |
944 | 1679 && !getline_equal(fgetline, cookie, get_func_line) |
4133 | 1680 #endif |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1681 // 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
|
1682 && !getline_equal(fgetline, cookie, getnextac)) |
7 | 1683 --quitmore; |
1684 | |
1685 /* | |
1686 * Reset browse, confirm, etc.. They are restored when returning, for | |
1687 * recursive calls. | |
1688 */ | |
1689 save_cmdmod = cmdmod; | |
1690 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1691 // "#!anything" is handled like a comment. |
930 | 1692 if ((*cmdlinep)[0] == '#' && (*cmdlinep)[1] == '!') |
1693 goto doend; | |
1694 | |
18297
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
1695 if (p_verbose >= 16) |
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
1696 msg_verbose_cmd(0, *cmdlinep); |
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
1697 |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
1698 /* |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
1699 * 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
|
1700 * 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
|
1701 */ |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
1702 // The "ea" structure holds the arguments that can be used. |
7 | 1703 ea.cmd = *cmdlinep; |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
1704 ea.cmdlinep = cmdlinep; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
1705 ea.getline = fgetline; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
1706 ea.cookie = cookie; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
1707 #ifdef FEAT_EVAL |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
1708 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
|
1709 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
|
1710 #endif |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
1711 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
|
1712 goto doend; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
1713 |
9941
e975914c17e9
commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
9927
diff
changeset
|
1714 after_modifier = ea.cmd; |
7 | 1715 |
1716 #ifdef FEAT_EVAL | |
1717 ea.skip = did_emsg || got_int || did_throw || (cstack->cs_idx >= 0 | |
1718 && !(cstack->cs_flags[cstack->cs_idx] & CSF_ACTIVE)); | |
1719 #else | |
1720 ea.skip = (if_level > 0); | |
1721 #endif | |
1722 | |
1723 /* | |
6398 | 1724 * 3. Skip over the range to find the command. Let "p" point to after it. |
1725 * | |
1726 * We need the command to know what kind of range it uses. | |
1727 */ | |
1728 cmd = ea.cmd; | |
1729 ea.cmd = skip_range(ea.cmd, NULL); | |
1730 if (*ea.cmd == '*' && vim_strchr(p_cpo, CPO_STAR) == NULL) | |
1731 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
|
1732 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
1733 #ifdef FEAT_EVAL |
19497
639b1d672757
patch 8.2.0306: Vim9: :substitute(pat(repl does not work in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
19481
diff
changeset
|
1734 if (current_sctx.sc_version == SCRIPT_VERSION_VIM9 && !starts_with_colon) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
1735 p = find_ex_command(&ea, NULL, lookup_scriptvar, NULL); |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
1736 else |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
1737 #endif |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
1738 p = find_ex_command(&ea, NULL, NULL, NULL); |
6398 | 1739 |
14591
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1740 #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
|
1741 # 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
|
1742 // 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
|
1743 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
|
1744 && (!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
|
1745 && (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
|
1746 { |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1747 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
|
1748 |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1749 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
|
1750 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
|
1751 && (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
|
1752 && !(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
|
1753 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
|
1754 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
|
1755 && !(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
|
1756 & (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
|
1757 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
|
1758 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
|
1759 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
|
1760 && 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
|
1761 && 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
|
1762 && 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
|
1763 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
|
1764 |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1765 if (!skip) |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1766 { |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1767 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
|
1768 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
|
1769 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
|
1770 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
|
1771 } |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1772 } |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1773 # endif |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1774 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1775 // 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
|
1776 // 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
|
1777 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
|
1778 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
|
1779 { |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1780 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
|
1781 (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
|
1782 } |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1783 #endif |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1784 |
6398 | 1785 /* |
1786 * 4. parse a range specifier of the form: addr [,addr] [;addr] .. | |
7 | 1787 * |
1788 * where 'addr' is: | |
1789 * | |
1790 * % (entire file) | |
1791 * $ [+-NUM] | |
1792 * 'x [+-NUM] (where x denotes a currently defined mark) | |
1793 * . [+-NUM] | |
1794 * [+-NUM].. | |
1795 * NUM | |
1796 * | |
1797 * The ea.cmd pointer is updated to point to the first character following the | |
1798 * range spec. If an initial address is found, but no second, the upper bound | |
1799 * is equal to the lower. | |
1800 */ | |
1801 | |
16515
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
1802 // ea.addr_type for user commands is set by find_ucmd |
6489 | 1803 if (!IS_USER_CMDIDX(ea.cmdidx)) |
1804 { | |
1805 if (ea.cmdidx != CMD_SIZE) | |
1806 ea.addr_type = cmdnames[(int)ea.cmdidx].cmd_addr_type; | |
1807 else | |
1808 ea.addr_type = ADDR_LINES; | |
1809 | |
16515
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
1810 // :wincmd range depends on the argument. |
6506 | 1811 if (ea.cmdidx == CMD_wincmd && p != NULL) |
1812 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
|
1813 #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
|
1814 // :.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
|
1815 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
|
1816 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
|
1817 #endif |
6489 | 1818 } |
6398 | 1819 |
6489 | 1820 ea.cmd = cmd; |
14760
fd69edd2c67e
patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents:
14700
diff
changeset
|
1821 if (parse_cmd_address(&ea, &errormsg, FALSE) == FAIL) |
14505
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
1822 goto doend; |
7 | 1823 |
1824 /* | |
6398 | 1825 * 5. Parse the command. |
7 | 1826 */ |
1827 | |
1828 /* | |
1829 * Skip ':' and any white space | |
1830 */ | |
1831 ea.cmd = skipwhite(ea.cmd); | |
1832 while (*ea.cmd == ':') | |
1833 ea.cmd = skipwhite(ea.cmd + 1); | |
1834 | |
1835 /* | |
1836 * If we got a line, but no command, then go to the line. | |
1837 * If we find a '|' or '\n' we set ea.nextcmd. | |
1838 */ | |
6398 | 1839 if (*ea.cmd == NUL || *ea.cmd == '"' |
20059
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20027
diff
changeset
|
1840 #ifdef FEAT_EVAL |
20079
336483164ca6
patch 8.2.0595: Vim9: not all commands using ends_excmd() tested
Bram Moolenaar <Bram@vim.org>
parents:
20075
diff
changeset
|
1841 || (*ea.cmd == '#' && ea.cmd[1] != '{' |
336483164ca6
patch 8.2.0595: Vim9: not all commands using ends_excmd() tested
Bram Moolenaar <Bram@vim.org>
parents:
20075
diff
changeset
|
1842 && !starts_with_colon && in_vim9script()) |
20059
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20027
diff
changeset
|
1843 #endif |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20027
diff
changeset
|
1844 || (ea.nextcmd = check_nextcmd(ea.cmd)) != NULL) |
7 | 1845 { |
1846 /* | |
1847 * strange vi behaviour: | |
1848 * ":3" jumps to line 3 | |
1849 * ":3|..." prints line 3 | |
1850 * ":|" prints current line | |
1851 */ | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1852 if (ea.skip) // skip this if inside :if |
7 | 1853 goto doend; |
167 | 1854 if (*ea.cmd == '|' || (exmode_active && ea.line1 != ea.line2)) |
7 | 1855 { |
1856 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
|
1857 ea.argt = EX_RANGE+EX_COUNT+EX_TRLBAR; |
7 | 1858 if ((errormsg = invalid_range(&ea)) == NULL) |
1859 { | |
1860 correct_range(&ea); | |
1861 ex_print(&ea); | |
1862 } | |
1863 } | |
1864 else if (ea.addr_count != 0) | |
1865 { | |
631 | 1866 if (ea.line2 > curbuf->b_ml.ml_line_count) |
1867 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1868 // 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
|
1869 // error, otherwise put it at the end of the file. |
631 | 1870 if (vim_strchr(p_cpo, CPO_MINUS) != NULL) |
1871 ea.line2 = -1; | |
1872 else | |
1873 ea.line2 = curbuf->b_ml.ml_line_count; | |
1874 } | |
1875 | |
1876 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
|
1877 errormsg = _(e_invrange); |
7 | 1878 else |
1879 { | |
1880 if (ea.line2 == 0) | |
1881 curwin->w_cursor.lnum = 1; | |
1882 else | |
1883 curwin->w_cursor.lnum = ea.line2; | |
1884 beginline(BL_SOL | BL_FIX); | |
1885 } | |
1886 } | |
1887 goto doend; | |
1888 } | |
1889 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1890 // 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
|
1891 // autocommands defined, trigger the matching autocommands. |
6154 | 1892 if (p != NULL && ea.cmdidx == CMD_SIZE && !ea.skip |
1893 && ASCII_ISUPPER(*ea.cmd) | |
1894 && has_cmdundefined()) | |
1895 { | |
1896 int ret; | |
1897 | |
6156 | 1898 p = ea.cmd; |
6154 | 1899 while (ASCII_ISALNUM(*p)) |
1900 ++p; | |
6191 | 1901 p = vim_strnsave(ea.cmd, (int)(p - ea.cmd)); |
6154 | 1902 ret = apply_autocmds(EVENT_CMDUNDEFINED, p, p, TRUE, NULL); |
1903 vim_free(p); | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1904 // 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
|
1905 // finding the command again. |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
1906 p = (ret |
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
1907 #ifdef FEAT_EVAL |
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
1908 && !aborting() |
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
1909 #endif |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
1910 ) ? 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
|
1911 } |
6154 | 1912 |
7 | 1913 if (p == NULL) |
1914 { | |
1915 if (!ea.skip) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
1916 errormsg = _("E464: Ambiguous use of user-defined command"); |
7 | 1917 goto doend; |
1918 } | |
16411
5b5c5daf57de
patch 8.1.1210: support for user commands is spread out
Bram Moolenaar <Bram@vim.org>
parents:
16399
diff
changeset
|
1919 // 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
|
1920 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
|
1921 && !IS_USER_CMDIDX(ea.cmdidx)) |
7 | 1922 { |
1923 errormsg = uc_fun_cmd(); | |
1924 goto doend; | |
1925 } | |
16411
5b5c5daf57de
patch 8.1.1210: support for user commands is spread out
Bram Moolenaar <Bram@vim.org>
parents:
16399
diff
changeset
|
1926 |
7 | 1927 if (ea.cmdidx == CMD_SIZE) |
1928 { | |
1929 if (!ea.skip) | |
1930 { | |
1931 STRCPY(IObuff, _("E492: Not an editor command")); | |
1932 if (!sourcing) | |
9941
e975914c17e9
commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
9927
diff
changeset
|
1933 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1934 // 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
|
1935 // following command |
9941
e975914c17e9
commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
9927
diff
changeset
|
1936 if (after_modifier != NULL) |
e975914c17e9
commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
9927
diff
changeset
|
1937 append_command(after_modifier); |
e975914c17e9
commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
9927
diff
changeset
|
1938 else |
e975914c17e9
commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
9927
diff
changeset
|
1939 append_command(*cmdlinep); |
e975914c17e9
commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
9927
diff
changeset
|
1940 } |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
1941 errormsg = (char *)IObuff; |
3757 | 1942 did_emsg_syntax = TRUE; |
7 | 1943 } |
1944 goto doend; | |
1945 } | |
1946 | |
6305 | 1947 ni = (!IS_USER_CMDIDX(ea.cmdidx) |
1948 && (cmdnames[ea.cmdidx].cmd_func == ex_ni | |
1315 | 1949 #ifdef HAVE_EX_SCRIPT_NI |
1950 || cmdnames[ea.cmdidx].cmd_func == ex_script_ni | |
1951 #endif | |
1952 )); | |
7 | 1953 |
1954 #ifndef FEAT_EVAL | |
1955 /* | |
1956 * When the expression evaluation is disabled, recognize the ":if" and | |
1957 * ":endif" commands and ignore everything in between it. | |
1958 */ | |
1959 if (ea.cmdidx == CMD_if) | |
1960 ++if_level; | |
1961 if (if_level) | |
1962 { | |
1963 if (ea.cmdidx == CMD_endif) | |
1964 --if_level; | |
1965 goto doend; | |
1966 } | |
1967 | |
1968 #endif | |
1969 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1970 // forced commands |
1613 | 1971 if (*p == '!' && ea.cmdidx != CMD_substitute |
1972 && ea.cmdidx != CMD_smagic && ea.cmdidx != CMD_snomagic) | |
7 | 1973 { |
1974 ++p; | |
1975 ea.forceit = TRUE; | |
1976 } | |
1977 else | |
1978 ea.forceit = FALSE; | |
1979 | |
1980 /* | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
1981 * 6. Parse arguments. Then check for errors. |
7 | 1982 */ |
6305 | 1983 if (!IS_USER_CMDIDX(ea.cmdidx)) |
835 | 1984 ea.argt = (long)cmdnames[(int)ea.cmdidx].cmd_argt; |
7 | 1985 |
1986 if (!ea.skip) | |
1987 { | |
1988 #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
|
1989 if (sandbox != 0 && !(ea.argt & EX_SBOXOK)) |
7 | 1990 { |
15748
93b78c4a7cd5
patch 8.1.0881: can execute shell commands in rvim through interfaces
Bram Moolenaar <Bram@vim.org>
parents:
15713
diff
changeset
|
1991 // 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
|
1992 errormsg = _(e_sandbox); |
7 | 1993 goto doend; |
1994 } | |
1995 #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
|
1996 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
|
1997 { |
93b78c4a7cd5
patch 8.1.0881: can execute shell commands in rvim through interfaces
Bram Moolenaar <Bram@vim.org>
parents:
15713
diff
changeset
|
1998 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
|
1999 goto doend; |
93b78c4a7cd5
patch 8.1.0881: can execute shell commands in rvim through interfaces
Bram Moolenaar <Bram@vim.org>
parents:
15713
diff
changeset
|
2000 } |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2001 if (!curbuf->b_p_ma && (ea.argt & EX_MODIFY)) |
7 | 2002 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2003 // 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
|
2004 errormsg = _(e_modifiable); |
7 | 2005 goto doend; |
2006 } | |
631 | 2007 |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2008 if (text_locked() && !(ea.argt & EX_CMDWIN) |
6305 | 2009 && !IS_USER_CMDIDX(ea.cmdidx)) |
7 | 2010 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2011 // Command not allowed when editing the command line. |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2012 errormsg = _(get_text_locked_msg()); |
7 | 2013 goto doend; |
2014 } | |
14648
c3222a7342ab
patch 8.1.0337: :file fails in quickfix command
Christian Brabandt <cb@256bit.org>
parents:
14640
diff
changeset
|
2015 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2016 // 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
|
2017 // 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
|
2018 // 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
|
2019 // Do allow ":file" with no arguments (check for an argument later). |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2020 if (!(ea.argt & EX_CMDWIN) |
14648
c3222a7342ab
patch 8.1.0337: :file fails in quickfix command
Christian Brabandt <cb@256bit.org>
parents:
14640
diff
changeset
|
2021 && ea.cmdidx != CMD_checktime |
822 | 2022 && ea.cmdidx != CMD_edit |
14648
c3222a7342ab
patch 8.1.0337: :file fails in quickfix command
Christian Brabandt <cb@256bit.org>
parents:
14640
diff
changeset
|
2023 && ea.cmdidx != CMD_file |
6305 | 2024 && !IS_USER_CMDIDX(ea.cmdidx) |
819 | 2025 && curbuf_locked()) |
2026 goto doend; | |
7 | 2027 |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2028 if (!ni && !(ea.argt & EX_RANGE) && ea.addr_count > 0) |
7 | 2029 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2030 // no range allowed |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2031 errormsg = _(e_norange); |
7 | 2032 goto doend; |
2033 } | |
2034 } | |
2035 | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2036 if (!ni && !(ea.argt & EX_BANG) && ea.forceit) // no <!> allowed |
7 | 2037 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2038 errormsg = _(e_nobang); |
7 | 2039 goto doend; |
2040 } | |
2041 | |
2042 /* | |
2043 * Don't complain about the range if it is not used | |
2044 * (could happen if line_count is accidentally set to 0). | |
2045 */ | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2046 if (!ea.skip && !ni && (ea.argt & EX_RANGE)) |
7 | 2047 { |
2048 /* | |
2049 * If the range is backwards, ask for confirmation and, if given, swap | |
2050 * ea.line1 & ea.line2 so it's forwards again. | |
2051 * When global command is busy, don't ask, will fail below. | |
2052 */ | |
2053 if (!global_busy && ea.line1 > ea.line2) | |
2054 { | |
557 | 2055 if (msg_silent == 0) |
2056 { | |
2057 if (sourcing || exmode_active) | |
2058 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2059 errormsg = _("E493: Backwards range given"); |
557 | 2060 goto doend; |
2061 } | |
7 | 2062 if (ask_yesno((char_u *) |
2063 _("Backwards range given, OK to swap"), FALSE) != 'y') | |
557 | 2064 goto doend; |
7 | 2065 } |
2066 lnum = ea.line1; | |
2067 ea.line1 = ea.line2; | |
2068 ea.line2 = lnum; | |
2069 } | |
2070 if ((errormsg = invalid_range(&ea)) != NULL) | |
2071 goto doend; | |
2072 } | |
2073 | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
2074 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
|
2075 // default is 1, not cursor |
7 | 2076 ea.line2 = 1; |
2077 | |
2078 correct_range(&ea); | |
2079 | |
2080 #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
|
2081 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
|
2082 && ea.addr_type == ADDR_LINES) |
7 | 2083 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2084 // 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
|
2085 // at the end of a closed fold. |
7 | 2086 (void)hasFolding(ea.line1, &ea.line1, NULL); |
2087 (void)hasFolding(ea.line2, NULL, &ea.line2); | |
2088 } | |
2089 #endif | |
2090 | |
2091 #ifdef FEAT_QUICKFIX | |
2092 /* | |
41 | 2093 * For the ":make" and ":grep" commands we insert the 'makeprg'/'grepprg' |
7 | 2094 * option here, so things like % get expanded. |
2095 */ | |
344 | 2096 p = replace_makeprg(&ea, p, cmdlinep); |
2097 if (p == NULL) | |
2098 goto doend; | |
7 | 2099 #endif |
2100 | |
2101 /* | |
2102 * Skip to start of argument. | |
2103 * Don't do this for the ":!" command, because ":!! -l" needs the space. | |
2104 */ | |
2105 if (ea.cmdidx == CMD_bang) | |
2106 ea.arg = p; | |
2107 else | |
2108 ea.arg = skipwhite(p); | |
2109 | |
14648
c3222a7342ab
patch 8.1.0337: :file fails in quickfix command
Christian Brabandt <cb@256bit.org>
parents:
14640
diff
changeset
|
2110 // ":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
|
2111 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
|
2112 goto doend; |
c3222a7342ab
patch 8.1.0337: :file fails in quickfix command
Christian Brabandt <cb@256bit.org>
parents:
14640
diff
changeset
|
2113 |
7 | 2114 /* |
2115 * Check for "++opt=val" argument. | |
2116 * Must be first, allow ":w ++enc=utf8 !cmd" | |
2117 */ | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2118 if (ea.argt & EX_ARGOPT) |
7 | 2119 while (ea.arg[0] == '+' && ea.arg[1] == '+') |
2120 if (getargopt(&ea) == FAIL && !ni) | |
2121 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2122 errormsg = _(e_invarg); |
7 | 2123 goto doend; |
2124 } | |
2125 | |
2126 if (ea.cmdidx == CMD_write || ea.cmdidx == CMD_update) | |
2127 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2128 if (*ea.arg == '>') // append |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2129 { |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2130 if (*++ea.arg != '>') // typed wrong |
7 | 2131 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2132 errormsg = _("E494: Use w or w>>"); |
7 | 2133 goto doend; |
2134 } | |
2135 ea.arg = skipwhite(ea.arg + 1); | |
2136 ea.append = TRUE; | |
2137 } | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2138 else if (*ea.arg == '!' && ea.cmdidx == CMD_write) // :w !filter |
7 | 2139 { |
2140 ++ea.arg; | |
2141 ea.usefilter = TRUE; | |
2142 } | |
2143 } | |
2144 | |
2145 if (ea.cmdidx == CMD_read) | |
2146 { | |
2147 if (ea.forceit) | |
2148 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2149 ea.usefilter = TRUE; // :r! filter if ea.forceit |
7 | 2150 ea.forceit = FALSE; |
2151 } | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2152 else if (*ea.arg == '!') // :r !filter |
7 | 2153 { |
2154 ++ea.arg; | |
2155 ea.usefilter = TRUE; | |
2156 } | |
2157 } | |
2158 | |
2159 if (ea.cmdidx == CMD_lshift || ea.cmdidx == CMD_rshift) | |
2160 { | |
2161 ea.amount = 1; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2162 while (*ea.arg == *ea.cmd) // count number of '>' or '<' |
7 | 2163 { |
2164 ++ea.arg; | |
2165 ++ea.amount; | |
2166 } | |
2167 ea.arg = skipwhite(ea.arg); | |
2168 } | |
2169 | |
2170 /* | |
2171 * Check for "+command" argument, before checking for next command. | |
2172 * Don't do this for ":read !cmd" and ":write !cmd". | |
2173 */ | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2174 if ((ea.argt & EX_CMDARG) && !ea.usefilter) |
7 | 2175 ea.do_ecmd_cmd = getargcmd(&ea.arg); |
2176 | |
2177 /* | |
2178 * Check for '|' to separate commands and '"' to start comments. | |
2179 * Don't do this for ":read !cmd" and ":write !cmd". | |
2180 */ | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2181 if ((ea.argt & EX_TRLBAR) && !ea.usefilter) |
7 | 2182 separate_nextcmd(&ea); |
2183 | |
2184 /* | |
2185 * Check for <newline> to end a shell command. | |
167 | 2186 * Also do this for ":read !cmd", ":write !cmd" and ":global". |
2187 * Any others? | |
7 | 2188 */ |
167 | 2189 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
|
2190 || ea.cmdidx == CMD_terminal |
167 | 2191 || ea.cmdidx == CMD_global |
2192 || ea.cmdidx == CMD_vglobal | |
2193 || ea.usefilter) | |
7 | 2194 { |
2195 for (p = ea.arg; *p; ++p) | |
2196 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2197 // 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
|
2198 // 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
|
2199 // 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
|
2200 // 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
|
2201 // 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
|
2202 // versions. |
7 | 2203 if (*p == '\\' && p[1] == '\n') |
1619 | 2204 STRMOVE(p, p + 1); |
7 | 2205 else if (*p == '\n') |
2206 { | |
2207 ea.nextcmd = p + 1; | |
2208 *p = NUL; | |
2209 break; | |
2210 } | |
2211 } | |
2212 } | |
2213 | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2214 if ((ea.argt & EX_DFLALL) && ea.addr_count == 0) |
7 | 2215 { |
6424 | 2216 buf_T *buf; |
2217 | |
7 | 2218 ea.line1 = 1; |
6424 | 2219 switch (ea.addr_type) |
2220 { | |
2221 case ADDR_LINES: | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
2222 case ADDR_OTHER: |
6424 | 2223 ea.line2 = curbuf->b_ml.ml_line_count; |
2224 break; | |
2225 case ADDR_LOADED_BUFFERS: | |
2226 buf = firstbuf; | |
2227 while (buf->b_next != NULL && buf->b_ml.ml_mfp == NULL) | |
2228 buf = buf->b_next; | |
2229 ea.line1 = buf->b_fnum; | |
2230 buf = lastbuf; | |
2231 while (buf->b_prev != NULL && buf->b_ml.ml_mfp == NULL) | |
2232 buf = buf->b_prev; | |
2233 ea.line2 = buf->b_fnum; | |
2234 break; | |
2235 case ADDR_BUFFERS: | |
2236 ea.line1 = firstbuf->b_fnum; | |
2237 ea.line2 = lastbuf->b_fnum; | |
2238 break; | |
2239 case ADDR_WINDOWS: | |
2240 ea.line2 = LAST_WIN_NR; | |
2241 break; | |
2242 case ADDR_TABS: | |
2243 ea.line2 = LAST_TAB_NR; | |
2244 break; | |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
2245 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
|
2246 ea.line2 = 1; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
2247 break; |
6424 | 2248 case ADDR_ARGUMENTS: |
2249 if (ARGCOUNT == 0) | |
2250 ea.line1 = ea.line2 = 0; | |
2251 else | |
2252 ea.line2 = ARGCOUNT; | |
2253 break; | |
16515
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
2254 case ADDR_QUICKFIX_VALID: |
7105
f4456e686406
commit https://github.com/vim/vim/commit/e906c502079770ae0e0071c74cefb802689ff193
Christian Brabandt <cb@256bit.org>
parents:
7092
diff
changeset
|
2255 #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
|
2256 ea.line2 = qf_get_valid_size(&ea); |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
2257 if (ea.line2 == 0) |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
2258 ea.line2 = 1; |
16479
7dcf301d1432
patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents:
16475
diff
changeset
|
2259 #endif |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
2260 break; |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
2261 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
|
2262 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
|
2263 case ADDR_QUICKFIX: |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2264 iemsg(_("INTERNAL: Cannot use EX_DFLALL with ADDR_NONE, ADDR_UNSIGNED or ADDR_QUICKFIX")); |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
2265 break; |
6424 | 2266 } |
7 | 2267 } |
2268 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2269 // 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
|
2270 if ( (ea.argt & EX_REGSTR) |
7 | 2271 && *ea.arg != NUL |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2272 // Do not allow register = for user commands |
6305 | 2273 && (!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
|
2274 && !((ea.argt & EX_COUNT) && VIM_ISDIGIT(*ea.arg))) |
7 | 2275 { |
2791 | 2276 #ifndef FEAT_CLIPBOARD |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2277 // check these explicitly for a more specific error message |
2791 | 2278 if (*ea.arg == '*' || *ea.arg == '+') |
2279 { | |
15474
79e3dcc5aa50
patch 8.1.0745: compiler warnings for signed/unsigned string
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
2280 errormsg = _(e_invalidreg); |
2791 | 2281 goto doend; |
2282 } | |
2283 #endif | |
6305 | 2284 if (valid_yank_reg(*ea.arg, (ea.cmdidx != CMD_put |
2285 && !IS_USER_CMDIDX(ea.cmdidx)))) | |
2791 | 2286 { |
2287 ea.regname = *ea.arg++; | |
7 | 2288 #ifdef FEAT_EVAL |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2289 // for '=' register: accept the rest of the line as an expression |
2791 | 2290 if (ea.arg[-1] == '=' && ea.arg[0] != NUL) |
2291 { | |
2292 set_expr_line(vim_strsave(ea.arg)); | |
2293 ea.arg += STRLEN(ea.arg); | |
2294 } | |
2295 #endif | |
2296 ea.arg = skipwhite(ea.arg); | |
2297 } | |
7 | 2298 } |
2299 | |
2300 /* | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2301 * Check for a count. When accepting a EX_BUFNAME, don't use "123foo" as a |
7 | 2302 * count, it's a buffer name. |
2303 */ | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2304 if ((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
|
2305 && (!(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
|
2306 || VIM_ISWHITE(*p))) |
7 | 2307 { |
2308 n = getdigits(&ea.arg); | |
2309 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
|
2310 if (n <= 0 && !ni && (ea.argt & EX_ZEROR) == 0) |
7 | 2311 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2312 errormsg = _(e_zerocount); |
7 | 2313 goto doend; |
2314 } | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
2315 if (ea.addr_type != ADDR_LINES) // e.g. :buffer 2, :sleep 3 |
7 | 2316 { |
2317 ea.line2 = n; | |
2318 if (ea.addr_count == 0) | |
2319 ea.addr_count = 1; | |
2320 } | |
2321 else | |
2322 { | |
2323 ea.line1 = ea.line2; | |
2324 ea.line2 += n - 1; | |
2325 ++ea.addr_count; | |
2326 /* | |
2327 * Be vi compatible: no error message for out of range. | |
2328 */ | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
2329 if (ea.line2 > curbuf->b_ml.ml_line_count) |
7 | 2330 ea.line2 = curbuf->b_ml.ml_line_count; |
2331 } | |
2332 } | |
167 | 2333 |
2334 /* | |
2335 * Check for flags: 'l', 'p' and '#'. | |
2336 */ | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2337 if (ea.argt & EX_FLAGS) |
167 | 2338 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
|
2339 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
|
2340 && *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
|
2341 { |
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2342 // no arguments allowed but there is something |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2343 errormsg = _(e_trailing); |
7 | 2344 goto doend; |
2345 } | |
2346 | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2347 if (!ni && (ea.argt & EX_NEEDARG) && *ea.arg == NUL) |
7 | 2348 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2349 errormsg = _(e_argreq); |
7 | 2350 goto doend; |
2351 } | |
2352 | |
2353 #ifdef FEAT_EVAL | |
2354 /* | |
2355 * Skip the command when it's not going to be executed. | |
2356 * The commands like :if, :endif, etc. always need to be executed. | |
2357 * Also make an exception for commands that handle a trailing command | |
2358 * themselves. | |
2359 */ | |
2360 if (ea.skip) | |
2361 { | |
2362 switch (ea.cmdidx) | |
2363 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2364 // commands that need evaluation |
7 | 2365 case CMD_while: |
2366 case CMD_endwhile: | |
72 | 2367 case CMD_for: |
2368 case CMD_endfor: | |
7 | 2369 case CMD_if: |
2370 case CMD_elseif: | |
2371 case CMD_else: | |
2372 case CMD_endif: | |
2373 case CMD_try: | |
2374 case CMD_catch: | |
2375 case CMD_finally: | |
2376 case CMD_endtry: | |
2377 case CMD_function: | |
19575
3c0de44077cd
patch 8.2.0344: ":def" not skipped properly
Bram Moolenaar <Bram@vim.org>
parents:
19497
diff
changeset
|
2378 case CMD_def: |
7 | 2379 break; |
2380 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2381 // 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
|
2382 // 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
|
2383 // the list at ":help :bar". |
7 | 2384 case CMD_aboveleft: |
2385 case CMD_and: | |
2386 case CMD_belowright: | |
2387 case CMD_botright: | |
2388 case CMD_browse: | |
2389 case CMD_call: | |
2390 case CMD_confirm: | |
18713
baf890fa1621
patch 8.1.2348: :const cannot be followed by "| endif"
Bram Moolenaar <Bram@vim.org>
parents:
18406
diff
changeset
|
2391 case CMD_const: |
7 | 2392 case CMD_delfunction: |
2393 case CMD_djump: | |
2394 case CMD_dlist: | |
2395 case CMD_dsearch: | |
2396 case CMD_dsplit: | |
2397 case CMD_echo: | |
2398 case CMD_echoerr: | |
2399 case CMD_echomsg: | |
2400 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
|
2401 case CMD_eval: |
7 | 2402 case CMD_execute: |
9941
e975914c17e9
commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
9927
diff
changeset
|
2403 case CMD_filter: |
7 | 2404 case CMD_help: |
2405 case CMD_hide: | |
2406 case CMD_ijump: | |
2407 case CMD_ilist: | |
2408 case CMD_isearch: | |
2409 case CMD_isplit: | |
22 | 2410 case CMD_keepalt: |
7 | 2411 case CMD_keepjumps: |
2412 case CMD_keepmarks: | |
5467 | 2413 case CMD_keeppatterns: |
7 | 2414 case CMD_leftabove: |
2415 case CMD_let: | |
2416 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
|
2417 case CMD_lockvar: |
2320
966a5609669e
Added Lua interfae. (Luis Carvalho)
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
2418 case CMD_lua: |
7 | 2419 case CMD_match: |
14 | 2420 case CMD_mzscheme: |
5737 | 2421 case CMD_noautocmd: |
2422 case CMD_noswapfile: | |
7 | 2423 case CMD_perl: |
2424 case CMD_psearch: | |
2425 case CMD_python: | |
2350
06feaf4fe36a
Rename some "python3" symbols to "py3", as the command name.
Bram Moolenaar <bram@vim.org>
parents:
2340
diff
changeset
|
2426 case CMD_py3: |
2366
7a57fe6a5157
Fix that :py3file was not working.
Bram Moolenaar <bram@vim.org>
parents:
2360
diff
changeset
|
2427 case CMD_python3: |
7 | 2428 case CMD_return: |
2429 case CMD_rightbelow: | |
2430 case CMD_ruby: | |
2431 case CMD_silent: | |
2432 case CMD_smagic: | |
2433 case CMD_snomagic: | |
2434 case CMD_substitute: | |
2435 case CMD_syntax: | |
690 | 2436 case CMD_tab: |
7 | 2437 case CMD_tcl: |
2438 case CMD_throw: | |
2439 case CMD_tilde: | |
2440 case CMD_topleft: | |
2441 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
|
2442 case CMD_unlockvar: |
7 | 2443 case CMD_verbose: |
2444 case CMD_vertical: | |
2887 | 2445 case CMD_wincmd: |
7 | 2446 break; |
2447 | |
2448 default: goto doend; | |
2449 } | |
2450 } | |
2451 #endif | |
2452 | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2453 if (ea.argt & EX_XFILE) |
7 | 2454 { |
2455 if (expand_filename(&ea, cmdlinep, &errormsg) == FAIL) | |
2456 goto doend; | |
2457 } | |
2458 | |
2459 /* | |
2460 * Accept buffer name. Cannot be used at the same time with a buffer | |
2461 * number. Don't do this for a user command. | |
2462 */ | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2463 if ((ea.argt & EX_BUFNAME) && *ea.arg != NUL && ea.addr_count == 0 |
6305 | 2464 && !IS_USER_CMDIDX(ea.cmdidx)) |
7 | 2465 { |
2466 /* | |
2467 * :bdelete, :bwipeout and :bunload take several arguments, separated | |
2468 * by spaces: find next space (skipping over escaped characters). | |
2469 * The others take one argument: ignore trailing spaces. | |
2470 */ | |
2471 if (ea.cmdidx == CMD_bdelete || ea.cmdidx == CMD_bwipeout | |
2472 || ea.cmdidx == CMD_bunload) | |
2473 p = skiptowhite_esc(ea.arg); | |
2474 else | |
2475 { | |
2476 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
|
2477 while (p > ea.arg && VIM_ISWHITE(p[-1])) |
7 | 2478 --p; |
2479 } | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2480 ea.line2 = buflist_findpat(ea.arg, p, (ea.argt & EX_BUFUNL) != 0, |
4236 | 2481 FALSE, FALSE); |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2482 if (ea.line2 < 0) // failed |
7 | 2483 goto doend; |
2484 ea.addr_count = 1; | |
2485 ea.arg = skipwhite(p); | |
2486 } | |
2487 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2488 // 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
|
2489 // ":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
|
2490 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
|
2491 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2492 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
|
2493 if (emsg_silent < 0) |
530943a23d3f
patch 8.0.1518: error messages suppressed after ":silent! try"
Christian Brabandt <cb@256bit.org>
parents:
13268
diff
changeset
|
2494 emsg_silent = 0; |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2495 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
|
2496 } |
530943a23d3f
patch 8.0.1518: error messages suppressed after ":silent! try"
Christian Brabandt <cb@256bit.org>
parents:
13268
diff
changeset
|
2497 |
530943a23d3f
patch 8.0.1518: error messages suppressed after ":silent! try"
Christian Brabandt <cb@256bit.org>
parents:
13268
diff
changeset
|
2498 /* |
530943a23d3f
patch 8.0.1518: error messages suppressed after ":silent! try"
Christian Brabandt <cb@256bit.org>
parents:
13268
diff
changeset
|
2499 * 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
|
2500 */ |
7 | 2501 |
6305 | 2502 if (IS_USER_CMDIDX(ea.cmdidx)) |
7 | 2503 { |
2504 /* | |
2505 * Execute a user-defined command. | |
2506 */ | |
2507 do_ucmd(&ea); | |
2508 } | |
2509 else | |
2510 { | |
2511 /* | |
16411
5b5c5daf57de
patch 8.1.1210: support for user commands is spread out
Bram Moolenaar <Bram@vim.org>
parents:
16399
diff
changeset
|
2512 * Call the function to execute the builtin command. |
7 | 2513 */ |
2514 ea.errmsg = NULL; | |
2515 (cmdnames[ea.cmdidx].cmd_func)(&ea); | |
2516 if (ea.errmsg != NULL) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2517 errormsg = _(ea.errmsg); |
7 | 2518 } |
2519 | |
2520 #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
|
2521 // 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
|
2522 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
|
2523 && 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
|
2524 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
|
2525 |
7 | 2526 /* |
2527 * If the command just executed called do_cmdline(), any throw or ":return" | |
2528 * or ":finish" encountered there must also check the cstack of the still | |
2529 * active do_cmdline() that called this do_one_cmd(). Rethrow an uncaught | |
2530 * exception, or reanimate a returned function or finished script file and | |
2531 * return or finish it again. | |
2532 */ | |
2533 if (need_rethrow) | |
2534 do_throw(cstack); | |
2535 else if (check_cstack) | |
2536 { | |
944 | 2537 if (source_finished(fgetline, cookie)) |
7 | 2538 do_finish(&ea, TRUE); |
944 | 2539 else if (getline_equal(fgetline, cookie, get_func_line) |
7 | 2540 && current_func_returned()) |
2541 do_return(&ea, TRUE, FALSE, NULL); | |
2542 } | |
2543 need_rethrow = check_cstack = FALSE; | |
2544 #endif | |
2545 | |
2546 doend: | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2547 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
|
2548 { |
7 | 2549 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
|
2550 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
|
2551 } |
7 | 2552 |
2553 if (errormsg != NULL && *errormsg != NUL && !did_emsg) | |
2554 { | |
2555 if (sourcing) | |
2556 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2557 if (errormsg != (char *)IObuff) |
7 | 2558 { |
2559 STRCPY(IObuff, errormsg); | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2560 errormsg = (char *)IObuff; |
7 | 2561 } |
3097 | 2562 append_command(*cmdlinep); |
7 | 2563 } |
2564 emsg(errormsg); | |
2565 } | |
2566 #ifdef FEAT_EVAL | |
2567 do_errthrow(cstack, | |
6305 | 2568 (ea.cmdidx != CMD_SIZE && !IS_USER_CMDIDX(ea.cmdidx)) |
2569 ? cmdnames[(int)ea.cmdidx].cmd_name : (char_u *)NULL); | |
7 | 2570 #endif |
2571 | |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2572 if (ea.verbose_save >= 0) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2573 p_verbose = ea.verbose_save; |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
2574 |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2575 free_cmdmod(); |
7 | 2576 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
|
2577 reg_executing = save_reg_executing; |
7 | 2578 |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2579 if (ea.save_msg_silent != -1) |
7 | 2580 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2581 // messages could be enabled for a serious error, need to check if the |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2582 // counters don't become negative |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2583 if (!did_emsg || msg_silent > ea.save_msg_silent) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2584 msg_silent = ea.save_msg_silent; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2585 emsg_silent -= ea.did_esilent; |
7 | 2586 if (emsg_silent < 0) |
2587 emsg_silent = 0; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2588 // Restore msg_scroll, it's set by file I/O commands, even when no |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2589 // message is actually displayed. |
7 | 2590 msg_scroll = save_msg_scroll; |
1854 | 2591 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2592 // "silent reg" or "silent echo x" inside "redir" leaves msg_col |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2593 // somewhere in the line. Put it back in the first column. |
1854 | 2594 if (redirecting()) |
2595 msg_col = 0; | |
7 | 2596 } |
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; | |
2608 #endif | |
2609 | |
2610 return ea.nextcmd; | |
2611 } | |
2612 #if (_MSC_VER == 1200) | |
128 | 2613 #pragma optimize( "", on ) |
7 | 2614 #endif |
2615 | |
2616 /* | |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2617 * 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
|
2618 * - update eap->cmd |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2619 * - store flags in "cmdmod". |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2620 * - 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
|
2621 * - 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
|
2622 * - 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
|
2623 * - 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
|
2624 * - 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
|
2625 * 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
|
2626 * "cmdmod". |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2627 * 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
|
2628 * 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
|
2629 */ |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2630 int |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2631 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
|
2632 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2633 char_u *p; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2634 |
20007
aadd1cae2ff5
patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
2635 CLEAR_FIELD(cmdmod); |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2636 eap->verbose_save = -1; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2637 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
|
2638 |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2639 // 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
|
2640 for (;;) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2641 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2642 while (*eap->cmd == ' ' || *eap->cmd == '\t' || *eap->cmd == ':') |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2643 ++eap->cmd; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2644 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2645 // 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
|
2646 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
|
2647 && (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
|
2648 || 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
|
2649 && 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
|
2650 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2651 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
|
2652 if (!skip_only) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2653 ex_pressedreturn = TRUE; |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2654 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2655 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2656 // ignore comment and empty lines |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2657 if (*eap->cmd == '"') |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2658 return FAIL; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2659 if (*eap->cmd == NUL) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2660 { |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2661 if (!skip_only) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2662 ex_pressedreturn = TRUE; |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2663 return FAIL; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2664 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2665 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2666 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
|
2667 switch (*p) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2668 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2669 // 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
|
2670 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
|
2671 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2672 cmdmod.split |= WSP_ABOVE; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2673 continue; |
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 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
|
2676 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2677 cmdmod.split |= WSP_BELOW; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2678 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2679 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2680 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
|
2681 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2682 #ifdef FEAT_BROWSE_CMD |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2683 cmdmod.browse = TRUE; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2684 #endif |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2685 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2686 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2687 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
|
2688 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2689 cmdmod.split |= WSP_BOT; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2690 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2691 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2692 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
|
2693 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2694 #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
|
2695 cmdmod.confirm = TRUE; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2696 #endif |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2697 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2698 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2699 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
|
2700 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2701 cmdmod.keepmarks = TRUE; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2702 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2703 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2704 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
|
2705 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2706 cmdmod.keepalt = TRUE; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2707 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2708 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2709 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
|
2710 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2711 cmdmod.keeppatterns = TRUE; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2712 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2713 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2714 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
|
2715 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2716 cmdmod.keepjumps = TRUE; |
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 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2719 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
|
2720 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2721 char_u *reg_pat; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2722 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2723 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
|
2724 || *p == NUL || ends_excmd(*p)) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2725 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2726 if (*p == '!') |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2727 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2728 cmdmod.filter_force = TRUE; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2729 p = skipwhite(p + 1); |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2730 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
|
2731 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2732 } |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2733 if (skip_only) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2734 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
|
2735 else |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2736 // 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
|
2737 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
|
2738 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
|
2739 break; |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2740 if (!skip_only) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2741 { |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2742 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
|
2743 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
|
2744 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
|
2745 break; |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2746 } |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2747 eap->cmd = p; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2748 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2749 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2750 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2751 // ":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
|
2752 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
|
2753 || *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
|
2754 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2755 eap->cmd = p; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2756 cmdmod.hide = TRUE; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2757 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2758 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2759 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
|
2760 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2761 cmdmod.lockmarks = TRUE; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2762 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2763 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2764 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2765 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
|
2766 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2767 cmdmod.split |= WSP_ABOVE; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2768 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2769 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2770 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
|
2771 { |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2772 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
|
2773 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2774 // 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
|
2775 // 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
|
2776 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
|
2777 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
|
2778 (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
|
2779 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2780 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2781 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2782 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
|
2783 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2784 cmdmod.noswapfile = TRUE; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2785 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2786 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2787 case '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
|
2788 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2789 cmdmod.split |= WSP_BELOW; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2790 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2791 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2792 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
|
2793 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2794 #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
|
2795 if (!skip_only) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2796 { |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2797 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
|
2798 ++sandbox; |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2799 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
|
2800 } |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2801 #endif |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2802 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2803 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2804 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
|
2805 break; |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2806 if (!skip_only) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2807 { |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2808 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
|
2809 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
|
2810 ++msg_silent; |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2811 } |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2812 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
|
2813 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2814 // ":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
|
2815 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
|
2816 if (!skip_only) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2817 { |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2818 ++emsg_silent; |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2819 ++eap->did_esilent; |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2820 } |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2821 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2822 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2823 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2824 case '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
|
2825 { |
15263
ad065b8123e8
patch 8.1.0640: get E14 while typing command :tab with 'incsearch' set
Bram Moolenaar <Bram@vim.org>
parents:
15239
diff
changeset
|
2826 if (!skip_only) |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2827 { |
15263
ad065b8123e8
patch 8.1.0640: get E14 while typing command :tab with 'incsearch' set
Bram Moolenaar <Bram@vim.org>
parents:
15239
diff
changeset
|
2828 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
|
2829 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
|
2830 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
|
2831 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
|
2832 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
|
2833 else |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2834 { |
15263
ad065b8123e8
patch 8.1.0640: get E14 while typing command :tab with 'incsearch' set
Bram Moolenaar <Bram@vim.org>
parents:
15239
diff
changeset
|
2835 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
|
2836 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2837 *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
|
2838 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
|
2839 } |
ad065b8123e8
patch 8.1.0640: get E14 while typing command :tab with 'incsearch' set
Bram Moolenaar <Bram@vim.org>
parents:
15239
diff
changeset
|
2840 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
|
2841 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2842 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2843 eap->cmd = p; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2844 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2845 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2846 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
|
2847 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2848 cmdmod.split |= WSP_TOP; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2849 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2850 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2851 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
|
2852 break; |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2853 if (!skip_only) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2854 { |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2855 if (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
|
2856 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
|
2857 msg_silent = 0; |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2858 } |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2859 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2860 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2861 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
|
2862 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2863 cmdmod.split |= WSP_VERT; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2864 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2865 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2866 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
|
2867 break; |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2868 if (!skip_only) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2869 { |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2870 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
|
2871 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
|
2872 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
|
2873 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
|
2874 else |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2875 p_verbose = 1; |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2876 } |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2877 eap->cmd = p; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2878 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2879 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2880 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2881 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2882 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2883 return OK; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2884 } |
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 /* |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2887 * Free contents of "cmdmod". |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2888 */ |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2889 static void |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2890 free_cmdmod(void) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2891 { |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2892 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
|
2893 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2894 // 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
|
2895 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
|
2896 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
|
2897 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
|
2898 } |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2899 |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2900 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
|
2901 vim_regfree(cmdmod.filter_regmatch.regprog); |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2902 } |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2903 |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2904 /* |
14505
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2905 * 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
|
2906 * 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
|
2907 * 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
|
2908 */ |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2909 int |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2910 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
|
2911 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2912 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
|
2913 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
|
2914 |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2915 // 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
|
2916 for (;;) |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2917 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2918 eap->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
|
2919 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
|
2920 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2921 case ADDR_LINES: |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
2922 case ADDR_OTHER: |
20474
3fe45aa3bbc5
patch 8.2.0791: a second popup window with terminal causes trouble
Bram Moolenaar <Bram@vim.org>
parents:
20239
diff
changeset
|
2923 // Default is the cursor line number. Avoid using an invalid |
3fe45aa3bbc5
patch 8.2.0791: a second popup window with terminal causes trouble
Bram Moolenaar <Bram@vim.org>
parents:
20239
diff
changeset
|
2924 // line number though. |
3fe45aa3bbc5
patch 8.2.0791: a second popup window with terminal causes trouble
Bram Moolenaar <Bram@vim.org>
parents:
20239
diff
changeset
|
2925 if (curwin->w_cursor.lnum > curbuf->b_ml.ml_line_count) |
3fe45aa3bbc5
patch 8.2.0791: a second popup window with terminal causes trouble
Bram Moolenaar <Bram@vim.org>
parents:
20239
diff
changeset
|
2926 eap->line2 = curbuf->b_ml.ml_line_count; |
3fe45aa3bbc5
patch 8.2.0791: a second popup window with terminal causes trouble
Bram Moolenaar <Bram@vim.org>
parents:
20239
diff
changeset
|
2927 else |
3fe45aa3bbc5
patch 8.2.0791: a second popup window with terminal causes trouble
Bram Moolenaar <Bram@vim.org>
parents:
20239
diff
changeset
|
2928 eap->line2 = curwin->w_cursor.lnum; |
14505
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2929 break; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2930 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
|
2931 eap->line2 = CURRENT_WIN_NR; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2932 break; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2933 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
|
2934 eap->line2 = curwin->w_arg_idx + 1; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2935 if (eap->line2 > ARGCOUNT) |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2936 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
|
2937 break; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2938 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
|
2939 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
|
2940 eap->line2 = curbuf->b_fnum; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2941 break; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2942 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
|
2943 eap->line2 = CURRENT_TAB_NR; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2944 break; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2945 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
|
2946 case ADDR_UNSIGNED: |
14505
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2947 eap->line2 = 1; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2948 break; |
16479
7dcf301d1432
patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents:
16475
diff
changeset
|
2949 case ADDR_QUICKFIX: |
14505
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2950 #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
|
2951 eap->line2 = qf_get_cur_idx(eap); |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
2952 #endif |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
2953 break; |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
2954 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
|
2955 #ifdef FEAT_QUICKFIX |
14505
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2956 eap->line2 = qf_get_cur_valid_idx(eap); |
16479
7dcf301d1432
patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents:
16475
diff
changeset
|
2957 #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
|
2958 break; |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
2959 case ADDR_NONE: |
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
2960 // 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
|
2961 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
|
2962 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2963 eap->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
|
2964 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
|
2965 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
|
2966 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
|
2967 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
|
2968 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
|
2969 { |
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 == '%') // '%' - 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
|
2971 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2972 ++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
|
2973 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
|
2974 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2975 case ADDR_LINES: |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
2976 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
|
2977 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
|
2978 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
|
2979 break; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2980 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
|
2981 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2982 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
|
2983 |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2984 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
|
2985 && 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
|
2986 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
|
2987 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
|
2988 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
|
2989 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
|
2990 && 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
|
2991 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
|
2992 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
|
2993 break; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2994 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2995 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
|
2996 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
|
2997 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
|
2998 break; |
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_WINDOWS: |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3000 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
|
3001 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
|
3002 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3003 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
|
3004 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
|
3005 ? 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
|
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 else |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3008 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3009 // 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
|
3010 // 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
|
3011 *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
|
3012 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
|
3013 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3014 break; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3015 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
|
3016 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
|
3017 case ADDR_QUICKFIX: |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
3018 *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
|
3019 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
|
3020 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
|
3021 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
|
3022 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
|
3023 else |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3024 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3025 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
|
3026 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
|
3027 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3028 break; |
16515
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
3029 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
|
3030 #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
|
3031 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
|
3032 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
|
3033 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
|
3034 eap->line2 = 1; |
16479
7dcf301d1432
patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents:
16475
diff
changeset
|
3035 #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
|
3036 break; |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
3037 case ADDR_NONE: |
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
3038 // 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
|
3039 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
|
3040 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3041 ++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
|
3042 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3043 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
|
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 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
|
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 // '*' - 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
|
3048 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
|
3049 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
3050 *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
|
3051 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
|
3052 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3053 |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3054 ++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
|
3055 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
|
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 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
|
3058 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
|
3059 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
|
3060 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
|
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->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
|
3065 ++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
|
3066 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3067 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3068 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3069 else |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3070 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
|
3071 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
|
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 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
|
3074 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3075 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
|
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 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
|
3078 // 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
|
3079 // 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
|
3080 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
|
3081 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
|
3082 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3083 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3084 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
|
3085 break; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3086 ++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
|
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 |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3089 // 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
|
3090 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
|
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 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
|
3093 // ... 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
|
3094 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
|
3095 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
|
3096 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3097 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
|
3098 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3099 |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3100 /* |
93 | 3101 * Check for an Ex command with optional tail. |
7 | 3102 * If there is a match advance "pp" to the argument and return TRUE. |
3103 */ | |
93 | 3104 int |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3105 checkforcmd( |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3106 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
|
3107 char *cmd, // name of command |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3108 int len) // required length |
7 | 3109 { |
3110 int i; | |
3111 | |
3112 for (i = 0; cmd[i] != NUL; ++i) | |
1872 | 3113 if (((char_u *)cmd)[i] != (*pp)[i]) |
7 | 3114 break; |
3115 if (i >= len && !isalpha((*pp)[i])) | |
3116 { | |
3117 *pp = skipwhite(*pp + i); | |
3118 return TRUE; | |
3119 } | |
3120 return FALSE; | |
3121 } | |
3122 | |
3123 /* | |
3097 | 3124 * Append "cmd" to the error message in IObuff. |
3125 * Takes care of limiting the length and handling 0xa0, which would be | |
3126 * invisible otherwise. | |
3127 */ | |
3128 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3129 append_command(char_u *cmd) |
3097 | 3130 { |
3131 char_u *s = cmd; | |
3132 char_u *d; | |
3133 | |
3134 STRCAT(IObuff, ": "); | |
3135 d = IObuff + STRLEN(IObuff); | |
3136 while (*s != NUL && d - IObuff < IOSIZE - 7) | |
3137 { | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
3138 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
|
3139 { |
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
3140 s += enc_utf8 ? 2 : 1; |
3097 | 3141 STRCPY(d, "<a0>"); |
3142 d += 4; | |
3143 } | |
3144 else | |
3145 MB_COPY_CHAR(s, d); | |
3146 } | |
3147 *d = NUL; | |
3148 } | |
3149 | |
3150 /* | |
7 | 3151 * Find an Ex command by its name, either built-in or user. |
184 | 3152 * 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
|
3153 * Sets eap->cmdidx and returns a pointer to char after the command name. |
184 | 3154 * "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
|
3155 * |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3156 * 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
|
3157 * 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
|
3158 * "eap->cmd". |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3159 * |
7 | 3160 * Returns NULL for an ambiguous user command. |
3161 */ | |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3162 char_u * |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3163 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
|
3164 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
|
3165 int *full UNUSED, |
20239
2135b4641680
patch 8.2.0675: Vim9: no support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
3166 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
|
3167 cctx_T *cctx UNUSED) |
7 | 3168 { |
3169 int len; | |
3170 char_u *p; | |
167 | 3171 int i; |
7 | 3172 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3173 #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
|
3174 /* |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3175 * 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
|
3176 * "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
|
3177 */ |
19481
c27837cbe922
patch 8.2.0298: Vim9 script: cannot start command with a string constant
Bram Moolenaar <Bram@vim.org>
parents:
19475
diff
changeset
|
3178 p = eap->cmd; |
c27837cbe922
patch 8.2.0298: Vim9 script: cannot start command with a string constant
Bram Moolenaar <Bram@vim.org>
parents:
19475
diff
changeset
|
3179 if (lookup != NULL && (*p == '(' |
c27837cbe922
patch 8.2.0298: Vim9 script: cannot start command with a string constant
Bram Moolenaar <Bram@vim.org>
parents:
19475
diff
changeset
|
3180 || ((p = to_name_const_end(eap->cmd)) > eap->cmd && *p != NUL))) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3181 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3182 int oplen; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3183 int heredoc; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3184 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3185 // "funcname(" is always a function call. |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3186 // "varname[]" is an expression. |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3187 // "g:varname" is an expression. |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3188 // "varname->expr" is an expression. |
19481
c27837cbe922
patch 8.2.0298: Vim9 script: cannot start command with a string constant
Bram Moolenaar <Bram@vim.org>
parents:
19475
diff
changeset
|
3189 // "(..." is an expression. |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3190 if (*p == '(' |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3191 || *p == '[' |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3192 || p[1] == ':' |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3193 || (*p == '-' && p[1] == '>')) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3194 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3195 eap->cmdidx = CMD_eval; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3196 return eap->cmd; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3197 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3198 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3199 oplen = assignment_len(skipwhite(p), &heredoc); |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3200 if (oplen > 0) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3201 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3202 // Recognize an assignment if we recognize the variable name: |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3203 // "g:var = expr" |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3204 // "var = expr" where "var" is a local var name. |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3205 if (((p - eap->cmd) > 2 && eap->cmd[1] == ':') |
20239
2135b4641680
patch 8.2.0675: Vim9: no support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
3206 || lookup(eap->cmd, p - eap->cmd, cctx) != NULL) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3207 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3208 eap->cmdidx = CMD_let; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3209 return eap->cmd; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3210 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3211 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3212 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3213 #endif |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3214 |
7 | 3215 /* |
3216 * Isolate the command and search for it in the command table. | |
1441 | 3217 * Exceptions: |
7 | 3218 * - the 'k' command can directly be followed by any character. |
3219 * - the 's' command can be followed directly by 'c', 'g', 'i', 'I' or 'r' | |
6472 | 3220 * but :sre[wind] is another command, as are :scr[iptnames], |
7 | 3221 * :scs[cope], :sim[alt], :sig[ns] and :sil[ent]. |
167 | 3222 * - the "d" command can directly be followed by 'l' or 'p' flag. |
7 | 3223 */ |
3224 p = eap->cmd; | |
3225 if (*p == 'k') | |
3226 { | |
3227 eap->cmdidx = CMD_k; | |
3228 ++p; | |
3229 } | |
3230 else if (p[0] == 's' | |
6987 | 3231 && ((p[1] == 'c' && (p[2] == NUL || (p[2] != 's' && p[2] != 'r' |
3232 && (p[3] == NUL || (p[3] != 'i' && p[4] != 'p'))))) | |
7 | 3233 || p[1] == 'g' |
3234 || (p[1] == 'i' && p[2] != 'm' && p[2] != 'l' && p[2] != 'g') | |
3235 || p[1] == 'I' | |
3236 || (p[1] == 'r' && p[2] != 'e'))) | |
3237 { | |
3238 eap->cmdidx = CMD_substitute; | |
3239 ++p; | |
3240 } | |
3241 else | |
3242 { | |
3243 while (ASCII_ISALPHA(*p)) | |
3244 ++p; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3245 // for python 3.x support ":py3", ":python3", ":py3file", etc. |
2330 | 3246 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
|
3247 { |
2366
7a57fe6a5157
Fix that :py3file was not working.
Bram Moolenaar <bram@vim.org>
parents:
2360
diff
changeset
|
3248 while (ASCII_ISALNUM(*p)) |
7a57fe6a5157
Fix that :py3file was not working.
Bram Moolenaar <bram@vim.org>
parents:
2360
diff
changeset
|
3249 ++p; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3250 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3251 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
|
3252 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3253 // 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
|
3254 ++p; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3255 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
|
3256 ++p; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3257 } |
2329
ad2889f48843
Added support for Python 3. (Roland Puntaier)
Bram Moolenaar <bram@vim.org>
parents:
2320
diff
changeset
|
3258 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3259 // check for non-alpha command |
7 | 3260 if (p == eap->cmd && vim_strchr((char_u *)"@*!=><&~#", *p) != NULL) |
3261 ++p; | |
3262 len = (int)(p - eap->cmd); | |
167 | 3263 if (*eap->cmd == 'd' && (p[-1] == 'l' || p[-1] == 'p')) |
3264 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3265 // 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
|
3266 // :delete with the 'l' flag. Same for 'p'. |
167 | 3267 for (i = 0; i < len; ++i) |
1872 | 3268 if (eap->cmd[i] != ((char_u *)"delete")[i]) |
167 | 3269 break; |
3270 if (i == len - 1) | |
3271 { | |
3272 --len; | |
3273 if (p[-1] == 'l') | |
3274 eap->flags |= EXFLAG_LIST; | |
3275 else | |
3276 eap->flags |= EXFLAG_PRINT; | |
3277 } | |
3278 } | |
7 | 3279 |
11236
62c96fee518e
patch 8.0.0504: looking up an Ex command is a bit slow
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
3280 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
|
3281 { |
11240
06307d812ca7
patch 8.0.0506: can't build with ANSI C
Christian Brabandt <cb@256bit.org>
parents:
11236
diff
changeset
|
3282 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
|
3283 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
|
3284 |
11236
62c96fee518e
patch 8.0.0504: looking up an Ex command is a bit slow
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
3285 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
|
3286 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
3287 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
|
3288 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
|
3289 } |
62c96fee518e
patch 8.0.0504: looking up an Ex command is a bit slow
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
3290 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3291 // 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
|
3292 // 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
|
3293 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
|
3294 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
|
3295 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
|
3296 } |
20075
516b10943fdb
patch 8.2.0593: finding a user command is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
20063
diff
changeset
|
3297 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
|
3298 eap->cmdidx = CMD_Next; |
7 | 3299 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
|
3300 eap->cmdidx = CMD_bang; |
7 | 3301 |
3302 for ( ; (int)eap->cmdidx < (int)CMD_SIZE; | |
3303 eap->cmdidx = (cmdidx_T)((int)eap->cmdidx + 1)) | |
3304 if (STRNCMP(cmdnames[(int)eap->cmdidx].cmd_name, (char *)eap->cmd, | |
3305 (size_t)len) == 0) | |
3306 { | |
3307 #ifdef FEAT_EVAL | |
3308 if (full != NULL | |
3309 && cmdnames[(int)eap->cmdidx].cmd_name[len] == NUL) | |
3310 *full = TRUE; | |
3311 #endif | |
3312 break; | |
3313 } | |
3314 | |
16411
5b5c5daf57de
patch 8.1.1210: support for user commands is spread out
Bram Moolenaar <Bram@vim.org>
parents:
16399
diff
changeset
|
3315 // 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
|
3316 // overruled by a user defined command. |
2633 | 3317 if ((eap->cmdidx == CMD_SIZE || eap->cmdidx == CMD_Print) |
3318 && *eap->cmd >= 'A' && *eap->cmd <= 'Z') | |
7 | 3319 { |
16411
5b5c5daf57de
patch 8.1.1210: support for user commands is spread out
Bram Moolenaar <Bram@vim.org>
parents:
16399
diff
changeset
|
3320 // User defined commands may contain digits. |
7 | 3321 while (ASCII_ISALNUM(*p)) |
3322 ++p; | |
184 | 3323 p = find_ucmd(eap, p, full, NULL, NULL); |
3324 } | |
3325 if (p == eap->cmd) | |
7 | 3326 eap->cmdidx = CMD_SIZE; |
3327 } | |
3328 | |
3329 return p; | |
3330 } | |
3331 | |
3332 #if defined(FEAT_EVAL) || defined(PROTO) | |
1447 | 3333 static struct cmdmod |
3334 { | |
3335 char *name; | |
3336 int minlen; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3337 int has_count; // :123verbose :3tab |
1447 | 3338 } cmdmods[] = { |
3339 {"aboveleft", 3, FALSE}, | |
3340 {"belowright", 3, FALSE}, | |
3341 {"botright", 2, FALSE}, | |
3342 {"browse", 3, FALSE}, | |
3343 {"confirm", 4, FALSE}, | |
9941
e975914c17e9
commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
9927
diff
changeset
|
3344 {"filter", 4, FALSE}, |
1447 | 3345 {"hide", 3, FALSE}, |
3346 {"keepalt", 5, FALSE}, | |
3347 {"keepjumps", 5, FALSE}, | |
3348 {"keepmarks", 3, FALSE}, | |
5467 | 3349 {"keeppatterns", 5, FALSE}, |
1447 | 3350 {"leftabove", 5, FALSE}, |
3351 {"lockmarks", 3, FALSE}, | |
1721 | 3352 {"noautocmd", 3, FALSE}, |
5737 | 3353 {"noswapfile", 3, FALSE}, |
1447 | 3354 {"rightbelow", 6, FALSE}, |
3355 {"sandbox", 3, FALSE}, | |
3356 {"silent", 3, FALSE}, | |
3357 {"tab", 3, TRUE}, | |
3358 {"topleft", 2, FALSE}, | |
1926 | 3359 {"unsilent", 3, FALSE}, |
1447 | 3360 {"verbose", 4, TRUE}, |
3361 {"vertical", 4, FALSE}, | |
3362 }; | |
3363 | |
3364 /* | |
3365 * Return length of a command modifier (including optional count). | |
3366 * Return zero when it's not a modifier. | |
3367 */ | |
3368 int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3369 modifier_len(char_u *cmd) |
1447 | 3370 { |
3371 int i, j; | |
3372 char_u *p = cmd; | |
3373 | |
3374 if (VIM_ISDIGIT(*cmd)) | |
3375 p = skipwhite(skipdigits(cmd)); | |
1880 | 3376 for (i = 0; i < (int)(sizeof(cmdmods) / sizeof(struct cmdmod)); ++i) |
1447 | 3377 { |
3378 for (j = 0; p[j] != NUL; ++j) | |
3379 if (p[j] != cmdmods[i].name[j]) | |
3380 break; | |
4857
84a8d1ba81c3
updated for version 7.3.1175
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3381 if (!ASCII_ISALPHA(p[j]) && j >= cmdmods[i].minlen |
1447 | 3382 && (p == cmd || cmdmods[i].has_count)) |
1570 | 3383 return j + (int)(p - cmd); |
1447 | 3384 } |
3385 return 0; | |
3386 } | |
3387 | |
7 | 3388 /* |
3389 * Return > 0 if an Ex command "name" exists. | |
3390 * Return 2 if there is an exact match. | |
3391 * Return 3 if there is an ambiguous match. | |
3392 */ | |
3393 int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3394 cmd_exists(char_u *name) |
7 | 3395 { |
3396 exarg_T ea; | |
3397 int full = FALSE; | |
3398 int i; | |
3399 int j; | |
866 | 3400 char_u *p; |
7 | 3401 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3402 // Check command modifiers. |
1880 | 3403 for (i = 0; i < (int)(sizeof(cmdmods) / sizeof(struct cmdmod)); ++i) |
7 | 3404 { |
3405 for (j = 0; name[j] != NUL; ++j) | |
3406 if (name[j] != cmdmods[i].name[j]) | |
3407 break; | |
3408 if (name[j] == NUL && j >= cmdmods[i].minlen) | |
3409 return (cmdmods[i].name[j] == NUL ? 2 : 1); | |
3410 } | |
3411 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3412 // 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
|
3413 // For ":2match" and ":3match" we need to skip the number. |
862 | 3414 ea.cmd = (*name == '2' || *name == '3') ? name + 1 : name; |
7 | 3415 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
|
3416 p = find_ex_command(&ea, &full, NULL, NULL); |
866 | 3417 if (p == NULL) |
7 | 3418 return 3; |
862 | 3419 if (vim_isdigit(*name) && ea.cmdidx != CMD_match) |
3420 return 0; | |
866 | 3421 if (*skipwhite(p) != NUL) |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3422 return 0; // trailing garbage |
7 | 3423 return (ea.cmdidx == CMD_SIZE ? 0 : (full ? 2 : 1)); |
3424 } | |
3425 #endif | |
3426 | |
17835
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17823
diff
changeset
|
3427 cmdidx_T |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17823
diff
changeset
|
3428 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
|
3429 { |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17823
diff
changeset
|
3430 cmdidx_T idx; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17823
diff
changeset
|
3431 |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17823
diff
changeset
|
3432 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
|
3433 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
|
3434 if (STRNCMP(cmdnames[(int)idx].cmd_name, cmd, (size_t)len) == 0) |
7 | 3435 break; |
3436 | |
17835
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17823
diff
changeset
|
3437 return idx; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17823
diff
changeset
|
3438 } |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17823
diff
changeset
|
3439 |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17823
diff
changeset
|
3440 long |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17823
diff
changeset
|
3441 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
|
3442 { |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17823
diff
changeset
|
3443 return (long)cmdnames[(int)idx].cmd_argt; |
7 | 3444 } |
3445 | |
3446 /* | |
14505
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3447 * Skip a range specifier of the form: addr [,addr] [;addr] .. |
7 | 3448 * |
3449 * Backslashed delimiters after / or ? will be skipped, and commands will | |
3450 * not be expanded between /'s and ?'s or after "'". | |
3451 * | |
167 | 3452 * Also skip white space and ":" characters. |
7 | 3453 * Returns the "cmd" pointer advanced to beyond the range. |
3454 */ | |
3455 char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3456 skip_range( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3457 char_u *cmd, |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3458 int *ctx) // pointer to xp_context or NULL |
7 | 3459 { |
1872 | 3460 unsigned delim; |
7 | 3461 |
10817
cc8079703414
patch 8.0.0298: Ex command range with repeated search does not work
Christian Brabandt <cb@256bit.org>
parents:
10809
diff
changeset
|
3462 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
|
3463 { |
cc8079703414
patch 8.0.0298: Ex command range with repeated search does not work
Christian Brabandt <cb@256bit.org>
parents:
10809
diff
changeset
|
3464 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
|
3465 { |
cc8079703414
patch 8.0.0298: Ex command range with repeated search does not work
Christian Brabandt <cb@256bit.org>
parents:
10809
diff
changeset
|
3466 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
|
3467 ++cmd; |
cc8079703414
patch 8.0.0298: Ex command range with repeated search does not work
Christian Brabandt <cb@256bit.org>
parents:
10809
diff
changeset
|
3468 else |
cc8079703414
patch 8.0.0298: Ex command range with repeated search does not work
Christian Brabandt <cb@256bit.org>
parents:
10809
diff
changeset
|
3469 break; |
cc8079703414
patch 8.0.0298: Ex command range with repeated search does not work
Christian Brabandt <cb@256bit.org>
parents:
10809
diff
changeset
|
3470 } |
cc8079703414
patch 8.0.0298: Ex command range with repeated search does not work
Christian Brabandt <cb@256bit.org>
parents:
10809
diff
changeset
|
3471 else if (*cmd == '\'') |
7 | 3472 { |
3473 if (*++cmd == NUL && ctx != NULL) | |
3474 *ctx = EXPAND_NOTHING; | |
3475 } | |
3476 else if (*cmd == '/' || *cmd == '?') | |
3477 { | |
3478 delim = *cmd++; | |
3479 while (*cmd != NUL && *cmd != delim) | |
3480 if (*cmd++ == '\\' && *cmd != NUL) | |
3481 ++cmd; | |
3482 if (*cmd == NUL && ctx != NULL) | |
3483 *ctx = EXPAND_NOTHING; | |
3484 } | |
3485 if (*cmd != NUL) | |
3486 ++cmd; | |
3487 } | |
167 | 3488 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3489 // Skip ":" and white space. |
167 | 3490 while (*cmd == ':') |
3491 cmd = skipwhite(cmd + 1); | |
3492 | |
7 | 3493 return cmd; |
3494 } | |
3495 | |
17650
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
3496 static void |
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
3497 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
|
3498 { |
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
3499 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
|
3500 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
|
3501 else |
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
3502 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
|
3503 } |
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
3504 |
7 | 3505 /* |
14677
7771a1ff8b99
patch 8.1.0351: 'incsearch' for :/foo/s//<Esc> changes last search pattern
Christian Brabandt <cb@256bit.org>
parents:
14648
diff
changeset
|
3506 * Get a single EX address. |
7 | 3507 * |
3508 * Set ptr to the next character after the part that was interpreted. | |
3509 * 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
|
3510 * This may set the last used search pattern. |
7 | 3511 * |
3512 * Return MAXLNUM when no Ex address was found. | |
3513 */ | |
3514 static linenr_T | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3515 get_address( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3516 exarg_T *eap UNUSED, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3517 char_u **ptr, |
18849
b77ef4b8af7c
patch 8.1.2411: function argument copied unnecessarily
Bram Moolenaar <Bram@vim.org>
parents:
18779
diff
changeset
|
3518 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
|
3519 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
|
3520 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
|
3521 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
|
3522 int address_count UNUSED) // 1 for first address, >1 after comma |
7 | 3523 { |
3524 int c; | |
3525 int i; | |
3526 long n; | |
3527 char_u *cmd; | |
3528 pos_T pos; | |
3529 pos_T *fp; | |
3530 linenr_T lnum; | |
6424 | 3531 buf_T *buf; |
7 | 3532 |
3533 cmd = skipwhite(*ptr); | |
3534 lnum = MAXLNUM; | |
3535 do | |
3536 { | |
3537 switch (*cmd) | |
3538 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3539 case '.': // '.' - Cursor position |
6398 | 3540 ++cmd; |
3541 switch (addr_type) | |
3542 { | |
3543 case ADDR_LINES: | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
3544 case ADDR_OTHER: |
7 | 3545 lnum = curwin->w_cursor.lnum; |
3546 break; | |
6398 | 3547 case ADDR_WINDOWS: |
6409 | 3548 lnum = CURRENT_WIN_NR; |
6398 | 3549 break; |
3550 case ADDR_ARGUMENTS: | |
3551 lnum = curwin->w_arg_idx + 1; | |
3552 break; | |
3553 case ADDR_LOADED_BUFFERS: | |
6424 | 3554 case ADDR_BUFFERS: |
6398 | 3555 lnum = curbuf->b_fnum; |
3556 break; | |
3557 case ADDR_TABS: | |
6409 | 3558 lnum = CURRENT_TAB_NR; |
6398 | 3559 break; |
17650
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
3560 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
|
3561 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
|
3562 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
|
3563 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
|
3564 cmd = NULL; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
3565 goto error; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
3566 break; |
16479
7dcf301d1432
patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents:
16475
diff
changeset
|
3567 case ADDR_QUICKFIX: |
7105
f4456e686406
commit https://github.com/vim/vim/commit/e906c502079770ae0e0071c74cefb802689ff193
Christian Brabandt <cb@256bit.org>
parents:
7092
diff
changeset
|
3568 #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
|
3569 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
|
3570 #endif |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
3571 break; |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
3572 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
|
3573 #ifdef FEAT_QUICKFIX |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
3574 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
|
3575 #endif |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
3576 break; |
6398 | 3577 } |
3578 break; | |
7 | 3579 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3580 case '$': // '$' - last line |
6398 | 3581 ++cmd; |
3582 switch (addr_type) | |
3583 { | |
3584 case ADDR_LINES: | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
3585 case ADDR_OTHER: |
7 | 3586 lnum = curbuf->b_ml.ml_line_count; |
3587 break; | |
6398 | 3588 case ADDR_WINDOWS: |
6409 | 3589 lnum = LAST_WIN_NR; |
6398 | 3590 break; |
3591 case ADDR_ARGUMENTS: | |
3592 lnum = ARGCOUNT; | |
3593 break; | |
3594 case ADDR_LOADED_BUFFERS: | |
6424 | 3595 buf = lastbuf; |
3596 while (buf->b_ml.ml_mfp == NULL) | |
3597 { | |
3598 if (buf->b_prev == NULL) | |
3599 break; | |
3600 buf = buf->b_prev; | |
3601 } | |
3602 lnum = buf->b_fnum; | |
3603 break; | |
3604 case ADDR_BUFFERS: | |
6398 | 3605 lnum = lastbuf->b_fnum; |
3606 break; | |
3607 case ADDR_TABS: | |
6409 | 3608 lnum = LAST_TAB_NR; |
6398 | 3609 break; |
17650
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
3610 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
|
3611 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
|
3612 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
|
3613 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
|
3614 cmd = NULL; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
3615 goto error; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
3616 break; |
16479
7dcf301d1432
patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents:
16475
diff
changeset
|
3617 case ADDR_QUICKFIX: |
7105
f4456e686406
commit https://github.com/vim/vim/commit/e906c502079770ae0e0071c74cefb802689ff193
Christian Brabandt <cb@256bit.org>
parents:
7092
diff
changeset
|
3618 #ifdef FEAT_QUICKFIX |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
3619 lnum = qf_get_size(eap); |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
3620 if (lnum == 0) |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
3621 lnum = 1; |
16479
7dcf301d1432
patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents:
16475
diff
changeset
|
3622 #endif |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
3623 break; |
16515
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
3624 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
|
3625 #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
|
3626 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
|
3627 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
|
3628 lnum = 1; |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
3629 #endif |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
3630 break; |
6398 | 3631 } |
3632 break; | |
7 | 3633 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3634 case '\'': // ''' - mark |
6398 | 3635 if (*++cmd == NUL) |
3636 { | |
3637 cmd = NULL; | |
3638 goto error; | |
3639 } | |
3640 if (addr_type != ADDR_LINES) | |
3641 { | |
17650
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
3642 addr_error(addr_type); |
6581 | 3643 cmd = NULL; |
6398 | 3644 goto error; |
3645 } | |
3646 if (skip) | |
3647 ++cmd; | |
3648 else | |
3649 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3650 // 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
|
3651 // used by itself: ":'M". |
6398 | 3652 fp = getmark(*cmd, to_other_file && cmd[1] == NUL); |
3653 ++cmd; | |
3654 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
|
3655 // Jumped to another file. |
6398 | 3656 lnum = curwin->w_cursor.lnum; |
3657 else | |
3658 { | |
3659 if (check_mark(fp) == FAIL) | |
7 | 3660 { |
3661 cmd = NULL; | |
3662 goto error; | |
3663 } | |
6398 | 3664 lnum = fp->lnum; |
3665 } | |
3666 } | |
3667 break; | |
7 | 3668 |
3669 case '/': | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3670 case '?': // '/' or '?' - search |
6398 | 3671 c = *cmd++; |
3672 if (addr_type != ADDR_LINES) | |
3673 { | |
17650
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
3674 addr_error(addr_type); |
6581 | 3675 cmd = NULL; |
6398 | 3676 goto error; |
3677 } | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3678 if (skip) // skip "/pat/" |
6398 | 3679 { |
19892
5feb426d2ea1
patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19685
diff
changeset
|
3680 cmd = skip_regexp(cmd, c, (int)p_magic); |
6398 | 3681 if (*cmd == c) |
3682 ++cmd; | |
3683 } | |
3684 else | |
3685 { | |
14760
fd69edd2c67e
patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents:
14700
diff
changeset
|
3686 int flags; |
fd69edd2c67e
patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents:
14700
diff
changeset
|
3687 |
fd69edd2c67e
patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents:
14700
diff
changeset
|
3688 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
|
3689 |
fd69edd2c67e
patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents:
14700
diff
changeset
|
3690 // 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
|
3691 // there. |
6398 | 3692 if (lnum != MAXLNUM) |
3693 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
|
3694 |
fd69edd2c67e
patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents:
14700
diff
changeset
|
3695 // 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
|
3696 // 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
|
3697 // 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
|
3698 // 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
|
3699 // 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
|
3700 // next/previous line. |
13082
a80082fd1a1d
patch 8.0.1416: crash when searching for a sentence
Christian Brabandt <cb@256bit.org>
parents:
12824
diff
changeset
|
3701 if (c == '/' && curwin->w_cursor.lnum > 0) |
6398 | 3702 curwin->w_cursor.col = MAXCOL; |
3703 else | |
3704 curwin->w_cursor.col = 0; | |
3705 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
|
3706 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
|
3707 if (!do_search(NULL, c, c, cmd, 1L, flags, NULL)) |
6398 | 3708 { |
3709 curwin->w_cursor = pos; | |
3710 cmd = NULL; | |
3711 goto error; | |
3712 } | |
3713 lnum = curwin->w_cursor.lnum; | |
3714 curwin->w_cursor = pos; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3715 // adjust command string pointer |
6398 | 3716 cmd += searchcmdlen; |
3717 } | |
3718 break; | |
7 | 3719 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3720 case '\\': // "\?", "\/" or "\&", repeat search |
6398 | 3721 ++cmd; |
3722 if (addr_type != ADDR_LINES) | |
3723 { | |
17650
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
3724 addr_error(addr_type); |
6581 | 3725 cmd = NULL; |
6398 | 3726 goto error; |
3727 } | |
3728 if (*cmd == '&') | |
3729 i = RE_SUBST; | |
3730 else if (*cmd == '?' || *cmd == '/') | |
3731 i = RE_SEARCH; | |
3732 else | |
3733 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
3734 emsg(_(e_backslash)); |
6398 | 3735 cmd = NULL; |
3736 goto error; | |
3737 } | |
3738 | |
3739 if (!skip) | |
3740 { | |
3741 /* | |
3742 * When search follows another address, start from | |
3743 * there. | |
3744 */ | |
3745 if (lnum != MAXLNUM) | |
3746 pos.lnum = lnum; | |
3747 else | |
3748 pos.lnum = curwin->w_cursor.lnum; | |
3749 | |
3750 /* | |
3751 * Start the search just like for the above | |
3752 * do_search(). | |
3753 */ | |
3754 if (*cmd != '?') | |
3755 pos.col = MAXCOL; | |
3756 else | |
3757 pos.col = 0; | |
7007 | 3758 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
|
3759 if (searchit(curwin, curbuf, &pos, NULL, |
6398 | 3760 *cmd == '?' ? BACKWARD : FORWARD, |
18358
34d5cd432cac
patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents:
18297
diff
changeset
|
3761 (char_u *)"", 1L, SEARCH_MSG, i, NULL) != FAIL) |
6398 | 3762 lnum = pos.lnum; |
3763 else | |
3764 { | |
3765 cmd = NULL; | |
3766 goto error; | |
3767 } | |
3768 } | |
3769 ++cmd; | |
3770 break; | |
7 | 3771 |
3772 default: | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3773 if (VIM_ISDIGIT(*cmd)) // absolute line number |
6398 | 3774 lnum = getdigits(&cmd); |
7 | 3775 } |
3776 | |
3777 for (;;) | |
3778 { | |
3779 cmd = skipwhite(cmd); | |
3780 if (*cmd != '-' && *cmd != '+' && !VIM_ISDIGIT(*cmd)) | |
3781 break; | |
3782 | |
3783 if (lnum == MAXLNUM) | |
6398 | 3784 { |
3785 switch (addr_type) | |
3786 { | |
3787 case ADDR_LINES: | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
3788 case ADDR_OTHER: |
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
3789 // "+1" is same as ".+1" |
6409 | 3790 lnum = curwin->w_cursor.lnum; |
6398 | 3791 break; |
3792 case ADDR_WINDOWS: | |
6409 | 3793 lnum = CURRENT_WIN_NR; |
6398 | 3794 break; |
3795 case ADDR_ARGUMENTS: | |
3796 lnum = curwin->w_arg_idx + 1; | |
3797 break; | |
3798 case ADDR_LOADED_BUFFERS: | |
6424 | 3799 case ADDR_BUFFERS: |
6398 | 3800 lnum = curbuf->b_fnum; |
3801 break; | |
3802 case ADDR_TABS: | |
6409 | 3803 lnum = CURRENT_TAB_NR; |
6398 | 3804 break; |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
3805 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
|
3806 lnum = 1; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
3807 break; |
16479
7dcf301d1432
patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents:
16475
diff
changeset
|
3808 case ADDR_QUICKFIX: |
7105
f4456e686406
commit https://github.com/vim/vim/commit/e906c502079770ae0e0071c74cefb802689ff193
Christian Brabandt <cb@256bit.org>
parents:
7092
diff
changeset
|
3809 #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
|
3810 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
|
3811 #endif |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
3812 break; |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
3813 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
|
3814 #ifdef FEAT_QUICKFIX |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
3815 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
|
3816 #endif |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
3817 break; |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
3818 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
|
3819 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
|
3820 lnum = 0; |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
3821 break; |
6398 | 3822 } |
3823 } | |
3824 | |
7 | 3825 if (VIM_ISDIGIT(*cmd)) |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3826 i = '+'; // "number" is same as "+number" |
7 | 3827 else |
3828 i = *cmd++; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3829 if (!VIM_ISDIGIT(*cmd)) // '+' is '+1', but '+0' is not '+1' |
7 | 3830 n = 1; |
3831 else | |
3832 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
|
3833 |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
3834 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
|
3835 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
3836 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
|
3837 cmd = NULL; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
3838 goto error; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
3839 } |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
3840 else if (addr_type == ADDR_LOADED_BUFFERS |
6424 | 3841 || addr_type == ADDR_BUFFERS) |
6581 | 3842 lnum = compute_buffer_local_count( |
3843 addr_type, lnum, (i == '-') ? -1 * n : n); | |
7 | 3844 else |
10484
c7de1536780a
commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
10480
diff
changeset
|
3845 { |
c7de1536780a
commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
10480
diff
changeset
|
3846 #ifdef FEAT_FOLDING |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3847 // 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
|
3848 // 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
|
3849 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
|
3850 && address_count >= 2) |
c7de1536780a
commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
10480
diff
changeset
|
3851 (void)hasFolding(lnum, NULL, &lnum); |
c7de1536780a
commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
10480
diff
changeset
|
3852 #endif |
c7de1536780a
commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
10480
diff
changeset
|
3853 if (i == '-') |
c7de1536780a
commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
10480
diff
changeset
|
3854 lnum -= n; |
c7de1536780a
commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
10480
diff
changeset
|
3855 else |
c7de1536780a
commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
10480
diff
changeset
|
3856 lnum += n; |
c7de1536780a
commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
10480
diff
changeset
|
3857 } |
7 | 3858 } |
3859 } while (*cmd == '/' || *cmd == '?'); | |
3860 | |
3861 error: | |
3862 *ptr = cmd; | |
3863 return lnum; | |
3864 } | |
3865 | |
3866 /* | |
167 | 3867 * Get flags from an Ex command argument. |
3868 */ | |
3869 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3870 get_flags(exarg_T *eap) |
167 | 3871 { |
3872 while (vim_strchr((char_u *)"lp#", *eap->arg) != NULL) | |
3873 { | |
3874 if (*eap->arg == 'l') | |
3875 eap->flags |= EXFLAG_LIST; | |
3876 else if (*eap->arg == 'p') | |
3877 eap->flags |= EXFLAG_PRINT; | |
3878 else | |
3879 eap->flags |= EXFLAG_NR; | |
3880 eap->arg = skipwhite(eap->arg + 1); | |
3881 } | |
3882 } | |
3883 | |
3884 /* | |
7 | 3885 * Function called for command which is Not Implemented. NI! |
3886 */ | |
3887 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3888 ex_ni(exarg_T *eap) |
7 | 3889 { |
3890 if (!eap->skip) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
3891 eap->errmsg = N_("E319: Sorry, the command is not available in this version"); |
7 | 3892 } |
3893 | |
1315 | 3894 #ifdef HAVE_EX_SCRIPT_NI |
7 | 3895 /* |
3896 * Function called for script command which is Not Implemented. NI! | |
3897 * Skips over ":perl <<EOF" constructs. | |
3898 */ | |
3899 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3900 ex_script_ni(exarg_T *eap) |
7 | 3901 { |
3902 if (!eap->skip) | |
3903 ex_ni(eap); | |
3904 else | |
3905 vim_free(script_get(eap, eap->arg)); | |
3906 } | |
3907 #endif | |
3908 | |
3909 /* | |
3910 * Check range in Ex command for validity. | |
3911 * Return NULL when valid, error message when invalid. | |
3912 */ | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
3913 static char * |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3914 invalid_range(exarg_T *eap) |
7 | 3915 { |
6472 | 3916 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
|
3917 |
7 | 3918 if ( eap->line1 < 0 |
3919 || eap->line2 < 0 | |
6472 | 3920 || 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
|
3921 return _(e_invrange); |
6472 | 3922 |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
3923 if (eap->argt & EX_RANGE) |
6472 | 3924 { |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
3925 switch (eap->addr_type) |
6472 | 3926 { |
3927 case ADDR_LINES: | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
3928 if (eap->line2 > curbuf->b_ml.ml_line_count |
7 | 3929 #ifdef FEAT_DIFF |
6472 | 3930 + (eap->cmdidx == CMD_diffget) |
3931 #endif | |
3932 ) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
3933 return _(e_invrange); |
6472 | 3934 break; |
3935 case ADDR_ARGUMENTS: | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3936 // add 1 if ARGCOUNT is 0 |
6581 | 3937 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
|
3938 return _(e_invrange); |
6472 | 3939 break; |
3940 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
|
3941 // 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
|
3942 // exist. |
7e6b7a4f13bc
patch 8.1.1908: every popup window consumes a buffer number
Bram Moolenaar <Bram@vim.org>
parents:
17817
diff
changeset
|
3943 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
|
3944 return _(e_invrange); |
6472 | 3945 break; |
3946 case ADDR_LOADED_BUFFERS: | |
3947 buf = firstbuf; | |
3948 while (buf->b_ml.ml_mfp == NULL) | |
3949 { | |
3950 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
|
3951 return _(e_invrange); |
6472 | 3952 buf = buf->b_next; |
3953 } | |
3954 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
|
3955 return _(e_invrange); |
6472 | 3956 buf = lastbuf; |
3957 while (buf->b_ml.ml_mfp == NULL) | |
3958 { | |
3959 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
|
3960 return _(e_invrange); |
6472 | 3961 buf = buf->b_prev; |
3962 } | |
3963 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
|
3964 return _(e_invrange); |
6472 | 3965 break; |
3966 case ADDR_WINDOWS: | |
6480 | 3967 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
|
3968 return _(e_invrange); |
6472 | 3969 break; |
3970 case ADDR_TABS: | |
3971 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
|
3972 return _(e_invrange); |
6472 | 3973 break; |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
3974 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
|
3975 case ADDR_OTHER: |
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
3976 // 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
|
3977 break; |
16479
7dcf301d1432
patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents:
16475
diff
changeset
|
3978 case ADDR_QUICKFIX: |
7105
f4456e686406
commit https://github.com/vim/vim/commit/e906c502079770ae0e0071c74cefb802689ff193
Christian Brabandt <cb@256bit.org>
parents:
7092
diff
changeset
|
3979 #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
|
3980 // 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
|
3981 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
|
3982 return _(e_invrange); |
16479
7dcf301d1432
patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents:
16475
diff
changeset
|
3983 #endif |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
3984 break; |
16515
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
3985 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
|
3986 #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
|
3987 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
|
3988 || 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
|
3989 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
|
3990 #endif |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
3991 break; |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
3992 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
|
3993 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
|
3994 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
|
3995 break; |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
3996 case ADDR_NONE: |
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
3997 // 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
|
3998 break; |
6472 | 3999 } |
4000 } | |
7 | 4001 return NULL; |
4002 } | |
4003 | |
4004 /* | |
4005 * Correct the range for zero line number, if required. | |
4006 */ | |
4007 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4008 correct_range(exarg_T *eap) |
7 | 4009 { |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
4010 if (!(eap->argt & EX_ZEROR)) // zero in range not allowed |
7 | 4011 { |
4012 if (eap->line1 == 0) | |
4013 eap->line1 = 1; | |
4014 if (eap->line2 == 0) | |
4015 eap->line2 = 1; | |
4016 } | |
4017 } | |
4018 | |
153 | 4019 #ifdef FEAT_QUICKFIX |
4020 /* | |
4021 * For a ":vimgrep" or ":vimgrepadd" command return a pointer past the | |
4022 * pattern. Otherwise return eap->arg. | |
4023 */ | |
4024 static char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4025 skip_grep_pat(exarg_T *eap) |
153 | 4026 { |
4027 char_u *p = eap->arg; | |
4028 | |
655 | 4029 if (*p != NUL && (eap->cmdidx == CMD_vimgrep || eap->cmdidx == CMD_lvimgrep |
4030 || eap->cmdidx == CMD_vimgrepadd | |
4031 || eap->cmdidx == CMD_lvimgrepadd | |
4032 || grep_internal(eap->cmdidx))) | |
153 | 4033 { |
170 | 4034 p = skip_vimgrep_pat(p, NULL, NULL); |
153 | 4035 if (p == NULL) |
4036 p = eap->arg; | |
4037 } | |
4038 return p; | |
4039 } | |
344 | 4040 |
4041 /* | |
4042 * For the ":make" and ":grep" commands insert the 'makeprg'/'grepprg' option | |
4043 * in the command line, so that things like % get expanded. | |
4044 */ | |
4045 static char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4046 replace_makeprg(exarg_T *eap, char_u *p, char_u **cmdlinep) |
344 | 4047 { |
4048 char_u *new_cmdline; | |
4049 char_u *program; | |
4050 char_u *pos; | |
4051 char_u *ptr; | |
4052 int len; | |
4053 int i; | |
4054 | |
4055 /* | |
4056 * Don't do it when ":vimgrep" is used for ":grep". | |
4057 */ | |
655 | 4058 if ((eap->cmdidx == CMD_make || eap->cmdidx == CMD_lmake |
4059 || eap->cmdidx == CMD_grep || eap->cmdidx == CMD_lgrep | |
4060 || eap->cmdidx == CMD_grepadd | |
4061 || eap->cmdidx == CMD_lgrepadd) | |
344 | 4062 && !grep_internal(eap->cmdidx)) |
4063 { | |
655 | 4064 if (eap->cmdidx == CMD_grep || eap->cmdidx == CMD_lgrep |
4065 || eap->cmdidx == CMD_grepadd || eap->cmdidx == CMD_lgrepadd) | |
344 | 4066 { |
4067 if (*curbuf->b_p_gp == NUL) | |
4068 program = p_gp; | |
4069 else | |
4070 program = curbuf->b_p_gp; | |
4071 } | |
4072 else | |
4073 { | |
4074 if (*curbuf->b_p_mp == NUL) | |
4075 program = p_mp; | |
4076 else | |
4077 program = curbuf->b_p_mp; | |
4078 } | |
4079 | |
4080 p = skipwhite(p); | |
4081 | |
4082 if ((pos = (char_u *)strstr((char *)program, "$*")) != NULL) | |
4083 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4084 // replace $* by given arguments |
344 | 4085 i = 1; |
4086 while ((pos = (char_u *)strstr((char *)pos + 2, "$*")) != NULL) | |
4087 ++i; | |
4088 len = (int)STRLEN(p); | |
16782
fc58fee685e2
patch 8.1.1393: unnecessary type casts
Bram Moolenaar <Bram@vim.org>
parents:
16780
diff
changeset
|
4089 new_cmdline = alloc(STRLEN(program) + i * (len - 2) + 1); |
344 | 4090 if (new_cmdline == NULL) |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4091 return NULL; // out of memory |
344 | 4092 ptr = new_cmdline; |
4093 while ((pos = (char_u *)strstr((char *)program, "$*")) != NULL) | |
4094 { | |
4095 i = (int)(pos - program); | |
4096 STRNCPY(ptr, program, i); | |
4097 STRCPY(ptr += i, p); | |
4098 ptr += len; | |
4099 program = pos + 2; | |
4100 } | |
4101 STRCPY(ptr, program); | |
4102 } | |
4103 else | |
4104 { | |
16782
fc58fee685e2
patch 8.1.1393: unnecessary type casts
Bram Moolenaar <Bram@vim.org>
parents:
16780
diff
changeset
|
4105 new_cmdline = alloc(STRLEN(program) + STRLEN(p) + 2); |
344 | 4106 if (new_cmdline == NULL) |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4107 return NULL; // out of memory |
344 | 4108 STRCPY(new_cmdline, program); |
4109 STRCAT(new_cmdline, " "); | |
4110 STRCAT(new_cmdline, p); | |
4111 } | |
4112 msg_make(p); | |
4113 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4114 // 'eap->cmd' is not set here, because it is not used at CMD_make |
344 | 4115 vim_free(*cmdlinep); |
4116 *cmdlinep = new_cmdline; | |
4117 p = new_cmdline; | |
4118 } | |
4119 return p; | |
4120 } | |
153 | 4121 #endif |
4122 | |
7 | 4123 /* |
4124 * 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
|
4125 * When an error is detected, "errormsgp" is set to a non-NULL pointer. |
7 | 4126 * Return FAIL for failure, OK otherwise. |
4127 */ | |
4128 int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4129 expand_filename( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4130 exarg_T *eap, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4131 char_u **cmdlinep, |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
4132 char **errormsgp) |
7 | 4133 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4134 int has_wildcards; // need to expand wildcards |
7 | 4135 char_u *repl; |
4136 int srclen; | |
4137 char_u *p; | |
4138 int n; | |
1098 | 4139 int escaped; |
7 | 4140 |
153 | 4141 #ifdef FEAT_QUICKFIX |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4142 // Skip a regexp pattern for ":vimgrep[add] pat file..." |
153 | 4143 p = skip_grep_pat(eap); |
4144 #else | |
4145 p = eap->arg; | |
4146 #endif | |
4147 | |
7 | 4148 /* |
4149 * Decide to expand wildcards *before* replacing '%', '#', etc. If | |
4150 * the file name contains a wildcard it should not cause expanding. | |
4151 * (it will be expanded anyway if there is a wildcard before replacing). | |
4152 */ | |
153 | 4153 has_wildcards = mch_has_wildcard(p); |
4154 while (*p != NUL) | |
7 | 4155 { |
9 | 4156 #ifdef FEAT_EVAL |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4157 // Skip over `=expr`, wildcards in it are not expanded. |
9 | 4158 if (p[0] == '`' && p[1] == '=') |
4159 { | |
4160 p += 2; | |
4161 (void)skip_expr(&p); | |
4162 if (*p == '`') | |
4163 ++p; | |
4164 continue; | |
4165 } | |
4166 #endif | |
7 | 4167 /* |
4168 * Quick check if this cannot be the start of a special string. | |
4169 * Also removes backslash before '%', '#' and '<'. | |
4170 */ | |
4171 if (vim_strchr((char_u *)"%#<", *p) == NULL) | |
4172 { | |
4173 ++p; | |
4174 continue; | |
4175 } | |
4176 | |
4177 /* | |
4178 * Try to find a match at this position. | |
4179 */ | |
1098 | 4180 repl = eval_vars(p, eap->arg, &srclen, &(eap->do_ecmd_lnum), |
4181 errormsgp, &escaped); | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4182 if (*errormsgp != NULL) // error detected |
7 | 4183 return FAIL; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4184 if (repl == NULL) // no match found |
7 | 4185 { |
4186 p += srclen; | |
4187 continue; | |
4188 } | |
4189 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4190 // 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
|
4191 // literally. But do expand "~/file", "~user/file" and "$HOME/file". |
37 | 4192 if (vim_strchr(repl, '$') != NULL || vim_strchr(repl, '~') != NULL) |
4193 { | |
4194 char_u *l = repl; | |
4195 | |
4196 repl = expand_env_save(repl); | |
4197 vim_free(l); | |
4198 } | |
4199 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4200 // 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
|
4201 // Don't do this for: |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4202 // - 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
|
4203 // - 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
|
4204 // - 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
|
4205 // separate arguments then). |
7 | 4206 if (!eap->usefilter |
1098 | 4207 && !escaped |
7 | 4208 && eap->cmdidx != CMD_bang |
4209 && 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
|
4210 && eap->cmdidx != CMD_grepadd |
1c1cb1e9b7b3
patch 8.0.0785: wildcards are not expanded for :terminal
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
4211 && eap->cmdidx != CMD_hardcopy |
655 | 4212 && eap->cmdidx != CMD_lgrep |
4213 && 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
|
4214 && eap->cmdidx != CMD_lmake |
1c1cb1e9b7b3
patch 8.0.0785: wildcards are not expanded for :terminal
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
4215 && eap->cmdidx != CMD_make |
1c1cb1e9b7b3
patch 8.0.0785: wildcards are not expanded for :terminal
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
4216 && eap->cmdidx != CMD_terminal |
7 | 4217 #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
|
4218 && !(eap->argt & EX_NOSPC) |
7 | 4219 #endif |
4220 ) | |
4221 { | |
4222 char_u *l; | |
4223 #ifdef BACKSLASH_IN_FILENAME | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4224 // 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
|
4225 // remove it later. |
7 | 4226 static char_u *nobslash = (char_u *)" \t\"|"; |
4227 # define ESCAPE_CHARS nobslash | |
4228 #else | |
4229 # define ESCAPE_CHARS escape_chars | |
4230 #endif | |
4231 | |
4232 for (l = repl; *l; ++l) | |
4233 if (vim_strchr(ESCAPE_CHARS, *l) != NULL) | |
4234 { | |
4235 l = vim_strsave_escaped(repl, ESCAPE_CHARS); | |
4236 if (l != NULL) | |
4237 { | |
4238 vim_free(repl); | |
4239 repl = l; | |
4240 } | |
4241 break; | |
4242 } | |
4243 } | |
4244 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4245 // 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
|
4246 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
|
4247 || eap->cmdidx == CMD_terminal) |
5778 | 4248 && vim_strpbrk(repl, (char_u *)"!") != NULL) |
7 | 4249 { |
4250 char_u *l; | |
4251 | |
5778 | 4252 l = vim_strsave_escaped(repl, (char_u *)"!"); |
7 | 4253 if (l != NULL) |
4254 { | |
4255 vim_free(repl); | |
4256 repl = l; | |
4257 } | |
4258 } | |
4259 | |
4260 p = repl_cmdline(eap, p, srclen, repl, cmdlinep); | |
4261 vim_free(repl); | |
4262 if (p == NULL) | |
4263 return FAIL; | |
4264 } | |
4265 | |
4266 /* | |
4267 * One file argument: Expand wildcards. | |
4268 * Don't do this with ":r !command" or ":w !command". | |
4269 */ | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
4270 if ((eap->argt & EX_NOSPC) && !eap->usefilter) |
7 | 4271 { |
4272 /* | |
4273 * May do this twice: | |
4274 * 1. Replace environment variables. | |
4275 * 2. Replace any other wildcards, remove backslashes. | |
4276 */ | |
4277 for (n = 1; n <= 2; ++n) | |
4278 { | |
4279 if (n == 2) | |
4280 { | |
4281 /* | |
4282 * Halve the number of backslashes (this is Vi compatible). | |
4283 * For Unix and OS/2, when wildcards are expanded, this is | |
4284 * done by ExpandOne() below. | |
4285 */ | |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7262
diff
changeset
|
4286 #if defined(UNIX) |
7 | 4287 if (!has_wildcards) |
4288 #endif | |
4289 backslash_halve(eap->arg); | |
4290 } | |
4291 | |
4292 if (has_wildcards) | |
4293 { | |
4294 if (n == 1) | |
4295 { | |
4296 /* | |
4297 * First loop: May expand environment variables. This | |
4298 * can be done much faster with expand_env() than with | |
4299 * something else (e.g., calling a shell). | |
4300 * After expanding environment variables, check again | |
4301 * if there are still wildcards present. | |
4302 */ | |
4303 if (vim_strchr(eap->arg, '$') != NULL | |
4304 || vim_strchr(eap->arg, '~') != NULL) | |
4305 { | |
372 | 4306 expand_env_esc(eap->arg, NameBuff, MAXPATHL, |
1408 | 4307 TRUE, TRUE, NULL); |
7 | 4308 has_wildcards = mch_has_wildcard(NameBuff); |
4309 p = NameBuff; | |
4310 } | |
4311 else | |
4312 p = NULL; | |
4313 } | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4314 else // n == 2 |
7 | 4315 { |
4316 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
|
4317 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
|
4318 | WILD_NOERROR | WILD_ADD_SLASH; |
7 | 4319 |
4320 ExpandInit(&xpc); | |
4321 xpc.xp_context = EXPAND_FILES; | |
2652 | 4322 if (p_wic) |
4323 options += WILD_ICASE; | |
7 | 4324 p = ExpandOne(&xpc, eap->arg, NULL, |
2652 | 4325 options, WILD_EXPAND_FREE); |
7 | 4326 if (p == NULL) |
4327 return FAIL; | |
4328 } | |
4329 if (p != NULL) | |
4330 { | |
4331 (void)repl_cmdline(eap, eap->arg, (int)STRLEN(eap->arg), | |
4332 p, cmdlinep); | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4333 if (n == 2) // p came from ExpandOne() |
7 | 4334 vim_free(p); |
4335 } | |
4336 } | |
4337 } | |
4338 } | |
4339 return OK; | |
4340 } | |
4341 | |
4342 /* | |
4343 * Replace part of the command line, keeping eap->cmd, eap->arg and | |
4344 * eap->nextcmd correct. | |
4345 * "src" points to the part that is to be replaced, of length "srclen". | |
4346 * "repl" is the replacement string. | |
4347 * Returns a pointer to the character after the replaced string. | |
4348 * Returns NULL for failure. | |
4349 */ | |
4350 static char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4351 repl_cmdline( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4352 exarg_T *eap, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4353 char_u *src, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4354 int srclen, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4355 char_u *repl, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4356 char_u **cmdlinep) |
7 | 4357 { |
4358 int len; | |
4359 int i; | |
4360 char_u *new_cmdline; | |
4361 | |
4362 /* | |
4363 * The new command line is build in new_cmdline[]. | |
4364 * First allocate it. | |
4365 * Careful: a "+cmd" argument may have been NUL terminated. | |
4366 */ | |
4367 len = (int)STRLEN(repl); | |
4368 i = (int)(src - *cmdlinep) + (int)STRLEN(src + srclen) + len + 3; | |
698 | 4369 if (eap->nextcmd != NULL) |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4370 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
|
4371 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
|
4372 return NULL; // out of memory! |
7 | 4373 |
4374 /* | |
4375 * Copy the stuff before the expanded part. | |
4376 * Copy the expanded stuff. | |
4377 * Copy what came after the expanded part. | |
4378 * Copy the next commands, if there are any. | |
4379 */ | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4380 i = (int)(src - *cmdlinep); // length of part before match |
7 | 4381 mch_memmove(new_cmdline, *cmdlinep, (size_t)i); |
434 | 4382 |
7 | 4383 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
|
4384 i += len; // remember the end of the string |
7 | 4385 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
|
4386 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
|
4387 |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4388 if (eap->nextcmd != NULL) // append next command |
7 | 4389 { |
4390 i = (int)STRLEN(new_cmdline) + 1; | |
4391 STRCPY(new_cmdline + i, eap->nextcmd); | |
4392 eap->nextcmd = new_cmdline + i; | |
4393 } | |
4394 eap->cmd = new_cmdline + (eap->cmd - *cmdlinep); | |
4395 eap->arg = new_cmdline + (eap->arg - *cmdlinep); | |
4396 if (eap->do_ecmd_cmd != NULL && eap->do_ecmd_cmd != dollar_command) | |
4397 eap->do_ecmd_cmd = new_cmdline + (eap->do_ecmd_cmd - *cmdlinep); | |
4398 vim_free(*cmdlinep); | |
4399 *cmdlinep = new_cmdline; | |
4400 | |
4401 return src; | |
4402 } | |
4403 | |
4404 /* | |
4405 * Check for '|' to separate commands and '"' to start comments. | |
4406 */ | |
4407 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4408 separate_nextcmd(exarg_T *eap) |
7 | 4409 { |
4410 char_u *p; | |
4411 | |
153 | 4412 #ifdef FEAT_QUICKFIX |
4413 p = skip_grep_pat(eap); | |
4414 #else | |
41 | 4415 p = eap->arg; |
4416 #endif | |
4417 | |
11127
506f5d8b7d8b
patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11010
diff
changeset
|
4418 for ( ; *p; MB_PTR_ADV(p)) |
7 | 4419 { |
4420 if (*p == Ctrl_V) | |
4421 { | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
4422 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
|
4423 ++p; // skip CTRL-V and next char |
7 | 4424 else |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4425 // remove CTRL-V and skip next char |
1619 | 4426 STRMOVE(p, p + 1); |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4427 if (*p == NUL) // stop at NUL after CTRL-V |
7 | 4428 break; |
4429 } | |
9 | 4430 |
4431 #ifdef FEAT_EVAL | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4432 // 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
|
4433 else if (p[0] == '`' && p[1] == '=' && (eap->argt & EX_XFILE)) |
9 | 4434 { |
4435 p += 2; | |
4436 (void)skip_expr(&p); | |
4437 } | |
4438 #endif | |
4439 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4440 // 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
|
4441 // :@" 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
|
4442 // :redir @" doesn't either. |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
4443 else if ((*p == '"' && !(eap->argt & EX_NOTRLCOM) |
7 | 4444 && ((eap->cmdidx != CMD_at && eap->cmdidx != CMD_star) |
4445 || p != eap->arg) | |
4446 && (eap->cmdidx != CMD_redir | |
4447 || 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
|
4448 #ifdef FEAT_EVAL |
336483164ca6
patch 8.2.0595: Vim9: not all commands using ends_excmd() tested
Bram Moolenaar <Bram@vim.org>
parents:
20075
diff
changeset
|
4449 || (*p == '#' && in_vim9script() |
336483164ca6
patch 8.2.0595: Vim9: not all commands using ends_excmd() tested
Bram Moolenaar <Bram@vim.org>
parents:
20075
diff
changeset
|
4450 && p[1] != '{' && p > eap->cmd && VIM_ISWHITE(p[-1])) |
336483164ca6
patch 8.2.0595: Vim9: not all commands using ends_excmd() tested
Bram Moolenaar <Bram@vim.org>
parents:
20075
diff
changeset
|
4451 #endif |
7 | 4452 || *p == '|' || *p == '\n') |
4453 { | |
4454 /* | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
4455 * We remove the '\' before the '|', unless EX_CTRLV is used |
7 | 4456 * AND 'b' is present in 'cpoptions'. |
4457 */ | |
4458 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
|
4459 || !(eap->argt & EX_CTRLV)) && *(p - 1) == '\\') |
7 | 4460 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4461 STRMOVE(p - 1, p); // remove the '\' |
7 | 4462 --p; |
4463 } | |
4464 else | |
4465 { | |
4466 eap->nextcmd = check_nextcmd(p); | |
4467 *p = NUL; | |
4468 break; | |
4469 } | |
4470 } | |
41 | 4471 } |
4472 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4473 if (!(eap->argt & EX_NOTRLCOM)) // remove trailing spaces |
7 | 4474 del_trailing_spaces(eap->arg); |
4475 } | |
4476 | |
4477 /* | |
4478 * get + command from ex argument | |
4479 */ | |
4480 static char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4481 getargcmd(char_u **argp) |
7 | 4482 { |
4483 char_u *arg = *argp; | |
4484 char_u *command = NULL; | |
4485 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4486 if (*arg == '+') // +[command] |
7 | 4487 { |
4488 ++arg; | |
5790 | 4489 if (vim_isspace(*arg) || *arg == NUL) |
7 | 4490 command = dollar_command; |
4491 else | |
4492 { | |
4493 command = arg; | |
4494 arg = skip_cmd_arg(command, TRUE); | |
4495 if (*arg != NUL) | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4496 *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
|
4497 } |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4498 |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4499 arg = skipwhite(arg); // skip over spaces |
7 | 4500 *argp = arg; |
4501 } | |
4502 return command; | |
4503 } | |
4504 | |
4505 /* | |
4506 * Find end of "+command" argument. Skip over "\ " and "\\". | |
4507 */ | |
17835
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17823
diff
changeset
|
4508 char_u * |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4509 skip_cmd_arg( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4510 char_u *p, |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4511 int rembs) // TRUE to halve the number of backslashes |
7 | 4512 { |
4513 while (*p && !vim_isspace(*p)) | |
4514 { | |
4515 if (*p == '\\' && p[1] != NUL) | |
4516 { | |
4517 if (rembs) | |
1619 | 4518 STRMOVE(p, p + 1); |
7 | 4519 else |
4520 ++p; | |
4521 } | |
11127
506f5d8b7d8b
patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11010
diff
changeset
|
4522 MB_PTR_ADV(p); |
7 | 4523 } |
4524 return p; | |
4525 } | |
4526 | |
13575
4df23d9bad47
patch 8.0.1660: the terminal API "drop" command doesn't support options
Christian Brabandt <cb@256bit.org>
parents:
13553
diff
changeset
|
4527 int |
4df23d9bad47
patch 8.0.1660: the terminal API "drop" command doesn't support options
Christian Brabandt <cb@256bit.org>
parents:
13553
diff
changeset
|
4528 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
|
4529 { |
4df23d9bad47
patch 8.0.1660: the terminal API "drop" command doesn't support options
Christian Brabandt <cb@256bit.org>
parents:
13553
diff
changeset
|
4530 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
|
4531 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
|
4532 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
|
4533 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
|
4534 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
|
4535 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
|
4536 else |
c1ead25ed819
patch 8.1.0043: ++bad argument of :edit does not work properly
Christian Brabandt <cb@256bit.org>
parents:
14035
diff
changeset
|
4537 return FAIL; |
c1ead25ed819
patch 8.1.0043: ++bad argument of :edit does not work properly
Christian Brabandt <cb@256bit.org>
parents:
14035
diff
changeset
|
4538 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
|
4539 } |
4df23d9bad47
patch 8.0.1660: the terminal API "drop" command doesn't support options
Christian Brabandt <cb@256bit.org>
parents:
13553
diff
changeset
|
4540 |
7 | 4541 /* |
4542 * Get "++opt=arg" argument. | |
4543 * Return FAIL or OK. | |
4544 */ | |
4545 static int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4546 getargopt(exarg_T *eap) |
7 | 4547 { |
4548 char_u *arg = eap->arg + 2; | |
4549 int *pp = NULL; | |
2168 | 4550 int bad_char_idx; |
7 | 4551 char_u *p; |
4552 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4553 // ":edit ++[no]bin[ary] file" |
7 | 4554 if (STRNCMP(arg, "bin", 3) == 0 || STRNCMP(arg, "nobin", 5) == 0) |
4555 { | |
4556 if (*arg == 'n') | |
4557 { | |
4558 arg += 2; | |
4559 eap->force_bin = FORCE_NOBIN; | |
4560 } | |
4561 else | |
4562 eap->force_bin = FORCE_BIN; | |
4563 if (!checkforcmd(&arg, "binary", 3)) | |
4564 return FAIL; | |
4565 eap->arg = skipwhite(arg); | |
4566 return OK; | |
4567 } | |
4568 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4569 // ":read ++edit file" |
819 | 4570 if (STRNCMP(arg, "edit", 4) == 0) |
4571 { | |
4572 eap->read_edit = TRUE; | |
4573 eap->arg = skipwhite(arg + 4); | |
4574 return OK; | |
4575 } | |
4576 | |
7 | 4577 if (STRNCMP(arg, "ff", 2) == 0) |
4578 { | |
4579 arg += 2; | |
4580 pp = &eap->force_ff; | |
4581 } | |
4582 else if (STRNCMP(arg, "fileformat", 10) == 0) | |
4583 { | |
4584 arg += 10; | |
4585 pp = &eap->force_ff; | |
4586 } | |
4587 else if (STRNCMP(arg, "enc", 3) == 0) | |
4588 { | |
3208 | 4589 if (STRNCMP(arg, "encoding", 8) == 0) |
4590 arg += 8; | |
4591 else | |
4592 arg += 3; | |
7 | 4593 pp = &eap->force_enc; |
4594 } | |
595 | 4595 else if (STRNCMP(arg, "bad", 3) == 0) |
4596 { | |
4597 arg += 3; | |
2168 | 4598 pp = &bad_char_idx; |
595 | 4599 } |
7 | 4600 |
4601 if (pp == NULL || *arg != '=') | |
4602 return FAIL; | |
4603 | |
4604 ++arg; | |
4605 *pp = (int)(arg - eap->cmd); | |
4606 arg = skip_cmd_arg(arg, FALSE); | |
4607 eap->arg = skipwhite(arg); | |
4608 *arg = NUL; | |
4609 | |
4610 if (pp == &eap->force_ff) | |
4611 { | |
4612 if (check_ff_value(eap->cmd + eap->force_ff) == FAIL) | |
4613 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
|
4614 eap->force_ff = eap->cmd[eap->force_ff]; |
7 | 4615 } |
595 | 4616 else if (pp == &eap->force_enc) |
7 | 4617 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4618 // Make 'fileencoding' lower case. |
7 | 4619 for (p = eap->cmd + eap->force_enc; *p != NUL; ++p) |
4620 *p = TOLOWER_ASC(*p); | |
4621 } | |
595 | 4622 else |
4623 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4624 // 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
|
4625 // "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
|
4626 if (get_bad_opt(eap->cmd + bad_char_idx, eap) == FAIL) |
595 | 4627 return FAIL; |
4628 } | |
7 | 4629 |
4630 return OK; | |
4631 } | |
4632 | |
4633 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4634 ex_autocmd(exarg_T *eap) |
7 | 4635 { |
4636 /* | |
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
|
4637 * Disallow autocommands from .exrc and .vimrc in current |
7 | 4638 * directory for security reasons. |
4639 */ | |
4640 if (secure) | |
4641 { | |
4642 secure = 2; | |
4643 eap->errmsg = e_curdir; | |
4644 } | |
4645 else if (eap->cmdidx == CMD_autocmd) | |
4646 do_autocmd(eap->arg, eap->forceit); | |
4647 else | |
4648 do_augroup(eap->arg, eap->forceit); | |
4649 } | |
4650 | |
4651 /* | |
4652 * ":doautocmd": Apply the automatic commands to the current buffer. | |
4653 */ | |
4654 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4655 ex_doautocmd(exarg_T *eap) |
7 | 4656 { |
3350 | 4657 char_u *arg = eap->arg; |
4658 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
|
4659 int did_aucmd; |
ac8180818504
commit https://github.com/vim/vim/commit/1610d052413e0ed664498853a47acc2d677a22d1
Christian Brabandt <cb@256bit.org>
parents:
9230
diff
changeset
|
4660 |
ac8180818504
commit https://github.com/vim/vim/commit/1610d052413e0ed664498853a47acc2d677a22d1
Christian Brabandt <cb@256bit.org>
parents:
9230
diff
changeset
|
4661 (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
|
4662 // 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
|
4663 if (call_do_modelines && did_aucmd) |
3350 | 4664 do_modelines(0); |
7 | 4665 } |
4666 | |
4667 /* | |
4668 * :[N]bunload[!] [N] [bufname] unload buffer | |
4669 * :[N]bdelete[!] [N] [bufname] delete buffer from buffer list | |
4670 * :[N]bwipeout[!] [N] [bufname] delete buffer really | |
4671 */ | |
4672 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4673 ex_bunload(exarg_T *eap) |
7 | 4674 { |
19271
ebeeb4b4a1fa
patch 8.2.0194: some commands can cause problems in terminal popup
Bram Moolenaar <Bram@vim.org>
parents:
19261
diff
changeset
|
4675 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
|
4676 return; |
7 | 4677 eap->errmsg = do_bufdel( |
4678 eap->cmdidx == CMD_bdelete ? DOBUF_DEL | |
4679 : eap->cmdidx == CMD_bwipeout ? DOBUF_WIPE | |
4680 : DOBUF_UNLOAD, eap->arg, | |
4681 eap->addr_count, (int)eap->line1, (int)eap->line2, eap->forceit); | |
4682 } | |
4683 | |
4684 /* | |
4685 * :[N]buffer [N] to buffer N | |
4686 * :[N]sbuffer [N] to buffer N | |
4687 */ | |
4688 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4689 ex_buffer(exarg_T *eap) |
7 | 4690 { |
19271
ebeeb4b4a1fa
patch 8.2.0194: some commands can cause problems in terminal popup
Bram Moolenaar <Bram@vim.org>
parents:
19261
diff
changeset
|
4691 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
|
4692 return; |
7 | 4693 if (*eap->arg) |
4694 eap->errmsg = e_trailing; | |
4695 else | |
4696 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4697 if (eap->addr_count == 0) // default is current buffer |
7 | 4698 goto_buffer(eap, DOBUF_CURRENT, FORWARD, 0); |
4699 else | |
4700 goto_buffer(eap, DOBUF_FIRST, FORWARD, (int)eap->line2); | |
6230 | 4701 if (eap->do_ecmd_cmd != NULL) |
4702 do_cmdline_cmd(eap->do_ecmd_cmd); | |
7 | 4703 } |
4704 } | |
4705 | |
4706 /* | |
4707 * :[N]bmodified [N] to next mod. buffer | |
4708 * :[N]sbmodified [N] to next mod. buffer | |
4709 */ | |
4710 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4711 ex_bmodified(exarg_T *eap) |
7 | 4712 { |
4713 goto_buffer(eap, DOBUF_MOD, FORWARD, (int)eap->line2); | |
6230 | 4714 if (eap->do_ecmd_cmd != NULL) |
4715 do_cmdline_cmd(eap->do_ecmd_cmd); | |
7 | 4716 } |
4717 | |
4718 /* | |
4719 * :[N]bnext [N] to next buffer | |
4720 * :[N]sbnext [N] split and to next buffer | |
4721 */ | |
4722 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4723 ex_bnext(exarg_T *eap) |
7 | 4724 { |
19271
ebeeb4b4a1fa
patch 8.2.0194: some commands can cause problems in terminal popup
Bram Moolenaar <Bram@vim.org>
parents:
19261
diff
changeset
|
4725 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
|
4726 return; |
17722555af22
patch 8.2.0127: some buffer commands work in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19131
diff
changeset
|
4727 |
7 | 4728 goto_buffer(eap, DOBUF_CURRENT, FORWARD, (int)eap->line2); |
6230 | 4729 if (eap->do_ecmd_cmd != NULL) |
4730 do_cmdline_cmd(eap->do_ecmd_cmd); | |
7 | 4731 } |
4732 | |
4733 /* | |
4734 * :[N]bNext [N] to previous buffer | |
4735 * :[N]bprevious [N] to previous buffer | |
4736 * :[N]sbNext [N] split and to previous buffer | |
4737 * :[N]sbprevious [N] split and to previous buffer | |
4738 */ | |
4739 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4740 ex_bprevious(exarg_T *eap) |
7 | 4741 { |
19271
ebeeb4b4a1fa
patch 8.2.0194: some commands can cause problems in terminal popup
Bram Moolenaar <Bram@vim.org>
parents:
19261
diff
changeset
|
4742 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
|
4743 return; |
17722555af22
patch 8.2.0127: some buffer commands work in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19131
diff
changeset
|
4744 |
7 | 4745 goto_buffer(eap, DOBUF_CURRENT, BACKWARD, (int)eap->line2); |
6230 | 4746 if (eap->do_ecmd_cmd != NULL) |
4747 do_cmdline_cmd(eap->do_ecmd_cmd); | |
7 | 4748 } |
4749 | |
4750 /* | |
4751 * :brewind to first buffer | |
4752 * :bfirst to first buffer | |
4753 * :sbrewind split and to first buffer | |
4754 * :sbfirst split and to first buffer | |
4755 */ | |
4756 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4757 ex_brewind(exarg_T *eap) |
7 | 4758 { |
19271
ebeeb4b4a1fa
patch 8.2.0194: some commands can cause problems in terminal popup
Bram Moolenaar <Bram@vim.org>
parents:
19261
diff
changeset
|
4759 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
|
4760 return; |
17722555af22
patch 8.2.0127: some buffer commands work in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19131
diff
changeset
|
4761 |
7 | 4762 goto_buffer(eap, DOBUF_FIRST, FORWARD, 0); |
6230 | 4763 if (eap->do_ecmd_cmd != NULL) |
4764 do_cmdline_cmd(eap->do_ecmd_cmd); | |
7 | 4765 } |
4766 | |
4767 /* | |
4768 * :blast to last buffer | |
4769 * :sblast split and to last buffer | |
4770 */ | |
4771 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4772 ex_blast(exarg_T *eap) |
7 | 4773 { |
19271
ebeeb4b4a1fa
patch 8.2.0194: some commands can cause problems in terminal popup
Bram Moolenaar <Bram@vim.org>
parents:
19261
diff
changeset
|
4774 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
|
4775 return; |
17722555af22
patch 8.2.0127: some buffer commands work in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19131
diff
changeset
|
4776 |
7 | 4777 goto_buffer(eap, DOBUF_LAST, BACKWARD, 0); |
6230 | 4778 if (eap->do_ecmd_cmd != NULL) |
4779 do_cmdline_cmd(eap->do_ecmd_cmd); | |
7 | 4780 } |
4781 | |
20059
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20027
diff
changeset
|
4782 /* |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20027
diff
changeset
|
4783 * 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
|
4784 * 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
|
4785 */ |
7 | 4786 int |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4787 ends_excmd(int c) |
7 | 4788 { |
20027
23a4aef4f923
patch 8.2.0569: build failure with tiny version
Bram Moolenaar <Bram@vim.org>
parents:
20023
diff
changeset
|
4789 #ifdef FEAT_EVAL |
20023
c85d4e173cc9
patch 8.2.0567: Vim9: cannot put comments halfway expressions
Bram Moolenaar <Bram@vim.org>
parents:
20009
diff
changeset
|
4790 if (c == '#') |
20059
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20027
diff
changeset
|
4791 return in_vim9script(); |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20027
diff
changeset
|
4792 #endif |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20027
diff
changeset
|
4793 return (c == NUL || c == '|' || c == '"' || c == '\n'); |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20027
diff
changeset
|
4794 } |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20027
diff
changeset
|
4795 |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20027
diff
changeset
|
4796 /* |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20027
diff
changeset
|
4797 * 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
|
4798 * 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
|
4799 */ |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20027
diff
changeset
|
4800 int |
20063
cc146cde0b4d
patch 8.2.0587: compiler warning for unused variable
Bram Moolenaar <Bram@vim.org>
parents:
20059
diff
changeset
|
4801 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
|
4802 { |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20027
diff
changeset
|
4803 int c = *cmd; |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20027
diff
changeset
|
4804 |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20027
diff
changeset
|
4805 #ifdef FEAT_EVAL |
20079
336483164ca6
patch 8.2.0595: Vim9: not all commands using ends_excmd() tested
Bram Moolenaar <Bram@vim.org>
parents:
20075
diff
changeset
|
4806 if (c == '#' && cmd[1] != '{' && (cmd == cmd_start || VIM_ISWHITE(cmd[-1]))) |
20023
c85d4e173cc9
patch 8.2.0567: Vim9: cannot put comments halfway expressions
Bram Moolenaar <Bram@vim.org>
parents:
20009
diff
changeset
|
4807 return in_vim9script(); |
20027
23a4aef4f923
patch 8.2.0569: build failure with tiny version
Bram Moolenaar <Bram@vim.org>
parents:
20023
diff
changeset
|
4808 #endif |
7 | 4809 return (c == NUL || c == '|' || c == '"' || c == '\n'); |
4810 } | |
4811 | |
4812 #if defined(FEAT_SYN_HL) || defined(FEAT_SEARCH_EXTRA) || defined(FEAT_EVAL) \ | |
4813 || defined(PROTO) | |
4814 /* | |
4815 * Return the next command, after the first '|' or '\n'. | |
4816 * Return NULL if not found. | |
4817 */ | |
4818 char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4819 find_nextcmd(char_u *p) |
7 | 4820 { |
4821 while (*p != '|' && *p != '\n') | |
4822 { | |
4823 if (*p == NUL) | |
4824 return NULL; | |
4825 ++p; | |
4826 } | |
4827 return (p + 1); | |
4828 } | |
4829 #endif | |
4830 | |
4831 /* | |
10383
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
4832 * 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
|
4833 * Return NULL if it isn't, the following character if it is. |
7 | 4834 */ |
4835 char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4836 check_nextcmd(char_u *p) |
7 | 4837 { |
10383
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
4838 char_u *s = skipwhite(p); |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
4839 |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
4840 if (*s == '|' || *s == '\n') |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
4841 return (s + 1); |
7 | 4842 else |
4843 return NULL; | |
4844 } | |
4845 | |
4846 /* | |
4847 * - if there are more files to edit | |
4848 * - and this is the last window | |
4849 * - and forceit not used | |
4850 * - and not repeated twice on a row | |
4851 * return FAIL and give error message if 'message' TRUE | |
4852 * return OK otherwise | |
4853 */ | |
4854 static int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4855 check_more( |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4856 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
|
4857 int forceit) |
7 | 4858 { |
4859 int n = ARGCOUNT - curwin->w_arg_idx - 1; | |
4860 | |
672 | 4861 if (!forceit && only_one_window() |
4862 && ARGCOUNT > 1 && !arg_had_last && n >= 0 && quitmore == 0) | |
7 | 4863 { |
4864 if (message) | |
4865 { | |
4866 #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) | |
4867 if ((p_confirm || cmdmod.confirm) && curbuf->b_fname != NULL) | |
4868 { | |
2770 | 4869 char_u buff[DIALOG_MSG_SIZE]; |
7 | 4870 |
14585
c8f07e8b273e
patch 8.1.0306: plural messages are not translated properly
Christian Brabandt <cb@256bit.org>
parents:
14550
diff
changeset
|
4871 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
|
4872 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
|
4873 "%d more files to edit. Quit anyway?", n), n); |
7 | 4874 if (vim_dialog_yesno(VIM_QUESTION, NULL, buff, 1) == VIM_YES) |
4875 return OK; | |
4876 return FAIL; | |
4877 } | |
4878 #endif | |
15490
98c35d312987
patch 8.1.0753: printf format not checked for semsg()
Bram Moolenaar <Bram@vim.org>
parents:
15488
diff
changeset
|
4879 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
|
4880 "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
|
4881 quitmore = 2; // next try to quit is allowed |
7 | 4882 } |
4883 return FAIL; | |
4884 } | |
4885 return OK; | |
4886 } | |
4887 | |
4888 /* | |
4889 * Function given to ExpandGeneric() to obtain the list of command names. | |
4890 */ | |
4891 char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4892 get_command_name(expand_T *xp UNUSED, int idx) |
7 | 4893 { |
4894 if (idx >= (int)CMD_SIZE) | |
4895 return get_user_command_name(idx); | |
4896 return cmdnames[idx].cmd_name; | |
4897 } | |
4898 | |
4899 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4900 ex_colorscheme(exarg_T *eap) |
7 | 4901 { |
2142
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4902 if (*eap->arg == NUL) |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4903 { |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4904 #ifdef FEAT_EVAL |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4905 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
|
4906 char_u *p = NULL; |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4907 |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4908 if (expr != NULL) |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4909 { |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4910 ++emsg_off; |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4911 p = eval_to_string(expr, NULL, FALSE); |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4912 --emsg_off; |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4913 vim_free(expr); |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4914 } |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4915 if (p != NULL) |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4916 { |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15510
diff
changeset
|
4917 msg((char *)p); |
2142
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4918 vim_free(p); |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4919 } |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4920 else |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15510
diff
changeset
|
4921 msg("default"); |
2142
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4922 #else |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15510
diff
changeset
|
4923 msg(_("unknown")); |
2142
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4924 #endif |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4925 } |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4926 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
|
4927 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
|
4928 |
61448894376e
patch 8.1.0839: when using VTP wrong colors after a color scheme change
Bram Moolenaar <Bram@vim.org>
parents:
15643
diff
changeset
|
4929 #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
|
4930 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
|
4931 { |
61448894376e
patch 8.1.0839: when using VTP wrong colors after a color scheme change
Bram Moolenaar <Bram@vim.org>
parents:
15643
diff
changeset
|
4932 // 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
|
4933 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
|
4934 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
|
4935 } |
61448894376e
patch 8.1.0839: when using VTP wrong colors after a color scheme change
Bram Moolenaar <Bram@vim.org>
parents:
15643
diff
changeset
|
4936 #endif |
7 | 4937 } |
4938 | |
4939 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4940 ex_highlight(exarg_T *eap) |
7 | 4941 { |
4942 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
|
4943 msg(_("Greetings, Vim user!")); |
7 | 4944 do_highlight(eap->arg, eap->forceit, FALSE); |
4945 } | |
4946 | |
4947 | |
4948 /* | |
4949 * Call this function if we thought we were going to exit, but we won't | |
4950 * (because of an error). May need to restore the terminal mode. | |
4951 */ | |
4952 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4953 not_exiting(void) |
7 | 4954 { |
4955 exiting = FALSE; | |
4956 settmode(TMODE_RAW); | |
4957 } | |
4958 | |
13442
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
4959 static int |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
4960 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
|
4961 { |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
4962 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
|
4963 |
18406
fa6efc49d71f
patch 8.1.2197: ExitPre autocommand may cause accessing freed memory
Bram Moolenaar <Bram@vim.org>
parents:
18402
diff
changeset
|
4964 // 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
|
4965 // 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
|
4966 // only happen in autocommands). |
13442
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
4967 if (!win_valid(wp) |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
4968 || curbuf_locked() |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
4969 || (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
|
4970 return TRUE; |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
4971 |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
4972 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
|
4973 { |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
4974 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
|
4975 // 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
|
4976 // 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
|
4977 // autocommands). |
fa6efc49d71f
patch 8.1.2197: ExitPre autocommand may cause accessing freed memory
Bram Moolenaar <Bram@vim.org>
parents:
18402
diff
changeset
|
4978 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
|
4979 || (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
|
4980 return TRUE; |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
4981 } |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
4982 |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
4983 return FALSE; |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
4984 } |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
4985 |
7 | 4986 /* |
6409 | 4987 * ":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
|
4988 * ":{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
|
4989 * 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
|
4990 */ |
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
|
4991 void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4992 ex_quit(exarg_T *eap) |
7 | 4993 { |
6398 | 4994 win_T *wp; |
4995 | |
7 | 4996 #ifdef FEAT_CMDWIN |
4997 if (cmdwin_type != 0) | |
4998 { | |
4999 cmdwin_result = Ctrl_C; | |
5000 return; | |
5001 } | |
5002 #endif | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5003 // Don't quit while editing the command line. |
633 | 5004 if (text_locked()) |
5005 { | |
5006 text_locked_msg(); | |
631 | 5007 return; |
5008 } | |
6398 | 5009 if (eap->addr_count > 0) |
5010 { | |
6409 | 5011 int wnr = eap->line2; |
5012 | |
5013 for (wp = firstwin; wp->w_next != NULL; wp = wp->w_next) | |
5014 if (--wnr <= 0) | |
6398 | 5015 break; |
5016 } | |
5017 else | |
5018 wp = curwin; | |
6409 | 5019 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5020 // 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
|
5021 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
|
5022 return; |
13442
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5023 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5024 // 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
|
5025 if (before_quit_autocmds(wp, FALSE, eap->forceit)) |
819 | 5026 return; |
7 | 5027 |
5028 #ifdef FEAT_NETBEANS_INTG | |
5029 netbeansForcedQuit = eap->forceit; | |
5030 #endif | |
5031 | |
5032 /* | |
5033 * If there are more files or windows we won't exit. | |
5034 */ | |
5035 if (check_more(FALSE, eap->forceit) == OK && only_one_window()) | |
5036 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
|
5037 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
|
5038 && check_changed(wp->w_buffer, (p_awa ? CCGD_AW : 0) |
5464 | 5039 | (eap->forceit ? CCGD_FORCEIT : 0) |
5040 | CCGD_EXCMD)) | |
7 | 5041 || 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
|
5042 || (only_one_window() && check_changed_any(eap->forceit, TRUE))) |
7 | 5043 { |
5044 not_exiting(); | |
5045 } | |
5046 else | |
5047 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5048 // quit last window |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5049 // 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
|
5050 // 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
|
5051 // specified. Example: |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5052 // :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
|
5053 // :h|wincmd w|q - quit |
10349
cf988222b150
commit https://github.com/vim/vim/commit/a1f4cb93ba50ea9e40cd4b1f5592b8a6d1398660
Christian Brabandt <cb@256bit.org>
parents:
10275
diff
changeset
|
5054 if (only_one_window() && (ONE_WINDOW || eap->addr_count == 0)) |
7 | 5055 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
|
5056 not_exiting(); |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5057 #ifdef FEAT_GUI |
7 | 5058 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
|
5059 #endif |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5060 // 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
|
5061 win_close(wp, !buf_hide(wp->w_buffer) || eap->forceit); |
7 | 5062 } |
5063 } | |
5064 | |
5065 /* | |
5066 * ":cquit". | |
5067 */ | |
5068 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5069 ex_cquit(exarg_T *eap UNUSED) |
7 | 5070 { |
19069
e14feba578f1
patch 8.2.0095: cannot specify exit code for :cquit
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
5071 // 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
|
5072 getout(eap->addr_count > 0 ? (int)eap->line2 : EXIT_FAILURE); |
7 | 5073 } |
5074 | |
5075 /* | |
5076 * ":qall": try to quit all windows | |
5077 */ | |
5078 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5079 ex_quit_all(exarg_T *eap) |
7 | 5080 { |
5081 # ifdef FEAT_CMDWIN | |
5082 if (cmdwin_type != 0) | |
5083 { | |
5084 if (eap->forceit) | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5085 cmdwin_result = K_XF1; // ex_window() takes care of this |
7 | 5086 else |
5087 cmdwin_result = K_XF2; | |
5088 return; | |
5089 } | |
5090 # endif | |
631 | 5091 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5092 // Don't quit while editing the command line. |
633 | 5093 if (text_locked()) |
5094 { | |
5095 text_locked_msg(); | |
631 | 5096 return; |
5097 } | |
13442
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5098 |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5099 if (before_quit_autocmds(curwin, TRUE, eap->forceit)) |
819 | 5100 return; |
631 | 5101 |
7 | 5102 exiting = TRUE; |
7469
15eefe1b0dad
commit https://github.com/vim/vim/commit/027387f70c671f62e3e08e0bdd09ec05b0232735
Christian Brabandt <cb@256bit.org>
parents:
7465
diff
changeset
|
5103 if (eap->forceit || !check_changed_any(FALSE, FALSE)) |
7 | 5104 getout(0); |
5105 not_exiting(); | |
5106 } | |
5107 | |
5108 /* | |
5109 * ":close": close current window, unless it is the last one | |
5110 */ | |
5111 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5112 ex_close(exarg_T *eap) |
7 | 5113 { |
6398 | 5114 win_T *win; |
5115 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
|
5116 #ifdef FEAT_CMDWIN |
7 | 5117 if (cmdwin_type != 0) |
2839 | 5118 cmdwin_result = Ctrl_C; |
7 | 5119 else |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5120 #endif |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
5121 if (!text_locked() && !curbuf_locked()) |
6398 | 5122 { |
5123 if (eap->addr_count == 0) | |
5124 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
|
5125 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
|
5126 { |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9538
diff
changeset
|
5127 FOR_ALL_WINDOWS(win) |
6398 | 5128 { |
5129 winnr++; | |
5130 if (winnr == eap->line2) | |
5131 break; | |
5132 } | |
5133 if (win == NULL) | |
5134 win = lastwin; | |
5135 ex_win_close(eap->forceit, win, NULL); | |
5136 } | |
5137 } | |
667 | 5138 } |
5139 | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5140 #ifdef FEAT_QUICKFIX |
667 | 5141 /* |
5142 * ":pclose": Close any preview window. | |
5143 */ | |
5144 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5145 ex_pclose(exarg_T *eap) |
667 | 5146 { |
5147 win_T *win; | |
5148 | |
17431
ce35cdbe9f74
patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
17336
diff
changeset
|
5149 // First close any normal window. |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9538
diff
changeset
|
5150 FOR_ALL_WINDOWS(win) |
667 | 5151 if (win->w_p_pvw) |
5152 { | |
671 | 5153 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
|
5154 return; |
ce35cdbe9f74
patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
17336
diff
changeset
|
5155 } |
18763
49b78d6465e5
patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents:
18715
diff
changeset
|
5156 # 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
|
5157 // 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
|
5158 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
|
5159 # endif |
667 | 5160 } |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5161 #endif |
667 | 5162 |
671 | 5163 /* |
5164 * Close window "win" and take care of handling closing the last window for a | |
5165 * modified buffer. | |
5166 */ | |
5167 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5168 ex_win_close( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5169 int forceit, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5170 win_T *win, |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5171 tabpage_T *tp) // NULL or the tab page "win" is in |
7 | 5172 { |
5173 int need_hide; | |
5174 buf_T *buf = win->w_buffer; | |
5175 | |
5176 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
|
5177 if (need_hide && !buf_hide(buf) && !forceit) |
7 | 5178 { |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5179 #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) |
7 | 5180 if ((p_confirm || cmdmod.confirm) && p_write) |
5181 { | |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9460
diff
changeset
|
5182 bufref_T bufref; |
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9460
diff
changeset
|
5183 |
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9460
diff
changeset
|
5184 set_bufref(&bufref, buf); |
7 | 5185 dialog_changed(buf, FALSE); |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9460
diff
changeset
|
5186 if (bufref_valid(&bufref) && bufIsChanged(buf)) |
7 | 5187 return; |
5188 need_hide = FALSE; | |
5189 } | |
5190 else | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5191 #endif |
7 | 5192 { |
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
|
5193 no_write_message(); |
7 | 5194 return; |
5195 } | |
5196 } | |
5197 | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5198 #ifdef FEAT_GUI |
7 | 5199 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
|
5200 #endif |
671 | 5201 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5202 // free buffer when not hiding it or when it's a scratch buffer |
671 | 5203 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
|
5204 win_close(win, !need_hide && !buf_hide(buf)); |
671 | 5205 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
|
5206 win_close_othertab(win, !need_hide && !buf_hide(buf), tp); |
671 | 5207 } |
5208 | |
5209 /* | |
10741
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5210 * 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
|
5211 * Returns a tabpage number. |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5212 * 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
|
5213 */ |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5214 static int |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5215 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
|
5216 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5217 int tab_number; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5218 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
|
5219 |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5220 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
|
5221 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5222 char_u *p = eap->arg; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5223 char_u *p_save; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5224 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
|
5225 // 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
|
5226 |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5227 if (*p == '-') |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5228 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5229 relative = -1; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5230 p++; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5231 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5232 else if (*p == '+') |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5233 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5234 relative = 1; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5235 p++; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5236 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5237 |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5238 p_save = p; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5239 tab_number = getdigits(&p); |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5240 |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5241 if (relative == 0) |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5242 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5243 if (STRCMP(p, "$") == 0) |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5244 tab_number = LAST_TAB_NR; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5245 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
|
5246 || tab_number > LAST_TAB_NR) |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5247 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5248 // No numbers as argument. |
10741
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5249 eap->errmsg = e_invarg; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5250 goto theend; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5251 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5252 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5253 else |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5254 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5255 if (*p_save == NUL) |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5256 tab_number = 1; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5257 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
|
5258 || tab_number == 0) |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5259 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5260 // No numbers as argument. |
10741
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5261 eap->errmsg = e_invarg; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5262 goto theend; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5263 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5264 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
|
5265 if (!unaccept_arg0 && relative == -1) |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5266 --tab_number; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5267 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5268 if (tab_number < unaccept_arg0 || tab_number > LAST_TAB_NR) |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5269 eap->errmsg = e_invarg; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5270 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5271 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
|
5272 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5273 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
|
5274 { |
10741
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5275 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
|
5276 tab_number = 0; |
4961e7acdd8c
patch 8.0.0266: compiler warning for using uninitialized variable
Christian Brabandt <cb@256bit.org>
parents:
10741
diff
changeset
|
5277 } |
10741
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5278 else |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5279 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5280 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
|
5281 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
|
5282 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5283 --tab_number; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5284 if (tab_number < unaccept_arg0) |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5285 eap->errmsg = e_invarg; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5286 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5287 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5288 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5289 else |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5290 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5291 switch (eap->cmdidx) |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5292 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5293 case CMD_tabnext: |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5294 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
|
5295 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
|
5296 tab_number = 1; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5297 break; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5298 case CMD_tabmove: |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5299 tab_number = LAST_TAB_NR; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5300 break; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5301 default: |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5302 tab_number = tabpage_index(curtab); |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5303 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5304 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5305 |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5306 theend: |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5307 return tab_number; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5308 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5309 |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5310 /* |
671 | 5311 * ":tabclose": close current tab page, unless it is the last one. |
5312 * ":tabclose N": close tab page N. | |
667 | 5313 */ |
5314 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5315 ex_tabclose(exarg_T *eap) |
667 | 5316 { |
671 | 5317 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
|
5318 int tab_number; |
671 | 5319 |
667 | 5320 # ifdef FEAT_CMDWIN |
5321 if (cmdwin_type != 0) | |
5322 cmdwin_result = K_IGNORE; | |
5323 else | |
5324 # endif | |
671 | 5325 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
|
5326 emsg(_("E784: Cannot close last tab page")); |
671 | 5327 else |
5328 { | |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5329 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
|
5330 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
|
5331 { |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5332 tp = find_tabpage(tab_number); |
671 | 5333 if (tp == NULL) |
5334 { | |
5335 beep_flush(); | |
5336 return; | |
5337 } | |
674 | 5338 if (tp != curtab) |
671 | 5339 { |
5340 tabpage_close_other(tp, eap->forceit); | |
5341 return; | |
5342 } | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
5343 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
|
5344 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
|
5345 } |
671 | 5346 } |
672 | 5347 } |
5348 | |
5349 /* | |
5350 * ":tabonly": close all tab pages except the current one | |
5351 */ | |
5352 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5353 ex_tabonly(exarg_T *eap) |
672 | 5354 { |
5355 tabpage_T *tp; | |
5356 int done; | |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5357 int tab_number; |
672 | 5358 |
5359 # ifdef FEAT_CMDWIN | |
5360 if (cmdwin_type != 0) | |
5361 cmdwin_result = K_IGNORE; | |
5362 else | |
5363 # endif | |
5364 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
|
5365 msg(_("Already only one tab page")); |
672 | 5366 else |
5367 { | |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5368 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
|
5369 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
|
5370 { |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5371 goto_tabpage(tab_number); |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5372 // 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
|
5373 // 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
|
5374 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
|
5375 { |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5376 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
|
5377 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
|
5378 { |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5379 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
|
5380 // 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
|
5381 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
|
5382 done = 1000; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5383 // 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
|
5384 break; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5385 } |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5386 if (first_tabpage->tp_next == NULL) |
672 | 5387 break; |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5388 } |
672 | 5389 } |
5390 } | |
671 | 5391 } |
5392 | |
5393 /* | |
5394 * Close the current tab page. | |
5395 */ | |
5396 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5397 tabpage_close(int forceit) |
671 | 5398 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5399 // 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
|
5400 // 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
|
5401 if (!ONE_WINDOW) |
675 | 5402 close_others(TRUE, forceit); |
10357
59d01e335858
commit https://github.com/vim/vim/commit/459ca563128f2edb7e3bb190090bbb755a56dd55
Christian Brabandt <cb@256bit.org>
parents:
10349
diff
changeset
|
5403 if (ONE_WINDOW) |
671 | 5404 ex_win_close(forceit, curwin, NULL); |
5405 # ifdef FEAT_GUI | |
5406 need_mouse_correct = TRUE; | |
5407 # endif | |
5408 } | |
5409 | |
5410 /* | |
5411 * Close tab page "tp", which is not the current tab page. | |
5412 * Note that autocommands may make "tp" invalid. | |
971 | 5413 * Also takes care of the tab pages line disappearing when closing the |
5414 * last-but-one tab page. | |
671 | 5415 */ |
5416 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5417 tabpage_close_other(tabpage_T *tp, int forceit) |
671 | 5418 { |
5419 int done = 0; | |
672 | 5420 win_T *wp; |
971 | 5421 int h = tabline_height(); |
671 | 5422 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5423 // 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
|
5424 // one. OK, so I'm paranoid... |
671 | 5425 while (++done < 1000) |
5426 { | |
672 | 5427 wp = tp->tp_firstwin; |
5428 ex_win_close(forceit, wp, tp); | |
5429 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5430 // 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
|
5431 // fail to close a window with a modified buffer. |
672 | 5432 if (!valid_tabpage(tp) || tp->tp_firstwin == wp) |
671 | 5433 break; |
5434 } | |
971 | 5435 |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9538
diff
changeset
|
5436 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
|
5437 |
672 | 5438 redraw_tabline = TRUE; |
971 | 5439 if (h != tabline_height()) |
5440 shell_new_rows(); | |
667 | 5441 } |
7 | 5442 |
5443 /* | |
5444 * ":only". | |
5445 */ | |
5446 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5447 ex_only(exarg_T *eap) |
7 | 5448 { |
6398 | 5449 win_T *wp; |
5450 int wnr; | |
7 | 5451 # ifdef FEAT_GUI |
5452 need_mouse_correct = TRUE; | |
5453 # endif | |
6398 | 5454 if (eap->addr_count > 0) |
5455 { | |
5456 wnr = eap->line2; | |
5457 for (wp = firstwin; --wnr > 0; ) | |
5458 { | |
5459 if (wp->w_next == NULL) | |
5460 break; | |
5461 else | |
5462 wp = wp->w_next; | |
5463 } | |
5464 win_goto(wp); | |
5465 } | |
7 | 5466 close_others(TRUE, eap->forceit); |
5467 } | |
5468 | |
5469 static void | |
10492
b2cd5a71f4bb
commit https://github.com/vim/vim/commit/5e1e6d265d26ee2952c4a018a5ff72c950d2d700
Christian Brabandt <cb@256bit.org>
parents:
10490
diff
changeset
|
5470 ex_hide(exarg_T *eap UNUSED) |
7 | 5471 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5472 // ":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
|
5473 if (!eap->skip) |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5474 { |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5475 #ifdef FEAT_GUI |
10383
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5476 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
|
5477 #endif |
10383
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5478 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
|
5479 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
|
5480 else |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5481 { |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5482 int winnr = 0; |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5483 win_T *win; |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5484 |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5485 FOR_ALL_WINDOWS(win) |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5486 { |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5487 winnr++; |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5488 if (winnr == eap->line2) |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5489 break; |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5490 } |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5491 if (win == NULL) |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5492 win = lastwin; |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5493 win_close(win, FALSE); |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5494 } |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5495 } |
7 | 5496 } |
5497 | |
5498 /* | |
5499 * ":stop" and ":suspend": Suspend Vim. | |
5500 */ | |
5501 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5502 ex_stop(exarg_T *eap) |
7 | 5503 { |
5504 /* | |
5505 * Disallow suspending for "rvim". | |
5506 */ | |
10264
c036c0f636d5
commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents:
10240
diff
changeset
|
5507 if (!check_restricted()) |
7 | 5508 { |
5509 if (!eap->forceit) | |
5510 autowrite_all(); | |
5511 windgoto((int)Rows - 1, 0); | |
5512 out_char('\n'); | |
5513 out_flush(); | |
5514 stoptermcap(); | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5515 out_flush(); // needed for SUN to restore xterm buffer |
7 | 5516 #ifdef FEAT_TITLE |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5517 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
|
5518 #endif |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5519 ui_suspend(); // call machine specific function |
7 | 5520 #ifdef FEAT_TITLE |
5521 maketitle(); | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5522 resettitle(); // force updating the title |
7 | 5523 #endif |
5524 starttermcap(); | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5525 scroll_start(); // scroll screen before redrawing |
7 | 5526 redraw_later_clear(); |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5527 shell_resized(); // may have resized window |
7 | 5528 } |
5529 } | |
5530 | |
5531 /* | |
13442
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5532 * ":exit", ":xit" and ":wq": Write file and quite the current window. |
7 | 5533 */ |
5534 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5535 ex_exit(exarg_T *eap) |
7 | 5536 { |
5537 #ifdef FEAT_CMDWIN | |
5538 if (cmdwin_type != 0) | |
5539 { | |
5540 cmdwin_result = Ctrl_C; | |
5541 return; | |
5542 } | |
5543 #endif | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5544 // Don't quit while editing the command line. |
633 | 5545 if (text_locked()) |
5546 { | |
5547 text_locked_msg(); | |
631 | 5548 return; |
5549 } | |
13442
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5550 |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5551 if (before_quit_autocmds(curwin, FALSE, eap->forceit)) |
819 | 5552 return; |
7 | 5553 |
5554 /* | |
5555 * if more files or windows we won't exit | |
5556 */ | |
5557 if (check_more(FALSE, eap->forceit) == OK && only_one_window()) | |
5558 exiting = TRUE; | |
5559 if ( ((eap->cmdidx == CMD_wq | |
5560 || curbufIsChanged()) | |
5561 && do_write(eap) == FAIL) | |
5562 || 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
|
5563 || (only_one_window() && check_changed_any(eap->forceit, FALSE))) |
7 | 5564 { |
5565 not_exiting(); | |
5566 } | |
5567 else | |
5568 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5569 if (only_one_window()) // quit last window, exit Vim |
7 | 5570 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
|
5571 not_exiting(); |
7 | 5572 # ifdef FEAT_GUI |
5573 need_mouse_correct = TRUE; | |
5574 # endif | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5575 // 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
|
5576 win_close(curwin, !buf_hide(curwin->w_buffer)); |
7 | 5577 } |
5578 } | |
5579 | |
5580 /* | |
5581 * ":print", ":list", ":number". | |
5582 */ | |
5583 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5584 ex_print(exarg_T *eap) |
7 | 5585 { |
167 | 5586 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
|
5587 emsg(_(e_emptybuf)); |
167 | 5588 else |
5589 { | |
5590 for ( ;!got_int; ui_breakcheck()) | |
5591 { | |
5592 print_line(eap->line1, | |
5593 (eap->cmdidx == CMD_number || eap->cmdidx == CMD_pound | |
5594 || (eap->flags & EXFLAG_NR)), | |
5595 eap->cmdidx == CMD_list || (eap->flags & EXFLAG_LIST)); | |
5596 if (++eap->line1 > eap->line2) | |
5597 break; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5598 out_flush(); // show one line at a time |
167 | 5599 } |
5600 setpcmark(); | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5601 // put cursor at last line |
167 | 5602 curwin->w_cursor.lnum = eap->line2; |
5603 beginline(BL_SOL | BL_FIX); | |
5604 } | |
7 | 5605 |
5606 ex_no_reprint = TRUE; | |
5607 } | |
5608 | |
5609 #ifdef FEAT_BYTEOFF | |
5610 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5611 ex_goto(exarg_T *eap) |
7 | 5612 { |
5613 goto_byte(eap->line2); | |
5614 } | |
5615 #endif | |
5616 | |
5617 /* | |
5618 * ":shell". | |
5619 */ | |
5620 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5621 ex_shell(exarg_T *eap UNUSED) |
7 | 5622 { |
5623 do_shell(NULL, 0); | |
5624 } | |
5625 | |
14428
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5626 #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
|
5627 |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5628 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
|
5629 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
|
5630 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
|
5631 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
|
5632 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
|
5633 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
|
5634 |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5635 static void |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5636 handle_drop_internal(void) |
7 | 5637 { |
5638 exarg_T ea; | |
5639 int save_msg_scroll = msg_scroll; | |
5640 | |
14428
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5641 // 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
|
5642 // 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
|
5643 drop_busy = TRUE; |
7 | 5644 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5645 // 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
|
5646 // 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
|
5647 // 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
|
5648 // 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
|
5649 if (!buf_hide(curbuf) && !drop_split) |
7 | 5650 { |
5651 ++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
|
5652 drop_split = check_changed(curbuf, CCGD_AW); |
7 | 5653 --emsg_off; |
5654 } | |
14428
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5655 if (drop_split) |
7 | 5656 { |
5657 if (win_split(0, 0) == FAIL) | |
5658 return; | |
2583 | 5659 RESET_BINDING(curwin); |
7 | 5660 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5661 // 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
|
5662 // existing one is overwritten. |
7 | 5663 alist_unlink(curwin->w_alist); |
5664 alist_new(); | |
5665 } | |
5666 | |
5667 /* | |
5668 * Set up the new argument list. | |
5669 */ | |
14428
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5670 alist_set(ALIST(curwin), drop_filec, drop_filev, FALSE, NULL, 0); |
7 | 5671 |
5672 /* | |
5673 * Move to the first file. | |
5674 */ | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5675 // 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
|
5676 CLEAR_FIELD(ea); |
7 | 5677 ea.cmd = (char_u *)"next"; |
5678 do_argfile(&ea, 0); | |
5679 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5680 // 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
|
5681 // mode that is not needed here. |
7 | 5682 need_start_insertmode = FALSE; |
5683 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5684 // 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
|
5685 // 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
|
5686 // msg_scroll being set by displaying a message is irrelevant. |
7 | 5687 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
|
5688 |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5689 if (drop_callback != NULL) |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5690 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
|
5691 |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5692 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
|
5693 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
|
5694 } |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5695 |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5696 /* |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5697 * 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
|
5698 * :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
|
5699 * 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
|
5700 * 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
|
5701 * 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
|
5702 * |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5703 * 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
|
5704 * 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
|
5705 * list. |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5706 */ |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5707 void |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5708 handle_drop( |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5709 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
|
5710 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
|
5711 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
|
5712 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
|
5713 // list |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5714 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
|
5715 { |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5716 // 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
|
5717 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
|
5718 { |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5719 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
|
5720 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
|
5721 return; |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5722 } |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5723 |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5724 // 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
|
5725 // one. |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5726 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
|
5727 { |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5728 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
|
5729 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
|
5730 } |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5731 |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5732 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
|
5733 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
|
5734 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
|
5735 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
|
5736 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
|
5737 |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5738 // 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
|
5739 // - 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
|
5740 // - 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
|
5741 // - 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
|
5742 // 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
|
5743 // 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
|
5744 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
|
5745 return; |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5746 |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5747 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
|
5748 } |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5749 |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5750 /* |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5751 * 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
|
5752 * 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
|
5753 */ |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5754 void |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5755 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
|
5756 { |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5757 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
|
5758 && !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
|
5759 handle_drop_internal(); |
7 | 5760 } |
5761 #endif | |
5762 | |
5763 /* | |
5764 * ":preserve". | |
5765 */ | |
5766 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5767 ex_preserve(exarg_T *eap UNUSED) |
7 | 5768 { |
164 | 5769 curbuf->b_flags |= BF_PRESERVED; |
7 | 5770 ml_preserve(curbuf, TRUE); |
5771 } | |
5772 | |
5773 /* | |
5774 * ":recover". | |
5775 */ | |
5776 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5777 ex_recover(exarg_T *eap) |
7 | 5778 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5779 // Set recoverymode right away to avoid the ATTENTION prompt. |
7 | 5780 recoverymode = TRUE; |
5464 | 5781 if (!check_changed(curbuf, (p_awa ? CCGD_AW : 0) |
5782 | CCGD_MULTWIN | |
5783 | (eap->forceit ? CCGD_FORCEIT : 0) | |
5784 | CCGD_EXCMD) | |
5785 | |
7 | 5786 && (*eap->arg == NUL |
5787 || 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
|
5788 ml_recover(TRUE); |
7 | 5789 recoverymode = FALSE; |
5790 } | |
5791 | |
5792 /* | |
5793 * Command modifier used in a wrong way. | |
5794 */ | |
5795 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5796 ex_wrongmodifier(exarg_T *eap) |
7 | 5797 { |
5798 eap->errmsg = e_invcmd; | |
5799 } | |
5800 | |
5801 /* | |
5802 * :sview [+command] file split window with new file, read-only | |
5803 * :split [[+command] file] split window with current or new file | |
5804 * :vsplit [[+command] file] split window vertically with current or new file | |
5805 * :new [[+command] file] split window with no or new file | |
5806 * :vnew [[+command] file] split vertically window with no or new file | |
5807 * :sfind [+command] file split window with file in 'path' | |
675 | 5808 * |
5809 * :tabedit open new Tab page with empty window | |
5810 * :tabedit [+command] file open new Tab page and edit "file" | |
5811 * :tabnew [[+command] file] just like :tabedit | |
5812 * :tabfind [+command] file open new Tab page and find "file" | |
7 | 5813 */ |
5814 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5815 ex_splitview(exarg_T *eap) |
7 | 5816 { |
675 | 5817 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
|
5818 #if defined(FEAT_SEARCHPATH) || defined(FEAT_BROWSE) |
7 | 5819 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
|
5820 #endif |
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5821 #ifdef FEAT_BROWSE |
7 | 5822 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
|
5823 #endif |
14155
da09e29e59d9
patch 8.1.0095: dialog for ":browse tabnew" says "new window"
Christian Brabandt <cb@256bit.org>
parents:
14059
diff
changeset
|
5824 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
|
5825 || 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
|
5826 || 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
|
5827 |
19271
ebeeb4b4a1fa
patch 8.2.0194: some commands can cause problems in terminal popup
Bram Moolenaar <Bram@vim.org>
parents:
19261
diff
changeset
|
5828 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
|
5829 return; |
da5f5836e90c
patch 8.1.1438: some commands cause trouble in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
5830 |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5831 #ifdef FEAT_GUI |
7 | 5832 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
|
5833 #endif |
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5834 |
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5835 #ifdef FEAT_QUICKFIX |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5836 // 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
|
5837 // quickfix windows. But it's OK when doing ":tab split". |
1661 | 5838 if (bt_quickfix(curbuf) && cmdmod.tab == 0) |
7 | 5839 { |
5840 if (eap->cmdidx == CMD_split) | |
5841 eap->cmdidx = CMD_new; | |
5842 if (eap->cmdidx == CMD_vsplit) | |
5843 eap->cmdidx = CMD_vnew; | |
667 | 5844 } |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5845 #endif |
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5846 |
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5847 #ifdef FEAT_SEARCHPATH |
675 | 5848 if (eap->cmdidx == CMD_sfind || eap->cmdidx == CMD_tabfind) |
7 | 5849 { |
5850 fname = find_file_in_path(eap->arg, (int)STRLEN(eap->arg), | |
5851 FNAME_MESS, TRUE, curbuf->b_ffname); | |
5852 if (fname == NULL) | |
5853 goto theend; | |
5854 eap->arg = fname; | |
5855 } | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5856 # ifdef FEAT_BROWSE |
7 | 5857 else |
5858 # endif | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5859 #endif |
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5860 #ifdef FEAT_BROWSE |
7 | 5861 if (cmdmod.browse |
5862 && eap->cmdidx != CMD_vnew | |
5863 && eap->cmdidx != CMD_new) | |
5864 { | |
461 | 5865 if ( |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
5866 # ifdef FEAT_GUI |
461 | 5867 !gui.in_use && |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
5868 # endif |
461 | 5869 au_has_group((char_u *)"FileExplorer")) |
5870 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5871 // 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
|
5872 // Edit the directory. |
461 | 5873 if (*eap->arg == NUL || !mch_isdir(eap->arg)) |
5874 eap->arg = (char_u *)"."; | |
5875 } | |
5876 else | |
5877 { | |
14155
da09e29e59d9
patch 8.1.0095: dialog for ":browse tabnew" says "new window"
Christian Brabandt <cb@256bit.org>
parents:
14059
diff
changeset
|
5878 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
|
5879 ? _("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
|
5880 : _("Edit File in new window")), |
7 | 5881 eap->arg, NULL, NULL, NULL, curbuf); |
461 | 5882 if (fname == NULL) |
5883 goto theend; | |
5884 eap->arg = fname; | |
5885 } | |
7 | 5886 } |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5887 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
|
5888 #endif |
7 | 5889 |
675 | 5890 /* |
5891 * Either open new tab page or split the window. | |
5892 */ | |
14155
da09e29e59d9
patch 8.1.0095: dialog for ":browse tabnew" says "new window"
Christian Brabandt <cb@256bit.org>
parents:
14059
diff
changeset
|
5893 if (use_tab) |
675 | 5894 { |
820 | 5895 if (win_new_tabpage(cmdmod.tab != 0 ? cmdmod.tab |
5896 : eap->addr_count == 0 ? 0 | |
5897 : (int)eap->line2 + 1) != FAIL) | |
675 | 5898 { |
1498 | 5899 do_exedit(eap, old_curwin); |
675 | 5900 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5901 // set the alternate buffer for the window we came from |
675 | 5902 if (curwin != old_curwin |
5903 && win_valid(old_curwin) | |
5904 && old_curwin->w_buffer != curbuf | |
5905 && !cmdmod.keepalt) | |
5906 old_curwin->w_alt_fnum = curbuf->b_fnum; | |
5907 } | |
5908 } | |
5909 else if (win_split(eap->addr_count > 0 ? (int)eap->line2 : 0, | |
7 | 5910 *eap->cmd == 'v' ? WSP_VERT : 0) != FAIL) |
5911 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5912 // 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
|
5913 // doing ":split" without arguments. |
7 | 5914 if (*eap->arg != NUL |
13384
6740c499de13
patch 8.0.1566: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13380
diff
changeset
|
5915 # ifdef FEAT_BROWSE |
7 | 5916 || cmdmod.browse |
13384
6740c499de13
patch 8.0.1566: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13380
diff
changeset
|
5917 # endif |
7 | 5918 ) |
2583 | 5919 RESET_BINDING(curwin); |
7 | 5920 else |
5921 do_check_scrollbind(FALSE); | |
5922 do_exedit(eap, old_curwin); | |
5923 } | |
5924 | |
667 | 5925 # ifdef FEAT_BROWSE |
7 | 5926 cmdmod.browse = browse_flag; |
667 | 5927 # endif |
5928 | |
5929 # if defined(FEAT_SEARCHPATH) || defined(FEAT_BROWSE) | |
7 | 5930 theend: |
5931 vim_free(fname); | |
667 | 5932 # endif |
5933 } | |
5934 | |
5935 /* | |
682 | 5936 * Open a new tab page. |
667 | 5937 */ |
5938 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5939 tabpage_new(void) |
682 | 5940 { |
5941 exarg_T ea; | |
5942 | |
20007
aadd1cae2ff5
patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
5943 CLEAR_FIELD(ea); |
682 | 5944 ea.cmdidx = CMD_tabnew; |
5945 ea.cmd = (char_u *)"tabn"; | |
5946 ea.arg = (char_u *)""; | |
5947 ex_splitview(&ea); | |
5948 } | |
5949 | |
5950 /* | |
5951 * :tabnext command | |
5952 */ | |
5953 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5954 ex_tabnext(exarg_T *eap) |
682 | 5955 { |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5956 int tab_number; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5957 |
17111
af861fccc309
patch 8.1.1555: NOT_IN_POPUP_WINDOW is confusing
Bram Moolenaar <Bram@vim.org>
parents:
17095
diff
changeset
|
5958 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
|
5959 return; |
685 | 5960 switch (eap->cmdidx) |
5961 { | |
5962 case CMD_tabfirst: | |
5963 case CMD_tabrewind: | |
5964 goto_tabpage(1); | |
5965 break; | |
5966 case CMD_tablast: | |
5967 goto_tabpage(9999); | |
5968 break; | |
5969 case CMD_tabprevious: | |
5970 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
|
5971 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
|
5972 { |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5973 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
|
5974 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
|
5975 |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5976 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
|
5977 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
|
5978 || tab_number == 0) |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5979 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5980 // No numbers as argument. |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5981 eap->errmsg = e_invarg; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5982 return; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5983 } |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5984 } |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5985 else |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5986 { |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5987 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
|
5988 tab_number = 1; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5989 else |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5990 { |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5991 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
|
5992 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
|
5993 { |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5994 eap->errmsg = e_invrange; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5995 return; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5996 } |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5997 } |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5998 } |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5999 goto_tabpage(-tab_number); |
685 | 6000 break; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6001 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
|
6002 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
|
6003 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
|
6004 goto_tabpage(tab_number); |
685 | 6005 break; |
6006 } | |
682 | 6007 } |
6008 | |
6009 /* | |
6010 * :tabmove command | |
6011 */ | |
6012 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6013 ex_tabmove(exarg_T *eap) |
682 | 6014 { |
6775 | 6015 int tab_number; |
3662 | 6016 |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6017 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
|
6018 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
|
6019 tabpage_move(tab_number); |
667 | 6020 } |
6021 | |
6022 /* | |
6023 * :tabs command: List tabs and their contents. | |
6024 */ | |
6025 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6026 ex_tabs(exarg_T *eap UNUSED) |
667 | 6027 { |
6028 tabpage_T *tp; | |
6029 win_T *wp; | |
6030 int tabcount = 1; | |
6031 | |
6032 msg_start(); | |
6033 msg_scroll = TRUE; | |
6034 for (tp = first_tabpage; tp != NULL && !got_int; tp = tp->tp_next) | |
6035 { | |
6036 msg_putchar('\n'); | |
6037 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
|
6038 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
|
6039 out_flush(); // output one line at a time |
667 | 6040 ui_breakcheck(); |
6041 | |
678 | 6042 if (tp == curtab) |
667 | 6043 wp = firstwin; |
6044 else | |
6045 wp = tp->tp_firstwin; | |
6046 for ( ; wp != NULL && !got_int; wp = wp->w_next) | |
6047 { | |
682 | 6048 msg_putchar('\n'); |
6049 msg_putchar(wp == curwin ? '>' : ' '); | |
6050 msg_putchar(' '); | |
672 | 6051 msg_putchar(bufIsChanged(wp->w_buffer) ? '+' : ' '); |
6052 msg_putchar(' '); | |
667 | 6053 if (buf_spname(wp->w_buffer) != NULL) |
3839 | 6054 vim_strncpy(IObuff, buf_spname(wp->w_buffer), IOSIZE - 1); |
667 | 6055 else |
6056 home_replace(wp->w_buffer, wp->w_buffer->b_fname, | |
6057 IObuff, IOSIZE, TRUE); | |
6058 msg_outtrans(IObuff); | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6059 out_flush(); // output one line at a time |
667 | 6060 ui_breakcheck(); |
6061 } | |
6062 } | |
6063 } | |
6064 | |
7 | 6065 /* |
6066 * ":mode": Set screen mode. | |
6067 * If no argument given, just get the screen size and redraw. | |
6068 */ | |
6069 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6070 ex_mode(exarg_T *eap) |
7 | 6071 { |
6072 if (*eap->arg == NUL) | |
6073 shell_resized(); | |
6074 else | |
19131
1fe99999625c
patch 8.2.0125: :mode no longer works for any system
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
6075 emsg(_(e_screenmode)); |
7 | 6076 } |
6077 | |
6078 /* | |
6079 * ":resize". | |
6080 * set, increment or decrement current window height | |
6081 */ | |
6082 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6083 ex_resize(exarg_T *eap) |
7 | 6084 { |
6085 int n; | |
6086 win_T *wp = curwin; | |
6087 | |
6088 if (eap->addr_count > 0) | |
6089 { | |
6090 n = eap->line2; | |
6091 for (wp = firstwin; wp->w_next != NULL && --n > 0; wp = wp->w_next) | |
6092 ; | |
6093 } | |
6094 | |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8577
diff
changeset
|
6095 # ifdef FEAT_GUI |
7 | 6096 need_mouse_correct = TRUE; |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8577
diff
changeset
|
6097 # endif |
7 | 6098 n = atol((char *)eap->arg); |
6099 if (cmdmod.split & WSP_VERT) | |
6100 { | |
6101 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
|
6102 n += curwin->w_width; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6103 else if (n == 0 && eap->arg[0] == NUL) // default is very wide |
7 | 6104 n = 9999; |
6105 win_setwidth_win((int)n, wp); | |
6106 } | |
6107 else | |
6108 { | |
6109 if (*eap->arg == '-' || *eap->arg == '+') | |
6110 n += curwin->w_height; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6111 else if (n == 0 && eap->arg[0] == NUL) // default is very high |
7 | 6112 n = 9999; |
6113 win_setheight_win((int)n, wp); | |
6114 } | |
6115 } | |
6116 | |
6117 /* | |
6118 * ":find [+command] <file>" command. | |
6119 */ | |
6120 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6121 ex_find(exarg_T *eap) |
7 | 6122 { |
6123 #ifdef FEAT_SEARCHPATH | |
6124 char_u *fname; | |
6125 int count; | |
6126 | |
6127 fname = find_file_in_path(eap->arg, (int)STRLEN(eap->arg), FNAME_MESS, | |
6128 TRUE, curbuf->b_ffname); | |
6129 if (eap->addr_count > 0) | |
6130 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6131 // 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
|
6132 // appears several times in the path. |
7 | 6133 count = eap->line2; |
6134 while (fname != NULL && --count > 0) | |
6135 { | |
6136 vim_free(fname); | |
6137 fname = find_file_in_path(NULL, 0, FNAME_MESS, | |
6138 FALSE, curbuf->b_ffname); | |
6139 } | |
6140 } | |
6141 | |
6142 if (fname != NULL) | |
6143 { | |
6144 eap->arg = fname; | |
6145 #endif | |
6146 do_exedit(eap, NULL); | |
6147 #ifdef FEAT_SEARCHPATH | |
6148 vim_free(fname); | |
6149 } | |
6150 #endif | |
6151 } | |
6152 | |
6153 /* | |
167 | 6154 * ":open" simulation: for now just work like ":visual". |
6155 */ | |
6156 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6157 ex_open(exarg_T *eap) |
167 | 6158 { |
6159 regmatch_T regmatch; | |
6160 char_u *p; | |
6161 | |
6162 curwin->w_cursor.lnum = eap->line2; | |
6163 beginline(BL_SOL | BL_FIX); | |
6164 if (*eap->arg == '/') | |
6165 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6166 // ":open /pattern/": put cursor in column found with pattern |
167 | 6167 ++eap->arg; |
19892
5feb426d2ea1
patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19685
diff
changeset
|
6168 p = skip_regexp(eap->arg, '/', p_magic); |
167 | 6169 *p = NUL; |
6170 regmatch.regprog = vim_regcomp(eap->arg, p_magic ? RE_MAGIC : 0); | |
6171 if (regmatch.regprog != NULL) | |
6172 { | |
6173 regmatch.rm_ic = p_ic; | |
6174 p = ml_get_curline(); | |
6175 if (vim_regexec(®match, p, (colnr_T)0)) | |
835 | 6176 curwin->w_cursor.col = (colnr_T)(regmatch.startp[0] - p); |
167 | 6177 else |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
6178 emsg(_(e_nomatch)); |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4803
diff
changeset
|
6179 vim_regfree(regmatch.regprog); |
167 | 6180 } |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6181 // Move to the NUL, ignore any other arguments. |
167 | 6182 eap->arg += STRLEN(eap->arg); |
6183 } | |
6184 check_cursor(); | |
6185 | |
6186 eap->cmdidx = CMD_visual; | |
6187 do_exedit(eap, NULL); | |
6188 } | |
6189 | |
6190 /* | |
6191 * ":edit", ":badd", ":visual". | |
7 | 6192 */ |
6193 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6194 ex_edit(exarg_T *eap) |
7 | 6195 { |
6196 do_exedit(eap, NULL); | |
6197 } | |
6198 | |
6199 /* | |
19195
2ef19eed524a
patch 8.2.0156: various typos in source files and tests
Bram Moolenaar <Bram@vim.org>
parents:
19191
diff
changeset
|
6200 * ":edit <file>" command and alike. |
7 | 6201 */ |
6202 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6203 do_exedit( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6204 exarg_T *eap, |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6205 win_T *old_curwin) // curwin before doing a split or NULL |
7 | 6206 { |
6207 int n; | |
6208 int need_hide; | |
167 | 6209 int exmode_was = exmode_active; |
7 | 6210 |
19271
ebeeb4b4a1fa
patch 8.2.0194: some commands can cause problems in terminal popup
Bram Moolenaar <Bram@vim.org>
parents:
19261
diff
changeset
|
6211 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
|
6212 || 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
|
6213 return; |
7 | 6214 /* |
6215 * ":vi" command ends Ex mode. | |
6216 */ | |
6217 if (exmode_active && (eap->cmdidx == CMD_visual | |
6218 || eap->cmdidx == CMD_view)) | |
6219 { | |
6220 exmode_active = FALSE; | |
6221 if (*eap->arg == NUL) | |
167 | 6222 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6223 // Special case: ":global/pat/visual\NLvi-commands" |
167 | 6224 if (global_busy) |
6225 { | |
6226 int rd = RedrawingDisabled; | |
6227 int nwr = no_wait_return; | |
6228 int ms = msg_scroll; | |
6229 #ifdef FEAT_GUI | |
6230 int he = hold_gui_events; | |
6231 #endif | |
6232 | |
6233 if (eap->nextcmd != NULL) | |
6234 { | |
6235 stuffReadbuff(eap->nextcmd); | |
6236 eap->nextcmd = NULL; | |
6237 } | |
6238 | |
6239 if (exmode_was != EXMODE_VIM) | |
6240 settmode(TMODE_RAW); | |
6241 RedrawingDisabled = 0; | |
6242 no_wait_return = 0; | |
6243 need_wait_return = FALSE; | |
6244 msg_scroll = 0; | |
6245 #ifdef FEAT_GUI | |
6246 hold_gui_events = 0; | |
6247 #endif | |
6248 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
|
6249 pending_exmode_active = TRUE; |
167 | 6250 |
6251 main_loop(FALSE, TRUE); | |
6252 | |
19433
af9d5585cfbf
patch 8.2.0274: hang with combination of feedkeys(), Ex mode and :global
Bram Moolenaar <Bram@vim.org>
parents:
19415
diff
changeset
|
6253 pending_exmode_active = FALSE; |
167 | 6254 RedrawingDisabled = rd; |
6255 no_wait_return = nwr; | |
6256 msg_scroll = ms; | |
6257 #ifdef FEAT_GUI | |
6258 hold_gui_events = he; | |
6259 #endif | |
6260 } | |
7 | 6261 return; |
167 | 6262 } |
7 | 6263 } |
6264 | |
6265 if ((eap->cmdidx == CMD_new | |
675 | 6266 || eap->cmdidx == CMD_tabnew |
6267 || 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
|
6268 || eap->cmdidx == CMD_vnew) && *eap->arg == NUL) |
7 | 6269 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6270 // ":new" or ":tabnew" without argument: edit an new empty buffer |
7 | 6271 setpcmark(); |
6272 (void)do_ecmd(0, NULL, NULL, eap, ECMD_ONE, | |
1743 | 6273 ECMD_HIDE + (eap->forceit ? ECMD_FORCEIT : 0), |
6274 old_curwin == NULL ? curwin : NULL); | |
7 | 6275 } |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
6276 else if ((eap->cmdidx != CMD_split && eap->cmdidx != CMD_vsplit) |
7 | 6277 || *eap->arg != NUL |
6278 #ifdef FEAT_BROWSE | |
6279 || cmdmod.browse | |
6280 #endif | |
6281 ) | |
6282 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6283 // 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
|
6284 // can bring us here, others are stopped earlier. |
822 | 6285 if (*eap->arg != NUL && curbuf_locked()) |
6286 return; | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
6287 |
7 | 6288 n = readonlymode; |
6289 if (eap->cmdidx == CMD_view || eap->cmdidx == CMD_sview) | |
6290 readonlymode = TRUE; | |
6291 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
|
6292 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
|
6293 // empty buffer |
7 | 6294 setpcmark(); |
6295 if (do_ecmd(0, (eap->cmdidx == CMD_enew ? NULL : eap->arg), | |
6296 NULL, eap, | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6297 // ":edit" goes to first line if Vi compatible |
7 | 6298 (*eap->arg == NUL && eap->do_ecmd_lnum == 0 |
6299 && vim_strchr(p_cpo, CPO_GOTO1) != NULL) | |
6300 ? 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
|
6301 (buf_hide(curbuf) ? ECMD_HIDE : 0) |
7 | 6302 + (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
|
6303 // after a split we can use an existing buffer |
5741 | 6304 + (old_curwin != NULL ? ECMD_OLDBUF : 0) |
7 | 6305 + (eap->cmdidx == CMD_badd ? ECMD_ADDBUF : 0 ) |
1743 | 6306 , old_curwin == NULL ? curwin : NULL) == FAIL) |
7 | 6307 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6308 // Editing the file failed. If the window was split, close it. |
7 | 6309 if (old_curwin != NULL) |
6310 { | |
6311 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
|
6312 if (!need_hide || buf_hide(curbuf)) |
7 | 6313 { |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
6314 #if defined(FEAT_EVAL) |
24 | 6315 cleanup_T cs; |
6316 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6317 // 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
|
6318 // aborting() returns FALSE when closing a window. |
24 | 6319 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
|
6320 #endif |
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
6321 #ifdef FEAT_GUI |
7 | 6322 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
|
6323 #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
|
6324 win_close(curwin, !need_hide && !buf_hide(curbuf)); |
24 | 6325 |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
6326 #if defined(FEAT_EVAL) |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6327 // 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
|
6328 // 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
|
6329 // uncaught exception. |
24 | 6330 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
|
6331 #endif |
7 | 6332 } |
6333 } | |
6334 } | |
6335 else if (readonlymode && curbuf->b_nwindows == 1) | |
6336 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6337 // 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
|
6338 // 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
|
6339 // 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
|
6340 // editing the same buffer. |
7 | 6341 curbuf->b_p_ro = TRUE; |
6342 } | |
6343 readonlymode = n; | |
6344 } | |
6345 else | |
6346 { | |
6347 if (eap->do_ecmd_cmd != NULL) | |
6348 do_cmdline_cmd(eap->do_ecmd_cmd); | |
6349 #ifdef FEAT_TITLE | |
6350 n = curwin->w_arg_idx_invalid; | |
6351 #endif | |
6352 check_arg_idx(curwin); | |
6353 #ifdef FEAT_TITLE | |
6354 if (n != curwin->w_arg_idx_invalid) | |
6355 maketitle(); | |
6356 #endif | |
6357 } | |
6358 | |
6359 /* | |
6360 * if ":split file" worked, set alternate file name in old window to new | |
6361 * file | |
6362 */ | |
6363 if (old_curwin != NULL | |
6364 && *eap->arg != NUL | |
6365 && curwin != old_curwin | |
6366 && win_valid(old_curwin) | |
22 | 6367 && old_curwin->w_buffer != curbuf |
6368 && !cmdmod.keepalt) | |
7 | 6369 old_curwin->w_alt_fnum = curbuf->b_fnum; |
6370 | |
6371 ex_no_reprint = TRUE; | |
6372 } | |
6373 | |
6374 #ifndef FEAT_GUI | |
6375 /* | |
6376 * ":gui" and ":gvim" when there is no GUI. | |
6377 */ | |
6378 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6379 ex_nogui(exarg_T *eap) |
7 | 6380 { |
6381 eap->errmsg = e_nogvim; | |
6382 } | |
6383 #endif | |
6384 | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15866
diff
changeset
|
6385 #if defined(FEAT_GUI_MSWIN) && defined(FEAT_MENU) && defined(FEAT_TEAROFF) |
7 | 6386 static void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6387 ex_tearoff(exarg_T *eap) |
7 | 6388 { |
6389 gui_make_tearoff(eap->arg); | |
6390 } | |
6391 #endif | |
6392 | |
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
|
6393 #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
|
6394 || defined(FEAT_TERM_POPUP_MENU)) && defined(FEAT_MENU) |
7 | 6395 static void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6396 ex_popup(exarg_T *eap) |
7 | 6397 { |
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
|
6398 # 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
|
6399 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
|
6400 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
|
6401 # 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
|
6402 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
|
6403 # 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
|
6404 # 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
|
6405 # 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
|
6406 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
|
6407 # endif |
7 | 6408 } |
6409 #endif | |
6410 | |
6411 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6412 ex_swapname(exarg_T *eap UNUSED) |
7 | 6413 { |
6414 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
|
6415 msg(_("No swap file")); |
7 | 6416 else |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15510
diff
changeset
|
6417 msg((char *)curbuf->b_ml.ml_mfp->mf_fname); |
7 | 6418 } |
6419 | |
6420 /* | |
6421 * ":syncbind" forces all 'scrollbind' windows to have the same relative | |
6422 * offset. | |
6423 * (1998-11-02 16:21:01 R. Edward Ralston <eralston@computer.org>) | |
6424 */ | |
6425 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6426 ex_syncbind(exarg_T *eap UNUSED) |
7 | 6427 { |
6428 win_T *wp; | |
5566 | 6429 win_T *save_curwin = curwin; |
6430 buf_T *save_curbuf = curbuf; | |
7 | 6431 long topline; |
6432 long y; | |
6433 linenr_T old_linenr = curwin->w_cursor.lnum; | |
6434 | |
6435 setpcmark(); | |
6436 | |
6437 /* | |
6438 * determine max topline | |
6439 */ | |
6440 if (curwin->w_p_scb) | |
6441 { | |
6442 topline = curwin->w_topline; | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9538
diff
changeset
|
6443 FOR_ALL_WINDOWS(wp) |
7 | 6444 { |
6445 if (wp->w_p_scb && wp->w_buffer) | |
6446 { | |
15713
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15663
diff
changeset
|
6447 y = wp->w_buffer->b_ml.ml_line_count - get_scrolloff_value(); |
7 | 6448 if (topline > y) |
6449 topline = y; | |
6450 } | |
6451 } | |
6452 if (topline < 1) | |
6453 topline = 1; | |
6454 } | |
6455 else | |
6456 { | |
6457 topline = 1; | |
6458 } | |
6459 | |
6460 | |
6461 /* | |
5566 | 6462 * Set all scrollbind windows to the same topline. |
7 | 6463 */ |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9538
diff
changeset
|
6464 FOR_ALL_WINDOWS(curwin) |
7 | 6465 { |
6466 if (curwin->w_p_scb) | |
6467 { | |
5566 | 6468 curbuf = curwin->w_buffer; |
7 | 6469 y = topline - curwin->w_topline; |
6470 if (y > 0) | |
6471 scrollup(y, TRUE); | |
6472 else | |
6473 scrolldown(-y, TRUE); | |
6474 curwin->w_scbind_pos = topline; | |
6475 redraw_later(VALID); | |
6476 cursor_correct(); | |
6477 curwin->w_redr_status = TRUE; | |
6478 } | |
6479 } | |
5566 | 6480 curwin = save_curwin; |
6481 curbuf = save_curbuf; | |
7 | 6482 if (curwin->w_p_scb) |
6483 { | |
6484 did_syncbind = TRUE; | |
6485 checkpcmark(); | |
6486 if (old_linenr != curwin->w_cursor.lnum) | |
6487 { | |
6488 char_u ctrl_o[2]; | |
6489 | |
6490 ctrl_o[0] = Ctrl_O; | |
6491 ctrl_o[1] = 0; | |
6492 ins_typebuf(ctrl_o, REMAP_NONE, 0, TRUE, FALSE); | |
6493 } | |
6494 } | |
6495 } | |
6496 | |
6497 | |
6498 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6499 ex_read(exarg_T *eap) |
7 | 6500 { |
167 | 6501 int i; |
6502 int empty = (curbuf->b_ml.ml_flags & ML_EMPTY); | |
6503 linenr_T lnum; | |
7 | 6504 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6505 if (eap->usefilter) // :r!cmd |
7 | 6506 do_bang(1, eap, FALSE, FALSE, TRUE); |
6507 else | |
6508 { | |
6509 if (u_save(eap->line2, (linenr_T)(eap->line2 + 1)) == FAIL) | |
6510 return; | |
6511 | |
6512 #ifdef FEAT_BROWSE | |
6513 if (cmdmod.browse) | |
6514 { | |
6515 char_u *browseFile; | |
6516 | |
28 | 6517 browseFile = do_browse(0, (char_u *)_("Append File"), eap->arg, |
7 | 6518 NULL, NULL, NULL, curbuf); |
6519 if (browseFile != NULL) | |
6520 { | |
6521 i = readfile(browseFile, NULL, | |
6522 eap->line2, (linenr_T)0, (linenr_T)MAXLNUM, eap, 0); | |
6523 vim_free(browseFile); | |
6524 } | |
6525 else | |
6526 i = OK; | |
6527 } | |
6528 else | |
6529 #endif | |
6530 if (*eap->arg == NUL) | |
6531 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6532 if (check_fname() == FAIL) // check for no file name |
7 | 6533 return; |
6534 i = readfile(curbuf->b_ffname, curbuf->b_fname, | |
6535 eap->line2, (linenr_T)0, (linenr_T)MAXLNUM, eap, 0); | |
6536 } | |
6537 else | |
6538 { | |
6539 if (vim_strchr(p_cpo, CPO_ALTREAD) != NULL) | |
6540 (void)setaltfname(eap->arg, eap->arg, (linenr_T)1); | |
6541 i = readfile(eap->arg, NULL, | |
6542 eap->line2, (linenr_T)0, (linenr_T)MAXLNUM, eap, 0); | |
6543 | |
6544 } | |
10575
01a5f64a7a20
patch 8.0.0177: BufEnter autocommand not fired for a directory
Christian Brabandt <cb@256bit.org>
parents:
10520
diff
changeset
|
6545 if (i != OK) |
7 | 6546 { |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
6547 #if defined(FEAT_EVAL) |
7 | 6548 if (!aborting()) |
6549 #endif | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
6550 semsg(_(e_notopen), eap->arg); |
7 | 6551 } |
6552 else | |
167 | 6553 { |
6554 if (empty && exmode_active) | |
6555 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6556 // 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
|
6557 // this but vi doesn't. |
167 | 6558 if (eap->line2 == 0) |
6559 lnum = curbuf->b_ml.ml_line_count; | |
6560 else | |
6561 lnum = 1; | |
573 | 6562 if (*ml_get(lnum) == NUL && u_savedel(lnum, 1L) == OK) |
167 | 6563 { |
6564 ml_delete(lnum, FALSE); | |
573 | 6565 if (curwin->w_cursor.lnum > 1 |
6566 && curwin->w_cursor.lnum >= lnum) | |
167 | 6567 --curwin->w_cursor.lnum; |
1929 | 6568 deleted_lines_mark(lnum, 1L); |
167 | 6569 } |
6570 } | |
7 | 6571 redraw_curbuf_later(VALID); |
167 | 6572 } |
7 | 6573 } |
6574 } | |
6575 | |
358 | 6576 static char_u *prev_dir = NULL; |
6577 | |
6578 #if defined(EXITFREE) || defined(PROTO) | |
6579 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6580 free_cd_dir(void) |
358 | 6581 { |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13221
diff
changeset
|
6582 VIM_CLEAR(prev_dir); |
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13221
diff
changeset
|
6583 VIM_CLEAR(globaldir); |
358 | 6584 } |
6585 #endif | |
6586 | |
4704
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
6587 /* |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
6588 * 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
|
6589 * 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
|
6590 * 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
|
6591 */ |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
6592 void |
16576
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6593 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
|
6594 { |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6595 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
|
6596 // 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
|
6597 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
|
6598 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
|
6599 if (scope != CDSCOPE_GLOBAL) |
4704
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
6600 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6601 // If still in global directory, need to remember current |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6602 // directory as global directory. |
4704
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
6603 if (globaldir == NULL && prev_dir != NULL) |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
6604 globaldir = vim_strsave(prev_dir); |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6605 // Remember this local directory for the window. |
4704
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
6606 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
|
6607 { |
16576
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6608 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
|
6609 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
|
6610 else |
8c3a1bd270bb
patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents:
16411
diff
changeset
|
6611 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
|
6612 } |
4704
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
6613 } |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
6614 else |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
6615 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6616 // We are now in the global directory, no need to remember its |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6617 // name. |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13221
diff
changeset
|
6618 VIM_CLEAR(globaldir); |
4704
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
6619 } |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
6620 |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
6621 shorten_fnames(TRUE); |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
6622 } |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
6623 |
16576
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6624 /* |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6625 * Change directory function used by :cd/:tcd/:lcd Ex commands and the |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6626 * chdir() function. If 'winlocaldir' is TRUE, then changes the window-local |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6627 * directory. If 'tablocaldir' is TRUE, then changes the tab-local directory. |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6628 * Otherwise changes the global directory. |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6629 * 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
|
6630 */ |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6631 int |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6632 changedir_func( |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6633 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
|
6634 int forceit, |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6635 cdscope_T scope) |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6636 { |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6637 char_u *tofree; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6638 int dir_differs; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6639 int retval = FALSE; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6640 |
19261
a20c66f13a6e
patch 8.2.0189: cd() with NULL argument crashes
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
6641 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
|
6642 return FALSE; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6643 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6644 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
|
6645 { |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6646 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
|
6647 return FALSE; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6648 } |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6649 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6650 // ":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
|
6651 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
|
6652 { |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6653 if (prev_dir == NULL) |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6654 { |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6655 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
|
6656 return FALSE; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6657 } |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6658 new_dir = prev_dir; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6659 } |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6660 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6661 // 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
|
6662 tofree = prev_dir; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6663 if (mch_dirname(NameBuff, MAXPATHL) == OK) |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6664 prev_dir = vim_strsave(NameBuff); |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6665 else |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6666 prev_dir = NULL; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6667 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6668 #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
|
6669 // 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
|
6670 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
|
6671 { |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6672 // 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
|
6673 # ifdef VMS |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6674 char_u *p; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6675 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6676 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
|
6677 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
|
6678 NameBuff[0] = NUL; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6679 else |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6680 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
|
6681 # else |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6682 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
|
6683 # endif |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6684 new_dir = NameBuff; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6685 } |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6686 #endif |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6687 dir_differs = new_dir == NULL || prev_dir == NULL |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6688 || pathcmp((char *)prev_dir, (char *)new_dir, -1) != 0; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6689 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
|
6690 emsg(_(e_failed)); |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6691 else |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6692 { |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6693 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
|
6694 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6695 post_chdir(scope); |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6696 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6697 if (dir_differs) |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6698 { |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6699 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
|
6700 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
|
6701 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
|
6702 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
|
6703 else |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6704 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
|
6705 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
|
6706 curbuf); |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6707 } |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6708 retval = TRUE; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6709 } |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6710 vim_free(tofree); |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6711 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6712 return retval; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6713 } |
358 | 6714 |
7 | 6715 /* |
16427
8c3a1bd270bb
patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents:
16411
diff
changeset
|
6716 * ":cd", ":tcd", ":lcd", ":chdir" ":tchdir" and ":lchdir". |
7 | 6717 */ |
1411 | 6718 void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6719 ex_cd(exarg_T *eap) |
7 | 6720 { |
15184
90ab2d3ce11d
patch 8.1.0602: DirChanged is also triggered when directory didn't change
Bram Moolenaar <Bram@vim.org>
parents:
15152
diff
changeset
|
6721 char_u *new_dir; |
7 | 6722 |
6723 new_dir = eap->arg; | |
6724 #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
|
6725 // for non-UNIX ":cd" means: print current directory |
7 | 6726 if (*new_dir == NUL) |
6727 ex_pwd(NULL); | |
6728 else | |
6729 #endif | |
6730 { | |
16576
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6731 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
|
6732 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6733 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
|
6734 scope = CDSCOPE_WINDOW; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6735 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
|
6736 scope = CDSCOPE_TABPAGE; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6737 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6738 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
|
6739 { |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6740 // Echo the new current directory if the command was typed. |
1930 | 6741 if (KeyTyped || p_verbose >= 5) |
7 | 6742 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
|
6743 } |
7 | 6744 } |
6745 } | |
6746 | |
6747 /* | |
6748 * ":pwd". | |
6749 */ | |
6750 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6751 ex_pwd(exarg_T *eap UNUSED) |
7 | 6752 { |
6753 if (mch_dirname(NameBuff, MAXPATHL) == OK) | |
6754 { | |
6755 #ifdef BACKSLASH_IN_FILENAME | |
6756 slash_adjust(NameBuff); | |
6757 #endif | |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15510
diff
changeset
|
6758 msg((char *)NameBuff); |
7 | 6759 } |
6760 else | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
6761 emsg(_("E187: Unknown")); |
7 | 6762 } |
6763 | |
6764 /* | |
6765 * ":=". | |
6766 */ | |
6767 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6768 ex_equal(exarg_T *eap) |
7 | 6769 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
6770 smsg("%ld", (long)eap->line2); |
167 | 6771 ex_may_print(eap); |
7 | 6772 } |
6773 | |
6774 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6775 ex_sleep(exarg_T *eap) |
7 | 6776 { |
236 | 6777 int n; |
6778 long len; | |
7 | 6779 |
6780 if (cursor_valid()) | |
6781 { | |
6782 n = W_WINROW(curwin) + curwin->w_wrow - msg_scrolled; | |
6783 if (n >= 0) | |
12513
3ca08bf99396
patch 8.0.1135: W_WINCOL() is always the same
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
6784 windgoto((int)n, curwin->w_wincol + curwin->w_wcol); |
7 | 6785 } |
236 | 6786 |
6787 len = eap->line2; | |
6788 switch (*eap->arg) | |
6789 { | |
6790 case 'm': break; | |
6791 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
|
6792 default: semsg(_(e_invarg2), eap->arg); return; |
236 | 6793 } |
6794 do_sleep(len); | |
7 | 6795 } |
6796 | |
6797 /* | |
6798 * Sleep for "msec" milliseconds, but keep checking for a CTRL-C every second. | |
6799 */ | |
6800 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6801 do_sleep(long msec) |
7 | 6802 { |
17712
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
6803 long done = 0; |
8577
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
6804 long wait_now; |
17712
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
6805 # ifdef ELAPSED_FUNC |
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
6806 elapsed_T start_tv; |
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
6807 |
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
6808 // 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
|
6809 // 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
|
6810 ELAPSED_INIT(start_tv); |
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
6811 # endif |
7 | 6812 |
6813 cursor_on(); | |
14860
ac5d0d27aef9
patch 8.1.0442: GUI: cursor not drawn after ":redraw | sleep"
Christian Brabandt <cb@256bit.org>
parents:
14760
diff
changeset
|
6814 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
|
6815 while (!got_int && done < msec) |
8577
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
6816 { |
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
6817 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
|
6818 #ifdef FEAT_TIMERS |
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
6819 { |
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
6820 long due_time = check_due_timer(); |
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
6821 |
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
6822 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
|
6823 wait_now = due_time; |
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
6824 } |
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
6825 #endif |
10240
175b1116f96a
commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents:
10184
diff
changeset
|
6826 #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
|
6827 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
|
6828 wait_now = 20L; |
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17652
diff
changeset
|
6829 #endif |
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17652
diff
changeset
|
6830 #ifdef FEAT_SOUND |
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17652
diff
changeset
|
6831 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
|
6832 wait_now = 20L; |
10240
175b1116f96a
commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents:
10184
diff
changeset
|
6833 #endif |
8577
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
6834 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
|
6835 |
10240
175b1116f96a
commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents:
10184
diff
changeset
|
6836 #ifdef FEAT_JOB_CHANNEL |
175b1116f96a
commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents:
10184
diff
changeset
|
6837 if (has_any_channel()) |
175b1116f96a
commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents:
10184
diff
changeset
|
6838 ui_breakcheck_force(TRUE); |
175b1116f96a
commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents:
10184
diff
changeset
|
6839 else |
175b1116f96a
commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents:
10184
diff
changeset
|
6840 #endif |
175b1116f96a
commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents:
10184
diff
changeset
|
6841 ui_breakcheck(); |
7109
fa95595fbc52
commit https://github.com/vim/vim/commit/93c88e0f6a4a8f7634ed84721daf4af46fc0d5db
Christian Brabandt <cb@256bit.org>
parents:
7105
diff
changeset
|
6842 #ifdef MESSAGE_QUEUE |
17712
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
6843 // 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
|
6844 // 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
|
6845 // 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
|
6846 parse_queued_messages(); |
3151 | 6847 #endif |
17712
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
6848 |
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
6849 # ifdef ELAPSED_FUNC |
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
6850 // actual time passed |
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
6851 done = ELAPSED_FUNC(start_tv); |
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
6852 # else |
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
6853 // 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
|
6854 done += wait_now; |
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
6855 # endif |
7 | 6856 } |
14284
7cd8298c4c04
patch 8.1.0158: GUI: input() fails if CTRL-C was pressed before
Christian Brabandt <cb@256bit.org>
parents:
14266
diff
changeset
|
6857 |
7cd8298c4c04
patch 8.1.0158: GUI: input() fails if CTRL-C was pressed before
Christian Brabandt <cb@256bit.org>
parents:
14266
diff
changeset
|
6858 // 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
|
6859 // 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
|
6860 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
|
6861 (void)vpeekc(); |
7 | 6862 } |
6863 | |
6864 /* | |
6865 * ":winsize" command (obsolete). | |
6866 */ | |
6867 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6868 ex_winsize(exarg_T *eap) |
7 | 6869 { |
6870 int w, h; | |
6871 char_u *arg = eap->arg; | |
6872 char_u *p; | |
6873 | |
6874 w = getdigits(&arg); | |
6875 arg = skipwhite(arg); | |
6876 p = arg; | |
6877 h = getdigits(&arg); | |
6878 if (*p != NUL && *arg == NUL) | |
6879 set_shellsize(w, h, TRUE); | |
6880 else | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
6881 emsg(_("E465: :winsize requires two number arguments")); |
7 | 6882 } |
6883 | |
6884 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6885 ex_wincmd(exarg_T *eap) |
7 | 6886 { |
6887 int xchar = NUL; | |
6888 char_u *p; | |
6889 | |
6890 if (*eap->arg == 'g' || *eap->arg == Ctrl_G) | |
6891 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6892 // CTRL-W g and CTRL-W CTRL-G have an extra command character |
7 | 6893 if (eap->arg[1] == NUL) |
6894 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
6895 emsg(_(e_invarg)); |
7 | 6896 return; |
6897 } | |
6898 xchar = eap->arg[1]; | |
6899 p = eap->arg + 2; | |
6900 } | |
6901 else | |
6902 p = eap->arg + 1; | |
6903 | |
6904 eap->nextcmd = check_nextcmd(p); | |
6905 p = skipwhite(p); | |
6906 if (*p != NUL && *p != '"' && eap->nextcmd == NULL) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
6907 emsg(_(e_invarg)); |
2887 | 6908 else if (!eap->skip) |
7 | 6909 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6910 // Pass flags on for ":vertical wincmd ]". |
7 | 6911 postponed_split_flags = cmdmod.split; |
1090 | 6912 postponed_split_tab = cmdmod.tab; |
7 | 6913 do_window(*eap->arg, eap->addr_count > 0 ? eap->line2 : 0L, xchar); |
6914 postponed_split_flags = 0; | |
1090 | 6915 postponed_split_tab = 0; |
7 | 6916 } |
6917 } | |
6918 | |
11 | 6919 #if defined(FEAT_GUI) || defined(UNIX) || defined(VMS) || defined(MSWIN) |
7 | 6920 /* |
6921 * ":winpos". | |
6922 */ | |
6923 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6924 ex_winpos(exarg_T *eap) |
7 | 6925 { |
6926 int x, y; | |
6927 char_u *arg = eap->arg; | |
6928 char_u *p; | |
6929 | |
6930 if (*arg == NUL) | |
6931 { | |
11 | 6932 # 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
|
6933 # 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
|
6934 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
|
6935 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
|
6936 # elif defined(FEAT_GUI) |
7 | 6937 if (gui.in_use && gui_mch_get_winpos(&x, &y) != FAIL) |
11 | 6938 # else |
6939 if (mch_get_winpos(&x, &y) != FAIL) | |
6940 # endif | |
7 | 6941 { |
6942 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
|
6943 msg((char *)IObuff); |
7 | 6944 } |
6945 else | |
6946 # endif | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
6947 emsg(_("E188: Obtaining window position not implemented for this platform")); |
7 | 6948 } |
6949 else | |
6950 { | |
6951 x = getdigits(&arg); | |
6952 arg = skipwhite(arg); | |
6953 p = arg; | |
6954 y = getdigits(&arg); | |
6955 if (*p == NUL || *arg != NUL) | |
6956 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
6957 emsg(_("E466: :winpos requires two number arguments")); |
7 | 6958 return; |
6959 } | |
6960 # ifdef FEAT_GUI | |
6961 if (gui.in_use) | |
6962 gui_mch_set_winpos(x, y); | |
6963 else if (gui.starting) | |
6964 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6965 // Remember the coordinates for when the window is opened. |
7 | 6966 gui_win_x = x; |
6967 gui_win_y = y; | |
6968 } | |
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
|
6969 # if defined(HAVE_TGETENT) || defined(VIMDLL) |
7 | 6970 else |
6971 # 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
|
6972 # 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
|
6973 # if defined(MSWIN) && (!defined(FEAT_GUI) || defined(VIMDLL)) |
11 | 6974 mch_set_winpos(x, y); |
7 | 6975 # endif |
6976 # ifdef HAVE_TGETENT | |
6977 if (*T_CWP) | |
6978 term_set_winpos(x, y); | |
6979 # endif | |
6980 } | |
6981 } | |
6982 #endif | |
6983 | |
6984 /* | |
6985 * Handle command that work like operators: ":delete", ":yank", ":>" and ":<". | |
6986 */ | |
6987 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6988 ex_operators(exarg_T *eap) |
7 | 6989 { |
6990 oparg_T oa; | |
6991 | |
6992 clear_oparg(&oa); | |
6993 oa.regname = eap->regname; | |
6994 oa.start.lnum = eap->line1; | |
6995 oa.end.lnum = eap->line2; | |
6996 oa.line_count = eap->line2 - eap->line1 + 1; | |
6997 oa.motion_type = MLINE; | |
6998 virtual_op = FALSE; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6999 if (eap->cmdidx != CMD_yank) // position cursor for undo |
7 | 7000 { |
7001 setpcmark(); | |
7002 curwin->w_cursor.lnum = eap->line1; | |
7003 beginline(BL_SOL | BL_FIX); | |
7004 } | |
7005 | |
5498 | 7006 if (VIsual_active) |
7007 end_visual_mode(); | |
7008 | |
7 | 7009 switch (eap->cmdidx) |
7010 { | |
7011 case CMD_delete: | |
7012 oa.op_type = OP_DELETE; | |
7013 op_delete(&oa); | |
7014 break; | |
7015 | |
7016 case CMD_yank: | |
7017 oa.op_type = OP_YANK; | |
7018 (void)op_yank(&oa, FALSE, TRUE); | |
7019 break; | |
7020 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7021 default: // CMD_rshift or CMD_lshift |
4889
25d64a4edc0b
updated for version 7.3.1190
Bram Moolenaar <bram@vim.org>
parents:
4857
diff
changeset
|
7022 if ( |
7 | 7023 #ifdef FEAT_RIGHTLEFT |
4889
25d64a4edc0b
updated for version 7.3.1190
Bram Moolenaar <bram@vim.org>
parents:
4857
diff
changeset
|
7024 (eap->cmdidx == CMD_rshift) ^ curwin->w_p_rl |
25d64a4edc0b
updated for version 7.3.1190
Bram Moolenaar <bram@vim.org>
parents:
4857
diff
changeset
|
7025 #else |
25d64a4edc0b
updated for version 7.3.1190
Bram Moolenaar <bram@vim.org>
parents:
4857
diff
changeset
|
7026 eap->cmdidx == CMD_rshift |
25d64a4edc0b
updated for version 7.3.1190
Bram Moolenaar <bram@vim.org>
parents:
4857
diff
changeset
|
7027 #endif |
25d64a4edc0b
updated for version 7.3.1190
Bram Moolenaar <bram@vim.org>
parents:
4857
diff
changeset
|
7028 ) |
7 | 7029 oa.op_type = OP_RSHIFT; |
7030 else | |
7031 oa.op_type = OP_LSHIFT; | |
7032 op_shift(&oa, FALSE, eap->amount); | |
7033 break; | |
7034 } | |
7035 virtual_op = MAYBE; | |
167 | 7036 ex_may_print(eap); |
7 | 7037 } |
7038 | |
7039 /* | |
7040 * ":put". | |
7041 */ | |
7042 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7043 ex_put(exarg_T *eap) |
7 | 7044 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7045 // ":0put" works like ":1put!". |
7 | 7046 if (eap->line2 == 0) |
7047 { | |
7048 eap->line2 = 1; | |
7049 eap->forceit = TRUE; | |
7050 } | |
7051 curwin->w_cursor.lnum = eap->line2; | |
167 | 7052 do_put(eap->regname, eap->forceit ? BACKWARD : FORWARD, 1L, |
7053 PUT_LINE|PUT_CURSLINE); | |
7 | 7054 } |
7055 | |
7056 /* | |
7057 * Handle ":copy" and ":move". | |
7058 */ | |
7059 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7060 ex_copymove(exarg_T *eap) |
7 | 7061 { |
7062 long n; | |
7063 | |
14760
fd69edd2c67e
patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents:
14700
diff
changeset
|
7064 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
|
7065 if (eap->arg == NULL) // error detected |
7 | 7066 { |
7067 eap->nextcmd = NULL; | |
7068 return; | |
7069 } | |
167 | 7070 get_flags(eap); |
7 | 7071 |
7072 /* | |
7073 * move or copy lines from 'eap->line1'-'eap->line2' to below line 'n' | |
7074 */ | |
7075 if (n == MAXLNUM || n < 0 || n > curbuf->b_ml.ml_line_count) | |
7076 { | |
17650
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
7077 emsg(_(e_invrange)); |
7 | 7078 return; |
7079 } | |
7080 | |
7081 if (eap->cmdidx == CMD_move) | |
7082 { | |
7083 if (do_move(eap->line1, eap->line2, n) == FAIL) | |
7084 return; | |
7085 } | |
7086 else | |
7087 ex_copy(eap->line1, eap->line2, n); | |
7088 u_clearline(); | |
7089 beginline(BL_SOL | BL_FIX); | |
167 | 7090 ex_may_print(eap); |
7091 } | |
7092 | |
7093 /* | |
7094 * Print the current line if flags were given to the Ex command. | |
7095 */ | |
5776 | 7096 void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7097 ex_may_print(exarg_T *eap) |
167 | 7098 { |
7099 if (eap->flags != 0) | |
7100 { | |
7101 print_line(curwin->w_cursor.lnum, (eap->flags & EXFLAG_NR), | |
7102 (eap->flags & EXFLAG_LIST)); | |
7103 ex_no_reprint = TRUE; | |
7104 } | |
7 | 7105 } |
7106 | |
7107 /* | |
7108 * ":smagic" and ":snomagic". | |
7109 */ | |
7110 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7111 ex_submagic(exarg_T *eap) |
7 | 7112 { |
7113 int magic_save = p_magic; | |
7114 | |
7115 p_magic = (eap->cmdidx == CMD_smagic); | |
7116 do_sub(eap); | |
7117 p_magic = magic_save; | |
7118 } | |
7119 | |
7120 /* | |
7121 * ":join". | |
7122 */ | |
7123 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7124 ex_join(exarg_T *eap) |
7 | 7125 { |
7126 curwin->w_cursor.lnum = eap->line1; | |
7127 if (eap->line1 == eap->line2) | |
7128 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7129 if (eap->addr_count >= 2) // :2,2join does nothing |
7 | 7130 return; |
7131 if (eap->line2 == curbuf->b_ml.ml_line_count) | |
7132 { | |
7133 beep_flush(); | |
7134 return; | |
7135 } | |
7136 ++eap->line2; | |
7137 } | |
5848 | 7138 (void)do_join(eap->line2 - eap->line1 + 1, !eap->forceit, TRUE, TRUE, TRUE); |
7 | 7139 beginline(BL_WHITE | BL_FIX); |
167 | 7140 ex_may_print(eap); |
7 | 7141 } |
7142 | |
7143 /* | |
7144 * ":[addr]@r" or ":[addr]*r": execute register | |
7145 */ | |
7146 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7147 ex_at(exarg_T *eap) |
7 | 7148 { |
7149 int c; | |
1973 | 7150 int prev_len = typebuf.tb_len; |
7 | 7151 |
7152 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
|
7153 check_cursor_col(); |
7 | 7154 |
7155 #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
|
7156 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
|
7157 #endif |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7158 |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7159 // get the register name. No name means to use the previous one |
7 | 7160 c = *eap->arg; |
7161 if (c == NUL || (c == '*' && *eap->cmd == '*')) | |
7162 c = '@'; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7163 // Put the register in the typeahead buffer with the "silent" flag. |
1034 | 7164 if (do_execreg(c, TRUE, vim_strchr(p_cpo, CPO_EXECBUF) != NULL, TRUE) |
7165 == FAIL) | |
167 | 7166 { |
7 | 7167 beep_flush(); |
167 | 7168 } |
7 | 7169 else |
7170 { | |
7171 int save_efr = exec_from_reg; | |
7172 | |
7173 exec_from_reg = TRUE; | |
7174 | |
7175 /* | |
7176 * Execute from the typeahead buffer. | |
1973 | 7177 * Continue until the stuff buffer is empty and all added characters |
7178 * have been consumed. | |
7 | 7179 */ |
1973 | 7180 while (!stuff_empty() || typebuf.tb_len > prev_len) |
7 | 7181 (void)do_cmdline(NULL, getexline, NULL, DOCMD_NOWAIT|DOCMD_VERBOSE); |
7182 | |
7183 exec_from_reg = save_efr; | |
7184 } | |
7185 } | |
7186 | |
7187 /* | |
7188 * ":!". | |
7189 */ | |
7190 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7191 ex_bang(exarg_T *eap) |
7 | 7192 { |
7193 do_bang(eap->addr_count, eap, eap->forceit, TRUE, TRUE); | |
7194 } | |
7195 | |
7196 /* | |
7197 * ":undo". | |
7198 */ | |
7199 static void | |
8368
db2a07b710ed
commit https://github.com/vim/vim/commit/f1d2501ebe33e148886c2914acd33140e20ee222
Christian Brabandt <cb@256bit.org>
parents:
8281
diff
changeset
|
7200 ex_undo(exarg_T *eap) |
7 | 7201 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7202 if (eap->addr_count == 1) // :undo 123 |
2281
e41433ea71df
Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents:
2276
diff
changeset
|
7203 undo_time(eap->line2, FALSE, FALSE, TRUE); |
771 | 7204 else |
7205 u_undo(1); | |
7 | 7206 } |
7207 | |
2214
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
7208 #ifdef FEAT_PERSISTENT_UNDO |
2340
99c1eba60b2d
Make automatic prototype generation work with more interfaces.
Bram Moolenaar <bram@vim.org>
parents:
2333
diff
changeset
|
7209 static void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7210 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
|
7211 { |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
7212 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
|
7213 |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
7214 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
|
7215 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
|
7216 } |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
7217 |
2340
99c1eba60b2d
Make automatic prototype generation work with more interfaces.
Bram Moolenaar <bram@vim.org>
parents:
2333
diff
changeset
|
7218 static void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7219 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
|
7220 { |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
7221 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
|
7222 |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
7223 u_compute_hash(hash); |
2238
3d0a7beb0d75
Made reading/writing undo info a bit more robust.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
7224 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
|
7225 } |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
7226 #endif |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
7227 |
7 | 7228 /* |
7229 * ":redo". | |
7230 */ | |
7231 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7232 ex_redo(exarg_T *eap UNUSED) |
7 | 7233 { |
7234 u_redo(1); | |
7235 } | |
7236 | |
7237 /* | |
756 | 7238 * ":earlier" and ":later". |
7239 */ | |
7240 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7241 ex_later(exarg_T *eap) |
756 | 7242 { |
7243 long count = 0; | |
7244 int sec = FALSE; | |
2281
e41433ea71df
Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents:
2276
diff
changeset
|
7245 int file = FALSE; |
756 | 7246 char_u *p = eap->arg; |
7247 | |
7248 if (*p == NUL) | |
7249 count = 1; | |
7250 else if (isdigit(*p)) | |
7251 { | |
7252 count = getdigits(&p); | |
7253 switch (*p) | |
7254 { | |
7255 case 's': ++p; sec = TRUE; break; | |
7256 case 'm': ++p; sec = TRUE; count *= 60; break; | |
7257 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
|
7258 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
|
7259 case 'f': ++p; file = TRUE; break; |
756 | 7260 } |
7261 } | |
7262 | |
7263 if (*p != NUL) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7264 semsg(_(e_invarg2), eap->arg); |
756 | 7265 else |
2281
e41433ea71df
Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents:
2276
diff
changeset
|
7266 undo_time(eap->cmdidx == CMD_earlier ? -count : count, |
e41433ea71df
Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents:
2276
diff
changeset
|
7267 sec, file, FALSE); |
756 | 7268 } |
7269 | |
7270 /* | |
7 | 7271 * ":redir": start/stop redirection. |
7272 */ | |
7273 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7274 ex_redir(exarg_T *eap) |
7 | 7275 { |
7276 char *mode; | |
7277 char_u *fname; | |
122 | 7278 char_u *arg = eap->arg; |
7 | 7279 |
9440
73c0d07cc15e
commit https://github.com/vim/vim/commit/ba768495c2e6bae74e49d22d489fbf211ecad55e
Christian Brabandt <cb@256bit.org>
parents:
9438
diff
changeset
|
7280 #ifdef FEAT_EVAL |
9454
9da0cb39cbee
commit https://github.com/vim/vim/commit/79815f1ec77406f2f21a618c053e5793b597db7a
Christian Brabandt <cb@256bit.org>
parents:
9440
diff
changeset
|
7281 if (redir_execute) |
9da0cb39cbee
commit https://github.com/vim/vim/commit/79815f1ec77406f2f21a618c053e5793b597db7a
Christian Brabandt <cb@256bit.org>
parents:
9440
diff
changeset
|
7282 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7283 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
|
7284 return; |
7897b1e4f3e7
commit https://github.com/vim/vim/commit/245a7cb6d33e556415c9fcaa874b784a6d8f0ef3
Christian Brabandt <cb@256bit.org>
parents:
9432
diff
changeset
|
7285 } |
9440
73c0d07cc15e
commit https://github.com/vim/vim/commit/ba768495c2e6bae74e49d22d489fbf211ecad55e
Christian Brabandt <cb@256bit.org>
parents:
9438
diff
changeset
|
7286 #endif |
9438
7897b1e4f3e7
commit https://github.com/vim/vim/commit/245a7cb6d33e556415c9fcaa874b784a6d8f0ef3
Christian Brabandt <cb@256bit.org>
parents:
9432
diff
changeset
|
7287 |
7 | 7288 if (STRICMP(eap->arg, "END") == 0) |
7289 close_redir(); | |
7290 else | |
7291 { | |
122 | 7292 if (*arg == '>') |
7293 { | |
7294 ++arg; | |
7295 if (*arg == '>') | |
7296 { | |
7297 ++arg; | |
7 | 7298 mode = "a"; |
7299 } | |
7300 else | |
7301 mode = "w"; | |
122 | 7302 arg = skipwhite(arg); |
7 | 7303 |
7304 close_redir(); | |
7305 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7306 // Expand environment variables and "~/". |
122 | 7307 fname = expand_env_save(arg); |
7 | 7308 if (fname == NULL) |
7309 return; | |
7310 #ifdef FEAT_BROWSE | |
7311 if (cmdmod.browse) | |
7312 { | |
7313 char_u *browseFile; | |
7314 | |
28 | 7315 browseFile = do_browse(BROWSE_SAVE, |
7316 (char_u *)_("Save Redirection"), | |
13802
378f9f8e6d8f
patch 8.0.1773: dialog messages are not translated
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
7317 fname, NULL, NULL, |
378f9f8e6d8f
patch 8.0.1773: dialog messages are not translated
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
7318 (char_u *)_(BROWSE_FILTER_ALL_FILES), curbuf); |
7 | 7319 if (browseFile == NULL) |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7320 return; // operation cancelled |
7 | 7321 vim_free(fname); |
7322 fname = browseFile; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7323 eap->forceit = TRUE; // since dialog already asked |
7 | 7324 } |
7325 #endif | |
7326 | |
7327 redir_fd = open_exfile(fname, eap->forceit, mode); | |
7328 vim_free(fname); | |
7329 } | |
7330 #ifdef FEAT_EVAL | |
122 | 7331 else if (*arg == '@') |
7 | 7332 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7333 // redirect to a register a-z (resp. A-Z for appending) |
7 | 7334 close_redir(); |
122 | 7335 ++arg; |
7336 if (ASCII_ISALPHA(*arg) | |
7 | 7337 # ifdef FEAT_CLIPBOARD |
122 | 7338 || *arg == '*' |
1038 | 7339 || *arg == '+' |
7 | 7340 # endif |
122 | 7341 || *arg == '"') |
7342 { | |
7343 redir_reg = *arg++; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7344 if (*arg == '>' && arg[1] == '>') // append |
268 | 7345 arg += 2; |
1427 | 7346 else |
7 | 7347 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7348 // Can use both "@a" and "@a>". |
296 | 7349 if (*arg == '>') |
7350 arg++; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7351 // 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
|
7352 // command is valid. |
1427 | 7353 if (*arg == NUL && !isupper(redir_reg)) |
7354 write_reg_contents(redir_reg, (char_u *)"", -1, FALSE); | |
7 | 7355 } |
167 | 7356 } |
7357 if (*arg != NUL) | |
7358 { | |
268 | 7359 redir_reg = 0; |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7360 semsg(_(e_invarg2), eap->arg); |
167 | 7361 } |
7362 } | |
7363 else if (*arg == '=' && arg[1] == '>') | |
7364 { | |
7365 int append; | |
7366 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7367 // redirect to a variable |
167 | 7368 close_redir(); |
7369 arg += 2; | |
7370 | |
7371 if (*arg == '>') | |
7372 { | |
7373 ++arg; | |
7374 append = TRUE; | |
7 | 7375 } |
7376 else | |
167 | 7377 append = FALSE; |
7378 | |
7379 if (var_redir_start(skipwhite(arg), append) == OK) | |
7380 redir_vname = 1; | |
7 | 7381 } |
7382 #endif | |
7383 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7384 // TODO: redirect to a buffer |
7 | 7385 |
7386 else | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7387 semsg(_(e_invarg2), eap->arg); |
7 | 7388 } |
972 | 7389 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7390 // 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
|
7391 // that indirectly invokes a command to catch its output. |
972 | 7392 if (redir_fd != NULL |
7393 #ifdef FEAT_EVAL | |
7394 || redir_reg || redir_vname | |
7395 #endif | |
7396 ) | |
7397 redir_off = FALSE; | |
7 | 7398 } |
7399 | |
7400 /* | |
7401 * ":redraw": force redraw | |
7402 */ | |
7864
6b0891de44a9
commit https://github.com/vim/vim/commit/fb1f62691eae7c79a28b3b17a60e72ce198c71a2
Christian Brabandt <cb@256bit.org>
parents:
7850
diff
changeset
|
7403 void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7404 ex_redraw(exarg_T *eap) |
7 | 7405 { |
7406 int r = RedrawingDisabled; | |
7407 int p = p_lz; | |
7408 | |
7409 RedrawingDisabled = 0; | |
7410 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
|
7411 validate_cursor(); |
7 | 7412 update_topline(); |
5735 | 7413 update_screen(eap->forceit ? CLEAR : VIsual_active ? INVERTED : 0); |
7 | 7414 #ifdef FEAT_TITLE |
7415 if (need_maketitle) | |
7416 maketitle(); | |
7417 #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
|
7418 #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
|
7419 # 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
|
7420 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
|
7421 # 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
|
7422 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
|
7423 #endif |
7 | 7424 RedrawingDisabled = r; |
7425 p_lz = p; | |
7426 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7427 // Reset msg_didout, so that a message that's there is overwritten. |
7 | 7428 msg_didout = FALSE; |
7429 msg_col = 0; | |
7430 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7431 // 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
|
7432 need_wait_return = FALSE; |
1b89e3f916c5
updated for version 7.4a.025
Bram Moolenaar <bram@vim.org>
parents:
4928
diff
changeset
|
7433 |
7 | 7434 out_flush(); |
7435 } | |
7436 | |
7437 /* | |
7438 * ":redrawstatus": force redraw of status line(s) | |
7439 */ | |
7440 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7441 ex_redrawstatus(exarg_T *eap UNUSED) |
7 | 7442 { |
7443 int r = RedrawingDisabled; | |
7444 int p = p_lz; | |
7445 | |
7446 RedrawingDisabled = 0; | |
7447 p_lz = FALSE; | |
7448 if (eap->forceit) | |
7449 status_redraw_all(); | |
7450 else | |
7451 status_redraw_curbuf(); | |
5735 | 7452 update_screen(VIsual_active ? INVERTED : 0); |
7 | 7453 RedrawingDisabled = r; |
7454 p_lz = p; | |
7455 out_flush(); | |
7456 } | |
7457 | |
15396
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7458 /* |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7459 * ":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
|
7460 */ |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7461 static void |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7462 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
|
7463 { |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7464 int r = RedrawingDisabled; |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7465 int p = p_lz; |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7466 |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7467 RedrawingDisabled = 0; |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7468 p_lz = FALSE; |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7469 |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7470 draw_tabline(); |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7471 |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7472 RedrawingDisabled = r; |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7473 p_lz = p; |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7474 out_flush(); |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7475 } |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7476 |
7 | 7477 static void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7478 close_redir(void) |
7 | 7479 { |
7480 if (redir_fd != NULL) | |
7481 { | |
7482 fclose(redir_fd); | |
7483 redir_fd = NULL; | |
7484 } | |
7485 #ifdef FEAT_EVAL | |
7486 redir_reg = 0; | |
167 | 7487 if (redir_vname) |
7488 { | |
7489 var_redir_stop(); | |
7490 redir_vname = 0; | |
7491 } | |
7 | 7492 #endif |
7493 } | |
7494 | |
17539
554240b9574b
patch 8.1.1767: FEAT_SESSION defined separately
Bram Moolenaar <Bram@vim.org>
parents:
17536
diff
changeset
|
7495 #if (defined(FEAT_SESSION) || defined(FEAT_EVAL)) || defined(PROTO) |
167 | 7496 int |
18139
59bc3cd42cf5
patch 8.1.2064: MS-Windows: compiler warnings for unused arguments
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
7497 vim_mkdir_emsg(char_u *name, int prot UNUSED) |
167 | 7498 { |
7499 if (vim_mkdir(name, prot) != 0) | |
7500 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7501 semsg(_("E739: Cannot create directory: %s"), name); |
167 | 7502 return FAIL; |
7503 } | |
7504 return OK; | |
7505 } | |
7506 #endif | |
7507 | |
7 | 7508 /* |
7509 * Open a file for writing for an Ex command, with some checks. | |
7510 * Return file descriptor, or NULL on failure. | |
7511 */ | |
7512 FILE * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7513 open_exfile( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7514 char_u *fname, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7515 int forceit, |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7516 char *mode) // "w" for create new file or "a" for append |
7 | 7517 { |
7518 FILE *fd; | |
7519 | |
7520 #ifdef UNIX | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7521 // with Unix it is possible to open a directory |
7 | 7522 if (mch_isdir(fname)) |
7523 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7524 semsg(_(e_isadir2), fname); |
7 | 7525 return NULL; |
7526 } | |
7527 #endif | |
7528 if (!forceit && *mode != 'a' && vim_fexists(fname)) | |
7529 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7530 semsg(_("E189: \"%s\" exists (add ! to override)"), fname); |
7 | 7531 return NULL; |
7532 } | |
7533 | |
7534 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
|
7535 semsg(_("E190: Cannot open \"%s\" for writing"), fname); |
7 | 7536 |
7537 return fd; | |
7538 } | |
7539 | |
7540 /* | |
7541 * ":mark" and ":k". | |
7542 */ | |
7543 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7544 ex_mark(exarg_T *eap) |
7 | 7545 { |
7546 pos_T pos; | |
7547 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7548 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
|
7549 emsg(_(e_argreq)); |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7550 else if (eap->arg[1] != NUL) // more than one character? |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7551 emsg(_(e_trailing)); |
7 | 7552 else |
7553 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7554 pos = curwin->w_cursor; // save curwin->w_cursor |
7 | 7555 curwin->w_cursor.lnum = eap->line2; |
7556 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
|
7557 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
|
7558 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
|
7559 curwin->w_cursor = pos; // restore curwin->w_cursor |
7 | 7560 } |
7561 } | |
7562 | |
7563 /* | |
7564 * Update w_topline, w_leftcol and the cursor position. | |
7565 */ | |
7566 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7567 update_topline_cursor(void) |
7 | 7568 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7569 check_cursor(); // put cursor on valid line |
7 | 7570 update_topline(); |
7571 if (!curwin->w_p_wrap) | |
7572 validate_cursor(); | |
7573 update_curswant(); | |
7574 } | |
7575 | |
7576 /* | |
12521
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7577 * 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
|
7578 * 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
|
7579 */ |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7580 int |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7581 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
|
7582 { |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7583 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
|
7584 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
|
7585 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
|
7586 sst->save_State = State; |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7587 sst->save_insertmode = p_im; |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7588 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
|
7589 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
|
7590 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
|
7591 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7592 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
|
7593 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
|
7594 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
|
7595 |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7596 /* |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7597 * 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
|
7598 * 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
|
7599 * ends with half a command. |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7600 */ |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7601 save_typeahead(&sst->tabuf); |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7602 return sst->tabuf.typebuf_valid; |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7603 } |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7604 |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7605 void |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7606 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
|
7607 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7608 // Restore the previous typeahead. |
12521
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7609 restore_typeahead(&sst->tabuf); |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7610 |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7611 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
|
7612 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
|
7613 p_im = sst->save_insertmode; |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7614 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
|
7615 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
|
7616 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
|
7617 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
|
7618 |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7619 // 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
|
7620 // '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
|
7621 State = sst->save_State; |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7622 #ifdef CURSOR_SHAPE |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7623 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
|
7624 #endif |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7625 } |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7626 |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7627 /* |
7 | 7628 * ":normal[!] {commands}": Execute normal mode commands. |
7629 */ | |
7840
28f569c7dab9
commit https://github.com/vim/vim/commit/20fb9f346497daca4d19402fdfa5de7958642477
Christian Brabandt <cb@256bit.org>
parents:
7819
diff
changeset
|
7630 void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7631 ex_normal(exarg_T *eap) |
7 | 7632 { |
12521
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7633 save_state_T save_state; |
7 | 7634 char_u *arg = NULL; |
7635 int l; | |
7636 char_u *p; | |
7637 | |
856 | 7638 if (ex_normal_lock > 0) |
7639 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7640 emsg(_(e_secure)); |
856 | 7641 return; |
7642 } | |
7 | 7643 if (ex_normal_busy >= p_mmd) |
7644 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7645 emsg(_("E192: Recursive use of :normal too deep")); |
7 | 7646 return; |
7647 } | |
7648 | |
7649 /* | |
7650 * vgetc() expects a CSI and K_SPECIAL to have been escaped. Don't do | |
7651 * this for the K_SPECIAL leading byte, otherwise special keys will not | |
7652 * work. | |
7653 */ | |
7654 if (has_mbyte) | |
7655 { | |
7656 int len = 0; | |
7657 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7658 // Count the number of characters to be escaped. |
7 | 7659 for (p = eap->arg; *p != NUL; ++p) |
7660 { | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
7661 #ifdef FEAT_GUI |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7662 if (*p == CSI) // leadbyte CSI |
7 | 7663 len += 2; |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
7664 #endif |
474 | 7665 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
|
7666 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
|
7667 #ifdef FEAT_GUI |
7 | 7668 || *p == CSI |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
7669 #endif |
7 | 7670 ) |
7671 len += 2; | |
7672 } | |
7673 if (len > 0) | |
7674 { | |
16764
ef00b6bc186b
patch 8.1.1384: using "int" for alloc() often results in compiler warnings
Bram Moolenaar <Bram@vim.org>
parents:
16738
diff
changeset
|
7675 arg = alloc(STRLEN(eap->arg) + len + 1); |
7 | 7676 if (arg != NULL) |
7677 { | |
7678 len = 0; | |
7679 for (p = eap->arg; *p != NUL; ++p) | |
7680 { | |
7681 arg[len++] = *p; | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
7682 #ifdef FEAT_GUI |
7 | 7683 if (*p == CSI) |
7684 { | |
7685 arg[len++] = KS_EXTRA; | |
7686 arg[len++] = (int)KE_CSI; | |
7687 } | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
7688 #endif |
474 | 7689 for (l = (*mb_ptr2len)(p) - 1; l > 0; --l) |
7 | 7690 { |
7691 arg[len++] = *++p; | |
7692 if (*p == K_SPECIAL) | |
7693 { | |
7694 arg[len++] = KS_SPECIAL; | |
7695 arg[len++] = KE_FILLER; | |
7696 } | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
7697 #ifdef FEAT_GUI |
7 | 7698 else if (*p == CSI) |
7699 { | |
7700 arg[len++] = KS_EXTRA; | |
7701 arg[len++] = (int)KE_CSI; | |
7702 } | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
7703 #endif |
7 | 7704 } |
7705 arg[len] = NUL; | |
7706 } | |
7707 } | |
7708 } | |
7709 } | |
7710 | |
12521
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7711 ++ex_normal_busy; |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7712 if (save_current_state(&save_state)) |
7 | 7713 { |
7714 /* | |
7715 * Repeat the :normal command for each line in the range. When no | |
7716 * range given, execute it just once, without positioning the cursor | |
7717 * first. | |
7718 */ | |
7719 do | |
7720 { | |
7721 if (eap->addr_count != 0) | |
7722 { | |
7723 curwin->w_cursor.lnum = eap->line1++; | |
7724 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
|
7725 check_cursor_moved(curwin); |
7 | 7726 } |
7727 | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
7728 exec_normal_cmd(arg != NULL |
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
7729 ? arg |
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
7730 : eap->arg, eap->forceit ? REMAP_NONE : REMAP_YES, FALSE); |
7 | 7731 } |
7732 while (eap->addr_count > 0 && eap->line1 <= eap->line2 && !got_int); | |
7733 } | |
7734 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7735 // Might not return to the main loop when in an event handler. |
7 | 7736 update_topline_cursor(); |
7737 | |
12521
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7738 restore_current_state(&save_state); |
7 | 7739 --ex_normal_busy; |
6322 | 7740 setmouse(); |
7741 #ifdef CURSOR_SHAPE | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7742 ui_cursor_shape(); // may show different cursor shape |
6322 | 7743 #endif |
7744 | |
7 | 7745 vim_free(arg); |
7746 } | |
7747 | |
7748 /* | |
598 | 7749 * ":startinsert", ":startreplace" and ":startgreplace" |
7 | 7750 */ |
7751 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7752 ex_startinsert(exarg_T *eap) |
7 | 7753 { |
98 | 7754 if (eap->forceit) |
7755 { | |
17984
2ea47dee7ddd
patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
7756 // 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
|
7757 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
|
7758 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
|
7759 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
|
7760 } |
20097
165ec447ca77
patch 8.2.0604: :startinsert in a terminal window used later
Bram Moolenaar <Bram@vim.org>
parents:
20079
diff
changeset
|
7761 #ifdef FEAT_TERMINAL |
165ec447ca77
patch 8.2.0604: :startinsert in a terminal window used later
Bram Moolenaar <Bram@vim.org>
parents:
20079
diff
changeset
|
7762 // 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
|
7763 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
|
7764 return; |
165ec447ca77
patch 8.2.0604: :startinsert in a terminal window used later
Bram Moolenaar <Bram@vim.org>
parents:
20079
diff
changeset
|
7765 #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
|
7766 |
2ea47dee7ddd
patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
7767 // 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
|
7768 // expression register that invokes a function can do this. |
89 | 7769 if (State & INSERT) |
7770 return; | |
7771 | |
598 | 7772 if (eap->cmdidx == CMD_startinsert) |
7773 restart_edit = 'a'; | |
7774 else if (eap->cmdidx == CMD_startreplace) | |
7775 restart_edit = 'R'; | |
7 | 7776 else |
598 | 7777 restart_edit = 'V'; |
7778 | |
7779 if (!eap->forceit) | |
7 | 7780 { |
14 | 7781 if (eap->cmdidx == CMD_startinsert) |
7782 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
|
7783 curwin->w_curswant = 0; // avoid MAXCOL |
7 | 7784 } |
7785 } | |
7786 | |
7787 /* | |
7788 * ":stopinsert" | |
7789 */ | |
7790 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7791 ex_stopinsert(exarg_T *eap UNUSED) |
7 | 7792 { |
7793 restart_edit = 0; | |
7794 stop_insert_mode = TRUE; | |
8817
b7eb7bbd71d0
commit https://github.com/vim/vim/commit/fd773e9e88add7d1ffef890fb9f3a00d613b4326
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
7795 clearmode(); |
7 | 7796 } |
7850
10f17a228661
commit https://github.com/vim/vim/commit/e2c3810c2ae290bbc2cba18eb47cc2d44e4b9797
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
7797 |
36 | 7798 /* |
7799 * Execute normal mode command "cmd". | |
7800 * "remap" can be REMAP_NONE or REMAP_YES. | |
7801 */ | |
7802 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7803 exec_normal_cmd(char_u *cmd, int remap, int silent) |
36 | 7804 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7805 // 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
|
7806 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
|
7807 exec_normal(FALSE, FALSE, FALSE); |
7703
39251e981d1f
commit https://github.com/vim/vim/commit/25281634cda03ce302aaf9f906a9520b5f81f91e
Christian Brabandt <cb@256bit.org>
parents:
7549
diff
changeset
|
7808 } |
7850
10f17a228661
commit https://github.com/vim/vim/commit/e2c3810c2ae290bbc2cba18eb47cc2d44e4b9797
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
7809 |
7703
39251e981d1f
commit https://github.com/vim/vim/commit/25281634cda03ce302aaf9f906a9520b5f81f91e
Christian Brabandt <cb@256bit.org>
parents:
7549
diff
changeset
|
7810 /* |
39251e981d1f
commit https://github.com/vim/vim/commit/25281634cda03ce302aaf9f906a9520b5f81f91e
Christian Brabandt <cb@256bit.org>
parents:
7549
diff
changeset
|
7811 * 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
|
7812 * 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
|
7813 */ |
39251e981d1f
commit https://github.com/vim/vim/commit/25281634cda03ce302aaf9f906a9520b5f81f91e
Christian Brabandt <cb@256bit.org>
parents:
7549
diff
changeset
|
7814 void |
14871
f20df682c8af
patch 8.1.0447: GUI scrollbar test fails with Athena and Motif
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
7815 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
|
7816 { |
36 | 7817 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
|
7818 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
|
7819 |
d3377393e3d9
patch 8.1.1136: decoding of mouse click escape sequence is not tested
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
7820 // 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
|
7821 // is nothing to get, so also check for Ctrl_C. |
36 | 7822 clear_oparg(&oa); |
7823 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
|
7824 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
|
7825 || ((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
|
7826 || (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
|
7827 && !got_int) |
36 | 7828 { |
7829 update_topline_cursor(); | |
13829
044337cbf854
patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents:
13802
diff
changeset
|
7830 #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
|
7831 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
|
7832 && 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
|
7833 && !VIsual_active) |
044337cbf854
patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents:
13802
diff
changeset
|
7834 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7835 // 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
|
7836 // 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
|
7837 // 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
|
7838 if (terminal_loop(TRUE) == OK) |
044337cbf854
patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents:
13802
diff
changeset
|
7839 normal_cmd(&oa, TRUE); |
044337cbf854
patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents:
13802
diff
changeset
|
7840 } |
044337cbf854
patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents:
13802
diff
changeset
|
7841 else |
044337cbf854
patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents:
13802
diff
changeset
|
7842 #endif |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7843 // execute a Normal mode cmd |
13829
044337cbf854
patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents:
13802
diff
changeset
|
7844 normal_cmd(&oa, TRUE); |
36 | 7845 } |
7846 } | |
7847 | |
7 | 7848 #ifdef FEAT_FIND_ID |
7849 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7850 ex_checkpath(exarg_T *eap) |
7 | 7851 { |
7852 find_pattern_in_path(NULL, 0, 0, FALSE, FALSE, CHECK_PATH, 1L, | |
7853 eap->forceit ? ACTION_SHOW_ALL : ACTION_SHOW, | |
7854 (linenr_T)1, (linenr_T)MAXLNUM); | |
7855 } | |
7856 | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
7857 #if defined(FEAT_QUICKFIX) |
7 | 7858 /* |
7859 * ":psearch" | |
7860 */ | |
7861 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7862 ex_psearch(exarg_T *eap) |
7 | 7863 { |
7864 g_do_tagpreview = p_pvh; | |
7865 ex_findpat(eap); | |
7866 g_do_tagpreview = 0; | |
7867 } | |
7868 #endif | |
7869 | |
7870 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7871 ex_findpat(exarg_T *eap) |
7 | 7872 { |
7873 int whole = TRUE; | |
7874 long n; | |
7875 char_u *p; | |
7876 int action; | |
7877 | |
7878 switch (cmdnames[eap->cmdidx].cmd_name[2]) | |
7879 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7880 case 'e': // ":psearch", ":isearch" and ":dsearch" |
7 | 7881 if (cmdnames[eap->cmdidx].cmd_name[0] == 'p') |
7882 action = ACTION_GOTO; | |
7883 else | |
7884 action = ACTION_SHOW; | |
7885 break; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7886 case 'i': // ":ilist" and ":dlist" |
7 | 7887 action = ACTION_SHOW_ALL; |
7888 break; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7889 case 'u': // ":ijump" and ":djump" |
7 | 7890 action = ACTION_GOTO; |
7891 break; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7892 default: // ":isplit" and ":dsplit" |
7 | 7893 action = ACTION_SPLIT; |
7894 break; | |
7895 } | |
7896 | |
7897 n = 1; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7898 if (vim_isdigit(*eap->arg)) // get count |
7 | 7899 { |
7900 n = getdigits(&eap->arg); | |
7901 eap->arg = skipwhite(eap->arg); | |
7902 } | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7903 if (*eap->arg == '/') // Match regexp, not just whole words |
7 | 7904 { |
7905 whole = FALSE; | |
7906 ++eap->arg; | |
19892
5feb426d2ea1
patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19685
diff
changeset
|
7907 p = skip_regexp(eap->arg, '/', p_magic); |
7 | 7908 if (*p) |
7909 { | |
7910 *p++ = NUL; | |
7911 p = skipwhite(p); | |
7912 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7913 // 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
|
7914 if (!ends_excmd2(eap->arg, p)) |
7 | 7915 eap->errmsg = e_trailing; |
7916 else | |
7917 eap->nextcmd = check_nextcmd(p); | |
7918 } | |
7919 } | |
7920 if (!eap->skip) | |
7921 find_pattern_in_path(eap->arg, 0, (int)STRLEN(eap->arg), | |
7922 whole, !eap->forceit, | |
7923 *eap->cmd == 'd' ? FIND_DEFINE : FIND_ANY, | |
7924 n, action, eap->line1, eap->line2); | |
7925 } | |
7926 #endif | |
7927 | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
7928 |
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
7929 #ifdef FEAT_QUICKFIX |
7 | 7930 /* |
7931 * ":ptag", ":ptselect", ":ptjump", ":ptnext", etc. | |
7932 */ | |
7933 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7934 ex_ptag(exarg_T *eap) |
7 | 7935 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7936 g_do_tagpreview = p_pvh; // will be reset to 0 in ex_tag_cmd() |
7 | 7937 ex_tag_cmd(eap, cmdnames[eap->cmdidx].cmd_name + 1); |
7938 } | |
7939 | |
7940 /* | |
7941 * ":pedit" | |
7942 */ | |
7943 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7944 ex_pedit(exarg_T *eap) |
7 | 7945 { |
7946 win_T *curwin_save = curwin; | |
7947 | |
19621
0d677257e35d
patch 8.2.0367: can use :pedit in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19575
diff
changeset
|
7948 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
|
7949 return; |
0d677257e35d
patch 8.2.0367: can use :pedit in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19575
diff
changeset
|
7950 |
17746
a4e488a6655c
patch 8.1.1870: using :pedit from a help file sets help filetype
Bram Moolenaar <Bram@vim.org>
parents:
17744
diff
changeset
|
7951 // Open the preview window or popup and make it the current window. |
7 | 7952 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
|
7953 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
|
7954 |
17746
a4e488a6655c
patch 8.1.1870: using :pedit from a help file sets help filetype
Bram Moolenaar <Bram@vim.org>
parents:
17744
diff
changeset
|
7955 // Edit the file. |
7 | 7956 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
|
7957 |
7 | 7958 if (curwin != curwin_save && win_valid(curwin_save)) |
7959 { | |
17746
a4e488a6655c
patch 8.1.1870: using :pedit from a help file sets help filetype
Bram Moolenaar <Bram@vim.org>
parents:
17744
diff
changeset
|
7960 // Return cursor to where we were |
7 | 7961 validate_cursor(); |
7962 redraw_later(VALID); | |
7963 win_enter(curwin_save, TRUE); | |
7964 } | |
18763
49b78d6465e5
patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents:
18715
diff
changeset
|
7965 # 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
|
7966 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
|
7967 { |
daa1dea1c1b3
patch 8.1.1819: :pedit does not work with a popup preview window
Bram Moolenaar <Bram@vim.org>
parents:
17622
diff
changeset
|
7968 // 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
|
7969 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
|
7970 } |
daa1dea1c1b3
patch 8.1.1819: :pedit does not work with a popup preview window
Bram Moolenaar <Bram@vim.org>
parents:
17622
diff
changeset
|
7971 # endif |
7 | 7972 g_do_tagpreview = 0; |
7973 } | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
7974 #endif |
7 | 7975 |
7976 /* | |
7977 * ":stag", ":stselect" and ":stjump". | |
7978 */ | |
7979 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7980 ex_stag(exarg_T *eap) |
7 | 7981 { |
7982 postponed_split = -1; | |
7983 postponed_split_flags = cmdmod.split; | |
1090 | 7984 postponed_split_tab = cmdmod.tab; |
7 | 7985 ex_tag_cmd(eap, cmdnames[eap->cmdidx].cmd_name + 1); |
7986 postponed_split_flags = 0; | |
1090 | 7987 postponed_split_tab = 0; |
7 | 7988 } |
7989 | |
7990 /* | |
7991 * ":tag", ":tselect", ":tjump", ":tnext", etc. | |
7992 */ | |
7993 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7994 ex_tag(exarg_T *eap) |
7 | 7995 { |
7996 ex_tag_cmd(eap, cmdnames[eap->cmdidx].cmd_name); | |
7997 } | |
7998 | |
7999 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8000 ex_tag_cmd(exarg_T *eap, char_u *name) |
7 | 8001 { |
8002 int cmd; | |
8003 | |
8004 switch (name[1]) | |
8005 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8006 case 'j': cmd = DT_JUMP; // ":tjump" |
7 | 8007 break; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8008 case 's': cmd = DT_SELECT; // ":tselect" |
7 | 8009 break; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8010 case 'p': cmd = DT_PREV; // ":tprevious" |
7 | 8011 break; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8012 case 'N': cmd = DT_PREV; // ":tNext" |
7 | 8013 break; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8014 case 'n': cmd = DT_NEXT; // ":tnext" |
7 | 8015 break; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8016 case 'o': cmd = DT_POP; // ":pop" |
7 | 8017 break; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8018 case 'f': // ":tfirst" |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8019 case 'r': cmd = DT_FIRST; // ":trewind" |
7 | 8020 break; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8021 case 'l': cmd = DT_LAST; // ":tlast" |
7 | 8022 break; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8023 default: // ":tag" |
7 | 8024 #ifdef FEAT_CSCOPE |
1603 | 8025 if (p_cst && *eap->arg != NUL) |
7 | 8026 { |
10373
bd674706408a
commit https://github.com/vim/vim/commit/d4db7719bdfbc54df396eac08d8cbb2389feacf4
Christian Brabandt <cb@256bit.org>
parents:
10361
diff
changeset
|
8027 ex_cstag(eap); |
7 | 8028 return; |
8029 } | |
8030 #endif | |
8031 cmd = DT_TAG; | |
8032 break; | |
8033 } | |
8034 | |
649 | 8035 if (name[0] == 'l') |
8036 { | |
8037 #ifndef FEAT_QUICKFIX | |
8038 ex_ni(eap); | |
8039 return; | |
8040 #else | |
8041 cmd = DT_LTAG; | |
8042 #endif | |
8043 } | |
8044 | |
7 | 8045 do_tag(eap->arg, cmd, eap->addr_count > 0 ? (int)eap->line2 : 1, |
8046 eap->forceit, TRUE); | |
8047 } | |
8048 | |
8049 /* | |
1661 | 8050 * Check "str" for starting with a special cmdline variable. |
8051 * If found return one of the SPEC_ values and set "*usedlen" to the length of | |
8052 * the variable. Otherwise return -1 and "*usedlen" is unchanged. | |
8053 */ | |
8054 int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8055 find_cmdline_var(char_u *src, int *usedlen) |
1661 | 8056 { |
8057 int len; | |
8058 int i; | |
1879 | 8059 static char *(spec_str[]) = { |
1661 | 8060 "%", |
8061 #define SPEC_PERC 0 | |
8062 "#", | |
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
|
8063 #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
|
8064 "<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
|
8065 #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
|
8066 "<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
|
8067 #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
|
8068 "<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
|
8069 #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
|
8070 "<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
|
8071 #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
|
8072 "<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
|
8073 #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
|
8074 "<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
|
8075 #define SPEC_SLNUM (SPEC_SFILE + 1) |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8076 "<afile>", // autocommand file name |
14700
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14677
diff
changeset
|
8077 #define SPEC_AFILE (SPEC_SLNUM + 1) |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8078 "<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
|
8079 #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
|
8080 "<amatch>", // autocommand match name |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
8081 #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
|
8082 "<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
|
8083 #define SPEC_SFLNUM (SPEC_AMATCH + 1) |
1661 | 8084 #ifdef FEAT_CLIENTSERVER |
8085 "<client>" | |
14700
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14677
diff
changeset
|
8086 # define SPEC_CLIENT (SPEC_SFLNUM + 1) |
1661 | 8087 #endif |
8088 }; | |
1872 | 8089 |
8090 for (i = 0; i < (int)(sizeof(spec_str) / sizeof(char *)); ++i) | |
1661 | 8091 { |
8092 len = (int)STRLEN(spec_str[i]); | |
8093 if (STRNCMP(src, spec_str[i], len) == 0) | |
8094 { | |
8095 *usedlen = len; | |
8096 return i; | |
8097 } | |
8098 } | |
8099 return -1; | |
8100 } | |
8101 | |
8102 /* | |
7 | 8103 * Evaluate cmdline variables. |
8104 * | |
8105 * change '%' to curbuf->b_ffname | |
8106 * '#' to curwin->w_altfile | |
8107 * '<cword>' to word under the cursor | |
8108 * '<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
|
8109 * '<cexpr>' to C-expression under the cursor |
7 | 8110 * '<cfile>' to path name under the cursor |
8111 * '<sfile>' to sourced file name | |
2645 | 8112 * '<slnum>' to sourced file line number |
7 | 8113 * '<afile>' to file name for autocommand |
8114 * '<abuf>' to buffer number for autocommand | |
8115 * '<amatch>' to matching name for autocommand | |
8116 * | |
8117 * When an error is detected, "errormsg" is set to a non-NULL pointer (may be | |
8118 * "" for error without a message) and NULL is returned. | |
8119 * Returns an allocated string if a valid match was found. | |
8120 * Returns NULL if no match was found. "usedlen" then still contains the | |
8121 * number of characters to skip. | |
8122 */ | |
8123 char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8124 eval_vars( |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8125 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
|
8126 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
|
8127 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
|
8128 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
|
8129 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
|
8130 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
|
8131 // be NULL) |
7 | 8132 { |
8133 int i; | |
8134 char_u *s; | |
8135 char_u *result; | |
8136 char_u *resultbuf = NULL; | |
8137 int resultlen; | |
8138 buf_T *buf; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8139 int valid = VALID_HEAD + VALID_PATH; // assume valid result |
7 | 8140 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
|
8141 int tilde_file = FALSE; |
7 | 8142 int skip_mod = FALSE; |
8143 char_u strbuf[30]; | |
8144 | |
8145 *errormsg = NULL; | |
1098 | 8146 if (escaped != NULL) |
8147 *escaped = FALSE; | |
7 | 8148 |
8149 /* | |
8150 * Check if there is something to do. | |
8151 */ | |
1661 | 8152 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
|
8153 if (spec_idx < 0) // no match |
7 | 8154 { |
8155 *usedlen = 1; | |
8156 return NULL; | |
8157 } | |
8158 | |
8159 /* | |
8160 * Skip when preceded with a backslash "\%" and "\#". | |
8161 * Note: In "\\%" the % is also not recognized! | |
8162 */ | |
8163 if (src > srcstart && src[-1] == '\\') | |
8164 { | |
8165 *usedlen = 0; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8166 STRMOVE(src - 1, src); // remove backslash |
7 | 8167 return NULL; |
8168 } | |
8169 | |
8170 /* | |
8171 * word or WORD under cursor | |
8172 */ | |
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
|
8173 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
|
8174 || 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
|
8175 { |
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
|
8176 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
|
8177 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
|
8178 : 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
|
8179 : FIND_STRING); |
7 | 8180 if (resultlen == 0) |
8181 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8182 *errormsg = ""; |
7 | 8183 return NULL; |
8184 } | |
8185 } | |
8186 | |
8187 /* | |
8188 * '#': Alternate file name | |
8189 * '%': Current file name | |
8190 * File name under the cursor | |
8191 * File name for autocommand | |
8192 * and following modifiers | |
8193 */ | |
8194 else | |
8195 { | |
8196 switch (spec_idx) | |
8197 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8198 case SPEC_PERC: // '%': current file |
7 | 8199 if (curbuf->b_fname == NULL) |
8200 { | |
8201 result = (char_u *)""; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8202 valid = 0; // Must have ":p:h" to be valid |
7 | 8203 } |
8204 else | |
14393
c62601adad69
patch 8.1.0211: expanding a file name "~" results in $HOME
Christian Brabandt <cb@256bit.org>
parents:
14286
diff
changeset
|
8205 { |
7 | 8206 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
|
8207 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
|
8208 } |
7 | 8209 break; |
8210 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8211 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
|
8212 if (src[1] == '#') // "##": the argument list |
7 | 8213 { |
8214 result = arg_all(); | |
8215 resultbuf = result; | |
8216 *usedlen = 2; | |
1098 | 8217 if (escaped != NULL) |
8218 *escaped = TRUE; | |
7 | 8219 skip_mod = TRUE; |
8220 break; | |
8221 } | |
8222 s = src + 1; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8223 if (*s == '<') // "#<99" uses v:oldfiles |
1733 | 8224 ++s; |
7 | 8225 i = (int)getdigits(&s); |
12706
9b882316aa63
patch 8.0.1231: expanding file name drops dash
Christian Brabandt <cb@256bit.org>
parents:
12674
diff
changeset
|
8226 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
|
8227 // 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
|
8228 s--; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8229 *usedlen = (int)(s - src); // length of what we expand |
7 | 8230 |
12706
9b882316aa63
patch 8.0.1231: expanding file name drops dash
Christian Brabandt <cb@256bit.org>
parents:
12674
diff
changeset
|
8231 if (src[1] == '<' && i != 0) |
7 | 8232 { |
1733 | 8233 if (*usedlen < 2) |
8234 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8235 // Should we give an error message for #<text? |
1733 | 8236 *usedlen = 1; |
8237 return NULL; | |
8238 } | |
8239 #ifdef FEAT_EVAL | |
8240 result = list_find_str(get_vim_var_list(VV_OLDFILES), | |
8241 (long)i); | |
8242 if (result == NULL) | |
8243 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8244 *errormsg = ""; |
1733 | 8245 return NULL; |
8246 } | |
8247 #else | |
15488
da8b98c008bf
patch 8.1.0752: one more compiler warning for signed/unsigned string
Bram Moolenaar <Bram@vim.org>
parents:
15474
diff
changeset
|
8248 *errormsg = _("E809: #< is not available without the +eval feature"); |
7 | 8249 return NULL; |
1733 | 8250 #endif |
7 | 8251 } |
8252 else | |
1733 | 8253 { |
12706
9b882316aa63
patch 8.0.1231: expanding file name drops dash
Christian Brabandt <cb@256bit.org>
parents:
12674
diff
changeset
|
8254 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
|
8255 *usedlen = 1; |
1733 | 8256 buf = buflist_findnr(i); |
8257 if (buf == NULL) | |
8258 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8259 *errormsg = _("E194: No alternate file name to substitute for '#'"); |
1733 | 8260 return NULL; |
8261 } | |
8262 if (lnump != NULL) | |
8263 *lnump = ECMD_LAST; | |
8264 if (buf->b_fname == NULL) | |
8265 { | |
8266 result = (char_u *)""; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8267 valid = 0; // Must have ":p:h" to be valid |
1733 | 8268 } |
8269 else | |
14393
c62601adad69
patch 8.1.0211: expanding a file name "~" results in $HOME
Christian Brabandt <cb@256bit.org>
parents:
14286
diff
changeset
|
8270 { |
1733 | 8271 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
|
8272 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
|
8273 } |
1733 | 8274 } |
7 | 8275 break; |
8276 | |
8277 #ifdef FEAT_SEARCHPATH | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8278 case SPEC_CFILE: // file name under cursor |
681 | 8279 result = file_name_at_cursor(FNAME_MESS|FNAME_HYP, 1L, NULL); |
7 | 8280 if (result == NULL) |
8281 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8282 *errormsg = ""; |
7 | 8283 return NULL; |
8284 } | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8285 resultbuf = result; // remember allocated string |
7 | 8286 break; |
8287 #endif | |
8288 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8289 case SPEC_AFILE: // file name for autocommand |
7 | 8290 result = autocmd_fname; |
1723 | 8291 if (result != NULL && !autocmd_fname_full) |
8292 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8293 // 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
|
8294 // postponed to avoid a delay when <afile> is not used. |
1723 | 8295 autocmd_fname_full = TRUE; |
8296 result = FullName_save(autocmd_fname, FALSE); | |
8297 vim_free(autocmd_fname); | |
8298 autocmd_fname = result; | |
8299 } | |
7 | 8300 if (result == NULL) |
8301 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8302 *errormsg = _("E495: no autocommand file name to substitute for \"<afile>\""); |
7 | 8303 return NULL; |
8304 } | |
1471 | 8305 result = shorten_fname1(result); |
7 | 8306 break; |
8307 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8308 case SPEC_ABUF: // buffer number for autocommand |
7 | 8309 if (autocmd_bufnr <= 0) |
8310 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8311 *errormsg = _("E496: no autocommand buffer number to substitute for \"<abuf>\""); |
7 | 8312 return NULL; |
8313 } | |
8314 sprintf((char *)strbuf, "%d", autocmd_bufnr); | |
8315 result = strbuf; | |
8316 break; | |
8317 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8318 case SPEC_AMATCH: // match name for autocommand |
7 | 8319 result = autocmd_match; |
8320 if (result == NULL) | |
8321 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8322 *errormsg = _("E497: no autocommand match name to substitute for \"<amatch>\""); |
7 | 8323 return NULL; |
8324 } | |
8325 break; | |
8326 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8327 case SPEC_SFILE: // file name for ":so" command |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18904
diff
changeset
|
8328 result = estack_sfile(); |
7 | 8329 if (result == NULL) |
8330 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8331 *errormsg = _("E498: no :source file name to substitute for \"<sfile>\""); |
7 | 8332 return NULL; |
8333 } | |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18904
diff
changeset
|
8334 resultbuf = result; // remember allocated string |
7 | 8335 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
|
8336 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8337 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
|
8338 if (SOURCING_NAME == NULL || SOURCING_LNUM == 0) |
2645 | 8339 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8340 *errormsg = _("E842: no line number to use for \"<slnum>\""); |
2645 | 8341 return NULL; |
8342 } | |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18904
diff
changeset
|
8343 sprintf((char *)strbuf, "%ld", SOURCING_LNUM); |
2645 | 8344 result = strbuf; |
8345 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
|
8346 |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14677
diff
changeset
|
8347 #ifdef FEAT_EVAL |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8348 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
|
8349 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
|
8350 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8351 *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
|
8352 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
|
8353 } |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14677
diff
changeset
|
8354 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
|
8355 (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
|
8356 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
|
8357 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
|
8358 #endif |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14677
diff
changeset
|
8359 |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14677
diff
changeset
|
8360 #ifdef FEAT_CLIENTSERVER |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8361 case SPEC_CLIENT: // Source of last submitted input |
840 | 8362 sprintf((char *)strbuf, PRINTF_HEX_LONG_U, |
8363 (long_u)clientWindow); | |
7 | 8364 result = strbuf; |
8365 break; | |
8366 #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
|
8367 |
11428
346168f2a6cb
patch 8.0.0598: building with gcc 7.1 yields new warnings
Christian Brabandt <cb@256bit.org>
parents:
11374
diff
changeset
|
8368 default: |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8369 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
|
8370 break; |
7 | 8371 } |
8372 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8373 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
|
8374 if (src[*usedlen] == '<') // remove the file name extension |
7 | 8375 { |
8376 ++*usedlen; | |
8377 if ((s = vim_strrchr(result, '.')) != NULL && s >= gettail(result)) | |
8378 resultlen = (int)(s - result); | |
8379 } | |
8380 else if (!skip_mod) | |
8381 { | |
14393
c62601adad69
patch 8.1.0211: expanding a file name "~" results in $HOME
Christian Brabandt <cb@256bit.org>
parents:
14286
diff
changeset
|
8382 valid |= modify_fname(src, tilde_file, usedlen, &result, &resultbuf, |
7 | 8383 &resultlen); |
8384 if (result == NULL) | |
8385 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8386 *errormsg = ""; |
7 | 8387 return NULL; |
8388 } | |
8389 } | |
8390 } | |
8391 | |
8392 if (resultlen == 0 || valid != VALID_HEAD + VALID_PATH) | |
8393 { | |
8394 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
|
8395 // 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
|
8396 *errormsg = _("E499: Empty file name for '%' or '#', only works with \":p:h\""); |
7 | 8397 else |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8398 *errormsg = _("E500: Evaluates to an empty string"); |
7 | 8399 result = NULL; |
8400 } | |
8401 else | |
8402 result = vim_strnsave(result, resultlen); | |
8403 vim_free(resultbuf); | |
8404 return result; | |
8405 } | |
8406 | |
8407 /* | |
8408 * Expand the <sfile> string in "arg". | |
8409 * | |
8410 * Returns an allocated string, or NULL for any error. | |
8411 */ | |
8412 char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8413 expand_sfile(char_u *arg) |
7 | 8414 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8415 char *errormsg; |
7 | 8416 int len; |
8417 char_u *result; | |
8418 char_u *newres; | |
8419 char_u *repl; | |
8420 int srclen; | |
8421 char_u *p; | |
8422 | |
8423 result = vim_strsave(arg); | |
8424 if (result == NULL) | |
8425 return NULL; | |
8426 | |
8427 for (p = result; *p; ) | |
8428 { | |
8429 if (STRNCMP(p, "<sfile>", 7) != 0) | |
8430 ++p; | |
8431 else | |
8432 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8433 // replace "<sfile>" with the sourced file name, and do ":" stuff |
1098 | 8434 repl = eval_vars(p, result, &srclen, NULL, &errormsg, NULL); |
7 | 8435 if (errormsg != NULL) |
8436 { | |
8437 if (*errormsg) | |
8438 emsg(errormsg); | |
8439 vim_free(result); | |
8440 return NULL; | |
8441 } | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8442 if (repl == NULL) // no match (cannot happen) |
7 | 8443 { |
8444 p += srclen; | |
8445 continue; | |
8446 } | |
8447 len = (int)STRLEN(result) - srclen + (int)STRLEN(repl) + 1; | |
8448 newres = alloc(len); | |
8449 if (newres == NULL) | |
8450 { | |
8451 vim_free(repl); | |
8452 vim_free(result); | |
8453 return NULL; | |
8454 } | |
8455 mch_memmove(newres, result, (size_t)(p - result)); | |
8456 STRCPY(newres + (p - result), repl); | |
8457 len = (int)STRLEN(newres); | |
8458 STRCAT(newres, p + srclen); | |
8459 vim_free(repl); | |
8460 vim_free(result); | |
8461 result = newres; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8462 p = newres + len; // continue after the match |
7 | 8463 } |
8464 } | |
8465 | |
8466 return result; | |
8467 } | |
8468 | |
8469 #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) || defined(PROTO) | |
272 | 8470 /* |
2770 | 8471 * Make a dialog message in "buff[DIALOG_MSG_SIZE]". |
310 | 8472 * "format" must contain "%s". |
272 | 8473 */ |
7 | 8474 void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8475 dialog_msg(char_u *buff, char *format, char_u *fname) |
7 | 8476 { |
8477 if (fname == NULL) | |
8478 fname = (char_u *)_("Untitled"); | |
2770 | 8479 vim_snprintf((char *)buff, DIALOG_MSG_SIZE, format, fname); |
7 | 8480 } |
8481 #endif | |
8482 | |
8483 /* | |
8484 * ":behave {mswin,xterm}" | |
8485 */ | |
8486 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8487 ex_behave(exarg_T *eap) |
7 | 8488 { |
8489 if (STRCMP(eap->arg, "mswin") == 0) | |
8490 { | |
8491 set_option_value((char_u *)"selection", 0L, (char_u *)"exclusive", 0); | |
8492 set_option_value((char_u *)"selectmode", 0L, (char_u *)"mouse,key", 0); | |
8493 set_option_value((char_u *)"mousemodel", 0L, (char_u *)"popup", 0); | |
8494 set_option_value((char_u *)"keymodel", 0L, | |
8495 (char_u *)"startsel,stopsel", 0); | |
8496 } | |
8497 else if (STRCMP(eap->arg, "xterm") == 0) | |
8498 { | |
8499 set_option_value((char_u *)"selection", 0L, (char_u *)"inclusive", 0); | |
8500 set_option_value((char_u *)"selectmode", 0L, (char_u *)"", 0); | |
8501 set_option_value((char_u *)"mousemodel", 0L, (char_u *)"extend", 0); | |
8502 set_option_value((char_u *)"keymodel", 0L, (char_u *)"", 0); | |
8503 } | |
8504 else | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8505 semsg(_(e_invarg2), eap->arg); |
7 | 8506 } |
8507 | |
8508 static int filetype_detect = FALSE; | |
8509 static int filetype_plugin = FALSE; | |
8510 static int filetype_indent = FALSE; | |
8511 | |
8512 /* | |
8513 * ":filetype [plugin] [indent] {on,off,detect}" | |
8514 * on: Load the filetype.vim file to install autocommands for file types. | |
8515 * off: Load the ftoff.vim file to remove all autocommands for file types. | |
8516 * plugin on: load filetype.vim and ftplugin.vim | |
8517 * plugin off: load ftplugof.vim | |
8518 * indent on: load filetype.vim and indent.vim | |
8519 * indent off: load indoff.vim | |
8520 */ | |
8521 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8522 ex_filetype(exarg_T *eap) |
7 | 8523 { |
8524 char_u *arg = eap->arg; | |
8525 int plugin = FALSE; | |
8526 int indent = FALSE; | |
8527 | |
8528 if (*eap->arg == NUL) | |
8529 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8530 // Print current status. |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8531 smsg("filetype detection:%s plugin:%s indent:%s", |
7 | 8532 filetype_detect ? "ON" : "OFF", |
8533 filetype_plugin ? (filetype_detect ? "ON" : "(on)") : "OFF", | |
8534 filetype_indent ? (filetype_detect ? "ON" : "(on)") : "OFF"); | |
8535 return; | |
8536 } | |
8537 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8538 // Accept "plugin" and "indent" in any order. |
7 | 8539 for (;;) |
8540 { | |
8541 if (STRNCMP(arg, "plugin", 6) == 0) | |
8542 { | |
8543 plugin = TRUE; | |
8544 arg = skipwhite(arg + 6); | |
8545 continue; | |
8546 } | |
8547 if (STRNCMP(arg, "indent", 6) == 0) | |
8548 { | |
8549 indent = TRUE; | |
8550 arg = skipwhite(arg + 6); | |
8551 continue; | |
8552 } | |
8553 break; | |
8554 } | |
8555 if (STRCMP(arg, "on") == 0 || STRCMP(arg, "detect") == 0) | |
8556 { | |
8557 if (*arg == 'o' || !filetype_detect) | |
8558 { | |
8524
2f57bbe870ea
commit https://github.com/vim/vim/commit/7f8989dd8a627af2185df381195351a913f3777f
Christian Brabandt <cb@256bit.org>
parents:
8402
diff
changeset
|
8559 source_runtime((char_u *)FILETYPE_FILE, DIP_ALL); |
7 | 8560 filetype_detect = TRUE; |
8561 if (plugin) | |
8562 { | |
8524
2f57bbe870ea
commit https://github.com/vim/vim/commit/7f8989dd8a627af2185df381195351a913f3777f
Christian Brabandt <cb@256bit.org>
parents:
8402
diff
changeset
|
8563 source_runtime((char_u *)FTPLUGIN_FILE, DIP_ALL); |
7 | 8564 filetype_plugin = TRUE; |
8565 } | |
8566 if (indent) | |
8567 { | |
8524
2f57bbe870ea
commit https://github.com/vim/vim/commit/7f8989dd8a627af2185df381195351a913f3777f
Christian Brabandt <cb@256bit.org>
parents:
8402
diff
changeset
|
8568 source_runtime((char_u *)INDENT_FILE, DIP_ALL); |
7 | 8569 filetype_indent = TRUE; |
8570 } | |
8571 } | |
8572 if (*arg == 'd') | |
8573 { | |
9260
ac8180818504
commit https://github.com/vim/vim/commit/1610d052413e0ed664498853a47acc2d677a22d1
Christian Brabandt <cb@256bit.org>
parents:
9230
diff
changeset
|
8574 (void)do_doautocmd((char_u *)"filetypedetect BufRead", TRUE, NULL); |
717 | 8575 do_modelines(0); |
7 | 8576 } |
8577 } | |
8578 else if (STRCMP(arg, "off") == 0) | |
8579 { | |
8580 if (plugin || indent) | |
8581 { | |
8582 if (plugin) | |
8583 { | |
8524
2f57bbe870ea
commit https://github.com/vim/vim/commit/7f8989dd8a627af2185df381195351a913f3777f
Christian Brabandt <cb@256bit.org>
parents:
8402
diff
changeset
|
8584 source_runtime((char_u *)FTPLUGOF_FILE, DIP_ALL); |
7 | 8585 filetype_plugin = FALSE; |
8586 } | |
8587 if (indent) | |
8588 { | |
8524
2f57bbe870ea
commit https://github.com/vim/vim/commit/7f8989dd8a627af2185df381195351a913f3777f
Christian Brabandt <cb@256bit.org>
parents:
8402
diff
changeset
|
8589 source_runtime((char_u *)INDOFF_FILE, DIP_ALL); |
7 | 8590 filetype_indent = FALSE; |
8591 } | |
8592 } | |
8593 else | |
8594 { | |
8524
2f57bbe870ea
commit https://github.com/vim/vim/commit/7f8989dd8a627af2185df381195351a913f3777f
Christian Brabandt <cb@256bit.org>
parents:
8402
diff
changeset
|
8595 source_runtime((char_u *)FTOFF_FILE, DIP_ALL); |
7 | 8596 filetype_detect = FALSE; |
8597 } | |
8598 } | |
8599 else | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8600 semsg(_(e_invarg2), arg); |
7 | 8601 } |
8602 | |
8603 /* | |
11459
561b76ed9d12
patch 8.0.0613: the conf filetype is used before ftdetect from packages
Christian Brabandt <cb@256bit.org>
parents:
11428
diff
changeset
|
8604 * ":setfiletype [FALLBACK] {name}" |
7 | 8605 */ |
8606 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8607 ex_setfiletype(exarg_T *eap) |
7 | 8608 { |
8609 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
|
8610 { |
561b76ed9d12
patch 8.0.0613: the conf filetype is used before ftdetect from packages
Christian Brabandt <cb@256bit.org>
parents:
11428
diff
changeset
|
8611 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
|
8612 |
561b76ed9d12
patch 8.0.0613: the conf filetype is used before ftdetect from packages
Christian Brabandt <cb@256bit.org>
parents:
11428
diff
changeset
|
8613 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
|
8614 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
|
8615 |
561b76ed9d12
patch 8.0.0613: the conf filetype is used before ftdetect from packages
Christian Brabandt <cb@256bit.org>
parents:
11428
diff
changeset
|
8616 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
|
8617 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
|
8618 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
|
8619 } |
7 | 8620 } |
8621 | |
8622 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8623 ex_digraphs(exarg_T *eap UNUSED) |
7 | 8624 { |
8625 #ifdef FEAT_DIGRAPHS | |
8626 if (*eap->arg != NUL) | |
8627 putdigraph(eap->arg); | |
8628 else | |
15152
1ef429366fd4
patch 8.1.0586: :digraph output is not easy to read
Bram Moolenaar <Bram@vim.org>
parents:
15125
diff
changeset
|
8629 listdigraphs(eap->forceit); |
7 | 8630 #else |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8631 emsg(_("E196: No digraphs in this version")); |
7 | 8632 #endif |
8633 } | |
8634 | |
13792
0e9b2971d7c3
patch 8.0.1768: SET_NO_HLSEARCH() used in a wrong way
Christian Brabandt <cb@256bit.org>
parents:
13581
diff
changeset
|
8635 #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
|
8636 void |
0e9b2971d7c3
patch 8.0.1768: SET_NO_HLSEARCH() used in a wrong way
Christian Brabandt <cb@256bit.org>
parents:
13581
diff
changeset
|
8637 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
|
8638 { |
0e9b2971d7c3
patch 8.0.1768: SET_NO_HLSEARCH() used in a wrong way
Christian Brabandt <cb@256bit.org>
parents:
13581
diff
changeset
|
8639 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
|
8640 # 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
|
8641 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
|
8642 # endif |
0e9b2971d7c3
patch 8.0.1768: SET_NO_HLSEARCH() used in a wrong way
Christian Brabandt <cb@256bit.org>
parents:
13581
diff
changeset
|
8643 } |
0e9b2971d7c3
patch 8.0.1768: SET_NO_HLSEARCH() used in a wrong way
Christian Brabandt <cb@256bit.org>
parents:
13581
diff
changeset
|
8644 |
7 | 8645 /* |
8646 * ":nohlsearch" | |
8647 */ | |
8648 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8649 ex_nohlsearch(exarg_T *eap UNUSED) |
7 | 8650 { |
13792
0e9b2971d7c3
patch 8.0.1768: SET_NO_HLSEARCH() used in a wrong way
Christian Brabandt <cb@256bit.org>
parents:
13581
diff
changeset
|
8651 set_no_hlsearch(TRUE); |
737 | 8652 redraw_all_later(SOME_VALID); |
7 | 8653 } |
8654 #endif | |
8655 | |
8656 #ifdef FEAT_CRYPT | |
8657 /* | |
8658 * ":X": Get crypt key | |
8659 */ | |
8660 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8661 ex_X(exarg_T *eap UNUSED) |
7 | 8662 { |
6353 | 8663 crypt_check_current_method(); |
6122 | 8664 (void)crypt_get_key(TRUE, TRUE); |
7 | 8665 } |
8666 #endif | |
8667 | |
8668 #ifdef FEAT_FOLDING | |
8669 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8670 ex_fold(exarg_T *eap) |
7 | 8671 { |
8672 if (foldManualAllowed(TRUE)) | |
8673 foldCreate(eap->line1, eap->line2); | |
8674 } | |
8675 | |
8676 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8677 ex_foldopen(exarg_T *eap) |
7 | 8678 { |
8679 opFoldRange(eap->line1, eap->line2, eap->cmdidx == CMD_foldopen, | |
8680 eap->forceit, FALSE); | |
8681 } | |
8682 | |
8683 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8684 ex_folddo(exarg_T *eap) |
7 | 8685 { |
8686 linenr_T lnum; | |
8687 | |
18297
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
8688 # ifdef FEAT_CLIPBOARD |
6116 | 8689 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
|
8690 # endif |
6116 | 8691 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8692 // First set the marks for all lines closed/open. |
7 | 8693 for (lnum = eap->line1; lnum <= eap->line2; ++lnum) |
8694 if (hasFolding(lnum, NULL, NULL) == (eap->cmdidx == CMD_folddoclosed)) | |
8695 ml_setmarked(lnum); | |
8696 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8697 // Execute the command on the marked lines. |
7 | 8698 global_exe(eap->arg); |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8699 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
|
8700 # ifdef FEAT_CLIPBOARD |
6116 | 8701 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
|
8702 # endif |
6116 | 8703 } |
8704 #endif | |
12459
937356f8f8d6
patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents:
12457
diff
changeset
|
8705 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
8706 #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
|
8707 /* |
60b9b6196644
patch 8.1.0288: quickfix code uses cmdidx too often
Christian Brabandt <cb@256bit.org>
parents:
14538
diff
changeset
|
8708 * 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
|
8709 * 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
|
8710 */ |
60b9b6196644
patch 8.1.0288: quickfix code uses cmdidx too often
Christian Brabandt <cb@256bit.org>
parents:
14538
diff
changeset
|
8711 int |
60b9b6196644
patch 8.1.0288: quickfix code uses cmdidx too often
Christian Brabandt <cb@256bit.org>
parents:
14538
diff
changeset
|
8712 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
|
8713 { |
14621
89cc3e7ecb68
patch 8.1.0324: off-by-one error in cmdidx check
Christian Brabandt <cb@256bit.org>
parents:
14591
diff
changeset
|
8714 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
|
8715 return FALSE; |
60b9b6196644
patch 8.1.0288: quickfix code uses cmdidx too often
Christian Brabandt <cb@256bit.org>
parents:
14538
diff
changeset
|
8716 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
|
8717 } |
60b9b6196644
patch 8.1.0288: quickfix code uses cmdidx too often
Christian Brabandt <cb@256bit.org>
parents:
14538
diff
changeset
|
8718 #endif |
60b9b6196644
patch 8.1.0288: quickfix code uses cmdidx too often
Christian Brabandt <cb@256bit.org>
parents:
14538
diff
changeset
|
8719 |
18297
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
8720 #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
|
8721 int |
937356f8f8d6
patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents:
12457
diff
changeset
|
8722 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
|
8723 { |
937356f8f8d6
patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents:
12457
diff
changeset
|
8724 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
|
8725 } |
937356f8f8d6
patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents:
12457
diff
changeset
|
8726 |
937356f8f8d6
patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents:
12457
diff
changeset
|
8727 void |
937356f8f8d6
patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents:
12457
diff
changeset
|
8728 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
|
8729 { |
937356f8f8d6
patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents:
12457
diff
changeset
|
8730 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
|
8731 } |
937356f8f8d6
patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents:
12457
diff
changeset
|
8732 #endif |