Mercurial > vim
annotate src/ex_docmd.c @ 21212:874a28fac941 v8.2.1157
patch 8.2.1157: Vim9: dict.name is not recognized as an expression
Commit: https://github.com/vim/vim/commit/0a47e0970a0e5d99aa7089169e0bcca0401decce
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Jul 8 18:30:06 2020 +0200
patch 8.2.1157: Vim9: dict.name is not recognized as an expression
Problem: Vim9: dict.name is not recognized as an expression.
Solution: Recognize ".name". (closes https://github.com/vim/vim/issues/6418)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 08 Jul 2020 18:45:07 +0200 |
parents | 96ae8622cfb6 |
children | 4be91a7eafb2 |
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 |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
28 static void append_command(char_u *cmd); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
29 |
7 | 30 #ifndef FEAT_MENU |
31 # define ex_emenu ex_ni | |
32 # define ex_menu ex_ni | |
33 # define ex_menutranslate ex_ni | |
34 #endif | |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
35 static void ex_autocmd(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
36 static void ex_doautocmd(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
37 static void ex_bunload(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
38 static void ex_buffer(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
39 static void ex_bmodified(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
40 static void ex_bnext(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
41 static void ex_bprevious(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
42 static void ex_brewind(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
43 static void ex_blast(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
44 static char_u *getargcmd(char_u **); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
45 static int getargopt(exarg_T *eap); |
7 | 46 #ifndef FEAT_QUICKFIX |
47 # define ex_make ex_ni | |
41 | 48 # define ex_cbuffer ex_ni |
7 | 49 # define ex_cc ex_ni |
50 # define ex_cnext ex_ni | |
16505
28e3ba82d8c8
patch 8.1.1256: cannot navigate through errors relative to the cursor
Bram Moolenaar <Bram@vim.org>
parents:
16479
diff
changeset
|
51 # define ex_cbelow ex_ni |
7 | 52 # define ex_cfile ex_ni |
53 # define qf_list ex_ni | |
54 # define qf_age ex_ni | |
9538
26da1efa9e46
commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
55 # define qf_history ex_ni |
7 | 56 # define ex_helpgrep ex_ni |
41 | 57 # define ex_vimgrep ex_ni |
7 | 58 #endif |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
59 #if !defined(FEAT_QUICKFIX) |
7 | 60 # define ex_cclose ex_ni |
61 # define ex_copen ex_ni | |
62 # define ex_cwindow ex_ni | |
9432
abb72f0b9e06
commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents:
9284
diff
changeset
|
63 # define ex_cbottom ex_ni |
7 | 64 #endif |
532 | 65 #if !defined(FEAT_QUICKFIX) || !defined(FEAT_EVAL) |
66 # define ex_cexpr ex_ni | |
67 #endif | |
7 | 68 |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
69 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
|
70 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
|
71 #if !defined(FEAT_PERL) \ |
aee7e1e5e0ce
Build problem when using all interfaces except Lua.
Bram Moolenaar <bram@vim.org>
parents:
2330
diff
changeset
|
72 || !defined(FEAT_PYTHON) || !defined(FEAT_PYTHON3) \ |
aee7e1e5e0ce
Build problem when using all interfaces except Lua.
Bram Moolenaar <bram@vim.org>
parents:
2330
diff
changeset
|
73 || !defined(FEAT_TCL) \ |
aee7e1e5e0ce
Build problem when using all interfaces except Lua.
Bram Moolenaar <bram@vim.org>
parents:
2330
diff
changeset
|
74 || !defined(FEAT_RUBY) \ |
aee7e1e5e0ce
Build problem when using all interfaces except Lua.
Bram Moolenaar <bram@vim.org>
parents:
2330
diff
changeset
|
75 || !defined(FEAT_LUA) \ |
aee7e1e5e0ce
Build problem when using all interfaces except Lua.
Bram Moolenaar <bram@vim.org>
parents:
2330
diff
changeset
|
76 || !defined(FEAT_MZSCHEME) |
1315 | 77 # define HAVE_EX_SCRIPT_NI |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
78 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
|
79 #endif |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
80 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
|
81 static void correct_range(exarg_T *eap); |
344 | 82 #ifdef FEAT_QUICKFIX |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
83 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
|
84 #endif |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
85 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
|
86 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
|
87 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
|
88 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
|
89 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
|
90 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
|
91 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
|
92 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
|
93 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
|
94 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
|
95 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
|
96 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
|
97 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
|
98 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
|
99 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
|
100 #if defined(FEAT_QUICKFIX) |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
101 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
|
102 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
|
103 static void ex_pedit(exarg_T *eap); |
7 | 104 #else |
105 # define ex_pclose ex_ni | |
106 # define ex_ptag ex_ni | |
107 # define ex_pedit ex_ni | |
108 #endif | |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
109 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
|
110 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
|
111 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
|
112 static void ex_print(exarg_T *eap); |
7 | 113 #ifdef FEAT_BYTEOFF |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
114 static void ex_goto(exarg_T *eap); |
7 | 115 #else |
116 # define ex_goto ex_ni | |
117 #endif | |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
118 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
|
119 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
|
120 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
|
121 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
|
122 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
|
123 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
|
124 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
|
125 static void ex_edit(exarg_T *eap); |
7 | 126 #ifndef FEAT_GUI |
127 # define ex_gui ex_nogui | |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
128 static void ex_nogui(exarg_T *eap); |
7 | 129 #endif |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15866
diff
changeset
|
130 #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
|
131 static void ex_tearoff(exarg_T *eap); |
7 | 132 #else |
133 # define ex_tearoff ex_ni | |
134 #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
|
135 #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
|
136 || 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
|
137 static void ex_popup(exarg_T *eap); |
7 | 138 #else |
139 # define ex_popup ex_ni | |
140 #endif | |
141 #ifndef FEAT_GUI_MSWIN | |
142 # define ex_simalt ex_ni | |
143 #endif | |
573 | 144 #if !defined(FEAT_GUI_MSWIN) && !defined(FEAT_GUI_GTK) && !defined(FEAT_GUI_MOTIF) |
7 | 145 # define gui_mch_find_dialog ex_ni |
146 # define gui_mch_replace_dialog ex_ni | |
147 #endif | |
573 | 148 #if !defined(FEAT_GUI_GTK) |
7 | 149 # define ex_helpfind ex_ni |
150 #endif | |
151 #ifndef FEAT_CSCOPE | |
10373
bd674706408a
commit https://github.com/vim/vim/commit/d4db7719bdfbc54df396eac08d8cbb2389feacf4
Christian Brabandt <cb@256bit.org>
parents:
10361
diff
changeset
|
152 # define ex_cscope ex_ni |
bd674706408a
commit https://github.com/vim/vim/commit/d4db7719bdfbc54df396eac08d8cbb2389feacf4
Christian Brabandt <cb@256bit.org>
parents:
10361
diff
changeset
|
153 # define ex_scscope ex_ni |
bd674706408a
commit https://github.com/vim/vim/commit/d4db7719bdfbc54df396eac08d8cbb2389feacf4
Christian Brabandt <cb@256bit.org>
parents:
10361
diff
changeset
|
154 # define ex_cstag ex_ni |
7 | 155 #endif |
156 #ifndef FEAT_SYN_HL | |
157 # define ex_syntax ex_ni | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2238
diff
changeset
|
158 # define ex_ownsyntax ex_ni |
737 | 159 #endif |
4766
ec24ff78a79c
updated for version 7.3.1130
Bram Moolenaar <bram@vim.org>
parents:
4764
diff
changeset
|
160 #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
|
161 # define ex_syntime ex_ni |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4710
diff
changeset
|
162 #endif |
737 | 163 #ifndef FEAT_SPELL |
310 | 164 # define ex_spell ex_ni |
236 | 165 # define ex_mkspell ex_ni |
351 | 166 # define ex_spelldump ex_ni |
714 | 167 # define ex_spellinfo ex_ni |
372 | 168 # define ex_spellrepall ex_ni |
236 | 169 #endif |
2214
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
170 #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
|
171 # 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
|
172 # 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
|
173 #endif |
2320
966a5609669e
Added Lua interfae. (Luis Carvalho)
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
174 #ifndef FEAT_LUA |
966a5609669e
Added Lua interfae. (Luis Carvalho)
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
175 # define ex_lua ex_script_ni |
966a5609669e
Added Lua interfae. (Luis Carvalho)
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
176 # define ex_luado ex_ni |
966a5609669e
Added Lua interfae. (Luis Carvalho)
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
177 # define ex_luafile ex_ni |
966a5609669e
Added Lua interfae. (Luis Carvalho)
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
178 #endif |
14 | 179 #ifndef FEAT_MZSCHEME |
180 # define ex_mzscheme ex_script_ni | |
181 # define ex_mzfile ex_ni | |
182 #endif | |
7 | 183 #ifndef FEAT_PERL |
184 # define ex_perl ex_script_ni | |
185 # define ex_perldo ex_ni | |
186 #endif | |
187 #ifndef FEAT_PYTHON | |
188 # define ex_python ex_script_ni | |
4435 | 189 # define ex_pydo ex_ni |
7 | 190 # define ex_pyfile ex_ni |
191 #endif | |
2329
ad2889f48843
Added support for Python 3. (Roland Puntaier)
Bram Moolenaar <bram@vim.org>
parents:
2320
diff
changeset
|
192 #ifndef FEAT_PYTHON3 |
2350
06feaf4fe36a
Rename some "python3" symbols to "py3", as the command name.
Bram Moolenaar <bram@vim.org>
parents:
2340
diff
changeset
|
193 # define ex_py3 ex_script_ni |
4417 | 194 # define ex_py3do ex_ni |
2329
ad2889f48843
Added support for Python 3. (Roland Puntaier)
Bram Moolenaar <bram@vim.org>
parents:
2320
diff
changeset
|
195 # define ex_py3file ex_ni |
ad2889f48843
Added support for Python 3. (Roland Puntaier)
Bram Moolenaar <bram@vim.org>
parents:
2320
diff
changeset
|
196 #endif |
10722
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10656
diff
changeset
|
197 #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
|
198 # 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
|
199 # 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
|
200 # 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
|
201 #endif |
7 | 202 #ifndef FEAT_TCL |
203 # define ex_tcl ex_script_ni | |
204 # define ex_tcldo ex_ni | |
205 # define ex_tclfile ex_ni | |
206 #endif | |
207 #ifndef FEAT_RUBY | |
208 # define ex_ruby ex_script_ni | |
209 # define ex_rubydo ex_ni | |
210 # define ex_rubyfile ex_ni | |
211 #endif | |
212 #ifndef FEAT_KEYMAP | |
213 # define ex_loadkeymap ex_ni | |
214 #endif | |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
215 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
|
216 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
|
217 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
|
218 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
|
219 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
|
220 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
|
221 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
|
222 static void ex_wincmd(exarg_T *eap); |
11 | 223 #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
|
224 static void ex_winpos(exarg_T *eap); |
7 | 225 #else |
226 # define ex_winpos ex_ni | |
227 #endif | |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
228 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
|
229 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
|
230 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
|
231 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
|
232 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
|
233 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
|
234 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
|
235 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
|
236 #ifdef FEAT_PERSISTENT_UNDO |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
237 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
|
238 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
|
239 #endif |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
240 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
|
241 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
|
242 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
|
243 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
|
244 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
|
245 static void close_redir(void); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
246 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
|
247 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
|
248 static void ex_stopinsert(exarg_T *eap); |
7 | 249 #ifdef FEAT_FIND_ID |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
250 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
|
251 static void ex_findpat(exarg_T *eap); |
7 | 252 #else |
253 # define ex_findpat ex_ni | |
254 # define ex_checkpath ex_ni | |
255 #endif | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
256 #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
|
257 static void ex_psearch(exarg_T *eap); |
7 | 258 #else |
259 # define ex_psearch ex_ni | |
260 #endif | |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
261 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
|
262 static void ex_tag_cmd(exarg_T *eap, char_u *name); |
7 | 263 #ifndef FEAT_EVAL |
17622
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
264 # define ex_break ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
265 # define ex_breakadd ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
266 # define ex_breakdel ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
267 # define ex_breaklist ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
268 # define ex_call ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
269 # define ex_catch ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
270 # define ex_compiler ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
271 # define ex_continue ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
272 # define ex_debug ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
273 # 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
|
274 # 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
|
275 # 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
|
276 # define ex_delfunction ex_ni |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
277 # define ex_disassemble ex_ni |
7 | 278 # define ex_echo ex_ni |
279 # define ex_echohl ex_ni | |
17622
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
280 # define ex_else ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
281 # define ex_endfunction ex_ni |
7 | 282 # define ex_endif ex_ni |
17622
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
283 # define ex_endtry ex_ni |
7 | 284 # define ex_endwhile ex_ni |
17622
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
285 # define ex_eval ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
286 # define ex_execute ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
287 # define ex_finally ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
288 # define ex_finish ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
289 # define ex_function ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
290 # define ex_if ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
291 # define ex_let ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
292 # define ex_lockvar ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
293 # define ex_oldfiles ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
294 # define ex_options ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
295 # define ex_packadd ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
296 # define ex_packloadall ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
297 # define ex_return ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
298 # define ex_scriptnames ex_ni |
7 | 299 # define ex_throw ex_ni |
300 # define ex_try ex_ni | |
301 # define ex_unlet ex_ni | |
146 | 302 # define ex_unlockvar ex_ni |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
303 # define ex_vim9script ex_ni |
17622
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
304 # define ex_while ex_ni |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
305 # define ex_import ex_ni |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
306 # define ex_export ex_ni |
7 | 307 #endif |
17536
e00d12c085a5
patch 8.1.1766: code for writing session file is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17496
diff
changeset
|
308 #ifndef FEAT_SESSION |
7 | 309 # define ex_loadview ex_ni |
310 #endif | |
17458
cfdef48743ed
patch 8.1.1727: code for viminfo support is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17431
diff
changeset
|
311 #ifndef FEAT_VIMINFO |
7 | 312 # define ex_viminfo ex_ni |
313 #endif | |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
314 static void ex_behave(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
315 static void ex_filetype(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
316 static void ex_setfiletype(exarg_T *eap); |
7 | 317 #ifndef FEAT_DIFF |
16 | 318 # define ex_diffoff ex_ni |
7 | 319 # define ex_diffpatch ex_ni |
320 # define ex_diffgetput ex_ni | |
321 # define ex_diffsplit ex_ni | |
322 # define ex_diffthis ex_ni | |
323 # define ex_diffupdate ex_ni | |
324 #endif | |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
325 static void ex_digraphs(exarg_T *eap); |
7 | 326 #ifdef FEAT_SEARCH_EXTRA |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
327 static void ex_nohlsearch(exarg_T *eap); |
7 | 328 #else |
329 # define ex_nohlsearch ex_ni | |
330 # define ex_match ex_ni | |
331 #endif | |
332 #ifdef FEAT_CRYPT | |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
333 static void ex_X(exarg_T *eap); |
7 | 334 #else |
335 # define ex_X ex_ni | |
336 #endif | |
337 #ifdef FEAT_FOLDING | |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
338 static void ex_fold(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
339 static void ex_foldopen(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
340 static void ex_folddo(exarg_T *eap); |
7 | 341 #else |
342 # define ex_fold ex_ni | |
343 # define ex_foldopen ex_ni | |
344 # define ex_folddo ex_ni | |
345 #endif | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
346 #if !(defined(HAVE_LOCALE_H) || defined(X_LOCALE)) |
7 | 347 # define ex_language ex_ni |
348 #endif | |
349 #ifndef FEAT_SIGNS | |
350 # define ex_sign ex_ni | |
351 #endif | |
33 | 352 #ifndef FEAT_NETBEANS_INTG |
2210 | 353 # define ex_nbclose ex_ni |
33 | 354 # define ex_nbkey ex_ni |
2210 | 355 # define ex_nbstart ex_ni |
33 | 356 #endif |
7 | 357 |
358 #ifndef FEAT_JUMPLIST | |
359 # define ex_jumps ex_ni | |
9284
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
9260
diff
changeset
|
360 # define ex_clearjumps ex_ni |
7 | 361 # define ex_changes ex_ni |
362 #endif | |
363 | |
170 | 364 #ifndef FEAT_PROFILE |
365 # define ex_profile ex_ni | |
366 #endif | |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
11547
diff
changeset
|
367 #ifndef FEAT_TERMINAL |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
11547
diff
changeset
|
368 # define ex_terminal ex_ni |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
11547
diff
changeset
|
369 #endif |
16608
0422b14bce58
patch 8.1.1307: cannot reconnect to the X server after it restarted
Bram Moolenaar <Bram@vim.org>
parents:
16576
diff
changeset
|
370 #if !defined(FEAT_X11) || !defined(FEAT_XCLIPBOARD) |
0422b14bce58
patch 8.1.1307: cannot reconnect to the X server after it restarted
Bram Moolenaar <Bram@vim.org>
parents:
16576
diff
changeset
|
371 # define ex_xrestore ex_ni |
0422b14bce58
patch 8.1.1307: cannot reconnect to the X server after it restarted
Bram Moolenaar <Bram@vim.org>
parents:
16576
diff
changeset
|
372 #endif |
18763
49b78d6465e5
patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents:
18715
diff
changeset
|
373 #if !defined(FEAT_PROP_POPUP) |
16780
491c01280a5d
patch 8.1.1392: build failure in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
374 # define ex_popupclear ex_ni |
491c01280a5d
patch 8.1.1392: build failure in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
375 #endif |
170 | 376 |
7 | 377 /* |
378 * Declare cmdnames[]. | |
379 */ | |
380 #define DO_DECLARE_EXCMD | |
381 #include "ex_cmds.h" | |
11374
889da8649221
patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents:
11258
diff
changeset
|
382 #include "ex_cmdidxs.h" |
11236
62c96fee518e
patch 8.0.0504: looking up an Ex command is a bit slow
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
383 |
7 | 384 static char_u dollar_command[2] = {'$', 0}; |
385 | |
386 | |
387 #ifdef FEAT_EVAL | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
388 // Struct for storing a line inside a while/for loop |
7 | 389 typedef struct |
390 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
391 char_u *line; // command line |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
392 linenr_T lnum; // sourcing_lnum of the line |
7 | 393 } wcmd_T; |
394 | |
395 /* | |
72 | 396 * Structure used to store info for line position in a while or for loop. |
7 | 397 * This is required, because do_one_cmd() may invoke ex_function(), which |
72 | 398 * reads more lines that may come from the while/for loop. |
399 */ | |
400 struct loop_cookie | |
7 | 401 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
402 garray_T *lines_gap; // growarray with line info |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
403 int current_line; // last read line from growarray |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
404 int repeating; // TRUE when looping a second time |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
405 // When "repeating" is FALSE use "getline" and "cookie" to get lines |
17178
40c4cb095d53
patch 8.1.1588: in :let-heredoc line continuation is recognized
Bram Moolenaar <Bram@vim.org>
parents:
17111
diff
changeset
|
406 char_u *(*getline)(int, void *, int, int); |
7 | 407 void *cookie; |
408 }; | |
409 | |
17178
40c4cb095d53
patch 8.1.1588: in :let-heredoc line continuation is recognized
Bram Moolenaar <Bram@vim.org>
parents:
17111
diff
changeset
|
410 static char_u *get_loop_line(int c, void *cookie, int indent, int do_concat); |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
411 static int store_loop_line(garray_T *gap, char_u *line); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
412 static void free_cmdlines(garray_T *gap); |
8 | 413 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
414 // Struct to save a few things while debugging. Used in do_cmdline() only. |
8 | 415 struct dbg_stuff |
416 { | |
417 int trylevel; | |
418 int force_abort; | |
419 except_T *caught_stack; | |
420 char_u *vv_exception; | |
421 char_u *vv_throwpoint; | |
422 int did_emsg; | |
423 int got_int; | |
424 int did_throw; | |
425 int need_rethrow; | |
426 int check_cstack; | |
427 except_T *current_exception; | |
428 }; | |
429 | |
430 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
431 save_dbg_stuff(struct dbg_stuff *dsp) |
8 | 432 { |
433 dsp->trylevel = trylevel; trylevel = 0; | |
434 dsp->force_abort = force_abort; force_abort = FALSE; | |
435 dsp->caught_stack = caught_stack; caught_stack = NULL; | |
436 dsp->vv_exception = v_exception(NULL); | |
437 dsp->vv_throwpoint = v_throwpoint(NULL); | |
438 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
439 // Necessary for debugging an inactive ":catch", ":finally", ":endtry" |
8 | 440 dsp->did_emsg = did_emsg; did_emsg = FALSE; |
441 dsp->got_int = got_int; got_int = FALSE; | |
442 dsp->did_throw = did_throw; did_throw = FALSE; | |
443 dsp->need_rethrow = need_rethrow; need_rethrow = FALSE; | |
444 dsp->check_cstack = check_cstack; check_cstack = FALSE; | |
445 dsp->current_exception = current_exception; current_exception = NULL; | |
446 } | |
447 | |
448 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
449 restore_dbg_stuff(struct dbg_stuff *dsp) |
8 | 450 { |
451 suppress_errthrow = FALSE; | |
452 trylevel = dsp->trylevel; | |
453 force_abort = dsp->force_abort; | |
454 caught_stack = dsp->caught_stack; | |
455 (void)v_exception(dsp->vv_exception); | |
456 (void)v_throwpoint(dsp->vv_throwpoint); | |
457 did_emsg = dsp->did_emsg; | |
458 got_int = dsp->got_int; | |
459 did_throw = dsp->did_throw; | |
460 need_rethrow = dsp->need_rethrow; | |
461 check_cstack = dsp->check_cstack; | |
462 current_exception = dsp->current_exception; | |
463 } | |
7 | 464 #endif |
465 | |
466 /* | |
467 * do_exmode(): Repeatedly get commands for the "Ex" mode, until the ":vi" | |
468 * command is given. | |
469 */ | |
470 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
471 do_exmode( |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
472 int improved) // TRUE for "improved Ex" mode |
7 | 473 { |
474 int save_msg_scroll; | |
475 int prev_msg_row; | |
476 linenr_T prev_line; | |
10889
5780bd3a5a7e
patch 8.0.0334: can't access b:changedtick from a dict reference
Christian Brabandt <cb@256bit.org>
parents:
10875
diff
changeset
|
477 varnumber_T changedtick; |
167 | 478 |
479 if (improved) | |
480 exmode_active = EXMODE_VIM; | |
481 else | |
482 exmode_active = EXMODE_NORMAL; | |
483 State = NORMAL; | |
484 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
485 // When using ":global /pat/ visual" and then "Q" we return to continue |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
486 // the :global command. |
167 | 487 if (global_busy) |
488 return; | |
7 | 489 |
490 save_msg_scroll = msg_scroll; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
491 ++RedrawingDisabled; // don't redisplay the window |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
492 ++no_wait_return; // don't wait for return |
7 | 493 #ifdef FEAT_GUI |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
494 // Ignore scrollbar and mouse events in Ex mode |
7 | 495 ++hold_gui_events; |
496 #endif | |
497 | |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15510
diff
changeset
|
498 msg(_("Entering Ex mode. Type \"visual\" to go to Normal mode.")); |
7 | 499 while (exmode_active) |
500 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
501 // Check for a ":normal" command and no more characters left. |
161 | 502 if (ex_normal_busy > 0 && typebuf.tb_len == 0) |
503 { | |
504 exmode_active = FALSE; | |
505 break; | |
506 } | |
7 | 507 msg_scroll = TRUE; |
508 need_wait_return = FALSE; | |
509 ex_pressedreturn = FALSE; | |
510 ex_no_reprint = FALSE; | |
10952
835604f3c37a
patch 8.0.0365: might free a dict item that wasn't allocated
Christian Brabandt <cb@256bit.org>
parents:
10889
diff
changeset
|
511 changedtick = CHANGEDTICK(curbuf); |
7 | 512 prev_msg_row = msg_row; |
513 prev_line = curwin->w_cursor.lnum; | |
514 if (improved) | |
515 { | |
516 cmdline_row = msg_row; | |
517 do_cmdline(NULL, getexline, NULL, 0); | |
518 } | |
519 else | |
520 do_cmdline(NULL, getexmodeline, NULL, DOCMD_NOWAIT); | |
521 lines_left = Rows - 1; | |
522 | |
167 | 523 if ((prev_line != curwin->w_cursor.lnum |
10952
835604f3c37a
patch 8.0.0365: might free a dict item that wasn't allocated
Christian Brabandt <cb@256bit.org>
parents:
10889
diff
changeset
|
524 || changedtick != CHANGEDTICK(curbuf)) && !ex_no_reprint) |
167 | 525 { |
526 if (curbuf->b_ml.ml_flags & ML_EMPTY) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
527 emsg(_(e_emptybuf)); |
167 | 528 else |
529 { | |
530 if (ex_pressedreturn) | |
531 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
532 // go up one line, to overwrite the ":<CR>" line, so the |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
533 // output doesn't contain empty lines. |
167 | 534 msg_row = prev_msg_row; |
535 if (prev_msg_row == Rows - 1) | |
536 msg_row--; | |
537 } | |
538 msg_col = 0; | |
539 print_line_no_prefix(curwin->w_cursor.lnum, FALSE, FALSE); | |
540 msg_clr_eos(); | |
541 } | |
542 } | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
543 else if (ex_pressedreturn && !ex_no_reprint) // must be at EOF |
167 | 544 { |
545 if (curbuf->b_ml.ml_flags & ML_EMPTY) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
546 emsg(_(e_emptybuf)); |
167 | 547 else |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
548 emsg(_("E501: At end-of-file")); |
167 | 549 } |
7 | 550 } |
551 | |
552 #ifdef FEAT_GUI | |
553 --hold_gui_events; | |
554 #endif | |
555 --RedrawingDisabled; | |
556 --no_wait_return; | |
557 update_screen(CLEAR); | |
558 need_wait_return = FALSE; | |
559 msg_scroll = save_msg_scroll; | |
560 } | |
561 | |
562 /* | |
18297
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
563 * Print the executed command for when 'verbose' is set. |
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
564 * When "lnum" is 0 only print the command. |
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
565 */ |
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
566 static void |
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
567 msg_verbose_cmd(linenr_T lnum, char_u *cmd) |
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
568 { |
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
569 ++no_wait_return; |
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
570 verbose_enter_scroll(); |
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
571 |
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
572 if (lnum == 0) |
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
573 smsg(_("Executing: %s"), cmd); |
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
574 else |
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
575 smsg(_("line %ld: %s"), (long)lnum, cmd); |
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
576 if (msg_silent == 0) |
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
577 msg_puts("\n"); // don't overwrite this |
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
578 |
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
579 verbose_leave_scroll(); |
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
580 --no_wait_return; |
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
581 } |
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
582 |
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
583 /* |
7 | 584 * Execute a simple command line. Used for translated commands like "*". |
585 */ | |
586 int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
587 do_cmdline_cmd(char_u *cmd) |
7 | 588 { |
589 return do_cmdline(cmd, NULL, NULL, | |
590 DOCMD_VERBOSE|DOCMD_NOWAIT|DOCMD_KEYTYPED); | |
591 } | |
592 | |
593 /* | |
594 * do_cmdline(): execute one Ex command line | |
595 * | |
596 * 1. Execute "cmdline" when it is not NULL. | |
2635 | 597 * If "cmdline" is NULL, or more lines are needed, fgetline() is used. |
7 | 598 * 2. Split up in parts separated with '|'. |
599 * | |
600 * This function can be called recursively! | |
601 * | |
602 * flags: | |
603 * DOCMD_VERBOSE - The command will be included in the error message. | |
604 * DOCMD_NOWAIT - Don't call wait_return() and friends. | |
2635 | 605 * DOCMD_REPEAT - Repeat execution until fgetline() returns NULL. |
7 | 606 * DOCMD_KEYTYPED - Don't reset KeyTyped. |
607 * DOCMD_EXCRESET - Reset the exception environment (used for debugging). | |
608 * DOCMD_KEEPLINE - Store first typed line (for repeating with "."). | |
609 * | |
610 * return FAIL if cmdline could not be executed, OK otherwise | |
611 */ | |
612 int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
613 do_cmdline( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
614 char_u *cmdline, |
17178
40c4cb095d53
patch 8.1.1588: in :let-heredoc line continuation is recognized
Bram Moolenaar <Bram@vim.org>
parents:
17111
diff
changeset
|
615 char_u *(*fgetline)(int, void *, int, int), |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
616 void *cookie, // argument for fgetline() |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
617 int flags) |
7 | 618 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
619 char_u *next_cmdline; // next cmd to execute |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
620 char_u *cmdline_copy = NULL; // copy of cmd line |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
621 int used_getline = FALSE; // used "fgetline" to obtain command |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
622 static int recursive = 0; // recursive depth |
7 | 623 int msg_didout_before_start = 0; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
624 int count = 0; // line number count |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
625 int did_inc = FALSE; // incremented RedrawingDisabled |
7 | 626 int retval = OK; |
627 #ifdef FEAT_EVAL | |
18904
2bdc2e1f6e1f
patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents:
18849
diff
changeset
|
628 cstack_T cstack; // conditional stack |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
629 garray_T lines_ga; // keep lines for ":while"/":for" |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
630 int current_line = 0; // active line in lines_ga |
21056
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
631 int current_line_before = 0; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
632 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
|
633 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
|
634 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
|
635 struct dbg_stuff debug_saved; // saved things for debug mode |
7 | 636 int initial_trylevel; |
20538
9f921ba86d05
patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents:
20536
diff
changeset
|
637 msglist_T **saved_msg_list = NULL; |
9f921ba86d05
patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents:
20536
diff
changeset
|
638 msglist_T *private_msg_list; |
7 | 639 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
640 // "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
|
641 char_u *(*cmd_getline)(int, void *, int, int); |
7 | 642 void *cmd_cookie; |
72 | 643 struct loop_cookie cmd_loop_cookie; |
7 | 644 void *real_cookie; |
170 | 645 int getline_is_func; |
7 | 646 #else |
2635 | 647 # define cmd_getline fgetline |
7 | 648 # define cmd_cookie cookie |
649 #endif | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
650 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
|
651 #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
|
652 ESTACK_CHECK_DECLARATION |
7 | 653 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
654 // 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
|
655 // 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
|
656 // 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
|
657 // 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
|
658 // 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
|
659 // BufWritePost autocommands are executed after a write error. |
7 | 660 saved_msg_list = msg_list; |
661 msg_list = &private_msg_list; | |
662 private_msg_list = NULL; | |
663 #endif | |
664 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
665 // 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
|
666 // 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
|
667 // 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
|
668 if (call_depth >= 200 |
8f2191b56d52
commit https://github.com/vim/vim/commit/b094ff4b2be4d8b7364c566a1cc7e27aa4452a50
Christian Brabandt <cb@256bit.org>
parents:
10488
diff
changeset
|
669 #ifdef FEAT_EVAL |
8f2191b56d52
commit https://github.com/vim/vim/commit/b094ff4b2be4d8b7364c566a1cc7e27aa4452a50
Christian Brabandt <cb@256bit.org>
parents:
10488
diff
changeset
|
670 && call_depth >= p_mfd |
8f2191b56d52
commit https://github.com/vim/vim/commit/b094ff4b2be4d8b7364c566a1cc7e27aa4452a50
Christian Brabandt <cb@256bit.org>
parents:
10488
diff
changeset
|
671 #endif |
8f2191b56d52
commit https://github.com/vim/vim/commit/b094ff4b2be4d8b7364c566a1cc7e27aa4452a50
Christian Brabandt <cb@256bit.org>
parents:
10488
diff
changeset
|
672 ) |
7 | 673 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
674 emsg(_("E169: Command too recursive")); |
7 | 675 #ifdef FEAT_EVAL |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
676 // 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
|
677 // 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
|
678 do_errthrow((cstack_T *)NULL, (char_u *)NULL); |
7 | 679 msg_list = saved_msg_list; |
680 #endif | |
681 return FAIL; | |
682 } | |
683 ++call_depth; | |
684 | |
685 #ifdef FEAT_EVAL | |
686 cstack.cs_idx = -1; | |
72 | 687 cstack.cs_looplevel = 0; |
7 | 688 cstack.cs_trylevel = 0; |
689 cstack.cs_emsg_silent_list = NULL; | |
72 | 690 cstack.cs_lflags = 0; |
7 | 691 ga_init2(&lines_ga, (int)sizeof(wcmd_T), 10); |
692 | |
2635 | 693 real_cookie = getline_cookie(fgetline, cookie); |
7 | 694 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
695 // Inside a function use a higher nesting level. |
2635 | 696 getline_is_func = getline_equal(fgetline, cookie, get_func_line); |
170 | 697 if (getline_is_func && ex_nesting_level == func_level(real_cookie)) |
7 | 698 ++ex_nesting_level; |
699 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
700 // 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
|
701 // line and the debug tick for a function or script are stored. |
170 | 702 if (getline_is_func) |
7 | 703 { |
704 fname = func_name(real_cookie); | |
705 breakpoint = func_breakpoint(real_cookie); | |
706 dbg_tick = func_dbg_tick(real_cookie); | |
707 } | |
2635 | 708 else if (getline_equal(fgetline, cookie, getsourceline)) |
7 | 709 { |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18904
diff
changeset
|
710 fname = SOURCING_NAME; |
7 | 711 breakpoint = source_breakpoint(real_cookie); |
712 dbg_tick = source_dbg_tick(real_cookie); | |
713 } | |
714 | |
715 /* | |
716 * Initialize "force_abort" and "suppress_errthrow" at the top level. | |
717 */ | |
718 if (!recursive) | |
719 { | |
720 force_abort = FALSE; | |
721 suppress_errthrow = FALSE; | |
722 } | |
723 | |
724 /* | |
725 * If requested, store and reset the global values controlling the | |
944 | 726 * exception handling (used when debugging). Otherwise clear it to avoid |
727 * a bogus compiler warning when the optimizer uses inline functions... | |
7 | 728 */ |
878 | 729 if (flags & DOCMD_EXCRESET) |
8 | 730 save_dbg_stuff(&debug_saved); |
944 | 731 else |
20007
aadd1cae2ff5
patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
732 CLEAR_FIELD(debug_saved); |
7 | 733 |
734 initial_trylevel = trylevel; | |
735 | |
736 /* | |
737 * "did_throw" will be set to TRUE when an exception is being thrown. | |
738 */ | |
739 did_throw = FALSE; | |
740 #endif | |
741 /* | |
742 * "did_emsg" will be set to TRUE when emsg() is used, in which case we | |
72 | 743 * cancel the whole command line, and any if/endif or loop. |
7 | 744 * If force_abort is set, we cancel everything. |
745 */ | |
746 did_emsg = FALSE; | |
747 | |
748 /* | |
749 * KeyTyped is only set when calling vgetc(). Reset it here when not | |
750 * calling vgetc() (sourced command lines). | |
751 */ | |
2635 | 752 if (!(flags & DOCMD_KEYTYPED) |
753 && !getline_equal(fgetline, cookie, getexline)) | |
7 | 754 KeyTyped = FALSE; |
755 | |
756 /* | |
757 * Continue executing command lines: | |
72 | 758 * - when inside an ":if", ":while" or ":for" |
7 | 759 * - for multiple commands on one line, separated with '|' |
760 * - when repeating until there are no more lines (for ":source") | |
761 */ | |
762 next_cmdline = cmdline; | |
763 do | |
764 { | |
170 | 765 #ifdef FEAT_EVAL |
2635 | 766 getline_is_func = getline_equal(fgetline, cookie, get_func_line); |
170 | 767 #endif |
768 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
769 // stop skipping cmds for an error msg after all endif/while/for |
7 | 770 if (next_cmdline == NULL |
771 #ifdef FEAT_EVAL | |
772 && !force_abort | |
773 && cstack.cs_idx < 0 | |
170 | 774 && !(getline_is_func && func_has_abort(real_cookie)) |
7 | 775 #endif |
776 ) | |
777 did_emsg = FALSE; | |
778 | |
779 /* | |
72 | 780 * 1. If repeating a line in a loop, get a line from lines_ga. |
2635 | 781 * 2. If no line given: Get an allocated line with fgetline(). |
7 | 782 * 3. If a line is given: Make a copy, so we can mess with it. |
783 */ | |
784 | |
785 #ifdef FEAT_EVAL | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
786 // 1. If repeating, get a previous line from lines_ga. |
72 | 787 if (cstack.cs_looplevel > 0 && current_line < lines_ga.ga_len) |
7 | 788 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
789 // 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
|
790 // 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
|
791 VIM_CLEAR(cmdline_copy); |
7 | 792 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
793 // 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
|
794 // try conditional, aborted. |
170 | 795 if (getline_is_func) |
796 { | |
797 # ifdef FEAT_PROFILE | |
788 | 798 if (do_profiling == PROF_YES) |
170 | 799 func_line_end(real_cookie); |
800 # endif | |
801 if (func_has_ended(real_cookie)) | |
802 { | |
803 retval = FAIL; | |
804 break; | |
805 } | |
806 } | |
807 #ifdef FEAT_PROFILE | |
788 | 808 else if (do_profiling == PROF_YES |
2635 | 809 && getline_equal(fgetline, cookie, getsourceline)) |
170 | 810 script_line_end(); |
811 #endif | |
7 | 812 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
813 // Check if a sourced file hit a ":finish" command. |
2635 | 814 if (source_finished(fgetline, cookie)) |
7 | 815 { |
816 retval = FAIL; | |
817 break; | |
818 } | |
819 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
820 // If breakpoints have been added/deleted need to check for it. |
7 | 821 if (breakpoint != NULL && dbg_tick != NULL |
822 && *dbg_tick != debug_tick) | |
823 { | |
824 *breakpoint = dbg_find_breakpoint( | |
2635 | 825 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
|
826 fname, SOURCING_LNUM); |
7 | 827 *dbg_tick = debug_tick; |
828 } | |
829 | |
830 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
|
831 SOURCING_LNUM = ((wcmd_T *)(lines_ga.ga_data))[current_line].lnum; |
7 | 832 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
833 // Did we encounter a breakpoint? |
7 | 834 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
|
835 && *breakpoint <= SOURCING_LNUM) |
7 | 836 { |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18904
diff
changeset
|
837 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
|
838 // Find next breakpoint. |
7 | 839 *breakpoint = dbg_find_breakpoint( |
2635 | 840 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
|
841 fname, SOURCING_LNUM); |
7 | 842 *dbg_tick = debug_tick; |
843 } | |
170 | 844 # ifdef FEAT_PROFILE |
788 | 845 if (do_profiling == PROF_YES) |
170 | 846 { |
847 if (getline_is_func) | |
848 func_line_start(real_cookie); | |
2635 | 849 else if (getline_equal(fgetline, cookie, getsourceline)) |
170 | 850 script_line_start(); |
851 } | |
852 # endif | |
7 | 853 } |
854 #endif | |
855 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
856 // 2. If no line given, get an allocated line with fgetline(). |
7 | 857 if (next_cmdline == NULL) |
858 { | |
859 /* | |
860 * Need to set msg_didout for the first line after an ":if", | |
861 * otherwise the ":if" will be overwritten. | |
862 */ | |
2635 | 863 if (count == 1 && getline_equal(fgetline, cookie, getexline)) |
7 | 864 msg_didout = TRUE; |
2635 | 865 if (fgetline == NULL || (next_cmdline = fgetline(':', cookie, |
7 | 866 #ifdef FEAT_EVAL |
867 cstack.cs_idx < 0 ? 0 : (cstack.cs_idx + 1) * 2 | |
868 #else | |
869 0 | |
870 #endif | |
17178
40c4cb095d53
patch 8.1.1588: in :let-heredoc line continuation is recognized
Bram Moolenaar <Bram@vim.org>
parents:
17111
diff
changeset
|
871 , TRUE)) == NULL) |
7 | 872 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
873 // 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
|
874 // 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
|
875 // doesn't do this. |
7 | 876 if (KeyTyped && !(flags & DOCMD_REPEAT)) |
877 need_wait_return = FALSE; | |
878 retval = FAIL; | |
879 break; | |
880 } | |
881 used_getline = TRUE; | |
882 | |
883 /* | |
884 * Keep the first typed line. Clear it when more lines are typed. | |
885 */ | |
886 if (flags & DOCMD_KEEPLINE) | |
887 { | |
888 vim_free(repeat_cmdline); | |
889 if (count == 0) | |
890 repeat_cmdline = vim_strsave(next_cmdline); | |
891 else | |
892 repeat_cmdline = NULL; | |
893 } | |
894 } | |
895 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
896 // 3. Make a copy of the command so we can mess with it. |
7 | 897 else if (cmdline_copy == NULL) |
898 { | |
899 next_cmdline = vim_strsave(next_cmdline); | |
900 if (next_cmdline == NULL) | |
901 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
902 emsg(_(e_outofmem)); |
7 | 903 retval = FAIL; |
904 break; | |
905 } | |
906 } | |
907 cmdline_copy = next_cmdline; | |
908 | |
909 #ifdef FEAT_EVAL | |
910 /* | |
21056
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
911 * Inside a while/for loop, and when the command looks like a ":while" |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
912 * or ":for", the line is stored, because we may need it later when |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
913 * looping. |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
914 * |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
915 * When there is a '|' and another command, it is stored separately, |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
916 * because we need to be able to jump back to it from an |
72 | 917 * :endwhile/:endfor. |
21056
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
918 * |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
919 * Pass a different "fgetline" function to do_one_cmd() below, |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
920 * that it stores lines in or reads them from "lines_ga". Makes it |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
921 * possible to define a function inside a while/for loop and handles |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
922 * line continuation. |
7 | 923 */ |
21056
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
924 if ((cstack.cs_looplevel > 0 || has_loop_cmd(next_cmdline))) |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
925 { |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
926 cmd_getline = get_loop_line; |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
927 cmd_cookie = (void *)&cmd_loop_cookie; |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
928 cmd_loop_cookie.lines_gap = &lines_ga; |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
929 cmd_loop_cookie.current_line = current_line; |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
930 cmd_loop_cookie.getline = fgetline; |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
931 cmd_loop_cookie.cookie = cookie; |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
932 cmd_loop_cookie.repeating = (current_line < lines_ga.ga_len); |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
933 |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
934 // Save the current line when encountering it the first time. |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
935 if (current_line == lines_ga.ga_len |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
936 && store_loop_line(&lines_ga, next_cmdline) == FAIL) |
7 | 937 { |
938 retval = FAIL; | |
939 break; | |
940 } | |
21056
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
941 current_line_before = current_line; |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
942 } |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
943 else |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
944 { |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
945 cmd_getline = fgetline; |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
946 cmd_cookie = cookie; |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
947 } |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
948 |
7 | 949 did_endif = FALSE; |
950 #endif | |
951 | |
952 if (count++ == 0) | |
953 { | |
954 /* | |
955 * All output from the commands is put below each other, without | |
956 * waiting for a return. Don't do this when executing commands | |
957 * from a script or when being called recursive (e.g. for ":e | |
958 * +command file"). | |
959 */ | |
960 if (!(flags & DOCMD_NOWAIT) && !recursive) | |
961 { | |
962 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
|
963 msg_didany = FALSE; // no output yet |
7 | 964 msg_start(); |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
965 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
|
966 ++no_wait_return; // don't wait for return until finished |
7 | 967 ++RedrawingDisabled; |
968 did_inc = TRUE; | |
969 } | |
970 } | |
971 | |
20575
501b72481d0a
patch 8.2.0841: 'verbose' value 16 causes duplicate output
Bram Moolenaar <Bram@vim.org>
parents:
20538
diff
changeset
|
972 if ((p_verbose >= 15 && SOURCING_NAME != NULL) || p_verbose >= 16) |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18904
diff
changeset
|
973 msg_verbose_cmd(SOURCING_LNUM, cmdline_copy); |
7 | 974 |
975 /* | |
976 * 2. Execute one '|' separated command. | |
977 * do_one_cmd() will return NULL if there is no trailing '|'. | |
978 * "cmdline_copy" can change, e.g. for '%' and '#' expansion. | |
979 */ | |
980 ++recursive; | |
981 next_cmdline = do_one_cmd(&cmdline_copy, flags & DOCMD_VERBOSE, | |
982 #ifdef FEAT_EVAL | |
983 &cstack, | |
984 #endif | |
985 cmd_getline, cmd_cookie); | |
986 --recursive; | |
987 | |
988 #ifdef FEAT_EVAL | |
72 | 989 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
|
990 // 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
|
991 // incremented when defining a function. |
72 | 992 current_line = cmd_loop_cookie.current_line; |
7 | 993 #endif |
994 | |
995 if (next_cmdline == NULL) | |
996 { | |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13221
diff
changeset
|
997 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
|
998 |
7 | 999 /* |
1000 * If the command was typed, remember it for the ':' register. | |
1001 * Do this AFTER executing the command to make :@: work. | |
1002 */ | |
2635 | 1003 if (getline_equal(fgetline, cookie, getexline) |
7 | 1004 && new_last_cmdline != NULL) |
1005 { | |
1006 vim_free(last_cmdline); | |
1007 last_cmdline = new_last_cmdline; | |
1008 new_last_cmdline = NULL; | |
1009 } | |
1010 } | |
1011 else | |
1012 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1013 // 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
|
1014 // next do_one_cmd() |
1619 | 1015 STRMOVE(cmdline_copy, next_cmdline); |
7 | 1016 next_cmdline = cmdline_copy; |
1017 } | |
1018 | |
1019 | |
1020 #ifdef FEAT_EVAL | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1021 // reset did_emsg for a function that is not aborted by an error |
7 | 1022 if (did_emsg && !force_abort |
2635 | 1023 && getline_equal(fgetline, cookie, get_func_line) |
7 | 1024 && !func_has_abort(real_cookie)) |
1025 did_emsg = FALSE; | |
1026 | |
72 | 1027 if (cstack.cs_looplevel > 0) |
7 | 1028 { |
1029 ++current_line; | |
1030 | |
1031 /* | |
72 | 1032 * An ":endwhile", ":endfor" and ":continue" is handled here. |
1033 * If we were executing commands, jump back to the ":while" or | |
1034 * ":for". | |
1035 * If we were not executing commands, decrement cs_looplevel. | |
7 | 1036 */ |
72 | 1037 if (cstack.cs_lflags & (CSL_HAD_CONT | CSL_HAD_ENDLOOP)) |
1038 { | |
1039 cstack.cs_lflags &= ~(CSL_HAD_CONT | CSL_HAD_ENDLOOP); | |
1040 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1041 // 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
|
1042 // 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
|
1043 // 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
|
1044 // cause a crash. |
7 | 1045 if (!did_emsg && !got_int && !did_throw |
1046 && cstack.cs_idx >= 0 | |
72 | 1047 && (cstack.cs_flags[cstack.cs_idx] |
1048 & (CSF_WHILE | CSF_FOR)) | |
7 | 1049 && cstack.cs_line[cstack.cs_idx] >= 0 |
1050 && (cstack.cs_flags[cstack.cs_idx] & CSF_ACTIVE)) | |
1051 { | |
1052 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
|
1053 // remember we jumped there |
72 | 1054 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
|
1055 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
|
1056 |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1057 // 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
|
1058 // or ":for". |
7 | 1059 if (breakpoint != NULL) |
1060 { | |
1061 *breakpoint = dbg_find_breakpoint( | |
2635 | 1062 getline_equal(fgetline, cookie, getsourceline), |
7 | 1063 fname, |
1064 ((wcmd_T *)lines_ga.ga_data)[current_line].lnum-1); | |
1065 *dbg_tick = debug_tick; | |
1066 } | |
1067 } | |
72 | 1068 else |
7 | 1069 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1070 // can only get here with ":endwhile" or ":endfor" |
7 | 1071 if (cstack.cs_idx >= 0) |
77 | 1072 rewind_conditionals(&cstack, cstack.cs_idx - 1, |
1073 CSF_WHILE | CSF_FOR, &cstack.cs_looplevel); | |
7 | 1074 } |
1075 } | |
1076 | |
1077 /* | |
72 | 1078 * For a ":while" or ":for" we need to remember the line number. |
7 | 1079 */ |
72 | 1080 else if (cstack.cs_lflags & CSL_HAD_LOOP) |
1081 { | |
1082 cstack.cs_lflags &= ~CSL_HAD_LOOP; | |
21056
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1083 cstack.cs_line[cstack.cs_idx] = current_line_before; |
7 | 1084 } |
1085 } | |
1086 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1087 // 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
|
1088 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
|
1089 { |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18904
diff
changeset
|
1090 *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
|
1091 *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
|
1092 } |
69278c25429d
patch 8.0.1505: debugger can't break on a condition
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
1093 |
7 | 1094 /* |
1095 * When not inside any ":while" loop, clear remembered lines. | |
1096 */ | |
72 | 1097 if (cstack.cs_looplevel == 0) |
7 | 1098 { |
1099 if (lines_ga.ga_len > 0) | |
1100 { | |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18904
diff
changeset
|
1101 SOURCING_LNUM = |
7 | 1102 ((wcmd_T *)lines_ga.ga_data)[lines_ga.ga_len - 1].lnum; |
1103 free_cmdlines(&lines_ga); | |
1104 } | |
1105 current_line = 0; | |
1106 } | |
1107 | |
1108 /* | |
72 | 1109 * A ":finally" makes did_emsg, got_int, and did_throw pending for |
1110 * being restored at the ":endtry". Reset them here and set the | |
1111 * ACTIVE and FINALLY flags, so that the finally clause gets executed. | |
1112 * This includes the case where a missing ":endif", ":endwhile" or | |
1113 * ":endfor" was detected by the ":finally" itself. | |
7 | 1114 */ |
72 | 1115 if (cstack.cs_lflags & CSL_HAD_FINA) |
1116 { | |
1117 cstack.cs_lflags &= ~CSL_HAD_FINA; | |
1118 report_make_pending(cstack.cs_pending[cstack.cs_idx] | |
1119 & (CSTP_ERROR | CSTP_INTERRUPT | CSTP_THROW), | |
7 | 1120 did_throw ? (void *)current_exception : NULL); |
1121 did_emsg = got_int = did_throw = FALSE; | |
1122 cstack.cs_flags[cstack.cs_idx] |= CSF_ACTIVE | CSF_FINALLY; | |
1123 } | |
1124 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1125 // 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
|
1126 // within this loop. |
7 | 1127 trylevel = initial_trylevel + cstack.cs_trylevel; |
1128 | |
1129 /* | |
1190 | 1130 * If the outermost try conditional (across function calls and sourced |
7 | 1131 * files) is aborted because of an error, an interrupt, or an uncaught |
1132 * exception, cancel everything. If it is left normally, reset | |
1133 * force_abort to get the non-EH compatible abortion behavior for | |
1134 * the rest of the script. | |
1135 */ | |
1136 if (trylevel == 0 && !did_emsg && !got_int && !did_throw) | |
1137 force_abort = FALSE; | |
1138 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1139 // Convert an interrupt to an exception if appropriate. |
7 | 1140 (void)do_intthrow(&cstack); |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1141 #endif // FEAT_EVAL |
7 | 1142 |
1143 } | |
1144 /* | |
1145 * Continue executing command lines when: | |
1146 * - no CTRL-C typed, no aborting error, no exception thrown or try | |
1147 * conditionals need to be checked for executing finally clauses or | |
1148 * catching an interrupt exception | |
1149 * - didn't get an error message or lines are not typed | |
72 | 1150 * - there is a command after '|', inside a :if, :while, :for or :try, or |
7 | 1151 * looping for ":source" command or function call. |
1152 */ | |
1153 while (!((got_int | |
1154 #ifdef FEAT_EVAL | |
1155 || (did_emsg && force_abort) || did_throw | |
1156 #endif | |
1157 ) | |
1158 #ifdef FEAT_EVAL | |
1159 && cstack.cs_trylevel == 0 | |
1160 #endif | |
1161 ) | |
3757 | 1162 && !(did_emsg |
1163 #ifdef FEAT_EVAL | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1164 // 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
|
1165 // 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
|
1166 // the :endtry to be missed. |
3757 | 1167 && (cstack.cs_trylevel == 0 || did_emsg_syntax) |
1168 #endif | |
1169 && used_getline | |
2635 | 1170 && (getline_equal(fgetline, cookie, getexmodeline) |
1171 || getline_equal(fgetline, cookie, getexline))) | |
7 | 1172 && (next_cmdline != NULL |
1173 #ifdef FEAT_EVAL | |
1174 || cstack.cs_idx >= 0 | |
1175 #endif | |
1176 || (flags & DOCMD_REPEAT))); | |
1177 | |
1178 vim_free(cmdline_copy); | |
3757 | 1179 did_emsg_syntax = FALSE; |
7 | 1180 #ifdef FEAT_EVAL |
1181 free_cmdlines(&lines_ga); | |
1182 ga_clear(&lines_ga); | |
1183 | |
1184 if (cstack.cs_idx >= 0) | |
1185 { | |
1186 /* | |
1187 * If a sourced file or executed function ran to its end, report the | |
1188 * unclosed conditional. | |
1189 */ | |
1190 if (!got_int && !did_throw | |
2635 | 1191 && ((getline_equal(fgetline, cookie, getsourceline) |
1192 && !source_finished(fgetline, cookie)) | |
1193 || (getline_equal(fgetline, cookie, get_func_line) | |
7 | 1194 && !func_has_ended(real_cookie)))) |
1195 { | |
1196 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
|
1197 emsg(_(e_endtry)); |
7 | 1198 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
|
1199 emsg(_(e_endwhile)); |
72 | 1200 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
|
1201 emsg(_(e_endfor)); |
7 | 1202 else |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
1203 emsg(_(e_endif)); |
7 | 1204 } |
1205 | |
1206 /* | |
1207 * Reset "trylevel" in case of a ":finish" or ":return" or a missing | |
1208 * ":endtry" in a sourced file or executed function. If the try | |
1209 * conditional is in its finally clause, ignore anything pending. | |
1210 * If it is in a catch clause, finish the caught exception. | |
77 | 1211 * Also cleanup any "cs_forinfo" structures. |
7 | 1212 */ |
1213 do | |
77 | 1214 { |
1215 int idx = cleanup_conditionals(&cstack, 0, TRUE); | |
1216 | |
111 | 1217 if (idx >= 0) |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1218 --idx; // remove try block not in its finally clause |
77 | 1219 rewind_conditionals(&cstack, idx, CSF_WHILE | CSF_FOR, |
1220 &cstack.cs_looplevel); | |
1221 } | |
1222 while (cstack.cs_idx >= 0); | |
7 | 1223 trylevel = initial_trylevel; |
1224 } | |
1225 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1226 // 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
|
1227 // 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
|
1228 // exception, do this now after rewinding the cstack. |
2635 | 1229 do_errthrow(&cstack, getline_equal(fgetline, cookie, get_func_line) |
7 | 1230 ? (char_u *)"endfunction" : (char_u *)NULL); |
1231 | |
1232 if (trylevel == 0) | |
1233 { | |
1234 /* | |
1235 * When an exception is being thrown out of the outermost try | |
1236 * conditional, discard the uncaught exception, disable the conversion | |
1237 * of interrupts or errors to exceptions, and ensure that no more | |
1238 * commands are executed. | |
1239 */ | |
1240 if (did_throw) | |
1241 { | |
1242 void *p = NULL; | |
20538
9f921ba86d05
patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents:
20536
diff
changeset
|
1243 msglist_T *messages = NULL, *next; |
7 | 1244 |
1245 /* | |
1246 * If the uncaught exception is a user exception, report it as an | |
1247 * error. If it is an error exception, display the saved error | |
1248 * message now. For an interrupt exception, do nothing; the | |
1249 * interrupt message is given elsewhere. | |
1250 */ | |
1251 switch (current_exception->type) | |
1252 { | |
1253 case ET_USER: | |
272 | 1254 vim_snprintf((char *)IObuff, IOSIZE, |
1255 _("E605: Exception not caught: %s"), | |
7 | 1256 current_exception->value); |
1257 p = vim_strsave(IObuff); | |
1258 break; | |
1259 case ET_ERROR: | |
1260 messages = current_exception->messages; | |
1261 current_exception->messages = NULL; | |
1262 break; | |
1263 case ET_INTERRUPT: | |
1264 break; | |
1265 } | |
1266 | |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18904
diff
changeset
|
1267 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
|
1268 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
|
1269 ESTACK_CHECK_SETUP |
7 | 1270 current_exception->throw_name = NULL; |
1271 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1272 discard_current_exception(); // uses IObuff if 'verbose' |
7 | 1273 suppress_errthrow = TRUE; |
1274 force_abort = TRUE; | |
1275 | |
1276 if (messages != NULL) | |
1277 { | |
1278 do | |
1279 { | |
1280 next = messages->next; | |
1281 emsg(messages->msg); | |
1282 vim_free(messages->msg); | |
20659
3437bf2ce2d4
patch 8.2.0883: memory leak in test 49
Bram Moolenaar <Bram@vim.org>
parents:
20645
diff
changeset
|
1283 vim_free(messages->sfile); |
7 | 1284 vim_free(messages); |
1285 messages = next; | |
1286 } | |
1287 while (messages != NULL); | |
1288 } | |
1289 else if (p != NULL) | |
1290 { | |
15490
98c35d312987
patch 8.1.0753: printf format not checked for semsg()
Bram Moolenaar <Bram@vim.org>
parents:
15488
diff
changeset
|
1291 emsg(p); |
7 | 1292 vim_free(p); |
1293 } | |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18904
diff
changeset
|
1294 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
|
1295 ESTACK_CHECK_NOW |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18904
diff
changeset
|
1296 estack_pop(); |
7 | 1297 } |
1298 | |
1299 /* | |
1300 * On an interrupt or an aborting error not converted to an exception, | |
1301 * 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
|
1302 * converted anymore, here.) This enables also the interrupt message |
7 | 1303 * when force_abort is set and did_emsg unset in case of an interrupt |
1304 * from a finally clause after an error. | |
1305 */ | |
1306 else if (got_int || (did_emsg && force_abort)) | |
1307 suppress_errthrow = TRUE; | |
1308 } | |
1309 | |
1310 /* | |
1311 * The current cstack will be freed when do_cmdline() returns. An uncaught | |
1312 * exception will have to be rethrown in the previous cstack. If a function | |
1313 * has just returned or a script file was just finished and the previous | |
1314 * cstack belongs to the same function or, respectively, script file, it | |
1315 * will have to be checked for finally clauses to be executed due to the | |
1316 * ":return" or ":finish". This is done in do_one_cmd(). | |
1317 */ | |
1318 if (did_throw) | |
1319 need_rethrow = TRUE; | |
2635 | 1320 if ((getline_equal(fgetline, cookie, getsourceline) |
7 | 1321 && ex_nesting_level > source_level(real_cookie)) |
2635 | 1322 || (getline_equal(fgetline, cookie, get_func_line) |
7 | 1323 && ex_nesting_level > func_level(real_cookie) + 1)) |
1324 { | |
1325 if (!did_throw) | |
1326 check_cstack = TRUE; | |
1327 } | |
1328 else | |
1329 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1330 // When leaving a function, reduce nesting level. |
2635 | 1331 if (getline_equal(fgetline, cookie, get_func_line)) |
7 | 1332 --ex_nesting_level; |
1333 /* | |
1334 * Go to debug mode when returning from a function in which we are | |
1335 * single-stepping. | |
1336 */ | |
2635 | 1337 if ((getline_equal(fgetline, cookie, getsourceline) |
1338 || getline_equal(fgetline, cookie, get_func_line)) | |
7 | 1339 && ex_nesting_level + 1 <= debug_break_level) |
2635 | 1340 do_debug(getline_equal(fgetline, cookie, getsourceline) |
7 | 1341 ? (char_u *)_("End of sourced file") |
1342 : (char_u *)_("End of function")); | |
1343 } | |
1344 | |
1345 /* | |
1346 * Restore the exception environment (done after returning from the | |
1347 * debugger). | |
1348 */ | |
1349 if (flags & DOCMD_EXCRESET) | |
8 | 1350 restore_dbg_stuff(&debug_saved); |
7 | 1351 |
1352 msg_list = saved_msg_list; | |
19685
d64f403289db
patch 8.2.0399: various memory leaks
Bram Moolenaar <Bram@vim.org>
parents:
19621
diff
changeset
|
1353 |
d64f403289db
patch 8.2.0399: various memory leaks
Bram Moolenaar <Bram@vim.org>
parents:
19621
diff
changeset
|
1354 // Cleanup if "cs_emsg_silent_list" remains. |
d64f403289db
patch 8.2.0399: various memory leaks
Bram Moolenaar <Bram@vim.org>
parents:
19621
diff
changeset
|
1355 if (cstack.cs_emsg_silent_list != NULL) |
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 eslist_T *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 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
|
1360 { |
d64f403289db
patch 8.2.0399: various memory leaks
Bram Moolenaar <Bram@vim.org>
parents:
19621
diff
changeset
|
1361 temp = elem->next; |
d64f403289db
patch 8.2.0399: various memory leaks
Bram Moolenaar <Bram@vim.org>
parents:
19621
diff
changeset
|
1362 vim_free(elem); |
d64f403289db
patch 8.2.0399: various memory leaks
Bram Moolenaar <Bram@vim.org>
parents:
19621
diff
changeset
|
1363 } |
d64f403289db
patch 8.2.0399: various memory leaks
Bram Moolenaar <Bram@vim.org>
parents:
19621
diff
changeset
|
1364 } |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1365 #endif // FEAT_EVAL |
7 | 1366 |
1367 /* | |
1368 * If there was too much output to fit on the command line, ask the user to | |
1369 * hit return before redrawing the screen. With the ":global" command we do | |
1370 * this only once after the command is finished. | |
1371 */ | |
1372 if (did_inc) | |
1373 { | |
1374 --RedrawingDisabled; | |
1375 --no_wait_return; | |
1376 msg_scroll = FALSE; | |
1377 | |
1378 /* | |
1379 * When just finished an ":if"-":else" which was typed, no need to | |
1380 * wait for hit-return. Also for an error situation. | |
1381 */ | |
1382 if (retval == FAIL | |
1383 #ifdef FEAT_EVAL | |
1384 || (did_endif && KeyTyped && !did_emsg) | |
1385 #endif | |
1386 ) | |
1387 { | |
1388 need_wait_return = FALSE; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1389 msg_didany = FALSE; // don't wait when restarting edit |
7 | 1390 } |
1391 else if (need_wait_return) | |
1392 { | |
1393 /* | |
1394 * The msg_start() above clears msg_didout. The wait_return we do | |
1395 * here should not overwrite the command that may be shown before | |
1396 * doing that. | |
1397 */ | |
1398 msg_didout |= msg_didout_before_start; | |
1399 wait_return(FALSE); | |
1400 } | |
1401 } | |
1402 | |
3976 | 1403 #ifdef FEAT_EVAL |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1404 did_endif = FALSE; // in case do_cmdline used recursively |
3976 | 1405 #else |
7 | 1406 /* |
1407 * Reset if_level, in case a sourced script file contains more ":if" than | |
1408 * ":endif" (could be ":if x | foo | endif"). | |
1409 */ | |
1410 if_level = 0; | |
3972 | 1411 #endif |
3963 | 1412 |
7 | 1413 --call_depth; |
1414 return retval; | |
1415 } | |
1416 | |
1417 #ifdef FEAT_EVAL | |
1418 /* | |
72 | 1419 * Obtain a line when inside a ":while" or ":for" loop. |
7 | 1420 */ |
1421 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
|
1422 get_loop_line(int c, void *cookie, int indent, int do_concat) |
7 | 1423 { |
72 | 1424 struct loop_cookie *cp = (struct loop_cookie *)cookie; |
7 | 1425 wcmd_T *wp; |
1426 char_u *line; | |
1427 | |
1428 if (cp->current_line + 1 >= cp->lines_gap->ga_len) | |
1429 { | |
1430 if (cp->repeating) | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1431 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
|
1432 |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1433 // First time inside the ":while"/":for": get line normally. |
7 | 1434 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
|
1435 line = getcmdline(c, 0L, indent, do_concat); |
7 | 1436 else |
17178
40c4cb095d53
patch 8.1.1588: in :let-heredoc line continuation is recognized
Bram Moolenaar <Bram@vim.org>
parents:
17111
diff
changeset
|
1437 line = cp->getline(c, cp->cookie, indent, do_concat); |
857 | 1438 if (line != NULL && store_loop_line(cp->lines_gap, line) == OK) |
7 | 1439 ++cp->current_line; |
1440 | |
1441 return line; | |
1442 } | |
1443 | |
1444 KeyTyped = FALSE; | |
1445 ++cp->current_line; | |
1446 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
|
1447 SOURCING_LNUM = wp->lnum; |
7 | 1448 return vim_strsave(wp->line); |
1449 } | |
1450 | |
1451 /* | |
1452 * Store a line in "gap" so that a ":while" loop can execute it again. | |
1453 */ | |
1454 static int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
1455 store_loop_line(garray_T *gap, char_u *line) |
7 | 1456 { |
1457 if (ga_grow(gap, 1) == FAIL) | |
1458 return FAIL; | |
1459 ((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
|
1460 ((wcmd_T *)(gap->ga_data))[gap->ga_len].lnum = SOURCING_LNUM; |
7 | 1461 ++gap->ga_len; |
1462 return OK; | |
1463 } | |
1464 | |
1465 /* | |
72 | 1466 * Free the lines stored for a ":while" or ":for" loop. |
7 | 1467 */ |
1468 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
1469 free_cmdlines(garray_T *gap) |
7 | 1470 { |
1471 while (gap->ga_len > 0) | |
1472 { | |
1473 vim_free(((wcmd_T *)(gap->ga_data))[gap->ga_len - 1].line); | |
1474 --gap->ga_len; | |
1475 } | |
1476 } | |
1477 #endif | |
1478 | |
1479 /* | |
944 | 1480 * If "fgetline" is get_loop_line(), return TRUE if the getline it uses equals |
1481 * "func". * Otherwise return TRUE when "fgetline" equals "func". | |
7 | 1482 */ |
1483 int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
1484 getline_equal( |
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 *(*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
|
1486 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
|
1487 char_u *(*func)(int, void *, int, int)) |
7 | 1488 { |
1489 #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
|
1490 char_u *(*gp)(int, void *, int, int); |
72 | 1491 struct loop_cookie *cp; |
1492 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1493 // 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
|
1494 // 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
|
1495 // nested several levels. |
944 | 1496 gp = fgetline; |
72 | 1497 cp = (struct loop_cookie *)cookie; |
1498 while (gp == get_loop_line) | |
7 | 1499 { |
1500 gp = cp->getline; | |
1501 cp = cp->cookie; | |
1502 } | |
1503 return gp == func; | |
1504 #else | |
944 | 1505 return fgetline == func; |
7 | 1506 #endif |
1507 } | |
1508 | |
1509 /* | |
944 | 1510 * If "fgetline" is get_loop_line(), return the cookie used by the original |
7 | 1511 * getline function. Otherwise return "cookie". |
1512 */ | |
1513 void * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
1514 getline_cookie( |
17178
40c4cb095d53
patch 8.1.1588: in :let-heredoc line continuation is recognized
Bram Moolenaar <Bram@vim.org>
parents:
17111
diff
changeset
|
1515 char_u *(*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
|
1516 void *cookie) // argument for fgetline() |
7 | 1517 { |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
1518 #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
|
1519 char_u *(*gp)(int, void *, int, int); |
21056
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1520 struct loop_cookie *cp; |
72 | 1521 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1522 // 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
|
1523 // 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
|
1524 // several levels. |
944 | 1525 gp = fgetline; |
72 | 1526 cp = (struct loop_cookie *)cookie; |
1527 while (gp == get_loop_line) | |
7 | 1528 { |
1529 gp = cp->getline; | |
1530 cp = cp->cookie; | |
1531 } | |
1532 return cp; | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
1533 #else |
7 | 1534 return cookie; |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
1535 #endif |
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
1536 } |
7 | 1537 |
21056
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1538 #if defined(FEAT_EVAL) || defined(PROT) |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1539 /* |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1540 * Get the next line source line without advancing. |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1541 */ |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1542 char_u * |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1543 getline_peek( |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1544 char_u *(*fgetline)(int, void *, int, int) UNUSED, |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1545 void *cookie) // argument for fgetline() |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1546 { |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1547 char_u *(*gp)(int, void *, int, int); |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1548 struct loop_cookie *cp; |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1549 wcmd_T *wp; |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1550 |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1551 // When "fgetline" is "get_loop_line()" use the "cookie" to find the |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1552 // cookie that's originally used to obtain the lines. This may be nested |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1553 // several levels. |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1554 gp = fgetline; |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1555 cp = (struct loop_cookie *)cookie; |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1556 while (gp == get_loop_line) |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1557 { |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1558 if (cp->current_line + 1 < cp->lines_gap->ga_len) |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1559 { |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1560 // executing lines a second time, use the stored copy |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1561 wp = (wcmd_T *)(cp->lines_gap->ga_data) + cp->current_line + 1; |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1562 return wp->line; |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1563 } |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1564 gp = cp->getline; |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1565 cp = cp->cookie; |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1566 } |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1567 if (gp == getsourceline) |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1568 return source_nextline(cp); |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1569 return NULL; |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1570 } |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1571 #endif |
a7c202f5cbe9
patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents:
21016
diff
changeset
|
1572 |
6398 | 1573 |
1574 /* | |
1575 * Helper function to apply an offset for buffer commands, i.e. ":bdelete", | |
1576 * ":bwipeout", etc. | |
1577 * Returns the buffer number. | |
1578 */ | |
1579 static int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
1580 compute_buffer_local_count(int addr_type, int lnum, int offset) |
6398 | 1581 { |
1582 buf_T *buf; | |
6417 | 1583 buf_T *nextbuf; |
6398 | 1584 int count = offset; |
1585 | |
1586 buf = firstbuf; | |
1587 while (buf->b_next != NULL && buf->b_fnum < lnum) | |
1588 buf = buf->b_next; | |
1589 while (count != 0) | |
1590 { | |
6417 | 1591 count += (offset < 0) ? 1 : -1; |
1592 nextbuf = (offset < 0) ? buf->b_prev : buf->b_next; | |
1593 if (nextbuf == NULL) | |
6398 | 1594 break; |
6417 | 1595 buf = nextbuf; |
6398 | 1596 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
|
1597 // skip over unloaded buffers |
6417 | 1598 while (buf->b_ml.ml_mfp == NULL) |
1599 { | |
1600 nextbuf = (offset < 0) ? buf->b_prev : buf->b_next; | |
1601 if (nextbuf == NULL) | |
1602 break; | |
1603 buf = nextbuf; | |
1604 } | |
1605 } | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1606 // we might have gone too far, last buffer is not loadedd |
6417 | 1607 if (addr_type == ADDR_LOADED_BUFFERS) |
1608 while (buf->b_ml.ml_mfp == NULL) | |
1609 { | |
1610 nextbuf = (offset >= 0) ? buf->b_prev : buf->b_next; | |
1611 if (nextbuf == NULL) | |
1612 break; | |
1613 buf = nextbuf; | |
1614 } | |
6398 | 1615 return buf->b_fnum; |
1616 } | |
1617 | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
1618 /* |
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
1619 * 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
|
1620 * 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
|
1621 */ |
6409 | 1622 static int |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
1623 current_win_nr(win_T *win) |
6409 | 1624 { |
1625 win_T *wp; | |
1626 int nr = 0; | |
1627 | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9538
diff
changeset
|
1628 FOR_ALL_WINDOWS(wp) |
6409 | 1629 { |
1630 ++nr; | |
1631 if (wp == win) | |
1632 break; | |
1633 } | |
1634 return nr; | |
1635 } | |
1636 | |
1637 static int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
1638 current_tab_nr(tabpage_T *tab) |
6409 | 1639 { |
1640 tabpage_T *tp; | |
1641 int nr = 0; | |
1642 | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9538
diff
changeset
|
1643 FOR_ALL_TABPAGES(tp) |
6409 | 1644 { |
1645 ++nr; | |
1646 if (tp == tab) | |
1647 break; | |
1648 } | |
1649 return nr; | |
1650 } | |
1651 | |
1652 # define CURRENT_WIN_NR current_win_nr(curwin) | |
1653 # define LAST_WIN_NR current_win_nr(NULL) | |
1654 # define CURRENT_TAB_NR current_tab_nr(curtab) | |
1655 # define LAST_TAB_NR current_tab_nr(NULL) | |
6398 | 1656 |
7 | 1657 /* |
1658 * Execute one Ex command. | |
1659 * | |
1660 * If 'sourcing' is TRUE, the command will be included in the error message. | |
1661 * | |
1662 * 1. skip comment lines and leading space | |
1663 * 2. handle command modifiers | |
6400 | 1664 * 3. find the command |
6398 | 1665 * 4. parse range |
6400 | 1666 * 5. Parse the command. |
6398 | 1667 * 6. parse arguments |
1668 * 7. switch on command name | |
7 | 1669 * |
944 | 1670 * Note: "fgetline" can be NULL. |
7 | 1671 * |
1672 * This function may be called recursively! | |
1673 */ | |
1674 #if (_MSC_VER == 1200) | |
1675 /* | |
8 | 1676 * Avoid optimisation bug in VC++ version 6.0 |
7 | 1677 */ |
128 | 1678 #pragma optimize( "g", off ) |
7 | 1679 #endif |
1680 static char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
1681 do_one_cmd( |
18904
2bdc2e1f6e1f
patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents:
18849
diff
changeset
|
1682 char_u **cmdlinep, |
2bdc2e1f6e1f
patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents:
18849
diff
changeset
|
1683 int sourcing, |
7 | 1684 #ifdef FEAT_EVAL |
18904
2bdc2e1f6e1f
patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents:
18849
diff
changeset
|
1685 cstack_T *cstack, |
2bdc2e1f6e1f
patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents:
18849
diff
changeset
|
1686 #endif |
2bdc2e1f6e1f
patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents:
18849
diff
changeset
|
1687 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
|
1688 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
|
1689 { |
2bdc2e1f6e1f
patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents:
18849
diff
changeset
|
1690 char_u *p; |
2bdc2e1f6e1f
patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents:
18849
diff
changeset
|
1691 linenr_T lnum; |
2bdc2e1f6e1f
patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents:
18849
diff
changeset
|
1692 long n; |
2bdc2e1f6e1f
patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents:
18849
diff
changeset
|
1693 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
|
1694 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
|
1695 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
|
1696 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
|
1697 cmdmod_T save_cmdmod; |
2bdc2e1f6e1f
patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents:
18849
diff
changeset
|
1698 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
|
1699 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
|
1700 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
|
1701 #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
|
1702 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
|
1703 #endif |
7 | 1704 |
20007
aadd1cae2ff5
patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
1705 CLEAR_FIELD(ea); |
7 | 1706 ea.line1 = 1; |
1707 ea.line2 = 1; | |
1708 #ifdef FEAT_EVAL | |
1709 ++ex_nesting_level; | |
1710 #endif | |
1711 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1712 // When the last file has not been edited :q has to be typed twice. |
7 | 1713 if (quitmore |
1714 #ifdef FEAT_EVAL | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1715 // avoid that a function call in 'statusline' does this |
944 | 1716 && !getline_equal(fgetline, cookie, get_func_line) |
4133 | 1717 #endif |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1718 // 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
|
1719 && !getline_equal(fgetline, cookie, getnextac)) |
7 | 1720 --quitmore; |
1721 | |
1722 /* | |
1723 * Reset browse, confirm, etc.. They are restored when returning, for | |
1724 * recursive calls. | |
1725 */ | |
1726 save_cmdmod = cmdmod; | |
1727 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1728 // "#!anything" is handled like a comment. |
930 | 1729 if ((*cmdlinep)[0] == '#' && (*cmdlinep)[1] == '!') |
1730 goto doend; | |
1731 | |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
1732 /* |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
1733 * 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
|
1734 * 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
|
1735 */ |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
1736 // The "ea" structure holds the arguments that can be used. |
7 | 1737 ea.cmd = *cmdlinep; |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
1738 ea.cmdlinep = cmdlinep; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
1739 ea.getline = fgetline; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
1740 ea.cookie = cookie; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
1741 #ifdef FEAT_EVAL |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
1742 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
|
1743 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
|
1744 #endif |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
1745 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
|
1746 goto doend; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
1747 |
9941
e975914c17e9
commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
9927
diff
changeset
|
1748 after_modifier = ea.cmd; |
7 | 1749 |
1750 #ifdef FEAT_EVAL | |
1751 ea.skip = did_emsg || got_int || did_throw || (cstack->cs_idx >= 0 | |
1752 && !(cstack->cs_flags[cstack->cs_idx] & CSF_ACTIVE)); | |
1753 #else | |
1754 ea.skip = (if_level > 0); | |
1755 #endif | |
1756 | |
1757 /* | |
6398 | 1758 * 3. Skip over the range to find the command. Let "p" point to after it. |
1759 * | |
1760 * We need the command to know what kind of range it uses. | |
1761 */ | |
1762 cmd = ea.cmd; | |
1763 ea.cmd = skip_range(ea.cmd, NULL); | |
1764 if (*ea.cmd == '*' && vim_strchr(p_cpo, CPO_STAR) == NULL) | |
1765 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
|
1766 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
1767 #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
|
1768 if (current_sctx.sc_version == SCRIPT_VERSION_VIM9 && !starts_with_colon) |
20982
bb49b5090a9c
patch 8.2.1042: Vim9: cannot put an operator on the next line
Bram Moolenaar <Bram@vim.org>
parents:
20897
diff
changeset
|
1769 { |
bb49b5090a9c
patch 8.2.1042: Vim9: cannot put an operator on the next line
Bram Moolenaar <Bram@vim.org>
parents:
20897
diff
changeset
|
1770 if (ea.cmd > cmd) |
bb49b5090a9c
patch 8.2.1042: Vim9: cannot put an operator on the next line
Bram Moolenaar <Bram@vim.org>
parents:
20897
diff
changeset
|
1771 { |
bb49b5090a9c
patch 8.2.1042: Vim9: cannot put an operator on the next line
Bram Moolenaar <Bram@vim.org>
parents:
20897
diff
changeset
|
1772 emsg(_(e_colon_required)); |
bb49b5090a9c
patch 8.2.1042: Vim9: cannot put an operator on the next line
Bram Moolenaar <Bram@vim.org>
parents:
20897
diff
changeset
|
1773 goto doend; |
bb49b5090a9c
patch 8.2.1042: Vim9: cannot put an operator on the next line
Bram Moolenaar <Bram@vim.org>
parents:
20897
diff
changeset
|
1774 } |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
1775 p = find_ex_command(&ea, NULL, lookup_scriptvar, NULL); |
20982
bb49b5090a9c
patch 8.2.1042: Vim9: cannot put an operator on the next line
Bram Moolenaar <Bram@vim.org>
parents:
20897
diff
changeset
|
1776 } |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
1777 else |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
1778 #endif |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
1779 p = find_ex_command(&ea, NULL, NULL, NULL); |
6398 | 1780 |
14591
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1781 #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
|
1782 # 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
|
1783 // 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
|
1784 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
|
1785 && (!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
|
1786 && (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
|
1787 { |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1788 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
|
1789 |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1790 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
|
1791 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
|
1792 && (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
|
1793 && !(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
|
1794 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
|
1795 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
|
1796 && !(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
|
1797 & (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
|
1798 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
|
1799 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
|
1800 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
|
1801 && 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
|
1802 && 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
|
1803 && 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
|
1804 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
|
1805 |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1806 if (!skip) |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1807 { |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1808 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
|
1809 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
|
1810 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
|
1811 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
|
1812 } |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1813 } |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1814 # endif |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1815 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1816 // 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
|
1817 // 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
|
1818 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
|
1819 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
|
1820 { |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1821 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
|
1822 (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
|
1823 } |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1824 #endif |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1825 |
6398 | 1826 /* |
1827 * 4. parse a range specifier of the form: addr [,addr] [;addr] .. | |
7 | 1828 * |
1829 * where 'addr' is: | |
1830 * | |
1831 * % (entire file) | |
1832 * $ [+-NUM] | |
1833 * 'x [+-NUM] (where x denotes a currently defined mark) | |
1834 * . [+-NUM] | |
1835 * [+-NUM].. | |
1836 * NUM | |
1837 * | |
1838 * The ea.cmd pointer is updated to point to the first character following the | |
1839 * range spec. If an initial address is found, but no second, the upper bound | |
1840 * is equal to the lower. | |
1841 */ | |
1842 | |
16515
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
1843 // ea.addr_type for user commands is set by find_ucmd |
6489 | 1844 if (!IS_USER_CMDIDX(ea.cmdidx)) |
1845 { | |
1846 if (ea.cmdidx != CMD_SIZE) | |
1847 ea.addr_type = cmdnames[(int)ea.cmdidx].cmd_addr_type; | |
1848 else | |
1849 ea.addr_type = ADDR_LINES; | |
1850 | |
16515
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
1851 // :wincmd range depends on the argument. |
6506 | 1852 if (ea.cmdidx == CMD_wincmd && p != NULL) |
1853 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
|
1854 #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
|
1855 // :.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
|
1856 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
|
1857 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
|
1858 #endif |
6489 | 1859 } |
6398 | 1860 |
6489 | 1861 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
|
1862 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
|
1863 goto doend; |
7 | 1864 |
1865 /* | |
6398 | 1866 * 5. Parse the command. |
7 | 1867 */ |
1868 | |
1869 /* | |
1870 * Skip ':' and any white space | |
1871 */ | |
1872 ea.cmd = skipwhite(ea.cmd); | |
1873 while (*ea.cmd == ':') | |
1874 ea.cmd = skipwhite(ea.cmd + 1); | |
1875 | |
1876 /* | |
1877 * If we got a line, but no command, then go to the line. | |
1878 * If we find a '|' or '\n' we set ea.nextcmd. | |
1879 */ | |
6398 | 1880 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
|
1881 #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
|
1882 || (*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
|
1883 && !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
|
1884 #endif |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20027
diff
changeset
|
1885 || (ea.nextcmd = check_nextcmd(ea.cmd)) != NULL) |
7 | 1886 { |
1887 /* | |
1888 * strange vi behaviour: | |
1889 * ":3" jumps to line 3 | |
1890 * ":3|..." prints line 3 | |
1891 * ":|" prints current line | |
1892 */ | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1893 if (ea.skip) // skip this if inside :if |
7 | 1894 goto doend; |
167 | 1895 if (*ea.cmd == '|' || (exmode_active && ea.line1 != ea.line2)) |
7 | 1896 { |
1897 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
|
1898 ea.argt = EX_RANGE+EX_COUNT+EX_TRLBAR; |
7 | 1899 if ((errormsg = invalid_range(&ea)) == NULL) |
1900 { | |
1901 correct_range(&ea); | |
1902 ex_print(&ea); | |
1903 } | |
1904 } | |
1905 else if (ea.addr_count != 0) | |
1906 { | |
631 | 1907 if (ea.line2 > curbuf->b_ml.ml_line_count) |
1908 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1909 // 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
|
1910 // error, otherwise put it at the end of the file. |
631 | 1911 if (vim_strchr(p_cpo, CPO_MINUS) != NULL) |
1912 ea.line2 = -1; | |
1913 else | |
1914 ea.line2 = curbuf->b_ml.ml_line_count; | |
1915 } | |
1916 | |
1917 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
|
1918 errormsg = _(e_invrange); |
7 | 1919 else |
1920 { | |
1921 if (ea.line2 == 0) | |
1922 curwin->w_cursor.lnum = 1; | |
1923 else | |
1924 curwin->w_cursor.lnum = ea.line2; | |
1925 beginline(BL_SOL | BL_FIX); | |
1926 } | |
1927 } | |
1928 goto doend; | |
1929 } | |
1930 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1931 // 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
|
1932 // autocommands defined, trigger the matching autocommands. |
6154 | 1933 if (p != NULL && ea.cmdidx == CMD_SIZE && !ea.skip |
1934 && ASCII_ISUPPER(*ea.cmd) | |
1935 && has_cmdundefined()) | |
1936 { | |
1937 int ret; | |
1938 | |
6156 | 1939 p = ea.cmd; |
6154 | 1940 while (ASCII_ISALNUM(*p)) |
1941 ++p; | |
20897
213fb059e02e
patch 8.2.1000: get error when leaving Ex mode with :visual
Bram Moolenaar <Bram@vim.org>
parents:
20711
diff
changeset
|
1942 p = vim_strnsave(ea.cmd, p - ea.cmd); |
6154 | 1943 ret = apply_autocmds(EVENT_CMDUNDEFINED, p, p, TRUE, NULL); |
1944 vim_free(p); | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1945 // 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
|
1946 // finding the command again. |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
1947 p = (ret |
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
1948 #ifdef FEAT_EVAL |
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
1949 && !aborting() |
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
1950 #endif |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
1951 ) ? 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
|
1952 } |
6154 | 1953 |
7 | 1954 if (p == NULL) |
1955 { | |
1956 if (!ea.skip) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
1957 errormsg = _("E464: Ambiguous use of user-defined command"); |
7 | 1958 goto doend; |
1959 } | |
16411
5b5c5daf57de
patch 8.1.1210: support for user commands is spread out
Bram Moolenaar <Bram@vim.org>
parents:
16399
diff
changeset
|
1960 // 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
|
1961 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
|
1962 && !IS_USER_CMDIDX(ea.cmdidx)) |
7 | 1963 { |
1964 errormsg = uc_fun_cmd(); | |
1965 goto doend; | |
1966 } | |
16411
5b5c5daf57de
patch 8.1.1210: support for user commands is spread out
Bram Moolenaar <Bram@vim.org>
parents:
16399
diff
changeset
|
1967 |
7 | 1968 if (ea.cmdidx == CMD_SIZE) |
1969 { | |
1970 if (!ea.skip) | |
1971 { | |
1972 STRCPY(IObuff, _("E492: Not an editor command")); | |
1973 if (!sourcing) | |
9941
e975914c17e9
commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
9927
diff
changeset
|
1974 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1975 // 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
|
1976 // following command |
9941
e975914c17e9
commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
9927
diff
changeset
|
1977 if (after_modifier != NULL) |
e975914c17e9
commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
9927
diff
changeset
|
1978 append_command(after_modifier); |
e975914c17e9
commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
9927
diff
changeset
|
1979 else |
e975914c17e9
commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
9927
diff
changeset
|
1980 append_command(*cmdlinep); |
e975914c17e9
commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
9927
diff
changeset
|
1981 } |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
1982 errormsg = (char *)IObuff; |
3757 | 1983 did_emsg_syntax = TRUE; |
7 | 1984 } |
1985 goto doend; | |
1986 } | |
1987 | |
6305 | 1988 ni = (!IS_USER_CMDIDX(ea.cmdidx) |
1989 && (cmdnames[ea.cmdidx].cmd_func == ex_ni | |
1315 | 1990 #ifdef HAVE_EX_SCRIPT_NI |
1991 || cmdnames[ea.cmdidx].cmd_func == ex_script_ni | |
1992 #endif | |
1993 )); | |
7 | 1994 |
1995 #ifndef FEAT_EVAL | |
1996 /* | |
1997 * When the expression evaluation is disabled, recognize the ":if" and | |
1998 * ":endif" commands and ignore everything in between it. | |
1999 */ | |
2000 if (ea.cmdidx == CMD_if) | |
2001 ++if_level; | |
2002 if (if_level) | |
2003 { | |
2004 if (ea.cmdidx == CMD_endif) | |
2005 --if_level; | |
2006 goto doend; | |
2007 } | |
2008 | |
2009 #endif | |
2010 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2011 // forced commands |
1613 | 2012 if (*p == '!' && ea.cmdidx != CMD_substitute |
2013 && ea.cmdidx != CMD_smagic && ea.cmdidx != CMD_snomagic) | |
7 | 2014 { |
2015 ++p; | |
2016 ea.forceit = TRUE; | |
2017 } | |
2018 else | |
2019 ea.forceit = FALSE; | |
2020 | |
2021 /* | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
2022 * 6. Parse arguments. Then check for errors. |
7 | 2023 */ |
6305 | 2024 if (!IS_USER_CMDIDX(ea.cmdidx)) |
835 | 2025 ea.argt = (long)cmdnames[(int)ea.cmdidx].cmd_argt; |
7 | 2026 |
2027 if (!ea.skip) | |
2028 { | |
2029 #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
|
2030 if (sandbox != 0 && !(ea.argt & EX_SBOXOK)) |
7 | 2031 { |
15748
93b78c4a7cd5
patch 8.1.0881: can execute shell commands in rvim through interfaces
Bram Moolenaar <Bram@vim.org>
parents:
15713
diff
changeset
|
2032 // 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
|
2033 errormsg = _(e_sandbox); |
7 | 2034 goto doend; |
2035 } | |
2036 #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
|
2037 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
|
2038 { |
93b78c4a7cd5
patch 8.1.0881: can execute shell commands in rvim through interfaces
Bram Moolenaar <Bram@vim.org>
parents:
15713
diff
changeset
|
2039 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
|
2040 goto doend; |
93b78c4a7cd5
patch 8.1.0881: can execute shell commands in rvim through interfaces
Bram Moolenaar <Bram@vim.org>
parents:
15713
diff
changeset
|
2041 } |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2042 if (!curbuf->b_p_ma && (ea.argt & EX_MODIFY)) |
7 | 2043 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2044 // 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
|
2045 errormsg = _(e_modifiable); |
7 | 2046 goto doend; |
2047 } | |
631 | 2048 |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2049 if (text_locked() && !(ea.argt & EX_CMDWIN) |
6305 | 2050 && !IS_USER_CMDIDX(ea.cmdidx)) |
7 | 2051 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2052 // 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
|
2053 errormsg = _(get_text_locked_msg()); |
7 | 2054 goto doend; |
2055 } | |
14648
c3222a7342ab
patch 8.1.0337: :file fails in quickfix command
Christian Brabandt <cb@256bit.org>
parents:
14640
diff
changeset
|
2056 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2057 // 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
|
2058 // 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
|
2059 // 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
|
2060 // 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
|
2061 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
|
2062 && ea.cmdidx != CMD_checktime |
822 | 2063 && ea.cmdidx != CMD_edit |
14648
c3222a7342ab
patch 8.1.0337: :file fails in quickfix command
Christian Brabandt <cb@256bit.org>
parents:
14640
diff
changeset
|
2064 && ea.cmdidx != CMD_file |
6305 | 2065 && !IS_USER_CMDIDX(ea.cmdidx) |
819 | 2066 && curbuf_locked()) |
2067 goto doend; | |
7 | 2068 |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2069 if (!ni && !(ea.argt & EX_RANGE) && ea.addr_count > 0) |
7 | 2070 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2071 // no range allowed |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2072 errormsg = _(e_norange); |
7 | 2073 goto doend; |
2074 } | |
2075 } | |
2076 | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2077 if (!ni && !(ea.argt & EX_BANG) && ea.forceit) // no <!> allowed |
7 | 2078 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2079 errormsg = _(e_nobang); |
7 | 2080 goto doend; |
2081 } | |
2082 | |
2083 /* | |
2084 * Don't complain about the range if it is not used | |
2085 * (could happen if line_count is accidentally set to 0). | |
2086 */ | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2087 if (!ea.skip && !ni && (ea.argt & EX_RANGE)) |
7 | 2088 { |
2089 /* | |
2090 * If the range is backwards, ask for confirmation and, if given, swap | |
2091 * ea.line1 & ea.line2 so it's forwards again. | |
2092 * When global command is busy, don't ask, will fail below. | |
2093 */ | |
2094 if (!global_busy && ea.line1 > ea.line2) | |
2095 { | |
557 | 2096 if (msg_silent == 0) |
2097 { | |
2098 if (sourcing || exmode_active) | |
2099 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2100 errormsg = _("E493: Backwards range given"); |
557 | 2101 goto doend; |
2102 } | |
7 | 2103 if (ask_yesno((char_u *) |
2104 _("Backwards range given, OK to swap"), FALSE) != 'y') | |
557 | 2105 goto doend; |
7 | 2106 } |
2107 lnum = ea.line1; | |
2108 ea.line1 = ea.line2; | |
2109 ea.line2 = lnum; | |
2110 } | |
2111 if ((errormsg = invalid_range(&ea)) != NULL) | |
2112 goto doend; | |
2113 } | |
2114 | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
2115 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
|
2116 // default is 1, not cursor |
7 | 2117 ea.line2 = 1; |
2118 | |
2119 correct_range(&ea); | |
2120 | |
2121 #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
|
2122 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
|
2123 && ea.addr_type == ADDR_LINES) |
7 | 2124 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2125 // 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
|
2126 // at the end of a closed fold. |
7 | 2127 (void)hasFolding(ea.line1, &ea.line1, NULL); |
2128 (void)hasFolding(ea.line2, NULL, &ea.line2); | |
2129 } | |
2130 #endif | |
2131 | |
2132 #ifdef FEAT_QUICKFIX | |
2133 /* | |
41 | 2134 * For the ":make" and ":grep" commands we insert the 'makeprg'/'grepprg' |
7 | 2135 * option here, so things like % get expanded. |
2136 */ | |
344 | 2137 p = replace_makeprg(&ea, p, cmdlinep); |
2138 if (p == NULL) | |
2139 goto doend; | |
7 | 2140 #endif |
2141 | |
2142 /* | |
2143 * Skip to start of argument. | |
2144 * Don't do this for the ":!" command, because ":!! -l" needs the space. | |
2145 */ | |
2146 if (ea.cmdidx == CMD_bang) | |
2147 ea.arg = p; | |
2148 else | |
2149 ea.arg = skipwhite(p); | |
2150 | |
14648
c3222a7342ab
patch 8.1.0337: :file fails in quickfix command
Christian Brabandt <cb@256bit.org>
parents:
14640
diff
changeset
|
2151 // ":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
|
2152 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
|
2153 goto doend; |
c3222a7342ab
patch 8.1.0337: :file fails in quickfix command
Christian Brabandt <cb@256bit.org>
parents:
14640
diff
changeset
|
2154 |
7 | 2155 /* |
2156 * Check for "++opt=val" argument. | |
2157 * Must be first, allow ":w ++enc=utf8 !cmd" | |
2158 */ | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2159 if (ea.argt & EX_ARGOPT) |
7 | 2160 while (ea.arg[0] == '+' && ea.arg[1] == '+') |
2161 if (getargopt(&ea) == FAIL && !ni) | |
2162 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2163 errormsg = _(e_invarg); |
7 | 2164 goto doend; |
2165 } | |
2166 | |
2167 if (ea.cmdidx == CMD_write || ea.cmdidx == CMD_update) | |
2168 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2169 if (*ea.arg == '>') // append |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2170 { |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2171 if (*++ea.arg != '>') // typed wrong |
7 | 2172 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2173 errormsg = _("E494: Use w or w>>"); |
7 | 2174 goto doend; |
2175 } | |
2176 ea.arg = skipwhite(ea.arg + 1); | |
2177 ea.append = TRUE; | |
2178 } | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2179 else if (*ea.arg == '!' && ea.cmdidx == CMD_write) // :w !filter |
7 | 2180 { |
2181 ++ea.arg; | |
2182 ea.usefilter = TRUE; | |
2183 } | |
2184 } | |
2185 | |
2186 if (ea.cmdidx == CMD_read) | |
2187 { | |
2188 if (ea.forceit) | |
2189 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2190 ea.usefilter = TRUE; // :r! filter if ea.forceit |
7 | 2191 ea.forceit = FALSE; |
2192 } | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2193 else if (*ea.arg == '!') // :r !filter |
7 | 2194 { |
2195 ++ea.arg; | |
2196 ea.usefilter = TRUE; | |
2197 } | |
2198 } | |
2199 | |
2200 if (ea.cmdidx == CMD_lshift || ea.cmdidx == CMD_rshift) | |
2201 { | |
2202 ea.amount = 1; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2203 while (*ea.arg == *ea.cmd) // count number of '>' or '<' |
7 | 2204 { |
2205 ++ea.arg; | |
2206 ++ea.amount; | |
2207 } | |
2208 ea.arg = skipwhite(ea.arg); | |
2209 } | |
2210 | |
2211 /* | |
2212 * Check for "+command" argument, before checking for next command. | |
2213 * Don't do this for ":read !cmd" and ":write !cmd". | |
2214 */ | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2215 if ((ea.argt & EX_CMDARG) && !ea.usefilter) |
7 | 2216 ea.do_ecmd_cmd = getargcmd(&ea.arg); |
2217 | |
2218 /* | |
2219 * Check for '|' to separate commands and '"' to start comments. | |
2220 * Don't do this for ":read !cmd" and ":write !cmd". | |
2221 */ | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2222 if ((ea.argt & EX_TRLBAR) && !ea.usefilter) |
7 | 2223 separate_nextcmd(&ea); |
2224 | |
2225 /* | |
2226 * Check for <newline> to end a shell command. | |
167 | 2227 * Also do this for ":read !cmd", ":write !cmd" and ":global". |
2228 * Any others? | |
7 | 2229 */ |
167 | 2230 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
|
2231 || ea.cmdidx == CMD_terminal |
167 | 2232 || ea.cmdidx == CMD_global |
2233 || ea.cmdidx == CMD_vglobal | |
2234 || ea.usefilter) | |
7 | 2235 { |
2236 for (p = ea.arg; *p; ++p) | |
2237 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2238 // 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
|
2239 // 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
|
2240 // 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
|
2241 // 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
|
2242 // 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
|
2243 // versions. |
7 | 2244 if (*p == '\\' && p[1] == '\n') |
1619 | 2245 STRMOVE(p, p + 1); |
7 | 2246 else if (*p == '\n') |
2247 { | |
2248 ea.nextcmd = p + 1; | |
2249 *p = NUL; | |
2250 break; | |
2251 } | |
2252 } | |
2253 } | |
2254 | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2255 if ((ea.argt & EX_DFLALL) && ea.addr_count == 0) |
7 | 2256 { |
6424 | 2257 buf_T *buf; |
2258 | |
7 | 2259 ea.line1 = 1; |
6424 | 2260 switch (ea.addr_type) |
2261 { | |
2262 case ADDR_LINES: | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
2263 case ADDR_OTHER: |
6424 | 2264 ea.line2 = curbuf->b_ml.ml_line_count; |
2265 break; | |
2266 case ADDR_LOADED_BUFFERS: | |
2267 buf = firstbuf; | |
2268 while (buf->b_next != NULL && buf->b_ml.ml_mfp == NULL) | |
2269 buf = buf->b_next; | |
2270 ea.line1 = buf->b_fnum; | |
2271 buf = lastbuf; | |
2272 while (buf->b_prev != NULL && buf->b_ml.ml_mfp == NULL) | |
2273 buf = buf->b_prev; | |
2274 ea.line2 = buf->b_fnum; | |
2275 break; | |
2276 case ADDR_BUFFERS: | |
2277 ea.line1 = firstbuf->b_fnum; | |
2278 ea.line2 = lastbuf->b_fnum; | |
2279 break; | |
2280 case ADDR_WINDOWS: | |
2281 ea.line2 = LAST_WIN_NR; | |
2282 break; | |
2283 case ADDR_TABS: | |
2284 ea.line2 = LAST_TAB_NR; | |
2285 break; | |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
2286 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
|
2287 ea.line2 = 1; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
2288 break; |
6424 | 2289 case ADDR_ARGUMENTS: |
2290 if (ARGCOUNT == 0) | |
2291 ea.line1 = ea.line2 = 0; | |
2292 else | |
2293 ea.line2 = ARGCOUNT; | |
2294 break; | |
16515
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
2295 case ADDR_QUICKFIX_VALID: |
7105
f4456e686406
commit https://github.com/vim/vim/commit/e906c502079770ae0e0071c74cefb802689ff193
Christian Brabandt <cb@256bit.org>
parents:
7092
diff
changeset
|
2296 #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
|
2297 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
|
2298 if (ea.line2 == 0) |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
2299 ea.line2 = 1; |
16479
7dcf301d1432
patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents:
16475
diff
changeset
|
2300 #endif |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
2301 break; |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
2302 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
|
2303 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
|
2304 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
|
2305 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
|
2306 break; |
6424 | 2307 } |
7 | 2308 } |
2309 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2310 // 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
|
2311 if ( (ea.argt & EX_REGSTR) |
7 | 2312 && *ea.arg != NUL |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2313 // Do not allow register = for user commands |
6305 | 2314 && (!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
|
2315 && !((ea.argt & EX_COUNT) && VIM_ISDIGIT(*ea.arg))) |
7 | 2316 { |
2791 | 2317 #ifndef FEAT_CLIPBOARD |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2318 // check these explicitly for a more specific error message |
2791 | 2319 if (*ea.arg == '*' || *ea.arg == '+') |
2320 { | |
15474
79e3dcc5aa50
patch 8.1.0745: compiler warnings for signed/unsigned string
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
2321 errormsg = _(e_invalidreg); |
2791 | 2322 goto doend; |
2323 } | |
2324 #endif | |
6305 | 2325 if (valid_yank_reg(*ea.arg, (ea.cmdidx != CMD_put |
2326 && !IS_USER_CMDIDX(ea.cmdidx)))) | |
2791 | 2327 { |
2328 ea.regname = *ea.arg++; | |
7 | 2329 #ifdef FEAT_EVAL |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2330 // for '=' register: accept the rest of the line as an expression |
2791 | 2331 if (ea.arg[-1] == '=' && ea.arg[0] != NUL) |
2332 { | |
2333 set_expr_line(vim_strsave(ea.arg)); | |
2334 ea.arg += STRLEN(ea.arg); | |
2335 } | |
2336 #endif | |
2337 ea.arg = skipwhite(ea.arg); | |
2338 } | |
7 | 2339 } |
2340 | |
2341 /* | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2342 * Check for a count. When accepting a EX_BUFNAME, don't use "123foo" as a |
7 | 2343 * count, it's a buffer name. |
2344 */ | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2345 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
|
2346 && (!(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
|
2347 || VIM_ISWHITE(*p))) |
7 | 2348 { |
2349 n = getdigits(&ea.arg); | |
2350 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
|
2351 if (n <= 0 && !ni && (ea.argt & EX_ZEROR) == 0) |
7 | 2352 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2353 errormsg = _(e_zerocount); |
7 | 2354 goto doend; |
2355 } | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
2356 if (ea.addr_type != ADDR_LINES) // e.g. :buffer 2, :sleep 3 |
7 | 2357 { |
2358 ea.line2 = n; | |
2359 if (ea.addr_count == 0) | |
2360 ea.addr_count = 1; | |
2361 } | |
2362 else | |
2363 { | |
2364 ea.line1 = ea.line2; | |
2365 ea.line2 += n - 1; | |
2366 ++ea.addr_count; | |
2367 /* | |
2368 * Be vi compatible: no error message for out of range. | |
2369 */ | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
2370 if (ea.line2 > curbuf->b_ml.ml_line_count) |
7 | 2371 ea.line2 = curbuf->b_ml.ml_line_count; |
2372 } | |
2373 } | |
167 | 2374 |
2375 /* | |
2376 * Check for flags: 'l', 'p' and '#'. | |
2377 */ | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2378 if (ea.argt & EX_FLAGS) |
167 | 2379 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
|
2380 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
|
2381 && *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
|
2382 { |
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2383 // 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
|
2384 errormsg = _(e_trailing); |
7 | 2385 goto doend; |
2386 } | |
2387 | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2388 if (!ni && (ea.argt & EX_NEEDARG) && *ea.arg == NUL) |
7 | 2389 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2390 errormsg = _(e_argreq); |
7 | 2391 goto doend; |
2392 } | |
2393 | |
2394 #ifdef FEAT_EVAL | |
2395 /* | |
2396 * Skip the command when it's not going to be executed. | |
2397 * The commands like :if, :endif, etc. always need to be executed. | |
2398 * Also make an exception for commands that handle a trailing command | |
2399 * themselves. | |
2400 */ | |
2401 if (ea.skip) | |
2402 { | |
2403 switch (ea.cmdidx) | |
2404 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2405 // commands that need evaluation |
7 | 2406 case CMD_while: |
2407 case CMD_endwhile: | |
72 | 2408 case CMD_for: |
2409 case CMD_endfor: | |
7 | 2410 case CMD_if: |
2411 case CMD_elseif: | |
2412 case CMD_else: | |
2413 case CMD_endif: | |
2414 case CMD_try: | |
2415 case CMD_catch: | |
2416 case CMD_finally: | |
2417 case CMD_endtry: | |
2418 case CMD_function: | |
19575
3c0de44077cd
patch 8.2.0344: ":def" not skipped properly
Bram Moolenaar <Bram@vim.org>
parents:
19497
diff
changeset
|
2419 case CMD_def: |
7 | 2420 break; |
2421 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2422 // 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
|
2423 // 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
|
2424 // the list at ":help :bar". |
7 | 2425 case CMD_aboveleft: |
2426 case CMD_and: | |
2427 case CMD_belowright: | |
2428 case CMD_botright: | |
2429 case CMD_browse: | |
2430 case CMD_call: | |
2431 case CMD_confirm: | |
18713
baf890fa1621
patch 8.1.2348: :const cannot be followed by "| endif"
Bram Moolenaar <Bram@vim.org>
parents:
18406
diff
changeset
|
2432 case CMD_const: |
7 | 2433 case CMD_delfunction: |
2434 case CMD_djump: | |
2435 case CMD_dlist: | |
2436 case CMD_dsearch: | |
2437 case CMD_dsplit: | |
2438 case CMD_echo: | |
2439 case CMD_echoerr: | |
2440 case CMD_echomsg: | |
2441 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
|
2442 case CMD_eval: |
7 | 2443 case CMD_execute: |
9941
e975914c17e9
commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
9927
diff
changeset
|
2444 case CMD_filter: |
7 | 2445 case CMD_help: |
2446 case CMD_hide: | |
2447 case CMD_ijump: | |
2448 case CMD_ilist: | |
2449 case CMD_isearch: | |
2450 case CMD_isplit: | |
22 | 2451 case CMD_keepalt: |
7 | 2452 case CMD_keepjumps: |
2453 case CMD_keepmarks: | |
5467 | 2454 case CMD_keeppatterns: |
7 | 2455 case CMD_leftabove: |
2456 case CMD_let: | |
2457 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
|
2458 case CMD_lockvar: |
2320
966a5609669e
Added Lua interfae. (Luis Carvalho)
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
2459 case CMD_lua: |
7 | 2460 case CMD_match: |
14 | 2461 case CMD_mzscheme: |
5737 | 2462 case CMD_noautocmd: |
2463 case CMD_noswapfile: | |
7 | 2464 case CMD_perl: |
2465 case CMD_psearch: | |
2466 case CMD_python: | |
2350
06feaf4fe36a
Rename some "python3" symbols to "py3", as the command name.
Bram Moolenaar <bram@vim.org>
parents:
2340
diff
changeset
|
2467 case CMD_py3: |
2366
7a57fe6a5157
Fix that :py3file was not working.
Bram Moolenaar <bram@vim.org>
parents:
2360
diff
changeset
|
2468 case CMD_python3: |
7 | 2469 case CMD_return: |
2470 case CMD_rightbelow: | |
2471 case CMD_ruby: | |
2472 case CMD_silent: | |
2473 case CMD_smagic: | |
2474 case CMD_snomagic: | |
2475 case CMD_substitute: | |
2476 case CMD_syntax: | |
690 | 2477 case CMD_tab: |
7 | 2478 case CMD_tcl: |
2479 case CMD_throw: | |
2480 case CMD_tilde: | |
2481 case CMD_topleft: | |
2482 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
|
2483 case CMD_unlockvar: |
7 | 2484 case CMD_verbose: |
2485 case CMD_vertical: | |
2887 | 2486 case CMD_wincmd: |
7 | 2487 break; |
2488 | |
2489 default: goto doend; | |
2490 } | |
2491 } | |
2492 #endif | |
2493 | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2494 if (ea.argt & EX_XFILE) |
7 | 2495 { |
2496 if (expand_filename(&ea, cmdlinep, &errormsg) == FAIL) | |
2497 goto doend; | |
2498 } | |
2499 | |
2500 /* | |
2501 * Accept buffer name. Cannot be used at the same time with a buffer | |
2502 * number. Don't do this for a user command. | |
2503 */ | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2504 if ((ea.argt & EX_BUFNAME) && *ea.arg != NUL && ea.addr_count == 0 |
6305 | 2505 && !IS_USER_CMDIDX(ea.cmdidx)) |
7 | 2506 { |
2507 /* | |
2508 * :bdelete, :bwipeout and :bunload take several arguments, separated | |
2509 * by spaces: find next space (skipping over escaped characters). | |
2510 * The others take one argument: ignore trailing spaces. | |
2511 */ | |
2512 if (ea.cmdidx == CMD_bdelete || ea.cmdidx == CMD_bwipeout | |
2513 || ea.cmdidx == CMD_bunload) | |
2514 p = skiptowhite_esc(ea.arg); | |
2515 else | |
2516 { | |
2517 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
|
2518 while (p > ea.arg && VIM_ISWHITE(p[-1])) |
7 | 2519 --p; |
2520 } | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2521 ea.line2 = buflist_findpat(ea.arg, p, (ea.argt & EX_BUFUNL) != 0, |
4236 | 2522 FALSE, FALSE); |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2523 if (ea.line2 < 0) // failed |
7 | 2524 goto doend; |
2525 ea.addr_count = 1; | |
2526 ea.arg = skipwhite(p); | |
2527 } | |
2528 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2529 // 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
|
2530 // ":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
|
2531 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
|
2532 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2533 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
|
2534 if (emsg_silent < 0) |
530943a23d3f
patch 8.0.1518: error messages suppressed after ":silent! try"
Christian Brabandt <cb@256bit.org>
parents:
13268
diff
changeset
|
2535 emsg_silent = 0; |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2536 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
|
2537 } |
530943a23d3f
patch 8.0.1518: error messages suppressed after ":silent! try"
Christian Brabandt <cb@256bit.org>
parents:
13268
diff
changeset
|
2538 |
530943a23d3f
patch 8.0.1518: error messages suppressed after ":silent! try"
Christian Brabandt <cb@256bit.org>
parents:
13268
diff
changeset
|
2539 /* |
530943a23d3f
patch 8.0.1518: error messages suppressed after ":silent! try"
Christian Brabandt <cb@256bit.org>
parents:
13268
diff
changeset
|
2540 * 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
|
2541 */ |
7 | 2542 |
6305 | 2543 if (IS_USER_CMDIDX(ea.cmdidx)) |
7 | 2544 { |
2545 /* | |
2546 * Execute a user-defined command. | |
2547 */ | |
2548 do_ucmd(&ea); | |
2549 } | |
2550 else | |
2551 { | |
2552 /* | |
16411
5b5c5daf57de
patch 8.1.1210: support for user commands is spread out
Bram Moolenaar <Bram@vim.org>
parents:
16399
diff
changeset
|
2553 * Call the function to execute the builtin command. |
7 | 2554 */ |
2555 ea.errmsg = NULL; | |
2556 (cmdnames[ea.cmdidx].cmd_func)(&ea); | |
2557 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
|
2558 errormsg = _(ea.errmsg); |
7 | 2559 } |
2560 | |
2561 #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
|
2562 // 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
|
2563 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
|
2564 && 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
|
2565 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
|
2566 |
7 | 2567 /* |
2568 * If the command just executed called do_cmdline(), any throw or ":return" | |
2569 * or ":finish" encountered there must also check the cstack of the still | |
2570 * active do_cmdline() that called this do_one_cmd(). Rethrow an uncaught | |
2571 * exception, or reanimate a returned function or finished script file and | |
2572 * return or finish it again. | |
2573 */ | |
2574 if (need_rethrow) | |
2575 do_throw(cstack); | |
2576 else if (check_cstack) | |
2577 { | |
944 | 2578 if (source_finished(fgetline, cookie)) |
7 | 2579 do_finish(&ea, TRUE); |
944 | 2580 else if (getline_equal(fgetline, cookie, get_func_line) |
7 | 2581 && current_func_returned()) |
2582 do_return(&ea, TRUE, FALSE, NULL); | |
2583 } | |
2584 need_rethrow = check_cstack = FALSE; | |
2585 #endif | |
2586 | |
2587 doend: | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2588 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
|
2589 { |
7 | 2590 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
|
2591 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
|
2592 } |
7 | 2593 |
2594 if (errormsg != NULL && *errormsg != NUL && !did_emsg) | |
2595 { | |
2596 if (sourcing) | |
2597 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2598 if (errormsg != (char *)IObuff) |
7 | 2599 { |
2600 STRCPY(IObuff, errormsg); | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2601 errormsg = (char *)IObuff; |
7 | 2602 } |
3097 | 2603 append_command(*cmdlinep); |
7 | 2604 } |
2605 emsg(errormsg); | |
2606 } | |
2607 #ifdef FEAT_EVAL | |
2608 do_errthrow(cstack, | |
6305 | 2609 (ea.cmdidx != CMD_SIZE && !IS_USER_CMDIDX(ea.cmdidx)) |
2610 ? cmdnames[(int)ea.cmdidx].cmd_name : (char_u *)NULL); | |
7 | 2611 #endif |
2612 | |
21172
96ae8622cfb6
patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents:
21130
diff
changeset
|
2613 undo_cmdmod(&ea, save_msg_scroll); |
7 | 2614 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
|
2615 reg_executing = save_reg_executing; |
7 | 2616 |
28 | 2617 #ifdef HAVE_SANDBOX |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2618 if (ea.did_sandbox) |
28 | 2619 --sandbox; |
2620 #endif | |
2621 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2622 if (ea.nextcmd && *ea.nextcmd == NUL) // not really a next command |
7 | 2623 ea.nextcmd = NULL; |
2624 | |
2625 #ifdef FEAT_EVAL | |
2626 --ex_nesting_level; | |
20996
3af71cbcfdbe
patch 8.2.1049: Vim9: leaking memory when using continuation line
Bram Moolenaar <Bram@vim.org>
parents:
20982
diff
changeset
|
2627 vim_free(ea.cmdline_tofree); |
7 | 2628 #endif |
2629 | |
2630 return ea.nextcmd; | |
2631 } | |
2632 #if (_MSC_VER == 1200) | |
128 | 2633 #pragma optimize( "", on ) |
7 | 2634 #endif |
2635 | |
2636 /* | |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2637 * 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
|
2638 * - update eap->cmd |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2639 * - store flags in "cmdmod". |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2640 * - 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
|
2641 * - 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
|
2642 * - 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
|
2643 * - 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
|
2644 * - 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
|
2645 * 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
|
2646 * "cmdmod". |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2647 * 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
|
2648 * 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
|
2649 */ |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2650 int |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2651 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
|
2652 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2653 char_u *p; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2654 |
20007
aadd1cae2ff5
patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
2655 CLEAR_FIELD(cmdmod); |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2656 eap->verbose_save = -1; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2657 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
|
2658 |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2659 // 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
|
2660 for (;;) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2661 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2662 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
|
2663 ++eap->cmd; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2664 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2665 // in ex mode, an empty line works like :+ |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2666 if (*eap->cmd == NUL && exmode_active |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2667 && (getline_equal(eap->getline, eap->cookie, getexmodeline) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2668 || getline_equal(eap->getline, eap->cookie, getexline)) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2669 && curwin->w_cursor.lnum < curbuf->b_ml.ml_line_count) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2670 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2671 eap->cmd = (char_u *)"+"; |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2672 if (!skip_only) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2673 ex_pressedreturn = TRUE; |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2674 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2675 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2676 // ignore comment and empty lines |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2677 if (*eap->cmd == '"') |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2678 return FAIL; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2679 if (*eap->cmd == NUL) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2680 { |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2681 if (!skip_only) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2682 ex_pressedreturn = TRUE; |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2683 return FAIL; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2684 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2685 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2686 p = skip_range(eap->cmd, NULL); |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2687 switch (*p) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2688 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2689 // When adding an entry, also modify cmd_exists(). |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2690 case 'a': if (!checkforcmd(&eap->cmd, "aboveleft", 3)) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2691 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2692 cmdmod.split |= WSP_ABOVE; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2693 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2694 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2695 case 'b': if (checkforcmd(&eap->cmd, "belowright", 3)) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2696 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2697 cmdmod.split |= WSP_BELOW; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2698 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2699 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2700 if (checkforcmd(&eap->cmd, "browse", 3)) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2701 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2702 #ifdef FEAT_BROWSE_CMD |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2703 cmdmod.browse = TRUE; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2704 #endif |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2705 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2706 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2707 if (!checkforcmd(&eap->cmd, "botright", 2)) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2708 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2709 cmdmod.split |= WSP_BOT; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2710 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2711 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2712 case 'c': if (!checkforcmd(&eap->cmd, "confirm", 4)) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2713 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2714 #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2715 cmdmod.confirm = TRUE; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2716 #endif |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2717 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2718 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2719 case 'k': if (checkforcmd(&eap->cmd, "keepmarks", 3)) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2720 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2721 cmdmod.keepmarks = TRUE; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2722 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2723 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2724 if (checkforcmd(&eap->cmd, "keepalt", 5)) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2725 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2726 cmdmod.keepalt = TRUE; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2727 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2728 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2729 if (checkforcmd(&eap->cmd, "keeppatterns", 5)) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2730 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2731 cmdmod.keeppatterns = TRUE; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2732 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2733 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2734 if (!checkforcmd(&eap->cmd, "keepjumps", 5)) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2735 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2736 cmdmod.keepjumps = TRUE; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2737 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2738 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2739 case 'f': // only accept ":filter {pat} cmd" |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2740 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2741 char_u *reg_pat; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2742 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2743 if (!checkforcmd(&p, "filter", 4) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2744 || *p == NUL || ends_excmd(*p)) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2745 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2746 if (*p == '!') |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2747 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2748 cmdmod.filter_force = TRUE; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2749 p = skipwhite(p + 1); |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2750 if (*p == NUL || ends_excmd(*p)) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2751 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2752 } |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2753 if (skip_only) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2754 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
|
2755 else |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2756 // 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
|
2757 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
|
2758 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
|
2759 break; |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2760 if (!skip_only) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2761 { |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2762 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
|
2763 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
|
2764 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
|
2765 break; |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2766 } |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2767 eap->cmd = p; |
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 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2771 // ":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
|
2772 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
|
2773 || *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
|
2774 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2775 eap->cmd = p; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2776 cmdmod.hide = TRUE; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2777 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2778 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2779 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
|
2780 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2781 cmdmod.lockmarks = TRUE; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2782 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2783 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2784 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2785 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
|
2786 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2787 cmdmod.split |= WSP_ABOVE; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2788 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2789 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2790 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
|
2791 { |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2792 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
|
2793 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2794 // 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
|
2795 // 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
|
2796 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
|
2797 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
|
2798 (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
|
2799 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2800 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2801 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2802 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
|
2803 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2804 cmdmod.noswapfile = TRUE; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2805 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2806 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2807 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
|
2808 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2809 cmdmod.split |= WSP_BELOW; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2810 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2811 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2812 case '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
|
2813 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2814 #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
|
2815 if (!skip_only) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2816 { |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2817 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
|
2818 ++sandbox; |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2819 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
|
2820 } |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2821 #endif |
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 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
|
2825 break; |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2826 if (!skip_only) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2827 { |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2828 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
|
2829 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
|
2830 ++msg_silent; |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2831 } |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2832 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
|
2833 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2834 // ":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
|
2835 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
|
2836 if (!skip_only) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2837 { |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2838 ++emsg_silent; |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2839 ++eap->did_esilent; |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2840 } |
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 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2843 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2844 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
|
2845 { |
15263
ad065b8123e8
patch 8.1.0640: get E14 while typing command :tab with 'incsearch' set
Bram Moolenaar <Bram@vim.org>
parents:
15239
diff
changeset
|
2846 if (!skip_only) |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2847 { |
15263
ad065b8123e8
patch 8.1.0640: get E14 while typing command :tab with 'incsearch' set
Bram Moolenaar <Bram@vim.org>
parents:
15239
diff
changeset
|
2848 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
|
2849 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
|
2850 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
|
2851 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
|
2852 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
|
2853 else |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2854 { |
15263
ad065b8123e8
patch 8.1.0640: get E14 while typing command :tab with 'incsearch' set
Bram Moolenaar <Bram@vim.org>
parents:
15239
diff
changeset
|
2855 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
|
2856 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2857 *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
|
2858 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
|
2859 } |
ad065b8123e8
patch 8.1.0640: get E14 while typing command :tab with 'incsearch' set
Bram Moolenaar <Bram@vim.org>
parents:
15239
diff
changeset
|
2860 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
|
2861 } |
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 eap->cmd = p; |
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(&eap->cmd, "topleft", 2)) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2867 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2868 cmdmod.split |= WSP_TOP; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2869 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2870 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2871 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
|
2872 break; |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2873 if (!skip_only) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2874 { |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2875 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
|
2876 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
|
2877 msg_silent = 0; |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2878 } |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2879 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2880 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2881 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
|
2882 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2883 cmdmod.split |= WSP_VERT; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2884 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2885 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2886 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
|
2887 break; |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2888 if (!skip_only) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2889 { |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2890 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
|
2891 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
|
2892 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
|
2893 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
|
2894 else |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2895 p_verbose = 1; |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2896 } |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2897 eap->cmd = p; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2898 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2899 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2900 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2901 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2902 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2903 return OK; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2904 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2905 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2906 /* |
21172
96ae8622cfb6
patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents:
21130
diff
changeset
|
2907 * Unod and free contents of "cmdmod". |
96ae8622cfb6
patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents:
21130
diff
changeset
|
2908 */ |
96ae8622cfb6
patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents:
21130
diff
changeset
|
2909 void |
96ae8622cfb6
patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents:
21130
diff
changeset
|
2910 undo_cmdmod(exarg_T *eap, int save_msg_scroll) |
96ae8622cfb6
patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents:
21130
diff
changeset
|
2911 { |
96ae8622cfb6
patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents:
21130
diff
changeset
|
2912 if (eap->verbose_save >= 0) |
96ae8622cfb6
patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents:
21130
diff
changeset
|
2913 p_verbose = eap->verbose_save; |
96ae8622cfb6
patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents:
21130
diff
changeset
|
2914 |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2915 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
|
2916 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
2917 // 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
|
2918 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
|
2919 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
|
2920 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
|
2921 } |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2922 |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2923 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
|
2924 vim_regfree(cmdmod.filter_regmatch.regprog); |
21172
96ae8622cfb6
patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents:
21130
diff
changeset
|
2925 |
96ae8622cfb6
patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents:
21130
diff
changeset
|
2926 if (eap->save_msg_silent != -1) |
96ae8622cfb6
patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents:
21130
diff
changeset
|
2927 { |
96ae8622cfb6
patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents:
21130
diff
changeset
|
2928 // messages could be enabled for a serious error, need to check if the |
96ae8622cfb6
patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents:
21130
diff
changeset
|
2929 // counters don't become negative |
96ae8622cfb6
patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents:
21130
diff
changeset
|
2930 if (!did_emsg || msg_silent > eap->save_msg_silent) |
96ae8622cfb6
patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents:
21130
diff
changeset
|
2931 msg_silent = eap->save_msg_silent; |
96ae8622cfb6
patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents:
21130
diff
changeset
|
2932 emsg_silent -= eap->did_esilent; |
96ae8622cfb6
patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents:
21130
diff
changeset
|
2933 if (emsg_silent < 0) |
96ae8622cfb6
patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents:
21130
diff
changeset
|
2934 emsg_silent = 0; |
96ae8622cfb6
patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents:
21130
diff
changeset
|
2935 // Restore msg_scroll, it's set by file I/O commands, even when no |
96ae8622cfb6
patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents:
21130
diff
changeset
|
2936 // message is actually displayed. |
96ae8622cfb6
patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents:
21130
diff
changeset
|
2937 msg_scroll = save_msg_scroll; |
96ae8622cfb6
patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents:
21130
diff
changeset
|
2938 |
96ae8622cfb6
patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents:
21130
diff
changeset
|
2939 // "silent reg" or "silent echo x" inside "redir" leaves msg_col |
96ae8622cfb6
patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents:
21130
diff
changeset
|
2940 // somewhere in the line. Put it back in the first column. |
96ae8622cfb6
patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents:
21130
diff
changeset
|
2941 if (redirecting()) |
96ae8622cfb6
patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents:
21130
diff
changeset
|
2942 msg_col = 0; |
96ae8622cfb6
patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents:
21130
diff
changeset
|
2943 } |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2944 } |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2945 |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2946 /* |
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 * 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
|
2948 * 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
|
2949 * 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
|
2950 */ |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2951 int |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2952 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
|
2953 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2954 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
|
2955 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
|
2956 |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2957 // 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
|
2958 for (;;) |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2959 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2960 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
|
2961 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
|
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 case ADDR_LINES: |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
2964 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
|
2965 // 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
|
2966 // 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
|
2967 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
|
2968 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
|
2969 else |
3fe45aa3bbc5
patch 8.2.0791: a second popup window with terminal causes trouble
Bram Moolenaar <Bram@vim.org>
parents:
20239
diff
changeset
|
2970 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
|
2971 break; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2972 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
|
2973 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
|
2974 break; |
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_ARGUMENTS: |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2976 eap->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
|
2977 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
|
2978 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
|
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 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
|
2982 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
|
2983 break; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2984 case ADDR_TABS: |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2985 eap->line2 = 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
|
2986 break; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2987 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
|
2988 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
|
2989 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
|
2990 break; |
16479
7dcf301d1432
patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents:
16475
diff
changeset
|
2991 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
|
2992 #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
|
2993 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
|
2994 #endif |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
2995 break; |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
2996 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
|
2997 #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
|
2998 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
|
2999 #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
|
3000 break; |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
3001 case ADDR_NONE: |
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
3002 // 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
|
3003 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
|
3004 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3005 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
|
3006 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
|
3007 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
|
3008 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
|
3009 return FAIL; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3010 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
|
3011 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3012 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
|
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 ++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
|
3015 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
|
3016 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3017 case ADDR_LINES: |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
3018 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
|
3019 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
|
3020 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
|
3021 break; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3022 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
|
3023 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3024 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
|
3025 |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3026 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
|
3027 && 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
|
3028 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
|
3029 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
|
3030 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
|
3031 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
|
3032 && 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
|
3033 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
|
3034 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
|
3035 break; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3036 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3037 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
|
3038 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
|
3039 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
|
3040 break; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3041 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
|
3042 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
|
3043 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
|
3044 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3045 eap->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
|
3046 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
|
3047 ? 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
|
3048 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3049 else |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3050 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3051 // 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
|
3052 // 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
|
3053 *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
|
3054 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
|
3055 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3056 break; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3057 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
|
3058 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
|
3059 case ADDR_QUICKFIX: |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
3060 *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
|
3061 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
|
3062 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
|
3063 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
|
3064 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
|
3065 else |
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 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
|
3068 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
|
3069 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3070 break; |
16515
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
3071 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
|
3072 #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
|
3073 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
|
3074 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
|
3075 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
|
3076 eap->line2 = 1; |
16479
7dcf301d1432
patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents:
16475
diff
changeset
|
3077 #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
|
3078 break; |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
3079 case ADDR_NONE: |
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
3080 // 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
|
3081 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
|
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 ++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
|
3084 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3085 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
|
3086 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3087 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
|
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 // '*' - 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
|
3090 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
|
3091 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
3092 *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
|
3093 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
|
3094 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3095 |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3096 ++eap->cmd; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3097 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
|
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 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
|
3100 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
|
3101 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
|
3102 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
|
3103 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
|
3104 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
|
3105 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
|
3106 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
|
3107 ++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
|
3108 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3109 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3110 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3111 else |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3112 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
|
3113 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
|
3114 |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3115 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
|
3116 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3117 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
|
3118 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3119 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
|
3120 // 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
|
3121 // 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
|
3122 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
|
3123 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
|
3124 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3125 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3126 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
|
3127 break; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3128 ++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
|
3129 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3130 |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3131 // 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
|
3132 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
|
3133 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3134 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
|
3135 // ... 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
|
3136 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
|
3137 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
|
3138 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3139 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
|
3140 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3141 |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3142 /* |
93 | 3143 * Check for an Ex command with optional tail. |
7 | 3144 * If there is a match advance "pp" to the argument and return TRUE. |
3145 */ | |
93 | 3146 int |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3147 checkforcmd( |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3148 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
|
3149 char *cmd, // name of command |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3150 int len) // required length |
7 | 3151 { |
3152 int i; | |
3153 | |
3154 for (i = 0; cmd[i] != NUL; ++i) | |
1872 | 3155 if (((char_u *)cmd)[i] != (*pp)[i]) |
7 | 3156 break; |
3157 if (i >= len && !isalpha((*pp)[i])) | |
3158 { | |
3159 *pp = skipwhite(*pp + i); | |
3160 return TRUE; | |
3161 } | |
3162 return FALSE; | |
3163 } | |
3164 | |
3165 /* | |
3097 | 3166 * Append "cmd" to the error message in IObuff. |
3167 * Takes care of limiting the length and handling 0xa0, which would be | |
3168 * invisible otherwise. | |
3169 */ | |
3170 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3171 append_command(char_u *cmd) |
3097 | 3172 { |
3173 char_u *s = cmd; | |
3174 char_u *d; | |
3175 | |
3176 STRCAT(IObuff, ": "); | |
3177 d = IObuff + STRLEN(IObuff); | |
3178 while (*s != NUL && d - IObuff < IOSIZE - 7) | |
3179 { | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
3180 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
|
3181 { |
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
3182 s += enc_utf8 ? 2 : 1; |
3097 | 3183 STRCPY(d, "<a0>"); |
3184 d += 4; | |
3185 } | |
3186 else | |
3187 MB_COPY_CHAR(s, d); | |
3188 } | |
3189 *d = NUL; | |
3190 } | |
3191 | |
3192 /* | |
7 | 3193 * Find an Ex command by its name, either built-in or user. |
184 | 3194 * 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
|
3195 * Sets eap->cmdidx and returns a pointer to char after the command name. |
184 | 3196 * "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
|
3197 * |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3198 * 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
|
3199 * 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
|
3200 * "eap->cmd". |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3201 * |
7 | 3202 * Returns NULL for an ambiguous user command. |
3203 */ | |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3204 char_u * |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3205 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
|
3206 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
|
3207 int *full UNUSED, |
20239
2135b4641680
patch 8.2.0675: Vim9: no support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20229
diff
changeset
|
3208 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
|
3209 cctx_T *cctx UNUSED) |
7 | 3210 { |
3211 int len; | |
3212 char_u *p; | |
167 | 3213 int i; |
7 | 3214 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3215 #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
|
3216 /* |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3217 * 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
|
3218 * "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
|
3219 */ |
19481
c27837cbe922
patch 8.2.0298: Vim9 script: cannot start command with a string constant
Bram Moolenaar <Bram@vim.org>
parents:
19475
diff
changeset
|
3220 p = eap->cmd; |
21130
4a1e8086759b
patch 8.2.1116: Vim9: parsing command checks for list twice
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
3221 if (lookup != NULL && (*p == '(' || *p == '{' |
4a1e8086759b
patch 8.2.1116: Vim9: parsing command checks for list twice
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
3222 || ((p = to_name_const_end(eap->cmd)) > eap->cmd && *p != NUL) |
4a1e8086759b
patch 8.2.1116: Vim9: parsing command checks for list twice
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
3223 || *p == '[')) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3224 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3225 int oplen; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3226 int heredoc; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3227 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3228 // "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
|
3229 // "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
|
3230 // "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
|
3231 // "varname->expr" is an expression. |
21212
874a28fac941
patch 8.2.1157: Vim9: dict.name is not recognized as an expression
Bram Moolenaar <Bram@vim.org>
parents:
21172
diff
changeset
|
3232 // "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
|
3233 // "(..." is an expression. |
21122
839ace6773aa
patch 8.2.1112: Vim9: no line continuation allowed in method call
Bram Moolenaar <Bram@vim.org>
parents:
21056
diff
changeset
|
3234 // "{..." is an dict expression. |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3235 if (*p == '(' |
21122
839ace6773aa
patch 8.2.1112: Vim9: no line continuation allowed in method call
Bram Moolenaar <Bram@vim.org>
parents:
21056
diff
changeset
|
3236 || *p == '{' |
21130
4a1e8086759b
patch 8.2.1116: Vim9: parsing command checks for list twice
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
3237 || (*p == '[' && p > eap->cmd) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3238 || p[1] == ':' |
21212
874a28fac941
patch 8.2.1157: Vim9: dict.name is not recognized as an expression
Bram Moolenaar <Bram@vim.org>
parents:
21172
diff
changeset
|
3239 || (*p == '-' && p[1] == '>') |
874a28fac941
patch 8.2.1157: Vim9: dict.name is not recognized as an expression
Bram Moolenaar <Bram@vim.org>
parents:
21172
diff
changeset
|
3240 || (*p == '.' && ASCII_ISALPHA(p[1]))) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3241 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3242 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
|
3243 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
|
3244 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3245 |
21130
4a1e8086759b
patch 8.2.1116: Vim9: parsing command checks for list twice
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
3246 // "[...]->Method()" is a list expression, but "[a, b] = Func()" is |
4a1e8086759b
patch 8.2.1116: Vim9: parsing command checks for list twice
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
3247 // an assignment. |
4a1e8086759b
patch 8.2.1116: Vim9: parsing command checks for list twice
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
3248 // If there is no line break inside the "[...]" then "p" is advanced to |
4a1e8086759b
patch 8.2.1116: Vim9: parsing command checks for list twice
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
3249 // after the "]" by to_name_const_end(): check if a "=" follows. |
4a1e8086759b
patch 8.2.1116: Vim9: parsing command checks for list twice
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
3250 // If "[...]" has a line break "p" still points at the "[" and it can't |
4a1e8086759b
patch 8.2.1116: Vim9: parsing command checks for list twice
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
3251 // be an assignment. |
4a1e8086759b
patch 8.2.1116: Vim9: parsing command checks for list twice
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
3252 if (*eap->cmd == '[' && (p == eap->cmd || *skipwhite(p) != '=')) |
4a1e8086759b
patch 8.2.1116: Vim9: parsing command checks for list twice
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
3253 { |
4a1e8086759b
patch 8.2.1116: Vim9: parsing command checks for list twice
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
3254 eap->cmdidx = CMD_eval; |
4a1e8086759b
patch 8.2.1116: Vim9: parsing command checks for list twice
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
3255 return eap->cmd; |
4a1e8086759b
patch 8.2.1116: Vim9: parsing command checks for list twice
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
3256 } |
4a1e8086759b
patch 8.2.1116: Vim9: parsing command checks for list twice
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
3257 |
21122
839ace6773aa
patch 8.2.1112: Vim9: no line continuation allowed in method call
Bram Moolenaar <Bram@vim.org>
parents:
21056
diff
changeset
|
3258 // Recognize an assignment if we recognize the variable name: |
839ace6773aa
patch 8.2.1112: Vim9: no line continuation allowed in method call
Bram Moolenaar <Bram@vim.org>
parents:
21056
diff
changeset
|
3259 // "g:var = expr" |
839ace6773aa
patch 8.2.1112: Vim9: no line continuation allowed in method call
Bram Moolenaar <Bram@vim.org>
parents:
21056
diff
changeset
|
3260 // "var = expr" where "var" is a local var name. |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3261 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
|
3262 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
|
3263 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3264 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
|
3265 || 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
|
3266 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3267 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
|
3268 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
|
3269 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3270 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3271 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3272 #endif |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3273 |
7 | 3274 /* |
3275 * Isolate the command and search for it in the command table. | |
1441 | 3276 * Exceptions: |
7 | 3277 * - the 'k' command can directly be followed by any character. |
3278 * - the 's' command can be followed directly by 'c', 'g', 'i', 'I' or 'r' | |
6472 | 3279 * but :sre[wind] is another command, as are :scr[iptnames], |
7 | 3280 * :scs[cope], :sim[alt], :sig[ns] and :sil[ent]. |
167 | 3281 * - the "d" command can directly be followed by 'l' or 'p' flag. |
7 | 3282 */ |
3283 p = eap->cmd; | |
3284 if (*p == 'k') | |
3285 { | |
3286 eap->cmdidx = CMD_k; | |
3287 ++p; | |
3288 } | |
3289 else if (p[0] == 's' | |
6987 | 3290 && ((p[1] == 'c' && (p[2] == NUL || (p[2] != 's' && p[2] != 'r' |
3291 && (p[3] == NUL || (p[3] != 'i' && p[4] != 'p'))))) | |
7 | 3292 || p[1] == 'g' |
3293 || (p[1] == 'i' && p[2] != 'm' && p[2] != 'l' && p[2] != 'g') | |
3294 || p[1] == 'I' | |
3295 || (p[1] == 'r' && p[2] != 'e'))) | |
3296 { | |
3297 eap->cmdidx = CMD_substitute; | |
3298 ++p; | |
3299 } | |
3300 else | |
3301 { | |
3302 while (ASCII_ISALPHA(*p)) | |
3303 ++p; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3304 // for python 3.x support ":py3", ":python3", ":py3file", etc. |
2330 | 3305 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
|
3306 { |
2366
7a57fe6a5157
Fix that :py3file was not working.
Bram Moolenaar <bram@vim.org>
parents:
2360
diff
changeset
|
3307 while (ASCII_ISALNUM(*p)) |
7a57fe6a5157
Fix that :py3file was not working.
Bram Moolenaar <bram@vim.org>
parents:
2360
diff
changeset
|
3308 ++p; |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3309 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3310 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
|
3311 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3312 // 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
|
3313 ++p; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3314 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
|
3315 ++p; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
3316 } |
2329
ad2889f48843
Added support for Python 3. (Roland Puntaier)
Bram Moolenaar <bram@vim.org>
parents:
2320
diff
changeset
|
3317 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3318 // check for non-alpha command |
7 | 3319 if (p == eap->cmd && vim_strchr((char_u *)"@*!=><&~#", *p) != NULL) |
3320 ++p; | |
3321 len = (int)(p - eap->cmd); | |
167 | 3322 if (*eap->cmd == 'd' && (p[-1] == 'l' || p[-1] == 'p')) |
3323 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3324 // 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
|
3325 // :delete with the 'l' flag. Same for 'p'. |
167 | 3326 for (i = 0; i < len; ++i) |
1872 | 3327 if (eap->cmd[i] != ((char_u *)"delete")[i]) |
167 | 3328 break; |
3329 if (i == len - 1) | |
3330 { | |
3331 --len; | |
3332 if (p[-1] == 'l') | |
3333 eap->flags |= EXFLAG_LIST; | |
3334 else | |
3335 eap->flags |= EXFLAG_PRINT; | |
3336 } | |
3337 } | |
7 | 3338 |
11236
62c96fee518e
patch 8.0.0504: looking up an Ex command is a bit slow
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
3339 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
|
3340 { |
11240
06307d812ca7
patch 8.0.0506: can't build with ANSI C
Christian Brabandt <cb@256bit.org>
parents:
11236
diff
changeset
|
3341 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
|
3342 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
|
3343 |
11236
62c96fee518e
patch 8.0.0504: looking up an Ex command is a bit slow
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
3344 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
|
3345 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
3346 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
|
3347 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
|
3348 } |
62c96fee518e
patch 8.0.0504: looking up an Ex command is a bit slow
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
3349 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3350 // 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
|
3351 // 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
|
3352 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
|
3353 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
|
3354 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
|
3355 } |
20075
516b10943fdb
patch 8.2.0593: finding a user command is not optimal
Bram Moolenaar <Bram@vim.org>
parents:
20063
diff
changeset
|
3356 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
|
3357 eap->cmdidx = CMD_Next; |
7 | 3358 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
|
3359 eap->cmdidx = CMD_bang; |
7 | 3360 |
3361 for ( ; (int)eap->cmdidx < (int)CMD_SIZE; | |
3362 eap->cmdidx = (cmdidx_T)((int)eap->cmdidx + 1)) | |
3363 if (STRNCMP(cmdnames[(int)eap->cmdidx].cmd_name, (char *)eap->cmd, | |
3364 (size_t)len) == 0) | |
3365 { | |
3366 #ifdef FEAT_EVAL | |
3367 if (full != NULL | |
3368 && cmdnames[(int)eap->cmdidx].cmd_name[len] == NUL) | |
3369 *full = TRUE; | |
3370 #endif | |
3371 break; | |
3372 } | |
3373 | |
16411
5b5c5daf57de
patch 8.1.1210: support for user commands is spread out
Bram Moolenaar <Bram@vim.org>
parents:
16399
diff
changeset
|
3374 // 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
|
3375 // overruled by a user defined command. |
2633 | 3376 if ((eap->cmdidx == CMD_SIZE || eap->cmdidx == CMD_Print) |
3377 && *eap->cmd >= 'A' && *eap->cmd <= 'Z') | |
7 | 3378 { |
16411
5b5c5daf57de
patch 8.1.1210: support for user commands is spread out
Bram Moolenaar <Bram@vim.org>
parents:
16399
diff
changeset
|
3379 // User defined commands may contain digits. |
7 | 3380 while (ASCII_ISALNUM(*p)) |
3381 ++p; | |
184 | 3382 p = find_ucmd(eap, p, full, NULL, NULL); |
3383 } | |
3384 if (p == eap->cmd) | |
7 | 3385 eap->cmdidx = CMD_SIZE; |
3386 } | |
3387 | |
3388 return p; | |
3389 } | |
3390 | |
3391 #if defined(FEAT_EVAL) || defined(PROTO) | |
1447 | 3392 static struct cmdmod |
3393 { | |
3394 char *name; | |
3395 int minlen; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3396 int has_count; // :123verbose :3tab |
1447 | 3397 } cmdmods[] = { |
3398 {"aboveleft", 3, FALSE}, | |
3399 {"belowright", 3, FALSE}, | |
3400 {"botright", 2, FALSE}, | |
3401 {"browse", 3, FALSE}, | |
3402 {"confirm", 4, FALSE}, | |
9941
e975914c17e9
commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
9927
diff
changeset
|
3403 {"filter", 4, FALSE}, |
1447 | 3404 {"hide", 3, FALSE}, |
3405 {"keepalt", 5, FALSE}, | |
3406 {"keepjumps", 5, FALSE}, | |
3407 {"keepmarks", 3, FALSE}, | |
5467 | 3408 {"keeppatterns", 5, FALSE}, |
1447 | 3409 {"leftabove", 5, FALSE}, |
3410 {"lockmarks", 3, FALSE}, | |
1721 | 3411 {"noautocmd", 3, FALSE}, |
5737 | 3412 {"noswapfile", 3, FALSE}, |
1447 | 3413 {"rightbelow", 6, FALSE}, |
3414 {"sandbox", 3, FALSE}, | |
3415 {"silent", 3, FALSE}, | |
3416 {"tab", 3, TRUE}, | |
3417 {"topleft", 2, FALSE}, | |
1926 | 3418 {"unsilent", 3, FALSE}, |
1447 | 3419 {"verbose", 4, TRUE}, |
3420 {"vertical", 4, FALSE}, | |
3421 }; | |
3422 | |
3423 /* | |
3424 * Return length of a command modifier (including optional count). | |
3425 * Return zero when it's not a modifier. | |
3426 */ | |
3427 int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3428 modifier_len(char_u *cmd) |
1447 | 3429 { |
3430 int i, j; | |
3431 char_u *p = cmd; | |
3432 | |
3433 if (VIM_ISDIGIT(*cmd)) | |
3434 p = skipwhite(skipdigits(cmd)); | |
1880 | 3435 for (i = 0; i < (int)(sizeof(cmdmods) / sizeof(struct cmdmod)); ++i) |
1447 | 3436 { |
3437 for (j = 0; p[j] != NUL; ++j) | |
3438 if (p[j] != cmdmods[i].name[j]) | |
3439 break; | |
4857
84a8d1ba81c3
updated for version 7.3.1175
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3440 if (!ASCII_ISALPHA(p[j]) && j >= cmdmods[i].minlen |
1447 | 3441 && (p == cmd || cmdmods[i].has_count)) |
1570 | 3442 return j + (int)(p - cmd); |
1447 | 3443 } |
3444 return 0; | |
3445 } | |
3446 | |
7 | 3447 /* |
3448 * Return > 0 if an Ex command "name" exists. | |
3449 * Return 2 if there is an exact match. | |
3450 * Return 3 if there is an ambiguous match. | |
3451 */ | |
3452 int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3453 cmd_exists(char_u *name) |
7 | 3454 { |
3455 exarg_T ea; | |
3456 int full = FALSE; | |
3457 int i; | |
3458 int j; | |
866 | 3459 char_u *p; |
7 | 3460 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3461 // Check command modifiers. |
1880 | 3462 for (i = 0; i < (int)(sizeof(cmdmods) / sizeof(struct cmdmod)); ++i) |
7 | 3463 { |
3464 for (j = 0; name[j] != NUL; ++j) | |
3465 if (name[j] != cmdmods[i].name[j]) | |
3466 break; | |
3467 if (name[j] == NUL && j >= cmdmods[i].minlen) | |
3468 return (cmdmods[i].name[j] == NUL ? 2 : 1); | |
3469 } | |
3470 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3471 // 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
|
3472 // For ":2match" and ":3match" we need to skip the number. |
862 | 3473 ea.cmd = (*name == '2' || *name == '3') ? name + 1 : name; |
7 | 3474 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
|
3475 p = find_ex_command(&ea, &full, NULL, NULL); |
866 | 3476 if (p == NULL) |
7 | 3477 return 3; |
862 | 3478 if (vim_isdigit(*name) && ea.cmdidx != CMD_match) |
3479 return 0; | |
866 | 3480 if (*skipwhite(p) != NUL) |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3481 return 0; // trailing garbage |
7 | 3482 return (ea.cmdidx == CMD_SIZE ? 0 : (full ? 2 : 1)); |
3483 } | |
3484 #endif | |
3485 | |
17835
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17823
diff
changeset
|
3486 cmdidx_T |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17823
diff
changeset
|
3487 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
|
3488 { |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17823
diff
changeset
|
3489 cmdidx_T idx; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17823
diff
changeset
|
3490 |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17823
diff
changeset
|
3491 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
|
3492 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
|
3493 if (STRNCMP(cmdnames[(int)idx].cmd_name, cmd, (size_t)len) == 0) |
7 | 3494 break; |
3495 | |
17835
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17823
diff
changeset
|
3496 return idx; |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17823
diff
changeset
|
3497 } |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17823
diff
changeset
|
3498 |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17823
diff
changeset
|
3499 long |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17823
diff
changeset
|
3500 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
|
3501 { |
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17823
diff
changeset
|
3502 return (long)cmdnames[(int)idx].cmd_argt; |
7 | 3503 } |
3504 | |
3505 /* | |
14505
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3506 * Skip a range specifier of the form: addr [,addr] [;addr] .. |
7 | 3507 * |
3508 * Backslashed delimiters after / or ? will be skipped, and commands will | |
3509 * not be expanded between /'s and ?'s or after "'". | |
3510 * | |
20982
bb49b5090a9c
patch 8.2.1042: Vim9: cannot put an operator on the next line
Bram Moolenaar <Bram@vim.org>
parents:
20897
diff
changeset
|
3511 * Also skip white space and ":" characters after the range. |
7 | 3512 * Returns the "cmd" pointer advanced to beyond the range. |
3513 */ | |
3514 char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3515 skip_range( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3516 char_u *cmd, |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3517 int *ctx) // pointer to xp_context or NULL |
7 | 3518 { |
1872 | 3519 unsigned delim; |
7 | 3520 |
10817
cc8079703414
patch 8.0.0298: Ex command range with repeated search does not work
Christian Brabandt <cb@256bit.org>
parents:
10809
diff
changeset
|
3521 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
|
3522 { |
cc8079703414
patch 8.0.0298: Ex command range with repeated search does not work
Christian Brabandt <cb@256bit.org>
parents:
10809
diff
changeset
|
3523 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
|
3524 { |
cc8079703414
patch 8.0.0298: Ex command range with repeated search does not work
Christian Brabandt <cb@256bit.org>
parents:
10809
diff
changeset
|
3525 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
|
3526 ++cmd; |
cc8079703414
patch 8.0.0298: Ex command range with repeated search does not work
Christian Brabandt <cb@256bit.org>
parents:
10809
diff
changeset
|
3527 else |
cc8079703414
patch 8.0.0298: Ex command range with repeated search does not work
Christian Brabandt <cb@256bit.org>
parents:
10809
diff
changeset
|
3528 break; |
cc8079703414
patch 8.0.0298: Ex command range with repeated search does not work
Christian Brabandt <cb@256bit.org>
parents:
10809
diff
changeset
|
3529 } |
cc8079703414
patch 8.0.0298: Ex command range with repeated search does not work
Christian Brabandt <cb@256bit.org>
parents:
10809
diff
changeset
|
3530 else if (*cmd == '\'') |
7 | 3531 { |
3532 if (*++cmd == NUL && ctx != NULL) | |
3533 *ctx = EXPAND_NOTHING; | |
3534 } | |
3535 else if (*cmd == '/' || *cmd == '?') | |
3536 { | |
3537 delim = *cmd++; | |
3538 while (*cmd != NUL && *cmd != delim) | |
3539 if (*cmd++ == '\\' && *cmd != NUL) | |
3540 ++cmd; | |
3541 if (*cmd == NUL && ctx != NULL) | |
3542 *ctx = EXPAND_NOTHING; | |
3543 } | |
3544 if (*cmd != NUL) | |
3545 ++cmd; | |
3546 } | |
167 | 3547 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3548 // Skip ":" and white space. |
167 | 3549 while (*cmd == ':') |
3550 cmd = skipwhite(cmd + 1); | |
3551 | |
7 | 3552 return cmd; |
3553 } | |
3554 | |
17650
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
3555 static void |
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
3556 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
|
3557 { |
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
3558 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
|
3559 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
|
3560 else |
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
3561 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
|
3562 } |
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
3563 |
7 | 3564 /* |
14677
7771a1ff8b99
patch 8.1.0351: 'incsearch' for :/foo/s//<Esc> changes last search pattern
Christian Brabandt <cb@256bit.org>
parents:
14648
diff
changeset
|
3565 * Get a single EX address. |
7 | 3566 * |
3567 * Set ptr to the next character after the part that was interpreted. | |
3568 * 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
|
3569 * This may set the last used search pattern. |
7 | 3570 * |
3571 * Return MAXLNUM when no Ex address was found. | |
3572 */ | |
3573 static linenr_T | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3574 get_address( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3575 exarg_T *eap UNUSED, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3576 char_u **ptr, |
18849
b77ef4b8af7c
patch 8.1.2411: function argument copied unnecessarily
Bram Moolenaar <Bram@vim.org>
parents:
18779
diff
changeset
|
3577 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
|
3578 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
|
3579 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
|
3580 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
|
3581 int address_count UNUSED) // 1 for first address, >1 after comma |
7 | 3582 { |
3583 int c; | |
3584 int i; | |
3585 long n; | |
3586 char_u *cmd; | |
3587 pos_T pos; | |
3588 pos_T *fp; | |
3589 linenr_T lnum; | |
6424 | 3590 buf_T *buf; |
7 | 3591 |
3592 cmd = skipwhite(*ptr); | |
3593 lnum = MAXLNUM; | |
3594 do | |
3595 { | |
3596 switch (*cmd) | |
3597 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3598 case '.': // '.' - Cursor position |
6398 | 3599 ++cmd; |
3600 switch (addr_type) | |
3601 { | |
3602 case ADDR_LINES: | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
3603 case ADDR_OTHER: |
7 | 3604 lnum = curwin->w_cursor.lnum; |
3605 break; | |
6398 | 3606 case ADDR_WINDOWS: |
6409 | 3607 lnum = CURRENT_WIN_NR; |
6398 | 3608 break; |
3609 case ADDR_ARGUMENTS: | |
3610 lnum = curwin->w_arg_idx + 1; | |
3611 break; | |
3612 case ADDR_LOADED_BUFFERS: | |
6424 | 3613 case ADDR_BUFFERS: |
6398 | 3614 lnum = curbuf->b_fnum; |
3615 break; | |
3616 case ADDR_TABS: | |
6409 | 3617 lnum = CURRENT_TAB_NR; |
6398 | 3618 break; |
17650
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
3619 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
|
3620 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
|
3621 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
|
3622 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
|
3623 cmd = NULL; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
3624 goto error; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
3625 break; |
16479
7dcf301d1432
patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents:
16475
diff
changeset
|
3626 case ADDR_QUICKFIX: |
7105
f4456e686406
commit https://github.com/vim/vim/commit/e906c502079770ae0e0071c74cefb802689ff193
Christian Brabandt <cb@256bit.org>
parents:
7092
diff
changeset
|
3627 #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
|
3628 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
|
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; |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
3631 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
|
3632 #ifdef FEAT_QUICKFIX |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
3633 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
|
3634 #endif |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
3635 break; |
6398 | 3636 } |
3637 break; | |
7 | 3638 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3639 case '$': // '$' - last line |
6398 | 3640 ++cmd; |
3641 switch (addr_type) | |
3642 { | |
3643 case ADDR_LINES: | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
3644 case ADDR_OTHER: |
7 | 3645 lnum = curbuf->b_ml.ml_line_count; |
3646 break; | |
6398 | 3647 case ADDR_WINDOWS: |
6409 | 3648 lnum = LAST_WIN_NR; |
6398 | 3649 break; |
3650 case ADDR_ARGUMENTS: | |
3651 lnum = ARGCOUNT; | |
3652 break; | |
3653 case ADDR_LOADED_BUFFERS: | |
6424 | 3654 buf = lastbuf; |
3655 while (buf->b_ml.ml_mfp == NULL) | |
3656 { | |
3657 if (buf->b_prev == NULL) | |
3658 break; | |
3659 buf = buf->b_prev; | |
3660 } | |
3661 lnum = buf->b_fnum; | |
3662 break; | |
3663 case ADDR_BUFFERS: | |
6398 | 3664 lnum = lastbuf->b_fnum; |
3665 break; | |
3666 case ADDR_TABS: | |
6409 | 3667 lnum = LAST_TAB_NR; |
6398 | 3668 break; |
17650
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
3669 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
|
3670 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
|
3671 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
|
3672 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
|
3673 cmd = NULL; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
3674 goto error; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
3675 break; |
16479
7dcf301d1432
patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents:
16475
diff
changeset
|
3676 case ADDR_QUICKFIX: |
7105
f4456e686406
commit https://github.com/vim/vim/commit/e906c502079770ae0e0071c74cefb802689ff193
Christian Brabandt <cb@256bit.org>
parents:
7092
diff
changeset
|
3677 #ifdef FEAT_QUICKFIX |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
3678 lnum = qf_get_size(eap); |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
3679 if (lnum == 0) |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
3680 lnum = 1; |
16479
7dcf301d1432
patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents:
16475
diff
changeset
|
3681 #endif |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
3682 break; |
16515
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
3683 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
|
3684 #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
|
3685 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
|
3686 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
|
3687 lnum = 1; |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
3688 #endif |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
3689 break; |
6398 | 3690 } |
3691 break; | |
7 | 3692 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3693 case '\'': // ''' - mark |
6398 | 3694 if (*++cmd == NUL) |
3695 { | |
3696 cmd = NULL; | |
3697 goto error; | |
3698 } | |
3699 if (addr_type != ADDR_LINES) | |
3700 { | |
17650
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
3701 addr_error(addr_type); |
6581 | 3702 cmd = NULL; |
6398 | 3703 goto error; |
3704 } | |
3705 if (skip) | |
3706 ++cmd; | |
3707 else | |
3708 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3709 // 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
|
3710 // used by itself: ":'M". |
6398 | 3711 fp = getmark(*cmd, to_other_file && cmd[1] == NUL); |
3712 ++cmd; | |
3713 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
|
3714 // Jumped to another file. |
6398 | 3715 lnum = curwin->w_cursor.lnum; |
3716 else | |
3717 { | |
3718 if (check_mark(fp) == FAIL) | |
7 | 3719 { |
3720 cmd = NULL; | |
3721 goto error; | |
3722 } | |
6398 | 3723 lnum = fp->lnum; |
3724 } | |
3725 } | |
3726 break; | |
7 | 3727 |
3728 case '/': | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3729 case '?': // '/' or '?' - search |
6398 | 3730 c = *cmd++; |
3731 if (addr_type != ADDR_LINES) | |
3732 { | |
17650
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
3733 addr_error(addr_type); |
6581 | 3734 cmd = NULL; |
6398 | 3735 goto error; |
3736 } | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3737 if (skip) // skip "/pat/" |
6398 | 3738 { |
19892
5feb426d2ea1
patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19685
diff
changeset
|
3739 cmd = skip_regexp(cmd, c, (int)p_magic); |
6398 | 3740 if (*cmd == c) |
3741 ++cmd; | |
3742 } | |
3743 else | |
3744 { | |
14760
fd69edd2c67e
patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents:
14700
diff
changeset
|
3745 int flags; |
fd69edd2c67e
patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents:
14700
diff
changeset
|
3746 |
fd69edd2c67e
patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents:
14700
diff
changeset
|
3747 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
|
3748 |
fd69edd2c67e
patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents:
14700
diff
changeset
|
3749 // 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
|
3750 // there. |
6398 | 3751 if (lnum != MAXLNUM) |
3752 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
|
3753 |
fd69edd2c67e
patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents:
14700
diff
changeset
|
3754 // 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
|
3755 // 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
|
3756 // 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
|
3757 // 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
|
3758 // 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
|
3759 // next/previous line. |
13082
a80082fd1a1d
patch 8.0.1416: crash when searching for a sentence
Christian Brabandt <cb@256bit.org>
parents:
12824
diff
changeset
|
3760 if (c == '/' && curwin->w_cursor.lnum > 0) |
6398 | 3761 curwin->w_cursor.col = MAXCOL; |
3762 else | |
3763 curwin->w_cursor.col = 0; | |
3764 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
|
3765 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
|
3766 if (!do_search(NULL, c, c, cmd, 1L, flags, NULL)) |
6398 | 3767 { |
3768 curwin->w_cursor = pos; | |
3769 cmd = NULL; | |
3770 goto error; | |
3771 } | |
3772 lnum = curwin->w_cursor.lnum; | |
3773 curwin->w_cursor = pos; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3774 // adjust command string pointer |
6398 | 3775 cmd += searchcmdlen; |
3776 } | |
3777 break; | |
7 | 3778 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3779 case '\\': // "\?", "\/" or "\&", repeat search |
6398 | 3780 ++cmd; |
3781 if (addr_type != ADDR_LINES) | |
3782 { | |
17650
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
3783 addr_error(addr_type); |
6581 | 3784 cmd = NULL; |
6398 | 3785 goto error; |
3786 } | |
3787 if (*cmd == '&') | |
3788 i = RE_SUBST; | |
3789 else if (*cmd == '?' || *cmd == '/') | |
3790 i = RE_SEARCH; | |
3791 else | |
3792 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
3793 emsg(_(e_backslash)); |
6398 | 3794 cmd = NULL; |
3795 goto error; | |
3796 } | |
3797 | |
3798 if (!skip) | |
3799 { | |
3800 /* | |
3801 * When search follows another address, start from | |
3802 * there. | |
3803 */ | |
3804 if (lnum != MAXLNUM) | |
3805 pos.lnum = lnum; | |
3806 else | |
3807 pos.lnum = curwin->w_cursor.lnum; | |
3808 | |
3809 /* | |
3810 * Start the search just like for the above | |
3811 * do_search(). | |
3812 */ | |
3813 if (*cmd != '?') | |
3814 pos.col = MAXCOL; | |
3815 else | |
3816 pos.col = 0; | |
7007 | 3817 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
|
3818 if (searchit(curwin, curbuf, &pos, NULL, |
6398 | 3819 *cmd == '?' ? BACKWARD : FORWARD, |
18358
34d5cd432cac
patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents:
18297
diff
changeset
|
3820 (char_u *)"", 1L, SEARCH_MSG, i, NULL) != FAIL) |
6398 | 3821 lnum = pos.lnum; |
3822 else | |
3823 { | |
3824 cmd = NULL; | |
3825 goto error; | |
3826 } | |
3827 } | |
3828 ++cmd; | |
3829 break; | |
7 | 3830 |
3831 default: | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3832 if (VIM_ISDIGIT(*cmd)) // absolute line number |
6398 | 3833 lnum = getdigits(&cmd); |
7 | 3834 } |
3835 | |
3836 for (;;) | |
3837 { | |
3838 cmd = skipwhite(cmd); | |
3839 if (*cmd != '-' && *cmd != '+' && !VIM_ISDIGIT(*cmd)) | |
3840 break; | |
3841 | |
3842 if (lnum == MAXLNUM) | |
6398 | 3843 { |
3844 switch (addr_type) | |
3845 { | |
3846 case ADDR_LINES: | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
3847 case ADDR_OTHER: |
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
3848 // "+1" is same as ".+1" |
6409 | 3849 lnum = curwin->w_cursor.lnum; |
6398 | 3850 break; |
3851 case ADDR_WINDOWS: | |
6409 | 3852 lnum = CURRENT_WIN_NR; |
6398 | 3853 break; |
3854 case ADDR_ARGUMENTS: | |
3855 lnum = curwin->w_arg_idx + 1; | |
3856 break; | |
3857 case ADDR_LOADED_BUFFERS: | |
6424 | 3858 case ADDR_BUFFERS: |
6398 | 3859 lnum = curbuf->b_fnum; |
3860 break; | |
3861 case ADDR_TABS: | |
6409 | 3862 lnum = CURRENT_TAB_NR; |
6398 | 3863 break; |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
3864 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
|
3865 lnum = 1; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
3866 break; |
16479
7dcf301d1432
patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents:
16475
diff
changeset
|
3867 case ADDR_QUICKFIX: |
7105
f4456e686406
commit https://github.com/vim/vim/commit/e906c502079770ae0e0071c74cefb802689ff193
Christian Brabandt <cb@256bit.org>
parents:
7092
diff
changeset
|
3868 #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
|
3869 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
|
3870 #endif |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
3871 break; |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
3872 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
|
3873 #ifdef FEAT_QUICKFIX |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
3874 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
|
3875 #endif |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
3876 break; |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
3877 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
|
3878 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
|
3879 lnum = 0; |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
3880 break; |
6398 | 3881 } |
3882 } | |
3883 | |
7 | 3884 if (VIM_ISDIGIT(*cmd)) |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3885 i = '+'; // "number" is same as "+number" |
7 | 3886 else |
3887 i = *cmd++; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3888 if (!VIM_ISDIGIT(*cmd)) // '+' is '+1', but '+0' is not '+1' |
7 | 3889 n = 1; |
3890 else | |
3891 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
|
3892 |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
3893 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
|
3894 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
3895 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
|
3896 cmd = NULL; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
3897 goto error; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
3898 } |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
3899 else if (addr_type == ADDR_LOADED_BUFFERS |
6424 | 3900 || addr_type == ADDR_BUFFERS) |
6581 | 3901 lnum = compute_buffer_local_count( |
3902 addr_type, lnum, (i == '-') ? -1 * n : n); | |
7 | 3903 else |
10484
c7de1536780a
commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
10480
diff
changeset
|
3904 { |
c7de1536780a
commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
10480
diff
changeset
|
3905 #ifdef FEAT_FOLDING |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3906 // 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
|
3907 // 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
|
3908 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
|
3909 && address_count >= 2) |
c7de1536780a
commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
10480
diff
changeset
|
3910 (void)hasFolding(lnum, NULL, &lnum); |
c7de1536780a
commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
10480
diff
changeset
|
3911 #endif |
c7de1536780a
commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
10480
diff
changeset
|
3912 if (i == '-') |
c7de1536780a
commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
10480
diff
changeset
|
3913 lnum -= n; |
c7de1536780a
commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
10480
diff
changeset
|
3914 else |
c7de1536780a
commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
10480
diff
changeset
|
3915 lnum += n; |
c7de1536780a
commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
10480
diff
changeset
|
3916 } |
7 | 3917 } |
3918 } while (*cmd == '/' || *cmd == '?'); | |
3919 | |
3920 error: | |
3921 *ptr = cmd; | |
3922 return lnum; | |
3923 } | |
3924 | |
3925 /* | |
167 | 3926 * Get flags from an Ex command argument. |
3927 */ | |
3928 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3929 get_flags(exarg_T *eap) |
167 | 3930 { |
3931 while (vim_strchr((char_u *)"lp#", *eap->arg) != NULL) | |
3932 { | |
3933 if (*eap->arg == 'l') | |
3934 eap->flags |= EXFLAG_LIST; | |
3935 else if (*eap->arg == 'p') | |
3936 eap->flags |= EXFLAG_PRINT; | |
3937 else | |
3938 eap->flags |= EXFLAG_NR; | |
3939 eap->arg = skipwhite(eap->arg + 1); | |
3940 } | |
3941 } | |
3942 | |
3943 /* | |
7 | 3944 * Function called for command which is Not Implemented. NI! |
3945 */ | |
3946 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3947 ex_ni(exarg_T *eap) |
7 | 3948 { |
3949 if (!eap->skip) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
3950 eap->errmsg = N_("E319: Sorry, the command is not available in this version"); |
7 | 3951 } |
3952 | |
1315 | 3953 #ifdef HAVE_EX_SCRIPT_NI |
7 | 3954 /* |
3955 * Function called for script command which is Not Implemented. NI! | |
3956 * Skips over ":perl <<EOF" constructs. | |
3957 */ | |
3958 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3959 ex_script_ni(exarg_T *eap) |
7 | 3960 { |
3961 if (!eap->skip) | |
3962 ex_ni(eap); | |
3963 else | |
3964 vim_free(script_get(eap, eap->arg)); | |
3965 } | |
3966 #endif | |
3967 | |
3968 /* | |
3969 * Check range in Ex command for validity. | |
3970 * Return NULL when valid, error message when invalid. | |
3971 */ | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
3972 static char * |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3973 invalid_range(exarg_T *eap) |
7 | 3974 { |
6472 | 3975 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
|
3976 |
7 | 3977 if ( eap->line1 < 0 |
3978 || eap->line2 < 0 | |
6472 | 3979 || 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
|
3980 return _(e_invrange); |
6472 | 3981 |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
3982 if (eap->argt & EX_RANGE) |
6472 | 3983 { |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
3984 switch (eap->addr_type) |
6472 | 3985 { |
3986 case ADDR_LINES: | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
3987 if (eap->line2 > curbuf->b_ml.ml_line_count |
7 | 3988 #ifdef FEAT_DIFF |
6472 | 3989 + (eap->cmdidx == CMD_diffget) |
3990 #endif | |
3991 ) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
3992 return _(e_invrange); |
6472 | 3993 break; |
3994 case ADDR_ARGUMENTS: | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
3995 // add 1 if ARGCOUNT is 0 |
6581 | 3996 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
|
3997 return _(e_invrange); |
6472 | 3998 break; |
3999 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
|
4000 // 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
|
4001 // exist. |
7e6b7a4f13bc
patch 8.1.1908: every popup window consumes a buffer number
Bram Moolenaar <Bram@vim.org>
parents:
17817
diff
changeset
|
4002 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
|
4003 return _(e_invrange); |
6472 | 4004 break; |
4005 case ADDR_LOADED_BUFFERS: | |
4006 buf = firstbuf; | |
4007 while (buf->b_ml.ml_mfp == NULL) | |
4008 { | |
4009 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
|
4010 return _(e_invrange); |
6472 | 4011 buf = buf->b_next; |
4012 } | |
4013 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
|
4014 return _(e_invrange); |
6472 | 4015 buf = lastbuf; |
4016 while (buf->b_ml.ml_mfp == NULL) | |
4017 { | |
4018 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
|
4019 return _(e_invrange); |
6472 | 4020 buf = buf->b_prev; |
4021 } | |
4022 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
|
4023 return _(e_invrange); |
6472 | 4024 break; |
4025 case ADDR_WINDOWS: | |
6480 | 4026 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
|
4027 return _(e_invrange); |
6472 | 4028 break; |
4029 case ADDR_TABS: | |
4030 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
|
4031 return _(e_invrange); |
6472 | 4032 break; |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
4033 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
|
4034 case ADDR_OTHER: |
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
4035 // 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
|
4036 break; |
16479
7dcf301d1432
patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents:
16475
diff
changeset
|
4037 case ADDR_QUICKFIX: |
7105
f4456e686406
commit https://github.com/vim/vim/commit/e906c502079770ae0e0071c74cefb802689ff193
Christian Brabandt <cb@256bit.org>
parents:
7092
diff
changeset
|
4038 #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
|
4039 // 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
|
4040 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
|
4041 return _(e_invrange); |
16479
7dcf301d1432
patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents:
16475
diff
changeset
|
4042 #endif |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
4043 break; |
16515
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
4044 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
|
4045 #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
|
4046 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
|
4047 || 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
|
4048 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
|
4049 #endif |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
4050 break; |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
4051 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
|
4052 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
|
4053 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
|
4054 break; |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
4055 case ADDR_NONE: |
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
4056 // 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
|
4057 break; |
6472 | 4058 } |
4059 } | |
7 | 4060 return NULL; |
4061 } | |
4062 | |
4063 /* | |
4064 * Correct the range for zero line number, if required. | |
4065 */ | |
4066 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4067 correct_range(exarg_T *eap) |
7 | 4068 { |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
4069 if (!(eap->argt & EX_ZEROR)) // zero in range not allowed |
7 | 4070 { |
4071 if (eap->line1 == 0) | |
4072 eap->line1 = 1; | |
4073 if (eap->line2 == 0) | |
4074 eap->line2 = 1; | |
4075 } | |
4076 } | |
4077 | |
153 | 4078 #ifdef FEAT_QUICKFIX |
4079 /* | |
4080 * For a ":vimgrep" or ":vimgrepadd" command return a pointer past the | |
4081 * pattern. Otherwise return eap->arg. | |
4082 */ | |
4083 static char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4084 skip_grep_pat(exarg_T *eap) |
153 | 4085 { |
4086 char_u *p = eap->arg; | |
4087 | |
655 | 4088 if (*p != NUL && (eap->cmdidx == CMD_vimgrep || eap->cmdidx == CMD_lvimgrep |
4089 || eap->cmdidx == CMD_vimgrepadd | |
4090 || eap->cmdidx == CMD_lvimgrepadd | |
4091 || grep_internal(eap->cmdidx))) | |
153 | 4092 { |
170 | 4093 p = skip_vimgrep_pat(p, NULL, NULL); |
153 | 4094 if (p == NULL) |
4095 p = eap->arg; | |
4096 } | |
4097 return p; | |
4098 } | |
344 | 4099 |
4100 /* | |
4101 * For the ":make" and ":grep" commands insert the 'makeprg'/'grepprg' option | |
4102 * in the command line, so that things like % get expanded. | |
4103 */ | |
4104 static char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4105 replace_makeprg(exarg_T *eap, char_u *p, char_u **cmdlinep) |
344 | 4106 { |
4107 char_u *new_cmdline; | |
4108 char_u *program; | |
4109 char_u *pos; | |
4110 char_u *ptr; | |
4111 int len; | |
4112 int i; | |
4113 | |
4114 /* | |
4115 * Don't do it when ":vimgrep" is used for ":grep". | |
4116 */ | |
655 | 4117 if ((eap->cmdidx == CMD_make || eap->cmdidx == CMD_lmake |
4118 || eap->cmdidx == CMD_grep || eap->cmdidx == CMD_lgrep | |
4119 || eap->cmdidx == CMD_grepadd | |
4120 || eap->cmdidx == CMD_lgrepadd) | |
344 | 4121 && !grep_internal(eap->cmdidx)) |
4122 { | |
655 | 4123 if (eap->cmdidx == CMD_grep || eap->cmdidx == CMD_lgrep |
4124 || eap->cmdidx == CMD_grepadd || eap->cmdidx == CMD_lgrepadd) | |
344 | 4125 { |
4126 if (*curbuf->b_p_gp == NUL) | |
4127 program = p_gp; | |
4128 else | |
4129 program = curbuf->b_p_gp; | |
4130 } | |
4131 else | |
4132 { | |
4133 if (*curbuf->b_p_mp == NUL) | |
4134 program = p_mp; | |
4135 else | |
4136 program = curbuf->b_p_mp; | |
4137 } | |
4138 | |
4139 p = skipwhite(p); | |
4140 | |
4141 if ((pos = (char_u *)strstr((char *)program, "$*")) != NULL) | |
4142 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4143 // replace $* by given arguments |
344 | 4144 i = 1; |
4145 while ((pos = (char_u *)strstr((char *)pos + 2, "$*")) != NULL) | |
4146 ++i; | |
4147 len = (int)STRLEN(p); | |
16782
fc58fee685e2
patch 8.1.1393: unnecessary type casts
Bram Moolenaar <Bram@vim.org>
parents:
16780
diff
changeset
|
4148 new_cmdline = alloc(STRLEN(program) + i * (len - 2) + 1); |
344 | 4149 if (new_cmdline == NULL) |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4150 return NULL; // out of memory |
344 | 4151 ptr = new_cmdline; |
4152 while ((pos = (char_u *)strstr((char *)program, "$*")) != NULL) | |
4153 { | |
4154 i = (int)(pos - program); | |
4155 STRNCPY(ptr, program, i); | |
4156 STRCPY(ptr += i, p); | |
4157 ptr += len; | |
4158 program = pos + 2; | |
4159 } | |
4160 STRCPY(ptr, program); | |
4161 } | |
4162 else | |
4163 { | |
16782
fc58fee685e2
patch 8.1.1393: unnecessary type casts
Bram Moolenaar <Bram@vim.org>
parents:
16780
diff
changeset
|
4164 new_cmdline = alloc(STRLEN(program) + STRLEN(p) + 2); |
344 | 4165 if (new_cmdline == NULL) |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4166 return NULL; // out of memory |
344 | 4167 STRCPY(new_cmdline, program); |
4168 STRCAT(new_cmdline, " "); | |
4169 STRCAT(new_cmdline, p); | |
4170 } | |
4171 msg_make(p); | |
4172 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4173 // 'eap->cmd' is not set here, because it is not used at CMD_make |
344 | 4174 vim_free(*cmdlinep); |
4175 *cmdlinep = new_cmdline; | |
4176 p = new_cmdline; | |
4177 } | |
4178 return p; | |
4179 } | |
153 | 4180 #endif |
4181 | |
7 | 4182 /* |
4183 * 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
|
4184 * When an error is detected, "errormsgp" is set to a non-NULL pointer. |
7 | 4185 * Return FAIL for failure, OK otherwise. |
4186 */ | |
4187 int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4188 expand_filename( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4189 exarg_T *eap, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4190 char_u **cmdlinep, |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
4191 char **errormsgp) |
7 | 4192 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4193 int has_wildcards; // need to expand wildcards |
7 | 4194 char_u *repl; |
4195 int srclen; | |
4196 char_u *p; | |
4197 int n; | |
1098 | 4198 int escaped; |
7 | 4199 |
153 | 4200 #ifdef FEAT_QUICKFIX |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4201 // Skip a regexp pattern for ":vimgrep[add] pat file..." |
153 | 4202 p = skip_grep_pat(eap); |
4203 #else | |
4204 p = eap->arg; | |
4205 #endif | |
4206 | |
7 | 4207 /* |
4208 * Decide to expand wildcards *before* replacing '%', '#', etc. If | |
4209 * the file name contains a wildcard it should not cause expanding. | |
4210 * (it will be expanded anyway if there is a wildcard before replacing). | |
4211 */ | |
153 | 4212 has_wildcards = mch_has_wildcard(p); |
4213 while (*p != NUL) | |
7 | 4214 { |
9 | 4215 #ifdef FEAT_EVAL |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4216 // Skip over `=expr`, wildcards in it are not expanded. |
9 | 4217 if (p[0] == '`' && p[1] == '=') |
4218 { | |
4219 p += 2; | |
4220 (void)skip_expr(&p); | |
4221 if (*p == '`') | |
4222 ++p; | |
4223 continue; | |
4224 } | |
4225 #endif | |
7 | 4226 /* |
4227 * Quick check if this cannot be the start of a special string. | |
4228 * Also removes backslash before '%', '#' and '<'. | |
4229 */ | |
4230 if (vim_strchr((char_u *)"%#<", *p) == NULL) | |
4231 { | |
4232 ++p; | |
4233 continue; | |
4234 } | |
4235 | |
4236 /* | |
4237 * Try to find a match at this position. | |
4238 */ | |
1098 | 4239 repl = eval_vars(p, eap->arg, &srclen, &(eap->do_ecmd_lnum), |
4240 errormsgp, &escaped); | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4241 if (*errormsgp != NULL) // error detected |
7 | 4242 return FAIL; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4243 if (repl == NULL) // no match found |
7 | 4244 { |
4245 p += srclen; | |
4246 continue; | |
4247 } | |
4248 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4249 // 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
|
4250 // literally. But do expand "~/file", "~user/file" and "$HOME/file". |
37 | 4251 if (vim_strchr(repl, '$') != NULL || vim_strchr(repl, '~') != NULL) |
4252 { | |
4253 char_u *l = repl; | |
4254 | |
4255 repl = expand_env_save(repl); | |
4256 vim_free(l); | |
4257 } | |
4258 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4259 // 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
|
4260 // Don't do this for: |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4261 // - 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
|
4262 // - 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
|
4263 // - 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
|
4264 // separate arguments then). |
7 | 4265 if (!eap->usefilter |
1098 | 4266 && !escaped |
7 | 4267 && eap->cmdidx != CMD_bang |
4268 && 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
|
4269 && eap->cmdidx != CMD_grepadd |
1c1cb1e9b7b3
patch 8.0.0785: wildcards are not expanded for :terminal
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
4270 && eap->cmdidx != CMD_hardcopy |
655 | 4271 && eap->cmdidx != CMD_lgrep |
4272 && 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
|
4273 && eap->cmdidx != CMD_lmake |
1c1cb1e9b7b3
patch 8.0.0785: wildcards are not expanded for :terminal
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
4274 && eap->cmdidx != CMD_make |
1c1cb1e9b7b3
patch 8.0.0785: wildcards are not expanded for :terminal
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
4275 && eap->cmdidx != CMD_terminal |
7 | 4276 #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
|
4277 && !(eap->argt & EX_NOSPC) |
7 | 4278 #endif |
4279 ) | |
4280 { | |
4281 char_u *l; | |
4282 #ifdef BACKSLASH_IN_FILENAME | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4283 // 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
|
4284 // remove it later. |
7 | 4285 static char_u *nobslash = (char_u *)" \t\"|"; |
4286 # define ESCAPE_CHARS nobslash | |
4287 #else | |
4288 # define ESCAPE_CHARS escape_chars | |
4289 #endif | |
4290 | |
4291 for (l = repl; *l; ++l) | |
4292 if (vim_strchr(ESCAPE_CHARS, *l) != NULL) | |
4293 { | |
4294 l = vim_strsave_escaped(repl, ESCAPE_CHARS); | |
4295 if (l != NULL) | |
4296 { | |
4297 vim_free(repl); | |
4298 repl = l; | |
4299 } | |
4300 break; | |
4301 } | |
4302 } | |
4303 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4304 // 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
|
4305 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
|
4306 || eap->cmdidx == CMD_terminal) |
5778 | 4307 && vim_strpbrk(repl, (char_u *)"!") != NULL) |
7 | 4308 { |
4309 char_u *l; | |
4310 | |
5778 | 4311 l = vim_strsave_escaped(repl, (char_u *)"!"); |
7 | 4312 if (l != NULL) |
4313 { | |
4314 vim_free(repl); | |
4315 repl = l; | |
4316 } | |
4317 } | |
4318 | |
4319 p = repl_cmdline(eap, p, srclen, repl, cmdlinep); | |
4320 vim_free(repl); | |
4321 if (p == NULL) | |
4322 return FAIL; | |
4323 } | |
4324 | |
4325 /* | |
4326 * One file argument: Expand wildcards. | |
4327 * Don't do this with ":r !command" or ":w !command". | |
4328 */ | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
4329 if ((eap->argt & EX_NOSPC) && !eap->usefilter) |
7 | 4330 { |
4331 /* | |
4332 * May do this twice: | |
4333 * 1. Replace environment variables. | |
4334 * 2. Replace any other wildcards, remove backslashes. | |
4335 */ | |
4336 for (n = 1; n <= 2; ++n) | |
4337 { | |
4338 if (n == 2) | |
4339 { | |
4340 /* | |
4341 * Halve the number of backslashes (this is Vi compatible). | |
4342 * For Unix and OS/2, when wildcards are expanded, this is | |
4343 * done by ExpandOne() below. | |
4344 */ | |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7262
diff
changeset
|
4345 #if defined(UNIX) |
7 | 4346 if (!has_wildcards) |
4347 #endif | |
4348 backslash_halve(eap->arg); | |
4349 } | |
4350 | |
4351 if (has_wildcards) | |
4352 { | |
4353 if (n == 1) | |
4354 { | |
4355 /* | |
4356 * First loop: May expand environment variables. This | |
4357 * can be done much faster with expand_env() than with | |
4358 * something else (e.g., calling a shell). | |
4359 * After expanding environment variables, check again | |
4360 * if there are still wildcards present. | |
4361 */ | |
4362 if (vim_strchr(eap->arg, '$') != NULL | |
4363 || vim_strchr(eap->arg, '~') != NULL) | |
4364 { | |
372 | 4365 expand_env_esc(eap->arg, NameBuff, MAXPATHL, |
1408 | 4366 TRUE, TRUE, NULL); |
7 | 4367 has_wildcards = mch_has_wildcard(NameBuff); |
4368 p = NameBuff; | |
4369 } | |
4370 else | |
4371 p = NULL; | |
4372 } | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4373 else // n == 2 |
7 | 4374 { |
4375 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
|
4376 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
|
4377 | WILD_NOERROR | WILD_ADD_SLASH; |
7 | 4378 |
4379 ExpandInit(&xpc); | |
4380 xpc.xp_context = EXPAND_FILES; | |
2652 | 4381 if (p_wic) |
4382 options += WILD_ICASE; | |
7 | 4383 p = ExpandOne(&xpc, eap->arg, NULL, |
2652 | 4384 options, WILD_EXPAND_FREE); |
7 | 4385 if (p == NULL) |
4386 return FAIL; | |
4387 } | |
4388 if (p != NULL) | |
4389 { | |
4390 (void)repl_cmdline(eap, eap->arg, (int)STRLEN(eap->arg), | |
4391 p, cmdlinep); | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4392 if (n == 2) // p came from ExpandOne() |
7 | 4393 vim_free(p); |
4394 } | |
4395 } | |
4396 } | |
4397 } | |
4398 return OK; | |
4399 } | |
4400 | |
4401 /* | |
4402 * Replace part of the command line, keeping eap->cmd, eap->arg and | |
4403 * eap->nextcmd correct. | |
4404 * "src" points to the part that is to be replaced, of length "srclen". | |
4405 * "repl" is the replacement string. | |
4406 * Returns a pointer to the character after the replaced string. | |
4407 * Returns NULL for failure. | |
4408 */ | |
4409 static char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4410 repl_cmdline( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4411 exarg_T *eap, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4412 char_u *src, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4413 int srclen, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4414 char_u *repl, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4415 char_u **cmdlinep) |
7 | 4416 { |
4417 int len; | |
4418 int i; | |
4419 char_u *new_cmdline; | |
4420 | |
4421 /* | |
4422 * The new command line is build in new_cmdline[]. | |
4423 * First allocate it. | |
4424 * Careful: a "+cmd" argument may have been NUL terminated. | |
4425 */ | |
4426 len = (int)STRLEN(repl); | |
4427 i = (int)(src - *cmdlinep) + (int)STRLEN(src + srclen) + len + 3; | |
698 | 4428 if (eap->nextcmd != NULL) |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4429 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
|
4430 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
|
4431 return NULL; // out of memory! |
7 | 4432 |
4433 /* | |
4434 * Copy the stuff before the expanded part. | |
4435 * Copy the expanded stuff. | |
4436 * Copy what came after the expanded part. | |
4437 * Copy the next commands, if there are any. | |
4438 */ | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4439 i = (int)(src - *cmdlinep); // length of part before match |
7 | 4440 mch_memmove(new_cmdline, *cmdlinep, (size_t)i); |
434 | 4441 |
7 | 4442 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
|
4443 i += len; // remember the end of the string |
7 | 4444 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
|
4445 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
|
4446 |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4447 if (eap->nextcmd != NULL) // append next command |
7 | 4448 { |
4449 i = (int)STRLEN(new_cmdline) + 1; | |
4450 STRCPY(new_cmdline + i, eap->nextcmd); | |
4451 eap->nextcmd = new_cmdline + i; | |
4452 } | |
4453 eap->cmd = new_cmdline + (eap->cmd - *cmdlinep); | |
4454 eap->arg = new_cmdline + (eap->arg - *cmdlinep); | |
4455 if (eap->do_ecmd_cmd != NULL && eap->do_ecmd_cmd != dollar_command) | |
4456 eap->do_ecmd_cmd = new_cmdline + (eap->do_ecmd_cmd - *cmdlinep); | |
4457 vim_free(*cmdlinep); | |
4458 *cmdlinep = new_cmdline; | |
4459 | |
4460 return src; | |
4461 } | |
4462 | |
4463 /* | |
4464 * Check for '|' to separate commands and '"' to start comments. | |
4465 */ | |
4466 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4467 separate_nextcmd(exarg_T *eap) |
7 | 4468 { |
4469 char_u *p; | |
4470 | |
153 | 4471 #ifdef FEAT_QUICKFIX |
4472 p = skip_grep_pat(eap); | |
4473 #else | |
41 | 4474 p = eap->arg; |
4475 #endif | |
4476 | |
11127
506f5d8b7d8b
patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11010
diff
changeset
|
4477 for ( ; *p; MB_PTR_ADV(p)) |
7 | 4478 { |
4479 if (*p == Ctrl_V) | |
4480 { | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
4481 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
|
4482 ++p; // skip CTRL-V and next char |
7 | 4483 else |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4484 // remove CTRL-V and skip next char |
1619 | 4485 STRMOVE(p, p + 1); |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4486 if (*p == NUL) // stop at NUL after CTRL-V |
7 | 4487 break; |
4488 } | |
9 | 4489 |
4490 #ifdef FEAT_EVAL | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4491 // 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
|
4492 else if (p[0] == '`' && p[1] == '=' && (eap->argt & EX_XFILE)) |
9 | 4493 { |
4494 p += 2; | |
4495 (void)skip_expr(&p); | |
4496 } | |
4497 #endif | |
4498 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4499 // 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
|
4500 // :@" 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
|
4501 // :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
|
4502 else if ((*p == '"' && !(eap->argt & EX_NOTRLCOM) |
7 | 4503 && ((eap->cmdidx != CMD_at && eap->cmdidx != CMD_star) |
4504 || p != eap->arg) | |
4505 && (eap->cmdidx != CMD_redir | |
4506 || 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
|
4507 #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
|
4508 || (*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
|
4509 && 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
|
4510 #endif |
7 | 4511 || *p == '|' || *p == '\n') |
4512 { | |
4513 /* | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
4514 * We remove the '\' before the '|', unless EX_CTRLV is used |
7 | 4515 * AND 'b' is present in 'cpoptions'. |
4516 */ | |
4517 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
|
4518 || !(eap->argt & EX_CTRLV)) && *(p - 1) == '\\') |
7 | 4519 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4520 STRMOVE(p - 1, p); // remove the '\' |
7 | 4521 --p; |
4522 } | |
4523 else | |
4524 { | |
4525 eap->nextcmd = check_nextcmd(p); | |
4526 *p = NUL; | |
4527 break; | |
4528 } | |
4529 } | |
41 | 4530 } |
4531 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4532 if (!(eap->argt & EX_NOTRLCOM)) // remove trailing spaces |
7 | 4533 del_trailing_spaces(eap->arg); |
4534 } | |
4535 | |
4536 /* | |
4537 * get + command from ex argument | |
4538 */ | |
4539 static char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4540 getargcmd(char_u **argp) |
7 | 4541 { |
4542 char_u *arg = *argp; | |
4543 char_u *command = NULL; | |
4544 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4545 if (*arg == '+') // +[command] |
7 | 4546 { |
4547 ++arg; | |
5790 | 4548 if (vim_isspace(*arg) || *arg == NUL) |
7 | 4549 command = dollar_command; |
4550 else | |
4551 { | |
4552 command = arg; | |
4553 arg = skip_cmd_arg(command, TRUE); | |
4554 if (*arg != NUL) | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4555 *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
|
4556 } |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4557 |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4558 arg = skipwhite(arg); // skip over spaces |
7 | 4559 *argp = arg; |
4560 } | |
4561 return command; | |
4562 } | |
4563 | |
4564 /* | |
4565 * Find end of "+command" argument. Skip over "\ " and "\\". | |
4566 */ | |
17835
fd6c8dc33152
patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17823
diff
changeset
|
4567 char_u * |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4568 skip_cmd_arg( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4569 char_u *p, |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4570 int rembs) // TRUE to halve the number of backslashes |
7 | 4571 { |
4572 while (*p && !vim_isspace(*p)) | |
4573 { | |
4574 if (*p == '\\' && p[1] != NUL) | |
4575 { | |
4576 if (rembs) | |
1619 | 4577 STRMOVE(p, p + 1); |
7 | 4578 else |
4579 ++p; | |
4580 } | |
11127
506f5d8b7d8b
patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11010
diff
changeset
|
4581 MB_PTR_ADV(p); |
7 | 4582 } |
4583 return p; | |
4584 } | |
4585 | |
13575
4df23d9bad47
patch 8.0.1660: the terminal API "drop" command doesn't support options
Christian Brabandt <cb@256bit.org>
parents:
13553
diff
changeset
|
4586 int |
4df23d9bad47
patch 8.0.1660: the terminal API "drop" command doesn't support options
Christian Brabandt <cb@256bit.org>
parents:
13553
diff
changeset
|
4587 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
|
4588 { |
4df23d9bad47
patch 8.0.1660: the terminal API "drop" command doesn't support options
Christian Brabandt <cb@256bit.org>
parents:
13553
diff
changeset
|
4589 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
|
4590 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
|
4591 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
|
4592 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
|
4593 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
|
4594 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
|
4595 else |
c1ead25ed819
patch 8.1.0043: ++bad argument of :edit does not work properly
Christian Brabandt <cb@256bit.org>
parents:
14035
diff
changeset
|
4596 return FAIL; |
c1ead25ed819
patch 8.1.0043: ++bad argument of :edit does not work properly
Christian Brabandt <cb@256bit.org>
parents:
14035
diff
changeset
|
4597 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
|
4598 } |
4df23d9bad47
patch 8.0.1660: the terminal API "drop" command doesn't support options
Christian Brabandt <cb@256bit.org>
parents:
13553
diff
changeset
|
4599 |
7 | 4600 /* |
4601 * Get "++opt=arg" argument. | |
4602 * Return FAIL or OK. | |
4603 */ | |
4604 static int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4605 getargopt(exarg_T *eap) |
7 | 4606 { |
4607 char_u *arg = eap->arg + 2; | |
4608 int *pp = NULL; | |
2168 | 4609 int bad_char_idx; |
7 | 4610 char_u *p; |
4611 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4612 // ":edit ++[no]bin[ary] file" |
7 | 4613 if (STRNCMP(arg, "bin", 3) == 0 || STRNCMP(arg, "nobin", 5) == 0) |
4614 { | |
4615 if (*arg == 'n') | |
4616 { | |
4617 arg += 2; | |
4618 eap->force_bin = FORCE_NOBIN; | |
4619 } | |
4620 else | |
4621 eap->force_bin = FORCE_BIN; | |
4622 if (!checkforcmd(&arg, "binary", 3)) | |
4623 return FAIL; | |
4624 eap->arg = skipwhite(arg); | |
4625 return OK; | |
4626 } | |
4627 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4628 // ":read ++edit file" |
819 | 4629 if (STRNCMP(arg, "edit", 4) == 0) |
4630 { | |
4631 eap->read_edit = TRUE; | |
4632 eap->arg = skipwhite(arg + 4); | |
4633 return OK; | |
4634 } | |
4635 | |
7 | 4636 if (STRNCMP(arg, "ff", 2) == 0) |
4637 { | |
4638 arg += 2; | |
4639 pp = &eap->force_ff; | |
4640 } | |
4641 else if (STRNCMP(arg, "fileformat", 10) == 0) | |
4642 { | |
4643 arg += 10; | |
4644 pp = &eap->force_ff; | |
4645 } | |
4646 else if (STRNCMP(arg, "enc", 3) == 0) | |
4647 { | |
3208 | 4648 if (STRNCMP(arg, "encoding", 8) == 0) |
4649 arg += 8; | |
4650 else | |
4651 arg += 3; | |
7 | 4652 pp = &eap->force_enc; |
4653 } | |
595 | 4654 else if (STRNCMP(arg, "bad", 3) == 0) |
4655 { | |
4656 arg += 3; | |
2168 | 4657 pp = &bad_char_idx; |
595 | 4658 } |
7 | 4659 |
4660 if (pp == NULL || *arg != '=') | |
4661 return FAIL; | |
4662 | |
4663 ++arg; | |
4664 *pp = (int)(arg - eap->cmd); | |
4665 arg = skip_cmd_arg(arg, FALSE); | |
4666 eap->arg = skipwhite(arg); | |
4667 *arg = NUL; | |
4668 | |
4669 if (pp == &eap->force_ff) | |
4670 { | |
4671 if (check_ff_value(eap->cmd + eap->force_ff) == FAIL) | |
4672 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
|
4673 eap->force_ff = eap->cmd[eap->force_ff]; |
7 | 4674 } |
595 | 4675 else if (pp == &eap->force_enc) |
7 | 4676 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4677 // Make 'fileencoding' lower case. |
7 | 4678 for (p = eap->cmd + eap->force_enc; *p != NUL; ++p) |
4679 *p = TOLOWER_ASC(*p); | |
4680 } | |
595 | 4681 else |
4682 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4683 // 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
|
4684 // "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
|
4685 if (get_bad_opt(eap->cmd + bad_char_idx, eap) == FAIL) |
595 | 4686 return FAIL; |
4687 } | |
7 | 4688 |
4689 return OK; | |
4690 } | |
4691 | |
4692 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4693 ex_autocmd(exarg_T *eap) |
7 | 4694 { |
4695 /* | |
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
|
4696 * Disallow autocommands from .exrc and .vimrc in current |
7 | 4697 * directory for security reasons. |
4698 */ | |
4699 if (secure) | |
4700 { | |
4701 secure = 2; | |
4702 eap->errmsg = e_curdir; | |
4703 } | |
4704 else if (eap->cmdidx == CMD_autocmd) | |
4705 do_autocmd(eap->arg, eap->forceit); | |
4706 else | |
4707 do_augroup(eap->arg, eap->forceit); | |
4708 } | |
4709 | |
4710 /* | |
4711 * ":doautocmd": Apply the automatic commands to the current buffer. | |
4712 */ | |
4713 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4714 ex_doautocmd(exarg_T *eap) |
7 | 4715 { |
3350 | 4716 char_u *arg = eap->arg; |
4717 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
|
4718 int did_aucmd; |
ac8180818504
commit https://github.com/vim/vim/commit/1610d052413e0ed664498853a47acc2d677a22d1
Christian Brabandt <cb@256bit.org>
parents:
9230
diff
changeset
|
4719 |
ac8180818504
commit https://github.com/vim/vim/commit/1610d052413e0ed664498853a47acc2d677a22d1
Christian Brabandt <cb@256bit.org>
parents:
9230
diff
changeset
|
4720 (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
|
4721 // 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
|
4722 if (call_do_modelines && did_aucmd) |
3350 | 4723 do_modelines(0); |
7 | 4724 } |
4725 | |
4726 /* | |
4727 * :[N]bunload[!] [N] [bufname] unload buffer | |
4728 * :[N]bdelete[!] [N] [bufname] delete buffer from buffer list | |
4729 * :[N]bwipeout[!] [N] [bufname] delete buffer really | |
4730 */ | |
4731 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4732 ex_bunload(exarg_T *eap) |
7 | 4733 { |
19271
ebeeb4b4a1fa
patch 8.2.0194: some commands can cause problems in terminal popup
Bram Moolenaar <Bram@vim.org>
parents:
19261
diff
changeset
|
4734 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
|
4735 return; |
7 | 4736 eap->errmsg = do_bufdel( |
4737 eap->cmdidx == CMD_bdelete ? DOBUF_DEL | |
4738 : eap->cmdidx == CMD_bwipeout ? DOBUF_WIPE | |
4739 : DOBUF_UNLOAD, eap->arg, | |
4740 eap->addr_count, (int)eap->line1, (int)eap->line2, eap->forceit); | |
4741 } | |
4742 | |
4743 /* | |
4744 * :[N]buffer [N] to buffer N | |
4745 * :[N]sbuffer [N] to buffer N | |
4746 */ | |
4747 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4748 ex_buffer(exarg_T *eap) |
7 | 4749 { |
19271
ebeeb4b4a1fa
patch 8.2.0194: some commands can cause problems in terminal popup
Bram Moolenaar <Bram@vim.org>
parents:
19261
diff
changeset
|
4750 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
|
4751 return; |
7 | 4752 if (*eap->arg) |
4753 eap->errmsg = e_trailing; | |
4754 else | |
4755 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4756 if (eap->addr_count == 0) // default is current buffer |
7 | 4757 goto_buffer(eap, DOBUF_CURRENT, FORWARD, 0); |
4758 else | |
4759 goto_buffer(eap, DOBUF_FIRST, FORWARD, (int)eap->line2); | |
6230 | 4760 if (eap->do_ecmd_cmd != NULL) |
4761 do_cmdline_cmd(eap->do_ecmd_cmd); | |
7 | 4762 } |
4763 } | |
4764 | |
4765 /* | |
4766 * :[N]bmodified [N] to next mod. buffer | |
4767 * :[N]sbmodified [N] to next mod. buffer | |
4768 */ | |
4769 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4770 ex_bmodified(exarg_T *eap) |
7 | 4771 { |
4772 goto_buffer(eap, DOBUF_MOD, FORWARD, (int)eap->line2); | |
6230 | 4773 if (eap->do_ecmd_cmd != NULL) |
4774 do_cmdline_cmd(eap->do_ecmd_cmd); | |
7 | 4775 } |
4776 | |
4777 /* | |
4778 * :[N]bnext [N] to next buffer | |
4779 * :[N]sbnext [N] split and to next buffer | |
4780 */ | |
4781 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4782 ex_bnext(exarg_T *eap) |
7 | 4783 { |
19271
ebeeb4b4a1fa
patch 8.2.0194: some commands can cause problems in terminal popup
Bram Moolenaar <Bram@vim.org>
parents:
19261
diff
changeset
|
4784 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
|
4785 return; |
17722555af22
patch 8.2.0127: some buffer commands work in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19131
diff
changeset
|
4786 |
7 | 4787 goto_buffer(eap, DOBUF_CURRENT, FORWARD, (int)eap->line2); |
6230 | 4788 if (eap->do_ecmd_cmd != NULL) |
4789 do_cmdline_cmd(eap->do_ecmd_cmd); | |
7 | 4790 } |
4791 | |
4792 /* | |
4793 * :[N]bNext [N] to previous buffer | |
4794 * :[N]bprevious [N] to previous buffer | |
4795 * :[N]sbNext [N] split and to previous buffer | |
4796 * :[N]sbprevious [N] split and to previous buffer | |
4797 */ | |
4798 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4799 ex_bprevious(exarg_T *eap) |
7 | 4800 { |
19271
ebeeb4b4a1fa
patch 8.2.0194: some commands can cause problems in terminal popup
Bram Moolenaar <Bram@vim.org>
parents:
19261
diff
changeset
|
4801 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
|
4802 return; |
17722555af22
patch 8.2.0127: some buffer commands work in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19131
diff
changeset
|
4803 |
7 | 4804 goto_buffer(eap, DOBUF_CURRENT, BACKWARD, (int)eap->line2); |
6230 | 4805 if (eap->do_ecmd_cmd != NULL) |
4806 do_cmdline_cmd(eap->do_ecmd_cmd); | |
7 | 4807 } |
4808 | |
4809 /* | |
4810 * :brewind to first buffer | |
4811 * :bfirst to first buffer | |
4812 * :sbrewind split and to first buffer | |
4813 * :sbfirst split and to first buffer | |
4814 */ | |
4815 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4816 ex_brewind(exarg_T *eap) |
7 | 4817 { |
19271
ebeeb4b4a1fa
patch 8.2.0194: some commands can cause problems in terminal popup
Bram Moolenaar <Bram@vim.org>
parents:
19261
diff
changeset
|
4818 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
|
4819 return; |
17722555af22
patch 8.2.0127: some buffer commands work in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19131
diff
changeset
|
4820 |
7 | 4821 goto_buffer(eap, DOBUF_FIRST, FORWARD, 0); |
6230 | 4822 if (eap->do_ecmd_cmd != NULL) |
4823 do_cmdline_cmd(eap->do_ecmd_cmd); | |
7 | 4824 } |
4825 | |
4826 /* | |
4827 * :blast to last buffer | |
4828 * :sblast split and to last buffer | |
4829 */ | |
4830 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4831 ex_blast(exarg_T *eap) |
7 | 4832 { |
19271
ebeeb4b4a1fa
patch 8.2.0194: some commands can cause problems in terminal popup
Bram Moolenaar <Bram@vim.org>
parents:
19261
diff
changeset
|
4833 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
|
4834 return; |
17722555af22
patch 8.2.0127: some buffer commands work in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19131
diff
changeset
|
4835 |
7 | 4836 goto_buffer(eap, DOBUF_LAST, BACKWARD, 0); |
6230 | 4837 if (eap->do_ecmd_cmd != NULL) |
4838 do_cmdline_cmd(eap->do_ecmd_cmd); | |
7 | 4839 } |
4840 | |
20059
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20027
diff
changeset
|
4841 /* |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20027
diff
changeset
|
4842 * 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
|
4843 * 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
|
4844 */ |
7 | 4845 int |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4846 ends_excmd(int c) |
7 | 4847 { |
20027
23a4aef4f923
patch 8.2.0569: build failure with tiny version
Bram Moolenaar <Bram@vim.org>
parents:
20023
diff
changeset
|
4848 #ifdef FEAT_EVAL |
20023
c85d4e173cc9
patch 8.2.0567: Vim9: cannot put comments halfway expressions
Bram Moolenaar <Bram@vim.org>
parents:
20009
diff
changeset
|
4849 if (c == '#') |
20059
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20027
diff
changeset
|
4850 return in_vim9script(); |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20027
diff
changeset
|
4851 #endif |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20027
diff
changeset
|
4852 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
|
4853 } |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20027
diff
changeset
|
4854 |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20027
diff
changeset
|
4855 /* |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20027
diff
changeset
|
4856 * 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
|
4857 * 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
|
4858 */ |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20027
diff
changeset
|
4859 int |
20063
cc146cde0b4d
patch 8.2.0587: compiler warning for unused variable
Bram Moolenaar <Bram@vim.org>
parents:
20059
diff
changeset
|
4860 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
|
4861 { |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20027
diff
changeset
|
4862 int c = *cmd; |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20027
diff
changeset
|
4863 |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20027
diff
changeset
|
4864 #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
|
4865 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
|
4866 return in_vim9script(); |
20027
23a4aef4f923
patch 8.2.0569: build failure with tiny version
Bram Moolenaar <Bram@vim.org>
parents:
20023
diff
changeset
|
4867 #endif |
7 | 4868 return (c == NUL || c == '|' || c == '"' || c == '\n'); |
4869 } | |
4870 | |
4871 #if defined(FEAT_SYN_HL) || defined(FEAT_SEARCH_EXTRA) || defined(FEAT_EVAL) \ | |
4872 || defined(PROTO) | |
4873 /* | |
4874 * Return the next command, after the first '|' or '\n'. | |
4875 * Return NULL if not found. | |
4876 */ | |
4877 char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4878 find_nextcmd(char_u *p) |
7 | 4879 { |
4880 while (*p != '|' && *p != '\n') | |
4881 { | |
4882 if (*p == NUL) | |
4883 return NULL; | |
4884 ++p; | |
4885 } | |
4886 return (p + 1); | |
4887 } | |
4888 #endif | |
4889 | |
4890 /* | |
10383
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
4891 * 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
|
4892 * Return NULL if it isn't, the following character if it is. |
7 | 4893 */ |
4894 char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4895 check_nextcmd(char_u *p) |
7 | 4896 { |
10383
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
4897 char_u *s = skipwhite(p); |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
4898 |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
4899 if (*s == '|' || *s == '\n') |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
4900 return (s + 1); |
7 | 4901 else |
4902 return NULL; | |
4903 } | |
4904 | |
4905 /* | |
4906 * - if there are more files to edit | |
4907 * - and this is the last window | |
4908 * - and forceit not used | |
4909 * - and not repeated twice on a row | |
4910 * return FAIL and give error message if 'message' TRUE | |
4911 * return OK otherwise | |
4912 */ | |
4913 static int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4914 check_more( |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
4915 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
|
4916 int forceit) |
7 | 4917 { |
4918 int n = ARGCOUNT - curwin->w_arg_idx - 1; | |
4919 | |
672 | 4920 if (!forceit && only_one_window() |
4921 && ARGCOUNT > 1 && !arg_had_last && n >= 0 && quitmore == 0) | |
7 | 4922 { |
4923 if (message) | |
4924 { | |
4925 #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) | |
4926 if ((p_confirm || cmdmod.confirm) && curbuf->b_fname != NULL) | |
4927 { | |
2770 | 4928 char_u buff[DIALOG_MSG_SIZE]; |
7 | 4929 |
14585
c8f07e8b273e
patch 8.1.0306: plural messages are not translated properly
Christian Brabandt <cb@256bit.org>
parents:
14550
diff
changeset
|
4930 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
|
4931 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
|
4932 "%d more files to edit. Quit anyway?", n), n); |
7 | 4933 if (vim_dialog_yesno(VIM_QUESTION, NULL, buff, 1) == VIM_YES) |
4934 return OK; | |
4935 return FAIL; | |
4936 } | |
4937 #endif | |
15490
98c35d312987
patch 8.1.0753: printf format not checked for semsg()
Bram Moolenaar <Bram@vim.org>
parents:
15488
diff
changeset
|
4938 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
|
4939 "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
|
4940 quitmore = 2; // next try to quit is allowed |
7 | 4941 } |
4942 return FAIL; | |
4943 } | |
4944 return OK; | |
4945 } | |
4946 | |
4947 /* | |
4948 * Function given to ExpandGeneric() to obtain the list of command names. | |
4949 */ | |
4950 char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4951 get_command_name(expand_T *xp UNUSED, int idx) |
7 | 4952 { |
4953 if (idx >= (int)CMD_SIZE) | |
4954 return get_user_command_name(idx); | |
4955 return cmdnames[idx].cmd_name; | |
4956 } | |
4957 | |
4958 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4959 ex_colorscheme(exarg_T *eap) |
7 | 4960 { |
2142
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4961 if (*eap->arg == NUL) |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4962 { |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4963 #ifdef FEAT_EVAL |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4964 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
|
4965 char_u *p = NULL; |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4966 |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4967 if (expr != NULL) |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4968 { |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4969 ++emsg_off; |
20996
3af71cbcfdbe
patch 8.2.1049: Vim9: leaking memory when using continuation line
Bram Moolenaar <Bram@vim.org>
parents:
20982
diff
changeset
|
4970 p = eval_to_string(expr, FALSE); |
2142
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4971 --emsg_off; |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4972 vim_free(expr); |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4973 } |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4974 if (p != NULL) |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4975 { |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15510
diff
changeset
|
4976 msg((char *)p); |
2142
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4977 vim_free(p); |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4978 } |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4979 else |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15510
diff
changeset
|
4980 msg("default"); |
2142
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4981 #else |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15510
diff
changeset
|
4982 msg(_("unknown")); |
2142
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4983 #endif |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4984 } |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
4985 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
|
4986 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
|
4987 |
61448894376e
patch 8.1.0839: when using VTP wrong colors after a color scheme change
Bram Moolenaar <Bram@vim.org>
parents:
15643
diff
changeset
|
4988 #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
|
4989 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
|
4990 { |
61448894376e
patch 8.1.0839: when using VTP wrong colors after a color scheme change
Bram Moolenaar <Bram@vim.org>
parents:
15643
diff
changeset
|
4991 // 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
|
4992 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
|
4993 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
|
4994 } |
61448894376e
patch 8.1.0839: when using VTP wrong colors after a color scheme change
Bram Moolenaar <Bram@vim.org>
parents:
15643
diff
changeset
|
4995 #endif |
7 | 4996 } |
4997 | |
4998 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4999 ex_highlight(exarg_T *eap) |
7 | 5000 { |
5001 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
|
5002 msg(_("Greetings, Vim user!")); |
7 | 5003 do_highlight(eap->arg, eap->forceit, FALSE); |
5004 } | |
5005 | |
5006 | |
5007 /* | |
5008 * Call this function if we thought we were going to exit, but we won't | |
5009 * (because of an error). May need to restore the terminal mode. | |
5010 */ | |
5011 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5012 not_exiting(void) |
7 | 5013 { |
5014 exiting = FALSE; | |
5015 settmode(TMODE_RAW); | |
5016 } | |
5017 | |
13442
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5018 static int |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5019 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
|
5020 { |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5021 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
|
5022 |
18406
fa6efc49d71f
patch 8.1.2197: ExitPre autocommand may cause accessing freed memory
Bram Moolenaar <Bram@vim.org>
parents:
18402
diff
changeset
|
5023 // 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
|
5024 // 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
|
5025 // only happen in autocommands). |
13442
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5026 if (!win_valid(wp) |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5027 || curbuf_locked() |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5028 || (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
|
5029 return TRUE; |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5030 |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5031 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
|
5032 { |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5033 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
|
5034 // 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
|
5035 // 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
|
5036 // autocommands). |
fa6efc49d71f
patch 8.1.2197: ExitPre autocommand may cause accessing freed memory
Bram Moolenaar <Bram@vim.org>
parents:
18402
diff
changeset
|
5037 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
|
5038 || (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
|
5039 return TRUE; |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5040 } |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5041 |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5042 return FALSE; |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5043 } |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5044 |
7 | 5045 /* |
6409 | 5046 * ":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
|
5047 * ":{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
|
5048 * 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
|
5049 */ |
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
|
5050 void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5051 ex_quit(exarg_T *eap) |
7 | 5052 { |
6398 | 5053 win_T *wp; |
5054 | |
7 | 5055 #ifdef FEAT_CMDWIN |
5056 if (cmdwin_type != 0) | |
5057 { | |
5058 cmdwin_result = Ctrl_C; | |
5059 return; | |
5060 } | |
5061 #endif | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5062 // Don't quit while editing the command line. |
633 | 5063 if (text_locked()) |
5064 { | |
5065 text_locked_msg(); | |
631 | 5066 return; |
5067 } | |
6398 | 5068 if (eap->addr_count > 0) |
5069 { | |
6409 | 5070 int wnr = eap->line2; |
5071 | |
5072 for (wp = firstwin; wp->w_next != NULL; wp = wp->w_next) | |
5073 if (--wnr <= 0) | |
6398 | 5074 break; |
5075 } | |
5076 else | |
5077 wp = curwin; | |
6409 | 5078 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5079 // 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
|
5080 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
|
5081 return; |
13442
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5082 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5083 // 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
|
5084 if (before_quit_autocmds(wp, FALSE, eap->forceit)) |
819 | 5085 return; |
7 | 5086 |
5087 #ifdef FEAT_NETBEANS_INTG | |
5088 netbeansForcedQuit = eap->forceit; | |
5089 #endif | |
5090 | |
5091 /* | |
5092 * If there are more files or windows we won't exit. | |
5093 */ | |
5094 if (check_more(FALSE, eap->forceit) == OK && only_one_window()) | |
5095 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
|
5096 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
|
5097 && check_changed(wp->w_buffer, (p_awa ? CCGD_AW : 0) |
5464 | 5098 | (eap->forceit ? CCGD_FORCEIT : 0) |
5099 | CCGD_EXCMD)) | |
7 | 5100 || 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
|
5101 || (only_one_window() && check_changed_any(eap->forceit, TRUE))) |
7 | 5102 { |
5103 not_exiting(); | |
5104 } | |
5105 else | |
5106 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5107 // quit last window |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5108 // 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
|
5109 // 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
|
5110 // specified. Example: |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5111 // :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
|
5112 // :h|wincmd w|q - quit |
10349
cf988222b150
commit https://github.com/vim/vim/commit/a1f4cb93ba50ea9e40cd4b1f5592b8a6d1398660
Christian Brabandt <cb@256bit.org>
parents:
10275
diff
changeset
|
5113 if (only_one_window() && (ONE_WINDOW || eap->addr_count == 0)) |
7 | 5114 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
|
5115 not_exiting(); |
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_GUI |
7 | 5117 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
|
5118 #endif |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5119 // 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
|
5120 win_close(wp, !buf_hide(wp->w_buffer) || eap->forceit); |
7 | 5121 } |
5122 } | |
5123 | |
5124 /* | |
5125 * ":cquit". | |
5126 */ | |
5127 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5128 ex_cquit(exarg_T *eap UNUSED) |
7 | 5129 { |
19069
e14feba578f1
patch 8.2.0095: cannot specify exit code for :cquit
Bram Moolenaar <Bram@vim.org>
parents:
18991
diff
changeset
|
5130 // 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
|
5131 getout(eap->addr_count > 0 ? (int)eap->line2 : EXIT_FAILURE); |
7 | 5132 } |
5133 | |
5134 /* | |
5135 * ":qall": try to quit all windows | |
5136 */ | |
5137 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5138 ex_quit_all(exarg_T *eap) |
7 | 5139 { |
5140 # ifdef FEAT_CMDWIN | |
5141 if (cmdwin_type != 0) | |
5142 { | |
5143 if (eap->forceit) | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5144 cmdwin_result = K_XF1; // ex_window() takes care of this |
7 | 5145 else |
5146 cmdwin_result = K_XF2; | |
5147 return; | |
5148 } | |
5149 # endif | |
631 | 5150 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5151 // Don't quit while editing the command line. |
633 | 5152 if (text_locked()) |
5153 { | |
5154 text_locked_msg(); | |
631 | 5155 return; |
5156 } | |
13442
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5157 |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5158 if (before_quit_autocmds(curwin, TRUE, eap->forceit)) |
819 | 5159 return; |
631 | 5160 |
7 | 5161 exiting = TRUE; |
7469
15eefe1b0dad
commit https://github.com/vim/vim/commit/027387f70c671f62e3e08e0bdd09ec05b0232735
Christian Brabandt <cb@256bit.org>
parents:
7465
diff
changeset
|
5162 if (eap->forceit || !check_changed_any(FALSE, FALSE)) |
7 | 5163 getout(0); |
5164 not_exiting(); | |
5165 } | |
5166 | |
5167 /* | |
5168 * ":close": close current window, unless it is the last one | |
5169 */ | |
5170 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5171 ex_close(exarg_T *eap) |
7 | 5172 { |
6398 | 5173 win_T *win; |
5174 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
|
5175 #ifdef FEAT_CMDWIN |
7 | 5176 if (cmdwin_type != 0) |
2839 | 5177 cmdwin_result = Ctrl_C; |
7 | 5178 else |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5179 #endif |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
5180 if (!text_locked() && !curbuf_locked()) |
6398 | 5181 { |
5182 if (eap->addr_count == 0) | |
5183 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
|
5184 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
|
5185 { |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9538
diff
changeset
|
5186 FOR_ALL_WINDOWS(win) |
6398 | 5187 { |
5188 winnr++; | |
5189 if (winnr == eap->line2) | |
5190 break; | |
5191 } | |
5192 if (win == NULL) | |
5193 win = lastwin; | |
5194 ex_win_close(eap->forceit, win, NULL); | |
5195 } | |
5196 } | |
667 | 5197 } |
5198 | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5199 #ifdef FEAT_QUICKFIX |
667 | 5200 /* |
5201 * ":pclose": Close any preview window. | |
5202 */ | |
5203 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5204 ex_pclose(exarg_T *eap) |
667 | 5205 { |
5206 win_T *win; | |
5207 | |
17431
ce35cdbe9f74
patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
17336
diff
changeset
|
5208 // First close any normal window. |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9538
diff
changeset
|
5209 FOR_ALL_WINDOWS(win) |
667 | 5210 if (win->w_p_pvw) |
5211 { | |
671 | 5212 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
|
5213 return; |
ce35cdbe9f74
patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
17336
diff
changeset
|
5214 } |
18763
49b78d6465e5
patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents:
18715
diff
changeset
|
5215 # 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
|
5216 // 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
|
5217 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
|
5218 # endif |
667 | 5219 } |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5220 #endif |
667 | 5221 |
671 | 5222 /* |
5223 * Close window "win" and take care of handling closing the last window for a | |
5224 * modified buffer. | |
5225 */ | |
5226 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5227 ex_win_close( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5228 int forceit, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5229 win_T *win, |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5230 tabpage_T *tp) // NULL or the tab page "win" is in |
7 | 5231 { |
5232 int need_hide; | |
5233 buf_T *buf = win->w_buffer; | |
5234 | |
21016
0738c44504cb
patch 8.2.1059: crash when using :tabonly in an autocommand
Bram Moolenaar <Bram@vim.org>
parents:
20996
diff
changeset
|
5235 // Never close the autocommand window. |
0738c44504cb
patch 8.2.1059: crash when using :tabonly in an autocommand
Bram Moolenaar <Bram@vim.org>
parents:
20996
diff
changeset
|
5236 if (win == aucmd_win) |
0738c44504cb
patch 8.2.1059: crash when using :tabonly in an autocommand
Bram Moolenaar <Bram@vim.org>
parents:
20996
diff
changeset
|
5237 { |
0738c44504cb
patch 8.2.1059: crash when using :tabonly in an autocommand
Bram Moolenaar <Bram@vim.org>
parents:
20996
diff
changeset
|
5238 emsg(_(e_autocmd_close)); |
0738c44504cb
patch 8.2.1059: crash when using :tabonly in an autocommand
Bram Moolenaar <Bram@vim.org>
parents:
20996
diff
changeset
|
5239 return; |
0738c44504cb
patch 8.2.1059: crash when using :tabonly in an autocommand
Bram Moolenaar <Bram@vim.org>
parents:
20996
diff
changeset
|
5240 } |
0738c44504cb
patch 8.2.1059: crash when using :tabonly in an autocommand
Bram Moolenaar <Bram@vim.org>
parents:
20996
diff
changeset
|
5241 |
7 | 5242 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
|
5243 if (need_hide && !buf_hide(buf) && !forceit) |
7 | 5244 { |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5245 #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) |
7 | 5246 if ((p_confirm || cmdmod.confirm) && p_write) |
5247 { | |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9460
diff
changeset
|
5248 bufref_T bufref; |
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9460
diff
changeset
|
5249 |
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9460
diff
changeset
|
5250 set_bufref(&bufref, buf); |
7 | 5251 dialog_changed(buf, FALSE); |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9460
diff
changeset
|
5252 if (bufref_valid(&bufref) && bufIsChanged(buf)) |
7 | 5253 return; |
5254 need_hide = FALSE; | |
5255 } | |
5256 else | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5257 #endif |
7 | 5258 { |
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
|
5259 no_write_message(); |
7 | 5260 return; |
5261 } | |
5262 } | |
5263 | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5264 #ifdef FEAT_GUI |
7 | 5265 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
|
5266 #endif |
671 | 5267 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5268 // free buffer when not hiding it or when it's a scratch buffer |
671 | 5269 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
|
5270 win_close(win, !need_hide && !buf_hide(buf)); |
671 | 5271 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
|
5272 win_close_othertab(win, !need_hide && !buf_hide(buf), tp); |
671 | 5273 } |
5274 | |
5275 /* | |
10741
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5276 * 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
|
5277 * Returns a tabpage number. |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5278 * 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
|
5279 */ |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5280 static int |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5281 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
|
5282 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5283 int tab_number; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5284 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
|
5285 |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5286 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
|
5287 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5288 char_u *p = eap->arg; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5289 char_u *p_save; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5290 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
|
5291 // 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
|
5292 |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5293 if (*p == '-') |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5294 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5295 relative = -1; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5296 p++; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5297 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5298 else if (*p == '+') |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5299 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5300 relative = 1; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5301 p++; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5302 } |
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 p_save = p; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5305 tab_number = getdigits(&p); |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5306 |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5307 if (relative == 0) |
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 if (STRCMP(p, "$") == 0) |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5310 tab_number = LAST_TAB_NR; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5311 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
|
5312 || tab_number > LAST_TAB_NR) |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5313 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5314 // No numbers as argument. |
10741
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5315 eap->errmsg = e_invarg; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5316 goto theend; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5317 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5318 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5319 else |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5320 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5321 if (*p_save == NUL) |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5322 tab_number = 1; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5323 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
|
5324 || tab_number == 0) |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5325 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5326 // No numbers as argument. |
10741
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5327 eap->errmsg = e_invarg; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5328 goto theend; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5329 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5330 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
|
5331 if (!unaccept_arg0 && relative == -1) |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5332 --tab_number; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5333 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5334 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
|
5335 eap->errmsg = e_invarg; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5336 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5337 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
|
5338 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5339 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
|
5340 { |
10741
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5341 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
|
5342 tab_number = 0; |
4961e7acdd8c
patch 8.0.0266: compiler warning for using uninitialized variable
Christian Brabandt <cb@256bit.org>
parents:
10741
diff
changeset
|
5343 } |
10741
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5344 else |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5345 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5346 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
|
5347 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
|
5348 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5349 --tab_number; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5350 if (tab_number < unaccept_arg0) |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5351 eap->errmsg = e_invarg; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5352 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5353 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5354 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5355 else |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5356 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5357 switch (eap->cmdidx) |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5358 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5359 case CMD_tabnext: |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5360 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
|
5361 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
|
5362 tab_number = 1; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5363 break; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5364 case CMD_tabmove: |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5365 tab_number = LAST_TAB_NR; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5366 break; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5367 default: |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5368 tab_number = tabpage_index(curtab); |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5369 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5370 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5371 |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5372 theend: |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5373 return tab_number; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5374 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5375 |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5376 /* |
671 | 5377 * ":tabclose": close current tab page, unless it is the last one. |
5378 * ":tabclose N": close tab page N. | |
667 | 5379 */ |
5380 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5381 ex_tabclose(exarg_T *eap) |
667 | 5382 { |
671 | 5383 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
|
5384 int tab_number; |
671 | 5385 |
667 | 5386 # ifdef FEAT_CMDWIN |
5387 if (cmdwin_type != 0) | |
5388 cmdwin_result = K_IGNORE; | |
5389 else | |
5390 # endif | |
671 | 5391 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
|
5392 emsg(_("E784: Cannot close last tab page")); |
671 | 5393 else |
5394 { | |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5395 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
|
5396 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
|
5397 { |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5398 tp = find_tabpage(tab_number); |
671 | 5399 if (tp == NULL) |
5400 { | |
5401 beep_flush(); | |
5402 return; | |
5403 } | |
674 | 5404 if (tp != curtab) |
671 | 5405 { |
5406 tabpage_close_other(tp, eap->forceit); | |
5407 return; | |
5408 } | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
5409 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
|
5410 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
|
5411 } |
671 | 5412 } |
672 | 5413 } |
5414 | |
5415 /* | |
5416 * ":tabonly": close all tab pages except the current one | |
5417 */ | |
5418 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5419 ex_tabonly(exarg_T *eap) |
672 | 5420 { |
5421 tabpage_T *tp; | |
5422 int done; | |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5423 int tab_number; |
672 | 5424 |
5425 # ifdef FEAT_CMDWIN | |
5426 if (cmdwin_type != 0) | |
5427 cmdwin_result = K_IGNORE; | |
5428 else | |
5429 # endif | |
5430 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
|
5431 msg(_("Already only one tab page")); |
672 | 5432 else |
5433 { | |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5434 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
|
5435 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
|
5436 { |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5437 goto_tabpage(tab_number); |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5438 // 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
|
5439 // 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
|
5440 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
|
5441 { |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5442 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
|
5443 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
|
5444 { |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5445 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
|
5446 // 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
|
5447 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
|
5448 done = 1000; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5449 // 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
|
5450 break; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5451 } |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5452 if (first_tabpage->tp_next == NULL) |
672 | 5453 break; |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5454 } |
672 | 5455 } |
5456 } | |
671 | 5457 } |
5458 | |
5459 /* | |
5460 * Close the current tab page. | |
5461 */ | |
5462 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5463 tabpage_close(int forceit) |
671 | 5464 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5465 // 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
|
5466 // 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
|
5467 if (!ONE_WINDOW) |
675 | 5468 close_others(TRUE, forceit); |
10357
59d01e335858
commit https://github.com/vim/vim/commit/459ca563128f2edb7e3bb190090bbb755a56dd55
Christian Brabandt <cb@256bit.org>
parents:
10349
diff
changeset
|
5469 if (ONE_WINDOW) |
671 | 5470 ex_win_close(forceit, curwin, NULL); |
5471 # ifdef FEAT_GUI | |
5472 need_mouse_correct = TRUE; | |
5473 # endif | |
5474 } | |
5475 | |
5476 /* | |
5477 * Close tab page "tp", which is not the current tab page. | |
5478 * Note that autocommands may make "tp" invalid. | |
971 | 5479 * Also takes care of the tab pages line disappearing when closing the |
5480 * last-but-one tab page. | |
671 | 5481 */ |
5482 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5483 tabpage_close_other(tabpage_T *tp, int forceit) |
671 | 5484 { |
5485 int done = 0; | |
672 | 5486 win_T *wp; |
971 | 5487 int h = tabline_height(); |
671 | 5488 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5489 // 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
|
5490 // one. OK, so I'm paranoid... |
671 | 5491 while (++done < 1000) |
5492 { | |
672 | 5493 wp = tp->tp_firstwin; |
5494 ex_win_close(forceit, wp, tp); | |
5495 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5496 // 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
|
5497 // fail to close a window with a modified buffer. |
672 | 5498 if (!valid_tabpage(tp) || tp->tp_firstwin == wp) |
671 | 5499 break; |
5500 } | |
971 | 5501 |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9538
diff
changeset
|
5502 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
|
5503 |
672 | 5504 redraw_tabline = TRUE; |
971 | 5505 if (h != tabline_height()) |
5506 shell_new_rows(); | |
667 | 5507 } |
7 | 5508 |
5509 /* | |
5510 * ":only". | |
5511 */ | |
5512 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5513 ex_only(exarg_T *eap) |
7 | 5514 { |
6398 | 5515 win_T *wp; |
5516 int wnr; | |
7 | 5517 # ifdef FEAT_GUI |
5518 need_mouse_correct = TRUE; | |
5519 # endif | |
6398 | 5520 if (eap->addr_count > 0) |
5521 { | |
5522 wnr = eap->line2; | |
5523 for (wp = firstwin; --wnr > 0; ) | |
5524 { | |
5525 if (wp->w_next == NULL) | |
5526 break; | |
5527 else | |
5528 wp = wp->w_next; | |
5529 } | |
5530 win_goto(wp); | |
5531 } | |
7 | 5532 close_others(TRUE, eap->forceit); |
5533 } | |
5534 | |
5535 static void | |
10492
b2cd5a71f4bb
commit https://github.com/vim/vim/commit/5e1e6d265d26ee2952c4a018a5ff72c950d2d700
Christian Brabandt <cb@256bit.org>
parents:
10490
diff
changeset
|
5536 ex_hide(exarg_T *eap UNUSED) |
7 | 5537 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5538 // ":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
|
5539 if (!eap->skip) |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5540 { |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5541 #ifdef FEAT_GUI |
10383
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5542 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
|
5543 #endif |
10383
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5544 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
|
5545 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
|
5546 else |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5547 { |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5548 int winnr = 0; |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5549 win_T *win; |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5550 |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5551 FOR_ALL_WINDOWS(win) |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5552 { |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5553 winnr++; |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5554 if (winnr == eap->line2) |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5555 break; |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5556 } |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5557 if (win == NULL) |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5558 win = lastwin; |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5559 win_close(win, FALSE); |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5560 } |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5561 } |
7 | 5562 } |
5563 | |
5564 /* | |
5565 * ":stop" and ":suspend": Suspend Vim. | |
5566 */ | |
5567 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5568 ex_stop(exarg_T *eap) |
7 | 5569 { |
5570 /* | |
5571 * Disallow suspending for "rvim". | |
5572 */ | |
10264
c036c0f636d5
commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents:
10240
diff
changeset
|
5573 if (!check_restricted()) |
7 | 5574 { |
5575 if (!eap->forceit) | |
5576 autowrite_all(); | |
5577 windgoto((int)Rows - 1, 0); | |
5578 out_char('\n'); | |
5579 out_flush(); | |
5580 stoptermcap(); | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5581 out_flush(); // needed for SUN to restore xterm buffer |
7 | 5582 #ifdef FEAT_TITLE |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5583 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
|
5584 #endif |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5585 ui_suspend(); // call machine specific function |
7 | 5586 #ifdef FEAT_TITLE |
5587 maketitle(); | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5588 resettitle(); // force updating the title |
7 | 5589 #endif |
5590 starttermcap(); | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5591 scroll_start(); // scroll screen before redrawing |
7 | 5592 redraw_later_clear(); |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5593 shell_resized(); // may have resized window |
7 | 5594 } |
5595 } | |
5596 | |
5597 /* | |
13442
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5598 * ":exit", ":xit" and ":wq": Write file and quite the current window. |
7 | 5599 */ |
5600 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5601 ex_exit(exarg_T *eap) |
7 | 5602 { |
5603 #ifdef FEAT_CMDWIN | |
5604 if (cmdwin_type != 0) | |
5605 { | |
5606 cmdwin_result = Ctrl_C; | |
5607 return; | |
5608 } | |
5609 #endif | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5610 // Don't quit while editing the command line. |
633 | 5611 if (text_locked()) |
5612 { | |
5613 text_locked_msg(); | |
631 | 5614 return; |
5615 } | |
13442
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5616 |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5617 if (before_quit_autocmds(curwin, FALSE, eap->forceit)) |
819 | 5618 return; |
7 | 5619 |
5620 /* | |
5621 * if more files or windows we won't exit | |
5622 */ | |
5623 if (check_more(FALSE, eap->forceit) == OK && only_one_window()) | |
5624 exiting = TRUE; | |
5625 if ( ((eap->cmdidx == CMD_wq | |
5626 || curbufIsChanged()) | |
5627 && do_write(eap) == FAIL) | |
5628 || 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
|
5629 || (only_one_window() && check_changed_any(eap->forceit, FALSE))) |
7 | 5630 { |
5631 not_exiting(); | |
5632 } | |
5633 else | |
5634 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5635 if (only_one_window()) // quit last window, exit Vim |
7 | 5636 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
|
5637 not_exiting(); |
7 | 5638 # ifdef FEAT_GUI |
5639 need_mouse_correct = TRUE; | |
5640 # endif | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5641 // 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
|
5642 win_close(curwin, !buf_hide(curwin->w_buffer)); |
7 | 5643 } |
5644 } | |
5645 | |
5646 /* | |
5647 * ":print", ":list", ":number". | |
5648 */ | |
5649 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5650 ex_print(exarg_T *eap) |
7 | 5651 { |
167 | 5652 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
|
5653 emsg(_(e_emptybuf)); |
167 | 5654 else |
5655 { | |
5656 for ( ;!got_int; ui_breakcheck()) | |
5657 { | |
5658 print_line(eap->line1, | |
5659 (eap->cmdidx == CMD_number || eap->cmdidx == CMD_pound | |
5660 || (eap->flags & EXFLAG_NR)), | |
5661 eap->cmdidx == CMD_list || (eap->flags & EXFLAG_LIST)); | |
5662 if (++eap->line1 > eap->line2) | |
5663 break; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5664 out_flush(); // show one line at a time |
167 | 5665 } |
5666 setpcmark(); | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5667 // put cursor at last line |
167 | 5668 curwin->w_cursor.lnum = eap->line2; |
5669 beginline(BL_SOL | BL_FIX); | |
5670 } | |
7 | 5671 |
5672 ex_no_reprint = TRUE; | |
5673 } | |
5674 | |
5675 #ifdef FEAT_BYTEOFF | |
5676 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5677 ex_goto(exarg_T *eap) |
7 | 5678 { |
5679 goto_byte(eap->line2); | |
5680 } | |
5681 #endif | |
5682 | |
5683 /* | |
5684 * ":shell". | |
5685 */ | |
5686 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5687 ex_shell(exarg_T *eap UNUSED) |
7 | 5688 { |
5689 do_shell(NULL, 0); | |
5690 } | |
5691 | |
14428
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5692 #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
|
5693 |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5694 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
|
5695 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
|
5696 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
|
5697 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
|
5698 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
|
5699 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
|
5700 |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5701 static void |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5702 handle_drop_internal(void) |
7 | 5703 { |
5704 exarg_T ea; | |
5705 int save_msg_scroll = msg_scroll; | |
5706 | |
14428
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5707 // 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
|
5708 // 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
|
5709 drop_busy = TRUE; |
7 | 5710 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5711 // 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
|
5712 // 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
|
5713 // 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
|
5714 // 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
|
5715 if (!buf_hide(curbuf) && !drop_split) |
7 | 5716 { |
5717 ++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
|
5718 drop_split = check_changed(curbuf, CCGD_AW); |
7 | 5719 --emsg_off; |
5720 } | |
14428
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5721 if (drop_split) |
7 | 5722 { |
5723 if (win_split(0, 0) == FAIL) | |
5724 return; | |
2583 | 5725 RESET_BINDING(curwin); |
7 | 5726 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5727 // 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
|
5728 // existing one is overwritten. |
7 | 5729 alist_unlink(curwin->w_alist); |
5730 alist_new(); | |
5731 } | |
5732 | |
5733 /* | |
5734 * Set up the new argument list. | |
5735 */ | |
14428
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5736 alist_set(ALIST(curwin), drop_filec, drop_filev, FALSE, NULL, 0); |
7 | 5737 |
5738 /* | |
5739 * Move to the first file. | |
5740 */ | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5741 // 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
|
5742 CLEAR_FIELD(ea); |
7 | 5743 ea.cmd = (char_u *)"next"; |
5744 do_argfile(&ea, 0); | |
5745 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5746 // 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
|
5747 // mode that is not needed here. |
7 | 5748 need_start_insertmode = FALSE; |
5749 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5750 // 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
|
5751 // 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
|
5752 // msg_scroll being set by displaying a message is irrelevant. |
7 | 5753 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
|
5754 |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5755 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
|
5756 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
|
5757 |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5758 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
|
5759 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
|
5760 } |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5761 |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5762 /* |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5763 * 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
|
5764 * :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
|
5765 * 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
|
5766 * 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
|
5767 * 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
|
5768 * |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5769 * 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
|
5770 * 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
|
5771 * list. |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5772 */ |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5773 void |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5774 handle_drop( |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5775 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
|
5776 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
|
5777 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
|
5778 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
|
5779 // list |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5780 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
|
5781 { |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5782 // 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
|
5783 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
|
5784 { |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5785 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
|
5786 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
|
5787 return; |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5788 } |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5789 |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5790 // 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
|
5791 // one. |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5792 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
|
5793 { |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5794 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
|
5795 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
|
5796 } |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5797 |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5798 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
|
5799 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
|
5800 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
|
5801 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
|
5802 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
|
5803 |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5804 // 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
|
5805 // - 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
|
5806 // - 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
|
5807 // - 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
|
5808 // 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
|
5809 // 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
|
5810 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
|
5811 return; |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5812 |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5813 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
|
5814 } |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5815 |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5816 /* |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5817 * 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
|
5818 * 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
|
5819 */ |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5820 void |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5821 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
|
5822 { |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
5823 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
|
5824 && !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
|
5825 handle_drop_internal(); |
7 | 5826 } |
5827 #endif | |
5828 | |
5829 /* | |
5830 * ":preserve". | |
5831 */ | |
5832 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5833 ex_preserve(exarg_T *eap UNUSED) |
7 | 5834 { |
164 | 5835 curbuf->b_flags |= BF_PRESERVED; |
7 | 5836 ml_preserve(curbuf, TRUE); |
5837 } | |
5838 | |
5839 /* | |
5840 * ":recover". | |
5841 */ | |
5842 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5843 ex_recover(exarg_T *eap) |
7 | 5844 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5845 // Set recoverymode right away to avoid the ATTENTION prompt. |
7 | 5846 recoverymode = TRUE; |
5464 | 5847 if (!check_changed(curbuf, (p_awa ? CCGD_AW : 0) |
5848 | CCGD_MULTWIN | |
5849 | (eap->forceit ? CCGD_FORCEIT : 0) | |
5850 | CCGD_EXCMD) | |
5851 | |
7 | 5852 && (*eap->arg == NUL |
5853 || 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
|
5854 ml_recover(TRUE); |
7 | 5855 recoverymode = FALSE; |
5856 } | |
5857 | |
5858 /* | |
5859 * Command modifier used in a wrong way. | |
5860 */ | |
5861 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5862 ex_wrongmodifier(exarg_T *eap) |
7 | 5863 { |
5864 eap->errmsg = e_invcmd; | |
5865 } | |
5866 | |
5867 /* | |
5868 * :sview [+command] file split window with new file, read-only | |
5869 * :split [[+command] file] split window with current or new file | |
5870 * :vsplit [[+command] file] split window vertically with current or new file | |
5871 * :new [[+command] file] split window with no or new file | |
5872 * :vnew [[+command] file] split vertically window with no or new file | |
5873 * :sfind [+command] file split window with file in 'path' | |
675 | 5874 * |
5875 * :tabedit open new Tab page with empty window | |
5876 * :tabedit [+command] file open new Tab page and edit "file" | |
5877 * :tabnew [[+command] file] just like :tabedit | |
5878 * :tabfind [+command] file open new Tab page and find "file" | |
7 | 5879 */ |
5880 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5881 ex_splitview(exarg_T *eap) |
7 | 5882 { |
675 | 5883 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
|
5884 #if defined(FEAT_SEARCHPATH) || defined(FEAT_BROWSE) |
7 | 5885 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
|
5886 #endif |
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5887 #ifdef FEAT_BROWSE |
7 | 5888 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
|
5889 #endif |
14155
da09e29e59d9
patch 8.1.0095: dialog for ":browse tabnew" says "new window"
Christian Brabandt <cb@256bit.org>
parents:
14059
diff
changeset
|
5890 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
|
5891 || 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
|
5892 || 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
|
5893 |
19271
ebeeb4b4a1fa
patch 8.2.0194: some commands can cause problems in terminal popup
Bram Moolenaar <Bram@vim.org>
parents:
19261
diff
changeset
|
5894 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
|
5895 return; |
da5f5836e90c
patch 8.1.1438: some commands cause trouble in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
5896 |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5897 #ifdef FEAT_GUI |
7 | 5898 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
|
5899 #endif |
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5900 |
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5901 #ifdef FEAT_QUICKFIX |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5902 // 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
|
5903 // quickfix windows. But it's OK when doing ":tab split". |
1661 | 5904 if (bt_quickfix(curbuf) && cmdmod.tab == 0) |
7 | 5905 { |
5906 if (eap->cmdidx == CMD_split) | |
5907 eap->cmdidx = CMD_new; | |
5908 if (eap->cmdidx == CMD_vsplit) | |
5909 eap->cmdidx = CMD_vnew; | |
667 | 5910 } |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5911 #endif |
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5912 |
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5913 #ifdef FEAT_SEARCHPATH |
675 | 5914 if (eap->cmdidx == CMD_sfind || eap->cmdidx == CMD_tabfind) |
7 | 5915 { |
5916 fname = find_file_in_path(eap->arg, (int)STRLEN(eap->arg), | |
5917 FNAME_MESS, TRUE, curbuf->b_ffname); | |
5918 if (fname == NULL) | |
5919 goto theend; | |
5920 eap->arg = fname; | |
5921 } | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5922 # ifdef FEAT_BROWSE |
7 | 5923 else |
5924 # endif | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5925 #endif |
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5926 #ifdef FEAT_BROWSE |
7 | 5927 if (cmdmod.browse |
5928 && eap->cmdidx != CMD_vnew | |
5929 && eap->cmdidx != CMD_new) | |
5930 { | |
461 | 5931 if ( |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
5932 # ifdef FEAT_GUI |
461 | 5933 !gui.in_use && |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
5934 # endif |
461 | 5935 au_has_group((char_u *)"FileExplorer")) |
5936 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5937 // 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
|
5938 // Edit the directory. |
461 | 5939 if (*eap->arg == NUL || !mch_isdir(eap->arg)) |
5940 eap->arg = (char_u *)"."; | |
5941 } | |
5942 else | |
5943 { | |
14155
da09e29e59d9
patch 8.1.0095: dialog for ":browse tabnew" says "new window"
Christian Brabandt <cb@256bit.org>
parents:
14059
diff
changeset
|
5944 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
|
5945 ? _("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
|
5946 : _("Edit File in new window")), |
7 | 5947 eap->arg, NULL, NULL, NULL, curbuf); |
461 | 5948 if (fname == NULL) |
5949 goto theend; | |
5950 eap->arg = fname; | |
5951 } | |
7 | 5952 } |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5953 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
|
5954 #endif |
7 | 5955 |
675 | 5956 /* |
5957 * Either open new tab page or split the window. | |
5958 */ | |
14155
da09e29e59d9
patch 8.1.0095: dialog for ":browse tabnew" says "new window"
Christian Brabandt <cb@256bit.org>
parents:
14059
diff
changeset
|
5959 if (use_tab) |
675 | 5960 { |
820 | 5961 if (win_new_tabpage(cmdmod.tab != 0 ? cmdmod.tab |
5962 : eap->addr_count == 0 ? 0 | |
5963 : (int)eap->line2 + 1) != FAIL) | |
675 | 5964 { |
1498 | 5965 do_exedit(eap, old_curwin); |
675 | 5966 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5967 // set the alternate buffer for the window we came from |
675 | 5968 if (curwin != old_curwin |
5969 && win_valid(old_curwin) | |
5970 && old_curwin->w_buffer != curbuf | |
5971 && !cmdmod.keepalt) | |
5972 old_curwin->w_alt_fnum = curbuf->b_fnum; | |
5973 } | |
5974 } | |
5975 else if (win_split(eap->addr_count > 0 ? (int)eap->line2 : 0, | |
7 | 5976 *eap->cmd == 'v' ? WSP_VERT : 0) != FAIL) |
5977 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
5978 // 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
|
5979 // doing ":split" without arguments. |
7 | 5980 if (*eap->arg != NUL |
13384
6740c499de13
patch 8.0.1566: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13380
diff
changeset
|
5981 # ifdef FEAT_BROWSE |
7 | 5982 || cmdmod.browse |
13384
6740c499de13
patch 8.0.1566: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13380
diff
changeset
|
5983 # endif |
7 | 5984 ) |
2583 | 5985 RESET_BINDING(curwin); |
7 | 5986 else |
5987 do_check_scrollbind(FALSE); | |
5988 do_exedit(eap, old_curwin); | |
5989 } | |
5990 | |
667 | 5991 # ifdef FEAT_BROWSE |
7 | 5992 cmdmod.browse = browse_flag; |
667 | 5993 # endif |
5994 | |
5995 # if defined(FEAT_SEARCHPATH) || defined(FEAT_BROWSE) | |
7 | 5996 theend: |
5997 vim_free(fname); | |
667 | 5998 # endif |
5999 } | |
6000 | |
6001 /* | |
682 | 6002 * Open a new tab page. |
667 | 6003 */ |
6004 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6005 tabpage_new(void) |
682 | 6006 { |
6007 exarg_T ea; | |
6008 | |
20007
aadd1cae2ff5
patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
6009 CLEAR_FIELD(ea); |
682 | 6010 ea.cmdidx = CMD_tabnew; |
6011 ea.cmd = (char_u *)"tabn"; | |
6012 ea.arg = (char_u *)""; | |
6013 ex_splitview(&ea); | |
6014 } | |
6015 | |
6016 /* | |
6017 * :tabnext command | |
6018 */ | |
6019 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6020 ex_tabnext(exarg_T *eap) |
682 | 6021 { |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6022 int tab_number; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6023 |
17111
af861fccc309
patch 8.1.1555: NOT_IN_POPUP_WINDOW is confusing
Bram Moolenaar <Bram@vim.org>
parents:
17095
diff
changeset
|
6024 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
|
6025 return; |
685 | 6026 switch (eap->cmdidx) |
6027 { | |
6028 case CMD_tabfirst: | |
6029 case CMD_tabrewind: | |
6030 goto_tabpage(1); | |
6031 break; | |
6032 case CMD_tablast: | |
6033 goto_tabpage(9999); | |
6034 break; | |
6035 case CMD_tabprevious: | |
6036 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
|
6037 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
|
6038 { |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6039 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
|
6040 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
|
6041 |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6042 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
|
6043 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
|
6044 || tab_number == 0) |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6045 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6046 // 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
|
6047 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
|
6048 return; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6049 } |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6050 } |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6051 else |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6052 { |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6053 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
|
6054 tab_number = 1; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6055 else |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6056 { |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6057 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
|
6058 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
|
6059 { |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6060 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
|
6061 return; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6062 } |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6063 } |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6064 } |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6065 goto_tabpage(-tab_number); |
685 | 6066 break; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6067 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
|
6068 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
|
6069 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
|
6070 goto_tabpage(tab_number); |
685 | 6071 break; |
6072 } | |
682 | 6073 } |
6074 | |
6075 /* | |
6076 * :tabmove command | |
6077 */ | |
6078 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6079 ex_tabmove(exarg_T *eap) |
682 | 6080 { |
6775 | 6081 int tab_number; |
3662 | 6082 |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6083 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
|
6084 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
|
6085 tabpage_move(tab_number); |
667 | 6086 } |
6087 | |
6088 /* | |
6089 * :tabs command: List tabs and their contents. | |
6090 */ | |
6091 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6092 ex_tabs(exarg_T *eap UNUSED) |
667 | 6093 { |
6094 tabpage_T *tp; | |
6095 win_T *wp; | |
6096 int tabcount = 1; | |
6097 | |
6098 msg_start(); | |
6099 msg_scroll = TRUE; | |
6100 for (tp = first_tabpage; tp != NULL && !got_int; tp = tp->tp_next) | |
6101 { | |
6102 msg_putchar('\n'); | |
6103 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
|
6104 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
|
6105 out_flush(); // output one line at a time |
667 | 6106 ui_breakcheck(); |
6107 | |
678 | 6108 if (tp == curtab) |
667 | 6109 wp = firstwin; |
6110 else | |
6111 wp = tp->tp_firstwin; | |
6112 for ( ; wp != NULL && !got_int; wp = wp->w_next) | |
6113 { | |
682 | 6114 msg_putchar('\n'); |
6115 msg_putchar(wp == curwin ? '>' : ' '); | |
6116 msg_putchar(' '); | |
672 | 6117 msg_putchar(bufIsChanged(wp->w_buffer) ? '+' : ' '); |
6118 msg_putchar(' '); | |
667 | 6119 if (buf_spname(wp->w_buffer) != NULL) |
3839 | 6120 vim_strncpy(IObuff, buf_spname(wp->w_buffer), IOSIZE - 1); |
667 | 6121 else |
6122 home_replace(wp->w_buffer, wp->w_buffer->b_fname, | |
6123 IObuff, IOSIZE, TRUE); | |
6124 msg_outtrans(IObuff); | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6125 out_flush(); // output one line at a time |
667 | 6126 ui_breakcheck(); |
6127 } | |
6128 } | |
6129 } | |
6130 | |
7 | 6131 /* |
6132 * ":mode": Set screen mode. | |
6133 * If no argument given, just get the screen size and redraw. | |
6134 */ | |
6135 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6136 ex_mode(exarg_T *eap) |
7 | 6137 { |
6138 if (*eap->arg == NUL) | |
6139 shell_resized(); | |
6140 else | |
19131
1fe99999625c
patch 8.2.0125: :mode no longer works for any system
Bram Moolenaar <Bram@vim.org>
parents:
19075
diff
changeset
|
6141 emsg(_(e_screenmode)); |
7 | 6142 } |
6143 | |
6144 /* | |
6145 * ":resize". | |
6146 * set, increment or decrement current window height | |
6147 */ | |
6148 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6149 ex_resize(exarg_T *eap) |
7 | 6150 { |
6151 int n; | |
6152 win_T *wp = curwin; | |
6153 | |
6154 if (eap->addr_count > 0) | |
6155 { | |
6156 n = eap->line2; | |
6157 for (wp = firstwin; wp->w_next != NULL && --n > 0; wp = wp->w_next) | |
6158 ; | |
6159 } | |
6160 | |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8577
diff
changeset
|
6161 # ifdef FEAT_GUI |
7 | 6162 need_mouse_correct = TRUE; |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8577
diff
changeset
|
6163 # endif |
7 | 6164 n = atol((char *)eap->arg); |
6165 if (cmdmod.split & WSP_VERT) | |
6166 { | |
6167 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
|
6168 n += curwin->w_width; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6169 else if (n == 0 && eap->arg[0] == NUL) // default is very wide |
7 | 6170 n = 9999; |
6171 win_setwidth_win((int)n, wp); | |
6172 } | |
6173 else | |
6174 { | |
6175 if (*eap->arg == '-' || *eap->arg == '+') | |
6176 n += curwin->w_height; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6177 else if (n == 0 && eap->arg[0] == NUL) // default is very high |
7 | 6178 n = 9999; |
6179 win_setheight_win((int)n, wp); | |
6180 } | |
6181 } | |
6182 | |
6183 /* | |
6184 * ":find [+command] <file>" command. | |
6185 */ | |
6186 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6187 ex_find(exarg_T *eap) |
7 | 6188 { |
6189 #ifdef FEAT_SEARCHPATH | |
6190 char_u *fname; | |
6191 int count; | |
6192 | |
6193 fname = find_file_in_path(eap->arg, (int)STRLEN(eap->arg), FNAME_MESS, | |
6194 TRUE, curbuf->b_ffname); | |
6195 if (eap->addr_count > 0) | |
6196 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6197 // 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
|
6198 // appears several times in the path. |
7 | 6199 count = eap->line2; |
6200 while (fname != NULL && --count > 0) | |
6201 { | |
6202 vim_free(fname); | |
6203 fname = find_file_in_path(NULL, 0, FNAME_MESS, | |
6204 FALSE, curbuf->b_ffname); | |
6205 } | |
6206 } | |
6207 | |
6208 if (fname != NULL) | |
6209 { | |
6210 eap->arg = fname; | |
6211 #endif | |
6212 do_exedit(eap, NULL); | |
6213 #ifdef FEAT_SEARCHPATH | |
6214 vim_free(fname); | |
6215 } | |
6216 #endif | |
6217 } | |
6218 | |
6219 /* | |
167 | 6220 * ":open" simulation: for now just work like ":visual". |
6221 */ | |
6222 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6223 ex_open(exarg_T *eap) |
167 | 6224 { |
6225 regmatch_T regmatch; | |
6226 char_u *p; | |
6227 | |
6228 curwin->w_cursor.lnum = eap->line2; | |
6229 beginline(BL_SOL | BL_FIX); | |
6230 if (*eap->arg == '/') | |
6231 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6232 // ":open /pattern/": put cursor in column found with pattern |
167 | 6233 ++eap->arg; |
19892
5feb426d2ea1
patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19685
diff
changeset
|
6234 p = skip_regexp(eap->arg, '/', p_magic); |
167 | 6235 *p = NUL; |
6236 regmatch.regprog = vim_regcomp(eap->arg, p_magic ? RE_MAGIC : 0); | |
6237 if (regmatch.regprog != NULL) | |
6238 { | |
6239 regmatch.rm_ic = p_ic; | |
6240 p = ml_get_curline(); | |
6241 if (vim_regexec(®match, p, (colnr_T)0)) | |
835 | 6242 curwin->w_cursor.col = (colnr_T)(regmatch.startp[0] - p); |
167 | 6243 else |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
6244 emsg(_(e_nomatch)); |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4803
diff
changeset
|
6245 vim_regfree(regmatch.regprog); |
167 | 6246 } |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6247 // Move to the NUL, ignore any other arguments. |
167 | 6248 eap->arg += STRLEN(eap->arg); |
6249 } | |
6250 check_cursor(); | |
6251 | |
6252 eap->cmdidx = CMD_visual; | |
6253 do_exedit(eap, NULL); | |
6254 } | |
6255 | |
6256 /* | |
6257 * ":edit", ":badd", ":visual". | |
7 | 6258 */ |
6259 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6260 ex_edit(exarg_T *eap) |
7 | 6261 { |
6262 do_exedit(eap, NULL); | |
6263 } | |
6264 | |
6265 /* | |
19195
2ef19eed524a
patch 8.2.0156: various typos in source files and tests
Bram Moolenaar <Bram@vim.org>
parents:
19191
diff
changeset
|
6266 * ":edit <file>" command and alike. |
7 | 6267 */ |
6268 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6269 do_exedit( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6270 exarg_T *eap, |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6271 win_T *old_curwin) // curwin before doing a split or NULL |
7 | 6272 { |
6273 int n; | |
6274 int need_hide; | |
167 | 6275 int exmode_was = exmode_active; |
7 | 6276 |
19271
ebeeb4b4a1fa
patch 8.2.0194: some commands can cause problems in terminal popup
Bram Moolenaar <Bram@vim.org>
parents:
19261
diff
changeset
|
6277 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
|
6278 || 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
|
6279 return; |
7 | 6280 /* |
6281 * ":vi" command ends Ex mode. | |
6282 */ | |
6283 if (exmode_active && (eap->cmdidx == CMD_visual | |
6284 || eap->cmdidx == CMD_view)) | |
6285 { | |
6286 exmode_active = FALSE; | |
20897
213fb059e02e
patch 8.2.1000: get error when leaving Ex mode with :visual
Bram Moolenaar <Bram@vim.org>
parents:
20711
diff
changeset
|
6287 ex_pressedreturn = FALSE; |
7 | 6288 if (*eap->arg == NUL) |
167 | 6289 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6290 // Special case: ":global/pat/visual\NLvi-commands" |
167 | 6291 if (global_busy) |
6292 { | |
6293 int rd = RedrawingDisabled; | |
6294 int nwr = no_wait_return; | |
6295 int ms = msg_scroll; | |
6296 #ifdef FEAT_GUI | |
6297 int he = hold_gui_events; | |
6298 #endif | |
6299 | |
6300 if (eap->nextcmd != NULL) | |
6301 { | |
6302 stuffReadbuff(eap->nextcmd); | |
6303 eap->nextcmd = NULL; | |
6304 } | |
6305 | |
6306 if (exmode_was != EXMODE_VIM) | |
6307 settmode(TMODE_RAW); | |
6308 RedrawingDisabled = 0; | |
6309 no_wait_return = 0; | |
6310 need_wait_return = FALSE; | |
6311 msg_scroll = 0; | |
6312 #ifdef FEAT_GUI | |
6313 hold_gui_events = 0; | |
6314 #endif | |
6315 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
|
6316 pending_exmode_active = TRUE; |
167 | 6317 |
6318 main_loop(FALSE, TRUE); | |
6319 | |
19433
af9d5585cfbf
patch 8.2.0274: hang with combination of feedkeys(), Ex mode and :global
Bram Moolenaar <Bram@vim.org>
parents:
19415
diff
changeset
|
6320 pending_exmode_active = FALSE; |
167 | 6321 RedrawingDisabled = rd; |
6322 no_wait_return = nwr; | |
6323 msg_scroll = ms; | |
6324 #ifdef FEAT_GUI | |
6325 hold_gui_events = he; | |
6326 #endif | |
6327 } | |
7 | 6328 return; |
167 | 6329 } |
7 | 6330 } |
6331 | |
6332 if ((eap->cmdidx == CMD_new | |
675 | 6333 || eap->cmdidx == CMD_tabnew |
6334 || 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
|
6335 || eap->cmdidx == CMD_vnew) && *eap->arg == NUL) |
7 | 6336 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6337 // ":new" or ":tabnew" without argument: edit an new empty buffer |
7 | 6338 setpcmark(); |
6339 (void)do_ecmd(0, NULL, NULL, eap, ECMD_ONE, | |
1743 | 6340 ECMD_HIDE + (eap->forceit ? ECMD_FORCEIT : 0), |
6341 old_curwin == NULL ? curwin : NULL); | |
7 | 6342 } |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
6343 else if ((eap->cmdidx != CMD_split && eap->cmdidx != CMD_vsplit) |
7 | 6344 || *eap->arg != NUL |
6345 #ifdef FEAT_BROWSE | |
6346 || cmdmod.browse | |
6347 #endif | |
6348 ) | |
6349 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6350 // 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
|
6351 // can bring us here, others are stopped earlier. |
822 | 6352 if (*eap->arg != NUL && curbuf_locked()) |
6353 return; | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
6354 |
7 | 6355 n = readonlymode; |
6356 if (eap->cmdidx == CMD_view || eap->cmdidx == CMD_sview) | |
6357 readonlymode = TRUE; | |
6358 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
|
6359 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
|
6360 // empty buffer |
7 | 6361 setpcmark(); |
6362 if (do_ecmd(0, (eap->cmdidx == CMD_enew ? NULL : eap->arg), | |
6363 NULL, eap, | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6364 // ":edit" goes to first line if Vi compatible |
7 | 6365 (*eap->arg == NUL && eap->do_ecmd_lnum == 0 |
6366 && vim_strchr(p_cpo, CPO_GOTO1) != NULL) | |
6367 ? 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
|
6368 (buf_hide(curbuf) ? ECMD_HIDE : 0) |
7 | 6369 + (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
|
6370 // after a split we can use an existing buffer |
5741 | 6371 + (old_curwin != NULL ? ECMD_OLDBUF : 0) |
7 | 6372 + (eap->cmdidx == CMD_badd ? ECMD_ADDBUF : 0 ) |
1743 | 6373 , old_curwin == NULL ? curwin : NULL) == FAIL) |
7 | 6374 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6375 // Editing the file failed. If the window was split, close it. |
7 | 6376 if (old_curwin != NULL) |
6377 { | |
6378 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
|
6379 if (!need_hide || buf_hide(curbuf)) |
7 | 6380 { |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
6381 #if defined(FEAT_EVAL) |
24 | 6382 cleanup_T cs; |
6383 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6384 // 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
|
6385 // aborting() returns FALSE when closing a window. |
24 | 6386 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
|
6387 #endif |
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
6388 #ifdef FEAT_GUI |
7 | 6389 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
|
6390 #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
|
6391 win_close(curwin, !need_hide && !buf_hide(curbuf)); |
24 | 6392 |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
6393 #if defined(FEAT_EVAL) |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6394 // 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
|
6395 // 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
|
6396 // uncaught exception. |
24 | 6397 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
|
6398 #endif |
7 | 6399 } |
6400 } | |
6401 } | |
6402 else if (readonlymode && curbuf->b_nwindows == 1) | |
6403 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6404 // 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
|
6405 // 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
|
6406 // 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
|
6407 // editing the same buffer. |
7 | 6408 curbuf->b_p_ro = TRUE; |
6409 } | |
6410 readonlymode = n; | |
6411 } | |
6412 else | |
6413 { | |
6414 if (eap->do_ecmd_cmd != NULL) | |
6415 do_cmdline_cmd(eap->do_ecmd_cmd); | |
6416 #ifdef FEAT_TITLE | |
6417 n = curwin->w_arg_idx_invalid; | |
6418 #endif | |
6419 check_arg_idx(curwin); | |
6420 #ifdef FEAT_TITLE | |
6421 if (n != curwin->w_arg_idx_invalid) | |
6422 maketitle(); | |
6423 #endif | |
6424 } | |
6425 | |
6426 /* | |
6427 * if ":split file" worked, set alternate file name in old window to new | |
6428 * file | |
6429 */ | |
6430 if (old_curwin != NULL | |
6431 && *eap->arg != NUL | |
6432 && curwin != old_curwin | |
6433 && win_valid(old_curwin) | |
22 | 6434 && old_curwin->w_buffer != curbuf |
6435 && !cmdmod.keepalt) | |
7 | 6436 old_curwin->w_alt_fnum = curbuf->b_fnum; |
6437 | |
6438 ex_no_reprint = TRUE; | |
6439 } | |
6440 | |
6441 #ifndef FEAT_GUI | |
6442 /* | |
6443 * ":gui" and ":gvim" when there is no GUI. | |
6444 */ | |
6445 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6446 ex_nogui(exarg_T *eap) |
7 | 6447 { |
6448 eap->errmsg = e_nogvim; | |
6449 } | |
6450 #endif | |
6451 | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15866
diff
changeset
|
6452 #if defined(FEAT_GUI_MSWIN) && defined(FEAT_MENU) && defined(FEAT_TEAROFF) |
7 | 6453 static void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6454 ex_tearoff(exarg_T *eap) |
7 | 6455 { |
6456 gui_make_tearoff(eap->arg); | |
6457 } | |
6458 #endif | |
6459 | |
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
|
6460 #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
|
6461 || defined(FEAT_TERM_POPUP_MENU)) && defined(FEAT_MENU) |
7 | 6462 static void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6463 ex_popup(exarg_T *eap) |
7 | 6464 { |
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
|
6465 # 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
|
6466 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
|
6467 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
|
6468 # 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
|
6469 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
|
6470 # 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
|
6471 # 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
|
6472 # 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
|
6473 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
|
6474 # endif |
7 | 6475 } |
6476 #endif | |
6477 | |
6478 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6479 ex_swapname(exarg_T *eap UNUSED) |
7 | 6480 { |
6481 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
|
6482 msg(_("No swap file")); |
7 | 6483 else |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15510
diff
changeset
|
6484 msg((char *)curbuf->b_ml.ml_mfp->mf_fname); |
7 | 6485 } |
6486 | |
6487 /* | |
6488 * ":syncbind" forces all 'scrollbind' windows to have the same relative | |
6489 * offset. | |
6490 * (1998-11-02 16:21:01 R. Edward Ralston <eralston@computer.org>) | |
6491 */ | |
6492 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6493 ex_syncbind(exarg_T *eap UNUSED) |
7 | 6494 { |
6495 win_T *wp; | |
5566 | 6496 win_T *save_curwin = curwin; |
6497 buf_T *save_curbuf = curbuf; | |
7 | 6498 long topline; |
6499 long y; | |
6500 linenr_T old_linenr = curwin->w_cursor.lnum; | |
6501 | |
6502 setpcmark(); | |
6503 | |
6504 /* | |
6505 * determine max topline | |
6506 */ | |
6507 if (curwin->w_p_scb) | |
6508 { | |
6509 topline = curwin->w_topline; | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9538
diff
changeset
|
6510 FOR_ALL_WINDOWS(wp) |
7 | 6511 { |
6512 if (wp->w_p_scb && wp->w_buffer) | |
6513 { | |
15713
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15663
diff
changeset
|
6514 y = wp->w_buffer->b_ml.ml_line_count - get_scrolloff_value(); |
7 | 6515 if (topline > y) |
6516 topline = y; | |
6517 } | |
6518 } | |
6519 if (topline < 1) | |
6520 topline = 1; | |
6521 } | |
6522 else | |
6523 { | |
6524 topline = 1; | |
6525 } | |
6526 | |
6527 | |
6528 /* | |
5566 | 6529 * Set all scrollbind windows to the same topline. |
7 | 6530 */ |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9538
diff
changeset
|
6531 FOR_ALL_WINDOWS(curwin) |
7 | 6532 { |
6533 if (curwin->w_p_scb) | |
6534 { | |
5566 | 6535 curbuf = curwin->w_buffer; |
7 | 6536 y = topline - curwin->w_topline; |
6537 if (y > 0) | |
6538 scrollup(y, TRUE); | |
6539 else | |
6540 scrolldown(-y, TRUE); | |
6541 curwin->w_scbind_pos = topline; | |
6542 redraw_later(VALID); | |
6543 cursor_correct(); | |
6544 curwin->w_redr_status = TRUE; | |
6545 } | |
6546 } | |
5566 | 6547 curwin = save_curwin; |
6548 curbuf = save_curbuf; | |
7 | 6549 if (curwin->w_p_scb) |
6550 { | |
6551 did_syncbind = TRUE; | |
6552 checkpcmark(); | |
6553 if (old_linenr != curwin->w_cursor.lnum) | |
6554 { | |
6555 char_u ctrl_o[2]; | |
6556 | |
6557 ctrl_o[0] = Ctrl_O; | |
6558 ctrl_o[1] = 0; | |
6559 ins_typebuf(ctrl_o, REMAP_NONE, 0, TRUE, FALSE); | |
6560 } | |
6561 } | |
6562 } | |
6563 | |
6564 | |
6565 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6566 ex_read(exarg_T *eap) |
7 | 6567 { |
167 | 6568 int i; |
6569 int empty = (curbuf->b_ml.ml_flags & ML_EMPTY); | |
6570 linenr_T lnum; | |
7 | 6571 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6572 if (eap->usefilter) // :r!cmd |
7 | 6573 do_bang(1, eap, FALSE, FALSE, TRUE); |
6574 else | |
6575 { | |
6576 if (u_save(eap->line2, (linenr_T)(eap->line2 + 1)) == FAIL) | |
6577 return; | |
6578 | |
6579 #ifdef FEAT_BROWSE | |
6580 if (cmdmod.browse) | |
6581 { | |
6582 char_u *browseFile; | |
6583 | |
28 | 6584 browseFile = do_browse(0, (char_u *)_("Append File"), eap->arg, |
7 | 6585 NULL, NULL, NULL, curbuf); |
6586 if (browseFile != NULL) | |
6587 { | |
6588 i = readfile(browseFile, NULL, | |
6589 eap->line2, (linenr_T)0, (linenr_T)MAXLNUM, eap, 0); | |
6590 vim_free(browseFile); | |
6591 } | |
6592 else | |
6593 i = OK; | |
6594 } | |
6595 else | |
6596 #endif | |
6597 if (*eap->arg == NUL) | |
6598 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6599 if (check_fname() == FAIL) // check for no file name |
7 | 6600 return; |
6601 i = readfile(curbuf->b_ffname, curbuf->b_fname, | |
6602 eap->line2, (linenr_T)0, (linenr_T)MAXLNUM, eap, 0); | |
6603 } | |
6604 else | |
6605 { | |
6606 if (vim_strchr(p_cpo, CPO_ALTREAD) != NULL) | |
6607 (void)setaltfname(eap->arg, eap->arg, (linenr_T)1); | |
6608 i = readfile(eap->arg, NULL, | |
6609 eap->line2, (linenr_T)0, (linenr_T)MAXLNUM, eap, 0); | |
6610 | |
6611 } | |
10575
01a5f64a7a20
patch 8.0.0177: BufEnter autocommand not fired for a directory
Christian Brabandt <cb@256bit.org>
parents:
10520
diff
changeset
|
6612 if (i != OK) |
7 | 6613 { |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
6614 #if defined(FEAT_EVAL) |
7 | 6615 if (!aborting()) |
6616 #endif | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
6617 semsg(_(e_notopen), eap->arg); |
7 | 6618 } |
6619 else | |
167 | 6620 { |
6621 if (empty && exmode_active) | |
6622 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6623 // 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
|
6624 // this but vi doesn't. |
167 | 6625 if (eap->line2 == 0) |
6626 lnum = curbuf->b_ml.ml_line_count; | |
6627 else | |
6628 lnum = 1; | |
573 | 6629 if (*ml_get(lnum) == NUL && u_savedel(lnum, 1L) == OK) |
167 | 6630 { |
20599
d571231175b4
patch 8.2.0853: ml_delete() often called with FALSE argument
Bram Moolenaar <Bram@vim.org>
parents:
20575
diff
changeset
|
6631 ml_delete(lnum); |
573 | 6632 if (curwin->w_cursor.lnum > 1 |
6633 && curwin->w_cursor.lnum >= lnum) | |
167 | 6634 --curwin->w_cursor.lnum; |
1929 | 6635 deleted_lines_mark(lnum, 1L); |
167 | 6636 } |
6637 } | |
7 | 6638 redraw_curbuf_later(VALID); |
167 | 6639 } |
7 | 6640 } |
6641 } | |
6642 | |
358 | 6643 static char_u *prev_dir = NULL; |
6644 | |
6645 #if defined(EXITFREE) || defined(PROTO) | |
6646 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6647 free_cd_dir(void) |
358 | 6648 { |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13221
diff
changeset
|
6649 VIM_CLEAR(prev_dir); |
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13221
diff
changeset
|
6650 VIM_CLEAR(globaldir); |
358 | 6651 } |
6652 #endif | |
6653 | |
4704
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
6654 /* |
20711
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
6655 * Get the previous directory for the given chdir scope. |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
6656 */ |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
6657 static char_u * |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
6658 get_prevdir(cdscope_T scope) |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
6659 { |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
6660 if (scope == CDSCOPE_WINDOW) |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
6661 return curwin->w_prevdir; |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
6662 else if (scope == CDSCOPE_TABPAGE) |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
6663 return curtab->tp_prevdir; |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
6664 return prev_dir; |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
6665 } |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
6666 |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
6667 /* |
4704
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
6668 * 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
|
6669 * 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
|
6670 * 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
|
6671 */ |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
6672 void |
16576
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6673 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
|
6674 { |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6675 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
|
6676 // 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
|
6677 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
|
6678 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
|
6679 if (scope != CDSCOPE_GLOBAL) |
4704
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
6680 { |
20711
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
6681 char_u *pdir = get_prevdir(scope); |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
6682 |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
6683 // If still in the global directory, need to remember current |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
6684 // directory as the global directory. |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
6685 if (globaldir == NULL && pdir != NULL) |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
6686 globaldir = vim_strsave(pdir); |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
6687 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6688 // Remember this local directory for the window. |
4704
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
6689 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
|
6690 { |
16576
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6691 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
|
6692 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
|
6693 else |
8c3a1bd270bb
patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents:
16411
diff
changeset
|
6694 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
|
6695 } |
4704
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
6696 } |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
6697 else |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
6698 { |
20711
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
6699 // We are now in the global directory, no need to remember its name. |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13221
diff
changeset
|
6700 VIM_CLEAR(globaldir); |
4704
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
6701 } |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
6702 |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
6703 shorten_fnames(TRUE); |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
6704 } |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
6705 |
16576
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6706 /* |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6707 * Change directory function used by :cd/:tcd/:lcd Ex commands and the |
20645
b60bb094af52
patch 8.2.0876: :pwd does not give a hint about the scope of the directory
Bram Moolenaar <Bram@vim.org>
parents:
20599
diff
changeset
|
6708 * chdir() function. |
b60bb094af52
patch 8.2.0876: :pwd does not give a hint about the scope of the directory
Bram Moolenaar <Bram@vim.org>
parents:
20599
diff
changeset
|
6709 * scope == CDSCOPE_WINDOW: changes the window-local directory |
b60bb094af52
patch 8.2.0876: :pwd does not give a hint about the scope of the directory
Bram Moolenaar <Bram@vim.org>
parents:
20599
diff
changeset
|
6710 * scope == CDSCOPE_TABPAGE: changes the tab-local directory |
b60bb094af52
patch 8.2.0876: :pwd does not give a hint about the scope of the directory
Bram Moolenaar <Bram@vim.org>
parents:
20599
diff
changeset
|
6711 * Otherwise: changes the global directory |
16576
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6712 * 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
|
6713 */ |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6714 int |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6715 changedir_func( |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6716 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
|
6717 int forceit, |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6718 cdscope_T scope) |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6719 { |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6720 char_u *tofree; |
20711
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
6721 char_u *pdir = NULL; |
16576
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6722 int dir_differs; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6723 int retval = FALSE; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6724 |
19261
a20c66f13a6e
patch 8.2.0189: cd() with NULL argument crashes
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
6725 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
|
6726 return FALSE; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6727 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6728 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
|
6729 { |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6730 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
|
6731 return FALSE; |
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 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6734 // ":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
|
6735 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
|
6736 { |
20711
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
6737 pdir = get_prevdir(scope); |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
6738 if (pdir == NULL) |
16576
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6739 { |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6740 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
|
6741 return FALSE; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6742 } |
20711
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
6743 new_dir = pdir; |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
6744 } |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
6745 |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
6746 // Free the previous directory |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
6747 tofree = get_prevdir(scope); |
16576
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6748 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6749 // 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
|
6750 if (mch_dirname(NameBuff, MAXPATHL) == OK) |
20711
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
6751 pdir = vim_strsave(NameBuff); |
16576
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6752 else |
20711
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
6753 pdir = NULL; |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
6754 if (scope == CDSCOPE_WINDOW) |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
6755 curwin->w_prevdir = pdir; |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
6756 else if (scope == CDSCOPE_TABPAGE) |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
6757 curtab->tp_prevdir = pdir; |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
6758 else |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
6759 prev_dir = pdir; |
16576
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6760 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6761 #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
|
6762 // 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
|
6763 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
|
6764 { |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6765 // 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
|
6766 # ifdef VMS |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6767 char_u *p; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6768 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6769 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
|
6770 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
|
6771 NameBuff[0] = NUL; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6772 else |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6773 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
|
6774 # else |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6775 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
|
6776 # endif |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6777 new_dir = NameBuff; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6778 } |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6779 #endif |
20711
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
6780 dir_differs = new_dir == NULL || pdir == NULL |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20659
diff
changeset
|
6781 || pathcmp((char *)pdir, (char *)new_dir, -1) != 0; |
16576
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6782 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
|
6783 emsg(_(e_failed)); |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6784 else |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6785 { |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6786 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
|
6787 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6788 post_chdir(scope); |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6789 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6790 if (dir_differs) |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6791 { |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6792 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
|
6793 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
|
6794 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
|
6795 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
|
6796 else |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6797 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
|
6798 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
|
6799 curbuf); |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6800 } |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6801 retval = TRUE; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6802 } |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6803 vim_free(tofree); |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6804 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6805 return retval; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6806 } |
358 | 6807 |
7 | 6808 /* |
16427
8c3a1bd270bb
patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents:
16411
diff
changeset
|
6809 * ":cd", ":tcd", ":lcd", ":chdir" ":tchdir" and ":lchdir". |
7 | 6810 */ |
1411 | 6811 void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6812 ex_cd(exarg_T *eap) |
7 | 6813 { |
15184
90ab2d3ce11d
patch 8.1.0602: DirChanged is also triggered when directory didn't change
Bram Moolenaar <Bram@vim.org>
parents:
15152
diff
changeset
|
6814 char_u *new_dir; |
7 | 6815 |
6816 new_dir = eap->arg; | |
6817 #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
|
6818 // for non-UNIX ":cd" means: print current directory |
7 | 6819 if (*new_dir == NUL) |
6820 ex_pwd(NULL); | |
6821 else | |
6822 #endif | |
6823 { | |
16576
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6824 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
|
6825 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6826 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
|
6827 scope = CDSCOPE_WINDOW; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6828 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
|
6829 scope = CDSCOPE_TABPAGE; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6830 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6831 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
|
6832 { |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
6833 // Echo the new current directory if the command was typed. |
1930 | 6834 if (KeyTyped || p_verbose >= 5) |
7 | 6835 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
|
6836 } |
7 | 6837 } |
6838 } | |
6839 | |
6840 /* | |
6841 * ":pwd". | |
6842 */ | |
6843 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6844 ex_pwd(exarg_T *eap UNUSED) |
7 | 6845 { |
6846 if (mch_dirname(NameBuff, MAXPATHL) == OK) | |
6847 { | |
6848 #ifdef BACKSLASH_IN_FILENAME | |
6849 slash_adjust(NameBuff); | |
6850 #endif | |
20645
b60bb094af52
patch 8.2.0876: :pwd does not give a hint about the scope of the directory
Bram Moolenaar <Bram@vim.org>
parents:
20599
diff
changeset
|
6851 if (p_verbose > 0) |
b60bb094af52
patch 8.2.0876: :pwd does not give a hint about the scope of the directory
Bram Moolenaar <Bram@vim.org>
parents:
20599
diff
changeset
|
6852 { |
b60bb094af52
patch 8.2.0876: :pwd does not give a hint about the scope of the directory
Bram Moolenaar <Bram@vim.org>
parents:
20599
diff
changeset
|
6853 char *context = "global"; |
b60bb094af52
patch 8.2.0876: :pwd does not give a hint about the scope of the directory
Bram Moolenaar <Bram@vim.org>
parents:
20599
diff
changeset
|
6854 |
b60bb094af52
patch 8.2.0876: :pwd does not give a hint about the scope of the directory
Bram Moolenaar <Bram@vim.org>
parents:
20599
diff
changeset
|
6855 if (curwin->w_localdir != NULL) |
b60bb094af52
patch 8.2.0876: :pwd does not give a hint about the scope of the directory
Bram Moolenaar <Bram@vim.org>
parents:
20599
diff
changeset
|
6856 context = "window"; |
b60bb094af52
patch 8.2.0876: :pwd does not give a hint about the scope of the directory
Bram Moolenaar <Bram@vim.org>
parents:
20599
diff
changeset
|
6857 else if (curtab->tp_localdir != NULL) |
b60bb094af52
patch 8.2.0876: :pwd does not give a hint about the scope of the directory
Bram Moolenaar <Bram@vim.org>
parents:
20599
diff
changeset
|
6858 context = "tabpage"; |
b60bb094af52
patch 8.2.0876: :pwd does not give a hint about the scope of the directory
Bram Moolenaar <Bram@vim.org>
parents:
20599
diff
changeset
|
6859 smsg("[%s] %s", context, (char *)NameBuff); |
b60bb094af52
patch 8.2.0876: :pwd does not give a hint about the scope of the directory
Bram Moolenaar <Bram@vim.org>
parents:
20599
diff
changeset
|
6860 } |
b60bb094af52
patch 8.2.0876: :pwd does not give a hint about the scope of the directory
Bram Moolenaar <Bram@vim.org>
parents:
20599
diff
changeset
|
6861 else |
b60bb094af52
patch 8.2.0876: :pwd does not give a hint about the scope of the directory
Bram Moolenaar <Bram@vim.org>
parents:
20599
diff
changeset
|
6862 msg((char *)NameBuff); |
7 | 6863 } |
6864 else | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
6865 emsg(_("E187: Unknown")); |
7 | 6866 } |
6867 | |
6868 /* | |
6869 * ":=". | |
6870 */ | |
6871 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6872 ex_equal(exarg_T *eap) |
7 | 6873 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
6874 smsg("%ld", (long)eap->line2); |
167 | 6875 ex_may_print(eap); |
7 | 6876 } |
6877 | |
6878 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6879 ex_sleep(exarg_T *eap) |
7 | 6880 { |
236 | 6881 int n; |
6882 long len; | |
7 | 6883 |
6884 if (cursor_valid()) | |
6885 { | |
6886 n = W_WINROW(curwin) + curwin->w_wrow - msg_scrolled; | |
6887 if (n >= 0) | |
12513
3ca08bf99396
patch 8.0.1135: W_WINCOL() is always the same
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
6888 windgoto((int)n, curwin->w_wincol + curwin->w_wcol); |
7 | 6889 } |
236 | 6890 |
6891 len = eap->line2; | |
6892 switch (*eap->arg) | |
6893 { | |
6894 case 'm': break; | |
6895 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
|
6896 default: semsg(_(e_invarg2), eap->arg); return; |
236 | 6897 } |
6898 do_sleep(len); | |
7 | 6899 } |
6900 | |
6901 /* | |
6902 * Sleep for "msec" milliseconds, but keep checking for a CTRL-C every second. | |
6903 */ | |
6904 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6905 do_sleep(long msec) |
7 | 6906 { |
17712
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
6907 long done = 0; |
8577
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
6908 long wait_now; |
17712
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
6909 # ifdef ELAPSED_FUNC |
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
6910 elapsed_T start_tv; |
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
6911 |
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
6912 // 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
|
6913 // 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
|
6914 ELAPSED_INIT(start_tv); |
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
6915 # endif |
7 | 6916 |
6917 cursor_on(); | |
14860
ac5d0d27aef9
patch 8.1.0442: GUI: cursor not drawn after ":redraw | sleep"
Christian Brabandt <cb@256bit.org>
parents:
14760
diff
changeset
|
6918 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
|
6919 while (!got_int && done < msec) |
8577
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
6920 { |
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
6921 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
|
6922 #ifdef FEAT_TIMERS |
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
6923 { |
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
6924 long due_time = check_due_timer(); |
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
6925 |
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
6926 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
|
6927 wait_now = due_time; |
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
6928 } |
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
6929 #endif |
10240
175b1116f96a
commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents:
10184
diff
changeset
|
6930 #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
|
6931 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
|
6932 wait_now = 20L; |
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17652
diff
changeset
|
6933 #endif |
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17652
diff
changeset
|
6934 #ifdef FEAT_SOUND |
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17652
diff
changeset
|
6935 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
|
6936 wait_now = 20L; |
10240
175b1116f96a
commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents:
10184
diff
changeset
|
6937 #endif |
8577
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
6938 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
|
6939 |
10240
175b1116f96a
commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents:
10184
diff
changeset
|
6940 #ifdef FEAT_JOB_CHANNEL |
175b1116f96a
commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents:
10184
diff
changeset
|
6941 if (has_any_channel()) |
175b1116f96a
commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents:
10184
diff
changeset
|
6942 ui_breakcheck_force(TRUE); |
175b1116f96a
commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents:
10184
diff
changeset
|
6943 else |
175b1116f96a
commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents:
10184
diff
changeset
|
6944 #endif |
175b1116f96a
commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents:
10184
diff
changeset
|
6945 ui_breakcheck(); |
7109
fa95595fbc52
commit https://github.com/vim/vim/commit/93c88e0f6a4a8f7634ed84721daf4af46fc0d5db
Christian Brabandt <cb@256bit.org>
parents:
7105
diff
changeset
|
6946 #ifdef MESSAGE_QUEUE |
17712
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
6947 // 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
|
6948 // 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
|
6949 // 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
|
6950 parse_queued_messages(); |
3151 | 6951 #endif |
17712
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
6952 |
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
6953 # ifdef ELAPSED_FUNC |
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
6954 // actual time passed |
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
6955 done = ELAPSED_FUNC(start_tv); |
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
6956 # else |
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
6957 // 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
|
6958 done += wait_now; |
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
6959 # endif |
7 | 6960 } |
14284
7cd8298c4c04
patch 8.1.0158: GUI: input() fails if CTRL-C was pressed before
Christian Brabandt <cb@256bit.org>
parents:
14266
diff
changeset
|
6961 |
7cd8298c4c04
patch 8.1.0158: GUI: input() fails if CTRL-C was pressed before
Christian Brabandt <cb@256bit.org>
parents:
14266
diff
changeset
|
6962 // 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
|
6963 // 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
|
6964 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
|
6965 (void)vpeekc(); |
7 | 6966 } |
6967 | |
6968 /* | |
6969 * ":winsize" command (obsolete). | |
6970 */ | |
6971 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6972 ex_winsize(exarg_T *eap) |
7 | 6973 { |
6974 int w, h; | |
6975 char_u *arg = eap->arg; | |
6976 char_u *p; | |
6977 | |
6978 w = getdigits(&arg); | |
6979 arg = skipwhite(arg); | |
6980 p = arg; | |
6981 h = getdigits(&arg); | |
6982 if (*p != NUL && *arg == NUL) | |
6983 set_shellsize(w, h, TRUE); | |
6984 else | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
6985 emsg(_("E465: :winsize requires two number arguments")); |
7 | 6986 } |
6987 | |
6988 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6989 ex_wincmd(exarg_T *eap) |
7 | 6990 { |
6991 int xchar = NUL; | |
6992 char_u *p; | |
6993 | |
6994 if (*eap->arg == 'g' || *eap->arg == Ctrl_G) | |
6995 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
6996 // CTRL-W g and CTRL-W CTRL-G have an extra command character |
7 | 6997 if (eap->arg[1] == NUL) |
6998 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
6999 emsg(_(e_invarg)); |
7 | 7000 return; |
7001 } | |
7002 xchar = eap->arg[1]; | |
7003 p = eap->arg + 2; | |
7004 } | |
7005 else | |
7006 p = eap->arg + 1; | |
7007 | |
7008 eap->nextcmd = check_nextcmd(p); | |
7009 p = skipwhite(p); | |
7010 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
|
7011 emsg(_(e_invarg)); |
2887 | 7012 else if (!eap->skip) |
7 | 7013 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7014 // Pass flags on for ":vertical wincmd ]". |
7 | 7015 postponed_split_flags = cmdmod.split; |
1090 | 7016 postponed_split_tab = cmdmod.tab; |
7 | 7017 do_window(*eap->arg, eap->addr_count > 0 ? eap->line2 : 0L, xchar); |
7018 postponed_split_flags = 0; | |
1090 | 7019 postponed_split_tab = 0; |
7 | 7020 } |
7021 } | |
7022 | |
11 | 7023 #if defined(FEAT_GUI) || defined(UNIX) || defined(VMS) || defined(MSWIN) |
7 | 7024 /* |
7025 * ":winpos". | |
7026 */ | |
7027 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7028 ex_winpos(exarg_T *eap) |
7 | 7029 { |
7030 int x, y; | |
7031 char_u *arg = eap->arg; | |
7032 char_u *p; | |
7033 | |
7034 if (*arg == NUL) | |
7035 { | |
11 | 7036 # 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
|
7037 # 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
|
7038 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
|
7039 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
|
7040 # elif defined(FEAT_GUI) |
7 | 7041 if (gui.in_use && gui_mch_get_winpos(&x, &y) != FAIL) |
11 | 7042 # else |
7043 if (mch_get_winpos(&x, &y) != FAIL) | |
7044 # endif | |
7 | 7045 { |
7046 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
|
7047 msg((char *)IObuff); |
7 | 7048 } |
7049 else | |
7050 # endif | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7051 emsg(_("E188: Obtaining window position not implemented for this platform")); |
7 | 7052 } |
7053 else | |
7054 { | |
7055 x = getdigits(&arg); | |
7056 arg = skipwhite(arg); | |
7057 p = arg; | |
7058 y = getdigits(&arg); | |
7059 if (*p == NUL || *arg != NUL) | |
7060 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7061 emsg(_("E466: :winpos requires two number arguments")); |
7 | 7062 return; |
7063 } | |
7064 # ifdef FEAT_GUI | |
7065 if (gui.in_use) | |
7066 gui_mch_set_winpos(x, y); | |
7067 else if (gui.starting) | |
7068 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7069 // Remember the coordinates for when the window is opened. |
7 | 7070 gui_win_x = x; |
7071 gui_win_y = y; | |
7072 } | |
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
|
7073 # if defined(HAVE_TGETENT) || defined(VIMDLL) |
7 | 7074 else |
7075 # 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
|
7076 # 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
|
7077 # if defined(MSWIN) && (!defined(FEAT_GUI) || defined(VIMDLL)) |
11 | 7078 mch_set_winpos(x, y); |
7 | 7079 # endif |
7080 # ifdef HAVE_TGETENT | |
7081 if (*T_CWP) | |
7082 term_set_winpos(x, y); | |
7083 # endif | |
7084 } | |
7085 } | |
7086 #endif | |
7087 | |
7088 /* | |
7089 * Handle command that work like operators: ":delete", ":yank", ":>" and ":<". | |
7090 */ | |
7091 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7092 ex_operators(exarg_T *eap) |
7 | 7093 { |
7094 oparg_T oa; | |
7095 | |
7096 clear_oparg(&oa); | |
7097 oa.regname = eap->regname; | |
7098 oa.start.lnum = eap->line1; | |
7099 oa.end.lnum = eap->line2; | |
7100 oa.line_count = eap->line2 - eap->line1 + 1; | |
7101 oa.motion_type = MLINE; | |
7102 virtual_op = FALSE; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7103 if (eap->cmdidx != CMD_yank) // position cursor for undo |
7 | 7104 { |
7105 setpcmark(); | |
7106 curwin->w_cursor.lnum = eap->line1; | |
7107 beginline(BL_SOL | BL_FIX); | |
7108 } | |
7109 | |
5498 | 7110 if (VIsual_active) |
7111 end_visual_mode(); | |
7112 | |
7 | 7113 switch (eap->cmdidx) |
7114 { | |
7115 case CMD_delete: | |
7116 oa.op_type = OP_DELETE; | |
7117 op_delete(&oa); | |
7118 break; | |
7119 | |
7120 case CMD_yank: | |
7121 oa.op_type = OP_YANK; | |
7122 (void)op_yank(&oa, FALSE, TRUE); | |
7123 break; | |
7124 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7125 default: // CMD_rshift or CMD_lshift |
4889
25d64a4edc0b
updated for version 7.3.1190
Bram Moolenaar <bram@vim.org>
parents:
4857
diff
changeset
|
7126 if ( |
7 | 7127 #ifdef FEAT_RIGHTLEFT |
4889
25d64a4edc0b
updated for version 7.3.1190
Bram Moolenaar <bram@vim.org>
parents:
4857
diff
changeset
|
7128 (eap->cmdidx == CMD_rshift) ^ curwin->w_p_rl |
25d64a4edc0b
updated for version 7.3.1190
Bram Moolenaar <bram@vim.org>
parents:
4857
diff
changeset
|
7129 #else |
25d64a4edc0b
updated for version 7.3.1190
Bram Moolenaar <bram@vim.org>
parents:
4857
diff
changeset
|
7130 eap->cmdidx == CMD_rshift |
25d64a4edc0b
updated for version 7.3.1190
Bram Moolenaar <bram@vim.org>
parents:
4857
diff
changeset
|
7131 #endif |
25d64a4edc0b
updated for version 7.3.1190
Bram Moolenaar <bram@vim.org>
parents:
4857
diff
changeset
|
7132 ) |
7 | 7133 oa.op_type = OP_RSHIFT; |
7134 else | |
7135 oa.op_type = OP_LSHIFT; | |
7136 op_shift(&oa, FALSE, eap->amount); | |
7137 break; | |
7138 } | |
7139 virtual_op = MAYBE; | |
167 | 7140 ex_may_print(eap); |
7 | 7141 } |
7142 | |
7143 /* | |
7144 * ":put". | |
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_put(exarg_T *eap) |
7 | 7148 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7149 // ":0put" works like ":1put!". |
7 | 7150 if (eap->line2 == 0) |
7151 { | |
7152 eap->line2 = 1; | |
7153 eap->forceit = TRUE; | |
7154 } | |
7155 curwin->w_cursor.lnum = eap->line2; | |
167 | 7156 do_put(eap->regname, eap->forceit ? BACKWARD : FORWARD, 1L, |
7157 PUT_LINE|PUT_CURSLINE); | |
7 | 7158 } |
7159 | |
7160 /* | |
7161 * Handle ":copy" and ":move". | |
7162 */ | |
7163 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7164 ex_copymove(exarg_T *eap) |
7 | 7165 { |
7166 long n; | |
7167 | |
14760
fd69edd2c67e
patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents:
14700
diff
changeset
|
7168 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
|
7169 if (eap->arg == NULL) // error detected |
7 | 7170 { |
7171 eap->nextcmd = NULL; | |
7172 return; | |
7173 } | |
167 | 7174 get_flags(eap); |
7 | 7175 |
7176 /* | |
7177 * move or copy lines from 'eap->line1'-'eap->line2' to below line 'n' | |
7178 */ | |
7179 if (n == MAXLNUM || n < 0 || n > curbuf->b_ml.ml_line_count) | |
7180 { | |
17650
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
7181 emsg(_(e_invrange)); |
7 | 7182 return; |
7183 } | |
7184 | |
7185 if (eap->cmdidx == CMD_move) | |
7186 { | |
7187 if (do_move(eap->line1, eap->line2, n) == FAIL) | |
7188 return; | |
7189 } | |
7190 else | |
7191 ex_copy(eap->line1, eap->line2, n); | |
7192 u_clearline(); | |
7193 beginline(BL_SOL | BL_FIX); | |
167 | 7194 ex_may_print(eap); |
7195 } | |
7196 | |
7197 /* | |
7198 * Print the current line if flags were given to the Ex command. | |
7199 */ | |
5776 | 7200 void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7201 ex_may_print(exarg_T *eap) |
167 | 7202 { |
7203 if (eap->flags != 0) | |
7204 { | |
7205 print_line(curwin->w_cursor.lnum, (eap->flags & EXFLAG_NR), | |
7206 (eap->flags & EXFLAG_LIST)); | |
7207 ex_no_reprint = TRUE; | |
7208 } | |
7 | 7209 } |
7210 | |
7211 /* | |
7212 * ":smagic" and ":snomagic". | |
7213 */ | |
7214 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7215 ex_submagic(exarg_T *eap) |
7 | 7216 { |
7217 int magic_save = p_magic; | |
7218 | |
7219 p_magic = (eap->cmdidx == CMD_smagic); | |
7220 do_sub(eap); | |
7221 p_magic = magic_save; | |
7222 } | |
7223 | |
7224 /* | |
7225 * ":join". | |
7226 */ | |
7227 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7228 ex_join(exarg_T *eap) |
7 | 7229 { |
7230 curwin->w_cursor.lnum = eap->line1; | |
7231 if (eap->line1 == eap->line2) | |
7232 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7233 if (eap->addr_count >= 2) // :2,2join does nothing |
7 | 7234 return; |
7235 if (eap->line2 == curbuf->b_ml.ml_line_count) | |
7236 { | |
7237 beep_flush(); | |
7238 return; | |
7239 } | |
7240 ++eap->line2; | |
7241 } | |
5848 | 7242 (void)do_join(eap->line2 - eap->line1 + 1, !eap->forceit, TRUE, TRUE, TRUE); |
7 | 7243 beginline(BL_WHITE | BL_FIX); |
167 | 7244 ex_may_print(eap); |
7 | 7245 } |
7246 | |
7247 /* | |
7248 * ":[addr]@r" or ":[addr]*r": execute register | |
7249 */ | |
7250 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7251 ex_at(exarg_T *eap) |
7 | 7252 { |
7253 int c; | |
1973 | 7254 int prev_len = typebuf.tb_len; |
7 | 7255 |
7256 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
|
7257 check_cursor_col(); |
7 | 7258 |
7259 #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
|
7260 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
|
7261 #endif |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7262 |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7263 // get the register name. No name means to use the previous one |
7 | 7264 c = *eap->arg; |
7265 if (c == NUL || (c == '*' && *eap->cmd == '*')) | |
7266 c = '@'; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7267 // Put the register in the typeahead buffer with the "silent" flag. |
1034 | 7268 if (do_execreg(c, TRUE, vim_strchr(p_cpo, CPO_EXECBUF) != NULL, TRUE) |
7269 == FAIL) | |
167 | 7270 { |
7 | 7271 beep_flush(); |
167 | 7272 } |
7 | 7273 else |
7274 { | |
7275 int save_efr = exec_from_reg; | |
7276 | |
7277 exec_from_reg = TRUE; | |
7278 | |
7279 /* | |
7280 * Execute from the typeahead buffer. | |
1973 | 7281 * Continue until the stuff buffer is empty and all added characters |
7282 * have been consumed. | |
7 | 7283 */ |
1973 | 7284 while (!stuff_empty() || typebuf.tb_len > prev_len) |
7 | 7285 (void)do_cmdline(NULL, getexline, NULL, DOCMD_NOWAIT|DOCMD_VERBOSE); |
7286 | |
7287 exec_from_reg = save_efr; | |
7288 } | |
7289 } | |
7290 | |
7291 /* | |
7292 * ":!". | |
7293 */ | |
7294 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7295 ex_bang(exarg_T *eap) |
7 | 7296 { |
7297 do_bang(eap->addr_count, eap, eap->forceit, TRUE, TRUE); | |
7298 } | |
7299 | |
7300 /* | |
7301 * ":undo". | |
7302 */ | |
7303 static void | |
8368
db2a07b710ed
commit https://github.com/vim/vim/commit/f1d2501ebe33e148886c2914acd33140e20ee222
Christian Brabandt <cb@256bit.org>
parents:
8281
diff
changeset
|
7304 ex_undo(exarg_T *eap) |
7 | 7305 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7306 if (eap->addr_count == 1) // :undo 123 |
2281
e41433ea71df
Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents:
2276
diff
changeset
|
7307 undo_time(eap->line2, FALSE, FALSE, TRUE); |
771 | 7308 else |
7309 u_undo(1); | |
7 | 7310 } |
7311 | |
2214
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
7312 #ifdef FEAT_PERSISTENT_UNDO |
2340
99c1eba60b2d
Make automatic prototype generation work with more interfaces.
Bram Moolenaar <bram@vim.org>
parents:
2333
diff
changeset
|
7313 static void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7314 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
|
7315 { |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
7316 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
|
7317 |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
7318 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
|
7319 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
|
7320 } |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
7321 |
2340
99c1eba60b2d
Make automatic prototype generation work with more interfaces.
Bram Moolenaar <bram@vim.org>
parents:
2333
diff
changeset
|
7322 static void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7323 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
|
7324 { |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
7325 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
|
7326 |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
7327 u_compute_hash(hash); |
2238
3d0a7beb0d75
Made reading/writing undo info a bit more robust.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
7328 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
|
7329 } |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
7330 #endif |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
7331 |
7 | 7332 /* |
7333 * ":redo". | |
7334 */ | |
7335 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7336 ex_redo(exarg_T *eap UNUSED) |
7 | 7337 { |
7338 u_redo(1); | |
7339 } | |
7340 | |
7341 /* | |
756 | 7342 * ":earlier" and ":later". |
7343 */ | |
7344 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7345 ex_later(exarg_T *eap) |
756 | 7346 { |
7347 long count = 0; | |
7348 int sec = FALSE; | |
2281
e41433ea71df
Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents:
2276
diff
changeset
|
7349 int file = FALSE; |
756 | 7350 char_u *p = eap->arg; |
7351 | |
7352 if (*p == NUL) | |
7353 count = 1; | |
7354 else if (isdigit(*p)) | |
7355 { | |
7356 count = getdigits(&p); | |
7357 switch (*p) | |
7358 { | |
7359 case 's': ++p; sec = TRUE; break; | |
7360 case 'm': ++p; sec = TRUE; count *= 60; break; | |
7361 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
|
7362 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
|
7363 case 'f': ++p; file = TRUE; break; |
756 | 7364 } |
7365 } | |
7366 | |
7367 if (*p != NUL) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7368 semsg(_(e_invarg2), eap->arg); |
756 | 7369 else |
2281
e41433ea71df
Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents:
2276
diff
changeset
|
7370 undo_time(eap->cmdidx == CMD_earlier ? -count : count, |
e41433ea71df
Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents:
2276
diff
changeset
|
7371 sec, file, FALSE); |
756 | 7372 } |
7373 | |
7374 /* | |
7 | 7375 * ":redir": start/stop redirection. |
7376 */ | |
7377 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7378 ex_redir(exarg_T *eap) |
7 | 7379 { |
7380 char *mode; | |
7381 char_u *fname; | |
122 | 7382 char_u *arg = eap->arg; |
7 | 7383 |
9440
73c0d07cc15e
commit https://github.com/vim/vim/commit/ba768495c2e6bae74e49d22d489fbf211ecad55e
Christian Brabandt <cb@256bit.org>
parents:
9438
diff
changeset
|
7384 #ifdef FEAT_EVAL |
9454
9da0cb39cbee
commit https://github.com/vim/vim/commit/79815f1ec77406f2f21a618c053e5793b597db7a
Christian Brabandt <cb@256bit.org>
parents:
9440
diff
changeset
|
7385 if (redir_execute) |
9da0cb39cbee
commit https://github.com/vim/vim/commit/79815f1ec77406f2f21a618c053e5793b597db7a
Christian Brabandt <cb@256bit.org>
parents:
9440
diff
changeset
|
7386 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7387 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
|
7388 return; |
7897b1e4f3e7
commit https://github.com/vim/vim/commit/245a7cb6d33e556415c9fcaa874b784a6d8f0ef3
Christian Brabandt <cb@256bit.org>
parents:
9432
diff
changeset
|
7389 } |
9440
73c0d07cc15e
commit https://github.com/vim/vim/commit/ba768495c2e6bae74e49d22d489fbf211ecad55e
Christian Brabandt <cb@256bit.org>
parents:
9438
diff
changeset
|
7390 #endif |
9438
7897b1e4f3e7
commit https://github.com/vim/vim/commit/245a7cb6d33e556415c9fcaa874b784a6d8f0ef3
Christian Brabandt <cb@256bit.org>
parents:
9432
diff
changeset
|
7391 |
7 | 7392 if (STRICMP(eap->arg, "END") == 0) |
7393 close_redir(); | |
7394 else | |
7395 { | |
122 | 7396 if (*arg == '>') |
7397 { | |
7398 ++arg; | |
7399 if (*arg == '>') | |
7400 { | |
7401 ++arg; | |
7 | 7402 mode = "a"; |
7403 } | |
7404 else | |
7405 mode = "w"; | |
122 | 7406 arg = skipwhite(arg); |
7 | 7407 |
7408 close_redir(); | |
7409 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7410 // Expand environment variables and "~/". |
122 | 7411 fname = expand_env_save(arg); |
7 | 7412 if (fname == NULL) |
7413 return; | |
7414 #ifdef FEAT_BROWSE | |
7415 if (cmdmod.browse) | |
7416 { | |
7417 char_u *browseFile; | |
7418 | |
28 | 7419 browseFile = do_browse(BROWSE_SAVE, |
7420 (char_u *)_("Save Redirection"), | |
13802
378f9f8e6d8f
patch 8.0.1773: dialog messages are not translated
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
7421 fname, NULL, NULL, |
378f9f8e6d8f
patch 8.0.1773: dialog messages are not translated
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
7422 (char_u *)_(BROWSE_FILTER_ALL_FILES), curbuf); |
7 | 7423 if (browseFile == NULL) |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7424 return; // operation cancelled |
7 | 7425 vim_free(fname); |
7426 fname = browseFile; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7427 eap->forceit = TRUE; // since dialog already asked |
7 | 7428 } |
7429 #endif | |
7430 | |
7431 redir_fd = open_exfile(fname, eap->forceit, mode); | |
7432 vim_free(fname); | |
7433 } | |
7434 #ifdef FEAT_EVAL | |
122 | 7435 else if (*arg == '@') |
7 | 7436 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7437 // redirect to a register a-z (resp. A-Z for appending) |
7 | 7438 close_redir(); |
122 | 7439 ++arg; |
7440 if (ASCII_ISALPHA(*arg) | |
7 | 7441 # ifdef FEAT_CLIPBOARD |
122 | 7442 || *arg == '*' |
1038 | 7443 || *arg == '+' |
7 | 7444 # endif |
122 | 7445 || *arg == '"') |
7446 { | |
7447 redir_reg = *arg++; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7448 if (*arg == '>' && arg[1] == '>') // append |
268 | 7449 arg += 2; |
1427 | 7450 else |
7 | 7451 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7452 // Can use both "@a" and "@a>". |
296 | 7453 if (*arg == '>') |
7454 arg++; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7455 // 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
|
7456 // command is valid. |
1427 | 7457 if (*arg == NUL && !isupper(redir_reg)) |
7458 write_reg_contents(redir_reg, (char_u *)"", -1, FALSE); | |
7 | 7459 } |
167 | 7460 } |
7461 if (*arg != NUL) | |
7462 { | |
268 | 7463 redir_reg = 0; |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7464 semsg(_(e_invarg2), eap->arg); |
167 | 7465 } |
7466 } | |
7467 else if (*arg == '=' && arg[1] == '>') | |
7468 { | |
7469 int append; | |
7470 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7471 // redirect to a variable |
167 | 7472 close_redir(); |
7473 arg += 2; | |
7474 | |
7475 if (*arg == '>') | |
7476 { | |
7477 ++arg; | |
7478 append = TRUE; | |
7 | 7479 } |
7480 else | |
167 | 7481 append = FALSE; |
7482 | |
7483 if (var_redir_start(skipwhite(arg), append) == OK) | |
7484 redir_vname = 1; | |
7 | 7485 } |
7486 #endif | |
7487 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7488 // TODO: redirect to a buffer |
7 | 7489 |
7490 else | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7491 semsg(_(e_invarg2), eap->arg); |
7 | 7492 } |
972 | 7493 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7494 // 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
|
7495 // that indirectly invokes a command to catch its output. |
972 | 7496 if (redir_fd != NULL |
7497 #ifdef FEAT_EVAL | |
7498 || redir_reg || redir_vname | |
7499 #endif | |
7500 ) | |
7501 redir_off = FALSE; | |
7 | 7502 } |
7503 | |
7504 /* | |
7505 * ":redraw": force redraw | |
7506 */ | |
7864
6b0891de44a9
commit https://github.com/vim/vim/commit/fb1f62691eae7c79a28b3b17a60e72ce198c71a2
Christian Brabandt <cb@256bit.org>
parents:
7850
diff
changeset
|
7507 void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7508 ex_redraw(exarg_T *eap) |
7 | 7509 { |
7510 int r = RedrawingDisabled; | |
7511 int p = p_lz; | |
7512 | |
7513 RedrawingDisabled = 0; | |
7514 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
|
7515 validate_cursor(); |
7 | 7516 update_topline(); |
5735 | 7517 update_screen(eap->forceit ? CLEAR : VIsual_active ? INVERTED : 0); |
7 | 7518 #ifdef FEAT_TITLE |
7519 if (need_maketitle) | |
7520 maketitle(); | |
7521 #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
|
7522 #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
|
7523 # 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
|
7524 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
|
7525 # 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
|
7526 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
|
7527 #endif |
7 | 7528 RedrawingDisabled = r; |
7529 p_lz = p; | |
7530 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7531 // Reset msg_didout, so that a message that's there is overwritten. |
7 | 7532 msg_didout = FALSE; |
7533 msg_col = 0; | |
7534 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7535 // 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
|
7536 need_wait_return = FALSE; |
1b89e3f916c5
updated for version 7.4a.025
Bram Moolenaar <bram@vim.org>
parents:
4928
diff
changeset
|
7537 |
7 | 7538 out_flush(); |
7539 } | |
7540 | |
7541 /* | |
7542 * ":redrawstatus": force redraw of status line(s) | |
7543 */ | |
7544 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7545 ex_redrawstatus(exarg_T *eap UNUSED) |
7 | 7546 { |
7547 int r = RedrawingDisabled; | |
7548 int p = p_lz; | |
7549 | |
7550 RedrawingDisabled = 0; | |
7551 p_lz = FALSE; | |
7552 if (eap->forceit) | |
7553 status_redraw_all(); | |
7554 else | |
7555 status_redraw_curbuf(); | |
5735 | 7556 update_screen(VIsual_active ? INVERTED : 0); |
7 | 7557 RedrawingDisabled = r; |
7558 p_lz = p; | |
7559 out_flush(); | |
7560 } | |
7561 | |
15396
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7562 /* |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7563 * ":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
|
7564 */ |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7565 static void |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7566 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
|
7567 { |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7568 int r = RedrawingDisabled; |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7569 int p = p_lz; |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7570 |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7571 RedrawingDisabled = 0; |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7572 p_lz = FALSE; |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7573 |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7574 draw_tabline(); |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7575 |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7576 RedrawingDisabled = r; |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7577 p_lz = p; |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7578 out_flush(); |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7579 } |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
7580 |
7 | 7581 static void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7582 close_redir(void) |
7 | 7583 { |
7584 if (redir_fd != NULL) | |
7585 { | |
7586 fclose(redir_fd); | |
7587 redir_fd = NULL; | |
7588 } | |
7589 #ifdef FEAT_EVAL | |
7590 redir_reg = 0; | |
167 | 7591 if (redir_vname) |
7592 { | |
7593 var_redir_stop(); | |
7594 redir_vname = 0; | |
7595 } | |
7 | 7596 #endif |
7597 } | |
7598 | |
17539
554240b9574b
patch 8.1.1767: FEAT_SESSION defined separately
Bram Moolenaar <Bram@vim.org>
parents:
17536
diff
changeset
|
7599 #if (defined(FEAT_SESSION) || defined(FEAT_EVAL)) || defined(PROTO) |
167 | 7600 int |
18139
59bc3cd42cf5
patch 8.1.2064: MS-Windows: compiler warnings for unused arguments
Bram Moolenaar <Bram@vim.org>
parents:
18135
diff
changeset
|
7601 vim_mkdir_emsg(char_u *name, int prot UNUSED) |
167 | 7602 { |
7603 if (vim_mkdir(name, prot) != 0) | |
7604 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7605 semsg(_("E739: Cannot create directory: %s"), name); |
167 | 7606 return FAIL; |
7607 } | |
7608 return OK; | |
7609 } | |
7610 #endif | |
7611 | |
7 | 7612 /* |
7613 * Open a file for writing for an Ex command, with some checks. | |
7614 * Return file descriptor, or NULL on failure. | |
7615 */ | |
7616 FILE * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7617 open_exfile( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7618 char_u *fname, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7619 int forceit, |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7620 char *mode) // "w" for create new file or "a" for append |
7 | 7621 { |
7622 FILE *fd; | |
7623 | |
7624 #ifdef UNIX | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7625 // with Unix it is possible to open a directory |
7 | 7626 if (mch_isdir(fname)) |
7627 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7628 semsg(_(e_isadir2), fname); |
7 | 7629 return NULL; |
7630 } | |
7631 #endif | |
7632 if (!forceit && *mode != 'a' && vim_fexists(fname)) | |
7633 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7634 semsg(_("E189: \"%s\" exists (add ! to override)"), fname); |
7 | 7635 return NULL; |
7636 } | |
7637 | |
7638 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
|
7639 semsg(_("E190: Cannot open \"%s\" for writing"), fname); |
7 | 7640 |
7641 return fd; | |
7642 } | |
7643 | |
7644 /* | |
7645 * ":mark" and ":k". | |
7646 */ | |
7647 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7648 ex_mark(exarg_T *eap) |
7 | 7649 { |
7650 pos_T pos; | |
7651 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7652 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
|
7653 emsg(_(e_argreq)); |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7654 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
|
7655 emsg(_(e_trailing)); |
7 | 7656 else |
7657 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7658 pos = curwin->w_cursor; // save curwin->w_cursor |
7 | 7659 curwin->w_cursor.lnum = eap->line2; |
7660 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
|
7661 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
|
7662 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
|
7663 curwin->w_cursor = pos; // restore curwin->w_cursor |
7 | 7664 } |
7665 } | |
7666 | |
7667 /* | |
7668 * Update w_topline, w_leftcol and the cursor position. | |
7669 */ | |
7670 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7671 update_topline_cursor(void) |
7 | 7672 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7673 check_cursor(); // put cursor on valid line |
7 | 7674 update_topline(); |
7675 if (!curwin->w_p_wrap) | |
7676 validate_cursor(); | |
7677 update_curswant(); | |
7678 } | |
7679 | |
7680 /* | |
12521
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7681 * 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
|
7682 * 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
|
7683 */ |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7684 int |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7685 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
|
7686 { |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7687 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
|
7688 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
|
7689 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
|
7690 sst->save_State = State; |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7691 sst->save_insertmode = p_im; |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7692 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
|
7693 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
|
7694 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
|
7695 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7696 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
|
7697 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
|
7698 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
|
7699 |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7700 /* |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7701 * 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
|
7702 * 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
|
7703 * ends with half a command. |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7704 */ |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7705 save_typeahead(&sst->tabuf); |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7706 return sst->tabuf.typebuf_valid; |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7707 } |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7708 |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7709 void |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7710 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
|
7711 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7712 // Restore the previous typeahead. |
12521
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7713 restore_typeahead(&sst->tabuf); |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7714 |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7715 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
|
7716 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
|
7717 p_im = sst->save_insertmode; |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7718 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
|
7719 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
|
7720 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
|
7721 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
|
7722 |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7723 // 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
|
7724 // '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
|
7725 State = sst->save_State; |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7726 #ifdef CURSOR_SHAPE |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7727 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
|
7728 #endif |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7729 } |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7730 |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7731 /* |
7 | 7732 * ":normal[!] {commands}": Execute normal mode commands. |
7733 */ | |
7840
28f569c7dab9
commit https://github.com/vim/vim/commit/20fb9f346497daca4d19402fdfa5de7958642477
Christian Brabandt <cb@256bit.org>
parents:
7819
diff
changeset
|
7734 void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7735 ex_normal(exarg_T *eap) |
7 | 7736 { |
12521
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7737 save_state_T save_state; |
7 | 7738 char_u *arg = NULL; |
7739 int l; | |
7740 char_u *p; | |
7741 | |
856 | 7742 if (ex_normal_lock > 0) |
7743 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7744 emsg(_(e_secure)); |
856 | 7745 return; |
7746 } | |
7 | 7747 if (ex_normal_busy >= p_mmd) |
7748 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7749 emsg(_("E192: Recursive use of :normal too deep")); |
7 | 7750 return; |
7751 } | |
7752 | |
7753 /* | |
7754 * vgetc() expects a CSI and K_SPECIAL to have been escaped. Don't do | |
7755 * this for the K_SPECIAL leading byte, otherwise special keys will not | |
7756 * work. | |
7757 */ | |
7758 if (has_mbyte) | |
7759 { | |
7760 int len = 0; | |
7761 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7762 // Count the number of characters to be escaped. |
7 | 7763 for (p = eap->arg; *p != NUL; ++p) |
7764 { | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
7765 #ifdef FEAT_GUI |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7766 if (*p == CSI) // leadbyte CSI |
7 | 7767 len += 2; |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
7768 #endif |
474 | 7769 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
|
7770 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
|
7771 #ifdef FEAT_GUI |
7 | 7772 || *p == CSI |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
7773 #endif |
7 | 7774 ) |
7775 len += 2; | |
7776 } | |
7777 if (len > 0) | |
7778 { | |
16764
ef00b6bc186b
patch 8.1.1384: using "int" for alloc() often results in compiler warnings
Bram Moolenaar <Bram@vim.org>
parents:
16738
diff
changeset
|
7779 arg = alloc(STRLEN(eap->arg) + len + 1); |
7 | 7780 if (arg != NULL) |
7781 { | |
7782 len = 0; | |
7783 for (p = eap->arg; *p != NUL; ++p) | |
7784 { | |
7785 arg[len++] = *p; | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
7786 #ifdef FEAT_GUI |
7 | 7787 if (*p == CSI) |
7788 { | |
7789 arg[len++] = KS_EXTRA; | |
7790 arg[len++] = (int)KE_CSI; | |
7791 } | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
7792 #endif |
474 | 7793 for (l = (*mb_ptr2len)(p) - 1; l > 0; --l) |
7 | 7794 { |
7795 arg[len++] = *++p; | |
7796 if (*p == K_SPECIAL) | |
7797 { | |
7798 arg[len++] = KS_SPECIAL; | |
7799 arg[len++] = KE_FILLER; | |
7800 } | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
7801 #ifdef FEAT_GUI |
7 | 7802 else if (*p == CSI) |
7803 { | |
7804 arg[len++] = KS_EXTRA; | |
7805 arg[len++] = (int)KE_CSI; | |
7806 } | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
7807 #endif |
7 | 7808 } |
7809 arg[len] = NUL; | |
7810 } | |
7811 } | |
7812 } | |
7813 } | |
7814 | |
12521
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7815 ++ex_normal_busy; |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7816 if (save_current_state(&save_state)) |
7 | 7817 { |
7818 /* | |
7819 * Repeat the :normal command for each line in the range. When no | |
7820 * range given, execute it just once, without positioning the cursor | |
7821 * first. | |
7822 */ | |
7823 do | |
7824 { | |
7825 if (eap->addr_count != 0) | |
7826 { | |
7827 curwin->w_cursor.lnum = eap->line1++; | |
7828 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
|
7829 check_cursor_moved(curwin); |
7 | 7830 } |
7831 | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
7832 exec_normal_cmd(arg != NULL |
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
7833 ? arg |
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
7834 : eap->arg, eap->forceit ? REMAP_NONE : REMAP_YES, FALSE); |
7 | 7835 } |
7836 while (eap->addr_count > 0 && eap->line1 <= eap->line2 && !got_int); | |
7837 } | |
7838 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7839 // Might not return to the main loop when in an event handler. |
7 | 7840 update_topline_cursor(); |
7841 | |
12521
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
7842 restore_current_state(&save_state); |
7 | 7843 --ex_normal_busy; |
6322 | 7844 setmouse(); |
7845 #ifdef CURSOR_SHAPE | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7846 ui_cursor_shape(); // may show different cursor shape |
6322 | 7847 #endif |
7848 | |
7 | 7849 vim_free(arg); |
7850 } | |
7851 | |
7852 /* | |
598 | 7853 * ":startinsert", ":startreplace" and ":startgreplace" |
7 | 7854 */ |
7855 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7856 ex_startinsert(exarg_T *eap) |
7 | 7857 { |
98 | 7858 if (eap->forceit) |
7859 { | |
17984
2ea47dee7ddd
patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
7860 // 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
|
7861 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
|
7862 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
|
7863 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
|
7864 } |
20097
165ec447ca77
patch 8.2.0604: :startinsert in a terminal window used later
Bram Moolenaar <Bram@vim.org>
parents:
20079
diff
changeset
|
7865 #ifdef FEAT_TERMINAL |
165ec447ca77
patch 8.2.0604: :startinsert in a terminal window used later
Bram Moolenaar <Bram@vim.org>
parents:
20079
diff
changeset
|
7866 // 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
|
7867 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
|
7868 return; |
165ec447ca77
patch 8.2.0604: :startinsert in a terminal window used later
Bram Moolenaar <Bram@vim.org>
parents:
20079
diff
changeset
|
7869 #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
|
7870 |
2ea47dee7ddd
patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents:
17966
diff
changeset
|
7871 // 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
|
7872 // expression register that invokes a function can do this. |
89 | 7873 if (State & INSERT) |
7874 return; | |
7875 | |
598 | 7876 if (eap->cmdidx == CMD_startinsert) |
7877 restart_edit = 'a'; | |
7878 else if (eap->cmdidx == CMD_startreplace) | |
7879 restart_edit = 'R'; | |
7 | 7880 else |
598 | 7881 restart_edit = 'V'; |
7882 | |
7883 if (!eap->forceit) | |
7 | 7884 { |
14 | 7885 if (eap->cmdidx == CMD_startinsert) |
7886 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
|
7887 curwin->w_curswant = 0; // avoid MAXCOL |
7 | 7888 } |
7889 } | |
7890 | |
7891 /* | |
7892 * ":stopinsert" | |
7893 */ | |
7894 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7895 ex_stopinsert(exarg_T *eap UNUSED) |
7 | 7896 { |
7897 restart_edit = 0; | |
7898 stop_insert_mode = TRUE; | |
8817
b7eb7bbd71d0
commit https://github.com/vim/vim/commit/fd773e9e88add7d1ffef890fb9f3a00d613b4326
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
7899 clearmode(); |
7 | 7900 } |
7850
10f17a228661
commit https://github.com/vim/vim/commit/e2c3810c2ae290bbc2cba18eb47cc2d44e4b9797
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
7901 |
36 | 7902 /* |
7903 * Execute normal mode command "cmd". | |
7904 * "remap" can be REMAP_NONE or REMAP_YES. | |
7905 */ | |
7906 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7907 exec_normal_cmd(char_u *cmd, int remap, int silent) |
36 | 7908 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7909 // 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
|
7910 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
|
7911 exec_normal(FALSE, FALSE, FALSE); |
7703
39251e981d1f
commit https://github.com/vim/vim/commit/25281634cda03ce302aaf9f906a9520b5f81f91e
Christian Brabandt <cb@256bit.org>
parents:
7549
diff
changeset
|
7912 } |
7850
10f17a228661
commit https://github.com/vim/vim/commit/e2c3810c2ae290bbc2cba18eb47cc2d44e4b9797
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
7913 |
7703
39251e981d1f
commit https://github.com/vim/vim/commit/25281634cda03ce302aaf9f906a9520b5f81f91e
Christian Brabandt <cb@256bit.org>
parents:
7549
diff
changeset
|
7914 /* |
39251e981d1f
commit https://github.com/vim/vim/commit/25281634cda03ce302aaf9f906a9520b5f81f91e
Christian Brabandt <cb@256bit.org>
parents:
7549
diff
changeset
|
7915 * 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
|
7916 * 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
|
7917 */ |
39251e981d1f
commit https://github.com/vim/vim/commit/25281634cda03ce302aaf9f906a9520b5f81f91e
Christian Brabandt <cb@256bit.org>
parents:
7549
diff
changeset
|
7918 void |
14871
f20df682c8af
patch 8.1.0447: GUI scrollbar test fails with Athena and Motif
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
7919 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
|
7920 { |
36 | 7921 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
|
7922 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
|
7923 |
d3377393e3d9
patch 8.1.1136: decoding of mouse click escape sequence is not tested
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
7924 // 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
|
7925 // is nothing to get, so also check for Ctrl_C. |
36 | 7926 clear_oparg(&oa); |
7927 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
|
7928 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
|
7929 || ((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
|
7930 || (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
|
7931 && !got_int) |
36 | 7932 { |
7933 update_topline_cursor(); | |
13829
044337cbf854
patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents:
13802
diff
changeset
|
7934 #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
|
7935 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
|
7936 && 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
|
7937 && !VIsual_active) |
044337cbf854
patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents:
13802
diff
changeset
|
7938 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7939 // 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
|
7940 // 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
|
7941 // 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
|
7942 if (terminal_loop(TRUE) == OK) |
044337cbf854
patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents:
13802
diff
changeset
|
7943 normal_cmd(&oa, TRUE); |
044337cbf854
patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents:
13802
diff
changeset
|
7944 } |
044337cbf854
patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents:
13802
diff
changeset
|
7945 else |
044337cbf854
patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents:
13802
diff
changeset
|
7946 #endif |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7947 // execute a Normal mode cmd |
13829
044337cbf854
patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents:
13802
diff
changeset
|
7948 normal_cmd(&oa, TRUE); |
36 | 7949 } |
7950 } | |
7951 | |
7 | 7952 #ifdef FEAT_FIND_ID |
7953 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7954 ex_checkpath(exarg_T *eap) |
7 | 7955 { |
7956 find_pattern_in_path(NULL, 0, 0, FALSE, FALSE, CHECK_PATH, 1L, | |
7957 eap->forceit ? ACTION_SHOW_ALL : ACTION_SHOW, | |
7958 (linenr_T)1, (linenr_T)MAXLNUM); | |
7959 } | |
7960 | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
7961 #if defined(FEAT_QUICKFIX) |
7 | 7962 /* |
7963 * ":psearch" | |
7964 */ | |
7965 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7966 ex_psearch(exarg_T *eap) |
7 | 7967 { |
7968 g_do_tagpreview = p_pvh; | |
7969 ex_findpat(eap); | |
7970 g_do_tagpreview = 0; | |
7971 } | |
7972 #endif | |
7973 | |
7974 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7975 ex_findpat(exarg_T *eap) |
7 | 7976 { |
7977 int whole = TRUE; | |
7978 long n; | |
7979 char_u *p; | |
7980 int action; | |
7981 | |
7982 switch (cmdnames[eap->cmdidx].cmd_name[2]) | |
7983 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7984 case 'e': // ":psearch", ":isearch" and ":dsearch" |
7 | 7985 if (cmdnames[eap->cmdidx].cmd_name[0] == 'p') |
7986 action = ACTION_GOTO; | |
7987 else | |
7988 action = ACTION_SHOW; | |
7989 break; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7990 case 'i': // ":ilist" and ":dlist" |
7 | 7991 action = ACTION_SHOW_ALL; |
7992 break; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7993 case 'u': // ":ijump" and ":djump" |
7 | 7994 action = ACTION_GOTO; |
7995 break; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
7996 default: // ":isplit" and ":dsplit" |
7 | 7997 action = ACTION_SPLIT; |
7998 break; | |
7999 } | |
8000 | |
8001 n = 1; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8002 if (vim_isdigit(*eap->arg)) // get count |
7 | 8003 { |
8004 n = getdigits(&eap->arg); | |
8005 eap->arg = skipwhite(eap->arg); | |
8006 } | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8007 if (*eap->arg == '/') // Match regexp, not just whole words |
7 | 8008 { |
8009 whole = FALSE; | |
8010 ++eap->arg; | |
19892
5feb426d2ea1
patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19685
diff
changeset
|
8011 p = skip_regexp(eap->arg, '/', p_magic); |
7 | 8012 if (*p) |
8013 { | |
8014 *p++ = NUL; | |
8015 p = skipwhite(p); | |
8016 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8017 // 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
|
8018 if (!ends_excmd2(eap->arg, p)) |
7 | 8019 eap->errmsg = e_trailing; |
8020 else | |
8021 eap->nextcmd = check_nextcmd(p); | |
8022 } | |
8023 } | |
8024 if (!eap->skip) | |
8025 find_pattern_in_path(eap->arg, 0, (int)STRLEN(eap->arg), | |
8026 whole, !eap->forceit, | |
8027 *eap->cmd == 'd' ? FIND_DEFINE : FIND_ANY, | |
8028 n, action, eap->line1, eap->line2); | |
8029 } | |
8030 #endif | |
8031 | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
8032 |
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
8033 #ifdef FEAT_QUICKFIX |
7 | 8034 /* |
8035 * ":ptag", ":ptselect", ":ptjump", ":ptnext", etc. | |
8036 */ | |
8037 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8038 ex_ptag(exarg_T *eap) |
7 | 8039 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8040 g_do_tagpreview = p_pvh; // will be reset to 0 in ex_tag_cmd() |
7 | 8041 ex_tag_cmd(eap, cmdnames[eap->cmdidx].cmd_name + 1); |
8042 } | |
8043 | |
8044 /* | |
8045 * ":pedit" | |
8046 */ | |
8047 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8048 ex_pedit(exarg_T *eap) |
7 | 8049 { |
8050 win_T *curwin_save = curwin; | |
8051 | |
19621
0d677257e35d
patch 8.2.0367: can use :pedit in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19575
diff
changeset
|
8052 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
|
8053 return; |
0d677257e35d
patch 8.2.0367: can use :pedit in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
19575
diff
changeset
|
8054 |
17746
a4e488a6655c
patch 8.1.1870: using :pedit from a help file sets help filetype
Bram Moolenaar <Bram@vim.org>
parents:
17744
diff
changeset
|
8055 // Open the preview window or popup and make it the current window. |
7 | 8056 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
|
8057 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
|
8058 |
17746
a4e488a6655c
patch 8.1.1870: using :pedit from a help file sets help filetype
Bram Moolenaar <Bram@vim.org>
parents:
17744
diff
changeset
|
8059 // Edit the file. |
7 | 8060 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
|
8061 |
7 | 8062 if (curwin != curwin_save && win_valid(curwin_save)) |
8063 { | |
17746
a4e488a6655c
patch 8.1.1870: using :pedit from a help file sets help filetype
Bram Moolenaar <Bram@vim.org>
parents:
17744
diff
changeset
|
8064 // Return cursor to where we were |
7 | 8065 validate_cursor(); |
8066 redraw_later(VALID); | |
8067 win_enter(curwin_save, TRUE); | |
8068 } | |
18763
49b78d6465e5
patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents:
18715
diff
changeset
|
8069 # 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
|
8070 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
|
8071 { |
daa1dea1c1b3
patch 8.1.1819: :pedit does not work with a popup preview window
Bram Moolenaar <Bram@vim.org>
parents:
17622
diff
changeset
|
8072 // 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
|
8073 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
|
8074 } |
daa1dea1c1b3
patch 8.1.1819: :pedit does not work with a popup preview window
Bram Moolenaar <Bram@vim.org>
parents:
17622
diff
changeset
|
8075 # endif |
7 | 8076 g_do_tagpreview = 0; |
8077 } | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
8078 #endif |
7 | 8079 |
8080 /* | |
8081 * ":stag", ":stselect" and ":stjump". | |
8082 */ | |
8083 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8084 ex_stag(exarg_T *eap) |
7 | 8085 { |
8086 postponed_split = -1; | |
8087 postponed_split_flags = cmdmod.split; | |
1090 | 8088 postponed_split_tab = cmdmod.tab; |
7 | 8089 ex_tag_cmd(eap, cmdnames[eap->cmdidx].cmd_name + 1); |
8090 postponed_split_flags = 0; | |
1090 | 8091 postponed_split_tab = 0; |
7 | 8092 } |
8093 | |
8094 /* | |
8095 * ":tag", ":tselect", ":tjump", ":tnext", etc. | |
8096 */ | |
8097 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8098 ex_tag(exarg_T *eap) |
7 | 8099 { |
8100 ex_tag_cmd(eap, cmdnames[eap->cmdidx].cmd_name); | |
8101 } | |
8102 | |
8103 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8104 ex_tag_cmd(exarg_T *eap, char_u *name) |
7 | 8105 { |
8106 int cmd; | |
8107 | |
8108 switch (name[1]) | |
8109 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8110 case 'j': cmd = DT_JUMP; // ":tjump" |
7 | 8111 break; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8112 case 's': cmd = DT_SELECT; // ":tselect" |
7 | 8113 break; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8114 case 'p': cmd = DT_PREV; // ":tprevious" |
7 | 8115 break; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8116 case 'N': cmd = DT_PREV; // ":tNext" |
7 | 8117 break; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8118 case 'n': cmd = DT_NEXT; // ":tnext" |
7 | 8119 break; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8120 case 'o': cmd = DT_POP; // ":pop" |
7 | 8121 break; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8122 case 'f': // ":tfirst" |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8123 case 'r': cmd = DT_FIRST; // ":trewind" |
7 | 8124 break; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8125 case 'l': cmd = DT_LAST; // ":tlast" |
7 | 8126 break; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8127 default: // ":tag" |
7 | 8128 #ifdef FEAT_CSCOPE |
1603 | 8129 if (p_cst && *eap->arg != NUL) |
7 | 8130 { |
10373
bd674706408a
commit https://github.com/vim/vim/commit/d4db7719bdfbc54df396eac08d8cbb2389feacf4
Christian Brabandt <cb@256bit.org>
parents:
10361
diff
changeset
|
8131 ex_cstag(eap); |
7 | 8132 return; |
8133 } | |
8134 #endif | |
8135 cmd = DT_TAG; | |
8136 break; | |
8137 } | |
8138 | |
649 | 8139 if (name[0] == 'l') |
8140 { | |
8141 #ifndef FEAT_QUICKFIX | |
8142 ex_ni(eap); | |
8143 return; | |
8144 #else | |
8145 cmd = DT_LTAG; | |
8146 #endif | |
8147 } | |
8148 | |
7 | 8149 do_tag(eap->arg, cmd, eap->addr_count > 0 ? (int)eap->line2 : 1, |
8150 eap->forceit, TRUE); | |
8151 } | |
8152 | |
8153 /* | |
1661 | 8154 * Check "str" for starting with a special cmdline variable. |
8155 * If found return one of the SPEC_ values and set "*usedlen" to the length of | |
8156 * the variable. Otherwise return -1 and "*usedlen" is unchanged. | |
8157 */ | |
8158 int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8159 find_cmdline_var(char_u *src, int *usedlen) |
1661 | 8160 { |
8161 int len; | |
8162 int i; | |
1879 | 8163 static char *(spec_str[]) = { |
1661 | 8164 "%", |
8165 #define SPEC_PERC 0 | |
8166 "#", | |
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
|
8167 #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
|
8168 "<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
|
8169 #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
|
8170 "<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
|
8171 #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
|
8172 "<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
|
8173 #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
|
8174 "<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
|
8175 #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
|
8176 "<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
|
8177 #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
|
8178 "<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
|
8179 #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
|
8180 "<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
|
8181 #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
|
8182 "<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
|
8183 #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
|
8184 "<amatch>", // autocommand match name |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
8185 #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
|
8186 "<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
|
8187 #define SPEC_SFLNUM (SPEC_AMATCH + 1) |
1661 | 8188 #ifdef FEAT_CLIENTSERVER |
8189 "<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
|
8190 # define SPEC_CLIENT (SPEC_SFLNUM + 1) |
1661 | 8191 #endif |
8192 }; | |
1872 | 8193 |
8194 for (i = 0; i < (int)(sizeof(spec_str) / sizeof(char *)); ++i) | |
1661 | 8195 { |
8196 len = (int)STRLEN(spec_str[i]); | |
8197 if (STRNCMP(src, spec_str[i], len) == 0) | |
8198 { | |
8199 *usedlen = len; | |
8200 return i; | |
8201 } | |
8202 } | |
8203 return -1; | |
8204 } | |
8205 | |
8206 /* | |
7 | 8207 * Evaluate cmdline variables. |
8208 * | |
8209 * change '%' to curbuf->b_ffname | |
8210 * '#' to curwin->w_altfile | |
8211 * '<cword>' to word under the cursor | |
8212 * '<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
|
8213 * '<cexpr>' to C-expression under the cursor |
7 | 8214 * '<cfile>' to path name under the cursor |
8215 * '<sfile>' to sourced file name | |
2645 | 8216 * '<slnum>' to sourced file line number |
7 | 8217 * '<afile>' to file name for autocommand |
8218 * '<abuf>' to buffer number for autocommand | |
8219 * '<amatch>' to matching name for autocommand | |
8220 * | |
8221 * When an error is detected, "errormsg" is set to a non-NULL pointer (may be | |
8222 * "" for error without a message) and NULL is returned. | |
8223 * Returns an allocated string if a valid match was found. | |
8224 * Returns NULL if no match was found. "usedlen" then still contains the | |
8225 * number of characters to skip. | |
8226 */ | |
8227 char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8228 eval_vars( |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8229 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
|
8230 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
|
8231 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
|
8232 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
|
8233 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
|
8234 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
|
8235 // be NULL) |
7 | 8236 { |
8237 int i; | |
8238 char_u *s; | |
8239 char_u *result; | |
8240 char_u *resultbuf = NULL; | |
8241 int resultlen; | |
8242 buf_T *buf; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8243 int valid = VALID_HEAD + VALID_PATH; // assume valid result |
7 | 8244 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
|
8245 int tilde_file = FALSE; |
7 | 8246 int skip_mod = FALSE; |
8247 char_u strbuf[30]; | |
8248 | |
8249 *errormsg = NULL; | |
1098 | 8250 if (escaped != NULL) |
8251 *escaped = FALSE; | |
7 | 8252 |
8253 /* | |
8254 * Check if there is something to do. | |
8255 */ | |
1661 | 8256 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
|
8257 if (spec_idx < 0) // no match |
7 | 8258 { |
8259 *usedlen = 1; | |
8260 return NULL; | |
8261 } | |
8262 | |
8263 /* | |
8264 * Skip when preceded with a backslash "\%" and "\#". | |
8265 * Note: In "\\%" the % is also not recognized! | |
8266 */ | |
8267 if (src > srcstart && src[-1] == '\\') | |
8268 { | |
8269 *usedlen = 0; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8270 STRMOVE(src - 1, src); // remove backslash |
7 | 8271 return NULL; |
8272 } | |
8273 | |
8274 /* | |
8275 * word or WORD under cursor | |
8276 */ | |
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
|
8277 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
|
8278 || 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
|
8279 { |
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
|
8280 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
|
8281 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
|
8282 : 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
|
8283 : FIND_STRING); |
7 | 8284 if (resultlen == 0) |
8285 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8286 *errormsg = ""; |
7 | 8287 return NULL; |
8288 } | |
8289 } | |
8290 | |
8291 /* | |
8292 * '#': Alternate file name | |
8293 * '%': Current file name | |
8294 * File name under the cursor | |
8295 * File name for autocommand | |
8296 * and following modifiers | |
8297 */ | |
8298 else | |
8299 { | |
8300 switch (spec_idx) | |
8301 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8302 case SPEC_PERC: // '%': current file |
7 | 8303 if (curbuf->b_fname == NULL) |
8304 { | |
8305 result = (char_u *)""; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8306 valid = 0; // Must have ":p:h" to be valid |
7 | 8307 } |
8308 else | |
14393
c62601adad69
patch 8.1.0211: expanding a file name "~" results in $HOME
Christian Brabandt <cb@256bit.org>
parents:
14286
diff
changeset
|
8309 { |
7 | 8310 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
|
8311 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
|
8312 } |
7 | 8313 break; |
8314 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8315 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
|
8316 if (src[1] == '#') // "##": the argument list |
7 | 8317 { |
8318 result = arg_all(); | |
8319 resultbuf = result; | |
8320 *usedlen = 2; | |
1098 | 8321 if (escaped != NULL) |
8322 *escaped = TRUE; | |
7 | 8323 skip_mod = TRUE; |
8324 break; | |
8325 } | |
8326 s = src + 1; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8327 if (*s == '<') // "#<99" uses v:oldfiles |
1733 | 8328 ++s; |
7 | 8329 i = (int)getdigits(&s); |
12706
9b882316aa63
patch 8.0.1231: expanding file name drops dash
Christian Brabandt <cb@256bit.org>
parents:
12674
diff
changeset
|
8330 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
|
8331 // 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
|
8332 s--; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8333 *usedlen = (int)(s - src); // length of what we expand |
7 | 8334 |
12706
9b882316aa63
patch 8.0.1231: expanding file name drops dash
Christian Brabandt <cb@256bit.org>
parents:
12674
diff
changeset
|
8335 if (src[1] == '<' && i != 0) |
7 | 8336 { |
1733 | 8337 if (*usedlen < 2) |
8338 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8339 // Should we give an error message for #<text? |
1733 | 8340 *usedlen = 1; |
8341 return NULL; | |
8342 } | |
8343 #ifdef FEAT_EVAL | |
8344 result = list_find_str(get_vim_var_list(VV_OLDFILES), | |
8345 (long)i); | |
8346 if (result == NULL) | |
8347 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8348 *errormsg = ""; |
1733 | 8349 return NULL; |
8350 } | |
8351 #else | |
15488
da8b98c008bf
patch 8.1.0752: one more compiler warning for signed/unsigned string
Bram Moolenaar <Bram@vim.org>
parents:
15474
diff
changeset
|
8352 *errormsg = _("E809: #< is not available without the +eval feature"); |
7 | 8353 return NULL; |
1733 | 8354 #endif |
7 | 8355 } |
8356 else | |
1733 | 8357 { |
12706
9b882316aa63
patch 8.0.1231: expanding file name drops dash
Christian Brabandt <cb@256bit.org>
parents:
12674
diff
changeset
|
8358 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
|
8359 *usedlen = 1; |
1733 | 8360 buf = buflist_findnr(i); |
8361 if (buf == NULL) | |
8362 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8363 *errormsg = _("E194: No alternate file name to substitute for '#'"); |
1733 | 8364 return NULL; |
8365 } | |
8366 if (lnump != NULL) | |
8367 *lnump = ECMD_LAST; | |
8368 if (buf->b_fname == NULL) | |
8369 { | |
8370 result = (char_u *)""; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8371 valid = 0; // Must have ":p:h" to be valid |
1733 | 8372 } |
8373 else | |
14393
c62601adad69
patch 8.1.0211: expanding a file name "~" results in $HOME
Christian Brabandt <cb@256bit.org>
parents:
14286
diff
changeset
|
8374 { |
1733 | 8375 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
|
8376 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
|
8377 } |
1733 | 8378 } |
7 | 8379 break; |
8380 | |
8381 #ifdef FEAT_SEARCHPATH | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8382 case SPEC_CFILE: // file name under cursor |
681 | 8383 result = file_name_at_cursor(FNAME_MESS|FNAME_HYP, 1L, NULL); |
7 | 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 } | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8389 resultbuf = result; // remember allocated string |
7 | 8390 break; |
8391 #endif | |
8392 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8393 case SPEC_AFILE: // file name for autocommand |
7 | 8394 result = autocmd_fname; |
1723 | 8395 if (result != NULL && !autocmd_fname_full) |
8396 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8397 // 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
|
8398 // postponed to avoid a delay when <afile> is not used. |
1723 | 8399 autocmd_fname_full = TRUE; |
8400 result = FullName_save(autocmd_fname, FALSE); | |
8401 vim_free(autocmd_fname); | |
8402 autocmd_fname = result; | |
8403 } | |
7 | 8404 if (result == NULL) |
8405 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8406 *errormsg = _("E495: no autocommand file name to substitute for \"<afile>\""); |
7 | 8407 return NULL; |
8408 } | |
1471 | 8409 result = shorten_fname1(result); |
7 | 8410 break; |
8411 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8412 case SPEC_ABUF: // buffer number for autocommand |
7 | 8413 if (autocmd_bufnr <= 0) |
8414 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8415 *errormsg = _("E496: no autocommand buffer number to substitute for \"<abuf>\""); |
7 | 8416 return NULL; |
8417 } | |
8418 sprintf((char *)strbuf, "%d", autocmd_bufnr); | |
8419 result = strbuf; | |
8420 break; | |
8421 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8422 case SPEC_AMATCH: // match name for autocommand |
7 | 8423 result = autocmd_match; |
8424 if (result == NULL) | |
8425 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8426 *errormsg = _("E497: no autocommand match name to substitute for \"<amatch>\""); |
7 | 8427 return NULL; |
8428 } | |
8429 break; | |
8430 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8431 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
|
8432 result = estack_sfile(); |
7 | 8433 if (result == NULL) |
8434 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8435 *errormsg = _("E498: no :source file name to substitute for \"<sfile>\""); |
7 | 8436 return NULL; |
8437 } | |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18904
diff
changeset
|
8438 resultbuf = result; // remember allocated string |
7 | 8439 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
|
8440 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8441 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
|
8442 if (SOURCING_NAME == NULL || SOURCING_LNUM == 0) |
2645 | 8443 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8444 *errormsg = _("E842: no line number to use for \"<slnum>\""); |
2645 | 8445 return NULL; |
8446 } | |
18991
847cc7932c42
patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents:
18904
diff
changeset
|
8447 sprintf((char *)strbuf, "%ld", SOURCING_LNUM); |
2645 | 8448 result = strbuf; |
8449 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
|
8450 |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14677
diff
changeset
|
8451 #ifdef FEAT_EVAL |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8452 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
|
8453 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
|
8454 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8455 *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
|
8456 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
|
8457 } |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14677
diff
changeset
|
8458 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
|
8459 (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
|
8460 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
|
8461 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
|
8462 #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
|
8463 |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14677
diff
changeset
|
8464 #ifdef FEAT_CLIENTSERVER |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8465 case SPEC_CLIENT: // Source of last submitted input |
840 | 8466 sprintf((char *)strbuf, PRINTF_HEX_LONG_U, |
8467 (long_u)clientWindow); | |
7 | 8468 result = strbuf; |
8469 break; | |
8470 #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
|
8471 |
11428
346168f2a6cb
patch 8.0.0598: building with gcc 7.1 yields new warnings
Christian Brabandt <cb@256bit.org>
parents:
11374
diff
changeset
|
8472 default: |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8473 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
|
8474 break; |
7 | 8475 } |
8476 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8477 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
|
8478 if (src[*usedlen] == '<') // remove the file name extension |
7 | 8479 { |
8480 ++*usedlen; | |
8481 if ((s = vim_strrchr(result, '.')) != NULL && s >= gettail(result)) | |
8482 resultlen = (int)(s - result); | |
8483 } | |
8484 else if (!skip_mod) | |
8485 { | |
14393
c62601adad69
patch 8.1.0211: expanding a file name "~" results in $HOME
Christian Brabandt <cb@256bit.org>
parents:
14286
diff
changeset
|
8486 valid |= modify_fname(src, tilde_file, usedlen, &result, &resultbuf, |
7 | 8487 &resultlen); |
8488 if (result == NULL) | |
8489 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8490 *errormsg = ""; |
7 | 8491 return NULL; |
8492 } | |
8493 } | |
8494 } | |
8495 | |
8496 if (resultlen == 0 || valid != VALID_HEAD + VALID_PATH) | |
8497 { | |
8498 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
|
8499 // 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
|
8500 *errormsg = _("E499: Empty file name for '%' or '#', only works with \":p:h\""); |
7 | 8501 else |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8502 *errormsg = _("E500: Evaluates to an empty string"); |
7 | 8503 result = NULL; |
8504 } | |
8505 else | |
8506 result = vim_strnsave(result, resultlen); | |
8507 vim_free(resultbuf); | |
8508 return result; | |
8509 } | |
8510 | |
8511 /* | |
8512 * Expand the <sfile> string in "arg". | |
8513 * | |
8514 * Returns an allocated string, or NULL for any error. | |
8515 */ | |
8516 char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8517 expand_sfile(char_u *arg) |
7 | 8518 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8519 char *errormsg; |
7 | 8520 int len; |
8521 char_u *result; | |
8522 char_u *newres; | |
8523 char_u *repl; | |
8524 int srclen; | |
8525 char_u *p; | |
8526 | |
8527 result = vim_strsave(arg); | |
8528 if (result == NULL) | |
8529 return NULL; | |
8530 | |
8531 for (p = result; *p; ) | |
8532 { | |
8533 if (STRNCMP(p, "<sfile>", 7) != 0) | |
8534 ++p; | |
8535 else | |
8536 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8537 // replace "<sfile>" with the sourced file name, and do ":" stuff |
1098 | 8538 repl = eval_vars(p, result, &srclen, NULL, &errormsg, NULL); |
7 | 8539 if (errormsg != NULL) |
8540 { | |
8541 if (*errormsg) | |
8542 emsg(errormsg); | |
8543 vim_free(result); | |
8544 return NULL; | |
8545 } | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8546 if (repl == NULL) // no match (cannot happen) |
7 | 8547 { |
8548 p += srclen; | |
8549 continue; | |
8550 } | |
8551 len = (int)STRLEN(result) - srclen + (int)STRLEN(repl) + 1; | |
8552 newres = alloc(len); | |
8553 if (newres == NULL) | |
8554 { | |
8555 vim_free(repl); | |
8556 vim_free(result); | |
8557 return NULL; | |
8558 } | |
8559 mch_memmove(newres, result, (size_t)(p - result)); | |
8560 STRCPY(newres + (p - result), repl); | |
8561 len = (int)STRLEN(newres); | |
8562 STRCAT(newres, p + srclen); | |
8563 vim_free(repl); | |
8564 vim_free(result); | |
8565 result = newres; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8566 p = newres + len; // continue after the match |
7 | 8567 } |
8568 } | |
8569 | |
8570 return result; | |
8571 } | |
8572 | |
8573 #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) || defined(PROTO) | |
272 | 8574 /* |
2770 | 8575 * Make a dialog message in "buff[DIALOG_MSG_SIZE]". |
310 | 8576 * "format" must contain "%s". |
272 | 8577 */ |
7 | 8578 void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8579 dialog_msg(char_u *buff, char *format, char_u *fname) |
7 | 8580 { |
8581 if (fname == NULL) | |
8582 fname = (char_u *)_("Untitled"); | |
2770 | 8583 vim_snprintf((char *)buff, DIALOG_MSG_SIZE, format, fname); |
7 | 8584 } |
8585 #endif | |
8586 | |
8587 /* | |
8588 * ":behave {mswin,xterm}" | |
8589 */ | |
8590 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8591 ex_behave(exarg_T *eap) |
7 | 8592 { |
8593 if (STRCMP(eap->arg, "mswin") == 0) | |
8594 { | |
8595 set_option_value((char_u *)"selection", 0L, (char_u *)"exclusive", 0); | |
8596 set_option_value((char_u *)"selectmode", 0L, (char_u *)"mouse,key", 0); | |
8597 set_option_value((char_u *)"mousemodel", 0L, (char_u *)"popup", 0); | |
8598 set_option_value((char_u *)"keymodel", 0L, | |
8599 (char_u *)"startsel,stopsel", 0); | |
8600 } | |
8601 else if (STRCMP(eap->arg, "xterm") == 0) | |
8602 { | |
8603 set_option_value((char_u *)"selection", 0L, (char_u *)"inclusive", 0); | |
8604 set_option_value((char_u *)"selectmode", 0L, (char_u *)"", 0); | |
8605 set_option_value((char_u *)"mousemodel", 0L, (char_u *)"extend", 0); | |
8606 set_option_value((char_u *)"keymodel", 0L, (char_u *)"", 0); | |
8607 } | |
8608 else | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8609 semsg(_(e_invarg2), eap->arg); |
7 | 8610 } |
8611 | |
8612 static int filetype_detect = FALSE; | |
8613 static int filetype_plugin = FALSE; | |
8614 static int filetype_indent = FALSE; | |
8615 | |
8616 /* | |
8617 * ":filetype [plugin] [indent] {on,off,detect}" | |
8618 * on: Load the filetype.vim file to install autocommands for file types. | |
8619 * off: Load the ftoff.vim file to remove all autocommands for file types. | |
8620 * plugin on: load filetype.vim and ftplugin.vim | |
8621 * plugin off: load ftplugof.vim | |
8622 * indent on: load filetype.vim and indent.vim | |
8623 * indent off: load indoff.vim | |
8624 */ | |
8625 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8626 ex_filetype(exarg_T *eap) |
7 | 8627 { |
8628 char_u *arg = eap->arg; | |
8629 int plugin = FALSE; | |
8630 int indent = FALSE; | |
8631 | |
8632 if (*eap->arg == NUL) | |
8633 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8634 // Print current status. |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8635 smsg("filetype detection:%s plugin:%s indent:%s", |
7 | 8636 filetype_detect ? "ON" : "OFF", |
8637 filetype_plugin ? (filetype_detect ? "ON" : "(on)") : "OFF", | |
8638 filetype_indent ? (filetype_detect ? "ON" : "(on)") : "OFF"); | |
8639 return; | |
8640 } | |
8641 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8642 // Accept "plugin" and "indent" in any order. |
7 | 8643 for (;;) |
8644 { | |
8645 if (STRNCMP(arg, "plugin", 6) == 0) | |
8646 { | |
8647 plugin = TRUE; | |
8648 arg = skipwhite(arg + 6); | |
8649 continue; | |
8650 } | |
8651 if (STRNCMP(arg, "indent", 6) == 0) | |
8652 { | |
8653 indent = TRUE; | |
8654 arg = skipwhite(arg + 6); | |
8655 continue; | |
8656 } | |
8657 break; | |
8658 } | |
8659 if (STRCMP(arg, "on") == 0 || STRCMP(arg, "detect") == 0) | |
8660 { | |
8661 if (*arg == 'o' || !filetype_detect) | |
8662 { | |
8524
2f57bbe870ea
commit https://github.com/vim/vim/commit/7f8989dd8a627af2185df381195351a913f3777f
Christian Brabandt <cb@256bit.org>
parents:
8402
diff
changeset
|
8663 source_runtime((char_u *)FILETYPE_FILE, DIP_ALL); |
7 | 8664 filetype_detect = TRUE; |
8665 if (plugin) | |
8666 { | |
8524
2f57bbe870ea
commit https://github.com/vim/vim/commit/7f8989dd8a627af2185df381195351a913f3777f
Christian Brabandt <cb@256bit.org>
parents:
8402
diff
changeset
|
8667 source_runtime((char_u *)FTPLUGIN_FILE, DIP_ALL); |
7 | 8668 filetype_plugin = TRUE; |
8669 } | |
8670 if (indent) | |
8671 { | |
8524
2f57bbe870ea
commit https://github.com/vim/vim/commit/7f8989dd8a627af2185df381195351a913f3777f
Christian Brabandt <cb@256bit.org>
parents:
8402
diff
changeset
|
8672 source_runtime((char_u *)INDENT_FILE, DIP_ALL); |
7 | 8673 filetype_indent = TRUE; |
8674 } | |
8675 } | |
8676 if (*arg == 'd') | |
8677 { | |
9260
ac8180818504
commit https://github.com/vim/vim/commit/1610d052413e0ed664498853a47acc2d677a22d1
Christian Brabandt <cb@256bit.org>
parents:
9230
diff
changeset
|
8678 (void)do_doautocmd((char_u *)"filetypedetect BufRead", TRUE, NULL); |
717 | 8679 do_modelines(0); |
7 | 8680 } |
8681 } | |
8682 else if (STRCMP(arg, "off") == 0) | |
8683 { | |
8684 if (plugin || indent) | |
8685 { | |
8686 if (plugin) | |
8687 { | |
8524
2f57bbe870ea
commit https://github.com/vim/vim/commit/7f8989dd8a627af2185df381195351a913f3777f
Christian Brabandt <cb@256bit.org>
parents:
8402
diff
changeset
|
8688 source_runtime((char_u *)FTPLUGOF_FILE, DIP_ALL); |
7 | 8689 filetype_plugin = FALSE; |
8690 } | |
8691 if (indent) | |
8692 { | |
8524
2f57bbe870ea
commit https://github.com/vim/vim/commit/7f8989dd8a627af2185df381195351a913f3777f
Christian Brabandt <cb@256bit.org>
parents:
8402
diff
changeset
|
8693 source_runtime((char_u *)INDOFF_FILE, DIP_ALL); |
7 | 8694 filetype_indent = FALSE; |
8695 } | |
8696 } | |
8697 else | |
8698 { | |
8524
2f57bbe870ea
commit https://github.com/vim/vim/commit/7f8989dd8a627af2185df381195351a913f3777f
Christian Brabandt <cb@256bit.org>
parents:
8402
diff
changeset
|
8699 source_runtime((char_u *)FTOFF_FILE, DIP_ALL); |
7 | 8700 filetype_detect = FALSE; |
8701 } | |
8702 } | |
8703 else | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8704 semsg(_(e_invarg2), arg); |
7 | 8705 } |
8706 | |
8707 /* | |
11459
561b76ed9d12
patch 8.0.0613: the conf filetype is used before ftdetect from packages
Christian Brabandt <cb@256bit.org>
parents:
11428
diff
changeset
|
8708 * ":setfiletype [FALLBACK] {name}" |
7 | 8709 */ |
8710 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8711 ex_setfiletype(exarg_T *eap) |
7 | 8712 { |
8713 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
|
8714 { |
561b76ed9d12
patch 8.0.0613: the conf filetype is used before ftdetect from packages
Christian Brabandt <cb@256bit.org>
parents:
11428
diff
changeset
|
8715 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
|
8716 |
561b76ed9d12
patch 8.0.0613: the conf filetype is used before ftdetect from packages
Christian Brabandt <cb@256bit.org>
parents:
11428
diff
changeset
|
8717 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
|
8718 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
|
8719 |
561b76ed9d12
patch 8.0.0613: the conf filetype is used before ftdetect from packages
Christian Brabandt <cb@256bit.org>
parents:
11428
diff
changeset
|
8720 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
|
8721 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
|
8722 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
|
8723 } |
7 | 8724 } |
8725 | |
8726 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8727 ex_digraphs(exarg_T *eap UNUSED) |
7 | 8728 { |
8729 #ifdef FEAT_DIGRAPHS | |
8730 if (*eap->arg != NUL) | |
8731 putdigraph(eap->arg); | |
8732 else | |
15152
1ef429366fd4
patch 8.1.0586: :digraph output is not easy to read
Bram Moolenaar <Bram@vim.org>
parents:
15125
diff
changeset
|
8733 listdigraphs(eap->forceit); |
7 | 8734 #else |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8735 emsg(_("E196: No digraphs in this version")); |
7 | 8736 #endif |
8737 } | |
8738 | |
13792
0e9b2971d7c3
patch 8.0.1768: SET_NO_HLSEARCH() used in a wrong way
Christian Brabandt <cb@256bit.org>
parents:
13581
diff
changeset
|
8739 #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
|
8740 void |
0e9b2971d7c3
patch 8.0.1768: SET_NO_HLSEARCH() used in a wrong way
Christian Brabandt <cb@256bit.org>
parents:
13581
diff
changeset
|
8741 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
|
8742 { |
0e9b2971d7c3
patch 8.0.1768: SET_NO_HLSEARCH() used in a wrong way
Christian Brabandt <cb@256bit.org>
parents:
13581
diff
changeset
|
8743 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
|
8744 # 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
|
8745 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
|
8746 # endif |
0e9b2971d7c3
patch 8.0.1768: SET_NO_HLSEARCH() used in a wrong way
Christian Brabandt <cb@256bit.org>
parents:
13581
diff
changeset
|
8747 } |
0e9b2971d7c3
patch 8.0.1768: SET_NO_HLSEARCH() used in a wrong way
Christian Brabandt <cb@256bit.org>
parents:
13581
diff
changeset
|
8748 |
7 | 8749 /* |
8750 * ":nohlsearch" | |
8751 */ | |
8752 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8753 ex_nohlsearch(exarg_T *eap UNUSED) |
7 | 8754 { |
13792
0e9b2971d7c3
patch 8.0.1768: SET_NO_HLSEARCH() used in a wrong way
Christian Brabandt <cb@256bit.org>
parents:
13581
diff
changeset
|
8755 set_no_hlsearch(TRUE); |
737 | 8756 redraw_all_later(SOME_VALID); |
7 | 8757 } |
8758 #endif | |
8759 | |
8760 #ifdef FEAT_CRYPT | |
8761 /* | |
8762 * ":X": Get crypt key | |
8763 */ | |
8764 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8765 ex_X(exarg_T *eap UNUSED) |
7 | 8766 { |
6353 | 8767 crypt_check_current_method(); |
6122 | 8768 (void)crypt_get_key(TRUE, TRUE); |
7 | 8769 } |
8770 #endif | |
8771 | |
8772 #ifdef FEAT_FOLDING | |
8773 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8774 ex_fold(exarg_T *eap) |
7 | 8775 { |
8776 if (foldManualAllowed(TRUE)) | |
8777 foldCreate(eap->line1, eap->line2); | |
8778 } | |
8779 | |
8780 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8781 ex_foldopen(exarg_T *eap) |
7 | 8782 { |
8783 opFoldRange(eap->line1, eap->line2, eap->cmdidx == CMD_foldopen, | |
8784 eap->forceit, FALSE); | |
8785 } | |
8786 | |
8787 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8788 ex_folddo(exarg_T *eap) |
7 | 8789 { |
8790 linenr_T lnum; | |
8791 | |
18297
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
8792 # ifdef FEAT_CLIPBOARD |
6116 | 8793 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
|
8794 # endif |
6116 | 8795 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8796 // First set the marks for all lines closed/open. |
7 | 8797 for (lnum = eap->line1; lnum <= eap->line2; ++lnum) |
8798 if (hasFolding(lnum, NULL, NULL) == (eap->cmdidx == CMD_folddoclosed)) | |
8799 ml_setmarked(lnum); | |
8800 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8801 // Execute the command on the marked lines. |
7 | 8802 global_exe(eap->arg); |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
8803 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
|
8804 # ifdef FEAT_CLIPBOARD |
6116 | 8805 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
|
8806 # endif |
6116 | 8807 } |
8808 #endif | |
12459
937356f8f8d6
patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents:
12457
diff
changeset
|
8809 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
19137
diff
changeset
|
8810 #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
|
8811 /* |
60b9b6196644
patch 8.1.0288: quickfix code uses cmdidx too often
Christian Brabandt <cb@256bit.org>
parents:
14538
diff
changeset
|
8812 * 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
|
8813 * 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
|
8814 */ |
60b9b6196644
patch 8.1.0288: quickfix code uses cmdidx too often
Christian Brabandt <cb@256bit.org>
parents:
14538
diff
changeset
|
8815 int |
60b9b6196644
patch 8.1.0288: quickfix code uses cmdidx too often
Christian Brabandt <cb@256bit.org>
parents:
14538
diff
changeset
|
8816 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
|
8817 { |
14621
89cc3e7ecb68
patch 8.1.0324: off-by-one error in cmdidx check
Christian Brabandt <cb@256bit.org>
parents:
14591
diff
changeset
|
8818 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
|
8819 return FALSE; |
60b9b6196644
patch 8.1.0288: quickfix code uses cmdidx too often
Christian Brabandt <cb@256bit.org>
parents:
14538
diff
changeset
|
8820 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
|
8821 } |
60b9b6196644
patch 8.1.0288: quickfix code uses cmdidx too often
Christian Brabandt <cb@256bit.org>
parents:
14538
diff
changeset
|
8822 #endif |
60b9b6196644
patch 8.1.0288: quickfix code uses cmdidx too often
Christian Brabandt <cb@256bit.org>
parents:
14538
diff
changeset
|
8823 |
18297
b0b37bd807ba
patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents:
18139
diff
changeset
|
8824 #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
|
8825 int |
937356f8f8d6
patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents:
12457
diff
changeset
|
8826 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
|
8827 { |
937356f8f8d6
patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents:
12457
diff
changeset
|
8828 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
|
8829 } |
937356f8f8d6
patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents:
12457
diff
changeset
|
8830 |
937356f8f8d6
patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents:
12457
diff
changeset
|
8831 void |
937356f8f8d6
patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents:
12457
diff
changeset
|
8832 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
|
8833 { |
937356f8f8d6
patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents:
12457
diff
changeset
|
8834 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
|
8835 } |
937356f8f8d6
patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents:
12457
diff
changeset
|
8836 #endif |