Mercurial > vim
annotate src/ex_docmd.c @ 17652:9efb4dda9720
patch 8.1.1823: command line history code is spread out
commit https://github.com/vim/vim/commit/d7663c22c6c1ff0f86b81371586fbc851d3a3e9e
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Aug 6 21:59:57 2019 +0200
patch 8.1.1823: command line history code is spread out
Problem: Command line history code is spread out.
Solution: Put the code in a new file. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/4779)
Also graduate the +cmdline_hist feature.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 06 Aug 2019 22:00:08 +0200 |
parents | a1437b8f2fac |
children | 10696f279e20 |
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 | |
17178
40c4cb095d53
patch 8.1.1588: in :let-heredoc line continuation is recognized
Bram Moolenaar <Bram@vim.org>
parents:
17111
diff
changeset
|
23 static char_u *do_one_cmd(char_u **, int, struct condstack *, 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); |
7 | 26 static int if_level = 0; /* depth in :if */ |
27 #endif | |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
28 static void free_cmdmod(void); |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
29 static void append_command(char_u *cmd); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
30 static char_u *find_command(exarg_T *eap, int *full); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
31 |
7 | 32 #ifndef FEAT_MENU |
33 # define ex_emenu ex_ni | |
34 # define ex_menu ex_ni | |
35 # define ex_menutranslate ex_ni | |
36 #endif | |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
37 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
|
38 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
|
39 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
|
40 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
|
41 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
|
42 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
|
43 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
|
44 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
|
45 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
|
46 static char_u *getargcmd(char_u **); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
47 static char_u *skip_cmd_arg(char_u *p, int rembs); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
48 static int getargopt(exarg_T *eap); |
7 | 49 #ifndef FEAT_QUICKFIX |
50 # define ex_make ex_ni | |
41 | 51 # define ex_cbuffer ex_ni |
7 | 52 # define ex_cc ex_ni |
53 # 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
|
54 # define ex_cbelow ex_ni |
7 | 55 # define ex_cfile ex_ni |
56 # define qf_list ex_ni | |
57 # define qf_age ex_ni | |
9538
26da1efa9e46
commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents:
9536
diff
changeset
|
58 # define qf_history ex_ni |
7 | 59 # define ex_helpgrep ex_ni |
41 | 60 # define ex_vimgrep ex_ni |
7 | 61 #endif |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
62 #if !defined(FEAT_QUICKFIX) |
7 | 63 # define ex_cclose ex_ni |
64 # define ex_copen ex_ni | |
65 # define ex_cwindow ex_ni | |
9432
abb72f0b9e06
commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents:
9284
diff
changeset
|
66 # define ex_cbottom ex_ni |
7 | 67 #endif |
532 | 68 #if !defined(FEAT_QUICKFIX) || !defined(FEAT_EVAL) |
69 # define ex_cexpr ex_ni | |
70 #endif | |
7 | 71 |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
72 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
|
73 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
|
74 #if !defined(FEAT_PERL) \ |
aee7e1e5e0ce
Build problem when using all interfaces except Lua.
Bram Moolenaar <bram@vim.org>
parents:
2330
diff
changeset
|
75 || !defined(FEAT_PYTHON) || !defined(FEAT_PYTHON3) \ |
aee7e1e5e0ce
Build problem when using all interfaces except Lua.
Bram Moolenaar <bram@vim.org>
parents:
2330
diff
changeset
|
76 || !defined(FEAT_TCL) \ |
aee7e1e5e0ce
Build problem when using all interfaces except Lua.
Bram Moolenaar <bram@vim.org>
parents:
2330
diff
changeset
|
77 || !defined(FEAT_RUBY) \ |
aee7e1e5e0ce
Build problem when using all interfaces except Lua.
Bram Moolenaar <bram@vim.org>
parents:
2330
diff
changeset
|
78 || !defined(FEAT_LUA) \ |
aee7e1e5e0ce
Build problem when using all interfaces except Lua.
Bram Moolenaar <bram@vim.org>
parents:
2330
diff
changeset
|
79 || !defined(FEAT_MZSCHEME) |
1315 | 80 # define HAVE_EX_SCRIPT_NI |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
81 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
|
82 #endif |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
83 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
|
84 static void correct_range(exarg_T *eap); |
344 | 85 #ifdef FEAT_QUICKFIX |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
86 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
|
87 #endif |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
88 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
|
89 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
|
90 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
|
91 static void ex_quit(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
92 static void ex_cquit(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_quit_all(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_close(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_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
|
96 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
|
97 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
|
98 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
|
99 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
|
100 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
|
101 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
|
102 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
|
103 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
|
104 #if defined(FEAT_QUICKFIX) |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
105 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
|
106 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
|
107 static void ex_pedit(exarg_T *eap); |
7 | 108 #else |
109 # define ex_pclose ex_ni | |
110 # define ex_ptag ex_ni | |
111 # define ex_pedit ex_ni | |
112 #endif | |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
113 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
|
114 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
|
115 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
|
116 static void ex_print(exarg_T *eap); |
7 | 117 #ifdef FEAT_BYTEOFF |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
118 static void ex_goto(exarg_T *eap); |
7 | 119 #else |
120 # define ex_goto ex_ni | |
121 #endif | |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
122 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
|
123 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
|
124 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
|
125 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
|
126 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
|
127 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
|
128 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
|
129 static void ex_edit(exarg_T *eap); |
7 | 130 #ifndef FEAT_GUI |
131 # define ex_gui ex_nogui | |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
132 static void ex_nogui(exarg_T *eap); |
7 | 133 #endif |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15866
diff
changeset
|
134 #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
|
135 static void ex_tearoff(exarg_T *eap); |
7 | 136 #else |
137 # define ex_tearoff ex_ni | |
138 #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
|
139 #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
|
140 || 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
|
141 static void ex_popup(exarg_T *eap); |
7 | 142 #else |
143 # define ex_popup ex_ni | |
144 #endif | |
145 #ifndef FEAT_GUI_MSWIN | |
146 # define ex_simalt ex_ni | |
147 #endif | |
573 | 148 #if !defined(FEAT_GUI_MSWIN) && !defined(FEAT_GUI_GTK) && !defined(FEAT_GUI_MOTIF) |
7 | 149 # define gui_mch_find_dialog ex_ni |
150 # define gui_mch_replace_dialog ex_ni | |
151 #endif | |
573 | 152 #if !defined(FEAT_GUI_GTK) |
7 | 153 # define ex_helpfind ex_ni |
154 #endif | |
155 #ifndef FEAT_CSCOPE | |
10373
bd674706408a
commit https://github.com/vim/vim/commit/d4db7719bdfbc54df396eac08d8cbb2389feacf4
Christian Brabandt <cb@256bit.org>
parents:
10361
diff
changeset
|
156 # define ex_cscope ex_ni |
bd674706408a
commit https://github.com/vim/vim/commit/d4db7719bdfbc54df396eac08d8cbb2389feacf4
Christian Brabandt <cb@256bit.org>
parents:
10361
diff
changeset
|
157 # define ex_scscope ex_ni |
bd674706408a
commit https://github.com/vim/vim/commit/d4db7719bdfbc54df396eac08d8cbb2389feacf4
Christian Brabandt <cb@256bit.org>
parents:
10361
diff
changeset
|
158 # define ex_cstag ex_ni |
7 | 159 #endif |
160 #ifndef FEAT_SYN_HL | |
161 # define ex_syntax ex_ni | |
2250
1bac28a53fae
Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents:
2238
diff
changeset
|
162 # define ex_ownsyntax ex_ni |
737 | 163 #endif |
4766
ec24ff78a79c
updated for version 7.3.1130
Bram Moolenaar <bram@vim.org>
parents:
4764
diff
changeset
|
164 #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
|
165 # define ex_syntime ex_ni |
f824cb97eb92
updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents:
4710
diff
changeset
|
166 #endif |
737 | 167 #ifndef FEAT_SPELL |
310 | 168 # define ex_spell ex_ni |
236 | 169 # define ex_mkspell ex_ni |
351 | 170 # define ex_spelldump ex_ni |
714 | 171 # define ex_spellinfo ex_ni |
372 | 172 # define ex_spellrepall ex_ni |
236 | 173 #endif |
2214
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
174 #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
|
175 # 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
|
176 # 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
|
177 #endif |
2320
966a5609669e
Added Lua interfae. (Luis Carvalho)
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
178 #ifndef FEAT_LUA |
966a5609669e
Added Lua interfae. (Luis Carvalho)
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
179 # define ex_lua ex_script_ni |
966a5609669e
Added Lua interfae. (Luis Carvalho)
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
180 # define ex_luado ex_ni |
966a5609669e
Added Lua interfae. (Luis Carvalho)
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
181 # define ex_luafile ex_ni |
966a5609669e
Added Lua interfae. (Luis Carvalho)
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
182 #endif |
14 | 183 #ifndef FEAT_MZSCHEME |
184 # define ex_mzscheme ex_script_ni | |
185 # define ex_mzfile ex_ni | |
186 #endif | |
7 | 187 #ifndef FEAT_PERL |
188 # define ex_perl ex_script_ni | |
189 # define ex_perldo ex_ni | |
190 #endif | |
191 #ifndef FEAT_PYTHON | |
192 # define ex_python ex_script_ni | |
4435 | 193 # define ex_pydo ex_ni |
7 | 194 # define ex_pyfile ex_ni |
195 #endif | |
2329
ad2889f48843
Added support for Python 3. (Roland Puntaier)
Bram Moolenaar <bram@vim.org>
parents:
2320
diff
changeset
|
196 #ifndef FEAT_PYTHON3 |
2350
06feaf4fe36a
Rename some "python3" symbols to "py3", as the command name.
Bram Moolenaar <bram@vim.org>
parents:
2340
diff
changeset
|
197 # define ex_py3 ex_script_ni |
4417 | 198 # define ex_py3do ex_ni |
2329
ad2889f48843
Added support for Python 3. (Roland Puntaier)
Bram Moolenaar <bram@vim.org>
parents:
2320
diff
changeset
|
199 # define ex_py3file ex_ni |
ad2889f48843
Added support for Python 3. (Roland Puntaier)
Bram Moolenaar <bram@vim.org>
parents:
2320
diff
changeset
|
200 #endif |
10722
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10656
diff
changeset
|
201 #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
|
202 # 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
|
203 # 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
|
204 # 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
|
205 #endif |
7 | 206 #ifndef FEAT_TCL |
207 # define ex_tcl ex_script_ni | |
208 # define ex_tcldo ex_ni | |
209 # define ex_tclfile ex_ni | |
210 #endif | |
211 #ifndef FEAT_RUBY | |
212 # define ex_ruby ex_script_ni | |
213 # define ex_rubydo ex_ni | |
214 # define ex_rubyfile ex_ni | |
215 #endif | |
216 #ifndef FEAT_KEYMAP | |
217 # define ex_loadkeymap ex_ni | |
218 #endif | |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
219 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
|
220 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
|
221 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
|
222 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
|
223 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
|
224 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
|
225 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
|
226 static void ex_wincmd(exarg_T *eap); |
11 | 227 #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
|
228 static void ex_winpos(exarg_T *eap); |
7 | 229 #else |
230 # define ex_winpos ex_ni | |
231 #endif | |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
232 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
|
233 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
|
234 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
|
235 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
|
236 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
|
237 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
|
238 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
|
239 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
|
240 #ifdef FEAT_PERSISTENT_UNDO |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
241 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
|
242 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
|
243 #endif |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
244 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
|
245 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
|
246 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
|
247 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
|
248 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
|
249 static void close_redir(void); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
250 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
|
251 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
|
252 static void ex_stopinsert(exarg_T *eap); |
7 | 253 #ifdef FEAT_FIND_ID |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
254 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
|
255 static void ex_findpat(exarg_T *eap); |
7 | 256 #else |
257 # define ex_findpat ex_ni | |
258 # define ex_checkpath ex_ni | |
259 #endif | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
260 #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
|
261 static void ex_psearch(exarg_T *eap); |
7 | 262 #else |
263 # define ex_psearch ex_ni | |
264 #endif | |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
265 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
|
266 static void ex_tag_cmd(exarg_T *eap, char_u *name); |
7 | 267 #ifndef FEAT_EVAL |
17622
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
268 # define ex_break ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
269 # define ex_breakadd ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
270 # define ex_breakdel ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
271 # define ex_breaklist ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
272 # define ex_call ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
273 # define ex_catch ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
274 # define ex_compiler ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
275 # define ex_const ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
276 # define ex_continue ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
277 # define ex_debug ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
278 # define ex_debuggreedy ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
279 # define ex_delfunction ex_ni |
7 | 280 # define ex_echo ex_ni |
281 # define ex_echohl ex_ni | |
17622
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
282 # define ex_else ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
283 # define ex_endfunction ex_ni |
7 | 284 # define ex_endif ex_ni |
17622
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
285 # define ex_endtry ex_ni |
7 | 286 # define ex_endwhile ex_ni |
17622
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
287 # define ex_eval ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
288 # define ex_execute ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
289 # define ex_finally ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
290 # define ex_finish ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
291 # define ex_function ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
292 # define ex_if ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
293 # define ex_let ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
294 # define ex_lockvar ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
295 # define ex_oldfiles ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
296 # define ex_options ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
297 # define ex_packadd ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
298 # define ex_packloadall ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
299 # define ex_return ex_ni |
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
300 # define ex_scriptnames ex_ni |
7 | 301 # define ex_throw ex_ni |
302 # define ex_try ex_ni | |
303 # define ex_unlet ex_ni | |
146 | 304 # define ex_unlockvar ex_ni |
17622
ccbf8c2a47ee
patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17576
diff
changeset
|
305 # define ex_while ex_ni |
7 | 306 #endif |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
307 static char_u *arg_all(void); |
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); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
326 static void ex_set(exarg_T *eap); |
7 | 327 #ifdef FEAT_SEARCH_EXTRA |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
328 static void ex_nohlsearch(exarg_T *eap); |
7 | 329 #else |
330 # define ex_nohlsearch ex_ni | |
331 # define ex_match ex_ni | |
332 #endif | |
333 #ifdef FEAT_CRYPT | |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
334 static void ex_X(exarg_T *eap); |
7 | 335 #else |
336 # define ex_X ex_ni | |
337 #endif | |
338 #ifdef FEAT_FOLDING | |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
339 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
|
340 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
|
341 static void ex_folddo(exarg_T *eap); |
7 | 342 #else |
343 # define ex_fold ex_ni | |
344 # define ex_foldopen ex_ni | |
345 # define ex_folddo ex_ni | |
346 #endif | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
347 #if !(defined(HAVE_LOCALE_H) || defined(X_LOCALE)) |
7 | 348 # define ex_language ex_ni |
349 #endif | |
350 #ifndef FEAT_SIGNS | |
351 # define ex_sign ex_ni | |
352 #endif | |
33 | 353 #ifndef FEAT_NETBEANS_INTG |
2210 | 354 # define ex_nbclose ex_ni |
33 | 355 # define ex_nbkey ex_ni |
2210 | 356 # define ex_nbstart ex_ni |
33 | 357 #endif |
7 | 358 |
359 #ifndef FEAT_JUMPLIST | |
360 # define ex_jumps ex_ni | |
9284
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
9260
diff
changeset
|
361 # define ex_clearjumps ex_ni |
7 | 362 # define ex_changes ex_ni |
363 #endif | |
364 | |
170 | 365 #ifndef FEAT_PROFILE |
366 # define ex_profile ex_ni | |
367 #endif | |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
11547
diff
changeset
|
368 #ifndef FEAT_TERMINAL |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
11547
diff
changeset
|
369 # define ex_terminal ex_ni |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
11547
diff
changeset
|
370 #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
|
371 #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
|
372 # 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
|
373 #endif |
16780
491c01280a5d
patch 8.1.1392: build failure in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
374 #if !defined(FEAT_TEXT_PROP) |
491c01280a5d
patch 8.1.1392: build failure in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
375 # define ex_popupclear ex_ni |
491c01280a5d
patch 8.1.1392: build failure in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
376 #endif |
170 | 377 |
7 | 378 /* |
379 * Declare cmdnames[]. | |
380 */ | |
381 #define DO_DECLARE_EXCMD | |
382 #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
|
383 #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
|
384 |
7 | 385 static char_u dollar_command[2] = {'$', 0}; |
386 | |
387 | |
388 #ifdef FEAT_EVAL | |
72 | 389 /* Struct for storing a line inside a while/for loop */ |
7 | 390 typedef struct |
391 { | |
392 char_u *line; /* command line */ | |
393 linenr_T lnum; /* sourcing_lnum of the line */ | |
394 } wcmd_T; | |
395 | |
396 /* | |
72 | 397 * Structure used to store info for line position in a while or for loop. |
7 | 398 * This is required, because do_one_cmd() may invoke ex_function(), which |
72 | 399 * reads more lines that may come from the while/for loop. |
400 */ | |
401 struct loop_cookie | |
7 | 402 { |
403 garray_T *lines_gap; /* growarray with line info */ | |
404 int current_line; /* last read line from growarray */ | |
405 int repeating; /* TRUE when looping a second time */ | |
406 /* 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
|
407 char_u *(*getline)(int, void *, int, int); |
7 | 408 void *cookie; |
409 }; | |
410 | |
17178
40c4cb095d53
patch 8.1.1588: in :let-heredoc line continuation is recognized
Bram Moolenaar <Bram@vim.org>
parents:
17111
diff
changeset
|
411 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
|
412 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
|
413 static void free_cmdlines(garray_T *gap); |
8 | 414 |
415 /* Struct to save a few things while debugging. Used in do_cmdline() only. */ | |
416 struct dbg_stuff | |
417 { | |
418 int trylevel; | |
419 int force_abort; | |
420 except_T *caught_stack; | |
421 char_u *vv_exception; | |
422 char_u *vv_throwpoint; | |
423 int did_emsg; | |
424 int got_int; | |
425 int did_throw; | |
426 int need_rethrow; | |
427 int check_cstack; | |
428 except_T *current_exception; | |
429 }; | |
430 | |
431 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
432 save_dbg_stuff(struct dbg_stuff *dsp) |
8 | 433 { |
434 dsp->trylevel = trylevel; trylevel = 0; | |
435 dsp->force_abort = force_abort; force_abort = FALSE; | |
436 dsp->caught_stack = caught_stack; caught_stack = NULL; | |
437 dsp->vv_exception = v_exception(NULL); | |
438 dsp->vv_throwpoint = v_throwpoint(NULL); | |
439 | |
440 /* Necessary for debugging an inactive ":catch", ":finally", ":endtry" */ | |
441 dsp->did_emsg = did_emsg; did_emsg = FALSE; | |
442 dsp->got_int = got_int; got_int = FALSE; | |
443 dsp->did_throw = did_throw; did_throw = FALSE; | |
444 dsp->need_rethrow = need_rethrow; need_rethrow = FALSE; | |
445 dsp->check_cstack = check_cstack; check_cstack = FALSE; | |
446 dsp->current_exception = current_exception; current_exception = NULL; | |
447 } | |
448 | |
449 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
450 restore_dbg_stuff(struct dbg_stuff *dsp) |
8 | 451 { |
452 suppress_errthrow = FALSE; | |
453 trylevel = dsp->trylevel; | |
454 force_abort = dsp->force_abort; | |
455 caught_stack = dsp->caught_stack; | |
456 (void)v_exception(dsp->vv_exception); | |
457 (void)v_throwpoint(dsp->vv_throwpoint); | |
458 did_emsg = dsp->did_emsg; | |
459 got_int = dsp->got_int; | |
460 did_throw = dsp->did_throw; | |
461 need_rethrow = dsp->need_rethrow; | |
462 check_cstack = dsp->check_cstack; | |
463 current_exception = dsp->current_exception; | |
464 } | |
7 | 465 #endif |
466 | |
467 /* | |
468 * do_exmode(): Repeatedly get commands for the "Ex" mode, until the ":vi" | |
469 * command is given. | |
470 */ | |
471 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
472 do_exmode( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
473 int improved) /* TRUE for "improved Ex" mode */ |
7 | 474 { |
475 int save_msg_scroll; | |
476 int prev_msg_row; | |
477 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
|
478 varnumber_T changedtick; |
167 | 479 |
480 if (improved) | |
481 exmode_active = EXMODE_VIM; | |
482 else | |
483 exmode_active = EXMODE_NORMAL; | |
484 State = NORMAL; | |
485 | |
486 /* When using ":global /pat/ visual" and then "Q" we return to continue | |
487 * the :global command. */ | |
488 if (global_busy) | |
489 return; | |
7 | 490 |
491 save_msg_scroll = msg_scroll; | |
492 ++RedrawingDisabled; /* don't redisplay the window */ | |
493 ++no_wait_return; /* don't wait for return */ | |
494 #ifdef FEAT_GUI | |
495 /* Ignore scrollbar and mouse events in Ex mode */ | |
496 ++hold_gui_events; | |
497 #endif | |
498 | |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15510
diff
changeset
|
499 msg(_("Entering Ex mode. Type \"visual\" to go to Normal mode.")); |
7 | 500 while (exmode_active) |
501 { | |
161 | 502 /* Check for a ":normal" command and no more characters left. */ |
503 if (ex_normal_busy > 0 && typebuf.tb_len == 0) | |
504 { | |
505 exmode_active = FALSE; | |
506 break; | |
507 } | |
7 | 508 msg_scroll = TRUE; |
509 need_wait_return = FALSE; | |
510 ex_pressedreturn = FALSE; | |
511 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
|
512 changedtick = CHANGEDTICK(curbuf); |
7 | 513 prev_msg_row = msg_row; |
514 prev_line = curwin->w_cursor.lnum; | |
515 if (improved) | |
516 { | |
517 cmdline_row = msg_row; | |
518 do_cmdline(NULL, getexline, NULL, 0); | |
519 } | |
520 else | |
521 do_cmdline(NULL, getexmodeline, NULL, DOCMD_NOWAIT); | |
522 lines_left = Rows - 1; | |
523 | |
167 | 524 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
|
525 || changedtick != CHANGEDTICK(curbuf)) && !ex_no_reprint) |
167 | 526 { |
527 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
|
528 emsg(_(e_emptybuf)); |
167 | 529 else |
530 { | |
531 if (ex_pressedreturn) | |
532 { | |
533 /* go up one line, to overwrite the ":<CR>" line, so the | |
1441 | 534 * output doesn't contain empty lines. */ |
167 | 535 msg_row = prev_msg_row; |
536 if (prev_msg_row == Rows - 1) | |
537 msg_row--; | |
538 } | |
539 msg_col = 0; | |
540 print_line_no_prefix(curwin->w_cursor.lnum, FALSE, FALSE); | |
541 msg_clr_eos(); | |
542 } | |
543 } | |
544 else if (ex_pressedreturn && !ex_no_reprint) /* must be at EOF */ | |
545 { | |
546 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
|
547 emsg(_(e_emptybuf)); |
167 | 548 else |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
549 emsg(_("E501: At end-of-file")); |
167 | 550 } |
7 | 551 } |
552 | |
553 #ifdef FEAT_GUI | |
554 --hold_gui_events; | |
555 #endif | |
556 --RedrawingDisabled; | |
557 --no_wait_return; | |
558 update_screen(CLEAR); | |
559 need_wait_return = FALSE; | |
560 msg_scroll = save_msg_scroll; | |
561 } | |
562 | |
563 /* | |
564 * Execute a simple command line. Used for translated commands like "*". | |
565 */ | |
566 int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
567 do_cmdline_cmd(char_u *cmd) |
7 | 568 { |
569 return do_cmdline(cmd, NULL, NULL, | |
570 DOCMD_VERBOSE|DOCMD_NOWAIT|DOCMD_KEYTYPED); | |
571 } | |
572 | |
573 /* | |
574 * do_cmdline(): execute one Ex command line | |
575 * | |
576 * 1. Execute "cmdline" when it is not NULL. | |
2635 | 577 * If "cmdline" is NULL, or more lines are needed, fgetline() is used. |
7 | 578 * 2. Split up in parts separated with '|'. |
579 * | |
580 * This function can be called recursively! | |
581 * | |
582 * flags: | |
583 * DOCMD_VERBOSE - The command will be included in the error message. | |
584 * DOCMD_NOWAIT - Don't call wait_return() and friends. | |
2635 | 585 * DOCMD_REPEAT - Repeat execution until fgetline() returns NULL. |
7 | 586 * DOCMD_KEYTYPED - Don't reset KeyTyped. |
587 * DOCMD_EXCRESET - Reset the exception environment (used for debugging). | |
588 * DOCMD_KEEPLINE - Store first typed line (for repeating with "."). | |
589 * | |
590 * return FAIL if cmdline could not be executed, OK otherwise | |
591 */ | |
592 int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
593 do_cmdline( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
594 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
|
595 char_u *(*fgetline)(int, void *, int, int), |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
596 void *cookie, /* argument for fgetline() */ |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
597 int flags) |
7 | 598 { |
599 char_u *next_cmdline; /* next cmd to execute */ | |
600 char_u *cmdline_copy = NULL; /* copy of cmd line */ | |
2635 | 601 int used_getline = FALSE; /* used "fgetline" to obtain command */ |
7 | 602 static int recursive = 0; /* recursive depth */ |
603 int msg_didout_before_start = 0; | |
604 int count = 0; /* line number count */ | |
605 int did_inc = FALSE; /* incremented RedrawingDisabled */ | |
606 int retval = OK; | |
607 #ifdef FEAT_EVAL | |
608 struct condstack cstack; /* conditional stack */ | |
72 | 609 garray_T lines_ga; /* keep lines for ":while"/":for" */ |
7 | 610 int current_line = 0; /* active line in lines_ga */ |
611 char_u *fname = NULL; /* function or script name */ | |
612 linenr_T *breakpoint = NULL; /* ptr to breakpoint field in cookie */ | |
613 int *dbg_tick = NULL; /* ptr to dbg_tick field in cookie */ | |
8 | 614 struct dbg_stuff debug_saved; /* saved things for debug mode */ |
7 | 615 int initial_trylevel; |
616 struct msglist **saved_msg_list = NULL; | |
617 struct msglist *private_msg_list; | |
618 | |
2635 | 619 /* "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
|
620 char_u *(*cmd_getline)(int, void *, int, int); |
7 | 621 void *cmd_cookie; |
72 | 622 struct loop_cookie cmd_loop_cookie; |
7 | 623 void *real_cookie; |
170 | 624 int getline_is_func; |
7 | 625 #else |
2635 | 626 # define cmd_getline fgetline |
7 | 627 # define cmd_cookie cookie |
628 #endif | |
629 static int call_depth = 0; /* recursiveness */ | |
630 | |
631 #ifdef FEAT_EVAL | |
632 /* For every pair of do_cmdline()/do_one_cmd() calls, use an extra memory | |
633 * location for storing error messages to be converted to an exception. | |
84 | 634 * This ensures that the do_errthrow() call in do_one_cmd() does not |
635 * combine the messages stored by an earlier invocation of do_one_cmd() | |
636 * with the command name of the later one. This would happen when | |
637 * BufWritePost autocommands are executed after a write error. */ | |
7 | 638 saved_msg_list = msg_list; |
639 msg_list = &private_msg_list; | |
640 private_msg_list = NULL; | |
641 #endif | |
642 | |
643 /* It's possible to create an endless loop with ":execute", catch that | |
10488
89200fa1d174
commit https://github.com/vim/vim/commit/777b30f827bcbe10a40640b1bf0361cb93a16be1
Christian Brabandt <cb@256bit.org>
parents:
10484
diff
changeset
|
644 * here. The value of 200 allows nested function calls, ":source", etc. |
89200fa1d174
commit https://github.com/vim/vim/commit/777b30f827bcbe10a40640b1bf0361cb93a16be1
Christian Brabandt <cb@256bit.org>
parents:
10484
diff
changeset
|
645 * 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
|
646 if (call_depth >= 200 |
8f2191b56d52
commit https://github.com/vim/vim/commit/b094ff4b2be4d8b7364c566a1cc7e27aa4452a50
Christian Brabandt <cb@256bit.org>
parents:
10488
diff
changeset
|
647 #ifdef FEAT_EVAL |
8f2191b56d52
commit https://github.com/vim/vim/commit/b094ff4b2be4d8b7364c566a1cc7e27aa4452a50
Christian Brabandt <cb@256bit.org>
parents:
10488
diff
changeset
|
648 && call_depth >= p_mfd |
8f2191b56d52
commit https://github.com/vim/vim/commit/b094ff4b2be4d8b7364c566a1cc7e27aa4452a50
Christian Brabandt <cb@256bit.org>
parents:
10488
diff
changeset
|
649 #endif |
8f2191b56d52
commit https://github.com/vim/vim/commit/b094ff4b2be4d8b7364c566a1cc7e27aa4452a50
Christian Brabandt <cb@256bit.org>
parents:
10488
diff
changeset
|
650 ) |
7 | 651 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
652 emsg(_("E169: Command too recursive")); |
7 | 653 #ifdef FEAT_EVAL |
654 /* When converting to an exception, we do not include the command name | |
655 * since this is not an error of the specific command. */ | |
656 do_errthrow((struct condstack *)NULL, (char_u *)NULL); | |
657 msg_list = saved_msg_list; | |
658 #endif | |
659 return FAIL; | |
660 } | |
661 ++call_depth; | |
662 | |
663 #ifdef FEAT_EVAL | |
664 cstack.cs_idx = -1; | |
72 | 665 cstack.cs_looplevel = 0; |
7 | 666 cstack.cs_trylevel = 0; |
667 cstack.cs_emsg_silent_list = NULL; | |
72 | 668 cstack.cs_lflags = 0; |
7 | 669 ga_init2(&lines_ga, (int)sizeof(wcmd_T), 10); |
670 | |
2635 | 671 real_cookie = getline_cookie(fgetline, cookie); |
7 | 672 |
673 /* Inside a function use a higher nesting level. */ | |
2635 | 674 getline_is_func = getline_equal(fgetline, cookie, get_func_line); |
170 | 675 if (getline_is_func && ex_nesting_level == func_level(real_cookie)) |
7 | 676 ++ex_nesting_level; |
677 | |
678 /* Get the function or script name and the address where the next breakpoint | |
679 * line and the debug tick for a function or script are stored. */ | |
170 | 680 if (getline_is_func) |
7 | 681 { |
682 fname = func_name(real_cookie); | |
683 breakpoint = func_breakpoint(real_cookie); | |
684 dbg_tick = func_dbg_tick(real_cookie); | |
685 } | |
2635 | 686 else if (getline_equal(fgetline, cookie, getsourceline)) |
7 | 687 { |
688 fname = sourcing_name; | |
689 breakpoint = source_breakpoint(real_cookie); | |
690 dbg_tick = source_dbg_tick(real_cookie); | |
691 } | |
692 | |
693 /* | |
694 * Initialize "force_abort" and "suppress_errthrow" at the top level. | |
695 */ | |
696 if (!recursive) | |
697 { | |
698 force_abort = FALSE; | |
699 suppress_errthrow = FALSE; | |
700 } | |
701 | |
702 /* | |
703 * If requested, store and reset the global values controlling the | |
944 | 704 * exception handling (used when debugging). Otherwise clear it to avoid |
705 * a bogus compiler warning when the optimizer uses inline functions... | |
7 | 706 */ |
878 | 707 if (flags & DOCMD_EXCRESET) |
8 | 708 save_dbg_stuff(&debug_saved); |
944 | 709 else |
7133
48ce650e8a27
commit https://github.com/vim/vim/commit/69b67f7e774dc212e8c97495ee81c601b8a89ac2
Christian Brabandt <cb@256bit.org>
parents:
7109
diff
changeset
|
710 vim_memset(&debug_saved, 0, sizeof(debug_saved)); |
7 | 711 |
712 initial_trylevel = trylevel; | |
713 | |
714 /* | |
715 * "did_throw" will be set to TRUE when an exception is being thrown. | |
716 */ | |
717 did_throw = FALSE; | |
718 #endif | |
719 /* | |
720 * "did_emsg" will be set to TRUE when emsg() is used, in which case we | |
72 | 721 * cancel the whole command line, and any if/endif or loop. |
7 | 722 * If force_abort is set, we cancel everything. |
723 */ | |
724 did_emsg = FALSE; | |
725 | |
726 /* | |
727 * KeyTyped is only set when calling vgetc(). Reset it here when not | |
728 * calling vgetc() (sourced command lines). | |
729 */ | |
2635 | 730 if (!(flags & DOCMD_KEYTYPED) |
731 && !getline_equal(fgetline, cookie, getexline)) | |
7 | 732 KeyTyped = FALSE; |
733 | |
734 /* | |
735 * Continue executing command lines: | |
72 | 736 * - when inside an ":if", ":while" or ":for" |
7 | 737 * - for multiple commands on one line, separated with '|' |
738 * - when repeating until there are no more lines (for ":source") | |
739 */ | |
740 next_cmdline = cmdline; | |
741 do | |
742 { | |
170 | 743 #ifdef FEAT_EVAL |
2635 | 744 getline_is_func = getline_equal(fgetline, cookie, get_func_line); |
170 | 745 #endif |
746 | |
72 | 747 /* stop skipping cmds for an error msg after all endif/while/for */ |
7 | 748 if (next_cmdline == NULL |
749 #ifdef FEAT_EVAL | |
750 && !force_abort | |
751 && cstack.cs_idx < 0 | |
170 | 752 && !(getline_is_func && func_has_abort(real_cookie)) |
7 | 753 #endif |
754 ) | |
755 did_emsg = FALSE; | |
756 | |
757 /* | |
72 | 758 * 1. If repeating a line in a loop, get a line from lines_ga. |
2635 | 759 * 2. If no line given: Get an allocated line with fgetline(). |
7 | 760 * 3. If a line is given: Make a copy, so we can mess with it. |
761 */ | |
762 | |
763 #ifdef FEAT_EVAL | |
764 /* 1. If repeating, get a previous line from lines_ga. */ | |
72 | 765 if (cstack.cs_looplevel > 0 && current_line < lines_ga.ga_len) |
7 | 766 { |
767 /* Each '|' separated command is stored separately in lines_ga, to | |
768 * 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
|
769 VIM_CLEAR(cmdline_copy); |
7 | 770 |
771 /* Check if a function has returned or, unless it has an unclosed | |
772 * try conditional, aborted. */ | |
170 | 773 if (getline_is_func) |
774 { | |
775 # ifdef FEAT_PROFILE | |
788 | 776 if (do_profiling == PROF_YES) |
170 | 777 func_line_end(real_cookie); |
778 # endif | |
779 if (func_has_ended(real_cookie)) | |
780 { | |
781 retval = FAIL; | |
782 break; | |
783 } | |
784 } | |
785 #ifdef FEAT_PROFILE | |
788 | 786 else if (do_profiling == PROF_YES |
2635 | 787 && getline_equal(fgetline, cookie, getsourceline)) |
170 | 788 script_line_end(); |
789 #endif | |
7 | 790 |
791 /* Check if a sourced file hit a ":finish" command. */ | |
2635 | 792 if (source_finished(fgetline, cookie)) |
7 | 793 { |
794 retval = FAIL; | |
795 break; | |
796 } | |
797 | |
798 /* If breakpoints have been added/deleted need to check for it. */ | |
799 if (breakpoint != NULL && dbg_tick != NULL | |
800 && *dbg_tick != debug_tick) | |
801 { | |
802 *breakpoint = dbg_find_breakpoint( | |
2635 | 803 getline_equal(fgetline, cookie, getsourceline), |
7 | 804 fname, sourcing_lnum); |
805 *dbg_tick = debug_tick; | |
806 } | |
807 | |
808 next_cmdline = ((wcmd_T *)(lines_ga.ga_data))[current_line].line; | |
809 sourcing_lnum = ((wcmd_T *)(lines_ga.ga_data))[current_line].lnum; | |
810 | |
811 /* Did we encounter a breakpoint? */ | |
812 if (breakpoint != NULL && *breakpoint != 0 | |
813 && *breakpoint <= sourcing_lnum) | |
814 { | |
815 dbg_breakpoint(fname, sourcing_lnum); | |
816 /* Find next breakpoint. */ | |
817 *breakpoint = dbg_find_breakpoint( | |
2635 | 818 getline_equal(fgetline, cookie, getsourceline), |
7 | 819 fname, sourcing_lnum); |
820 *dbg_tick = debug_tick; | |
821 } | |
170 | 822 # ifdef FEAT_PROFILE |
788 | 823 if (do_profiling == PROF_YES) |
170 | 824 { |
825 if (getline_is_func) | |
826 func_line_start(real_cookie); | |
2635 | 827 else if (getline_equal(fgetline, cookie, getsourceline)) |
170 | 828 script_line_start(); |
829 } | |
830 # endif | |
7 | 831 } |
832 | |
72 | 833 if (cstack.cs_looplevel > 0) |
834 { | |
835 /* Inside a while/for loop we need to store the lines and use them | |
2635 | 836 * again. Pass a different "fgetline" function to do_one_cmd() |
7 | 837 * below, so that it stores lines in or reads them from |
838 * "lines_ga". Makes it possible to define a function inside a | |
72 | 839 * while/for loop. */ |
840 cmd_getline = get_loop_line; | |
841 cmd_cookie = (void *)&cmd_loop_cookie; | |
842 cmd_loop_cookie.lines_gap = &lines_ga; | |
843 cmd_loop_cookie.current_line = current_line; | |
2635 | 844 cmd_loop_cookie.getline = fgetline; |
72 | 845 cmd_loop_cookie.cookie = cookie; |
846 cmd_loop_cookie.repeating = (current_line < lines_ga.ga_len); | |
7 | 847 } |
848 else | |
849 { | |
2635 | 850 cmd_getline = fgetline; |
7 | 851 cmd_cookie = cookie; |
852 } | |
853 #endif | |
854 | |
2635 | 855 /* 2. If no line given, get an allocated line with fgetline(). */ |
7 | 856 if (next_cmdline == NULL) |
857 { | |
858 /* | |
859 * Need to set msg_didout for the first line after an ":if", | |
860 * otherwise the ":if" will be overwritten. | |
861 */ | |
2635 | 862 if (count == 1 && getline_equal(fgetline, cookie, getexline)) |
7 | 863 msg_didout = TRUE; |
2635 | 864 if (fgetline == NULL || (next_cmdline = fgetline(':', cookie, |
7 | 865 #ifdef FEAT_EVAL |
866 cstack.cs_idx < 0 ? 0 : (cstack.cs_idx + 1) * 2 | |
867 #else | |
868 0 | |
869 #endif | |
17178
40c4cb095d53
patch 8.1.1588: in :let-heredoc line continuation is recognized
Bram Moolenaar <Bram@vim.org>
parents:
17111
diff
changeset
|
870 , TRUE)) == NULL) |
7 | 871 { |
872 /* Don't call wait_return for aborted command line. The NULL | |
873 * returned for the end of a sourced file or executed function | |
874 * doesn't do this. */ | |
875 if (KeyTyped && !(flags & DOCMD_REPEAT)) | |
876 need_wait_return = FALSE; | |
877 retval = FAIL; | |
878 break; | |
879 } | |
880 used_getline = TRUE; | |
881 | |
882 /* | |
883 * Keep the first typed line. Clear it when more lines are typed. | |
884 */ | |
885 if (flags & DOCMD_KEEPLINE) | |
886 { | |
887 vim_free(repeat_cmdline); | |
888 if (count == 0) | |
889 repeat_cmdline = vim_strsave(next_cmdline); | |
890 else | |
891 repeat_cmdline = NULL; | |
892 } | |
893 } | |
894 | |
895 /* 3. Make a copy of the command so we can mess with it. */ | |
896 else if (cmdline_copy == NULL) | |
897 { | |
898 next_cmdline = vim_strsave(next_cmdline); | |
899 if (next_cmdline == NULL) | |
900 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
901 emsg(_(e_outofmem)); |
7 | 902 retval = FAIL; |
903 break; | |
904 } | |
905 } | |
906 cmdline_copy = next_cmdline; | |
907 | |
908 #ifdef FEAT_EVAL | |
909 /* | |
72 | 910 * Save the current line when inside a ":while" or ":for", and when |
911 * the command looks like a ":while" or ":for", because we may need it | |
912 * later. When there is a '|' and another command, it is stored | |
913 * separately, because we need to be able to jump back to it from an | |
914 * :endwhile/:endfor. | |
7 | 915 */ |
72 | 916 if (current_line == lines_ga.ga_len |
917 && (cstack.cs_looplevel || has_loop_cmd(next_cmdline))) | |
918 { | |
919 if (store_loop_line(&lines_ga, next_cmdline) == FAIL) | |
7 | 920 { |
921 retval = FAIL; | |
922 break; | |
923 } | |
924 } | |
925 did_endif = FALSE; | |
926 #endif | |
927 | |
928 if (count++ == 0) | |
929 { | |
930 /* | |
931 * All output from the commands is put below each other, without | |
932 * waiting for a return. Don't do this when executing commands | |
933 * from a script or when being called recursive (e.g. for ":e | |
934 * +command file"). | |
935 */ | |
936 if (!(flags & DOCMD_NOWAIT) && !recursive) | |
937 { | |
938 msg_didout_before_start = msg_didout; | |
939 msg_didany = FALSE; /* no output yet */ | |
940 msg_start(); | |
941 msg_scroll = TRUE; /* put messages below each other */ | |
4352 | 942 ++no_wait_return; /* don't wait for return until finished */ |
7 | 943 ++RedrawingDisabled; |
944 did_inc = TRUE; | |
945 } | |
946 } | |
947 | |
948 if (p_verbose >= 15 && sourcing_name != NULL) | |
949 { | |
950 ++no_wait_return; | |
291 | 951 verbose_enter_scroll(); |
952 | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
953 smsg(_("line %ld: %s"), |
7 | 954 (long)sourcing_lnum, cmdline_copy); |
291 | 955 if (msg_silent == 0) |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15510
diff
changeset
|
956 msg_puts("\n"); /* don't overwrite this */ |
291 | 957 |
958 verbose_leave_scroll(); | |
7 | 959 --no_wait_return; |
960 } | |
961 | |
962 /* | |
963 * 2. Execute one '|' separated command. | |
964 * do_one_cmd() will return NULL if there is no trailing '|'. | |
965 * "cmdline_copy" can change, e.g. for '%' and '#' expansion. | |
966 */ | |
967 ++recursive; | |
968 next_cmdline = do_one_cmd(&cmdline_copy, flags & DOCMD_VERBOSE, | |
969 #ifdef FEAT_EVAL | |
970 &cstack, | |
971 #endif | |
972 cmd_getline, cmd_cookie); | |
973 --recursive; | |
974 | |
975 #ifdef FEAT_EVAL | |
72 | 976 if (cmd_cookie == (void *)&cmd_loop_cookie) |
977 /* Use "current_line" from "cmd_loop_cookie", it may have been | |
7 | 978 * incremented when defining a function. */ |
72 | 979 current_line = cmd_loop_cookie.current_line; |
7 | 980 #endif |
981 | |
982 if (next_cmdline == NULL) | |
983 { | |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13221
diff
changeset
|
984 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
|
985 |
7 | 986 /* |
987 * If the command was typed, remember it for the ':' register. | |
988 * Do this AFTER executing the command to make :@: work. | |
989 */ | |
2635 | 990 if (getline_equal(fgetline, cookie, getexline) |
7 | 991 && new_last_cmdline != NULL) |
992 { | |
993 vim_free(last_cmdline); | |
994 last_cmdline = new_last_cmdline; | |
995 new_last_cmdline = NULL; | |
996 } | |
997 } | |
998 else | |
999 { | |
1000 /* need to copy the command after the '|' to cmdline_copy, for the | |
1001 * next do_one_cmd() */ | |
1619 | 1002 STRMOVE(cmdline_copy, next_cmdline); |
7 | 1003 next_cmdline = cmdline_copy; |
1004 } | |
1005 | |
1006 | |
1007 #ifdef FEAT_EVAL | |
1008 /* reset did_emsg for a function that is not aborted by an error */ | |
1009 if (did_emsg && !force_abort | |
2635 | 1010 && getline_equal(fgetline, cookie, get_func_line) |
7 | 1011 && !func_has_abort(real_cookie)) |
1012 did_emsg = FALSE; | |
1013 | |
72 | 1014 if (cstack.cs_looplevel > 0) |
7 | 1015 { |
1016 ++current_line; | |
1017 | |
1018 /* | |
72 | 1019 * An ":endwhile", ":endfor" and ":continue" is handled here. |
1020 * If we were executing commands, jump back to the ":while" or | |
1021 * ":for". | |
1022 * If we were not executing commands, decrement cs_looplevel. | |
7 | 1023 */ |
72 | 1024 if (cstack.cs_lflags & (CSL_HAD_CONT | CSL_HAD_ENDLOOP)) |
1025 { | |
1026 cstack.cs_lflags &= ~(CSL_HAD_CONT | CSL_HAD_ENDLOOP); | |
1027 | |
1028 /* Jump back to the matching ":while" or ":for". Be careful | |
1029 * not to use a cs_line[] from an entry that isn't a ":while" | |
1030 * or ":for": It would make "current_line" invalid and can | |
1031 * cause a crash. */ | |
7 | 1032 if (!did_emsg && !got_int && !did_throw |
1033 && cstack.cs_idx >= 0 | |
72 | 1034 && (cstack.cs_flags[cstack.cs_idx] |
1035 & (CSF_WHILE | CSF_FOR)) | |
7 | 1036 && cstack.cs_line[cstack.cs_idx] >= 0 |
1037 && (cstack.cs_flags[cstack.cs_idx] & CSF_ACTIVE)) | |
1038 { | |
1039 current_line = cstack.cs_line[cstack.cs_idx]; | |
72 | 1040 /* remember we jumped there */ |
1041 cstack.cs_lflags |= CSL_HAD_LOOP; | |
7 | 1042 line_breakcheck(); /* check if CTRL-C typed */ |
1043 | |
72 | 1044 /* Check for the next breakpoint at or after the ":while" |
1045 * or ":for". */ | |
7 | 1046 if (breakpoint != NULL) |
1047 { | |
1048 *breakpoint = dbg_find_breakpoint( | |
2635 | 1049 getline_equal(fgetline, cookie, getsourceline), |
7 | 1050 fname, |
1051 ((wcmd_T *)lines_ga.ga_data)[current_line].lnum-1); | |
1052 *dbg_tick = debug_tick; | |
1053 } | |
1054 } | |
72 | 1055 else |
7 | 1056 { |
72 | 1057 /* can only get here with ":endwhile" or ":endfor" */ |
7 | 1058 if (cstack.cs_idx >= 0) |
77 | 1059 rewind_conditionals(&cstack, cstack.cs_idx - 1, |
1060 CSF_WHILE | CSF_FOR, &cstack.cs_looplevel); | |
7 | 1061 } |
1062 } | |
1063 | |
1064 /* | |
72 | 1065 * For a ":while" or ":for" we need to remember the line number. |
7 | 1066 */ |
72 | 1067 else if (cstack.cs_lflags & CSL_HAD_LOOP) |
1068 { | |
1069 cstack.cs_lflags &= ~CSL_HAD_LOOP; | |
7 | 1070 cstack.cs_line[cstack.cs_idx] = current_line - 1; |
1071 } | |
1072 } | |
1073 | |
13262
69278c25429d
patch 8.0.1505: debugger can't break on a condition
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
1074 /* Check for the next breakpoint after a watchexpression */ |
69278c25429d
patch 8.0.1505: debugger can't break on a condition
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
1075 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
|
1076 { |
69278c25429d
patch 8.0.1505: debugger can't break on a condition
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
1077 *breakpoint = dbg_find_breakpoint(FALSE, fname, sourcing_lnum); |
69278c25429d
patch 8.0.1505: debugger can't break on a condition
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
1078 *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
|
1079 } |
69278c25429d
patch 8.0.1505: debugger can't break on a condition
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
1080 |
7 | 1081 /* |
1082 * When not inside any ":while" loop, clear remembered lines. | |
1083 */ | |
72 | 1084 if (cstack.cs_looplevel == 0) |
7 | 1085 { |
1086 if (lines_ga.ga_len > 0) | |
1087 { | |
1088 sourcing_lnum = | |
1089 ((wcmd_T *)lines_ga.ga_data)[lines_ga.ga_len - 1].lnum; | |
1090 free_cmdlines(&lines_ga); | |
1091 } | |
1092 current_line = 0; | |
1093 } | |
1094 | |
1095 /* | |
72 | 1096 * A ":finally" makes did_emsg, got_int, and did_throw pending for |
1097 * being restored at the ":endtry". Reset them here and set the | |
1098 * ACTIVE and FINALLY flags, so that the finally clause gets executed. | |
1099 * This includes the case where a missing ":endif", ":endwhile" or | |
1100 * ":endfor" was detected by the ":finally" itself. | |
7 | 1101 */ |
72 | 1102 if (cstack.cs_lflags & CSL_HAD_FINA) |
1103 { | |
1104 cstack.cs_lflags &= ~CSL_HAD_FINA; | |
1105 report_make_pending(cstack.cs_pending[cstack.cs_idx] | |
1106 & (CSTP_ERROR | CSTP_INTERRUPT | CSTP_THROW), | |
7 | 1107 did_throw ? (void *)current_exception : NULL); |
1108 did_emsg = got_int = did_throw = FALSE; | |
1109 cstack.cs_flags[cstack.cs_idx] |= CSF_ACTIVE | CSF_FINALLY; | |
1110 } | |
1111 | |
1112 /* Update global "trylevel" for recursive calls to do_cmdline() from | |
1113 * within this loop. */ | |
1114 trylevel = initial_trylevel + cstack.cs_trylevel; | |
1115 | |
1116 /* | |
1190 | 1117 * If the outermost try conditional (across function calls and sourced |
7 | 1118 * files) is aborted because of an error, an interrupt, or an uncaught |
1119 * exception, cancel everything. If it is left normally, reset | |
1120 * force_abort to get the non-EH compatible abortion behavior for | |
1121 * the rest of the script. | |
1122 */ | |
1123 if (trylevel == 0 && !did_emsg && !got_int && !did_throw) | |
1124 force_abort = FALSE; | |
1125 | |
1126 /* Convert an interrupt to an exception if appropriate. */ | |
1127 (void)do_intthrow(&cstack); | |
1128 #endif /* FEAT_EVAL */ | |
1129 | |
1130 } | |
1131 /* | |
1132 * Continue executing command lines when: | |
1133 * - no CTRL-C typed, no aborting error, no exception thrown or try | |
1134 * conditionals need to be checked for executing finally clauses or | |
1135 * catching an interrupt exception | |
1136 * - didn't get an error message or lines are not typed | |
72 | 1137 * - there is a command after '|', inside a :if, :while, :for or :try, or |
7 | 1138 * looping for ":source" command or function call. |
1139 */ | |
1140 while (!((got_int | |
1141 #ifdef FEAT_EVAL | |
1142 || (did_emsg && force_abort) || did_throw | |
1143 #endif | |
1144 ) | |
1145 #ifdef FEAT_EVAL | |
1146 && cstack.cs_trylevel == 0 | |
1147 #endif | |
1148 ) | |
3757 | 1149 && !(did_emsg |
1150 #ifdef FEAT_EVAL | |
1151 /* Keep going when inside try/catch, so that the error can be | |
4352 | 1152 * deal with, except when it is a syntax error, it may cause |
3757 | 1153 * the :endtry to be missed. */ |
1154 && (cstack.cs_trylevel == 0 || did_emsg_syntax) | |
1155 #endif | |
1156 && used_getline | |
2635 | 1157 && (getline_equal(fgetline, cookie, getexmodeline) |
1158 || getline_equal(fgetline, cookie, getexline))) | |
7 | 1159 && (next_cmdline != NULL |
1160 #ifdef FEAT_EVAL | |
1161 || cstack.cs_idx >= 0 | |
1162 #endif | |
1163 || (flags & DOCMD_REPEAT))); | |
1164 | |
1165 vim_free(cmdline_copy); | |
3757 | 1166 did_emsg_syntax = FALSE; |
7 | 1167 #ifdef FEAT_EVAL |
1168 free_cmdlines(&lines_ga); | |
1169 ga_clear(&lines_ga); | |
1170 | |
1171 if (cstack.cs_idx >= 0) | |
1172 { | |
1173 /* | |
1174 * If a sourced file or executed function ran to its end, report the | |
1175 * unclosed conditional. | |
1176 */ | |
1177 if (!got_int && !did_throw | |
2635 | 1178 && ((getline_equal(fgetline, cookie, getsourceline) |
1179 && !source_finished(fgetline, cookie)) | |
1180 || (getline_equal(fgetline, cookie, get_func_line) | |
7 | 1181 && !func_has_ended(real_cookie)))) |
1182 { | |
1183 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
|
1184 emsg(_(e_endtry)); |
7 | 1185 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
|
1186 emsg(_(e_endwhile)); |
72 | 1187 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
|
1188 emsg(_(e_endfor)); |
7 | 1189 else |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
1190 emsg(_(e_endif)); |
7 | 1191 } |
1192 | |
1193 /* | |
1194 * Reset "trylevel" in case of a ":finish" or ":return" or a missing | |
1195 * ":endtry" in a sourced file or executed function. If the try | |
1196 * conditional is in its finally clause, ignore anything pending. | |
1197 * If it is in a catch clause, finish the caught exception. | |
77 | 1198 * Also cleanup any "cs_forinfo" structures. |
7 | 1199 */ |
1200 do | |
77 | 1201 { |
1202 int idx = cleanup_conditionals(&cstack, 0, TRUE); | |
1203 | |
111 | 1204 if (idx >= 0) |
1205 --idx; /* remove try block not in its finally clause */ | |
77 | 1206 rewind_conditionals(&cstack, idx, CSF_WHILE | CSF_FOR, |
1207 &cstack.cs_looplevel); | |
1208 } | |
1209 while (cstack.cs_idx >= 0); | |
7 | 1210 trylevel = initial_trylevel; |
1211 } | |
1212 | |
72 | 1213 /* If a missing ":endtry", ":endwhile", ":endfor", or ":endif" or a memory |
1214 * lack was reported above and the error message is to be converted to an | |
7 | 1215 * exception, do this now after rewinding the cstack. */ |
2635 | 1216 do_errthrow(&cstack, getline_equal(fgetline, cookie, get_func_line) |
7 | 1217 ? (char_u *)"endfunction" : (char_u *)NULL); |
1218 | |
1219 if (trylevel == 0) | |
1220 { | |
1221 /* | |
1222 * When an exception is being thrown out of the outermost try | |
1223 * conditional, discard the uncaught exception, disable the conversion | |
1224 * of interrupts or errors to exceptions, and ensure that no more | |
1225 * commands are executed. | |
1226 */ | |
1227 if (did_throw) | |
1228 { | |
1229 void *p = NULL; | |
1230 char_u *saved_sourcing_name; | |
1231 int saved_sourcing_lnum; | |
1232 struct msglist *messages = NULL, *next; | |
1233 | |
1234 /* | |
1235 * If the uncaught exception is a user exception, report it as an | |
1236 * error. If it is an error exception, display the saved error | |
1237 * message now. For an interrupt exception, do nothing; the | |
1238 * interrupt message is given elsewhere. | |
1239 */ | |
1240 switch (current_exception->type) | |
1241 { | |
1242 case ET_USER: | |
272 | 1243 vim_snprintf((char *)IObuff, IOSIZE, |
1244 _("E605: Exception not caught: %s"), | |
7 | 1245 current_exception->value); |
1246 p = vim_strsave(IObuff); | |
1247 break; | |
1248 case ET_ERROR: | |
1249 messages = current_exception->messages; | |
1250 current_exception->messages = NULL; | |
1251 break; | |
1252 case ET_INTERRUPT: | |
1253 break; | |
1254 } | |
1255 | |
1256 saved_sourcing_name = sourcing_name; | |
1257 saved_sourcing_lnum = sourcing_lnum; | |
1258 sourcing_name = current_exception->throw_name; | |
1259 sourcing_lnum = current_exception->throw_lnum; | |
1260 current_exception->throw_name = NULL; | |
1261 | |
1262 discard_current_exception(); /* uses IObuff if 'verbose' */ | |
1263 suppress_errthrow = TRUE; | |
1264 force_abort = TRUE; | |
1265 | |
1266 if (messages != NULL) | |
1267 { | |
1268 do | |
1269 { | |
1270 next = messages->next; | |
1271 emsg(messages->msg); | |
1272 vim_free(messages->msg); | |
1273 vim_free(messages); | |
1274 messages = next; | |
1275 } | |
1276 while (messages != NULL); | |
1277 } | |
1278 else if (p != NULL) | |
1279 { | |
15490
98c35d312987
patch 8.1.0753: printf format not checked for semsg()
Bram Moolenaar <Bram@vim.org>
parents:
15488
diff
changeset
|
1280 emsg(p); |
7 | 1281 vim_free(p); |
1282 } | |
1283 vim_free(sourcing_name); | |
1284 sourcing_name = saved_sourcing_name; | |
1285 sourcing_lnum = saved_sourcing_lnum; | |
1286 } | |
1287 | |
1288 /* | |
1289 * On an interrupt or an aborting error not converted to an exception, | |
1290 * disable the conversion of errors to exceptions. (Interrupts are not | |
1291 * converted any more, here.) This enables also the interrupt message | |
1292 * when force_abort is set and did_emsg unset in case of an interrupt | |
1293 * from a finally clause after an error. | |
1294 */ | |
1295 else if (got_int || (did_emsg && force_abort)) | |
1296 suppress_errthrow = TRUE; | |
1297 } | |
1298 | |
1299 /* | |
1300 * The current cstack will be freed when do_cmdline() returns. An uncaught | |
1301 * exception will have to be rethrown in the previous cstack. If a function | |
1302 * has just returned or a script file was just finished and the previous | |
1303 * cstack belongs to the same function or, respectively, script file, it | |
1304 * will have to be checked for finally clauses to be executed due to the | |
1305 * ":return" or ":finish". This is done in do_one_cmd(). | |
1306 */ | |
1307 if (did_throw) | |
1308 need_rethrow = TRUE; | |
2635 | 1309 if ((getline_equal(fgetline, cookie, getsourceline) |
7 | 1310 && ex_nesting_level > source_level(real_cookie)) |
2635 | 1311 || (getline_equal(fgetline, cookie, get_func_line) |
7 | 1312 && ex_nesting_level > func_level(real_cookie) + 1)) |
1313 { | |
1314 if (!did_throw) | |
1315 check_cstack = TRUE; | |
1316 } | |
1317 else | |
1318 { | |
1319 /* When leaving a function, reduce nesting level. */ | |
2635 | 1320 if (getline_equal(fgetline, cookie, get_func_line)) |
7 | 1321 --ex_nesting_level; |
1322 /* | |
1323 * Go to debug mode when returning from a function in which we are | |
1324 * single-stepping. | |
1325 */ | |
2635 | 1326 if ((getline_equal(fgetline, cookie, getsourceline) |
1327 || getline_equal(fgetline, cookie, get_func_line)) | |
7 | 1328 && ex_nesting_level + 1 <= debug_break_level) |
2635 | 1329 do_debug(getline_equal(fgetline, cookie, getsourceline) |
7 | 1330 ? (char_u *)_("End of sourced file") |
1331 : (char_u *)_("End of function")); | |
1332 } | |
1333 | |
1334 /* | |
1335 * Restore the exception environment (done after returning from the | |
1336 * debugger). | |
1337 */ | |
1338 if (flags & DOCMD_EXCRESET) | |
8 | 1339 restore_dbg_stuff(&debug_saved); |
7 | 1340 |
1341 msg_list = saved_msg_list; | |
1342 #endif /* FEAT_EVAL */ | |
1343 | |
1344 /* | |
1345 * If there was too much output to fit on the command line, ask the user to | |
1346 * hit return before redrawing the screen. With the ":global" command we do | |
1347 * this only once after the command is finished. | |
1348 */ | |
1349 if (did_inc) | |
1350 { | |
1351 --RedrawingDisabled; | |
1352 --no_wait_return; | |
1353 msg_scroll = FALSE; | |
1354 | |
1355 /* | |
1356 * When just finished an ":if"-":else" which was typed, no need to | |
1357 * wait for hit-return. Also for an error situation. | |
1358 */ | |
1359 if (retval == FAIL | |
1360 #ifdef FEAT_EVAL | |
1361 || (did_endif && KeyTyped && !did_emsg) | |
1362 #endif | |
1363 ) | |
1364 { | |
1365 need_wait_return = FALSE; | |
1366 msg_didany = FALSE; /* don't wait when restarting edit */ | |
1367 } | |
1368 else if (need_wait_return) | |
1369 { | |
1370 /* | |
1371 * The msg_start() above clears msg_didout. The wait_return we do | |
1372 * here should not overwrite the command that may be shown before | |
1373 * doing that. | |
1374 */ | |
1375 msg_didout |= msg_didout_before_start; | |
1376 wait_return(FALSE); | |
1377 } | |
1378 } | |
1379 | |
3976 | 1380 #ifdef FEAT_EVAL |
1381 did_endif = FALSE; /* in case do_cmdline used recursively */ | |
1382 #else | |
7 | 1383 /* |
1384 * Reset if_level, in case a sourced script file contains more ":if" than | |
1385 * ":endif" (could be ":if x | foo | endif"). | |
1386 */ | |
1387 if_level = 0; | |
3972 | 1388 #endif |
3963 | 1389 |
7 | 1390 --call_depth; |
1391 return retval; | |
1392 } | |
1393 | |
1394 #ifdef FEAT_EVAL | |
1395 /* | |
72 | 1396 * Obtain a line when inside a ":while" or ":for" loop. |
7 | 1397 */ |
1398 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
|
1399 get_loop_line(int c, void *cookie, int indent, int do_concat) |
7 | 1400 { |
72 | 1401 struct loop_cookie *cp = (struct loop_cookie *)cookie; |
7 | 1402 wcmd_T *wp; |
1403 char_u *line; | |
1404 | |
1405 if (cp->current_line + 1 >= cp->lines_gap->ga_len) | |
1406 { | |
1407 if (cp->repeating) | |
72 | 1408 return NULL; /* trying to read past ":endwhile"/":endfor" */ |
1409 | |
1410 /* First time inside the ":while"/":for": get line normally. */ | |
7 | 1411 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
|
1412 line = getcmdline(c, 0L, indent, do_concat); |
7 | 1413 else |
17178
40c4cb095d53
patch 8.1.1588: in :let-heredoc line continuation is recognized
Bram Moolenaar <Bram@vim.org>
parents:
17111
diff
changeset
|
1414 line = cp->getline(c, cp->cookie, indent, do_concat); |
857 | 1415 if (line != NULL && store_loop_line(cp->lines_gap, line) == OK) |
7 | 1416 ++cp->current_line; |
1417 | |
1418 return line; | |
1419 } | |
1420 | |
1421 KeyTyped = FALSE; | |
1422 ++cp->current_line; | |
1423 wp = (wcmd_T *)(cp->lines_gap->ga_data) + cp->current_line; | |
1424 sourcing_lnum = wp->lnum; | |
1425 return vim_strsave(wp->line); | |
1426 } | |
1427 | |
1428 /* | |
1429 * Store a line in "gap" so that a ":while" loop can execute it again. | |
1430 */ | |
1431 static int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
1432 store_loop_line(garray_T *gap, char_u *line) |
7 | 1433 { |
1434 if (ga_grow(gap, 1) == FAIL) | |
1435 return FAIL; | |
1436 ((wcmd_T *)(gap->ga_data))[gap->ga_len].line = vim_strsave(line); | |
1437 ((wcmd_T *)(gap->ga_data))[gap->ga_len].lnum = sourcing_lnum; | |
1438 ++gap->ga_len; | |
1439 return OK; | |
1440 } | |
1441 | |
1442 /* | |
72 | 1443 * Free the lines stored for a ":while" or ":for" loop. |
7 | 1444 */ |
1445 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
1446 free_cmdlines(garray_T *gap) |
7 | 1447 { |
1448 while (gap->ga_len > 0) | |
1449 { | |
1450 vim_free(((wcmd_T *)(gap->ga_data))[gap->ga_len - 1].line); | |
1451 --gap->ga_len; | |
1452 } | |
1453 } | |
1454 #endif | |
1455 | |
1456 /* | |
944 | 1457 * If "fgetline" is get_loop_line(), return TRUE if the getline it uses equals |
1458 * "func". * Otherwise return TRUE when "fgetline" equals "func". | |
7 | 1459 */ |
1460 int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
1461 getline_equal( |
17178
40c4cb095d53
patch 8.1.1588: in :let-heredoc line continuation is recognized
Bram Moolenaar <Bram@vim.org>
parents:
17111
diff
changeset
|
1462 char_u *(*fgetline)(int, void *, int, int), |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
1463 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
|
1464 char_u *(*func)(int, void *, int, int)) |
7 | 1465 { |
1466 #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
|
1467 char_u *(*gp)(int, void *, int, int); |
72 | 1468 struct loop_cookie *cp; |
1469 | |
944 | 1470 /* When "fgetline" is "get_loop_line()" use the "cookie" to find the |
1190 | 1471 * function that's originally used to obtain the lines. This may be |
1472 * nested several levels. */ | |
944 | 1473 gp = fgetline; |
72 | 1474 cp = (struct loop_cookie *)cookie; |
1475 while (gp == get_loop_line) | |
7 | 1476 { |
1477 gp = cp->getline; | |
1478 cp = cp->cookie; | |
1479 } | |
1480 return gp == func; | |
1481 #else | |
944 | 1482 return fgetline == func; |
7 | 1483 #endif |
1484 } | |
1485 | |
1486 /* | |
944 | 1487 * If "fgetline" is get_loop_line(), return the cookie used by the original |
7 | 1488 * getline function. Otherwise return "cookie". |
1489 */ | |
1490 void * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
1491 getline_cookie( |
17178
40c4cb095d53
patch 8.1.1588: in :let-heredoc line continuation is recognized
Bram Moolenaar <Bram@vim.org>
parents:
17111
diff
changeset
|
1492 char_u *(*fgetline)(int, void *, int, int) UNUSED, |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
1493 void *cookie) /* argument for fgetline() */ |
7 | 1494 { |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
1495 #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
|
1496 char_u *(*gp)(int, void *, int, int); |
72 | 1497 struct loop_cookie *cp; |
1498 | |
944 | 1499 /* When "fgetline" is "get_loop_line()" use the "cookie" to find the |
1190 | 1500 * cookie that's originally used to obtain the lines. This may be nested |
7 | 1501 * several levels. */ |
944 | 1502 gp = fgetline; |
72 | 1503 cp = (struct loop_cookie *)cookie; |
1504 while (gp == get_loop_line) | |
7 | 1505 { |
1506 gp = cp->getline; | |
1507 cp = cp->cookie; | |
1508 } | |
1509 return cp; | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
1510 #else |
7 | 1511 return cookie; |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
1512 #endif |
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
1513 } |
7 | 1514 |
6398 | 1515 |
1516 /* | |
1517 * Helper function to apply an offset for buffer commands, i.e. ":bdelete", | |
1518 * ":bwipeout", etc. | |
1519 * Returns the buffer number. | |
1520 */ | |
1521 static int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
1522 compute_buffer_local_count(int addr_type, int lnum, int offset) |
6398 | 1523 { |
1524 buf_T *buf; | |
6417 | 1525 buf_T *nextbuf; |
6398 | 1526 int count = offset; |
1527 | |
1528 buf = firstbuf; | |
1529 while (buf->b_next != NULL && buf->b_fnum < lnum) | |
1530 buf = buf->b_next; | |
1531 while (count != 0) | |
1532 { | |
6417 | 1533 count += (offset < 0) ? 1 : -1; |
1534 nextbuf = (offset < 0) ? buf->b_prev : buf->b_next; | |
1535 if (nextbuf == NULL) | |
6398 | 1536 break; |
6417 | 1537 buf = nextbuf; |
6398 | 1538 if (addr_type == ADDR_LOADED_BUFFERS) |
1539 /* skip over unloaded buffers */ | |
6417 | 1540 while (buf->b_ml.ml_mfp == NULL) |
1541 { | |
1542 nextbuf = (offset < 0) ? buf->b_prev : buf->b_next; | |
1543 if (nextbuf == NULL) | |
1544 break; | |
1545 buf = nextbuf; | |
1546 } | |
1547 } | |
1548 /* we might have gone too far, last buffer is not loadedd */ | |
1549 if (addr_type == ADDR_LOADED_BUFFERS) | |
1550 while (buf->b_ml.ml_mfp == NULL) | |
1551 { | |
1552 nextbuf = (offset >= 0) ? buf->b_prev : buf->b_next; | |
1553 if (nextbuf == NULL) | |
1554 break; | |
1555 buf = nextbuf; | |
1556 } | |
6398 | 1557 return buf->b_fnum; |
1558 } | |
1559 | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
1560 /* |
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
1561 * 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
|
1562 * 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
|
1563 */ |
6409 | 1564 static int |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
1565 current_win_nr(win_T *win) |
6409 | 1566 { |
1567 win_T *wp; | |
1568 int nr = 0; | |
1569 | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9538
diff
changeset
|
1570 FOR_ALL_WINDOWS(wp) |
6409 | 1571 { |
1572 ++nr; | |
1573 if (wp == win) | |
1574 break; | |
1575 } | |
1576 return nr; | |
1577 } | |
1578 | |
1579 static int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
1580 current_tab_nr(tabpage_T *tab) |
6409 | 1581 { |
1582 tabpage_T *tp; | |
1583 int nr = 0; | |
1584 | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9538
diff
changeset
|
1585 FOR_ALL_TABPAGES(tp) |
6409 | 1586 { |
1587 ++nr; | |
1588 if (tp == tab) | |
1589 break; | |
1590 } | |
1591 return nr; | |
1592 } | |
1593 | |
1594 # define CURRENT_WIN_NR current_win_nr(curwin) | |
1595 # define LAST_WIN_NR current_win_nr(NULL) | |
1596 # define CURRENT_TAB_NR current_tab_nr(curtab) | |
1597 # define LAST_TAB_NR current_tab_nr(NULL) | |
6398 | 1598 |
7 | 1599 /* |
1600 * Execute one Ex command. | |
1601 * | |
1602 * If 'sourcing' is TRUE, the command will be included in the error message. | |
1603 * | |
1604 * 1. skip comment lines and leading space | |
1605 * 2. handle command modifiers | |
6400 | 1606 * 3. find the command |
6398 | 1607 * 4. parse range |
6400 | 1608 * 5. Parse the command. |
6398 | 1609 * 6. parse arguments |
1610 * 7. switch on command name | |
7 | 1611 * |
944 | 1612 * Note: "fgetline" can be NULL. |
7 | 1613 * |
1614 * This function may be called recursively! | |
1615 */ | |
1616 #if (_MSC_VER == 1200) | |
1617 /* | |
8 | 1618 * Avoid optimisation bug in VC++ version 6.0 |
7 | 1619 */ |
128 | 1620 #pragma optimize( "g", off ) |
7 | 1621 #endif |
1622 static char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
1623 do_one_cmd( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
1624 char_u **cmdlinep, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
1625 int sourcing, |
7 | 1626 #ifdef FEAT_EVAL |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
1627 struct condstack *cstack, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
1628 #endif |
17178
40c4cb095d53
patch 8.1.1588: in :let-heredoc line continuation is recognized
Bram Moolenaar <Bram@vim.org>
parents:
17111
diff
changeset
|
1629 char_u *(*fgetline)(int, void *, int, int), |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
1630 void *cookie) /* argument for fgetline() */ |
7 | 1631 { |
1632 char_u *p; | |
1633 linenr_T lnum; | |
1634 long n; | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
1635 char *errormsg = NULL; /* error message */ |
9941
e975914c17e9
commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
9927
diff
changeset
|
1636 char_u *after_modifier = NULL; |
7 | 1637 exarg_T ea; /* Ex command arguments */ |
1926 | 1638 int save_msg_scroll = msg_scroll; |
7 | 1639 cmdmod_T save_cmdmod; |
16144
4850744dc181
patch 8.1.1077: reg_executing() is reset by calling input()
Bram Moolenaar <Bram@vim.org>
parents:
15973
diff
changeset
|
1640 int save_reg_executing = reg_executing; |
7 | 1641 int ni; /* set when Not Implemented */ |
6398 | 1642 char_u *cmd; |
7 | 1643 |
1644 vim_memset(&ea, 0, sizeof(ea)); | |
1645 ea.line1 = 1; | |
1646 ea.line2 = 1; | |
1647 #ifdef FEAT_EVAL | |
1648 ++ex_nesting_level; | |
1649 #endif | |
1650 | |
3997 | 1651 /* When the last file has not been edited :q has to be typed twice. */ |
7 | 1652 if (quitmore |
1653 #ifdef FEAT_EVAL | |
1654 /* avoid that a function call in 'statusline' does this */ | |
944 | 1655 && !getline_equal(fgetline, cookie, get_func_line) |
4133 | 1656 #endif |
3997 | 1657 /* 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
|
1658 && !getline_equal(fgetline, cookie, getnextac)) |
7 | 1659 --quitmore; |
1660 | |
1661 /* | |
1662 * Reset browse, confirm, etc.. They are restored when returning, for | |
1663 * recursive calls. | |
1664 */ | |
1665 save_cmdmod = cmdmod; | |
1666 | |
930 | 1667 /* "#!anything" is handled like a comment. */ |
1668 if ((*cmdlinep)[0] == '#' && (*cmdlinep)[1] == '!') | |
1669 goto doend; | |
1670 | |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
1671 /* |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
1672 * 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
|
1673 * 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
|
1674 */ |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
1675 // The "ea" structure holds the arguments that can be used. |
7 | 1676 ea.cmd = *cmdlinep; |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
1677 ea.cmdlinep = cmdlinep; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
1678 ea.getline = fgetline; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
1679 ea.cookie = cookie; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
1680 #ifdef FEAT_EVAL |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
1681 ea.cstack = cstack; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
1682 #endif |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
1683 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
|
1684 goto doend; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
1685 |
9941
e975914c17e9
commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
9927
diff
changeset
|
1686 after_modifier = ea.cmd; |
7 | 1687 |
1688 #ifdef FEAT_EVAL | |
1689 ea.skip = did_emsg || got_int || did_throw || (cstack->cs_idx >= 0 | |
1690 && !(cstack->cs_flags[cstack->cs_idx] & CSF_ACTIVE)); | |
1691 #else | |
1692 ea.skip = (if_level > 0); | |
1693 #endif | |
1694 | |
1695 /* | |
6398 | 1696 * 3. Skip over the range to find the command. Let "p" point to after it. |
1697 * | |
1698 * We need the command to know what kind of range it uses. | |
1699 */ | |
1700 cmd = ea.cmd; | |
1701 ea.cmd = skip_range(ea.cmd, NULL); | |
1702 if (*ea.cmd == '*' && vim_strchr(p_cpo, CPO_STAR) == NULL) | |
1703 ea.cmd = skipwhite(ea.cmd + 1); | |
1704 p = find_command(&ea, NULL); | |
1705 | |
14591
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1706 #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
|
1707 # 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
|
1708 // 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
|
1709 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
|
1710 && (!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
|
1711 && (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
|
1712 { |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1713 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
|
1714 |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1715 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
|
1716 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
|
1717 && (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
|
1718 && !(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
|
1719 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
|
1720 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
|
1721 && !(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
|
1722 & (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
|
1723 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
|
1724 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
|
1725 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
|
1726 && 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
|
1727 && 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
|
1728 && 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
|
1729 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
|
1730 |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1731 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
|
1732 { |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1733 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
|
1734 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
|
1735 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
|
1736 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
|
1737 } |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1738 } |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1739 # endif |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1740 |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1741 /* May go to debug mode. If this happens and the ">quit" debug command is |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1742 * used, throw an interrupt exception and skip the next command. */ |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1743 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
|
1744 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
|
1745 { |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1746 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
|
1747 (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
|
1748 } |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1749 #endif |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1750 |
6398 | 1751 /* |
1752 * 4. parse a range specifier of the form: addr [,addr] [;addr] .. | |
7 | 1753 * |
1754 * where 'addr' is: | |
1755 * | |
1756 * % (entire file) | |
1757 * $ [+-NUM] | |
1758 * 'x [+-NUM] (where x denotes a currently defined mark) | |
1759 * . [+-NUM] | |
1760 * [+-NUM].. | |
1761 * NUM | |
1762 * | |
1763 * The ea.cmd pointer is updated to point to the first character following the | |
1764 * range spec. If an initial address is found, but no second, the upper bound | |
1765 * is equal to the lower. | |
1766 */ | |
1767 | |
16515
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
1768 // ea.addr_type for user commands is set by find_ucmd |
6489 | 1769 if (!IS_USER_CMDIDX(ea.cmdidx)) |
1770 { | |
1771 if (ea.cmdidx != CMD_SIZE) | |
1772 ea.addr_type = cmdnames[(int)ea.cmdidx].cmd_addr_type; | |
1773 else | |
1774 ea.addr_type = ADDR_LINES; | |
1775 | |
16515
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
1776 // :wincmd range depends on the argument. |
6506 | 1777 if (ea.cmdidx == CMD_wincmd && p != NULL) |
1778 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
|
1779 #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
|
1780 // :.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
|
1781 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
|
1782 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
|
1783 #endif |
6489 | 1784 } |
6398 | 1785 |
6489 | 1786 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
|
1787 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
|
1788 goto doend; |
7 | 1789 |
1790 /* | |
6398 | 1791 * 5. Parse the command. |
7 | 1792 */ |
1793 | |
1794 /* | |
1795 * Skip ':' and any white space | |
1796 */ | |
1797 ea.cmd = skipwhite(ea.cmd); | |
1798 while (*ea.cmd == ':') | |
1799 ea.cmd = skipwhite(ea.cmd + 1); | |
1800 | |
1801 /* | |
1802 * If we got a line, but no command, then go to the line. | |
1803 * If we find a '|' or '\n' we set ea.nextcmd. | |
1804 */ | |
6398 | 1805 if (*ea.cmd == NUL || *ea.cmd == '"' |
1806 || (ea.nextcmd = check_nextcmd(ea.cmd)) != NULL) | |
7 | 1807 { |
1808 /* | |
1809 * strange vi behaviour: | |
1810 * ":3" jumps to line 3 | |
1811 * ":3|..." prints line 3 | |
1812 * ":|" prints current line | |
1813 */ | |
1814 if (ea.skip) /* skip this if inside :if */ | |
1815 goto doend; | |
167 | 1816 if (*ea.cmd == '|' || (exmode_active && ea.line1 != ea.line2)) |
7 | 1817 { |
1818 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
|
1819 ea.argt = EX_RANGE+EX_COUNT+EX_TRLBAR; |
7 | 1820 if ((errormsg = invalid_range(&ea)) == NULL) |
1821 { | |
1822 correct_range(&ea); | |
1823 ex_print(&ea); | |
1824 } | |
1825 } | |
1826 else if (ea.addr_count != 0) | |
1827 { | |
631 | 1828 if (ea.line2 > curbuf->b_ml.ml_line_count) |
1829 { | |
1830 /* With '-' in 'cpoptions' a line number past the file is an | |
1831 * error, otherwise put it at the end of the file. */ | |
1832 if (vim_strchr(p_cpo, CPO_MINUS) != NULL) | |
1833 ea.line2 = -1; | |
1834 else | |
1835 ea.line2 = curbuf->b_ml.ml_line_count; | |
1836 } | |
1837 | |
1838 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
|
1839 errormsg = _(e_invrange); |
7 | 1840 else |
1841 { | |
1842 if (ea.line2 == 0) | |
1843 curwin->w_cursor.lnum = 1; | |
1844 else | |
1845 curwin->w_cursor.lnum = ea.line2; | |
1846 beginline(BL_SOL | BL_FIX); | |
1847 } | |
1848 } | |
1849 goto doend; | |
1850 } | |
1851 | |
6154 | 1852 /* If this looks like an undefined user command and there are CmdUndefined |
1853 * autocommands defined, trigger the matching autocommands. */ | |
1854 if (p != NULL && ea.cmdidx == CMD_SIZE && !ea.skip | |
1855 && ASCII_ISUPPER(*ea.cmd) | |
1856 && has_cmdundefined()) | |
1857 { | |
1858 int ret; | |
1859 | |
6156 | 1860 p = ea.cmd; |
6154 | 1861 while (ASCII_ISALNUM(*p)) |
1862 ++p; | |
6191 | 1863 p = vim_strnsave(ea.cmd, (int)(p - ea.cmd)); |
6154 | 1864 ret = apply_autocmds(EVENT_CMDUNDEFINED, p, p, TRUE, NULL); |
1865 vim_free(p); | |
6965 | 1866 /* If the autocommands did something and didn't cause an error, try |
1867 * finding the command again. */ | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
1868 p = (ret |
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
1869 #ifdef FEAT_EVAL |
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
1870 && !aborting() |
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
1871 #endif |
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
1872 ) ? find_command(&ea, NULL) : ea.cmd; |
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
1873 } |
6154 | 1874 |
7 | 1875 if (p == NULL) |
1876 { | |
1877 if (!ea.skip) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
1878 errormsg = _("E464: Ambiguous use of user-defined command"); |
7 | 1879 goto doend; |
1880 } | |
16411
5b5c5daf57de
patch 8.1.1210: support for user commands is spread out
Bram Moolenaar <Bram@vim.org>
parents:
16399
diff
changeset
|
1881 // 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
|
1882 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
|
1883 && !IS_USER_CMDIDX(ea.cmdidx)) |
7 | 1884 { |
1885 errormsg = uc_fun_cmd(); | |
1886 goto doend; | |
1887 } | |
16411
5b5c5daf57de
patch 8.1.1210: support for user commands is spread out
Bram Moolenaar <Bram@vim.org>
parents:
16399
diff
changeset
|
1888 |
7 | 1889 if (ea.cmdidx == CMD_SIZE) |
1890 { | |
1891 if (!ea.skip) | |
1892 { | |
1893 STRCPY(IObuff, _("E492: Not an editor command")); | |
1894 if (!sourcing) | |
9941
e975914c17e9
commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
9927
diff
changeset
|
1895 { |
e975914c17e9
commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
9927
diff
changeset
|
1896 /* If the modifier was parsed OK the error must be in the |
e975914c17e9
commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
9927
diff
changeset
|
1897 * following command */ |
e975914c17e9
commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
9927
diff
changeset
|
1898 if (after_modifier != NULL) |
e975914c17e9
commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
9927
diff
changeset
|
1899 append_command(after_modifier); |
e975914c17e9
commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
9927
diff
changeset
|
1900 else |
e975914c17e9
commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
9927
diff
changeset
|
1901 append_command(*cmdlinep); |
e975914c17e9
commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
9927
diff
changeset
|
1902 } |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
1903 errormsg = (char *)IObuff; |
3757 | 1904 did_emsg_syntax = TRUE; |
7 | 1905 } |
1906 goto doend; | |
1907 } | |
1908 | |
6305 | 1909 ni = (!IS_USER_CMDIDX(ea.cmdidx) |
1910 && (cmdnames[ea.cmdidx].cmd_func == ex_ni | |
1315 | 1911 #ifdef HAVE_EX_SCRIPT_NI |
1912 || cmdnames[ea.cmdidx].cmd_func == ex_script_ni | |
1913 #endif | |
1914 )); | |
7 | 1915 |
1916 #ifndef FEAT_EVAL | |
1917 /* | |
1918 * When the expression evaluation is disabled, recognize the ":if" and | |
1919 * ":endif" commands and ignore everything in between it. | |
1920 */ | |
1921 if (ea.cmdidx == CMD_if) | |
1922 ++if_level; | |
1923 if (if_level) | |
1924 { | |
1925 if (ea.cmdidx == CMD_endif) | |
1926 --if_level; | |
1927 goto doend; | |
1928 } | |
1929 | |
1930 #endif | |
1931 | |
1613 | 1932 /* forced commands */ |
1933 if (*p == '!' && ea.cmdidx != CMD_substitute | |
1934 && ea.cmdidx != CMD_smagic && ea.cmdidx != CMD_snomagic) | |
7 | 1935 { |
1936 ++p; | |
1937 ea.forceit = TRUE; | |
1938 } | |
1939 else | |
1940 ea.forceit = FALSE; | |
1941 | |
1942 /* | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
1943 * 6. Parse arguments. Then check for errors. |
7 | 1944 */ |
6305 | 1945 if (!IS_USER_CMDIDX(ea.cmdidx)) |
835 | 1946 ea.argt = (long)cmdnames[(int)ea.cmdidx].cmd_argt; |
7 | 1947 |
1948 if (!ea.skip) | |
1949 { | |
1950 #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
|
1951 if (sandbox != 0 && !(ea.argt & EX_SBOXOK)) |
7 | 1952 { |
15748
93b78c4a7cd5
patch 8.1.0881: can execute shell commands in rvim through interfaces
Bram Moolenaar <Bram@vim.org>
parents:
15713
diff
changeset
|
1953 // 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
|
1954 errormsg = _(e_sandbox); |
7 | 1955 goto doend; |
1956 } | |
1957 #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
|
1958 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
|
1959 { |
93b78c4a7cd5
patch 8.1.0881: can execute shell commands in rvim through interfaces
Bram Moolenaar <Bram@vim.org>
parents:
15713
diff
changeset
|
1960 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
|
1961 goto doend; |
93b78c4a7cd5
patch 8.1.0881: can execute shell commands in rvim through interfaces
Bram Moolenaar <Bram@vim.org>
parents:
15713
diff
changeset
|
1962 } |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
1963 if (!curbuf->b_p_ma && (ea.argt & EX_MODIFY)) |
7 | 1964 { |
1965 /* 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
|
1966 errormsg = _(e_modifiable); |
7 | 1967 goto doend; |
1968 } | |
631 | 1969 |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
1970 if (text_locked() && !(ea.argt & EX_CMDWIN) |
6305 | 1971 && !IS_USER_CMDIDX(ea.cmdidx)) |
7 | 1972 { |
631 | 1973 /* 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
|
1974 errormsg = _(get_text_locked_msg()); |
7 | 1975 goto doend; |
1976 } | |
14648
c3222a7342ab
patch 8.1.0337: :file fails in quickfix command
Christian Brabandt <cb@256bit.org>
parents:
14640
diff
changeset
|
1977 |
822 | 1978 /* Disallow editing another buffer when "curbuf_lock" is set. |
14648
c3222a7342ab
patch 8.1.0337: :file fails in quickfix command
Christian Brabandt <cb@256bit.org>
parents:
14640
diff
changeset
|
1979 * Do allow ":checktime" (it is postponed). |
c3222a7342ab
patch 8.1.0337: :file fails in quickfix command
Christian Brabandt <cb@256bit.org>
parents:
14640
diff
changeset
|
1980 * Do allow ":edit" (check for an argument later). |
c3222a7342ab
patch 8.1.0337: :file fails in quickfix command
Christian Brabandt <cb@256bit.org>
parents:
14640
diff
changeset
|
1981 * 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
|
1982 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
|
1983 && ea.cmdidx != CMD_checktime |
822 | 1984 && ea.cmdidx != CMD_edit |
14648
c3222a7342ab
patch 8.1.0337: :file fails in quickfix command
Christian Brabandt <cb@256bit.org>
parents:
14640
diff
changeset
|
1985 && ea.cmdidx != CMD_file |
6305 | 1986 && !IS_USER_CMDIDX(ea.cmdidx) |
819 | 1987 && curbuf_locked()) |
1988 goto doend; | |
7 | 1989 |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
1990 if (!ni && !(ea.argt & EX_RANGE) && ea.addr_count > 0) |
7 | 1991 { |
1992 /* no range allowed */ | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
1993 errormsg = _(e_norange); |
7 | 1994 goto doend; |
1995 } | |
1996 } | |
1997 | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
1998 if (!ni && !(ea.argt & EX_BANG) && ea.forceit) // no <!> allowed |
7 | 1999 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2000 errormsg = _(e_nobang); |
7 | 2001 goto doend; |
2002 } | |
2003 | |
2004 /* | |
2005 * Don't complain about the range if it is not used | |
2006 * (could happen if line_count is accidentally set to 0). | |
2007 */ | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2008 if (!ea.skip && !ni && (ea.argt & EX_RANGE)) |
7 | 2009 { |
2010 /* | |
2011 * If the range is backwards, ask for confirmation and, if given, swap | |
2012 * ea.line1 & ea.line2 so it's forwards again. | |
2013 * When global command is busy, don't ask, will fail below. | |
2014 */ | |
2015 if (!global_busy && ea.line1 > ea.line2) | |
2016 { | |
557 | 2017 if (msg_silent == 0) |
2018 { | |
2019 if (sourcing || exmode_active) | |
2020 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2021 errormsg = _("E493: Backwards range given"); |
557 | 2022 goto doend; |
2023 } | |
7 | 2024 if (ask_yesno((char_u *) |
2025 _("Backwards range given, OK to swap"), FALSE) != 'y') | |
557 | 2026 goto doend; |
7 | 2027 } |
2028 lnum = ea.line1; | |
2029 ea.line1 = ea.line2; | |
2030 ea.line2 = lnum; | |
2031 } | |
2032 if ((errormsg = invalid_range(&ea)) != NULL) | |
2033 goto doend; | |
2034 } | |
2035 | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
2036 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
|
2037 // default is 1, not cursor |
7 | 2038 ea.line2 = 1; |
2039 | |
2040 correct_range(&ea); | |
2041 | |
2042 #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
|
2043 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
|
2044 && ea.addr_type == ADDR_LINES) |
7 | 2045 { |
2046 /* Put the first line at the start of a closed fold, put the last line | |
2047 * at the end of a closed fold. */ | |
2048 (void)hasFolding(ea.line1, &ea.line1, NULL); | |
2049 (void)hasFolding(ea.line2, NULL, &ea.line2); | |
2050 } | |
2051 #endif | |
2052 | |
2053 #ifdef FEAT_QUICKFIX | |
2054 /* | |
41 | 2055 * For the ":make" and ":grep" commands we insert the 'makeprg'/'grepprg' |
7 | 2056 * option here, so things like % get expanded. |
2057 */ | |
344 | 2058 p = replace_makeprg(&ea, p, cmdlinep); |
2059 if (p == NULL) | |
2060 goto doend; | |
7 | 2061 #endif |
2062 | |
2063 /* | |
2064 * Skip to start of argument. | |
2065 * Don't do this for the ":!" command, because ":!! -l" needs the space. | |
2066 */ | |
2067 if (ea.cmdidx == CMD_bang) | |
2068 ea.arg = p; | |
2069 else | |
2070 ea.arg = skipwhite(p); | |
2071 | |
14648
c3222a7342ab
patch 8.1.0337: :file fails in quickfix command
Christian Brabandt <cb@256bit.org>
parents:
14640
diff
changeset
|
2072 // ":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
|
2073 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
|
2074 goto doend; |
c3222a7342ab
patch 8.1.0337: :file fails in quickfix command
Christian Brabandt <cb@256bit.org>
parents:
14640
diff
changeset
|
2075 |
7 | 2076 /* |
2077 * Check for "++opt=val" argument. | |
2078 * Must be first, allow ":w ++enc=utf8 !cmd" | |
2079 */ | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2080 if (ea.argt & EX_ARGOPT) |
7 | 2081 while (ea.arg[0] == '+' && ea.arg[1] == '+') |
2082 if (getargopt(&ea) == FAIL && !ni) | |
2083 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2084 errormsg = _(e_invarg); |
7 | 2085 goto doend; |
2086 } | |
2087 | |
2088 if (ea.cmdidx == CMD_write || ea.cmdidx == CMD_update) | |
2089 { | |
2090 if (*ea.arg == '>') /* append */ | |
2091 { | |
2092 if (*++ea.arg != '>') /* typed wrong */ | |
2093 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2094 errormsg = _("E494: Use w or w>>"); |
7 | 2095 goto doend; |
2096 } | |
2097 ea.arg = skipwhite(ea.arg + 1); | |
2098 ea.append = TRUE; | |
2099 } | |
2100 else if (*ea.arg == '!' && ea.cmdidx == CMD_write) /* :w !filter */ | |
2101 { | |
2102 ++ea.arg; | |
2103 ea.usefilter = TRUE; | |
2104 } | |
2105 } | |
2106 | |
2107 if (ea.cmdidx == CMD_read) | |
2108 { | |
2109 if (ea.forceit) | |
2110 { | |
2111 ea.usefilter = TRUE; /* :r! filter if ea.forceit */ | |
2112 ea.forceit = FALSE; | |
2113 } | |
2114 else if (*ea.arg == '!') /* :r !filter */ | |
2115 { | |
2116 ++ea.arg; | |
2117 ea.usefilter = TRUE; | |
2118 } | |
2119 } | |
2120 | |
2121 if (ea.cmdidx == CMD_lshift || ea.cmdidx == CMD_rshift) | |
2122 { | |
2123 ea.amount = 1; | |
2124 while (*ea.arg == *ea.cmd) /* count number of '>' or '<' */ | |
2125 { | |
2126 ++ea.arg; | |
2127 ++ea.amount; | |
2128 } | |
2129 ea.arg = skipwhite(ea.arg); | |
2130 } | |
2131 | |
2132 /* | |
2133 * Check for "+command" argument, before checking for next command. | |
2134 * Don't do this for ":read !cmd" and ":write !cmd". | |
2135 */ | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2136 if ((ea.argt & EX_CMDARG) && !ea.usefilter) |
7 | 2137 ea.do_ecmd_cmd = getargcmd(&ea.arg); |
2138 | |
2139 /* | |
2140 * Check for '|' to separate commands and '"' to start comments. | |
2141 * Don't do this for ":read !cmd" and ":write !cmd". | |
2142 */ | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2143 if ((ea.argt & EX_TRLBAR) && !ea.usefilter) |
7 | 2144 separate_nextcmd(&ea); |
2145 | |
2146 /* | |
2147 * Check for <newline> to end a shell command. | |
167 | 2148 * Also do this for ":read !cmd", ":write !cmd" and ":global". |
2149 * Any others? | |
7 | 2150 */ |
167 | 2151 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
|
2152 || ea.cmdidx == CMD_terminal |
167 | 2153 || ea.cmdidx == CMD_global |
2154 || ea.cmdidx == CMD_vglobal | |
2155 || ea.usefilter) | |
7 | 2156 { |
2157 for (p = ea.arg; *p; ++p) | |
2158 { | |
2159 /* Remove one backslash before a newline, so that it's possible to | |
2160 * pass a newline to the shell and also a newline that is preceded | |
2161 * with a backslash. This makes it impossible to end a shell | |
2162 * command in a backslash, but that doesn't appear useful. | |
2163 * Halving the number of backslashes is incompatible with previous | |
2164 * versions. */ | |
2165 if (*p == '\\' && p[1] == '\n') | |
1619 | 2166 STRMOVE(p, p + 1); |
7 | 2167 else if (*p == '\n') |
2168 { | |
2169 ea.nextcmd = p + 1; | |
2170 *p = NUL; | |
2171 break; | |
2172 } | |
2173 } | |
2174 } | |
2175 | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2176 if ((ea.argt & EX_DFLALL) && ea.addr_count == 0) |
7 | 2177 { |
6424 | 2178 buf_T *buf; |
2179 | |
7 | 2180 ea.line1 = 1; |
6424 | 2181 switch (ea.addr_type) |
2182 { | |
2183 case ADDR_LINES: | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
2184 case ADDR_OTHER: |
6424 | 2185 ea.line2 = curbuf->b_ml.ml_line_count; |
2186 break; | |
2187 case ADDR_LOADED_BUFFERS: | |
2188 buf = firstbuf; | |
2189 while (buf->b_next != NULL && buf->b_ml.ml_mfp == NULL) | |
2190 buf = buf->b_next; | |
2191 ea.line1 = buf->b_fnum; | |
2192 buf = lastbuf; | |
2193 while (buf->b_prev != NULL && buf->b_ml.ml_mfp == NULL) | |
2194 buf = buf->b_prev; | |
2195 ea.line2 = buf->b_fnum; | |
2196 break; | |
2197 case ADDR_BUFFERS: | |
2198 ea.line1 = firstbuf->b_fnum; | |
2199 ea.line2 = lastbuf->b_fnum; | |
2200 break; | |
2201 case ADDR_WINDOWS: | |
2202 ea.line2 = LAST_WIN_NR; | |
2203 break; | |
2204 case ADDR_TABS: | |
2205 ea.line2 = LAST_TAB_NR; | |
2206 break; | |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
2207 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
|
2208 ea.line2 = 1; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
2209 break; |
6424 | 2210 case ADDR_ARGUMENTS: |
2211 if (ARGCOUNT == 0) | |
2212 ea.line1 = ea.line2 = 0; | |
2213 else | |
2214 ea.line2 = ARGCOUNT; | |
2215 break; | |
16515
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
2216 case ADDR_QUICKFIX_VALID: |
7105
f4456e686406
commit https://github.com/vim/vim/commit/e906c502079770ae0e0071c74cefb802689ff193
Christian Brabandt <cb@256bit.org>
parents:
7092
diff
changeset
|
2217 #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
|
2218 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
|
2219 if (ea.line2 == 0) |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
2220 ea.line2 = 1; |
16479
7dcf301d1432
patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents:
16475
diff
changeset
|
2221 #endif |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
2222 break; |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
2223 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
|
2224 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
|
2225 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
|
2226 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
|
2227 break; |
6424 | 2228 } |
7 | 2229 } |
2230 | |
2231 /* 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
|
2232 if ( (ea.argt & EX_REGSTR) |
7 | 2233 && *ea.arg != NUL |
6305 | 2234 /* Do not allow register = for user commands */ |
2235 && (!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
|
2236 && !((ea.argt & EX_COUNT) && VIM_ISDIGIT(*ea.arg))) |
7 | 2237 { |
2791 | 2238 #ifndef FEAT_CLIPBOARD |
2239 /* check these explicitly for a more specific error message */ | |
2240 if (*ea.arg == '*' || *ea.arg == '+') | |
2241 { | |
15474
79e3dcc5aa50
patch 8.1.0745: compiler warnings for signed/unsigned string
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
2242 errormsg = _(e_invalidreg); |
2791 | 2243 goto doend; |
2244 } | |
2245 #endif | |
6305 | 2246 if (valid_yank_reg(*ea.arg, (ea.cmdidx != CMD_put |
2247 && !IS_USER_CMDIDX(ea.cmdidx)))) | |
2791 | 2248 { |
2249 ea.regname = *ea.arg++; | |
7 | 2250 #ifdef FEAT_EVAL |
2791 | 2251 /* for '=' register: accept the rest of the line as an expression */ |
2252 if (ea.arg[-1] == '=' && ea.arg[0] != NUL) | |
2253 { | |
2254 set_expr_line(vim_strsave(ea.arg)); | |
2255 ea.arg += STRLEN(ea.arg); | |
2256 } | |
2257 #endif | |
2258 ea.arg = skipwhite(ea.arg); | |
2259 } | |
7 | 2260 } |
2261 | |
2262 /* | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2263 * Check for a count. When accepting a EX_BUFNAME, don't use "123foo" as a |
7 | 2264 * count, it's a buffer name. |
2265 */ | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2266 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
|
2267 && (!(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
|
2268 || VIM_ISWHITE(*p))) |
7 | 2269 { |
2270 n = getdigits(&ea.arg); | |
2271 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
|
2272 if (n <= 0 && !ni && (ea.argt & EX_ZEROR) == 0) |
7 | 2273 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2274 errormsg = _(e_zerocount); |
7 | 2275 goto doend; |
2276 } | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
2277 if (ea.addr_type != ADDR_LINES) // e.g. :buffer 2, :sleep 3 |
7 | 2278 { |
2279 ea.line2 = n; | |
2280 if (ea.addr_count == 0) | |
2281 ea.addr_count = 1; | |
2282 } | |
2283 else | |
2284 { | |
2285 ea.line1 = ea.line2; | |
2286 ea.line2 += n - 1; | |
2287 ++ea.addr_count; | |
2288 /* | |
2289 * Be vi compatible: no error message for out of range. | |
2290 */ | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
2291 if (ea.line2 > curbuf->b_ml.ml_line_count) |
7 | 2292 ea.line2 = curbuf->b_ml.ml_line_count; |
2293 } | |
2294 } | |
167 | 2295 |
2296 /* | |
2297 * Check for flags: 'l', 'p' and '#'. | |
2298 */ | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2299 if (ea.argt & EX_FLAGS) |
167 | 2300 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
|
2301 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
|
2302 && *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
|
2303 { |
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2304 // 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
|
2305 errormsg = _(e_trailing); |
7 | 2306 goto doend; |
2307 } | |
2308 | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2309 if (!ni && (ea.argt & EX_NEEDARG) && *ea.arg == NUL) |
7 | 2310 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2311 errormsg = _(e_argreq); |
7 | 2312 goto doend; |
2313 } | |
2314 | |
2315 #ifdef FEAT_EVAL | |
2316 /* | |
2317 * Skip the command when it's not going to be executed. | |
2318 * The commands like :if, :endif, etc. always need to be executed. | |
2319 * Also make an exception for commands that handle a trailing command | |
2320 * themselves. | |
2321 */ | |
2322 if (ea.skip) | |
2323 { | |
2324 switch (ea.cmdidx) | |
2325 { | |
2326 /* commands that need evaluation */ | |
2327 case CMD_while: | |
2328 case CMD_endwhile: | |
72 | 2329 case CMD_for: |
2330 case CMD_endfor: | |
7 | 2331 case CMD_if: |
2332 case CMD_elseif: | |
2333 case CMD_else: | |
2334 case CMD_endif: | |
2335 case CMD_try: | |
2336 case CMD_catch: | |
2337 case CMD_finally: | |
2338 case CMD_endtry: | |
2339 case CMD_function: | |
2340 break; | |
2341 | |
2342 /* Commands that handle '|' themselves. Check: A command should | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2343 * either have the EX_TRLBAR flag, appear in this list or appear in |
7 | 2344 * the list at ":help :bar". */ |
2345 case CMD_aboveleft: | |
2346 case CMD_and: | |
2347 case CMD_belowright: | |
2348 case CMD_botright: | |
2349 case CMD_browse: | |
2350 case CMD_call: | |
2351 case CMD_confirm: | |
2352 case CMD_delfunction: | |
2353 case CMD_djump: | |
2354 case CMD_dlist: | |
2355 case CMD_dsearch: | |
2356 case CMD_dsplit: | |
2357 case CMD_echo: | |
2358 case CMD_echoerr: | |
2359 case CMD_echomsg: | |
2360 case CMD_echon: | |
2361 case CMD_execute: | |
9941
e975914c17e9
commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
9927
diff
changeset
|
2362 case CMD_filter: |
7 | 2363 case CMD_help: |
2364 case CMD_hide: | |
2365 case CMD_ijump: | |
2366 case CMD_ilist: | |
2367 case CMD_isearch: | |
2368 case CMD_isplit: | |
22 | 2369 case CMD_keepalt: |
7 | 2370 case CMD_keepjumps: |
2371 case CMD_keepmarks: | |
5467 | 2372 case CMD_keeppatterns: |
7 | 2373 case CMD_leftabove: |
2374 case CMD_let: | |
2375 case CMD_lockmarks: | |
2320
966a5609669e
Added Lua interfae. (Luis Carvalho)
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
2376 case CMD_lua: |
7 | 2377 case CMD_match: |
14 | 2378 case CMD_mzscheme: |
5737 | 2379 case CMD_noautocmd: |
2380 case CMD_noswapfile: | |
7 | 2381 case CMD_perl: |
2382 case CMD_psearch: | |
2383 case CMD_python: | |
2350
06feaf4fe36a
Rename some "python3" symbols to "py3", as the command name.
Bram Moolenaar <bram@vim.org>
parents:
2340
diff
changeset
|
2384 case CMD_py3: |
2366
7a57fe6a5157
Fix that :py3file was not working.
Bram Moolenaar <bram@vim.org>
parents:
2360
diff
changeset
|
2385 case CMD_python3: |
7 | 2386 case CMD_return: |
2387 case CMD_rightbelow: | |
2388 case CMD_ruby: | |
2389 case CMD_silent: | |
2390 case CMD_smagic: | |
2391 case CMD_snomagic: | |
2392 case CMD_substitute: | |
2393 case CMD_syntax: | |
690 | 2394 case CMD_tab: |
7 | 2395 case CMD_tcl: |
2396 case CMD_throw: | |
2397 case CMD_tilde: | |
2398 case CMD_topleft: | |
2399 case CMD_unlet: | |
2400 case CMD_verbose: | |
2401 case CMD_vertical: | |
2887 | 2402 case CMD_wincmd: |
7 | 2403 break; |
2404 | |
2405 default: goto doend; | |
2406 } | |
2407 } | |
2408 #endif | |
2409 | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2410 if (ea.argt & EX_XFILE) |
7 | 2411 { |
2412 if (expand_filename(&ea, cmdlinep, &errormsg) == FAIL) | |
2413 goto doend; | |
2414 } | |
2415 | |
2416 /* | |
2417 * Accept buffer name. Cannot be used at the same time with a buffer | |
2418 * number. Don't do this for a user command. | |
2419 */ | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2420 if ((ea.argt & EX_BUFNAME) && *ea.arg != NUL && ea.addr_count == 0 |
6305 | 2421 && !IS_USER_CMDIDX(ea.cmdidx)) |
7 | 2422 { |
2423 /* | |
2424 * :bdelete, :bwipeout and :bunload take several arguments, separated | |
2425 * by spaces: find next space (skipping over escaped characters). | |
2426 * The others take one argument: ignore trailing spaces. | |
2427 */ | |
2428 if (ea.cmdidx == CMD_bdelete || ea.cmdidx == CMD_bwipeout | |
2429 || ea.cmdidx == CMD_bunload) | |
2430 p = skiptowhite_esc(ea.arg); | |
2431 else | |
2432 { | |
2433 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
|
2434 while (p > ea.arg && VIM_ISWHITE(p[-1])) |
7 | 2435 --p; |
2436 } | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2437 ea.line2 = buflist_findpat(ea.arg, p, (ea.argt & EX_BUFUNL) != 0, |
4236 | 2438 FALSE, FALSE); |
7 | 2439 if (ea.line2 < 0) /* failed */ |
2440 goto doend; | |
2441 ea.addr_count = 1; | |
2442 ea.arg = skipwhite(p); | |
2443 } | |
2444 | |
13288
530943a23d3f
patch 8.0.1518: error messages suppressed after ":silent! try"
Christian Brabandt <cb@256bit.org>
parents:
13268
diff
changeset
|
2445 /* The :try command saves the emsg_silent flag, reset it here when |
530943a23d3f
patch 8.0.1518: error messages suppressed after ":silent! try"
Christian Brabandt <cb@256bit.org>
parents:
13268
diff
changeset
|
2446 * ":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
|
2447 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
|
2448 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2449 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
|
2450 if (emsg_silent < 0) |
530943a23d3f
patch 8.0.1518: error messages suppressed after ":silent! try"
Christian Brabandt <cb@256bit.org>
parents:
13268
diff
changeset
|
2451 emsg_silent = 0; |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2452 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
|
2453 } |
530943a23d3f
patch 8.0.1518: error messages suppressed after ":silent! try"
Christian Brabandt <cb@256bit.org>
parents:
13268
diff
changeset
|
2454 |
530943a23d3f
patch 8.0.1518: error messages suppressed after ":silent! try"
Christian Brabandt <cb@256bit.org>
parents:
13268
diff
changeset
|
2455 /* |
530943a23d3f
patch 8.0.1518: error messages suppressed after ":silent! try"
Christian Brabandt <cb@256bit.org>
parents:
13268
diff
changeset
|
2456 * 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
|
2457 */ |
7 | 2458 |
6305 | 2459 if (IS_USER_CMDIDX(ea.cmdidx)) |
7 | 2460 { |
2461 /* | |
2462 * Execute a user-defined command. | |
2463 */ | |
2464 do_ucmd(&ea); | |
2465 } | |
2466 else | |
2467 { | |
2468 /* | |
16411
5b5c5daf57de
patch 8.1.1210: support for user commands is spread out
Bram Moolenaar <Bram@vim.org>
parents:
16399
diff
changeset
|
2469 * Call the function to execute the builtin command. |
7 | 2470 */ |
2471 ea.errmsg = NULL; | |
2472 (cmdnames[ea.cmdidx].cmd_func)(&ea); | |
2473 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
|
2474 errormsg = _(ea.errmsg); |
7 | 2475 } |
2476 | |
2477 #ifdef FEAT_EVAL | |
2478 /* | |
2479 * If the command just executed called do_cmdline(), any throw or ":return" | |
2480 * or ":finish" encountered there must also check the cstack of the still | |
2481 * active do_cmdline() that called this do_one_cmd(). Rethrow an uncaught | |
2482 * exception, or reanimate a returned function or finished script file and | |
2483 * return or finish it again. | |
2484 */ | |
2485 if (need_rethrow) | |
2486 do_throw(cstack); | |
2487 else if (check_cstack) | |
2488 { | |
944 | 2489 if (source_finished(fgetline, cookie)) |
7 | 2490 do_finish(&ea, TRUE); |
944 | 2491 else if (getline_equal(fgetline, cookie, get_func_line) |
7 | 2492 && current_func_returned()) |
2493 do_return(&ea, TRUE, FALSE, NULL); | |
2494 } | |
2495 need_rethrow = check_cstack = FALSE; | |
2496 #endif | |
2497 | |
2498 doend: | |
2499 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
|
2500 { |
7 | 2501 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
|
2502 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
|
2503 } |
7 | 2504 |
2505 if (errormsg != NULL && *errormsg != NUL && !did_emsg) | |
2506 { | |
2507 if (sourcing) | |
2508 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2509 if (errormsg != (char *)IObuff) |
7 | 2510 { |
2511 STRCPY(IObuff, errormsg); | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2512 errormsg = (char *)IObuff; |
7 | 2513 } |
3097 | 2514 append_command(*cmdlinep); |
7 | 2515 } |
2516 emsg(errormsg); | |
2517 } | |
2518 #ifdef FEAT_EVAL | |
2519 do_errthrow(cstack, | |
6305 | 2520 (ea.cmdidx != CMD_SIZE && !IS_USER_CMDIDX(ea.cmdidx)) |
2521 ? cmdnames[(int)ea.cmdidx].cmd_name : (char_u *)NULL); | |
7 | 2522 #endif |
2523 | |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2524 if (ea.verbose_save >= 0) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2525 p_verbose = ea.verbose_save; |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
2526 |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2527 free_cmdmod(); |
7 | 2528 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
|
2529 reg_executing = save_reg_executing; |
7 | 2530 |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2531 if (ea.save_msg_silent != -1) |
7 | 2532 { |
2533 /* messages could be enabled for a serious error, need to check if the | |
2534 * counters don't become negative */ | |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2535 if (!did_emsg || msg_silent > ea.save_msg_silent) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2536 msg_silent = ea.save_msg_silent; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2537 emsg_silent -= ea.did_esilent; |
7 | 2538 if (emsg_silent < 0) |
2539 emsg_silent = 0; | |
2540 /* Restore msg_scroll, it's set by file I/O commands, even when no | |
2541 * message is actually displayed. */ | |
2542 msg_scroll = save_msg_scroll; | |
1854 | 2543 |
2544 /* "silent reg" or "silent echo x" inside "redir" leaves msg_col | |
2545 * somewhere in the line. Put it back in the first column. */ | |
2546 if (redirecting()) | |
2547 msg_col = 0; | |
7 | 2548 } |
2549 | |
28 | 2550 #ifdef HAVE_SANDBOX |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2551 if (ea.did_sandbox) |
28 | 2552 --sandbox; |
2553 #endif | |
2554 | |
7 | 2555 if (ea.nextcmd && *ea.nextcmd == NUL) /* not really a next command */ |
2556 ea.nextcmd = NULL; | |
2557 | |
2558 #ifdef FEAT_EVAL | |
2559 --ex_nesting_level; | |
2560 #endif | |
2561 | |
2562 return ea.nextcmd; | |
2563 } | |
2564 #if (_MSC_VER == 1200) | |
128 | 2565 #pragma optimize( "", on ) |
7 | 2566 #endif |
2567 | |
2568 /* | |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2569 * 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
|
2570 * - update eap->cmd |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2571 * - store flags in "cmdmod". |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2572 * - 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
|
2573 * - 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
|
2574 * - 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
|
2575 * - 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
|
2576 * - 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
|
2577 * 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
|
2578 * "cmdmod". |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2579 * 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
|
2580 * 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
|
2581 */ |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2582 int |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2583 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
|
2584 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2585 char_u *p; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2586 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2587 vim_memset(&cmdmod, 0, sizeof(cmdmod)); |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2588 eap->verbose_save = -1; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2589 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
|
2590 |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2591 // 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
|
2592 for (;;) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2593 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2594 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
|
2595 ++eap->cmd; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2596 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2597 /* in ex mode, an empty line works like :+ */ |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2598 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
|
2599 && (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
|
2600 || 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
|
2601 && 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
|
2602 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2603 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
|
2604 if (!skip_only) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2605 ex_pressedreturn = TRUE; |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2606 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2607 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2608 /* ignore comment and empty lines */ |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2609 if (*eap->cmd == '"') |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2610 return FAIL; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2611 if (*eap->cmd == NUL) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2612 { |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2613 if (!skip_only) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2614 ex_pressedreturn = TRUE; |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2615 return FAIL; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2616 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2617 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2618 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
|
2619 switch (*p) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2620 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2621 /* When adding an entry, also modify cmd_exists(). */ |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2622 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
|
2623 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2624 cmdmod.split |= WSP_ABOVE; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2625 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2626 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2627 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
|
2628 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2629 cmdmod.split |= WSP_BELOW; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2630 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2631 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2632 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
|
2633 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2634 #ifdef FEAT_BROWSE_CMD |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2635 cmdmod.browse = TRUE; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2636 #endif |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2637 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2638 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2639 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
|
2640 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2641 cmdmod.split |= WSP_BOT; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2642 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2643 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2644 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
|
2645 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2646 #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
|
2647 cmdmod.confirm = TRUE; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2648 #endif |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2649 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2650 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2651 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
|
2652 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2653 cmdmod.keepmarks = TRUE; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2654 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2655 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2656 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
|
2657 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2658 cmdmod.keepalt = TRUE; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2659 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2660 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2661 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
|
2662 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2663 cmdmod.keeppatterns = TRUE; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2664 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2665 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2666 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
|
2667 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2668 cmdmod.keepjumps = TRUE; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2669 continue; |
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 case 'f': /* only accept ":filter {pat} cmd" */ |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2672 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2673 char_u *reg_pat; |
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 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
|
2676 || *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
|
2677 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2678 if (*p == '!') |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2679 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2680 cmdmod.filter_force = TRUE; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2681 p = skipwhite(p + 1); |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2682 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
|
2683 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2684 } |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2685 if (skip_only) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2686 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
|
2687 else |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2688 // 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
|
2689 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
|
2690 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
|
2691 break; |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2692 if (!skip_only) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2693 { |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2694 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
|
2695 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
|
2696 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
|
2697 break; |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2698 } |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2699 eap->cmd = p; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2700 continue; |
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 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2703 /* ":hide" and ":hide | cmd" are not modifiers */ |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2704 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
|
2705 || *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
|
2706 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2707 eap->cmd = p; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2708 cmdmod.hide = TRUE; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2709 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2710 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2711 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
|
2712 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2713 cmdmod.lockmarks = TRUE; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2714 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2715 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2716 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2717 if (!checkforcmd(&eap->cmd, "leftabove", 5)) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2718 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2719 cmdmod.split |= WSP_ABOVE; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2720 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2721 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2722 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
|
2723 { |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2724 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
|
2725 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2726 /* Set 'eventignore' to "all". Restore the |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2727 * existing option value later. */ |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2728 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
|
2729 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
|
2730 (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
|
2731 } |
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, "noswapfile", 3)) |
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.noswapfile = 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 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2739 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
|
2740 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2741 cmdmod.split |= WSP_BELOW; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2742 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2743 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2744 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
|
2745 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2746 #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
|
2747 if (!skip_only) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2748 { |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2749 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
|
2750 ++sandbox; |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2751 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
|
2752 } |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2753 #endif |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2754 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2755 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2756 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
|
2757 break; |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2758 if (!skip_only) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2759 { |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2760 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
|
2761 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
|
2762 ++msg_silent; |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2763 } |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2764 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
|
2765 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2766 /* ":silent!", but not "silent !cmd" */ |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2767 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
|
2768 if (!skip_only) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2769 { |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2770 ++emsg_silent; |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2771 ++eap->did_esilent; |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2772 } |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2773 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2774 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2775 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2776 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
|
2777 { |
15263
ad065b8123e8
patch 8.1.0640: get E14 while typing command :tab with 'incsearch' set
Bram Moolenaar <Bram@vim.org>
parents:
15239
diff
changeset
|
2778 if (!skip_only) |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2779 { |
15263
ad065b8123e8
patch 8.1.0640: get E14 while typing command :tab with 'incsearch' set
Bram Moolenaar <Bram@vim.org>
parents:
15239
diff
changeset
|
2780 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
|
2781 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
|
2782 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
|
2783 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
|
2784 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
|
2785 else |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2786 { |
15263
ad065b8123e8
patch 8.1.0640: get E14 while typing command :tab with 'incsearch' set
Bram Moolenaar <Bram@vim.org>
parents:
15239
diff
changeset
|
2787 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
|
2788 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2789 *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
|
2790 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
|
2791 } |
ad065b8123e8
patch 8.1.0640: get E14 while typing command :tab with 'incsearch' set
Bram Moolenaar <Bram@vim.org>
parents:
15239
diff
changeset
|
2792 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
|
2793 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2794 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2795 eap->cmd = p; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2796 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2797 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2798 if (!checkforcmd(&eap->cmd, "topleft", 2)) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2799 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2800 cmdmod.split |= WSP_TOP; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2801 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2802 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2803 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
|
2804 break; |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2805 if (!skip_only) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2806 { |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2807 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
|
2808 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
|
2809 msg_silent = 0; |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2810 } |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2811 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2812 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2813 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
|
2814 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2815 cmdmod.split |= WSP_VERT; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2816 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2817 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2818 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
|
2819 break; |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2820 if (!skip_only) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2821 { |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2822 if (eap->verbose_save < 0) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2823 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
|
2824 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
|
2825 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
|
2826 else |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2827 p_verbose = 1; |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2828 } |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2829 eap->cmd = p; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2830 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2831 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2832 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2833 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2834 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2835 return OK; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2836 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2837 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2838 /* |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2839 * Free contents of "cmdmod". |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2840 */ |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2841 static void |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2842 free_cmdmod(void) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2843 { |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2844 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
|
2845 { |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2846 /* Restore 'eventignore' to the value before ":noautocmd". */ |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2847 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
|
2848 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
|
2849 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
|
2850 } |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2851 |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2852 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
|
2853 vim_regfree(cmdmod.filter_regmatch.regprog); |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2854 } |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2855 |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2856 /* |
14505
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2857 * 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
|
2858 * 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
|
2859 * 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
|
2860 */ |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2861 int |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2862 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
|
2863 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2864 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
|
2865 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
|
2866 |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2867 // 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
|
2868 for (;;) |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2869 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2870 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
|
2871 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
|
2872 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2873 case ADDR_LINES: |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
2874 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
|
2875 // default is current line number |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2876 eap->line2 = curwin->w_cursor.lnum; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2877 break; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2878 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
|
2879 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
|
2880 break; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2881 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
|
2882 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
|
2883 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
|
2884 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
|
2885 break; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2886 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
|
2887 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
|
2888 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
|
2889 break; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2890 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
|
2891 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
|
2892 break; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2893 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
|
2894 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
|
2895 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
|
2896 break; |
16479
7dcf301d1432
patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents:
16475
diff
changeset
|
2897 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
|
2898 #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
|
2899 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
|
2900 #endif |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
2901 break; |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
2902 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
|
2903 #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
|
2904 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
|
2905 #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
|
2906 break; |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
2907 case ADDR_NONE: |
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
2908 // 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
|
2909 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
|
2910 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2911 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
|
2912 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
|
2913 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
|
2914 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
|
2915 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
|
2916 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
|
2917 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2918 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
|
2919 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2920 ++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
|
2921 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
|
2922 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2923 case ADDR_LINES: |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
2924 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
|
2925 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
|
2926 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
|
2927 break; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2928 case ADDR_LOADED_BUFFERS: |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2929 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2930 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
|
2931 |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2932 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
|
2933 && 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
|
2934 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
|
2935 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
|
2936 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
|
2937 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
|
2938 && 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
|
2939 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
|
2940 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
|
2941 break; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2942 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2943 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
|
2944 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
|
2945 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
|
2946 break; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2947 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
|
2948 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
|
2949 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
|
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 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
|
2952 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
|
2953 ? 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
|
2954 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2955 else |
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 // 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
|
2958 // 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
|
2959 *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
|
2960 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
|
2961 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2962 break; |
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_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
|
2964 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
|
2965 case ADDR_QUICKFIX: |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2966 *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
|
2967 return FAIL; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2968 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
|
2969 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
|
2970 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
|
2971 else |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2972 { |
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->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
|
2974 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
|
2975 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2976 break; |
16515
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
2977 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
|
2978 #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
|
2979 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
|
2980 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
|
2981 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
|
2982 eap->line2 = 1; |
16479
7dcf301d1432
patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents:
16475
diff
changeset
|
2983 #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
|
2984 break; |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
2985 case ADDR_NONE: |
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
2986 // 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
|
2987 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
|
2988 } |
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->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
|
2990 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2991 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
|
2992 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2993 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
|
2994 |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2995 // '*' - 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
|
2996 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
|
2997 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2998 *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
|
2999 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
|
3000 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3001 |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3002 ++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
|
3003 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
|
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 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
|
3006 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
|
3007 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
|
3008 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
|
3009 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
|
3010 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
|
3011 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
|
3012 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
|
3013 ++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
|
3014 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3015 } |
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 else |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3018 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
|
3019 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
|
3020 |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3021 if (*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
|
3022 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3023 if (!eap->skip) |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3024 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3025 curwin->w_cursor.lnum = eap->line2; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3026 // don't leave the cursor on an illegal line or column |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3027 check_cursor(); |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3028 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3029 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3030 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
|
3031 break; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3032 ++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
|
3033 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3034 |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3035 // 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
|
3036 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
|
3037 { |
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 = 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
|
3039 // ... 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
|
3040 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
|
3041 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
|
3042 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3043 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
|
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 |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3046 /* |
93 | 3047 * Check for an Ex command with optional tail. |
7 | 3048 * If there is a match advance "pp" to the argument and return TRUE. |
3049 */ | |
93 | 3050 int |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3051 checkforcmd( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3052 char_u **pp, /* start of command */ |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3053 char *cmd, /* name of command */ |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3054 int len) /* required length */ |
7 | 3055 { |
3056 int i; | |
3057 | |
3058 for (i = 0; cmd[i] != NUL; ++i) | |
1872 | 3059 if (((char_u *)cmd)[i] != (*pp)[i]) |
7 | 3060 break; |
3061 if (i >= len && !isalpha((*pp)[i])) | |
3062 { | |
3063 *pp = skipwhite(*pp + i); | |
3064 return TRUE; | |
3065 } | |
3066 return FALSE; | |
3067 } | |
3068 | |
3069 /* | |
3097 | 3070 * Append "cmd" to the error message in IObuff. |
3071 * Takes care of limiting the length and handling 0xa0, which would be | |
3072 * invisible otherwise. | |
3073 */ | |
3074 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3075 append_command(char_u *cmd) |
3097 | 3076 { |
3077 char_u *s = cmd; | |
3078 char_u *d; | |
3079 | |
3080 STRCAT(IObuff, ": "); | |
3081 d = IObuff + STRLEN(IObuff); | |
3082 while (*s != NUL && d - IObuff < IOSIZE - 7) | |
3083 { | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
3084 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
|
3085 { |
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
3086 s += enc_utf8 ? 2 : 1; |
3097 | 3087 STRCPY(d, "<a0>"); |
3088 d += 4; | |
3089 } | |
3090 else | |
3091 MB_COPY_CHAR(s, d); | |
3092 } | |
3093 *d = NUL; | |
3094 } | |
3095 | |
3096 /* | |
7 | 3097 * Find an Ex command by its name, either built-in or user. |
184 | 3098 * 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
|
3099 * Sets eap->cmdidx and returns a pointer to char after the command name. |
184 | 3100 * "full" is set to TRUE if the whole command name matched. |
7 | 3101 * Returns NULL for an ambiguous user command. |
3102 */ | |
3103 static char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3104 find_command(exarg_T *eap, int *full UNUSED) |
7 | 3105 { |
3106 int len; | |
3107 char_u *p; | |
167 | 3108 int i; |
7 | 3109 |
3110 /* | |
3111 * Isolate the command and search for it in the command table. | |
1441 | 3112 * Exceptions: |
7 | 3113 * - the 'k' command can directly be followed by any character. |
3114 * - the 's' command can be followed directly by 'c', 'g', 'i', 'I' or 'r' | |
6472 | 3115 * but :sre[wind] is another command, as are :scr[iptnames], |
7 | 3116 * :scs[cope], :sim[alt], :sig[ns] and :sil[ent]. |
167 | 3117 * - the "d" command can directly be followed by 'l' or 'p' flag. |
7 | 3118 */ |
3119 p = eap->cmd; | |
3120 if (*p == 'k') | |
3121 { | |
3122 eap->cmdidx = CMD_k; | |
3123 ++p; | |
3124 } | |
3125 else if (p[0] == 's' | |
6987 | 3126 && ((p[1] == 'c' && (p[2] == NUL || (p[2] != 's' && p[2] != 'r' |
3127 && (p[3] == NUL || (p[3] != 'i' && p[4] != 'p'))))) | |
7 | 3128 || p[1] == 'g' |
3129 || (p[1] == 'i' && p[2] != 'm' && p[2] != 'l' && p[2] != 'g') | |
3130 || p[1] == 'I' | |
3131 || (p[1] == 'r' && p[2] != 'e'))) | |
3132 { | |
3133 eap->cmdidx = CMD_substitute; | |
3134 ++p; | |
3135 } | |
3136 else | |
3137 { | |
3138 while (ASCII_ISALPHA(*p)) | |
3139 ++p; | |
2366
7a57fe6a5157
Fix that :py3file was not working.
Bram Moolenaar <bram@vim.org>
parents:
2360
diff
changeset
|
3140 /* for python 3.x support ":py3", ":python3", ":py3file", etc. */ |
2330 | 3141 if (eap->cmd[0] == 'p' && eap->cmd[1] == 'y') |
2366
7a57fe6a5157
Fix that :py3file was not working.
Bram Moolenaar <bram@vim.org>
parents:
2360
diff
changeset
|
3142 while (ASCII_ISALNUM(*p)) |
7a57fe6a5157
Fix that :py3file was not working.
Bram Moolenaar <bram@vim.org>
parents:
2360
diff
changeset
|
3143 ++p; |
2329
ad2889f48843
Added support for Python 3. (Roland Puntaier)
Bram Moolenaar <bram@vim.org>
parents:
2320
diff
changeset
|
3144 |
7 | 3145 /* check for non-alpha command */ |
3146 if (p == eap->cmd && vim_strchr((char_u *)"@*!=><&~#", *p) != NULL) | |
3147 ++p; | |
3148 len = (int)(p - eap->cmd); | |
167 | 3149 if (*eap->cmd == 'd' && (p[-1] == 'l' || p[-1] == 'p')) |
3150 { | |
3151 /* Check for ":dl", ":dell", etc. to ":deletel": that's | |
3152 * :delete with the 'l' flag. Same for 'p'. */ | |
3153 for (i = 0; i < len; ++i) | |
1872 | 3154 if (eap->cmd[i] != ((char_u *)"delete")[i]) |
167 | 3155 break; |
3156 if (i == len - 1) | |
3157 { | |
3158 --len; | |
3159 if (p[-1] == 'l') | |
3160 eap->flags |= EXFLAG_LIST; | |
3161 else | |
3162 eap->flags |= EXFLAG_PRINT; | |
3163 } | |
3164 } | |
7 | 3165 |
11236
62c96fee518e
patch 8.0.0504: looking up an Ex command is a bit slow
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
3166 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
|
3167 { |
11240
06307d812ca7
patch 8.0.0506: can't build with ANSI C
Christian Brabandt <cb@256bit.org>
parents:
11236
diff
changeset
|
3168 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
|
3169 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
|
3170 |
11236
62c96fee518e
patch 8.0.0504: looking up an Ex command is a bit slow
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
3171 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
|
3172 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
3173 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
|
3174 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
|
3175 } |
62c96fee518e
patch 8.0.0504: looking up an Ex command is a bit slow
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
3176 |
62c96fee518e
patch 8.0.0504: looking up an Ex command is a bit slow
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
3177 /* Use a precomputed index for fast look-up in cmdnames[] |
62c96fee518e
patch 8.0.0504: looking up an Ex command is a bit slow
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
3178 * taking into account the first 2 letters of eap->cmd. */ |
62c96fee518e
patch 8.0.0504: looking up an Ex command is a bit slow
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
3179 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
|
3180 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
|
3181 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
|
3182 } |
7 | 3183 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
|
3184 eap->cmdidx = CMD_bang; |
7 | 3185 |
3186 for ( ; (int)eap->cmdidx < (int)CMD_SIZE; | |
3187 eap->cmdidx = (cmdidx_T)((int)eap->cmdidx + 1)) | |
3188 if (STRNCMP(cmdnames[(int)eap->cmdidx].cmd_name, (char *)eap->cmd, | |
3189 (size_t)len) == 0) | |
3190 { | |
3191 #ifdef FEAT_EVAL | |
3192 if (full != NULL | |
3193 && cmdnames[(int)eap->cmdidx].cmd_name[len] == NUL) | |
3194 *full = TRUE; | |
3195 #endif | |
3196 break; | |
3197 } | |
3198 | |
16411
5b5c5daf57de
patch 8.1.1210: support for user commands is spread out
Bram Moolenaar <Bram@vim.org>
parents:
16399
diff
changeset
|
3199 // 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
|
3200 // overruled by a user defined command. |
2633 | 3201 if ((eap->cmdidx == CMD_SIZE || eap->cmdidx == CMD_Print) |
3202 && *eap->cmd >= 'A' && *eap->cmd <= 'Z') | |
7 | 3203 { |
16411
5b5c5daf57de
patch 8.1.1210: support for user commands is spread out
Bram Moolenaar <Bram@vim.org>
parents:
16399
diff
changeset
|
3204 // User defined commands may contain digits. |
7 | 3205 while (ASCII_ISALNUM(*p)) |
3206 ++p; | |
184 | 3207 p = find_ucmd(eap, p, full, NULL, NULL); |
3208 } | |
3209 if (p == eap->cmd) | |
7 | 3210 eap->cmdidx = CMD_SIZE; |
3211 } | |
3212 | |
3213 return p; | |
3214 } | |
3215 | |
3216 #if defined(FEAT_EVAL) || defined(PROTO) | |
1447 | 3217 static struct cmdmod |
3218 { | |
3219 char *name; | |
3220 int minlen; | |
3221 int has_count; /* :123verbose :3tab */ | |
3222 } cmdmods[] = { | |
3223 {"aboveleft", 3, FALSE}, | |
3224 {"belowright", 3, FALSE}, | |
3225 {"botright", 2, FALSE}, | |
3226 {"browse", 3, FALSE}, | |
3227 {"confirm", 4, FALSE}, | |
9941
e975914c17e9
commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
9927
diff
changeset
|
3228 {"filter", 4, FALSE}, |
1447 | 3229 {"hide", 3, FALSE}, |
3230 {"keepalt", 5, FALSE}, | |
3231 {"keepjumps", 5, FALSE}, | |
3232 {"keepmarks", 3, FALSE}, | |
5467 | 3233 {"keeppatterns", 5, FALSE}, |
1447 | 3234 {"leftabove", 5, FALSE}, |
3235 {"lockmarks", 3, FALSE}, | |
1721 | 3236 {"noautocmd", 3, FALSE}, |
5737 | 3237 {"noswapfile", 3, FALSE}, |
1447 | 3238 {"rightbelow", 6, FALSE}, |
3239 {"sandbox", 3, FALSE}, | |
3240 {"silent", 3, FALSE}, | |
3241 {"tab", 3, TRUE}, | |
3242 {"topleft", 2, FALSE}, | |
1926 | 3243 {"unsilent", 3, FALSE}, |
1447 | 3244 {"verbose", 4, TRUE}, |
3245 {"vertical", 4, FALSE}, | |
3246 }; | |
3247 | |
3248 /* | |
3249 * Return length of a command modifier (including optional count). | |
3250 * Return zero when it's not a modifier. | |
3251 */ | |
3252 int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3253 modifier_len(char_u *cmd) |
1447 | 3254 { |
3255 int i, j; | |
3256 char_u *p = cmd; | |
3257 | |
3258 if (VIM_ISDIGIT(*cmd)) | |
3259 p = skipwhite(skipdigits(cmd)); | |
1880 | 3260 for (i = 0; i < (int)(sizeof(cmdmods) / sizeof(struct cmdmod)); ++i) |
1447 | 3261 { |
3262 for (j = 0; p[j] != NUL; ++j) | |
3263 if (p[j] != cmdmods[i].name[j]) | |
3264 break; | |
4857
84a8d1ba81c3
updated for version 7.3.1175
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3265 if (!ASCII_ISALPHA(p[j]) && j >= cmdmods[i].minlen |
1447 | 3266 && (p == cmd || cmdmods[i].has_count)) |
1570 | 3267 return j + (int)(p - cmd); |
1447 | 3268 } |
3269 return 0; | |
3270 } | |
3271 | |
7 | 3272 /* |
3273 * Return > 0 if an Ex command "name" exists. | |
3274 * Return 2 if there is an exact match. | |
3275 * Return 3 if there is an ambiguous match. | |
3276 */ | |
3277 int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3278 cmd_exists(char_u *name) |
7 | 3279 { |
3280 exarg_T ea; | |
3281 int full = FALSE; | |
3282 int i; | |
3283 int j; | |
866 | 3284 char_u *p; |
7 | 3285 |
3286 /* Check command modifiers. */ | |
1880 | 3287 for (i = 0; i < (int)(sizeof(cmdmods) / sizeof(struct cmdmod)); ++i) |
7 | 3288 { |
3289 for (j = 0; name[j] != NUL; ++j) | |
3290 if (name[j] != cmdmods[i].name[j]) | |
3291 break; | |
3292 if (name[j] == NUL && j >= cmdmods[i].minlen) | |
3293 return (cmdmods[i].name[j] == NUL ? 2 : 1); | |
3294 } | |
3295 | |
862 | 3296 /* Check built-in commands and user defined commands. |
3297 * For ":2match" and ":3match" we need to skip the number. */ | |
3298 ea.cmd = (*name == '2' || *name == '3') ? name + 1 : name; | |
7 | 3299 ea.cmdidx = (cmdidx_T)0; |
866 | 3300 p = find_command(&ea, &full); |
3301 if (p == NULL) | |
7 | 3302 return 3; |
862 | 3303 if (vim_isdigit(*name) && ea.cmdidx != CMD_match) |
3304 return 0; | |
866 | 3305 if (*skipwhite(p) != NUL) |
3306 return 0; /* trailing garbage */ | |
7 | 3307 return (ea.cmdidx == CMD_SIZE ? 0 : (full ? 2 : 1)); |
3308 } | |
3309 #endif | |
3310 | |
3311 /* | |
3312 * This is all pretty much copied from do_one_cmd(), with all the extra stuff | |
3313 * we don't need/want deleted. Maybe this could be done better if we didn't | |
3314 * repeat all this stuff. The only problem is that they may not stay | |
3315 * perfectly compatible with each other, but then the command line syntax | |
3316 * probably won't change that much -- webb. | |
3317 */ | |
3318 char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3319 set_one_cmd_context( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3320 expand_T *xp, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3321 char_u *buff) /* buffer for command string */ |
7 | 3322 { |
3323 char_u *p; | |
3324 char_u *cmd, *arg; | |
184 | 3325 int len = 0; |
3326 exarg_T ea; | |
16411
5b5c5daf57de
patch 8.1.1210: support for user commands is spread out
Bram Moolenaar <Bram@vim.org>
parents:
16399
diff
changeset
|
3327 #ifdef FEAT_CMDL_COMPL |
7 | 3328 int compl = EXPAND_NOTHING; |
3329 int delim; | |
3330 #endif | |
3331 int forceit = FALSE; | |
3332 int usefilter = FALSE; /* filter instead of file name */ | |
3333 | |
631 | 3334 ExpandInit(xp); |
7 | 3335 xp->xp_pattern = buff; |
3336 xp->xp_context = EXPAND_COMMANDS; /* Default until we get past command */ | |
184 | 3337 ea.argt = 0; |
7 | 3338 |
3339 /* | |
6400 | 3340 * 1. skip comment lines and leading space, colons or bars |
7 | 3341 */ |
3342 for (cmd = buff; vim_strchr((char_u *)" \t:|", *cmd) != NULL; cmd++) | |
3343 ; | |
3344 xp->xp_pattern = cmd; | |
3345 | |
3346 if (*cmd == NUL) | |
3347 return NULL; | |
3348 if (*cmd == '"') /* ignore comment lines */ | |
3349 { | |
3350 xp->xp_context = EXPAND_NOTHING; | |
3351 return NULL; | |
3352 } | |
3353 | |
3354 /* | |
6400 | 3355 * 3. Skip over the range to find the command. |
7 | 3356 */ |
3357 cmd = skip_range(cmd, &xp->xp_context); | |
3358 xp->xp_pattern = cmd; | |
3359 if (*cmd == NUL) | |
3360 return NULL; | |
3361 if (*cmd == '"') | |
3362 { | |
3363 xp->xp_context = EXPAND_NOTHING; | |
3364 return NULL; | |
3365 } | |
3366 | |
3367 if (*cmd == '|' || *cmd == '\n') | |
3368 return cmd + 1; /* There's another command */ | |
3369 | |
3370 /* | |
3371 * Isolate the command and search for it in the command table. | |
3372 * Exceptions: | |
3373 * - the 'k' command can directly be followed by any character, but | |
22 | 3374 * do accept "keepmarks", "keepalt" and "keepjumps". |
7 | 3375 * - the 's' command can be followed directly by 'c', 'g', 'i', 'I' or 'r' |
3376 */ | |
3377 if (*cmd == 'k' && cmd[1] != 'e') | |
3378 { | |
184 | 3379 ea.cmdidx = CMD_k; |
7 | 3380 p = cmd + 1; |
3381 } | |
3382 else | |
3383 { | |
3384 p = cmd; | |
3385 while (ASCII_ISALPHA(*p) || *p == '*') /* Allow * wild card */ | |
3386 ++p; | |
7168
0f2807c05687
commit https://github.com/vim/vim/commit/23d1b62746dce048c80cc19e7e5af1d513b6b4cf
Christian Brabandt <cb@256bit.org>
parents:
7133
diff
changeset
|
3387 /* a user command may contain digits */ |
0f2807c05687
commit https://github.com/vim/vim/commit/23d1b62746dce048c80cc19e7e5af1d513b6b4cf
Christian Brabandt <cb@256bit.org>
parents:
7133
diff
changeset
|
3388 if (ASCII_ISUPPER(cmd[0])) |
0f2807c05687
commit https://github.com/vim/vim/commit/23d1b62746dce048c80cc19e7e5af1d513b6b4cf
Christian Brabandt <cb@256bit.org>
parents:
7133
diff
changeset
|
3389 while (ASCII_ISALNUM(*p) || *p == '*') |
0f2807c05687
commit https://github.com/vim/vim/commit/23d1b62746dce048c80cc19e7e5af1d513b6b4cf
Christian Brabandt <cb@256bit.org>
parents:
7133
diff
changeset
|
3390 ++p; |
4710
1c5da99d1b70
updated for version 7.3.1102
Bram Moolenaar <bram@vim.org>
parents:
4704
diff
changeset
|
3391 /* for python 3.x: ":py3*" commands completion */ |
1c5da99d1b70
updated for version 7.3.1102
Bram Moolenaar <bram@vim.org>
parents:
4704
diff
changeset
|
3392 if (cmd[0] == 'p' && cmd[1] == 'y' && p == cmd + 2 && *p == '3') |
5545 | 3393 { |
4710
1c5da99d1b70
updated for version 7.3.1102
Bram Moolenaar <bram@vim.org>
parents:
4704
diff
changeset
|
3394 ++p; |
5545 | 3395 while (ASCII_ISALPHA(*p) || *p == '*') |
3396 ++p; | |
3397 } | |
7168
0f2807c05687
commit https://github.com/vim/vim/commit/23d1b62746dce048c80cc19e7e5af1d513b6b4cf
Christian Brabandt <cb@256bit.org>
parents:
7133
diff
changeset
|
3398 /* check for non-alpha command */ |
0f2807c05687
commit https://github.com/vim/vim/commit/23d1b62746dce048c80cc19e7e5af1d513b6b4cf
Christian Brabandt <cb@256bit.org>
parents:
7133
diff
changeset
|
3399 if (p == cmd && vim_strchr((char_u *)"@*!=><&~#", *p) != NULL) |
0f2807c05687
commit https://github.com/vim/vim/commit/23d1b62746dce048c80cc19e7e5af1d513b6b4cf
Christian Brabandt <cb@256bit.org>
parents:
7133
diff
changeset
|
3400 ++p; |
184 | 3401 len = (int)(p - cmd); |
3402 | |
3403 if (len == 0) | |
7 | 3404 { |
3405 xp->xp_context = EXPAND_UNSUCCESSFUL; | |
3406 return NULL; | |
3407 } | |
184 | 3408 for (ea.cmdidx = (cmdidx_T)0; (int)ea.cmdidx < (int)CMD_SIZE; |
2097
8f72e3512b43
updated for version 7.2.381
Bram Moolenaar <bram@zimbu.org>
parents:
2068
diff
changeset
|
3409 ea.cmdidx = (cmdidx_T)((int)ea.cmdidx + 1)) |
8f72e3512b43
updated for version 7.2.381
Bram Moolenaar <bram@zimbu.org>
parents:
2068
diff
changeset
|
3410 if (STRNCMP(cmdnames[(int)ea.cmdidx].cmd_name, cmd, |
8f72e3512b43
updated for version 7.2.381
Bram Moolenaar <bram@zimbu.org>
parents:
2068
diff
changeset
|
3411 (size_t)len) == 0) |
7 | 3412 break; |
3413 | |
3414 if (cmd[0] >= 'A' && cmd[0] <= 'Z') | |
16411
5b5c5daf57de
patch 8.1.1210: support for user commands is spread out
Bram Moolenaar <Bram@vim.org>
parents:
16399
diff
changeset
|
3415 while (ASCII_ISALNUM(*p) || *p == '*') // Allow * wild card |
7 | 3416 ++p; |
3417 } | |
3418 | |
3419 /* | |
3420 * If the cursor is touching the command, and it ends in an alpha-numeric | |
3421 * character, complete the command name. | |
3422 */ | |
3423 if (*p == NUL && ASCII_ISALNUM(p[-1])) | |
3424 return NULL; | |
3425 | |
184 | 3426 if (ea.cmdidx == CMD_SIZE) |
7 | 3427 { |
3428 if (*cmd == 's' && vim_strchr((char_u *)"cgriI", cmd[1]) != NULL) | |
3429 { | |
184 | 3430 ea.cmdidx = CMD_substitute; |
7 | 3431 p = cmd + 1; |
3432 } | |
3433 else if (cmd[0] >= 'A' && cmd[0] <= 'Z') | |
3434 { | |
184 | 3435 ea.cmd = cmd; |
3436 p = find_ucmd(&ea, p, NULL, xp, | |
16411
5b5c5daf57de
patch 8.1.1210: support for user commands is spread out
Bram Moolenaar <Bram@vim.org>
parents:
16399
diff
changeset
|
3437 #if defined(FEAT_CMDL_COMPL) |
184 | 3438 &compl |
16411
5b5c5daf57de
patch 8.1.1210: support for user commands is spread out
Bram Moolenaar <Bram@vim.org>
parents:
16399
diff
changeset
|
3439 #else |
184 | 3440 NULL |
16411
5b5c5daf57de
patch 8.1.1210: support for user commands is spread out
Bram Moolenaar <Bram@vim.org>
parents:
16399
diff
changeset
|
3441 #endif |
184 | 3442 ); |
620 | 3443 if (p == NULL) |
16411
5b5c5daf57de
patch 8.1.1210: support for user commands is spread out
Bram Moolenaar <Bram@vim.org>
parents:
16399
diff
changeset
|
3444 ea.cmdidx = CMD_SIZE; // ambiguous user command |
5b5c5daf57de
patch 8.1.1210: support for user commands is spread out
Bram Moolenaar <Bram@vim.org>
parents:
16399
diff
changeset
|
3445 } |
184 | 3446 } |
3447 if (ea.cmdidx == CMD_SIZE) | |
7 | 3448 { |
3449 /* Not still touching the command and it was an illegal one */ | |
3450 xp->xp_context = EXPAND_UNSUCCESSFUL; | |
3451 return NULL; | |
3452 } | |
3453 | |
3454 xp->xp_context = EXPAND_NOTHING; /* Default now that we're past command */ | |
3455 | |
3456 if (*p == '!') /* forced commands */ | |
3457 { | |
3458 forceit = TRUE; | |
3459 ++p; | |
3460 } | |
3461 | |
3462 /* | |
6400 | 3463 * 6. parse arguments |
7 | 3464 */ |
6305 | 3465 if (!IS_USER_CMDIDX(ea.cmdidx)) |
835 | 3466 ea.argt = (long)cmdnames[(int)ea.cmdidx].cmd_argt; |
7 | 3467 |
3468 arg = skipwhite(p); | |
3469 | |
184 | 3470 if (ea.cmdidx == CMD_write || ea.cmdidx == CMD_update) |
7 | 3471 { |
3472 if (*arg == '>') /* append */ | |
3473 { | |
3474 if (*++arg == '>') | |
3475 ++arg; | |
3476 arg = skipwhite(arg); | |
3477 } | |
184 | 3478 else if (*arg == '!' && ea.cmdidx == CMD_write) /* :w !filter */ |
7 | 3479 { |
3480 ++arg; | |
3481 usefilter = TRUE; | |
3482 } | |
3483 } | |
3484 | |
184 | 3485 if (ea.cmdidx == CMD_read) |
7 | 3486 { |
3487 usefilter = forceit; /* :r! filter if forced */ | |
3488 if (*arg == '!') /* :r !filter */ | |
3489 { | |
3490 ++arg; | |
3491 usefilter = TRUE; | |
3492 } | |
3493 } | |
3494 | |
184 | 3495 if (ea.cmdidx == CMD_lshift || ea.cmdidx == CMD_rshift) |
7 | 3496 { |
3497 while (*arg == *cmd) /* allow any number of '>' or '<' */ | |
3498 ++arg; | |
3499 arg = skipwhite(arg); | |
3500 } | |
3501 | |
3502 /* Does command allow "+command"? */ | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
3503 if ((ea.argt & EX_CMDARG) && !usefilter && *arg == '+') |
7 | 3504 { |
3505 /* Check if we're in the +command */ | |
3506 p = arg + 1; | |
3507 arg = skip_cmd_arg(arg, FALSE); | |
3508 | |
3509 /* Still touching the command after '+'? */ | |
3510 if (*arg == NUL) | |
3511 return p; | |
3512 | |
3513 /* Skip space(s) after +command to get to the real argument */ | |
3514 arg = skipwhite(arg); | |
3515 } | |
3516 | |
3517 /* | |
3518 * Check for '|' to separate commands and '"' to start comments. | |
3519 * Don't do this for ":read !cmd" and ":write !cmd". | |
3520 */ | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
3521 if ((ea.argt & EX_TRLBAR) && !usefilter) |
7 | 3522 { |
3523 p = arg; | |
3524 /* ":redir @" is not the start of a comment */ | |
184 | 3525 if (ea.cmdidx == CMD_redir && p[0] == '@' && p[1] == '"') |
7 | 3526 p += 2; |
3527 while (*p) | |
3528 { | |
3529 if (*p == Ctrl_V) | |
3530 { | |
3531 if (p[1] != NUL) | |
3532 ++p; | |
3533 } | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
3534 else if ( (*p == '"' && !(ea.argt & EX_NOTRLCOM)) |
7 | 3535 || *p == '|' || *p == '\n') |
3536 { | |
3537 if (*(p - 1) != '\\') | |
3538 { | |
3539 if (*p == '|' || *p == '\n') | |
3540 return p + 1; | |
3541 return NULL; /* It's a comment */ | |
3542 } | |
3543 } | |
11127
506f5d8b7d8b
patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11010
diff
changeset
|
3544 MB_PTR_ADV(p); |
7 | 3545 } |
3546 } | |
3547 | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
3548 if (!(ea.argt & EX_EXTRA) && *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
|
3549 && vim_strchr((char_u *)"|\"", *arg) == NULL) |
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
3550 // no arguments allowed but there is something |
7 | 3551 return NULL; |
3552 | |
3553 /* Find start of last argument (argument just before cursor): */ | |
3711 | 3554 p = buff; |
7 | 3555 xp->xp_pattern = p; |
3724 | 3556 len = (int)STRLEN(buff); |
3711 | 3557 while (*p && p < buff + len) |
3558 { | |
3559 if (*p == ' ' || *p == TAB) | |
3560 { | |
3561 /* argument starts after a space */ | |
3562 xp->xp_pattern = ++p; | |
3563 } | |
3564 else | |
3565 { | |
3566 if (*p == '\\' && *(p + 1) != NUL) | |
3567 ++p; /* skip over escaped character */ | |
11127
506f5d8b7d8b
patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11010
diff
changeset
|
3568 MB_PTR_ADV(p); |
3711 | 3569 } |
3570 } | |
7 | 3571 |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
3572 if (ea.argt & EX_XFILE) |
7 | 3573 { |
1367 | 3574 int c; |
3575 int in_quote = FALSE; | |
3576 char_u *bow = NULL; /* Beginning of word */ | |
7 | 3577 |
3578 /* | |
3579 * Allow spaces within back-quotes to count as part of the argument | |
3580 * being expanded. | |
3581 */ | |
3582 xp->xp_pattern = skipwhite(arg); | |
1367 | 3583 p = xp->xp_pattern; |
3584 while (*p != NUL) | |
3585 { | |
3586 if (has_mbyte) | |
3587 c = mb_ptr2char(p); | |
3588 else | |
3589 c = *p; | |
3590 if (c == '\\' && p[1] != NUL) | |
7 | 3591 ++p; |
1367 | 3592 else if (c == '`') |
7 | 3593 { |
3594 if (!in_quote) | |
3595 { | |
3596 xp->xp_pattern = p; | |
3597 bow = p + 1; | |
3598 } | |
3599 in_quote = !in_quote; | |
3600 } | |
1511 | 3601 /* An argument can contain just about everything, except |
3602 * characters that end the command and white space. */ | |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
3603 else if (c == '|' || c == '\n' || c == '"' || (VIM_ISWHITE(c) |
1367 | 3604 #ifdef SPACE_IN_FILENAME |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
3605 && (!(ea.argt & EX_NOSPC) || usefilter) |
1511 | 3606 #endif |
3607 )) | |
1367 | 3608 { |
1551 | 3609 len = 0; /* avoid getting stuck when space is in 'isfname' */ |
1367 | 3610 while (*p != NUL) |
3611 { | |
3612 if (has_mbyte) | |
3613 c = mb_ptr2char(p); | |
3614 else | |
3615 c = *p; | |
1369 | 3616 if (c == '`' || vim_isfilec_or_wc(c)) |
1367 | 3617 break; |
3618 if (has_mbyte) | |
3619 len = (*mb_ptr2len)(p); | |
3620 else | |
3621 len = 1; | |
11127
506f5d8b7d8b
patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11010
diff
changeset
|
3622 MB_PTR_ADV(p); |
1367 | 3623 } |
3624 if (in_quote) | |
3625 bow = p; | |
3626 else | |
3627 xp->xp_pattern = p; | |
3628 p -= len; | |
3629 } | |
11127
506f5d8b7d8b
patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11010
diff
changeset
|
3630 MB_PTR_ADV(p); |
7 | 3631 } |
3632 | |
3633 /* | |
3634 * If we are still inside the quotes, and we passed a space, just | |
3635 * expand from there. | |
3636 */ | |
3637 if (bow != NULL && in_quote) | |
3638 xp->xp_pattern = bow; | |
3639 xp->xp_context = EXPAND_FILES; | |
714 | 3640 |
631 | 3641 /* For a shell command more chars need to be escaped. */ |
11806
1c1cb1e9b7b3
patch 8.0.0785: wildcards are not expanded for :terminal
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
3642 if (usefilter || ea.cmdidx == CMD_bang || ea.cmdidx == CMD_terminal) |
714 | 3643 { |
2511
2f5b709a6470
Fixed: on MS-Windows completion of shell commands didn't work.
Bram Moolenaar <bram@vim.org>
parents:
2444
diff
changeset
|
3644 #ifndef BACKSLASH_IN_FILENAME |
631 | 3645 xp->xp_shell = TRUE; |
2511
2f5b709a6470
Fixed: on MS-Windows completion of shell commands didn't work.
Bram Moolenaar <bram@vim.org>
parents:
2444
diff
changeset
|
3646 #endif |
714 | 3647 /* When still after the command name expand executables. */ |
3648 if (xp->xp_pattern == skipwhite(arg)) | |
1132 | 3649 xp->xp_context = EXPAND_SHELLCMD; |
714 | 3650 } |
7 | 3651 |
3652 /* Check for environment variable */ | |
3653 if (*xp->xp_pattern == '$' | |
8212
05b88224cea1
commit https://github.com/vim/vim/commit/48e330aff911be1c798c88a973af6437a8141fce
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
3654 #if defined(MSWIN) |
7 | 3655 || *xp->xp_pattern == '%' |
3656 #endif | |
3657 ) | |
3658 { | |
3659 for (p = xp->xp_pattern + 1; *p != NUL; ++p) | |
3660 if (!vim_isIDc(*p)) | |
3661 break; | |
3662 if (*p == NUL) | |
3663 { | |
3664 xp->xp_context = EXPAND_ENV_VARS; | |
3665 ++xp->xp_pattern; | |
16411
5b5c5daf57de
patch 8.1.1210: support for user commands is spread out
Bram Moolenaar <Bram@vim.org>
parents:
16399
diff
changeset
|
3666 #if defined(FEAT_CMDL_COMPL) |
17 | 3667 /* Avoid that the assignment uses EXPAND_FILES again. */ |
406 | 3668 if (compl != EXPAND_USER_DEFINED && compl != EXPAND_USER_LIST) |
17 | 3669 compl = EXPAND_ENV_VARS; |
3670 #endif | |
7 | 3671 } |
3672 } | |
3744 | 3673 #if defined(FEAT_CMDL_COMPL) |
3674 /* Check for user names */ | |
3675 if (*xp->xp_pattern == '~') | |
3676 { | |
3677 for (p = xp->xp_pattern + 1; *p != NUL && *p != '/'; ++p) | |
3678 ; | |
3679 /* Complete ~user only if it partially matches a user name. | |
3680 * A full match ~user<Tab> will be replaced by user's home | |
3681 * directory i.e. something like ~user<Tab> -> /home/user/ */ | |
3682 if (*p == NUL && p > xp->xp_pattern + 1 | |
14286
95030c543411
patch 8.1.0159: completion for user names does not work for a prefix.
Christian Brabandt <cb@256bit.org>
parents:
14284
diff
changeset
|
3683 && match_user(xp->xp_pattern + 1) >= 1) |
3744 | 3684 { |
3685 xp->xp_context = EXPAND_USER; | |
3686 ++xp->xp_pattern; | |
3687 } | |
3688 } | |
3689 #endif | |
7 | 3690 } |
3691 | |
3692 /* | |
6400 | 3693 * 6. Switch on command name. |
7 | 3694 */ |
184 | 3695 switch (ea.cmdidx) |
7 | 3696 { |
2311
ccda151dde4e
Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
3697 case CMD_find: |
ccda151dde4e
Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
3698 case CMD_sfind: |
ccda151dde4e
Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
3699 case CMD_tabfind: |
2575 | 3700 if (xp->xp_context == EXPAND_FILES) |
3701 xp->xp_context = EXPAND_FILES_IN_PATH; | |
2311
ccda151dde4e
Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
3702 break; |
7 | 3703 case CMD_cd: |
3704 case CMD_chdir: | |
16427
8c3a1bd270bb
patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents:
16411
diff
changeset
|
3705 case CMD_tcd: |
8c3a1bd270bb
patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents:
16411
diff
changeset
|
3706 case CMD_tchdir: |
7 | 3707 case CMD_lcd: |
3708 case CMD_lchdir: | |
3709 if (xp->xp_context == EXPAND_FILES) | |
3710 xp->xp_context = EXPAND_DIRECTORIES; | |
3711 break; | |
3712 case CMD_help: | |
3713 xp->xp_context = EXPAND_HELP; | |
3714 xp->xp_pattern = arg; | |
3715 break; | |
3716 | |
198 | 3717 /* Command modifiers: return the argument. |
3718 * Also for commands with an argument that is a command. */ | |
7 | 3719 case CMD_aboveleft: |
198 | 3720 case CMD_argdo: |
7 | 3721 case CMD_belowright: |
3722 case CMD_botright: | |
3723 case CMD_browse: | |
198 | 3724 case CMD_bufdo: |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
3725 case CMD_cdo: |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
3726 case CMD_cfdo: |
7 | 3727 case CMD_confirm: |
167 | 3728 case CMD_debug: |
7 | 3729 case CMD_folddoclosed: |
3730 case CMD_folddoopen: | |
3731 case CMD_hide: | |
22 | 3732 case CMD_keepalt: |
7 | 3733 case CMD_keepjumps: |
3734 case CMD_keepmarks: | |
5467 | 3735 case CMD_keeppatterns: |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
3736 case CMD_ldo: |
7 | 3737 case CMD_leftabove: |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
3738 case CMD_lfdo: |
7 | 3739 case CMD_lockmarks: |
5737 | 3740 case CMD_noautocmd: |
3741 case CMD_noswapfile: | |
7 | 3742 case CMD_rightbelow: |
198 | 3743 case CMD_sandbox: |
7 | 3744 case CMD_silent: |
690 | 3745 case CMD_tab: |
4928
afb00cc8caac
updated for version 7.3.1209
Bram Moolenaar <bram@vim.org>
parents:
4889
diff
changeset
|
3746 case CMD_tabdo: |
7 | 3747 case CMD_topleft: |
3748 case CMD_verbose: | |
3749 case CMD_vertical: | |
198 | 3750 case CMD_windo: |
7 | 3751 return arg; |
3752 | |
10520
4b152b5f414f
commit https://github.com/vim/vim/commit/7069bf18e1b1b7bc7640335e07d1022b5acc9048
Christian Brabandt <cb@256bit.org>
parents:
10492
diff
changeset
|
3753 case CMD_filter: |
4b152b5f414f
commit https://github.com/vim/vim/commit/7069bf18e1b1b7bc7640335e07d1022b5acc9048
Christian Brabandt <cb@256bit.org>
parents:
10492
diff
changeset
|
3754 if (*arg != NUL) |
4b152b5f414f
commit https://github.com/vim/vim/commit/7069bf18e1b1b7bc7640335e07d1022b5acc9048
Christian Brabandt <cb@256bit.org>
parents:
10492
diff
changeset
|
3755 arg = skip_vimgrep_pat(arg, NULL, NULL); |
4b152b5f414f
commit https://github.com/vim/vim/commit/7069bf18e1b1b7bc7640335e07d1022b5acc9048
Christian Brabandt <cb@256bit.org>
parents:
10492
diff
changeset
|
3756 if (arg == NULL || *arg == NUL) |
4b152b5f414f
commit https://github.com/vim/vim/commit/7069bf18e1b1b7bc7640335e07d1022b5acc9048
Christian Brabandt <cb@256bit.org>
parents:
10492
diff
changeset
|
3757 { |
4b152b5f414f
commit https://github.com/vim/vim/commit/7069bf18e1b1b7bc7640335e07d1022b5acc9048
Christian Brabandt <cb@256bit.org>
parents:
10492
diff
changeset
|
3758 xp->xp_context = EXPAND_NOTHING; |
4b152b5f414f
commit https://github.com/vim/vim/commit/7069bf18e1b1b7bc7640335e07d1022b5acc9048
Christian Brabandt <cb@256bit.org>
parents:
10492
diff
changeset
|
3759 return NULL; |
4b152b5f414f
commit https://github.com/vim/vim/commit/7069bf18e1b1b7bc7640335e07d1022b5acc9048
Christian Brabandt <cb@256bit.org>
parents:
10492
diff
changeset
|
3760 } |
4b152b5f414f
commit https://github.com/vim/vim/commit/7069bf18e1b1b7bc7640335e07d1022b5acc9048
Christian Brabandt <cb@256bit.org>
parents:
10492
diff
changeset
|
3761 return skipwhite(arg); |
4b152b5f414f
commit https://github.com/vim/vim/commit/7069bf18e1b1b7bc7640335e07d1022b5acc9048
Christian Brabandt <cb@256bit.org>
parents:
10492
diff
changeset
|
3762 |
1322 | 3763 #ifdef FEAT_CMDL_COMPL |
3764 # ifdef FEAT_SEARCH_EXTRA | |
7 | 3765 case CMD_match: |
3766 if (*arg == NUL || !ends_excmd(*arg)) | |
3767 { | |
1322 | 3768 /* also complete "None" */ |
3769 set_context_in_echohl_cmd(xp, arg); | |
7 | 3770 arg = skipwhite(skiptowhite(arg)); |
3771 if (*arg != NUL) | |
3772 { | |
3773 xp->xp_context = EXPAND_NOTHING; | |
3774 arg = skip_regexp(arg + 1, *arg, p_magic, NULL); | |
3775 } | |
3776 } | |
3777 return find_nextcmd(arg); | |
1322 | 3778 # endif |
3779 | |
7 | 3780 /* |
3781 * All completion for the +cmdline_compl feature goes here. | |
3782 */ | |
3783 | |
3784 case CMD_command: | |
16411
5b5c5daf57de
patch 8.1.1210: support for user commands is spread out
Bram Moolenaar <Bram@vim.org>
parents:
16399
diff
changeset
|
3785 return set_context_in_user_cmd(xp, arg); |
7 | 3786 |
3787 case CMD_delcommand: | |
3788 xp->xp_context = EXPAND_USER_COMMANDS; | |
3789 xp->xp_pattern = arg; | |
3790 break; | |
3791 | |
3792 case CMD_global: | |
3793 case CMD_vglobal: | |
3794 delim = *arg; /* get the delimiter */ | |
3795 if (delim) | |
3796 ++arg; /* skip delimiter if there is one */ | |
3797 | |
3798 while (arg[0] != NUL && arg[0] != delim) | |
3799 { | |
3800 if (arg[0] == '\\' && arg[1] != NUL) | |
3801 ++arg; | |
3802 ++arg; | |
3803 } | |
3804 if (arg[0] != NUL) | |
3805 return arg + 1; | |
3806 break; | |
3807 case CMD_and: | |
3808 case CMD_substitute: | |
3809 delim = *arg; | |
3810 if (delim) | |
3811 { | |
3812 /* skip "from" part */ | |
3813 ++arg; | |
3814 arg = skip_regexp(arg, delim, p_magic, NULL); | |
3815 } | |
3816 /* skip "to" part */ | |
3817 while (arg[0] != NUL && arg[0] != delim) | |
3818 { | |
3819 if (arg[0] == '\\' && arg[1] != NUL) | |
3820 ++arg; | |
3821 ++arg; | |
3822 } | |
3823 if (arg[0] != NUL) /* skip delimiter */ | |
3824 ++arg; | |
3825 while (arg[0] && vim_strchr((char_u *)"|\"#", arg[0]) == NULL) | |
3826 ++arg; | |
3827 if (arg[0] != NUL) | |
3828 return arg; | |
3829 break; | |
3830 case CMD_isearch: | |
3831 case CMD_dsearch: | |
3832 case CMD_ilist: | |
3833 case CMD_dlist: | |
3834 case CMD_ijump: | |
3835 case CMD_psearch: | |
3836 case CMD_djump: | |
3837 case CMD_isplit: | |
3838 case CMD_dsplit: | |
3839 arg = skipwhite(skipdigits(arg)); /* skip count */ | |
3840 if (*arg == '/') /* Match regexp, not just whole words */ | |
3841 { | |
3842 for (++arg; *arg && *arg != '/'; arg++) | |
3843 if (*arg == '\\' && arg[1] != NUL) | |
3844 arg++; | |
3845 if (*arg) | |
3846 { | |
3847 arg = skipwhite(arg + 1); | |
3848 | |
3849 /* Check for trailing illegal characters */ | |
3850 if (*arg && vim_strchr((char_u *)"|\"\n", *arg) == NULL) | |
3851 xp->xp_context = EXPAND_NOTHING; | |
3852 else | |
3853 return arg; | |
3854 } | |
3855 } | |
3856 break; | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
3857 |
7 | 3858 case CMD_autocmd: |
3859 return set_context_in_autocmd(xp, arg, FALSE); | |
3860 case CMD_doautocmd: | |
1731 | 3861 case CMD_doautoall: |
7 | 3862 return set_context_in_autocmd(xp, arg, TRUE); |
3863 case CMD_set: | |
3864 set_context_in_set_cmd(xp, arg, 0); | |
3865 break; | |
3866 case CMD_setglobal: | |
3867 set_context_in_set_cmd(xp, arg, OPT_GLOBAL); | |
3868 break; | |
3869 case CMD_setlocal: | |
3870 set_context_in_set_cmd(xp, arg, OPT_LOCAL); | |
3871 break; | |
3872 case CMD_tag: | |
3873 case CMD_stag: | |
3874 case CMD_ptag: | |
649 | 3875 case CMD_ltag: |
7 | 3876 case CMD_tselect: |
3877 case CMD_stselect: | |
3878 case CMD_ptselect: | |
3879 case CMD_tjump: | |
3880 case CMD_stjump: | |
3881 case CMD_ptjump: | |
40 | 3882 if (*p_wop != NUL) |
3883 xp->xp_context = EXPAND_TAGS_LISTFILES; | |
3884 else | |
3885 xp->xp_context = EXPAND_TAGS; | |
7 | 3886 xp->xp_pattern = arg; |
3887 break; | |
3888 case CMD_augroup: | |
3889 xp->xp_context = EXPAND_AUGROUP; | |
3890 xp->xp_pattern = arg; | |
3891 break; | |
3892 #ifdef FEAT_SYN_HL | |
3893 case CMD_syntax: | |
3894 set_context_in_syntax_cmd(xp, arg); | |
3895 break; | |
3896 #endif | |
3897 #ifdef FEAT_EVAL | |
3898 case CMD_let: | |
3899 case CMD_if: | |
3900 case CMD_elseif: | |
3901 case CMD_while: | |
72 | 3902 case CMD_for: |
7 | 3903 case CMD_echo: |
3904 case CMD_echon: | |
3905 case CMD_execute: | |
3906 case CMD_echomsg: | |
3907 case CMD_echoerr: | |
3908 case CMD_call: | |
3909 case CMD_return: | |
10656
4762bd300564
patch 8.0.0218: no completion for :cexpr and similar commands
Christian Brabandt <cb@256bit.org>
parents:
10575
diff
changeset
|
3910 case CMD_cexpr: |
4762bd300564
patch 8.0.0218: no completion for :cexpr and similar commands
Christian Brabandt <cb@256bit.org>
parents:
10575
diff
changeset
|
3911 case CMD_caddexpr: |
4762bd300564
patch 8.0.0218: no completion for :cexpr and similar commands
Christian Brabandt <cb@256bit.org>
parents:
10575
diff
changeset
|
3912 case CMD_cgetexpr: |
4762bd300564
patch 8.0.0218: no completion for :cexpr and similar commands
Christian Brabandt <cb@256bit.org>
parents:
10575
diff
changeset
|
3913 case CMD_lexpr: |
4762bd300564
patch 8.0.0218: no completion for :cexpr and similar commands
Christian Brabandt <cb@256bit.org>
parents:
10575
diff
changeset
|
3914 case CMD_laddexpr: |
4762bd300564
patch 8.0.0218: no completion for :cexpr and similar commands
Christian Brabandt <cb@256bit.org>
parents:
10575
diff
changeset
|
3915 case CMD_lgetexpr: |
184 | 3916 set_context_for_expression(xp, arg, ea.cmdidx); |
7 | 3917 break; |
3918 | |
3919 case CMD_unlet: | |
3920 while ((xp->xp_pattern = vim_strchr(arg, ' ')) != NULL) | |
3921 arg = xp->xp_pattern + 1; | |
14059
a94bc6a7b29e
patch 8.1.0047: no completion for :unlet $VAR
Christian Brabandt <cb@256bit.org>
parents:
14051
diff
changeset
|
3922 |
7 | 3923 xp->xp_context = EXPAND_USER_VARS; |
3924 xp->xp_pattern = arg; | |
14059
a94bc6a7b29e
patch 8.1.0047: no completion for :unlet $VAR
Christian Brabandt <cb@256bit.org>
parents:
14051
diff
changeset
|
3925 |
a94bc6a7b29e
patch 8.1.0047: no completion for :unlet $VAR
Christian Brabandt <cb@256bit.org>
parents:
14051
diff
changeset
|
3926 if (*xp->xp_pattern == '$') |
a94bc6a7b29e
patch 8.1.0047: no completion for :unlet $VAR
Christian Brabandt <cb@256bit.org>
parents:
14051
diff
changeset
|
3927 { |
a94bc6a7b29e
patch 8.1.0047: no completion for :unlet $VAR
Christian Brabandt <cb@256bit.org>
parents:
14051
diff
changeset
|
3928 xp->xp_context = EXPAND_ENV_VARS; |
a94bc6a7b29e
patch 8.1.0047: no completion for :unlet $VAR
Christian Brabandt <cb@256bit.org>
parents:
14051
diff
changeset
|
3929 ++xp->xp_pattern; |
a94bc6a7b29e
patch 8.1.0047: no completion for :unlet $VAR
Christian Brabandt <cb@256bit.org>
parents:
14051
diff
changeset
|
3930 } |
a94bc6a7b29e
patch 8.1.0047: no completion for :unlet $VAR
Christian Brabandt <cb@256bit.org>
parents:
14051
diff
changeset
|
3931 |
7 | 3932 break; |
3933 | |
3934 case CMD_function: | |
3935 case CMD_delfunction: | |
3936 xp->xp_context = EXPAND_USER_FUNC; | |
3937 xp->xp_pattern = arg; | |
3938 break; | |
3939 | |
3940 case CMD_echohl: | |
1322 | 3941 set_context_in_echohl_cmd(xp, arg); |
7 | 3942 break; |
3943 #endif | |
3944 case CMD_highlight: | |
3945 set_context_in_highlight_cmd(xp, arg); | |
3946 break; | |
1845 | 3947 #ifdef FEAT_CSCOPE |
3948 case CMD_cscope: | |
1858 | 3949 case CMD_lcscope: |
3950 case CMD_scscope: | |
3951 set_context_in_cscope_cmd(xp, arg, ea.cmdidx); | |
1845 | 3952 break; |
3953 #endif | |
1868 | 3954 #ifdef FEAT_SIGNS |
3955 case CMD_sign: | |
3956 set_context_in_sign_cmd(xp, arg); | |
3957 break; | |
3958 #endif | |
7 | 3959 case CMD_bdelete: |
3960 case CMD_bwipeout: | |
3961 case CMD_bunload: | |
3962 while ((xp->xp_pattern = vim_strchr(arg, ' ')) != NULL) | |
3963 arg = xp->xp_pattern + 1; | |
12674
e769c912fcd9
patch 8.0.1215: newer gcc warns for implicit fallthrough
Christian Brabandt <cb@256bit.org>
parents:
12654
diff
changeset
|
3964 /* FALLTHROUGH */ |
7 | 3965 case CMD_buffer: |
3966 case CMD_sbuffer: | |
3967 case CMD_checktime: | |
3968 xp->xp_context = EXPAND_BUFFERS; | |
3969 xp->xp_pattern = arg; | |
3970 break; | |
16411
5b5c5daf57de
patch 8.1.1210: support for user commands is spread out
Bram Moolenaar <Bram@vim.org>
parents:
16399
diff
changeset
|
3971 |
7 | 3972 case CMD_USER: |
3973 case CMD_USER_BUF: | |
3974 if (compl != EXPAND_NOTHING) | |
3975 { | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
3976 // EX_XFILE: file names are handled above |
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
3977 if (!(ea.argt & EX_XFILE)) |
7 | 3978 { |
16411
5b5c5daf57de
patch 8.1.1210: support for user commands is spread out
Bram Moolenaar <Bram@vim.org>
parents:
16399
diff
changeset
|
3979 #ifdef FEAT_MENU |
7 | 3980 if (compl == EXPAND_MENUS) |
3981 return set_context_in_menu_cmd(xp, cmd, arg, forceit); | |
16411
5b5c5daf57de
patch 8.1.1210: support for user commands is spread out
Bram Moolenaar <Bram@vim.org>
parents:
16399
diff
changeset
|
3982 #endif |
7 | 3983 if (compl == EXPAND_COMMANDS) |
3984 return arg; | |
3985 if (compl == EXPAND_MAPPINGS) | |
3986 return set_context_in_map_cmd(xp, (char_u *)"map", | |
3987 arg, forceit, FALSE, FALSE, CMD_map); | |
16411
5b5c5daf57de
patch 8.1.1210: support for user commands is spread out
Bram Moolenaar <Bram@vim.org>
parents:
16399
diff
changeset
|
3988 // Find start of last argument. |
3711 | 3989 p = arg; |
3990 while (*p) | |
3991 { | |
3992 if (*p == ' ') | |
16411
5b5c5daf57de
patch 8.1.1210: support for user commands is spread out
Bram Moolenaar <Bram@vim.org>
parents:
16399
diff
changeset
|
3993 // argument starts after a space |
3711 | 3994 arg = p + 1; |
3716 | 3995 else if (*p == '\\' && *(p + 1) != NUL) |
16411
5b5c5daf57de
patch 8.1.1210: support for user commands is spread out
Bram Moolenaar <Bram@vim.org>
parents:
16399
diff
changeset
|
3996 ++p; // skip over escaped character |
11127
506f5d8b7d8b
patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11010
diff
changeset
|
3997 MB_PTR_ADV(p); |
3711 | 3998 } |
7 | 3999 xp->xp_pattern = arg; |
4000 } | |
4001 xp->xp_context = compl; | |
4002 } | |
4003 break; | |
16411
5b5c5daf57de
patch 8.1.1210: support for user commands is spread out
Bram Moolenaar <Bram@vim.org>
parents:
16399
diff
changeset
|
4004 |
7 | 4005 case CMD_map: case CMD_noremap: |
4006 case CMD_nmap: case CMD_nnoremap: | |
4007 case CMD_vmap: case CMD_vnoremap: | |
4008 case CMD_omap: case CMD_onoremap: | |
4009 case CMD_imap: case CMD_inoremap: | |
4010 case CMD_cmap: case CMD_cnoremap: | |
2405
84c9bf950ed4
Add completion for :lmap and :lunmap.
Bram Moolenaar <bram@vim.org>
parents:
2366
diff
changeset
|
4011 case CMD_lmap: case CMD_lnoremap: |
4365 | 4012 case CMD_smap: case CMD_snoremap: |
12457
dfb8254aa735
patch 8.0.1108: cannot specify mappings for the terminal window
Christian Brabandt <cb@256bit.org>
parents:
12421
diff
changeset
|
4013 case CMD_tmap: case CMD_tnoremap: |
4365 | 4014 case CMD_xmap: case CMD_xnoremap: |
7 | 4015 return set_context_in_map_cmd(xp, cmd, arg, forceit, |
2405
84c9bf950ed4
Add completion for :lmap and :lunmap.
Bram Moolenaar <bram@vim.org>
parents:
2366
diff
changeset
|
4016 FALSE, FALSE, ea.cmdidx); |
7 | 4017 case CMD_unmap: |
4018 case CMD_nunmap: | |
4019 case CMD_vunmap: | |
4020 case CMD_ounmap: | |
4021 case CMD_iunmap: | |
4022 case CMD_cunmap: | |
2405
84c9bf950ed4
Add completion for :lmap and :lunmap.
Bram Moolenaar <bram@vim.org>
parents:
2366
diff
changeset
|
4023 case CMD_lunmap: |
4365 | 4024 case CMD_sunmap: |
12457
dfb8254aa735
patch 8.0.1108: cannot specify mappings for the terminal window
Christian Brabandt <cb@256bit.org>
parents:
12421
diff
changeset
|
4025 case CMD_tunmap: |
4365 | 4026 case CMD_xunmap: |
7 | 4027 return set_context_in_map_cmd(xp, cmd, arg, forceit, |
2405
84c9bf950ed4
Add completion for :lmap and :lunmap.
Bram Moolenaar <bram@vim.org>
parents:
2366
diff
changeset
|
4028 FALSE, TRUE, ea.cmdidx); |
11995
7df3dd3c0ac1
patch 8.0.0878: no completion for :mapclear
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
4029 case CMD_mapclear: |
7df3dd3c0ac1
patch 8.0.0878: no completion for :mapclear
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
4030 case CMD_nmapclear: |
7df3dd3c0ac1
patch 8.0.0878: no completion for :mapclear
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
4031 case CMD_vmapclear: |
7df3dd3c0ac1
patch 8.0.0878: no completion for :mapclear
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
4032 case CMD_omapclear: |
7df3dd3c0ac1
patch 8.0.0878: no completion for :mapclear
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
4033 case CMD_imapclear: |
7df3dd3c0ac1
patch 8.0.0878: no completion for :mapclear
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
4034 case CMD_cmapclear: |
7df3dd3c0ac1
patch 8.0.0878: no completion for :mapclear
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
4035 case CMD_lmapclear: |
7df3dd3c0ac1
patch 8.0.0878: no completion for :mapclear
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
4036 case CMD_smapclear: |
12457
dfb8254aa735
patch 8.0.1108: cannot specify mappings for the terminal window
Christian Brabandt <cb@256bit.org>
parents:
12421
diff
changeset
|
4037 case CMD_tmapclear: |
11995
7df3dd3c0ac1
patch 8.0.0878: no completion for :mapclear
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
4038 case CMD_xmapclear: |
7df3dd3c0ac1
patch 8.0.0878: no completion for :mapclear
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
4039 xp->xp_context = EXPAND_MAPCLEAR; |
7df3dd3c0ac1
patch 8.0.0878: no completion for :mapclear
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
4040 xp->xp_pattern = arg; |
7df3dd3c0ac1
patch 8.0.0878: no completion for :mapclear
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
4041 break; |
7df3dd3c0ac1
patch 8.0.0878: no completion for :mapclear
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
4042 |
7 | 4043 case CMD_abbreviate: case CMD_noreabbrev: |
4044 case CMD_cabbrev: case CMD_cnoreabbrev: | |
4045 case CMD_iabbrev: case CMD_inoreabbrev: | |
4046 return set_context_in_map_cmd(xp, cmd, arg, forceit, | |
2405
84c9bf950ed4
Add completion for :lmap and :lunmap.
Bram Moolenaar <bram@vim.org>
parents:
2366
diff
changeset
|
4047 TRUE, FALSE, ea.cmdidx); |
7 | 4048 case CMD_unabbreviate: |
4049 case CMD_cunabbrev: | |
4050 case CMD_iunabbrev: | |
4051 return set_context_in_map_cmd(xp, cmd, arg, forceit, | |
2405
84c9bf950ed4
Add completion for :lmap and :lunmap.
Bram Moolenaar <bram@vim.org>
parents:
2366
diff
changeset
|
4052 TRUE, TRUE, ea.cmdidx); |
7 | 4053 #ifdef FEAT_MENU |
4054 case CMD_menu: case CMD_noremenu: case CMD_unmenu: | |
4055 case CMD_amenu: case CMD_anoremenu: case CMD_aunmenu: | |
4056 case CMD_nmenu: case CMD_nnoremenu: case CMD_nunmenu: | |
4057 case CMD_vmenu: case CMD_vnoremenu: case CMD_vunmenu: | |
4058 case CMD_omenu: case CMD_onoremenu: case CMD_ounmenu: | |
4059 case CMD_imenu: case CMD_inoremenu: case CMD_iunmenu: | |
4060 case CMD_cmenu: case CMD_cnoremenu: case CMD_cunmenu: | |
14952
405309f9dd13
patch 8.1.0487: no menus specifically for the terminal window
Bram Moolenaar <Bram@vim.org>
parents:
14871
diff
changeset
|
4061 case CMD_tlmenu: case CMD_tlnoremenu: case CMD_tlunmenu: |
7 | 4062 case CMD_tmenu: case CMD_tunmenu: |
4063 case CMD_popup: case CMD_tearoff: case CMD_emenu: | |
4064 return set_context_in_menu_cmd(xp, cmd, arg, forceit); | |
4065 #endif | |
4066 | |
4067 case CMD_colorscheme: | |
4068 xp->xp_context = EXPAND_COLORS; | |
4069 xp->xp_pattern = arg; | |
4070 break; | |
4071 | |
4072 case CMD_compiler: | |
4073 xp->xp_context = EXPAND_COMPILER; | |
4074 xp->xp_pattern = arg; | |
4075 break; | |
4076 | |
2433
98b9a6b9e7d5
Add completion for ":ownsyntax" and improve completion for ":filetype".
Bram Moolenaar <bram@vim.org>
parents:
2406
diff
changeset
|
4077 case CMD_ownsyntax: |
98b9a6b9e7d5
Add completion for ":ownsyntax" and improve completion for ":filetype".
Bram Moolenaar <bram@vim.org>
parents:
2406
diff
changeset
|
4078 xp->xp_context = EXPAND_OWNSYNTAX; |
98b9a6b9e7d5
Add completion for ":ownsyntax" and improve completion for ":filetype".
Bram Moolenaar <bram@vim.org>
parents:
2406
diff
changeset
|
4079 xp->xp_pattern = arg; |
98b9a6b9e7d5
Add completion for ":ownsyntax" and improve completion for ":filetype".
Bram Moolenaar <bram@vim.org>
parents:
2406
diff
changeset
|
4080 break; |
98b9a6b9e7d5
Add completion for ":ownsyntax" and improve completion for ":filetype".
Bram Moolenaar <bram@vim.org>
parents:
2406
diff
changeset
|
4081 |
2406
bbff28ebfc7a
Add completion for :setfiletype. (Dominique Pelle)
Bram Moolenaar <bram@vim.org>
parents:
2405
diff
changeset
|
4082 case CMD_setfiletype: |
2268
aafed4a4866f
Command line completion for :ownsyntax. (Dominique Pelle)
Bram Moolenaar <bram@vim.org>
parents:
2250
diff
changeset
|
4083 xp->xp_context = EXPAND_FILETYPE; |
aafed4a4866f
Command line completion for :ownsyntax. (Dominique Pelle)
Bram Moolenaar <bram@vim.org>
parents:
2250
diff
changeset
|
4084 xp->xp_pattern = arg; |
aafed4a4866f
Command line completion for :ownsyntax. (Dominique Pelle)
Bram Moolenaar <bram@vim.org>
parents:
2250
diff
changeset
|
4085 break; |
aafed4a4866f
Command line completion for :ownsyntax. (Dominique Pelle)
Bram Moolenaar <bram@vim.org>
parents:
2250
diff
changeset
|
4086 |
8402
eed1ca42f9aa
commit https://github.com/vim/vim/commit/35ca0e7a1cb6e6daef8e0052a8437801226cef19
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
4087 case CMD_packadd: |
eed1ca42f9aa
commit https://github.com/vim/vim/commit/35ca0e7a1cb6e6daef8e0052a8437801226cef19
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
4088 xp->xp_context = EXPAND_PACKADD; |
eed1ca42f9aa
commit https://github.com/vim/vim/commit/35ca0e7a1cb6e6daef8e0052a8437801226cef19
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
4089 xp->xp_pattern = arg; |
eed1ca42f9aa
commit https://github.com/vim/vim/commit/35ca0e7a1cb6e6daef8e0052a8437801226cef19
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
4090 break; |
eed1ca42f9aa
commit https://github.com/vim/vim/commit/35ca0e7a1cb6e6daef8e0052a8437801226cef19
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
4091 |
15597
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15595
diff
changeset
|
4092 #if defined(HAVE_LOCALE_H) || defined(X_LOCALE) |
7 | 4093 case CMD_language: |
2853 | 4094 p = skiptowhite(arg); |
4095 if (*p == NUL) | |
7 | 4096 { |
4097 xp->xp_context = EXPAND_LANGUAGE; | |
4098 xp->xp_pattern = arg; | |
4099 } | |
4100 else | |
2853 | 4101 { |
4102 if ( STRNCMP(arg, "messages", p - arg) == 0 | |
4103 || STRNCMP(arg, "ctype", p - arg) == 0 | |
4104 || STRNCMP(arg, "time", p - arg) == 0) | |
4105 { | |
4106 xp->xp_context = EXPAND_LOCALES; | |
4107 xp->xp_pattern = skipwhite(p); | |
4108 } | |
4109 else | |
4110 xp->xp_context = EXPAND_NOTHING; | |
4111 } | |
7 | 4112 break; |
4113 #endif | |
2068
98a2a6e6b966
updated for version 7.2.353
Bram Moolenaar <bram@zimbu.org>
parents:
1973
diff
changeset
|
4114 #if defined(FEAT_PROFILE) |
98a2a6e6b966
updated for version 7.2.353
Bram Moolenaar <bram@zimbu.org>
parents:
1973
diff
changeset
|
4115 case CMD_profile: |
98a2a6e6b966
updated for version 7.2.353
Bram Moolenaar <bram@zimbu.org>
parents:
1973
diff
changeset
|
4116 set_context_in_profile_cmd(xp, arg); |
98a2a6e6b966
updated for version 7.2.353
Bram Moolenaar <bram@zimbu.org>
parents:
1973
diff
changeset
|
4117 break; |
98a2a6e6b966
updated for version 7.2.353
Bram Moolenaar <bram@zimbu.org>
parents:
1973
diff
changeset
|
4118 #endif |
2097
8f72e3512b43
updated for version 7.2.381
Bram Moolenaar <bram@zimbu.org>
parents:
2068
diff
changeset
|
4119 case CMD_behave: |
8f72e3512b43
updated for version 7.2.381
Bram Moolenaar <bram@zimbu.org>
parents:
2068
diff
changeset
|
4120 xp->xp_context = EXPAND_BEHAVE; |
3503 | 4121 xp->xp_pattern = arg; |
2097
8f72e3512b43
updated for version 7.2.381
Bram Moolenaar <bram@zimbu.org>
parents:
2068
diff
changeset
|
4122 break; |
7 | 4123 |
10275
6d8b2da002e9
commit https://github.com/vim/vim/commit/9e507ca8a3e1535e62de4bd86374b0fcd18ef5b8
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
4124 case CMD_messages: |
6d8b2da002e9
commit https://github.com/vim/vim/commit/9e507ca8a3e1535e62de4bd86374b0fcd18ef5b8
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
4125 xp->xp_context = EXPAND_MESSAGES; |
6d8b2da002e9
commit https://github.com/vim/vim/commit/9e507ca8a3e1535e62de4bd86374b0fcd18ef5b8
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
4126 xp->xp_pattern = arg; |
6d8b2da002e9
commit https://github.com/vim/vim/commit/9e507ca8a3e1535e62de4bd86374b0fcd18ef5b8
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
4127 break; |
6d8b2da002e9
commit https://github.com/vim/vim/commit/9e507ca8a3e1535e62de4bd86374b0fcd18ef5b8
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
4128 |
3503 | 4129 case CMD_history: |
4130 xp->xp_context = EXPAND_HISTORY; | |
4131 xp->xp_pattern = arg; | |
4132 break; | |
4803
220bdea4f579
updated for version 7.3.1148
Bram Moolenaar <bram@vim.org>
parents:
4766
diff
changeset
|
4133 #if defined(FEAT_PROFILE) |
220bdea4f579
updated for version 7.3.1148
Bram Moolenaar <bram@vim.org>
parents:
4766
diff
changeset
|
4134 case CMD_syntime: |
220bdea4f579
updated for version 7.3.1148
Bram Moolenaar <bram@vim.org>
parents:
4766
diff
changeset
|
4135 xp->xp_context = EXPAND_SYNTIME; |
220bdea4f579
updated for version 7.3.1148
Bram Moolenaar <bram@vim.org>
parents:
4766
diff
changeset
|
4136 xp->xp_pattern = arg; |
220bdea4f579
updated for version 7.3.1148
Bram Moolenaar <bram@vim.org>
parents:
4766
diff
changeset
|
4137 break; |
220bdea4f579
updated for version 7.3.1148
Bram Moolenaar <bram@vim.org>
parents:
4766
diff
changeset
|
4138 #endif |
3503 | 4139 |
13551
1fd0f8392946
patch 8.0.1649: no completion for argument list commands
Christian Brabandt <cb@256bit.org>
parents:
13442
diff
changeset
|
4140 case CMD_argdelete: |
1fd0f8392946
patch 8.0.1649: no completion for argument list commands
Christian Brabandt <cb@256bit.org>
parents:
13442
diff
changeset
|
4141 while ((xp->xp_pattern = vim_strchr(arg, ' ')) != NULL) |
1fd0f8392946
patch 8.0.1649: no completion for argument list commands
Christian Brabandt <cb@256bit.org>
parents:
13442
diff
changeset
|
4142 arg = xp->xp_pattern + 1; |
1fd0f8392946
patch 8.0.1649: no completion for argument list commands
Christian Brabandt <cb@256bit.org>
parents:
13442
diff
changeset
|
4143 xp->xp_context = EXPAND_ARGLIST; |
1fd0f8392946
patch 8.0.1649: no completion for argument list commands
Christian Brabandt <cb@256bit.org>
parents:
13442
diff
changeset
|
4144 xp->xp_pattern = arg; |
1fd0f8392946
patch 8.0.1649: no completion for argument list commands
Christian Brabandt <cb@256bit.org>
parents:
13442
diff
changeset
|
4145 break; |
1fd0f8392946
patch 8.0.1649: no completion for argument list commands
Christian Brabandt <cb@256bit.org>
parents:
13442
diff
changeset
|
4146 |
7 | 4147 #endif /* FEAT_CMDL_COMPL */ |
4148 | |
4149 default: | |
4150 break; | |
4151 } | |
4152 return NULL; | |
4153 } | |
4154 | |
4155 /* | |
14505
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
4156 * Skip a range specifier of the form: addr [,addr] [;addr] .. |
7 | 4157 * |
4158 * Backslashed delimiters after / or ? will be skipped, and commands will | |
4159 * not be expanded between /'s and ?'s or after "'". | |
4160 * | |
167 | 4161 * Also skip white space and ":" characters. |
7 | 4162 * Returns the "cmd" pointer advanced to beyond the range. |
4163 */ | |
4164 char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4165 skip_range( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4166 char_u *cmd, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4167 int *ctx) /* pointer to xp_context or NULL */ |
7 | 4168 { |
1872 | 4169 unsigned delim; |
7 | 4170 |
10817
cc8079703414
patch 8.0.0298: Ex command range with repeated search does not work
Christian Brabandt <cb@256bit.org>
parents:
10809
diff
changeset
|
4171 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
|
4172 { |
cc8079703414
patch 8.0.0298: Ex command range with repeated search does not work
Christian Brabandt <cb@256bit.org>
parents:
10809
diff
changeset
|
4173 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
|
4174 { |
cc8079703414
patch 8.0.0298: Ex command range with repeated search does not work
Christian Brabandt <cb@256bit.org>
parents:
10809
diff
changeset
|
4175 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
|
4176 ++cmd; |
cc8079703414
patch 8.0.0298: Ex command range with repeated search does not work
Christian Brabandt <cb@256bit.org>
parents:
10809
diff
changeset
|
4177 else |
cc8079703414
patch 8.0.0298: Ex command range with repeated search does not work
Christian Brabandt <cb@256bit.org>
parents:
10809
diff
changeset
|
4178 break; |
cc8079703414
patch 8.0.0298: Ex command range with repeated search does not work
Christian Brabandt <cb@256bit.org>
parents:
10809
diff
changeset
|
4179 } |
cc8079703414
patch 8.0.0298: Ex command range with repeated search does not work
Christian Brabandt <cb@256bit.org>
parents:
10809
diff
changeset
|
4180 else if (*cmd == '\'') |
7 | 4181 { |
4182 if (*++cmd == NUL && ctx != NULL) | |
4183 *ctx = EXPAND_NOTHING; | |
4184 } | |
4185 else if (*cmd == '/' || *cmd == '?') | |
4186 { | |
4187 delim = *cmd++; | |
4188 while (*cmd != NUL && *cmd != delim) | |
4189 if (*cmd++ == '\\' && *cmd != NUL) | |
4190 ++cmd; | |
4191 if (*cmd == NUL && ctx != NULL) | |
4192 *ctx = EXPAND_NOTHING; | |
4193 } | |
4194 if (*cmd != NUL) | |
4195 ++cmd; | |
4196 } | |
167 | 4197 |
4198 /* Skip ":" and white space. */ | |
4199 while (*cmd == ':') | |
4200 cmd = skipwhite(cmd + 1); | |
4201 | |
7 | 4202 return cmd; |
4203 } | |
4204 | |
17650
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
4205 static void |
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
4206 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
|
4207 { |
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
4208 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
|
4209 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
|
4210 else |
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
4211 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
|
4212 } |
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
4213 |
7 | 4214 /* |
14677
7771a1ff8b99
patch 8.1.0351: 'incsearch' for :/foo/s//<Esc> changes last search pattern
Christian Brabandt <cb@256bit.org>
parents:
14648
diff
changeset
|
4215 * Get a single EX address. |
7 | 4216 * |
4217 * Set ptr to the next character after the part that was interpreted. | |
4218 * 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
|
4219 * This may set the last used search pattern. |
7 | 4220 * |
4221 * Return MAXLNUM when no Ex address was found. | |
4222 */ | |
4223 static linenr_T | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4224 get_address( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4225 exarg_T *eap UNUSED, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4226 char_u **ptr, |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
4227 cmd_addr_T addr_type_arg, |
14760
fd69edd2c67e
patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents:
14700
diff
changeset
|
4228 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
|
4229 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
|
4230 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
|
4231 int address_count UNUSED) // 1 for first address, >1 after comma |
7 | 4232 { |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
4233 cmd_addr_T addr_type = addr_type_arg; |
7 | 4234 int c; |
4235 int i; | |
4236 long n; | |
4237 char_u *cmd; | |
4238 pos_T pos; | |
4239 pos_T *fp; | |
4240 linenr_T lnum; | |
6424 | 4241 buf_T *buf; |
7 | 4242 |
4243 cmd = skipwhite(*ptr); | |
4244 lnum = MAXLNUM; | |
4245 do | |
4246 { | |
4247 switch (*cmd) | |
4248 { | |
4249 case '.': /* '.' - Cursor position */ | |
6398 | 4250 ++cmd; |
4251 switch (addr_type) | |
4252 { | |
4253 case ADDR_LINES: | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
4254 case ADDR_OTHER: |
7 | 4255 lnum = curwin->w_cursor.lnum; |
4256 break; | |
6398 | 4257 case ADDR_WINDOWS: |
6409 | 4258 lnum = CURRENT_WIN_NR; |
6398 | 4259 break; |
4260 case ADDR_ARGUMENTS: | |
4261 lnum = curwin->w_arg_idx + 1; | |
4262 break; | |
4263 case ADDR_LOADED_BUFFERS: | |
6424 | 4264 case ADDR_BUFFERS: |
6398 | 4265 lnum = curbuf->b_fnum; |
4266 break; | |
4267 case ADDR_TABS: | |
6409 | 4268 lnum = CURRENT_TAB_NR; |
6398 | 4269 break; |
17650
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
4270 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
|
4271 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
|
4272 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
|
4273 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
|
4274 cmd = NULL; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
4275 goto error; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
4276 break; |
16479
7dcf301d1432
patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents:
16475
diff
changeset
|
4277 case ADDR_QUICKFIX: |
7105
f4456e686406
commit https://github.com/vim/vim/commit/e906c502079770ae0e0071c74cefb802689ff193
Christian Brabandt <cb@256bit.org>
parents:
7092
diff
changeset
|
4278 #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
|
4279 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
|
4280 #endif |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
4281 break; |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
4282 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
|
4283 #ifdef FEAT_QUICKFIX |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
4284 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
|
4285 #endif |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
4286 break; |
6398 | 4287 } |
4288 break; | |
7 | 4289 |
4290 case '$': /* '$' - last line */ | |
6398 | 4291 ++cmd; |
4292 switch (addr_type) | |
4293 { | |
4294 case ADDR_LINES: | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
4295 case ADDR_OTHER: |
7 | 4296 lnum = curbuf->b_ml.ml_line_count; |
4297 break; | |
6398 | 4298 case ADDR_WINDOWS: |
6409 | 4299 lnum = LAST_WIN_NR; |
6398 | 4300 break; |
4301 case ADDR_ARGUMENTS: | |
4302 lnum = ARGCOUNT; | |
4303 break; | |
4304 case ADDR_LOADED_BUFFERS: | |
6424 | 4305 buf = lastbuf; |
4306 while (buf->b_ml.ml_mfp == NULL) | |
4307 { | |
4308 if (buf->b_prev == NULL) | |
4309 break; | |
4310 buf = buf->b_prev; | |
4311 } | |
4312 lnum = buf->b_fnum; | |
4313 break; | |
4314 case ADDR_BUFFERS: | |
6398 | 4315 lnum = lastbuf->b_fnum; |
4316 break; | |
4317 case ADDR_TABS: | |
6409 | 4318 lnum = LAST_TAB_NR; |
6398 | 4319 break; |
17650
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
4320 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
|
4321 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
|
4322 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
|
4323 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
|
4324 cmd = NULL; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
4325 goto error; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
4326 break; |
16479
7dcf301d1432
patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents:
16475
diff
changeset
|
4327 case ADDR_QUICKFIX: |
7105
f4456e686406
commit https://github.com/vim/vim/commit/e906c502079770ae0e0071c74cefb802689ff193
Christian Brabandt <cb@256bit.org>
parents:
7092
diff
changeset
|
4328 #ifdef FEAT_QUICKFIX |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
4329 lnum = qf_get_size(eap); |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
4330 if (lnum == 0) |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
4331 lnum = 1; |
16479
7dcf301d1432
patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents:
16475
diff
changeset
|
4332 #endif |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
4333 break; |
16515
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
4334 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
|
4335 #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
|
4336 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
|
4337 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
|
4338 lnum = 1; |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
4339 #endif |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
4340 break; |
6398 | 4341 } |
4342 break; | |
7 | 4343 |
4344 case '\'': /* ''' - mark */ | |
6398 | 4345 if (*++cmd == NUL) |
4346 { | |
4347 cmd = NULL; | |
4348 goto error; | |
4349 } | |
4350 if (addr_type != ADDR_LINES) | |
4351 { | |
17650
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
4352 addr_error(addr_type); |
6581 | 4353 cmd = NULL; |
6398 | 4354 goto error; |
4355 } | |
4356 if (skip) | |
4357 ++cmd; | |
4358 else | |
4359 { | |
4360 /* Only accept a mark in another file when it is | |
4361 * used by itself: ":'M". */ | |
4362 fp = getmark(*cmd, to_other_file && cmd[1] == NUL); | |
4363 ++cmd; | |
4364 if (fp == (pos_T *)-1) | |
4365 /* Jumped to another file. */ | |
4366 lnum = curwin->w_cursor.lnum; | |
4367 else | |
4368 { | |
4369 if (check_mark(fp) == FAIL) | |
7 | 4370 { |
4371 cmd = NULL; | |
4372 goto error; | |
4373 } | |
6398 | 4374 lnum = fp->lnum; |
4375 } | |
4376 } | |
4377 break; | |
7 | 4378 |
4379 case '/': | |
4380 case '?': /* '/' or '?' - search */ | |
6398 | 4381 c = *cmd++; |
4382 if (addr_type != ADDR_LINES) | |
4383 { | |
17650
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
4384 addr_error(addr_type); |
6581 | 4385 cmd = NULL; |
6398 | 4386 goto error; |
4387 } | |
4388 if (skip) /* skip "/pat/" */ | |
4389 { | |
4390 cmd = skip_regexp(cmd, c, (int)p_magic, NULL); | |
4391 if (*cmd == c) | |
4392 ++cmd; | |
4393 } | |
4394 else | |
4395 { | |
14760
fd69edd2c67e
patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents:
14700
diff
changeset
|
4396 int flags; |
fd69edd2c67e
patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents:
14700
diff
changeset
|
4397 |
fd69edd2c67e
patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents:
14700
diff
changeset
|
4398 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
|
4399 |
fd69edd2c67e
patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents:
14700
diff
changeset
|
4400 // 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
|
4401 // there. |
6398 | 4402 if (lnum != MAXLNUM) |
4403 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
|
4404 |
fd69edd2c67e
patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents:
14700
diff
changeset
|
4405 // 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
|
4406 // 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
|
4407 // 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
|
4408 // 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
|
4409 // 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
|
4410 // next/previous line. |
13082
a80082fd1a1d
patch 8.0.1416: crash when searching for a sentence
Christian Brabandt <cb@256bit.org>
parents:
12824
diff
changeset
|
4411 if (c == '/' && curwin->w_cursor.lnum > 0) |
6398 | 4412 curwin->w_cursor.col = MAXCOL; |
4413 else | |
4414 curwin->w_cursor.col = 0; | |
4415 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
|
4416 flags = silent ? 0 : SEARCH_HIS | SEARCH_MSG; |
fd69edd2c67e
patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents:
14700
diff
changeset
|
4417 if (!do_search(NULL, c, cmd, 1L, flags, NULL, NULL)) |
6398 | 4418 { |
4419 curwin->w_cursor = pos; | |
4420 cmd = NULL; | |
4421 goto error; | |
4422 } | |
4423 lnum = curwin->w_cursor.lnum; | |
4424 curwin->w_cursor = pos; | |
4425 /* adjust command string pointer */ | |
4426 cmd += searchcmdlen; | |
4427 } | |
4428 break; | |
7 | 4429 |
4430 case '\\': /* "\?", "\/" or "\&", repeat search */ | |
6398 | 4431 ++cmd; |
4432 if (addr_type != ADDR_LINES) | |
4433 { | |
17650
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
4434 addr_error(addr_type); |
6581 | 4435 cmd = NULL; |
6398 | 4436 goto error; |
4437 } | |
4438 if (*cmd == '&') | |
4439 i = RE_SUBST; | |
4440 else if (*cmd == '?' || *cmd == '/') | |
4441 i = RE_SEARCH; | |
4442 else | |
4443 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
4444 emsg(_(e_backslash)); |
6398 | 4445 cmd = NULL; |
4446 goto error; | |
4447 } | |
4448 | |
4449 if (!skip) | |
4450 { | |
4451 /* | |
4452 * When search follows another address, start from | |
4453 * there. | |
4454 */ | |
4455 if (lnum != MAXLNUM) | |
4456 pos.lnum = lnum; | |
4457 else | |
4458 pos.lnum = curwin->w_cursor.lnum; | |
4459 | |
4460 /* | |
4461 * Start the search just like for the above | |
4462 * do_search(). | |
4463 */ | |
4464 if (*cmd != '?') | |
4465 pos.col = MAXCOL; | |
4466 else | |
4467 pos.col = 0; | |
7007 | 4468 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
|
4469 if (searchit(curwin, curbuf, &pos, NULL, |
6398 | 4470 *cmd == '?' ? BACKWARD : FORWARD, |
4471 (char_u *)"", 1L, SEARCH_MSG, | |
11521
578df034735d
patch 8.0.0643: when a pattern search is slow Vim becomes unusable
Christian Brabandt <cb@256bit.org>
parents:
11463
diff
changeset
|
4472 i, (linenr_T)0, NULL, NULL) != FAIL) |
6398 | 4473 lnum = pos.lnum; |
4474 else | |
4475 { | |
4476 cmd = NULL; | |
4477 goto error; | |
4478 } | |
4479 } | |
4480 ++cmd; | |
4481 break; | |
7 | 4482 |
4483 default: | |
6398 | 4484 if (VIM_ISDIGIT(*cmd)) /* absolute line number */ |
4485 lnum = getdigits(&cmd); | |
7 | 4486 } |
4487 | |
4488 for (;;) | |
4489 { | |
4490 cmd = skipwhite(cmd); | |
4491 if (*cmd != '-' && *cmd != '+' && !VIM_ISDIGIT(*cmd)) | |
4492 break; | |
4493 | |
4494 if (lnum == MAXLNUM) | |
6398 | 4495 { |
4496 switch (addr_type) | |
4497 { | |
4498 case ADDR_LINES: | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
4499 case ADDR_OTHER: |
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
4500 // "+1" is same as ".+1" |
6409 | 4501 lnum = curwin->w_cursor.lnum; |
6398 | 4502 break; |
4503 case ADDR_WINDOWS: | |
6409 | 4504 lnum = CURRENT_WIN_NR; |
6398 | 4505 break; |
4506 case ADDR_ARGUMENTS: | |
4507 lnum = curwin->w_arg_idx + 1; | |
4508 break; | |
4509 case ADDR_LOADED_BUFFERS: | |
6424 | 4510 case ADDR_BUFFERS: |
6398 | 4511 lnum = curbuf->b_fnum; |
4512 break; | |
4513 case ADDR_TABS: | |
6409 | 4514 lnum = CURRENT_TAB_NR; |
6398 | 4515 break; |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
4516 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
|
4517 lnum = 1; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
4518 break; |
16479
7dcf301d1432
patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents:
16475
diff
changeset
|
4519 case ADDR_QUICKFIX: |
7105
f4456e686406
commit https://github.com/vim/vim/commit/e906c502079770ae0e0071c74cefb802689ff193
Christian Brabandt <cb@256bit.org>
parents:
7092
diff
changeset
|
4520 #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
|
4521 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
|
4522 #endif |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
4523 break; |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
4524 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
|
4525 #ifdef FEAT_QUICKFIX |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
4526 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
|
4527 #endif |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
4528 break; |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
4529 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
|
4530 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
|
4531 lnum = 0; |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
4532 break; |
6398 | 4533 } |
4534 } | |
4535 | |
7 | 4536 if (VIM_ISDIGIT(*cmd)) |
4537 i = '+'; /* "number" is same as "+number" */ | |
4538 else | |
4539 i = *cmd++; | |
4540 if (!VIM_ISDIGIT(*cmd)) /* '+' is '+1', but '+0' is not '+1' */ | |
4541 n = 1; | |
4542 else | |
4543 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
|
4544 |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
4545 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
|
4546 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
4547 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
|
4548 cmd = NULL; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
4549 goto error; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
4550 } |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
4551 else if (addr_type == ADDR_LOADED_BUFFERS |
6424 | 4552 || addr_type == ADDR_BUFFERS) |
6581 | 4553 lnum = compute_buffer_local_count( |
4554 addr_type, lnum, (i == '-') ? -1 * n : n); | |
7 | 4555 else |
10484
c7de1536780a
commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
10480
diff
changeset
|
4556 { |
c7de1536780a
commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
10480
diff
changeset
|
4557 #ifdef FEAT_FOLDING |
c7de1536780a
commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
10480
diff
changeset
|
4558 /* Relative line addressing, need to adjust for folded lines |
c7de1536780a
commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
10480
diff
changeset
|
4559 * now, but only do it after the first address. */ |
c7de1536780a
commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
10480
diff
changeset
|
4560 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
|
4561 && address_count >= 2) |
c7de1536780a
commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
10480
diff
changeset
|
4562 (void)hasFolding(lnum, NULL, &lnum); |
c7de1536780a
commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
10480
diff
changeset
|
4563 #endif |
c7de1536780a
commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
10480
diff
changeset
|
4564 if (i == '-') |
c7de1536780a
commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
10480
diff
changeset
|
4565 lnum -= n; |
c7de1536780a
commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
10480
diff
changeset
|
4566 else |
c7de1536780a
commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
10480
diff
changeset
|
4567 lnum += n; |
c7de1536780a
commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
10480
diff
changeset
|
4568 } |
7 | 4569 } |
4570 } while (*cmd == '/' || *cmd == '?'); | |
4571 | |
4572 error: | |
4573 *ptr = cmd; | |
4574 return lnum; | |
4575 } | |
4576 | |
4577 /* | |
167 | 4578 * Get flags from an Ex command argument. |
4579 */ | |
4580 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4581 get_flags(exarg_T *eap) |
167 | 4582 { |
4583 while (vim_strchr((char_u *)"lp#", *eap->arg) != NULL) | |
4584 { | |
4585 if (*eap->arg == 'l') | |
4586 eap->flags |= EXFLAG_LIST; | |
4587 else if (*eap->arg == 'p') | |
4588 eap->flags |= EXFLAG_PRINT; | |
4589 else | |
4590 eap->flags |= EXFLAG_NR; | |
4591 eap->arg = skipwhite(eap->arg + 1); | |
4592 } | |
4593 } | |
4594 | |
4595 /* | |
7 | 4596 * Function called for command which is Not Implemented. NI! |
4597 */ | |
4598 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4599 ex_ni(exarg_T *eap) |
7 | 4600 { |
4601 if (!eap->skip) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
4602 eap->errmsg = N_("E319: Sorry, the command is not available in this version"); |
7 | 4603 } |
4604 | |
1315 | 4605 #ifdef HAVE_EX_SCRIPT_NI |
7 | 4606 /* |
4607 * Function called for script command which is Not Implemented. NI! | |
4608 * Skips over ":perl <<EOF" constructs. | |
4609 */ | |
4610 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4611 ex_script_ni(exarg_T *eap) |
7 | 4612 { |
4613 if (!eap->skip) | |
4614 ex_ni(eap); | |
4615 else | |
4616 vim_free(script_get(eap, eap->arg)); | |
4617 } | |
4618 #endif | |
4619 | |
4620 /* | |
4621 * Check range in Ex command for validity. | |
4622 * Return NULL when valid, error message when invalid. | |
4623 */ | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
4624 static char * |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4625 invalid_range(exarg_T *eap) |
7 | 4626 { |
6472 | 4627 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
|
4628 |
7 | 4629 if ( eap->line1 < 0 |
4630 || eap->line2 < 0 | |
6472 | 4631 || 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
|
4632 return _(e_invrange); |
6472 | 4633 |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
4634 if (eap->argt & EX_RANGE) |
6472 | 4635 { |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
4636 switch (eap->addr_type) |
6472 | 4637 { |
4638 case ADDR_LINES: | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
4639 if (eap->line2 > curbuf->b_ml.ml_line_count |
7 | 4640 #ifdef FEAT_DIFF |
6472 | 4641 + (eap->cmdidx == CMD_diffget) |
4642 #endif | |
4643 ) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
4644 return _(e_invrange); |
6472 | 4645 break; |
4646 case ADDR_ARGUMENTS: | |
6581 | 4647 /* add 1 if ARGCOUNT is 0 */ |
4648 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
|
4649 return _(e_invrange); |
6472 | 4650 break; |
4651 case ADDR_BUFFERS: | |
4652 if (eap->line1 < firstbuf->b_fnum | |
4653 || eap->line2 > lastbuf->b_fnum) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
4654 return _(e_invrange); |
6472 | 4655 break; |
4656 case ADDR_LOADED_BUFFERS: | |
4657 buf = firstbuf; | |
4658 while (buf->b_ml.ml_mfp == NULL) | |
4659 { | |
4660 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
|
4661 return _(e_invrange); |
6472 | 4662 buf = buf->b_next; |
4663 } | |
4664 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
|
4665 return _(e_invrange); |
6472 | 4666 buf = lastbuf; |
4667 while (buf->b_ml.ml_mfp == NULL) | |
4668 { | |
4669 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
|
4670 return _(e_invrange); |
6472 | 4671 buf = buf->b_prev; |
4672 } | |
4673 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
|
4674 return _(e_invrange); |
6472 | 4675 break; |
4676 case ADDR_WINDOWS: | |
6480 | 4677 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
|
4678 return _(e_invrange); |
6472 | 4679 break; |
4680 case ADDR_TABS: | |
4681 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
|
4682 return _(e_invrange); |
6472 | 4683 break; |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
4684 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
|
4685 case ADDR_OTHER: |
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
4686 // 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
|
4687 break; |
16479
7dcf301d1432
patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents:
16475
diff
changeset
|
4688 case ADDR_QUICKFIX: |
7105
f4456e686406
commit https://github.com/vim/vim/commit/e906c502079770ae0e0071c74cefb802689ff193
Christian Brabandt <cb@256bit.org>
parents:
7092
diff
changeset
|
4689 #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
|
4690 // 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
|
4691 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
|
4692 return _(e_invrange); |
16479
7dcf301d1432
patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents:
16475
diff
changeset
|
4693 #endif |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
4694 break; |
16515
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
4695 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
|
4696 #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
|
4697 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
|
4698 || 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
|
4699 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
|
4700 #endif |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
4701 break; |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
4702 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
|
4703 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
|
4704 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
|
4705 break; |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
4706 case ADDR_NONE: |
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
4707 // 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
|
4708 break; |
6472 | 4709 } |
4710 } | |
7 | 4711 return NULL; |
4712 } | |
4713 | |
4714 /* | |
4715 * Correct the range for zero line number, if required. | |
4716 */ | |
4717 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4718 correct_range(exarg_T *eap) |
7 | 4719 { |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
4720 if (!(eap->argt & EX_ZEROR)) // zero in range not allowed |
7 | 4721 { |
4722 if (eap->line1 == 0) | |
4723 eap->line1 = 1; | |
4724 if (eap->line2 == 0) | |
4725 eap->line2 = 1; | |
4726 } | |
4727 } | |
4728 | |
153 | 4729 #ifdef FEAT_QUICKFIX |
4730 /* | |
4731 * For a ":vimgrep" or ":vimgrepadd" command return a pointer past the | |
4732 * pattern. Otherwise return eap->arg. | |
4733 */ | |
4734 static char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4735 skip_grep_pat(exarg_T *eap) |
153 | 4736 { |
4737 char_u *p = eap->arg; | |
4738 | |
655 | 4739 if (*p != NUL && (eap->cmdidx == CMD_vimgrep || eap->cmdidx == CMD_lvimgrep |
4740 || eap->cmdidx == CMD_vimgrepadd | |
4741 || eap->cmdidx == CMD_lvimgrepadd | |
4742 || grep_internal(eap->cmdidx))) | |
153 | 4743 { |
170 | 4744 p = skip_vimgrep_pat(p, NULL, NULL); |
153 | 4745 if (p == NULL) |
4746 p = eap->arg; | |
4747 } | |
4748 return p; | |
4749 } | |
344 | 4750 |
4751 /* | |
4752 * For the ":make" and ":grep" commands insert the 'makeprg'/'grepprg' option | |
4753 * in the command line, so that things like % get expanded. | |
4754 */ | |
4755 static char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4756 replace_makeprg(exarg_T *eap, char_u *p, char_u **cmdlinep) |
344 | 4757 { |
4758 char_u *new_cmdline; | |
4759 char_u *program; | |
4760 char_u *pos; | |
4761 char_u *ptr; | |
4762 int len; | |
4763 int i; | |
4764 | |
4765 /* | |
4766 * Don't do it when ":vimgrep" is used for ":grep". | |
4767 */ | |
655 | 4768 if ((eap->cmdidx == CMD_make || eap->cmdidx == CMD_lmake |
4769 || eap->cmdidx == CMD_grep || eap->cmdidx == CMD_lgrep | |
4770 || eap->cmdidx == CMD_grepadd | |
4771 || eap->cmdidx == CMD_lgrepadd) | |
344 | 4772 && !grep_internal(eap->cmdidx)) |
4773 { | |
655 | 4774 if (eap->cmdidx == CMD_grep || eap->cmdidx == CMD_lgrep |
4775 || eap->cmdidx == CMD_grepadd || eap->cmdidx == CMD_lgrepadd) | |
344 | 4776 { |
4777 if (*curbuf->b_p_gp == NUL) | |
4778 program = p_gp; | |
4779 else | |
4780 program = curbuf->b_p_gp; | |
4781 } | |
4782 else | |
4783 { | |
4784 if (*curbuf->b_p_mp == NUL) | |
4785 program = p_mp; | |
4786 else | |
4787 program = curbuf->b_p_mp; | |
4788 } | |
4789 | |
4790 p = skipwhite(p); | |
4791 | |
4792 if ((pos = (char_u *)strstr((char *)program, "$*")) != NULL) | |
4793 { | |
4794 /* replace $* by given arguments */ | |
4795 i = 1; | |
4796 while ((pos = (char_u *)strstr((char *)pos + 2, "$*")) != NULL) | |
4797 ++i; | |
4798 len = (int)STRLEN(p); | |
16782
fc58fee685e2
patch 8.1.1393: unnecessary type casts
Bram Moolenaar <Bram@vim.org>
parents:
16780
diff
changeset
|
4799 new_cmdline = alloc(STRLEN(program) + i * (len - 2) + 1); |
344 | 4800 if (new_cmdline == NULL) |
4801 return NULL; /* out of memory */ | |
4802 ptr = new_cmdline; | |
4803 while ((pos = (char_u *)strstr((char *)program, "$*")) != NULL) | |
4804 { | |
4805 i = (int)(pos - program); | |
4806 STRNCPY(ptr, program, i); | |
4807 STRCPY(ptr += i, p); | |
4808 ptr += len; | |
4809 program = pos + 2; | |
4810 } | |
4811 STRCPY(ptr, program); | |
4812 } | |
4813 else | |
4814 { | |
16782
fc58fee685e2
patch 8.1.1393: unnecessary type casts
Bram Moolenaar <Bram@vim.org>
parents:
16780
diff
changeset
|
4815 new_cmdline = alloc(STRLEN(program) + STRLEN(p) + 2); |
344 | 4816 if (new_cmdline == NULL) |
4817 return NULL; /* out of memory */ | |
4818 STRCPY(new_cmdline, program); | |
4819 STRCAT(new_cmdline, " "); | |
4820 STRCAT(new_cmdline, p); | |
4821 } | |
4822 msg_make(p); | |
4823 | |
4824 /* 'eap->cmd' is not set here, because it is not used at CMD_make */ | |
4825 vim_free(*cmdlinep); | |
4826 *cmdlinep = new_cmdline; | |
4827 p = new_cmdline; | |
4828 } | |
4829 return p; | |
4830 } | |
153 | 4831 #endif |
4832 | |
7 | 4833 /* |
4834 * 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
|
4835 * When an error is detected, "errormsgp" is set to a non-NULL pointer. |
7 | 4836 * Return FAIL for failure, OK otherwise. |
4837 */ | |
4838 int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4839 expand_filename( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4840 exarg_T *eap, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4841 char_u **cmdlinep, |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
4842 char **errormsgp) |
7 | 4843 { |
4844 int has_wildcards; /* need to expand wildcards */ | |
4845 char_u *repl; | |
4846 int srclen; | |
4847 char_u *p; | |
4848 int n; | |
1098 | 4849 int escaped; |
7 | 4850 |
153 | 4851 #ifdef FEAT_QUICKFIX |
4852 /* Skip a regexp pattern for ":vimgrep[add] pat file..." */ | |
4853 p = skip_grep_pat(eap); | |
4854 #else | |
4855 p = eap->arg; | |
4856 #endif | |
4857 | |
7 | 4858 /* |
4859 * Decide to expand wildcards *before* replacing '%', '#', etc. If | |
4860 * the file name contains a wildcard it should not cause expanding. | |
4861 * (it will be expanded anyway if there is a wildcard before replacing). | |
4862 */ | |
153 | 4863 has_wildcards = mch_has_wildcard(p); |
4864 while (*p != NUL) | |
7 | 4865 { |
9 | 4866 #ifdef FEAT_EVAL |
4867 /* Skip over `=expr`, wildcards in it are not expanded. */ | |
4868 if (p[0] == '`' && p[1] == '=') | |
4869 { | |
4870 p += 2; | |
4871 (void)skip_expr(&p); | |
4872 if (*p == '`') | |
4873 ++p; | |
4874 continue; | |
4875 } | |
4876 #endif | |
7 | 4877 /* |
4878 * Quick check if this cannot be the start of a special string. | |
4879 * Also removes backslash before '%', '#' and '<'. | |
4880 */ | |
4881 if (vim_strchr((char_u *)"%#<", *p) == NULL) | |
4882 { | |
4883 ++p; | |
4884 continue; | |
4885 } | |
4886 | |
4887 /* | |
4888 * Try to find a match at this position. | |
4889 */ | |
1098 | 4890 repl = eval_vars(p, eap->arg, &srclen, &(eap->do_ecmd_lnum), |
4891 errormsgp, &escaped); | |
7 | 4892 if (*errormsgp != NULL) /* error detected */ |
4893 return FAIL; | |
4894 if (repl == NULL) /* no match found */ | |
4895 { | |
4896 p += srclen; | |
4897 continue; | |
4898 } | |
4899 | |
37 | 4900 /* Wildcards won't be expanded below, the replacement is taken |
4901 * literally. But do expand "~/file", "~user/file" and "$HOME/file". */ | |
4902 if (vim_strchr(repl, '$') != NULL || vim_strchr(repl, '~') != NULL) | |
4903 { | |
4904 char_u *l = repl; | |
4905 | |
4906 repl = expand_env_save(repl); | |
4907 vim_free(l); | |
4908 } | |
4909 | |
1098 | 4910 /* Need to escape white space et al. with a backslash. |
4911 * Don't do this for: | |
4912 * - replacement that already has been escaped: "##" | |
4913 * - shell commands (may have to use quotes instead). | |
4914 * - non-unix systems when there is a single argument (spaces don't | |
4915 * separate arguments then). | |
4916 */ | |
7 | 4917 if (!eap->usefilter |
1098 | 4918 && !escaped |
7 | 4919 && eap->cmdidx != CMD_bang |
4920 && 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
|
4921 && eap->cmdidx != CMD_grepadd |
1c1cb1e9b7b3
patch 8.0.0785: wildcards are not expanded for :terminal
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
4922 && eap->cmdidx != CMD_hardcopy |
655 | 4923 && eap->cmdidx != CMD_lgrep |
4924 && 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
|
4925 && eap->cmdidx != CMD_lmake |
1c1cb1e9b7b3
patch 8.0.0785: wildcards are not expanded for :terminal
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
4926 && eap->cmdidx != CMD_make |
1c1cb1e9b7b3
patch 8.0.0785: wildcards are not expanded for :terminal
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
4927 && eap->cmdidx != CMD_terminal |
7 | 4928 #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
|
4929 && !(eap->argt & EX_NOSPC) |
7 | 4930 #endif |
4931 ) | |
4932 { | |
4933 char_u *l; | |
4934 #ifdef BACKSLASH_IN_FILENAME | |
4935 /* Don't escape a backslash here, because rem_backslash() doesn't | |
4936 * remove it later. */ | |
4937 static char_u *nobslash = (char_u *)" \t\"|"; | |
4938 # define ESCAPE_CHARS nobslash | |
4939 #else | |
4940 # define ESCAPE_CHARS escape_chars | |
4941 #endif | |
4942 | |
4943 for (l = repl; *l; ++l) | |
4944 if (vim_strchr(ESCAPE_CHARS, *l) != NULL) | |
4945 { | |
4946 l = vim_strsave_escaped(repl, ESCAPE_CHARS); | |
4947 if (l != NULL) | |
4948 { | |
4949 vim_free(repl); | |
4950 repl = l; | |
4951 } | |
4952 break; | |
4953 } | |
4954 } | |
4955 | |
4956 /* 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
|
4957 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
|
4958 || eap->cmdidx == CMD_terminal) |
5778 | 4959 && vim_strpbrk(repl, (char_u *)"!") != NULL) |
7 | 4960 { |
4961 char_u *l; | |
4962 | |
5778 | 4963 l = vim_strsave_escaped(repl, (char_u *)"!"); |
7 | 4964 if (l != NULL) |
4965 { | |
4966 vim_free(repl); | |
4967 repl = l; | |
4968 } | |
4969 } | |
4970 | |
4971 p = repl_cmdline(eap, p, srclen, repl, cmdlinep); | |
4972 vim_free(repl); | |
4973 if (p == NULL) | |
4974 return FAIL; | |
4975 } | |
4976 | |
4977 /* | |
4978 * One file argument: Expand wildcards. | |
4979 * Don't do this with ":r !command" or ":w !command". | |
4980 */ | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
4981 if ((eap->argt & EX_NOSPC) && !eap->usefilter) |
7 | 4982 { |
4983 /* | |
4984 * May do this twice: | |
4985 * 1. Replace environment variables. | |
4986 * 2. Replace any other wildcards, remove backslashes. | |
4987 */ | |
4988 for (n = 1; n <= 2; ++n) | |
4989 { | |
4990 if (n == 2) | |
4991 { | |
4992 /* | |
4993 * Halve the number of backslashes (this is Vi compatible). | |
4994 * For Unix and OS/2, when wildcards are expanded, this is | |
4995 * done by ExpandOne() below. | |
4996 */ | |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7262
diff
changeset
|
4997 #if defined(UNIX) |
7 | 4998 if (!has_wildcards) |
4999 #endif | |
5000 backslash_halve(eap->arg); | |
5001 } | |
5002 | |
5003 if (has_wildcards) | |
5004 { | |
5005 if (n == 1) | |
5006 { | |
5007 /* | |
5008 * First loop: May expand environment variables. This | |
5009 * can be done much faster with expand_env() than with | |
5010 * something else (e.g., calling a shell). | |
5011 * After expanding environment variables, check again | |
5012 * if there are still wildcards present. | |
5013 */ | |
5014 if (vim_strchr(eap->arg, '$') != NULL | |
5015 || vim_strchr(eap->arg, '~') != NULL) | |
5016 { | |
372 | 5017 expand_env_esc(eap->arg, NameBuff, MAXPATHL, |
1408 | 5018 TRUE, TRUE, NULL); |
7 | 5019 has_wildcards = mch_has_wildcard(NameBuff); |
5020 p = NameBuff; | |
5021 } | |
5022 else | |
5023 p = NULL; | |
5024 } | |
5025 else /* n == 2 */ | |
5026 { | |
5027 expand_T xpc; | |
2652 | 5028 int options = WILD_LIST_NOTFOUND|WILD_ADD_SLASH; |
7 | 5029 |
5030 ExpandInit(&xpc); | |
5031 xpc.xp_context = EXPAND_FILES; | |
2652 | 5032 if (p_wic) |
5033 options += WILD_ICASE; | |
7 | 5034 p = ExpandOne(&xpc, eap->arg, NULL, |
2652 | 5035 options, WILD_EXPAND_FREE); |
7 | 5036 if (p == NULL) |
5037 return FAIL; | |
5038 } | |
5039 if (p != NULL) | |
5040 { | |
5041 (void)repl_cmdline(eap, eap->arg, (int)STRLEN(eap->arg), | |
5042 p, cmdlinep); | |
5043 if (n == 2) /* p came from ExpandOne() */ | |
5044 vim_free(p); | |
5045 } | |
5046 } | |
5047 } | |
5048 } | |
5049 return OK; | |
5050 } | |
5051 | |
5052 /* | |
5053 * Replace part of the command line, keeping eap->cmd, eap->arg and | |
5054 * eap->nextcmd correct. | |
5055 * "src" points to the part that is to be replaced, of length "srclen". | |
5056 * "repl" is the replacement string. | |
5057 * Returns a pointer to the character after the replaced string. | |
5058 * Returns NULL for failure. | |
5059 */ | |
5060 static char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5061 repl_cmdline( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5062 exarg_T *eap, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5063 char_u *src, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5064 int srclen, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5065 char_u *repl, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5066 char_u **cmdlinep) |
7 | 5067 { |
5068 int len; | |
5069 int i; | |
5070 char_u *new_cmdline; | |
5071 | |
5072 /* | |
5073 * The new command line is build in new_cmdline[]. | |
5074 * First allocate it. | |
5075 * Careful: a "+cmd" argument may have been NUL terminated. | |
5076 */ | |
5077 len = (int)STRLEN(repl); | |
5078 i = (int)(src - *cmdlinep) + (int)STRLEN(src + srclen) + len + 3; | |
698 | 5079 if (eap->nextcmd != NULL) |
7 | 5080 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
|
5081 if ((new_cmdline = alloc(i)) == NULL) |
7 | 5082 return NULL; /* out of memory! */ |
5083 | |
5084 /* | |
5085 * Copy the stuff before the expanded part. | |
5086 * Copy the expanded stuff. | |
5087 * Copy what came after the expanded part. | |
5088 * Copy the next commands, if there are any. | |
5089 */ | |
5090 i = (int)(src - *cmdlinep); /* length of part before match */ | |
5091 mch_memmove(new_cmdline, *cmdlinep, (size_t)i); | |
434 | 5092 |
7 | 5093 mch_memmove(new_cmdline + i, repl, (size_t)len); |
5094 i += len; /* remember the end of the string */ | |
5095 STRCPY(new_cmdline + i, src + srclen); | |
5096 src = new_cmdline + i; /* remember where to continue */ | |
5097 | |
698 | 5098 if (eap->nextcmd != NULL) /* append next command */ |
7 | 5099 { |
5100 i = (int)STRLEN(new_cmdline) + 1; | |
5101 STRCPY(new_cmdline + i, eap->nextcmd); | |
5102 eap->nextcmd = new_cmdline + i; | |
5103 } | |
5104 eap->cmd = new_cmdline + (eap->cmd - *cmdlinep); | |
5105 eap->arg = new_cmdline + (eap->arg - *cmdlinep); | |
5106 if (eap->do_ecmd_cmd != NULL && eap->do_ecmd_cmd != dollar_command) | |
5107 eap->do_ecmd_cmd = new_cmdline + (eap->do_ecmd_cmd - *cmdlinep); | |
5108 vim_free(*cmdlinep); | |
5109 *cmdlinep = new_cmdline; | |
5110 | |
5111 return src; | |
5112 } | |
5113 | |
5114 /* | |
5115 * Check for '|' to separate commands and '"' to start comments. | |
5116 */ | |
5117 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5118 separate_nextcmd(exarg_T *eap) |
7 | 5119 { |
5120 char_u *p; | |
5121 | |
153 | 5122 #ifdef FEAT_QUICKFIX |
5123 p = skip_grep_pat(eap); | |
5124 #else | |
41 | 5125 p = eap->arg; |
5126 #endif | |
5127 | |
11127
506f5d8b7d8b
patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11010
diff
changeset
|
5128 for ( ; *p; MB_PTR_ADV(p)) |
7 | 5129 { |
5130 if (*p == Ctrl_V) | |
5131 { | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
5132 if (eap->argt & (EX_CTRLV | EX_XFILE)) |
7 | 5133 ++p; /* skip CTRL-V and next char */ |
5134 else | |
1362 | 5135 /* remove CTRL-V and skip next char */ |
1619 | 5136 STRMOVE(p, p + 1); |
7 | 5137 if (*p == NUL) /* stop at NUL after CTRL-V */ |
5138 break; | |
5139 } | |
9 | 5140 |
5141 #ifdef FEAT_EVAL | |
5142 /* 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
|
5143 else if (p[0] == '`' && p[1] == '=' && (eap->argt & EX_XFILE)) |
9 | 5144 { |
5145 p += 2; | |
5146 (void)skip_expr(&p); | |
5147 } | |
5148 #endif | |
5149 | |
7 | 5150 /* Check for '"': start of comment or '|': next command */ |
5151 /* :@" and :*" do not start a comment! | |
5152 * :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
|
5153 else if ((*p == '"' && !(eap->argt & EX_NOTRLCOM) |
7 | 5154 && ((eap->cmdidx != CMD_at && eap->cmdidx != CMD_star) |
5155 || p != eap->arg) | |
5156 && (eap->cmdidx != CMD_redir | |
5157 || p != eap->arg + 1 || p[-1] != '@')) | |
5158 || *p == '|' || *p == '\n') | |
5159 { | |
5160 /* | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
5161 * We remove the '\' before the '|', unless EX_CTRLV is used |
7 | 5162 * AND 'b' is present in 'cpoptions'. |
5163 */ | |
5164 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
|
5165 || !(eap->argt & EX_CTRLV)) && *(p - 1) == '\\') |
7 | 5166 { |
1619 | 5167 STRMOVE(p - 1, p); /* remove the '\' */ |
7 | 5168 --p; |
5169 } | |
5170 else | |
5171 { | |
5172 eap->nextcmd = check_nextcmd(p); | |
5173 *p = NUL; | |
5174 break; | |
5175 } | |
5176 } | |
41 | 5177 } |
5178 | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
5179 if (!(eap->argt & EX_NOTRLCOM)) /* remove trailing spaces */ |
7 | 5180 del_trailing_spaces(eap->arg); |
5181 } | |
5182 | |
5183 /* | |
5184 * get + command from ex argument | |
5185 */ | |
5186 static char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5187 getargcmd(char_u **argp) |
7 | 5188 { |
5189 char_u *arg = *argp; | |
5190 char_u *command = NULL; | |
5191 | |
5192 if (*arg == '+') /* +[command] */ | |
5193 { | |
5194 ++arg; | |
5790 | 5195 if (vim_isspace(*arg) || *arg == NUL) |
7 | 5196 command = dollar_command; |
5197 else | |
5198 { | |
5199 command = arg; | |
5200 arg = skip_cmd_arg(command, TRUE); | |
5201 if (*arg != NUL) | |
5202 *arg++ = NUL; /* terminate command with NUL */ | |
5203 } | |
5204 | |
5205 arg = skipwhite(arg); /* skip over spaces */ | |
5206 *argp = arg; | |
5207 } | |
5208 return command; | |
5209 } | |
5210 | |
5211 /* | |
5212 * Find end of "+command" argument. Skip over "\ " and "\\". | |
5213 */ | |
5214 static char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5215 skip_cmd_arg( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5216 char_u *p, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5217 int rembs) /* TRUE to halve the number of backslashes */ |
7 | 5218 { |
5219 while (*p && !vim_isspace(*p)) | |
5220 { | |
5221 if (*p == '\\' && p[1] != NUL) | |
5222 { | |
5223 if (rembs) | |
1619 | 5224 STRMOVE(p, p + 1); |
7 | 5225 else |
5226 ++p; | |
5227 } | |
11127
506f5d8b7d8b
patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11010
diff
changeset
|
5228 MB_PTR_ADV(p); |
7 | 5229 } |
5230 return p; | |
5231 } | |
5232 | |
13575
4df23d9bad47
patch 8.0.1660: the terminal API "drop" command doesn't support options
Christian Brabandt <cb@256bit.org>
parents:
13553
diff
changeset
|
5233 int |
4df23d9bad47
patch 8.0.1660: the terminal API "drop" command doesn't support options
Christian Brabandt <cb@256bit.org>
parents:
13553
diff
changeset
|
5234 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
|
5235 { |
4df23d9bad47
patch 8.0.1660: the terminal API "drop" command doesn't support options
Christian Brabandt <cb@256bit.org>
parents:
13553
diff
changeset
|
5236 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
|
5237 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
|
5238 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
|
5239 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
|
5240 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
|
5241 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
|
5242 else |
c1ead25ed819
patch 8.1.0043: ++bad argument of :edit does not work properly
Christian Brabandt <cb@256bit.org>
parents:
14035
diff
changeset
|
5243 return FAIL; |
c1ead25ed819
patch 8.1.0043: ++bad argument of :edit does not work properly
Christian Brabandt <cb@256bit.org>
parents:
14035
diff
changeset
|
5244 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
|
5245 } |
4df23d9bad47
patch 8.0.1660: the terminal API "drop" command doesn't support options
Christian Brabandt <cb@256bit.org>
parents:
13553
diff
changeset
|
5246 |
7 | 5247 /* |
5248 * Get "++opt=arg" argument. | |
5249 * Return FAIL or OK. | |
5250 */ | |
5251 static int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5252 getargopt(exarg_T *eap) |
7 | 5253 { |
5254 char_u *arg = eap->arg + 2; | |
5255 int *pp = NULL; | |
2168 | 5256 int bad_char_idx; |
7 | 5257 char_u *p; |
5258 | |
5259 /* ":edit ++[no]bin[ary] file" */ | |
5260 if (STRNCMP(arg, "bin", 3) == 0 || STRNCMP(arg, "nobin", 5) == 0) | |
5261 { | |
5262 if (*arg == 'n') | |
5263 { | |
5264 arg += 2; | |
5265 eap->force_bin = FORCE_NOBIN; | |
5266 } | |
5267 else | |
5268 eap->force_bin = FORCE_BIN; | |
5269 if (!checkforcmd(&arg, "binary", 3)) | |
5270 return FAIL; | |
5271 eap->arg = skipwhite(arg); | |
5272 return OK; | |
5273 } | |
5274 | |
819 | 5275 /* ":read ++edit file" */ |
5276 if (STRNCMP(arg, "edit", 4) == 0) | |
5277 { | |
5278 eap->read_edit = TRUE; | |
5279 eap->arg = skipwhite(arg + 4); | |
5280 return OK; | |
5281 } | |
5282 | |
7 | 5283 if (STRNCMP(arg, "ff", 2) == 0) |
5284 { | |
5285 arg += 2; | |
5286 pp = &eap->force_ff; | |
5287 } | |
5288 else if (STRNCMP(arg, "fileformat", 10) == 0) | |
5289 { | |
5290 arg += 10; | |
5291 pp = &eap->force_ff; | |
5292 } | |
5293 else if (STRNCMP(arg, "enc", 3) == 0) | |
5294 { | |
3208 | 5295 if (STRNCMP(arg, "encoding", 8) == 0) |
5296 arg += 8; | |
5297 else | |
5298 arg += 3; | |
7 | 5299 pp = &eap->force_enc; |
5300 } | |
595 | 5301 else if (STRNCMP(arg, "bad", 3) == 0) |
5302 { | |
5303 arg += 3; | |
2168 | 5304 pp = &bad_char_idx; |
595 | 5305 } |
7 | 5306 |
5307 if (pp == NULL || *arg != '=') | |
5308 return FAIL; | |
5309 | |
5310 ++arg; | |
5311 *pp = (int)(arg - eap->cmd); | |
5312 arg = skip_cmd_arg(arg, FALSE); | |
5313 eap->arg = skipwhite(arg); | |
5314 *arg = NUL; | |
5315 | |
5316 if (pp == &eap->force_ff) | |
5317 { | |
5318 if (check_ff_value(eap->cmd + eap->force_ff) == FAIL) | |
5319 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
|
5320 eap->force_ff = eap->cmd[eap->force_ff]; |
7 | 5321 } |
595 | 5322 else if (pp == &eap->force_enc) |
7 | 5323 { |
5324 /* Make 'fileencoding' lower case. */ | |
5325 for (p = eap->cmd + eap->force_enc; *p != NUL; ++p) | |
5326 *p = TOLOWER_ASC(*p); | |
5327 } | |
595 | 5328 else |
5329 { | |
5330 /* Check ++bad= argument. Must be a single-byte character, "keep" or | |
5331 * "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
|
5332 if (get_bad_opt(eap->cmd + bad_char_idx, eap) == FAIL) |
595 | 5333 return FAIL; |
5334 } | |
7 | 5335 |
5336 return OK; | |
5337 } | |
5338 | |
5339 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5340 ex_autocmd(exarg_T *eap) |
7 | 5341 { |
5342 /* | |
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
|
5343 * Disallow autocommands from .exrc and .vimrc in current |
7 | 5344 * directory for security reasons. |
5345 */ | |
5346 if (secure) | |
5347 { | |
5348 secure = 2; | |
5349 eap->errmsg = e_curdir; | |
5350 } | |
5351 else if (eap->cmdidx == CMD_autocmd) | |
5352 do_autocmd(eap->arg, eap->forceit); | |
5353 else | |
5354 do_augroup(eap->arg, eap->forceit); | |
5355 } | |
5356 | |
5357 /* | |
5358 * ":doautocmd": Apply the automatic commands to the current buffer. | |
5359 */ | |
5360 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5361 ex_doautocmd(exarg_T *eap) |
7 | 5362 { |
3350 | 5363 char_u *arg = eap->arg; |
5364 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
|
5365 int did_aucmd; |
ac8180818504
commit https://github.com/vim/vim/commit/1610d052413e0ed664498853a47acc2d677a22d1
Christian Brabandt <cb@256bit.org>
parents:
9230
diff
changeset
|
5366 |
ac8180818504
commit https://github.com/vim/vim/commit/1610d052413e0ed664498853a47acc2d677a22d1
Christian Brabandt <cb@256bit.org>
parents:
9230
diff
changeset
|
5367 (void)do_doautocmd(arg, TRUE, &did_aucmd); |
ac8180818504
commit https://github.com/vim/vim/commit/1610d052413e0ed664498853a47acc2d677a22d1
Christian Brabandt <cb@256bit.org>
parents:
9230
diff
changeset
|
5368 /* Only when there is no <nomodeline>. */ |
ac8180818504
commit https://github.com/vim/vim/commit/1610d052413e0ed664498853a47acc2d677a22d1
Christian Brabandt <cb@256bit.org>
parents:
9230
diff
changeset
|
5369 if (call_do_modelines && did_aucmd) |
3350 | 5370 do_modelines(0); |
7 | 5371 } |
5372 | |
5373 /* | |
5374 * :[N]bunload[!] [N] [bufname] unload buffer | |
5375 * :[N]bdelete[!] [N] [bufname] delete buffer from buffer list | |
5376 * :[N]bwipeout[!] [N] [bufname] delete buffer really | |
5377 */ | |
5378 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5379 ex_bunload(exarg_T *eap) |
7 | 5380 { |
17111
af861fccc309
patch 8.1.1555: NOT_IN_POPUP_WINDOW is confusing
Bram Moolenaar <Bram@vim.org>
parents:
17095
diff
changeset
|
5381 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
|
5382 return; |
7 | 5383 eap->errmsg = do_bufdel( |
5384 eap->cmdidx == CMD_bdelete ? DOBUF_DEL | |
5385 : eap->cmdidx == CMD_bwipeout ? DOBUF_WIPE | |
5386 : DOBUF_UNLOAD, eap->arg, | |
5387 eap->addr_count, (int)eap->line1, (int)eap->line2, eap->forceit); | |
5388 } | |
5389 | |
5390 /* | |
5391 * :[N]buffer [N] to buffer N | |
5392 * :[N]sbuffer [N] to buffer N | |
5393 */ | |
5394 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5395 ex_buffer(exarg_T *eap) |
7 | 5396 { |
17111
af861fccc309
patch 8.1.1555: NOT_IN_POPUP_WINDOW is confusing
Bram Moolenaar <Bram@vim.org>
parents:
17095
diff
changeset
|
5397 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
|
5398 return; |
7 | 5399 if (*eap->arg) |
5400 eap->errmsg = e_trailing; | |
5401 else | |
5402 { | |
5403 if (eap->addr_count == 0) /* default is current buffer */ | |
5404 goto_buffer(eap, DOBUF_CURRENT, FORWARD, 0); | |
5405 else | |
5406 goto_buffer(eap, DOBUF_FIRST, FORWARD, (int)eap->line2); | |
6230 | 5407 if (eap->do_ecmd_cmd != NULL) |
5408 do_cmdline_cmd(eap->do_ecmd_cmd); | |
7 | 5409 } |
5410 } | |
5411 | |
5412 /* | |
5413 * :[N]bmodified [N] to next mod. buffer | |
5414 * :[N]sbmodified [N] to next mod. buffer | |
5415 */ | |
5416 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5417 ex_bmodified(exarg_T *eap) |
7 | 5418 { |
5419 goto_buffer(eap, DOBUF_MOD, FORWARD, (int)eap->line2); | |
6230 | 5420 if (eap->do_ecmd_cmd != NULL) |
5421 do_cmdline_cmd(eap->do_ecmd_cmd); | |
7 | 5422 } |
5423 | |
5424 /* | |
5425 * :[N]bnext [N] to next buffer | |
5426 * :[N]sbnext [N] split and to next buffer | |
5427 */ | |
5428 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5429 ex_bnext(exarg_T *eap) |
7 | 5430 { |
5431 goto_buffer(eap, DOBUF_CURRENT, FORWARD, (int)eap->line2); | |
6230 | 5432 if (eap->do_ecmd_cmd != NULL) |
5433 do_cmdline_cmd(eap->do_ecmd_cmd); | |
7 | 5434 } |
5435 | |
5436 /* | |
5437 * :[N]bNext [N] to previous buffer | |
5438 * :[N]bprevious [N] to previous buffer | |
5439 * :[N]sbNext [N] split and to previous buffer | |
5440 * :[N]sbprevious [N] split and to previous buffer | |
5441 */ | |
5442 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5443 ex_bprevious(exarg_T *eap) |
7 | 5444 { |
5445 goto_buffer(eap, DOBUF_CURRENT, BACKWARD, (int)eap->line2); | |
6230 | 5446 if (eap->do_ecmd_cmd != NULL) |
5447 do_cmdline_cmd(eap->do_ecmd_cmd); | |
7 | 5448 } |
5449 | |
5450 /* | |
5451 * :brewind to first buffer | |
5452 * :bfirst to first buffer | |
5453 * :sbrewind split and to first buffer | |
5454 * :sbfirst split and to first buffer | |
5455 */ | |
5456 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5457 ex_brewind(exarg_T *eap) |
7 | 5458 { |
5459 goto_buffer(eap, DOBUF_FIRST, FORWARD, 0); | |
6230 | 5460 if (eap->do_ecmd_cmd != NULL) |
5461 do_cmdline_cmd(eap->do_ecmd_cmd); | |
7 | 5462 } |
5463 | |
5464 /* | |
5465 * :blast to last buffer | |
5466 * :sblast split and to last buffer | |
5467 */ | |
5468 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5469 ex_blast(exarg_T *eap) |
7 | 5470 { |
5471 goto_buffer(eap, DOBUF_LAST, BACKWARD, 0); | |
6230 | 5472 if (eap->do_ecmd_cmd != NULL) |
5473 do_cmdline_cmd(eap->do_ecmd_cmd); | |
7 | 5474 } |
5475 | |
5476 int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5477 ends_excmd(int c) |
7 | 5478 { |
5479 return (c == NUL || c == '|' || c == '"' || c == '\n'); | |
5480 } | |
5481 | |
5482 #if defined(FEAT_SYN_HL) || defined(FEAT_SEARCH_EXTRA) || defined(FEAT_EVAL) \ | |
5483 || defined(PROTO) | |
5484 /* | |
5485 * Return the next command, after the first '|' or '\n'. | |
5486 * Return NULL if not found. | |
5487 */ | |
5488 char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5489 find_nextcmd(char_u *p) |
7 | 5490 { |
5491 while (*p != '|' && *p != '\n') | |
5492 { | |
5493 if (*p == NUL) | |
5494 return NULL; | |
5495 ++p; | |
5496 } | |
5497 return (p + 1); | |
5498 } | |
5499 #endif | |
5500 | |
5501 /* | |
10383
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5502 * 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
|
5503 * Return NULL if it isn't, the following character if it is. |
7 | 5504 */ |
5505 char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5506 check_nextcmd(char_u *p) |
7 | 5507 { |
10383
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5508 char_u *s = skipwhite(p); |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5509 |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5510 if (*s == '|' || *s == '\n') |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5511 return (s + 1); |
7 | 5512 else |
5513 return NULL; | |
5514 } | |
5515 | |
5516 /* | |
5517 * - if there are more files to edit | |
5518 * - and this is the last window | |
5519 * - and forceit not used | |
5520 * - and not repeated twice on a row | |
5521 * return FAIL and give error message if 'message' TRUE | |
5522 * return OK otherwise | |
5523 */ | |
5524 static int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5525 check_more( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5526 int message, /* when FALSE check only, no messages */ |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5527 int forceit) |
7 | 5528 { |
5529 int n = ARGCOUNT - curwin->w_arg_idx - 1; | |
5530 | |
672 | 5531 if (!forceit && only_one_window() |
5532 && ARGCOUNT > 1 && !arg_had_last && n >= 0 && quitmore == 0) | |
7 | 5533 { |
5534 if (message) | |
5535 { | |
5536 #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) | |
5537 if ((p_confirm || cmdmod.confirm) && curbuf->b_fname != NULL) | |
5538 { | |
2770 | 5539 char_u buff[DIALOG_MSG_SIZE]; |
7 | 5540 |
14585
c8f07e8b273e
patch 8.1.0306: plural messages are not translated properly
Christian Brabandt <cb@256bit.org>
parents:
14550
diff
changeset
|
5541 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
|
5542 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
|
5543 "%d more files to edit. Quit anyway?", n), n); |
7 | 5544 if (vim_dialog_yesno(VIM_QUESTION, NULL, buff, 1) == VIM_YES) |
5545 return OK; | |
5546 return FAIL; | |
5547 } | |
5548 #endif | |
15490
98c35d312987
patch 8.1.0753: printf format not checked for semsg()
Bram Moolenaar <Bram@vim.org>
parents:
15488
diff
changeset
|
5549 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
|
5550 "E173: %d more files to edit", n), n); |
7 | 5551 quitmore = 2; /* next try to quit is allowed */ |
5552 } | |
5553 return FAIL; | |
5554 } | |
5555 return OK; | |
5556 } | |
5557 | |
16411
5b5c5daf57de
patch 8.1.1210: support for user commands is spread out
Bram Moolenaar <Bram@vim.org>
parents:
16399
diff
changeset
|
5558 #if defined(FEAT_CMDL_COMPL) || defined(PROTO) |
7 | 5559 /* |
5560 * Function given to ExpandGeneric() to obtain the list of command names. | |
5561 */ | |
5562 char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5563 get_command_name(expand_T *xp UNUSED, int idx) |
7 | 5564 { |
5565 if (idx >= (int)CMD_SIZE) | |
5566 return get_user_command_name(idx); | |
5567 return cmdnames[idx].cmd_name; | |
5568 } | |
5569 #endif | |
5570 | |
5571 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5572 ex_colorscheme(exarg_T *eap) |
7 | 5573 { |
2142
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
5574 if (*eap->arg == NUL) |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
5575 { |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
5576 #ifdef FEAT_EVAL |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
5577 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
|
5578 char_u *p = NULL; |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
5579 |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
5580 if (expr != NULL) |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
5581 { |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
5582 ++emsg_off; |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
5583 p = eval_to_string(expr, NULL, FALSE); |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
5584 --emsg_off; |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
5585 vim_free(expr); |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
5586 } |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
5587 if (p != NULL) |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
5588 { |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15510
diff
changeset
|
5589 msg((char *)p); |
2142
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
5590 vim_free(p); |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
5591 } |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
5592 else |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15510
diff
changeset
|
5593 msg("default"); |
2142
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
5594 #else |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15510
diff
changeset
|
5595 msg(_("unknown")); |
2142
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
5596 #endif |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
5597 } |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
5598 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
|
5599 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
|
5600 |
61448894376e
patch 8.1.0839: when using VTP wrong colors after a color scheme change
Bram Moolenaar <Bram@vim.org>
parents:
15643
diff
changeset
|
5601 #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
|
5602 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
|
5603 { |
61448894376e
patch 8.1.0839: when using VTP wrong colors after a color scheme change
Bram Moolenaar <Bram@vim.org>
parents:
15643
diff
changeset
|
5604 // 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
|
5605 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
|
5606 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
|
5607 } |
61448894376e
patch 8.1.0839: when using VTP wrong colors after a color scheme change
Bram Moolenaar <Bram@vim.org>
parents:
15643
diff
changeset
|
5608 #endif |
7 | 5609 } |
5610 | |
5611 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5612 ex_highlight(exarg_T *eap) |
7 | 5613 { |
5614 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
|
5615 msg(_("Greetings, Vim user!")); |
7 | 5616 do_highlight(eap->arg, eap->forceit, FALSE); |
5617 } | |
5618 | |
5619 | |
5620 /* | |
5621 * Call this function if we thought we were going to exit, but we won't | |
5622 * (because of an error). May need to restore the terminal mode. | |
5623 */ | |
5624 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5625 not_exiting(void) |
7 | 5626 { |
5627 exiting = FALSE; | |
5628 settmode(TMODE_RAW); | |
5629 } | |
5630 | |
13442
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5631 static int |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5632 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
|
5633 { |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5634 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
|
5635 |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5636 /* Bail out when autocommands closed the window. |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5637 * Refuse to quit when the buffer in the last window is being closed (can |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5638 * only happen in autocommands). */ |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5639 if (!win_valid(wp) |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5640 || curbuf_locked() |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5641 || (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
|
5642 return TRUE; |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5643 |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5644 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
|
5645 { |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5646 apply_autocmds(EVENT_EXITPRE, NULL, NULL, FALSE, curbuf); |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5647 /* Refuse to quit when locked or when the buffer in the last window is |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5648 * being closed (can only happen in autocommands). */ |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5649 if (curbuf_locked() |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5650 || (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
|
5651 return TRUE; |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5652 } |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5653 |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5654 return FALSE; |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5655 } |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5656 |
7 | 5657 /* |
6409 | 5658 * ":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
|
5659 * ":{nr}quit": quit window {nr} |
7 | 5660 */ |
5661 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5662 ex_quit(exarg_T *eap) |
7 | 5663 { |
6398 | 5664 win_T *wp; |
5665 | |
7 | 5666 #ifdef FEAT_CMDWIN |
5667 if (cmdwin_type != 0) | |
5668 { | |
5669 cmdwin_result = Ctrl_C; | |
5670 return; | |
5671 } | |
5672 #endif | |
631 | 5673 /* Don't quit while editing the command line. */ |
633 | 5674 if (text_locked()) |
5675 { | |
5676 text_locked_msg(); | |
631 | 5677 return; |
5678 } | |
6398 | 5679 if (eap->addr_count > 0) |
5680 { | |
6409 | 5681 int wnr = eap->line2; |
5682 | |
5683 for (wp = firstwin; wp->w_next != NULL; wp = wp->w_next) | |
5684 if (--wnr <= 0) | |
6398 | 5685 break; |
5686 } | |
5687 else | |
5688 wp = curwin; | |
6409 | 5689 |
12652
272ecbaf1b4f
patch 8.0.1204: a QuitPre autocommand may get the wrong file name
Christian Brabandt <cb@256bit.org>
parents:
12624
diff
changeset
|
5690 /* Refuse to quit when locked. */ |
272ecbaf1b4f
patch 8.0.1204: a QuitPre autocommand may get the wrong file name
Christian Brabandt <cb@256bit.org>
parents:
12624
diff
changeset
|
5691 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
|
5692 return; |
13442
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5693 |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5694 /* Trigger QuitPre and maybe ExitPre */ |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5695 if (before_quit_autocmds(wp, FALSE, eap->forceit)) |
819 | 5696 return; |
7 | 5697 |
5698 #ifdef FEAT_NETBEANS_INTG | |
5699 netbeansForcedQuit = eap->forceit; | |
5700 #endif | |
5701 | |
5702 /* | |
5703 * If there are more files or windows we won't exit. | |
5704 */ | |
5705 if (check_more(FALSE, eap->forceit) == OK && only_one_window()) | |
5706 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
|
5707 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
|
5708 && check_changed(wp->w_buffer, (p_awa ? CCGD_AW : 0) |
5464 | 5709 | (eap->forceit ? CCGD_FORCEIT : 0) |
5710 | CCGD_EXCMD)) | |
7 | 5711 || 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
|
5712 || (only_one_window() && check_changed_any(eap->forceit, TRUE))) |
7 | 5713 { |
5714 not_exiting(); | |
5715 } | |
5716 else | |
5717 { | |
6838 | 5718 /* quit last window |
5719 * Note: only_one_window() returns true, even so a help window is | |
5720 * still open. In that case only quit, if no address has been | |
5721 * specified. Example: | |
5722 * :h|wincmd w|1q - don't quit | |
5723 * :h|wincmd w|q - quit | |
5724 */ | |
10349
cf988222b150
commit https://github.com/vim/vim/commit/a1f4cb93ba50ea9e40cd4b1f5592b8a6d1398660
Christian Brabandt <cb@256bit.org>
parents:
10275
diff
changeset
|
5725 if (only_one_window() && (ONE_WINDOW || eap->addr_count == 0)) |
7 | 5726 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
|
5727 not_exiting(); |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5728 #ifdef FEAT_GUI |
7 | 5729 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
|
5730 #endif |
7 | 5731 /* 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
|
5732 win_close(wp, !buf_hide(wp->w_buffer) || eap->forceit); |
7 | 5733 } |
5734 } | |
5735 | |
5736 /* | |
5737 * ":cquit". | |
5738 */ | |
5739 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5740 ex_cquit(exarg_T *eap UNUSED) |
7 | 5741 { |
5742 getout(1); /* this does not always pass on the exit code to the Manx | |
5743 compiler. why? */ | |
5744 } | |
5745 | |
5746 /* | |
5747 * ":qall": try to quit all windows | |
5748 */ | |
5749 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5750 ex_quit_all(exarg_T *eap) |
7 | 5751 { |
5752 # ifdef FEAT_CMDWIN | |
5753 if (cmdwin_type != 0) | |
5754 { | |
5755 if (eap->forceit) | |
5756 cmdwin_result = K_XF1; /* ex_window() takes care of this */ | |
5757 else | |
5758 cmdwin_result = K_XF2; | |
5759 return; | |
5760 } | |
5761 # endif | |
631 | 5762 |
5763 /* Don't quit while editing the command line. */ | |
633 | 5764 if (text_locked()) |
5765 { | |
5766 text_locked_msg(); | |
631 | 5767 return; |
5768 } | |
13442
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5769 |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5770 if (before_quit_autocmds(curwin, TRUE, eap->forceit)) |
819 | 5771 return; |
631 | 5772 |
7 | 5773 exiting = TRUE; |
7469
15eefe1b0dad
commit https://github.com/vim/vim/commit/027387f70c671f62e3e08e0bdd09ec05b0232735
Christian Brabandt <cb@256bit.org>
parents:
7465
diff
changeset
|
5774 if (eap->forceit || !check_changed_any(FALSE, FALSE)) |
7 | 5775 getout(0); |
5776 not_exiting(); | |
5777 } | |
5778 | |
5779 /* | |
5780 * ":close": close current window, unless it is the last one | |
5781 */ | |
5782 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5783 ex_close(exarg_T *eap) |
7 | 5784 { |
6398 | 5785 win_T *win; |
5786 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
|
5787 #ifdef FEAT_CMDWIN |
7 | 5788 if (cmdwin_type != 0) |
2839 | 5789 cmdwin_result = Ctrl_C; |
7 | 5790 else |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5791 #endif |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
5792 if (!text_locked() && !curbuf_locked()) |
6398 | 5793 { |
5794 if (eap->addr_count == 0) | |
5795 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
|
5796 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
|
5797 { |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9538
diff
changeset
|
5798 FOR_ALL_WINDOWS(win) |
6398 | 5799 { |
5800 winnr++; | |
5801 if (winnr == eap->line2) | |
5802 break; | |
5803 } | |
5804 if (win == NULL) | |
5805 win = lastwin; | |
5806 ex_win_close(eap->forceit, win, NULL); | |
5807 } | |
5808 } | |
667 | 5809 } |
5810 | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5811 #ifdef FEAT_QUICKFIX |
667 | 5812 /* |
5813 * ":pclose": Close any preview window. | |
5814 */ | |
5815 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5816 ex_pclose(exarg_T *eap) |
667 | 5817 { |
5818 win_T *win; | |
5819 | |
17431
ce35cdbe9f74
patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
17336
diff
changeset
|
5820 // First close any normal window. |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9538
diff
changeset
|
5821 FOR_ALL_WINDOWS(win) |
667 | 5822 if (win->w_p_pvw) |
5823 { | |
671 | 5824 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
|
5825 return; |
ce35cdbe9f74
patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
17336
diff
changeset
|
5826 } |
ce35cdbe9f74
patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
17336
diff
changeset
|
5827 # ifdef FEAT_TEXT_PROP |
ce35cdbe9f74
patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
17336
diff
changeset
|
5828 // Also when 'previewpopup' is empty, it might have been cleared. |
ce35cdbe9f74
patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
17336
diff
changeset
|
5829 popup_close_preview(); |
ce35cdbe9f74
patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
17336
diff
changeset
|
5830 # endif |
667 | 5831 } |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5832 #endif |
667 | 5833 |
671 | 5834 /* |
5835 * Close window "win" and take care of handling closing the last window for a | |
5836 * modified buffer. | |
5837 */ | |
5838 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5839 ex_win_close( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5840 int forceit, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5841 win_T *win, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5842 tabpage_T *tp) /* NULL or the tab page "win" is in */ |
7 | 5843 { |
5844 int need_hide; | |
5845 buf_T *buf = win->w_buffer; | |
5846 | |
5847 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
|
5848 if (need_hide && !buf_hide(buf) && !forceit) |
7 | 5849 { |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5850 #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) |
7 | 5851 if ((p_confirm || cmdmod.confirm) && p_write) |
5852 { | |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9460
diff
changeset
|
5853 bufref_T bufref; |
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9460
diff
changeset
|
5854 |
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9460
diff
changeset
|
5855 set_bufref(&bufref, buf); |
7 | 5856 dialog_changed(buf, FALSE); |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9460
diff
changeset
|
5857 if (bufref_valid(&bufref) && bufIsChanged(buf)) |
7 | 5858 return; |
5859 need_hide = FALSE; | |
5860 } | |
5861 else | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5862 #endif |
7 | 5863 { |
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
|
5864 no_write_message(); |
7 | 5865 return; |
5866 } | |
5867 } | |
5868 | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5869 #ifdef FEAT_GUI |
7 | 5870 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
|
5871 #endif |
671 | 5872 |
7 | 5873 /* free buffer when not hiding it or when it's a scratch buffer */ |
671 | 5874 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
|
5875 win_close(win, !need_hide && !buf_hide(buf)); |
671 | 5876 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
|
5877 win_close_othertab(win, !need_hide && !buf_hide(buf), tp); |
671 | 5878 } |
5879 | |
5880 /* | |
10741
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5881 * 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
|
5882 * Returns a tabpage number. |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5883 * 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
|
5884 */ |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5885 static int |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5886 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
|
5887 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5888 int tab_number; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5889 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
|
5890 |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5891 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
|
5892 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5893 char_u *p = eap->arg; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5894 char_u *p_save; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5895 int relative = 0; /* argument +N/-N means: go to N places to the |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5896 * right/left relative to the current position. */ |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5897 |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5898 if (*p == '-') |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5899 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5900 relative = -1; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5901 p++; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5902 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5903 else if (*p == '+') |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5904 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5905 relative = 1; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5906 p++; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5907 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5908 |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5909 p_save = p; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5910 tab_number = getdigits(&p); |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5911 |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5912 if (relative == 0) |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5913 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5914 if (STRCMP(p, "$") == 0) |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5915 tab_number = LAST_TAB_NR; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5916 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
|
5917 || tab_number > LAST_TAB_NR) |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5918 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5919 /* No numbers as argument. */ |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5920 eap->errmsg = e_invarg; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5921 goto theend; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5922 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5923 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5924 else |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5925 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5926 if (*p_save == NUL) |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5927 tab_number = 1; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5928 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
|
5929 || tab_number == 0) |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5930 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5931 /* No numbers as argument. */ |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5932 eap->errmsg = e_invarg; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5933 goto theend; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5934 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5935 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
|
5936 if (!unaccept_arg0 && relative == -1) |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5937 --tab_number; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5938 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5939 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
|
5940 eap->errmsg = e_invarg; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5941 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5942 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
|
5943 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5944 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
|
5945 { |
10741
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5946 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
|
5947 tab_number = 0; |
4961e7acdd8c
patch 8.0.0266: compiler warning for using uninitialized variable
Christian Brabandt <cb@256bit.org>
parents:
10741
diff
changeset
|
5948 } |
10741
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5949 else |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5950 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5951 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
|
5952 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
|
5953 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5954 --tab_number; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5955 if (tab_number < unaccept_arg0) |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5956 eap->errmsg = e_invarg; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5957 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5958 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5959 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5960 else |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5961 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5962 switch (eap->cmdidx) |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5963 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5964 case CMD_tabnext: |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5965 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
|
5966 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
|
5967 tab_number = 1; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5968 break; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5969 case CMD_tabmove: |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5970 tab_number = LAST_TAB_NR; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5971 break; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5972 default: |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5973 tab_number = tabpage_index(curtab); |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5974 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5975 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5976 |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5977 theend: |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5978 return tab_number; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5979 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5980 |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5981 /* |
671 | 5982 * ":tabclose": close current tab page, unless it is the last one. |
5983 * ":tabclose N": close tab page N. | |
667 | 5984 */ |
5985 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5986 ex_tabclose(exarg_T *eap) |
667 | 5987 { |
671 | 5988 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
|
5989 int tab_number; |
671 | 5990 |
667 | 5991 # ifdef FEAT_CMDWIN |
5992 if (cmdwin_type != 0) | |
5993 cmdwin_result = K_IGNORE; | |
5994 else | |
5995 # endif | |
671 | 5996 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
|
5997 emsg(_("E784: Cannot close last tab page")); |
671 | 5998 else |
5999 { | |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6000 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
|
6001 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
|
6002 { |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6003 tp = find_tabpage(tab_number); |
671 | 6004 if (tp == NULL) |
6005 { | |
6006 beep_flush(); | |
6007 return; | |
6008 } | |
674 | 6009 if (tp != curtab) |
671 | 6010 { |
6011 tabpage_close_other(tp, eap->forceit); | |
6012 return; | |
6013 } | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
6014 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
|
6015 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
|
6016 } |
671 | 6017 } |
672 | 6018 } |
6019 | |
6020 /* | |
6021 * ":tabonly": close all tab pages except the current one | |
6022 */ | |
6023 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6024 ex_tabonly(exarg_T *eap) |
672 | 6025 { |
6026 tabpage_T *tp; | |
6027 int done; | |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6028 int tab_number; |
672 | 6029 |
6030 # ifdef FEAT_CMDWIN | |
6031 if (cmdwin_type != 0) | |
6032 cmdwin_result = K_IGNORE; | |
6033 else | |
6034 # endif | |
6035 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
|
6036 msg(_("Already only one tab page")); |
672 | 6037 else |
6038 { | |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6039 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
|
6040 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
|
6041 { |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6042 goto_tabpage(tab_number); |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6043 /* Repeat this up to a 1000 times, because autocommands may |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6044 * mess up the lists. */ |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6045 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
|
6046 { |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6047 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
|
6048 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
|
6049 { |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6050 tabpage_close_other(tp, eap->forceit); |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6051 /* if we failed to close it quit */ |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6052 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
|
6053 done = 1000; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6054 /* start over, "tp" is now invalid */ |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6055 break; |
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 if (first_tabpage->tp_next == NULL) |
672 | 6058 break; |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6059 } |
672 | 6060 } |
6061 } | |
671 | 6062 } |
6063 | |
6064 /* | |
6065 * Close the current tab page. | |
6066 */ | |
6067 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6068 tabpage_close(int forceit) |
671 | 6069 { |
6070 /* First close all the windows but the current one. If that worked then | |
6071 * 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
|
6072 if (!ONE_WINDOW) |
675 | 6073 close_others(TRUE, forceit); |
10357
59d01e335858
commit https://github.com/vim/vim/commit/459ca563128f2edb7e3bb190090bbb755a56dd55
Christian Brabandt <cb@256bit.org>
parents:
10349
diff
changeset
|
6074 if (ONE_WINDOW) |
671 | 6075 ex_win_close(forceit, curwin, NULL); |
6076 # ifdef FEAT_GUI | |
6077 need_mouse_correct = TRUE; | |
6078 # endif | |
6079 } | |
6080 | |
6081 /* | |
6082 * Close tab page "tp", which is not the current tab page. | |
6083 * Note that autocommands may make "tp" invalid. | |
971 | 6084 * Also takes care of the tab pages line disappearing when closing the |
6085 * last-but-one tab page. | |
671 | 6086 */ |
6087 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6088 tabpage_close_other(tabpage_T *tp, int forceit) |
671 | 6089 { |
6090 int done = 0; | |
672 | 6091 win_T *wp; |
971 | 6092 int h = tabline_height(); |
671 | 6093 |
6094 /* Limit to 1000 windows, autocommands may add a window while we close | |
6095 * one. OK, so I'm paranoid... */ | |
6096 while (++done < 1000) | |
6097 { | |
672 | 6098 wp = tp->tp_firstwin; |
6099 ex_win_close(forceit, wp, tp); | |
6100 | |
6101 /* Autocommands may delete the tab page under our fingers and we may | |
6102 * fail to close a window with a modified buffer. */ | |
6103 if (!valid_tabpage(tp) || tp->tp_firstwin == wp) | |
671 | 6104 break; |
6105 } | |
971 | 6106 |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9538
diff
changeset
|
6107 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
|
6108 |
672 | 6109 redraw_tabline = TRUE; |
971 | 6110 if (h != tabline_height()) |
6111 shell_new_rows(); | |
667 | 6112 } |
7 | 6113 |
6114 /* | |
6115 * ":only". | |
6116 */ | |
6117 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6118 ex_only(exarg_T *eap) |
7 | 6119 { |
6398 | 6120 win_T *wp; |
6121 int wnr; | |
7 | 6122 # ifdef FEAT_GUI |
6123 need_mouse_correct = TRUE; | |
6124 # endif | |
6398 | 6125 if (eap->addr_count > 0) |
6126 { | |
6127 wnr = eap->line2; | |
6128 for (wp = firstwin; --wnr > 0; ) | |
6129 { | |
6130 if (wp->w_next == NULL) | |
6131 break; | |
6132 else | |
6133 wp = wp->w_next; | |
6134 } | |
6135 win_goto(wp); | |
6136 } | |
7 | 6137 close_others(TRUE, eap->forceit); |
6138 } | |
6139 | |
6140 /* | |
6141 * ":all" and ":sall". | |
727 | 6142 * Also used for ":tab drop file ..." after setting the argument list. |
6143 */ | |
6144 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6145 ex_all(exarg_T *eap) |
7 | 6146 { |
6147 if (eap->addr_count == 0) | |
6148 eap->line2 = 9999; | |
727 | 6149 do_arg_all((int)eap->line2, eap->forceit, eap->cmdidx == CMD_drop); |
7 | 6150 } |
6151 | |
6152 static void | |
10492
b2cd5a71f4bb
commit https://github.com/vim/vim/commit/5e1e6d265d26ee2952c4a018a5ff72c950d2d700
Christian Brabandt <cb@256bit.org>
parents:
10490
diff
changeset
|
6153 ex_hide(exarg_T *eap UNUSED) |
7 | 6154 { |
10383
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
6155 /* ":hide" or ":hide | cmd": hide current window */ |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
6156 if (!eap->skip) |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
6157 { |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
6158 #ifdef FEAT_GUI |
10383
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
6159 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
|
6160 #endif |
10383
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
6161 if (eap->addr_count == 0) |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
6162 win_close(curwin, FALSE); /* don't free buffer */ |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
6163 else |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
6164 { |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
6165 int winnr = 0; |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
6166 win_T *win; |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
6167 |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
6168 FOR_ALL_WINDOWS(win) |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
6169 { |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
6170 winnr++; |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
6171 if (winnr == eap->line2) |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
6172 break; |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
6173 } |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
6174 if (win == NULL) |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
6175 win = lastwin; |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
6176 win_close(win, FALSE); |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
6177 } |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
6178 } |
7 | 6179 } |
6180 | |
6181 /* | |
6182 * ":stop" and ":suspend": Suspend Vim. | |
6183 */ | |
6184 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6185 ex_stop(exarg_T *eap) |
7 | 6186 { |
6187 /* | |
6188 * Disallow suspending for "rvim". | |
6189 */ | |
10264
c036c0f636d5
commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents:
10240
diff
changeset
|
6190 if (!check_restricted()) |
7 | 6191 { |
6192 if (!eap->forceit) | |
6193 autowrite_all(); | |
6194 windgoto((int)Rows - 1, 0); | |
6195 out_char('\n'); | |
6196 out_flush(); | |
6197 stoptermcap(); | |
6198 out_flush(); /* needed for SUN to restore xterm buffer */ | |
6199 #ifdef FEAT_TITLE | |
14479
3375a8cbb442
patch 8.1.0253: saving and restoring window title does not always work
Christian Brabandt <cb@256bit.org>
parents:
14433
diff
changeset
|
6200 mch_restore_title(SAVE_RESTORE_BOTH); /* restore window titles */ |
7 | 6201 #endif |
6202 ui_suspend(); /* call machine specific function */ | |
6203 #ifdef FEAT_TITLE | |
6204 maketitle(); | |
6205 resettitle(); /* force updating the title */ | |
6206 #endif | |
6207 starttermcap(); | |
6208 scroll_start(); /* scroll screen before redrawing */ | |
6209 redraw_later_clear(); | |
6210 shell_resized(); /* may have resized window */ | |
6211 } | |
6212 } | |
6213 | |
6214 /* | |
13442
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
6215 * ":exit", ":xit" and ":wq": Write file and quite the current window. |
7 | 6216 */ |
6217 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6218 ex_exit(exarg_T *eap) |
7 | 6219 { |
6220 #ifdef FEAT_CMDWIN | |
6221 if (cmdwin_type != 0) | |
6222 { | |
6223 cmdwin_result = Ctrl_C; | |
6224 return; | |
6225 } | |
6226 #endif | |
631 | 6227 /* Don't quit while editing the command line. */ |
633 | 6228 if (text_locked()) |
6229 { | |
6230 text_locked_msg(); | |
631 | 6231 return; |
6232 } | |
13442
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
6233 |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
6234 if (before_quit_autocmds(curwin, FALSE, eap->forceit)) |
819 | 6235 return; |
7 | 6236 |
6237 /* | |
6238 * if more files or windows we won't exit | |
6239 */ | |
6240 if (check_more(FALSE, eap->forceit) == OK && only_one_window()) | |
6241 exiting = TRUE; | |
6242 if ( ((eap->cmdidx == CMD_wq | |
6243 || curbufIsChanged()) | |
6244 && do_write(eap) == FAIL) | |
6245 || 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
|
6246 || (only_one_window() && check_changed_any(eap->forceit, FALSE))) |
7 | 6247 { |
6248 not_exiting(); | |
6249 } | |
6250 else | |
6251 { | |
6252 if (only_one_window()) /* quit last window, exit Vim */ | |
6253 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
|
6254 not_exiting(); |
7 | 6255 # ifdef FEAT_GUI |
6256 need_mouse_correct = TRUE; | |
6257 # endif | |
5245
8c6615a30951
updated for version 7.4a.047
Bram Moolenaar <bram@vim.org>
parents:
5198
diff
changeset
|
6258 /* 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
|
6259 win_close(curwin, !buf_hide(curwin->w_buffer)); |
7 | 6260 } |
6261 } | |
6262 | |
6263 /* | |
6264 * ":print", ":list", ":number". | |
6265 */ | |
6266 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6267 ex_print(exarg_T *eap) |
7 | 6268 { |
167 | 6269 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
|
6270 emsg(_(e_emptybuf)); |
167 | 6271 else |
6272 { | |
6273 for ( ;!got_int; ui_breakcheck()) | |
6274 { | |
6275 print_line(eap->line1, | |
6276 (eap->cmdidx == CMD_number || eap->cmdidx == CMD_pound | |
6277 || (eap->flags & EXFLAG_NR)), | |
6278 eap->cmdidx == CMD_list || (eap->flags & EXFLAG_LIST)); | |
6279 if (++eap->line1 > eap->line2) | |
6280 break; | |
6281 out_flush(); /* show one line at a time */ | |
6282 } | |
6283 setpcmark(); | |
6284 /* put cursor at last line */ | |
6285 curwin->w_cursor.lnum = eap->line2; | |
6286 beginline(BL_SOL | BL_FIX); | |
6287 } | |
7 | 6288 |
6289 ex_no_reprint = TRUE; | |
6290 } | |
6291 | |
6292 #ifdef FEAT_BYTEOFF | |
6293 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6294 ex_goto(exarg_T *eap) |
7 | 6295 { |
6296 goto_byte(eap->line2); | |
6297 } | |
6298 #endif | |
6299 | |
6300 /* | |
6301 * ":shell". | |
6302 */ | |
6303 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6304 ex_shell(exarg_T *eap UNUSED) |
7 | 6305 { |
6306 do_shell(NULL, 0); | |
6307 } | |
6308 | |
14428
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6309 #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
|
6310 |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6311 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
|
6312 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
|
6313 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
|
6314 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
|
6315 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
|
6316 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
|
6317 |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6318 static void |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6319 handle_drop_internal(void) |
7 | 6320 { |
6321 exarg_T ea; | |
6322 int save_msg_scroll = msg_scroll; | |
6323 | |
14428
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6324 // 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
|
6325 // 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
|
6326 drop_busy = TRUE; |
7 | 6327 |
6328 /* Check whether the current buffer is changed. If so, we will need | |
6329 * to split the current window or data could be lost. | |
6330 * We don't need to check if the 'hidden' option is set, as in this | |
6331 * case the buffer won't be lost. | |
6332 */ | |
14428
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6333 if (!buf_hide(curbuf) && !drop_split) |
7 | 6334 { |
6335 ++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
|
6336 drop_split = check_changed(curbuf, CCGD_AW); |
7 | 6337 --emsg_off; |
6338 } | |
14428
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6339 if (drop_split) |
7 | 6340 { |
6341 if (win_split(0, 0) == FAIL) | |
6342 return; | |
2583 | 6343 RESET_BINDING(curwin); |
7 | 6344 |
6345 /* When splitting the window, create a new alist. Otherwise the | |
6346 * existing one is overwritten. */ | |
6347 alist_unlink(curwin->w_alist); | |
6348 alist_new(); | |
6349 } | |
6350 | |
6351 /* | |
6352 * Set up the new argument list. | |
6353 */ | |
14428
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6354 alist_set(ALIST(curwin), drop_filec, drop_filev, FALSE, NULL, 0); |
7 | 6355 |
6356 /* | |
6357 * Move to the first file. | |
6358 */ | |
6359 /* Fake up a minimal "next" command for do_argfile() */ | |
6360 vim_memset(&ea, 0, sizeof(ea)); | |
6361 ea.cmd = (char_u *)"next"; | |
6362 do_argfile(&ea, 0); | |
6363 | |
6364 /* do_ecmd() may set need_start_insertmode, but since we never left Insert | |
6365 * mode that is not needed here. */ | |
6366 need_start_insertmode = FALSE; | |
6367 | |
6368 /* Restore msg_scroll, otherwise a following command may cause scrolling | |
6369 * unexpectedly. The screen will be redrawn by the caller, thus | |
6370 * msg_scroll being set by displaying a message is irrelevant. */ | |
6371 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
|
6372 |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6373 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
|
6374 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
|
6375 |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6376 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
|
6377 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
|
6378 } |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6379 |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6380 /* |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6381 * 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
|
6382 * :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
|
6383 * 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
|
6384 * 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
|
6385 * 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
|
6386 * |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6387 * 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
|
6388 * 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
|
6389 * list. |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6390 */ |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6391 void |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6392 handle_drop( |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6393 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
|
6394 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
|
6395 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
|
6396 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
|
6397 // list |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6398 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
|
6399 { |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6400 // 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
|
6401 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
|
6402 { |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6403 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
|
6404 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
|
6405 return; |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6406 } |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6407 |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6408 // 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
|
6409 // one. |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6410 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
|
6411 { |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6412 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
|
6413 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
|
6414 } |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6415 |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6416 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
|
6417 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
|
6418 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
|
6419 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
|
6420 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
|
6421 |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6422 // 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
|
6423 // - 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
|
6424 // - 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
|
6425 // - 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
|
6426 // 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
|
6427 // 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
|
6428 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
|
6429 return; |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6430 |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6431 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
|
6432 } |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6433 |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6434 /* |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6435 * 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
|
6436 * 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
|
6437 */ |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6438 void |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6439 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
|
6440 { |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6441 if (!drop_busy && drop_filev != NULL |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6442 && !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
|
6443 handle_drop_internal(); |
7 | 6444 } |
6445 #endif | |
6446 | |
6447 /* | |
6448 * Clear an argument list: free all file names and reset it to zero entries. | |
6449 */ | |
23 | 6450 void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6451 alist_clear(alist_T *al) |
7 | 6452 { |
6453 while (--al->al_ga.ga_len >= 0) | |
6454 vim_free(AARGLIST(al)[al->al_ga.ga_len].ae_fname); | |
6455 ga_clear(&al->al_ga); | |
6456 } | |
6457 | |
6458 /* | |
6459 * Init an argument list. | |
6460 */ | |
6461 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6462 alist_init(alist_T *al) |
7 | 6463 { |
6464 ga_init2(&al->al_ga, (int)sizeof(aentry_T), 5); | |
6465 } | |
6466 | |
6467 /* | |
6468 * Remove a reference from an argument list. | |
6469 * Ignored when the argument list is the global one. | |
6470 * If the argument list is no longer used by any window, free it. | |
6471 */ | |
6472 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6473 alist_unlink(alist_T *al) |
7 | 6474 { |
6475 if (al != &global_alist && --al->al_refcount <= 0) | |
6476 { | |
6477 alist_clear(al); | |
6478 vim_free(al); | |
6479 } | |
6480 } | |
6481 | |
6482 /* | |
6483 * Create a new argument list and use it for the current window. | |
6484 */ | |
6485 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6486 alist_new(void) |
7 | 6487 { |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16782
diff
changeset
|
6488 curwin->w_alist = ALLOC_ONE(alist_T); |
7 | 6489 if (curwin->w_alist == NULL) |
6490 { | |
6491 curwin->w_alist = &global_alist; | |
6492 ++global_alist.al_refcount; | |
6493 } | |
6494 else | |
6495 { | |
6496 curwin->w_alist->al_refcount = 1; | |
5942 | 6497 curwin->w_alist->id = ++max_alist_id; |
7 | 6498 alist_init(curwin->w_alist); |
6499 } | |
6500 } | |
6501 | |
9536
b2aada04d84e
commit https://github.com/vim/vim/commit/a06ecab7a5159e744448ace731036f0dc5f87dd4
Christian Brabandt <cb@256bit.org>
parents:
9487
diff
changeset
|
6502 #if !defined(UNIX) || defined(PROTO) |
7 | 6503 /* |
6504 * Expand the file names in the global argument list. | |
41 | 6505 * If "fnum_list" is not NULL, use "fnum_list[fnum_len]" as a list of buffer |
6506 * numbers to be re-used. | |
7 | 6507 */ |
6508 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6509 alist_expand(int *fnum_list, int fnum_len) |
7 | 6510 { |
6511 char_u **old_arg_files; | |
41 | 6512 int old_arg_count; |
7 | 6513 char_u **new_arg_files; |
6514 int new_arg_file_count; | |
6515 char_u *save_p_su = p_su; | |
6516 int i; | |
6517 | |
6518 /* Don't use 'suffixes' here. This should work like the shell did the | |
6519 * expansion. Also, the vimrc file isn't read yet, thus the user | |
6520 * can't set the options. */ | |
6521 p_su = empty_option; | |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16782
diff
changeset
|
6522 old_arg_files = ALLOC_MULT(char_u *, GARGCOUNT); |
7 | 6523 if (old_arg_files != NULL) |
6524 { | |
6525 for (i = 0; i < GARGCOUNT; ++i) | |
41 | 6526 old_arg_files[i] = vim_strsave(GARGLIST[i].ae_fname); |
6527 old_arg_count = GARGCOUNT; | |
6528 if (expand_wildcards(old_arg_count, old_arg_files, | |
7 | 6529 &new_arg_file_count, &new_arg_files, |
2966 | 6530 EW_FILE|EW_NOTFOUND|EW_ADDSLASH|EW_NOERROR) == OK |
7 | 6531 && new_arg_file_count > 0) |
6532 { | |
41 | 6533 alist_set(&global_alist, new_arg_file_count, new_arg_files, |
6534 TRUE, fnum_list, fnum_len); | |
6535 FreeWild(old_arg_count, old_arg_files); | |
23 | 6536 } |
7 | 6537 } |
6538 p_su = save_p_su; | |
6539 } | |
6540 #endif | |
6541 | |
6542 /* | |
6543 * Set the argument list for the current window. | |
6544 * Takes over the allocated files[] and the allocated fnames in it. | |
6545 */ | |
6546 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6547 alist_set( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6548 alist_T *al, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6549 int count, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6550 char_u **files, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6551 int use_curbuf, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6552 int *fnum_list, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6553 int fnum_len) |
7 | 6554 { |
6555 int i; | |
13221
dc28351a85d4
patch 8.0.1485: weird autocmd may cause arglist to be changed recursively
Christian Brabandt <cb@256bit.org>
parents:
13170
diff
changeset
|
6556 static int recursive = 0; |
dc28351a85d4
patch 8.0.1485: weird autocmd may cause arglist to be changed recursively
Christian Brabandt <cb@256bit.org>
parents:
13170
diff
changeset
|
6557 |
dc28351a85d4
patch 8.0.1485: weird autocmd may cause arglist to be changed recursively
Christian Brabandt <cb@256bit.org>
parents:
13170
diff
changeset
|
6558 if (recursive) |
dc28351a85d4
patch 8.0.1485: weird autocmd may cause arglist to be changed recursively
Christian Brabandt <cb@256bit.org>
parents:
13170
diff
changeset
|
6559 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
6560 emsg(_(e_au_recursive)); |
13221
dc28351a85d4
patch 8.0.1485: weird autocmd may cause arglist to be changed recursively
Christian Brabandt <cb@256bit.org>
parents:
13170
diff
changeset
|
6561 return; |
dc28351a85d4
patch 8.0.1485: weird autocmd may cause arglist to be changed recursively
Christian Brabandt <cb@256bit.org>
parents:
13170
diff
changeset
|
6562 } |
dc28351a85d4
patch 8.0.1485: weird autocmd may cause arglist to be changed recursively
Christian Brabandt <cb@256bit.org>
parents:
13170
diff
changeset
|
6563 ++recursive; |
7 | 6564 |
6565 alist_clear(al); | |
6566 if (ga_grow(&al->al_ga, count) == OK) | |
6567 { | |
6568 for (i = 0; i < count; ++i) | |
23 | 6569 { |
6570 if (got_int) | |
6571 { | |
6572 /* When adding many buffers this can take a long time. Allow | |
6573 * interrupting here. */ | |
6574 while (i < count) | |
6575 vim_free(files[i++]); | |
6576 break; | |
6577 } | |
41 | 6578 |
6579 /* May set buffer name of a buffer previously used for the | |
6580 * argument list, so that it's re-used by alist_add. */ | |
6581 if (fnum_list != NULL && i < fnum_len) | |
6582 buf_set_name(fnum_list[i], files[i]); | |
6583 | |
7 | 6584 alist_add(al, files[i], use_curbuf ? 2 : 1); |
23 | 6585 ui_breakcheck(); |
6586 } | |
7 | 6587 vim_free(files); |
6588 } | |
6589 else | |
6590 FreeWild(count, files); | |
6591 if (al == &global_alist) | |
6592 arg_had_last = FALSE; | |
13221
dc28351a85d4
patch 8.0.1485: weird autocmd may cause arglist to be changed recursively
Christian Brabandt <cb@256bit.org>
parents:
13170
diff
changeset
|
6593 |
dc28351a85d4
patch 8.0.1485: weird autocmd may cause arglist to be changed recursively
Christian Brabandt <cb@256bit.org>
parents:
13170
diff
changeset
|
6594 --recursive; |
7 | 6595 } |
6596 | |
6597 /* | |
6598 * Add file "fname" to argument list "al". | |
6599 * "fname" must have been allocated and "al" must have been checked for room. | |
6600 */ | |
6601 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6602 alist_add( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6603 alist_T *al, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6604 char_u *fname, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6605 int set_fnum) /* 1: set buffer number; 2: re-use curbuf */ |
7 | 6606 { |
6607 if (fname == NULL) /* don't add NULL file names */ | |
6608 return; | |
6609 #ifdef BACKSLASH_IN_FILENAME | |
6610 slash_adjust(fname); | |
6611 #endif | |
6612 AARGLIST(al)[al->al_ga.ga_len].ae_fname = fname; | |
6613 if (set_fnum > 0) | |
6614 AARGLIST(al)[al->al_ga.ga_len].ae_fnum = | |
6615 buflist_add(fname, BLN_LISTED | (set_fnum == 2 ? BLN_CURBUF : 0)); | |
6616 ++al->al_ga.ga_len; | |
6617 } | |
6618 | |
6619 #if defined(BACKSLASH_IN_FILENAME) || defined(PROTO) | |
6620 /* | |
6621 * Adjust slashes in file names. Called after 'shellslash' was set. | |
6622 */ | |
6623 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6624 alist_slash_adjust(void) |
7 | 6625 { |
6626 int i; | |
6627 win_T *wp; | |
671 | 6628 tabpage_T *tp; |
7 | 6629 |
6630 for (i = 0; i < GARGCOUNT; ++i) | |
6631 if (GARGLIST[i].ae_fname != NULL) | |
6632 slash_adjust(GARGLIST[i].ae_fname); | |
671 | 6633 FOR_ALL_TAB_WINDOWS(tp, wp) |
7 | 6634 if (wp->w_alist != &global_alist) |
6635 for (i = 0; i < WARGCOUNT(wp); ++i) | |
6636 if (WARGLIST(wp)[i].ae_fname != NULL) | |
6637 slash_adjust(WARGLIST(wp)[i].ae_fname); | |
6638 } | |
6639 #endif | |
6640 | |
6641 /* | |
6642 * ":preserve". | |
6643 */ | |
6644 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6645 ex_preserve(exarg_T *eap UNUSED) |
7 | 6646 { |
164 | 6647 curbuf->b_flags |= BF_PRESERVED; |
7 | 6648 ml_preserve(curbuf, TRUE); |
6649 } | |
6650 | |
6651 /* | |
6652 * ":recover". | |
6653 */ | |
6654 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6655 ex_recover(exarg_T *eap) |
7 | 6656 { |
6657 /* Set recoverymode right away to avoid the ATTENTION prompt. */ | |
6658 recoverymode = TRUE; | |
5464 | 6659 if (!check_changed(curbuf, (p_awa ? CCGD_AW : 0) |
6660 | CCGD_MULTWIN | |
6661 | (eap->forceit ? CCGD_FORCEIT : 0) | |
6662 | CCGD_EXCMD) | |
6663 | |
7 | 6664 && (*eap->arg == NUL |
6665 || 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
|
6666 ml_recover(TRUE); |
7 | 6667 recoverymode = FALSE; |
6668 } | |
6669 | |
6670 /* | |
6671 * Command modifier used in a wrong way. | |
6672 */ | |
6673 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6674 ex_wrongmodifier(exarg_T *eap) |
7 | 6675 { |
6676 eap->errmsg = e_invcmd; | |
6677 } | |
6678 | |
6679 /* | |
6680 * :sview [+command] file split window with new file, read-only | |
6681 * :split [[+command] file] split window with current or new file | |
6682 * :vsplit [[+command] file] split window vertically with current or new file | |
6683 * :new [[+command] file] split window with no or new file | |
6684 * :vnew [[+command] file] split vertically window with no or new file | |
6685 * :sfind [+command] file split window with file in 'path' | |
675 | 6686 * |
6687 * :tabedit open new Tab page with empty window | |
6688 * :tabedit [+command] file open new Tab page and edit "file" | |
6689 * :tabnew [[+command] file] just like :tabedit | |
6690 * :tabfind [+command] file open new Tab page and find "file" | |
7 | 6691 */ |
6692 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6693 ex_splitview(exarg_T *eap) |
7 | 6694 { |
675 | 6695 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
|
6696 #if defined(FEAT_SEARCHPATH) || defined(FEAT_BROWSE) |
7 | 6697 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
|
6698 #endif |
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
6699 #ifdef FEAT_BROWSE |
7 | 6700 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
|
6701 #endif |
14155
da09e29e59d9
patch 8.1.0095: dialog for ":browse tabnew" says "new window"
Christian Brabandt <cb@256bit.org>
parents:
14059
diff
changeset
|
6702 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
|
6703 || 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
|
6704 || 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
|
6705 |
17111
af861fccc309
patch 8.1.1555: NOT_IN_POPUP_WINDOW is confusing
Bram Moolenaar <Bram@vim.org>
parents:
17095
diff
changeset
|
6706 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
|
6707 return; |
da5f5836e90c
patch 8.1.1438: some commands cause trouble in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
6708 |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
6709 #ifdef FEAT_GUI |
7 | 6710 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
|
6711 #endif |
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
6712 |
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
6713 #ifdef FEAT_QUICKFIX |
7 | 6714 /* A ":split" in the quickfix window works like ":new". Don't want two |
1661 | 6715 * quickfix windows. But it's OK when doing ":tab split". */ |
6716 if (bt_quickfix(curbuf) && cmdmod.tab == 0) | |
7 | 6717 { |
6718 if (eap->cmdidx == CMD_split) | |
6719 eap->cmdidx = CMD_new; | |
6720 if (eap->cmdidx == CMD_vsplit) | |
6721 eap->cmdidx = CMD_vnew; | |
667 | 6722 } |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
6723 #endif |
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
6724 |
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
6725 #ifdef FEAT_SEARCHPATH |
675 | 6726 if (eap->cmdidx == CMD_sfind || eap->cmdidx == CMD_tabfind) |
7 | 6727 { |
6728 fname = find_file_in_path(eap->arg, (int)STRLEN(eap->arg), | |
6729 FNAME_MESS, TRUE, curbuf->b_ffname); | |
6730 if (fname == NULL) | |
6731 goto theend; | |
6732 eap->arg = fname; | |
6733 } | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
6734 # ifdef FEAT_BROWSE |
7 | 6735 else |
6736 # endif | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
6737 #endif |
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
6738 #ifdef FEAT_BROWSE |
7 | 6739 if (cmdmod.browse |
6740 && eap->cmdidx != CMD_vnew | |
6741 && eap->cmdidx != CMD_new) | |
6742 { | |
461 | 6743 if ( |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
6744 # ifdef FEAT_GUI |
461 | 6745 !gui.in_use && |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
6746 # endif |
461 | 6747 au_has_group((char_u *)"FileExplorer")) |
6748 { | |
6749 /* No browsing supported but we do have the file explorer: | |
6750 * Edit the directory. */ | |
6751 if (*eap->arg == NUL || !mch_isdir(eap->arg)) | |
6752 eap->arg = (char_u *)"."; | |
6753 } | |
6754 else | |
6755 { | |
14155
da09e29e59d9
patch 8.1.0095: dialog for ":browse tabnew" says "new window"
Christian Brabandt <cb@256bit.org>
parents:
14059
diff
changeset
|
6756 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
|
6757 ? _("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
|
6758 : _("Edit File in new window")), |
7 | 6759 eap->arg, NULL, NULL, NULL, curbuf); |
461 | 6760 if (fname == NULL) |
6761 goto theend; | |
6762 eap->arg = fname; | |
6763 } | |
7 | 6764 } |
6765 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
|
6766 #endif |
7 | 6767 |
675 | 6768 /* |
6769 * Either open new tab page or split the window. | |
6770 */ | |
14155
da09e29e59d9
patch 8.1.0095: dialog for ":browse tabnew" says "new window"
Christian Brabandt <cb@256bit.org>
parents:
14059
diff
changeset
|
6771 if (use_tab) |
675 | 6772 { |
820 | 6773 if (win_new_tabpage(cmdmod.tab != 0 ? cmdmod.tab |
6774 : eap->addr_count == 0 ? 0 | |
6775 : (int)eap->line2 + 1) != FAIL) | |
675 | 6776 { |
1498 | 6777 do_exedit(eap, old_curwin); |
675 | 6778 |
6779 /* set the alternate buffer for the window we came from */ | |
6780 if (curwin != old_curwin | |
6781 && win_valid(old_curwin) | |
6782 && old_curwin->w_buffer != curbuf | |
6783 && !cmdmod.keepalt) | |
6784 old_curwin->w_alt_fnum = curbuf->b_fnum; | |
6785 } | |
6786 } | |
6787 else if (win_split(eap->addr_count > 0 ? (int)eap->line2 : 0, | |
7 | 6788 *eap->cmd == 'v' ? WSP_VERT : 0) != FAIL) |
6789 { | |
6790 /* Reset 'scrollbind' when editing another file, but keep it when | |
6791 * doing ":split" without arguments. */ | |
6792 if (*eap->arg != NUL | |
13384
6740c499de13
patch 8.0.1566: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13380
diff
changeset
|
6793 # ifdef FEAT_BROWSE |
7 | 6794 || cmdmod.browse |
13384
6740c499de13
patch 8.0.1566: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13380
diff
changeset
|
6795 # endif |
7 | 6796 ) |
2583 | 6797 RESET_BINDING(curwin); |
7 | 6798 else |
6799 do_check_scrollbind(FALSE); | |
6800 do_exedit(eap, old_curwin); | |
6801 } | |
6802 | |
667 | 6803 # ifdef FEAT_BROWSE |
7 | 6804 cmdmod.browse = browse_flag; |
667 | 6805 # endif |
6806 | |
6807 # if defined(FEAT_SEARCHPATH) || defined(FEAT_BROWSE) | |
7 | 6808 theend: |
6809 vim_free(fname); | |
667 | 6810 # endif |
6811 } | |
6812 | |
6813 /* | |
682 | 6814 * Open a new tab page. |
667 | 6815 */ |
6816 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6817 tabpage_new(void) |
682 | 6818 { |
6819 exarg_T ea; | |
6820 | |
6821 vim_memset(&ea, 0, sizeof(ea)); | |
6822 ea.cmdidx = CMD_tabnew; | |
6823 ea.cmd = (char_u *)"tabn"; | |
6824 ea.arg = (char_u *)""; | |
6825 ex_splitview(&ea); | |
6826 } | |
6827 | |
6828 /* | |
6829 * :tabnext command | |
6830 */ | |
6831 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6832 ex_tabnext(exarg_T *eap) |
682 | 6833 { |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6834 int tab_number; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6835 |
17111
af861fccc309
patch 8.1.1555: NOT_IN_POPUP_WINDOW is confusing
Bram Moolenaar <Bram@vim.org>
parents:
17095
diff
changeset
|
6836 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
|
6837 return; |
685 | 6838 switch (eap->cmdidx) |
6839 { | |
6840 case CMD_tabfirst: | |
6841 case CMD_tabrewind: | |
6842 goto_tabpage(1); | |
6843 break; | |
6844 case CMD_tablast: | |
6845 goto_tabpage(9999); | |
6846 break; | |
6847 case CMD_tabprevious: | |
6848 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
|
6849 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
|
6850 { |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6851 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
|
6852 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
|
6853 |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6854 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
|
6855 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
|
6856 || tab_number == 0) |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6857 { |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6858 /* No numbers as argument. */ |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6859 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
|
6860 return; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6861 } |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6862 } |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6863 else |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6864 { |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6865 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
|
6866 tab_number = 1; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6867 else |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6868 { |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6869 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
|
6870 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
|
6871 { |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6872 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
|
6873 return; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6874 } |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6875 } |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6876 } |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6877 goto_tabpage(-tab_number); |
685 | 6878 break; |
6879 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
|
6880 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
|
6881 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
|
6882 goto_tabpage(tab_number); |
685 | 6883 break; |
6884 } | |
682 | 6885 } |
6886 | |
6887 /* | |
6888 * :tabmove command | |
6889 */ | |
6890 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6891 ex_tabmove(exarg_T *eap) |
682 | 6892 { |
6775 | 6893 int tab_number; |
3662 | 6894 |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6895 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
|
6896 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
|
6897 tabpage_move(tab_number); |
667 | 6898 } |
6899 | |
6900 /* | |
6901 * :tabs command: List tabs and their contents. | |
6902 */ | |
6903 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6904 ex_tabs(exarg_T *eap UNUSED) |
667 | 6905 { |
6906 tabpage_T *tp; | |
6907 win_T *wp; | |
6908 int tabcount = 1; | |
6909 | |
6910 msg_start(); | |
6911 msg_scroll = TRUE; | |
6912 for (tp = first_tabpage; tp != NULL && !got_int; tp = tp->tp_next) | |
6913 { | |
6914 msg_putchar('\n'); | |
6915 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
|
6916 msg_outtrans_attr(IObuff, HL_ATTR(HLF_T)); |
667 | 6917 out_flush(); /* output one line at a time */ |
6918 ui_breakcheck(); | |
6919 | |
678 | 6920 if (tp == curtab) |
667 | 6921 wp = firstwin; |
6922 else | |
6923 wp = tp->tp_firstwin; | |
6924 for ( ; wp != NULL && !got_int; wp = wp->w_next) | |
6925 { | |
682 | 6926 msg_putchar('\n'); |
6927 msg_putchar(wp == curwin ? '>' : ' '); | |
6928 msg_putchar(' '); | |
672 | 6929 msg_putchar(bufIsChanged(wp->w_buffer) ? '+' : ' '); |
6930 msg_putchar(' '); | |
667 | 6931 if (buf_spname(wp->w_buffer) != NULL) |
3839 | 6932 vim_strncpy(IObuff, buf_spname(wp->w_buffer), IOSIZE - 1); |
667 | 6933 else |
6934 home_replace(wp->w_buffer, wp->w_buffer->b_fname, | |
6935 IObuff, IOSIZE, TRUE); | |
6936 msg_outtrans(IObuff); | |
6937 out_flush(); /* output one line at a time */ | |
6938 ui_breakcheck(); | |
6939 } | |
6940 } | |
6941 } | |
6942 | |
7 | 6943 /* |
6944 * ":mode": Set screen mode. | |
6945 * If no argument given, just get the screen size and redraw. | |
6946 */ | |
6947 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6948 ex_mode(exarg_T *eap) |
7 | 6949 { |
6950 if (*eap->arg == NUL) | |
6951 shell_resized(); | |
6952 else | |
6953 mch_screenmode(eap->arg); | |
6954 } | |
6955 | |
6956 /* | |
6957 * ":resize". | |
6958 * set, increment or decrement current window height | |
6959 */ | |
6960 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6961 ex_resize(exarg_T *eap) |
7 | 6962 { |
6963 int n; | |
6964 win_T *wp = curwin; | |
6965 | |
6966 if (eap->addr_count > 0) | |
6967 { | |
6968 n = eap->line2; | |
6969 for (wp = firstwin; wp->w_next != NULL && --n > 0; wp = wp->w_next) | |
6970 ; | |
6971 } | |
6972 | |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8577
diff
changeset
|
6973 # ifdef FEAT_GUI |
7 | 6974 need_mouse_correct = TRUE; |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8577
diff
changeset
|
6975 # endif |
7 | 6976 n = atol((char *)eap->arg); |
6977 if (cmdmod.split & WSP_VERT) | |
6978 { | |
6979 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
|
6980 n += curwin->w_width; |
7 | 6981 else if (n == 0 && eap->arg[0] == NUL) /* default is very wide */ |
6982 n = 9999; | |
6983 win_setwidth_win((int)n, wp); | |
6984 } | |
6985 else | |
6986 { | |
6987 if (*eap->arg == '-' || *eap->arg == '+') | |
6988 n += curwin->w_height; | |
11757
74abb6c84984
patch 8.0.0761: options not set properly for a terminal buffer
Christian Brabandt <cb@256bit.org>
parents:
11635
diff
changeset
|
6989 else if (n == 0 && eap->arg[0] == NUL) /* default is very high */ |
7 | 6990 n = 9999; |
6991 win_setheight_win((int)n, wp); | |
6992 } | |
6993 } | |
6994 | |
6995 /* | |
6996 * ":find [+command] <file>" command. | |
6997 */ | |
6998 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6999 ex_find(exarg_T *eap) |
7 | 7000 { |
7001 #ifdef FEAT_SEARCHPATH | |
7002 char_u *fname; | |
7003 int count; | |
7004 | |
7005 fname = find_file_in_path(eap->arg, (int)STRLEN(eap->arg), FNAME_MESS, | |
7006 TRUE, curbuf->b_ffname); | |
7007 if (eap->addr_count > 0) | |
7008 { | |
7009 /* Repeat finding the file "count" times. This matters when it | |
7010 * appears several times in the path. */ | |
7011 count = eap->line2; | |
7012 while (fname != NULL && --count > 0) | |
7013 { | |
7014 vim_free(fname); | |
7015 fname = find_file_in_path(NULL, 0, FNAME_MESS, | |
7016 FALSE, curbuf->b_ffname); | |
7017 } | |
7018 } | |
7019 | |
7020 if (fname != NULL) | |
7021 { | |
7022 eap->arg = fname; | |
7023 #endif | |
7024 do_exedit(eap, NULL); | |
7025 #ifdef FEAT_SEARCHPATH | |
7026 vim_free(fname); | |
7027 } | |
7028 #endif | |
7029 } | |
7030 | |
7031 /* | |
167 | 7032 * ":open" simulation: for now just work like ":visual". |
7033 */ | |
7034 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7035 ex_open(exarg_T *eap) |
167 | 7036 { |
7037 regmatch_T regmatch; | |
7038 char_u *p; | |
7039 | |
7040 curwin->w_cursor.lnum = eap->line2; | |
7041 beginline(BL_SOL | BL_FIX); | |
7042 if (*eap->arg == '/') | |
7043 { | |
7044 /* ":open /pattern/": put cursor in column found with pattern */ | |
7045 ++eap->arg; | |
7046 p = skip_regexp(eap->arg, '/', p_magic, NULL); | |
7047 *p = NUL; | |
7048 regmatch.regprog = vim_regcomp(eap->arg, p_magic ? RE_MAGIC : 0); | |
7049 if (regmatch.regprog != NULL) | |
7050 { | |
7051 regmatch.rm_ic = p_ic; | |
7052 p = ml_get_curline(); | |
7053 if (vim_regexec(®match, p, (colnr_T)0)) | |
835 | 7054 curwin->w_cursor.col = (colnr_T)(regmatch.startp[0] - p); |
167 | 7055 else |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7056 emsg(_(e_nomatch)); |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4803
diff
changeset
|
7057 vim_regfree(regmatch.regprog); |
167 | 7058 } |
7059 /* Move to the NUL, ignore any other arguments. */ | |
7060 eap->arg += STRLEN(eap->arg); | |
7061 } | |
7062 check_cursor(); | |
7063 | |
7064 eap->cmdidx = CMD_visual; | |
7065 do_exedit(eap, NULL); | |
7066 } | |
7067 | |
7068 /* | |
7069 * ":edit", ":badd", ":visual". | |
7 | 7070 */ |
7071 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7072 ex_edit(exarg_T *eap) |
7 | 7073 { |
7074 do_exedit(eap, NULL); | |
7075 } | |
7076 | |
7077 /* | |
7078 * ":edit <file>" command and alikes. | |
7079 */ | |
7080 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7081 do_exedit( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7082 exarg_T *eap, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7083 win_T *old_curwin) /* curwin before doing a split or NULL */ |
7 | 7084 { |
7085 int n; | |
7086 int need_hide; | |
167 | 7087 int exmode_was = exmode_active; |
7 | 7088 |
17644
daa1dea1c1b3
patch 8.1.1819: :pedit does not work with a popup preview window
Bram Moolenaar <Bram@vim.org>
parents:
17622
diff
changeset
|
7089 if (eap->cmdidx != CMD_pedit && 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
|
7090 return; |
7 | 7091 /* |
7092 * ":vi" command ends Ex mode. | |
7093 */ | |
7094 if (exmode_active && (eap->cmdidx == CMD_visual | |
7095 || eap->cmdidx == CMD_view)) | |
7096 { | |
7097 exmode_active = FALSE; | |
7098 if (*eap->arg == NUL) | |
167 | 7099 { |
7100 /* Special case: ":global/pat/visual\NLvi-commands" */ | |
7101 if (global_busy) | |
7102 { | |
7103 int rd = RedrawingDisabled; | |
7104 int nwr = no_wait_return; | |
7105 int ms = msg_scroll; | |
7106 #ifdef FEAT_GUI | |
7107 int he = hold_gui_events; | |
7108 #endif | |
7109 | |
7110 if (eap->nextcmd != NULL) | |
7111 { | |
7112 stuffReadbuff(eap->nextcmd); | |
7113 eap->nextcmd = NULL; | |
7114 } | |
7115 | |
7116 if (exmode_was != EXMODE_VIM) | |
7117 settmode(TMODE_RAW); | |
7118 RedrawingDisabled = 0; | |
7119 no_wait_return = 0; | |
7120 need_wait_return = FALSE; | |
7121 msg_scroll = 0; | |
7122 #ifdef FEAT_GUI | |
7123 hold_gui_events = 0; | |
7124 #endif | |
7125 must_redraw = CLEAR; | |
7126 | |
7127 main_loop(FALSE, TRUE); | |
7128 | |
7129 RedrawingDisabled = rd; | |
7130 no_wait_return = nwr; | |
7131 msg_scroll = ms; | |
7132 #ifdef FEAT_GUI | |
7133 hold_gui_events = he; | |
7134 #endif | |
7135 } | |
7 | 7136 return; |
167 | 7137 } |
7 | 7138 } |
7139 | |
7140 if ((eap->cmdidx == CMD_new | |
675 | 7141 || eap->cmdidx == CMD_tabnew |
7142 || 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
|
7143 || eap->cmdidx == CMD_vnew) && *eap->arg == NUL) |
7 | 7144 { |
675 | 7145 /* ":new" or ":tabnew" without argument: edit an new empty buffer */ |
7 | 7146 setpcmark(); |
7147 (void)do_ecmd(0, NULL, NULL, eap, ECMD_ONE, | |
1743 | 7148 ECMD_HIDE + (eap->forceit ? ECMD_FORCEIT : 0), |
7149 old_curwin == NULL ? curwin : NULL); | |
7 | 7150 } |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
7151 else if ((eap->cmdidx != CMD_split && eap->cmdidx != CMD_vsplit) |
7 | 7152 || *eap->arg != NUL |
7153 #ifdef FEAT_BROWSE | |
7154 || cmdmod.browse | |
7155 #endif | |
7156 ) | |
7157 { | |
822 | 7158 /* Can't edit another file when "curbuf_lock" is set. Only ":edit" |
7159 * can bring us here, others are stopped earlier. */ | |
7160 if (*eap->arg != NUL && curbuf_locked()) | |
7161 return; | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
7162 |
7 | 7163 n = readonlymode; |
7164 if (eap->cmdidx == CMD_view || eap->cmdidx == CMD_sview) | |
7165 readonlymode = TRUE; | |
7166 else if (eap->cmdidx == CMD_enew) | |
7167 readonlymode = FALSE; /* 'readonly' doesn't make sense in an | |
7168 empty buffer */ | |
7169 setpcmark(); | |
7170 if (do_ecmd(0, (eap->cmdidx == CMD_enew ? NULL : eap->arg), | |
7171 NULL, eap, | |
7172 /* ":edit" goes to first line if Vi compatible */ | |
7173 (*eap->arg == NUL && eap->do_ecmd_lnum == 0 | |
7174 && vim_strchr(p_cpo, CPO_GOTO1) != NULL) | |
7175 ? 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
|
7176 (buf_hide(curbuf) ? ECMD_HIDE : 0) |
7 | 7177 + (eap->forceit ? ECMD_FORCEIT : 0) |
5741 | 7178 /* after a split we can use an existing buffer */ |
7179 + (old_curwin != NULL ? ECMD_OLDBUF : 0) | |
7 | 7180 + (eap->cmdidx == CMD_badd ? ECMD_ADDBUF : 0 ) |
1743 | 7181 , old_curwin == NULL ? curwin : NULL) == FAIL) |
7 | 7182 { |
7183 /* Editing the file failed. If the window was split, close it. */ | |
7184 if (old_curwin != NULL) | |
7185 { | |
7186 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
|
7187 if (!need_hide || buf_hide(curbuf)) |
7 | 7188 { |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
7189 #if defined(FEAT_EVAL) |
24 | 7190 cleanup_T cs; |
7191 | |
7192 /* Reset the error/interrupt/exception state here so that | |
7193 * aborting() returns FALSE when closing a window. */ | |
7194 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
|
7195 #endif |
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
7196 #ifdef FEAT_GUI |
7 | 7197 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
|
7198 #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
|
7199 win_close(curwin, !need_hide && !buf_hide(curbuf)); |
24 | 7200 |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
7201 #if defined(FEAT_EVAL) |
24 | 7202 /* Restore the error/interrupt/exception state if not |
7203 * discarded by a new aborting error, interrupt, or | |
7204 * uncaught exception. */ | |
7205 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
|
7206 #endif |
7 | 7207 } |
7208 } | |
7209 } | |
7210 else if (readonlymode && curbuf->b_nwindows == 1) | |
7211 { | |
7212 /* When editing an already visited buffer, 'readonly' won't be set | |
7213 * but the previous value is kept. With ":view" and ":sview" we | |
7214 * want the file to be readonly, except when another window is | |
7215 * editing the same buffer. */ | |
7216 curbuf->b_p_ro = TRUE; | |
7217 } | |
7218 readonlymode = n; | |
7219 } | |
7220 else | |
7221 { | |
7222 if (eap->do_ecmd_cmd != NULL) | |
7223 do_cmdline_cmd(eap->do_ecmd_cmd); | |
7224 #ifdef FEAT_TITLE | |
7225 n = curwin->w_arg_idx_invalid; | |
7226 #endif | |
7227 check_arg_idx(curwin); | |
7228 #ifdef FEAT_TITLE | |
7229 if (n != curwin->w_arg_idx_invalid) | |
7230 maketitle(); | |
7231 #endif | |
7232 } | |
7233 | |
7234 /* | |
7235 * if ":split file" worked, set alternate file name in old window to new | |
7236 * file | |
7237 */ | |
7238 if (old_curwin != NULL | |
7239 && *eap->arg != NUL | |
7240 && curwin != old_curwin | |
7241 && win_valid(old_curwin) | |
22 | 7242 && old_curwin->w_buffer != curbuf |
7243 && !cmdmod.keepalt) | |
7 | 7244 old_curwin->w_alt_fnum = curbuf->b_fnum; |
7245 | |
7246 ex_no_reprint = TRUE; | |
7247 } | |
7248 | |
7249 #ifndef FEAT_GUI | |
7250 /* | |
7251 * ":gui" and ":gvim" when there is no GUI. | |
7252 */ | |
7253 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7254 ex_nogui(exarg_T *eap) |
7 | 7255 { |
7256 eap->errmsg = e_nogvim; | |
7257 } | |
7258 #endif | |
7259 | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15866
diff
changeset
|
7260 #if defined(FEAT_GUI_MSWIN) && defined(FEAT_MENU) && defined(FEAT_TEAROFF) |
7 | 7261 static void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7262 ex_tearoff(exarg_T *eap) |
7 | 7263 { |
7264 gui_make_tearoff(eap->arg); | |
7265 } | |
7266 #endif | |
7267 | |
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
|
7268 #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
|
7269 || defined(FEAT_TERM_POPUP_MENU)) && defined(FEAT_MENU) |
7 | 7270 static void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7271 ex_popup(exarg_T *eap) |
7 | 7272 { |
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
|
7273 # 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
|
7274 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
|
7275 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
|
7276 # 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
|
7277 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
|
7278 # 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
|
7279 # 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
|
7280 # 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
|
7281 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
|
7282 # endif |
7 | 7283 } |
7284 #endif | |
7285 | |
7286 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7287 ex_swapname(exarg_T *eap UNUSED) |
7 | 7288 { |
7289 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
|
7290 msg(_("No swap file")); |
7 | 7291 else |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15510
diff
changeset
|
7292 msg((char *)curbuf->b_ml.ml_mfp->mf_fname); |
7 | 7293 } |
7294 | |
7295 /* | |
7296 * ":syncbind" forces all 'scrollbind' windows to have the same relative | |
7297 * offset. | |
7298 * (1998-11-02 16:21:01 R. Edward Ralston <eralston@computer.org>) | |
7299 */ | |
7300 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7301 ex_syncbind(exarg_T *eap UNUSED) |
7 | 7302 { |
7303 win_T *wp; | |
5566 | 7304 win_T *save_curwin = curwin; |
7305 buf_T *save_curbuf = curbuf; | |
7 | 7306 long topline; |
7307 long y; | |
7308 linenr_T old_linenr = curwin->w_cursor.lnum; | |
7309 | |
7310 setpcmark(); | |
7311 | |
7312 /* | |
7313 * determine max topline | |
7314 */ | |
7315 if (curwin->w_p_scb) | |
7316 { | |
7317 topline = curwin->w_topline; | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9538
diff
changeset
|
7318 FOR_ALL_WINDOWS(wp) |
7 | 7319 { |
7320 if (wp->w_p_scb && wp->w_buffer) | |
7321 { | |
15713
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15663
diff
changeset
|
7322 y = wp->w_buffer->b_ml.ml_line_count - get_scrolloff_value(); |
7 | 7323 if (topline > y) |
7324 topline = y; | |
7325 } | |
7326 } | |
7327 if (topline < 1) | |
7328 topline = 1; | |
7329 } | |
7330 else | |
7331 { | |
7332 topline = 1; | |
7333 } | |
7334 | |
7335 | |
7336 /* | |
5566 | 7337 * Set all scrollbind windows to the same topline. |
7 | 7338 */ |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9538
diff
changeset
|
7339 FOR_ALL_WINDOWS(curwin) |
7 | 7340 { |
7341 if (curwin->w_p_scb) | |
7342 { | |
5566 | 7343 curbuf = curwin->w_buffer; |
7 | 7344 y = topline - curwin->w_topline; |
7345 if (y > 0) | |
7346 scrollup(y, TRUE); | |
7347 else | |
7348 scrolldown(-y, TRUE); | |
7349 curwin->w_scbind_pos = topline; | |
7350 redraw_later(VALID); | |
7351 cursor_correct(); | |
7352 curwin->w_redr_status = TRUE; | |
7353 } | |
7354 } | |
5566 | 7355 curwin = save_curwin; |
7356 curbuf = save_curbuf; | |
7 | 7357 if (curwin->w_p_scb) |
7358 { | |
7359 did_syncbind = TRUE; | |
7360 checkpcmark(); | |
7361 if (old_linenr != curwin->w_cursor.lnum) | |
7362 { | |
7363 char_u ctrl_o[2]; | |
7364 | |
7365 ctrl_o[0] = Ctrl_O; | |
7366 ctrl_o[1] = 0; | |
7367 ins_typebuf(ctrl_o, REMAP_NONE, 0, TRUE, FALSE); | |
7368 } | |
7369 } | |
7370 } | |
7371 | |
7372 | |
7373 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7374 ex_read(exarg_T *eap) |
7 | 7375 { |
167 | 7376 int i; |
7377 int empty = (curbuf->b_ml.ml_flags & ML_EMPTY); | |
7378 linenr_T lnum; | |
7 | 7379 |
7380 if (eap->usefilter) /* :r!cmd */ | |
7381 do_bang(1, eap, FALSE, FALSE, TRUE); | |
7382 else | |
7383 { | |
7384 if (u_save(eap->line2, (linenr_T)(eap->line2 + 1)) == FAIL) | |
7385 return; | |
7386 | |
7387 #ifdef FEAT_BROWSE | |
7388 if (cmdmod.browse) | |
7389 { | |
7390 char_u *browseFile; | |
7391 | |
28 | 7392 browseFile = do_browse(0, (char_u *)_("Append File"), eap->arg, |
7 | 7393 NULL, NULL, NULL, curbuf); |
7394 if (browseFile != NULL) | |
7395 { | |
7396 i = readfile(browseFile, NULL, | |
7397 eap->line2, (linenr_T)0, (linenr_T)MAXLNUM, eap, 0); | |
7398 vim_free(browseFile); | |
7399 } | |
7400 else | |
7401 i = OK; | |
7402 } | |
7403 else | |
7404 #endif | |
7405 if (*eap->arg == NUL) | |
7406 { | |
7407 if (check_fname() == FAIL) /* check for no file name */ | |
7408 return; | |
7409 i = readfile(curbuf->b_ffname, curbuf->b_fname, | |
7410 eap->line2, (linenr_T)0, (linenr_T)MAXLNUM, eap, 0); | |
7411 } | |
7412 else | |
7413 { | |
7414 if (vim_strchr(p_cpo, CPO_ALTREAD) != NULL) | |
7415 (void)setaltfname(eap->arg, eap->arg, (linenr_T)1); | |
7416 i = readfile(eap->arg, NULL, | |
7417 eap->line2, (linenr_T)0, (linenr_T)MAXLNUM, eap, 0); | |
7418 | |
7419 } | |
10575
01a5f64a7a20
patch 8.0.0177: BufEnter autocommand not fired for a directory
Christian Brabandt <cb@256bit.org>
parents:
10520
diff
changeset
|
7420 if (i != OK) |
7 | 7421 { |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
7422 #if defined(FEAT_EVAL) |
7 | 7423 if (!aborting()) |
7424 #endif | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7425 semsg(_(e_notopen), eap->arg); |
7 | 7426 } |
7427 else | |
167 | 7428 { |
7429 if (empty && exmode_active) | |
7430 { | |
7431 /* Delete the empty line that remains. Historically ex does | |
7432 * this but vi doesn't. */ | |
7433 if (eap->line2 == 0) | |
7434 lnum = curbuf->b_ml.ml_line_count; | |
7435 else | |
7436 lnum = 1; | |
573 | 7437 if (*ml_get(lnum) == NUL && u_savedel(lnum, 1L) == OK) |
167 | 7438 { |
7439 ml_delete(lnum, FALSE); | |
573 | 7440 if (curwin->w_cursor.lnum > 1 |
7441 && curwin->w_cursor.lnum >= lnum) | |
167 | 7442 --curwin->w_cursor.lnum; |
1929 | 7443 deleted_lines_mark(lnum, 1L); |
167 | 7444 } |
7445 } | |
7 | 7446 redraw_curbuf_later(VALID); |
167 | 7447 } |
7 | 7448 } |
7449 } | |
7450 | |
358 | 7451 static char_u *prev_dir = NULL; |
7452 | |
7453 #if defined(EXITFREE) || defined(PROTO) | |
7454 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7455 free_cd_dir(void) |
358 | 7456 { |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13221
diff
changeset
|
7457 VIM_CLEAR(prev_dir); |
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13221
diff
changeset
|
7458 VIM_CLEAR(globaldir); |
358 | 7459 } |
7460 #endif | |
7461 | |
4704
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
7462 /* |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
7463 * 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
|
7464 * 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
|
7465 * 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
|
7466 */ |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
7467 void |
16576
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7468 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
|
7469 { |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7470 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
|
7471 // 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
|
7472 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
|
7473 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
|
7474 if (scope != CDSCOPE_GLOBAL) |
4704
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
7475 { |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
7476 /* If still in global directory, need to remember current |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
7477 * directory as global directory. */ |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
7478 if (globaldir == NULL && prev_dir != NULL) |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
7479 globaldir = vim_strsave(prev_dir); |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
7480 /* Remember this local directory for the window. */ |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
7481 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
|
7482 { |
16576
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7483 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
|
7484 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
|
7485 else |
8c3a1bd270bb
patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents:
16411
diff
changeset
|
7486 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
|
7487 } |
4704
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
7488 } |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
7489 else |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
7490 { |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
7491 /* We are now in the global directory, no need to remember its |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
7492 * name. */ |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13221
diff
changeset
|
7493 VIM_CLEAR(globaldir); |
4704
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
7494 } |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
7495 |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
7496 shorten_fnames(TRUE); |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
7497 } |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
7498 |
16576
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7499 /* |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7500 * Change directory function used by :cd/:tcd/:lcd Ex commands and the |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7501 * chdir() function. If 'winlocaldir' is TRUE, then changes the window-local |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7502 * directory. If 'tablocaldir' is TRUE, then changes the tab-local directory. |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7503 * Otherwise changes the global directory. |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7504 * 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
|
7505 */ |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7506 int |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7507 changedir_func( |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7508 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
|
7509 int forceit, |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7510 cdscope_T scope) |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7511 { |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7512 char_u *tofree; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7513 int dir_differs; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7514 int retval = FALSE; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7515 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7516 if (allbuf_locked()) |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7517 return FALSE; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7518 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7519 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
|
7520 { |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7521 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
|
7522 return FALSE; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7523 } |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7524 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7525 // ":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
|
7526 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
|
7527 { |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7528 if (prev_dir == NULL) |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7529 { |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7530 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
|
7531 return FALSE; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7532 } |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7533 new_dir = prev_dir; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7534 } |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7535 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7536 // 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
|
7537 tofree = prev_dir; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7538 if (mch_dirname(NameBuff, MAXPATHL) == OK) |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7539 prev_dir = vim_strsave(NameBuff); |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7540 else |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7541 prev_dir = NULL; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7542 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7543 #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
|
7544 // 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
|
7545 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
|
7546 { |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7547 // 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
|
7548 # ifdef VMS |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7549 char_u *p; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7550 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7551 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
|
7552 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
|
7553 NameBuff[0] = NUL; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7554 else |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7555 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
|
7556 # else |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7557 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
|
7558 # endif |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7559 new_dir = NameBuff; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7560 } |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7561 #endif |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7562 dir_differs = new_dir == NULL || prev_dir == NULL |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7563 || pathcmp((char *)prev_dir, (char *)new_dir, -1) != 0; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7564 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
|
7565 emsg(_(e_failed)); |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7566 else |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7567 { |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7568 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
|
7569 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7570 post_chdir(scope); |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7571 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7572 if (dir_differs) |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7573 { |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7574 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
|
7575 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
|
7576 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
|
7577 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
|
7578 else |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7579 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
|
7580 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
|
7581 curbuf); |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7582 } |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7583 retval = TRUE; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7584 } |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7585 vim_free(tofree); |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7586 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7587 return retval; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7588 } |
358 | 7589 |
7 | 7590 /* |
16427
8c3a1bd270bb
patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents:
16411
diff
changeset
|
7591 * ":cd", ":tcd", ":lcd", ":chdir" ":tchdir" and ":lchdir". |
7 | 7592 */ |
1411 | 7593 void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7594 ex_cd(exarg_T *eap) |
7 | 7595 { |
15184
90ab2d3ce11d
patch 8.1.0602: DirChanged is also triggered when directory didn't change
Bram Moolenaar <Bram@vim.org>
parents:
15152
diff
changeset
|
7596 char_u *new_dir; |
7 | 7597 |
7598 new_dir = eap->arg; | |
7599 #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
|
7600 // for non-UNIX ":cd" means: print current directory |
7 | 7601 if (*new_dir == NUL) |
7602 ex_pwd(NULL); | |
7603 else | |
7604 #endif | |
7605 { | |
16576
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7606 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
|
7607 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7608 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
|
7609 scope = CDSCOPE_WINDOW; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7610 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
|
7611 scope = CDSCOPE_TABPAGE; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7612 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7613 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
|
7614 { |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7615 // Echo the new current directory if the command was typed. |
1930 | 7616 if (KeyTyped || p_verbose >= 5) |
7 | 7617 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
|
7618 } |
7 | 7619 } |
7620 } | |
7621 | |
7622 /* | |
7623 * ":pwd". | |
7624 */ | |
7625 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7626 ex_pwd(exarg_T *eap UNUSED) |
7 | 7627 { |
7628 if (mch_dirname(NameBuff, MAXPATHL) == OK) | |
7629 { | |
7630 #ifdef BACKSLASH_IN_FILENAME | |
7631 slash_adjust(NameBuff); | |
7632 #endif | |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15510
diff
changeset
|
7633 msg((char *)NameBuff); |
7 | 7634 } |
7635 else | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7636 emsg(_("E187: Unknown")); |
7 | 7637 } |
7638 | |
7639 /* | |
7640 * ":=". | |
7641 */ | |
7642 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7643 ex_equal(exarg_T *eap) |
7 | 7644 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7645 smsg("%ld", (long)eap->line2); |
167 | 7646 ex_may_print(eap); |
7 | 7647 } |
7648 | |
7649 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7650 ex_sleep(exarg_T *eap) |
7 | 7651 { |
236 | 7652 int n; |
7653 long len; | |
7 | 7654 |
7655 if (cursor_valid()) | |
7656 { | |
7657 n = W_WINROW(curwin) + curwin->w_wrow - msg_scrolled; | |
7658 if (n >= 0) | |
12513
3ca08bf99396
patch 8.0.1135: W_WINCOL() is always the same
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
7659 windgoto((int)n, curwin->w_wincol + curwin->w_wcol); |
7 | 7660 } |
236 | 7661 |
7662 len = eap->line2; | |
7663 switch (*eap->arg) | |
7664 { | |
7665 case 'm': break; | |
7666 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
|
7667 default: semsg(_(e_invarg2), eap->arg); return; |
236 | 7668 } |
7669 do_sleep(len); | |
7 | 7670 } |
7671 | |
7672 /* | |
7673 * Sleep for "msec" milliseconds, but keep checking for a CTRL-C every second. | |
7674 */ | |
7675 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7676 do_sleep(long msec) |
7 | 7677 { |
7678 long done; | |
8577
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
7679 long wait_now; |
7 | 7680 |
7681 cursor_on(); | |
14860
ac5d0d27aef9
patch 8.1.0442: GUI: cursor not drawn after ":redraw | sleep"
Christian Brabandt <cb@256bit.org>
parents:
14760
diff
changeset
|
7682 out_flush_cursor(FALSE, FALSE); |
8577
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
7683 for (done = 0; !got_int && done < msec; done += wait_now) |
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
7684 { |
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
7685 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
|
7686 #ifdef FEAT_TIMERS |
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
7687 { |
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
7688 long due_time = check_due_timer(); |
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
7689 |
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
7690 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
|
7691 wait_now = due_time; |
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
7692 } |
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
7693 #endif |
10240
175b1116f96a
commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents:
10184
diff
changeset
|
7694 #ifdef FEAT_JOB_CHANNEL |
175b1116f96a
commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents:
10184
diff
changeset
|
7695 if (has_any_channel() && wait_now > 100L) |
175b1116f96a
commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents:
10184
diff
changeset
|
7696 wait_now = 100L; |
175b1116f96a
commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents:
10184
diff
changeset
|
7697 #endif |
8577
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
7698 ui_delay(wait_now, TRUE); |
10240
175b1116f96a
commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents:
10184
diff
changeset
|
7699 #ifdef FEAT_JOB_CHANNEL |
175b1116f96a
commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents:
10184
diff
changeset
|
7700 if (has_any_channel()) |
175b1116f96a
commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents:
10184
diff
changeset
|
7701 ui_breakcheck_force(TRUE); |
175b1116f96a
commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents:
10184
diff
changeset
|
7702 else |
175b1116f96a
commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents:
10184
diff
changeset
|
7703 #endif |
175b1116f96a
commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents:
10184
diff
changeset
|
7704 ui_breakcheck(); |
7109
fa95595fbc52
commit https://github.com/vim/vim/commit/93c88e0f6a4a8f7634ed84721daf4af46fc0d5db
Christian Brabandt <cb@256bit.org>
parents:
7105
diff
changeset
|
7705 #ifdef MESSAGE_QUEUE |
fa95595fbc52
commit https://github.com/vim/vim/commit/93c88e0f6a4a8f7634ed84721daf4af46fc0d5db
Christian Brabandt <cb@256bit.org>
parents:
7105
diff
changeset
|
7706 /* Process the netbeans and clientserver messages that may have been |
fa95595fbc52
commit https://github.com/vim/vim/commit/93c88e0f6a4a8f7634ed84721daf4af46fc0d5db
Christian Brabandt <cb@256bit.org>
parents:
7105
diff
changeset
|
7707 * received in the call to ui_breakcheck() when the GUI is in use. This |
fa95595fbc52
commit https://github.com/vim/vim/commit/93c88e0f6a4a8f7634ed84721daf4af46fc0d5db
Christian Brabandt <cb@256bit.org>
parents:
7105
diff
changeset
|
7708 * may occur when running a test case. */ |
fa95595fbc52
commit https://github.com/vim/vim/commit/93c88e0f6a4a8f7634ed84721daf4af46fc0d5db
Christian Brabandt <cb@256bit.org>
parents:
7105
diff
changeset
|
7709 parse_queued_messages(); |
3151 | 7710 #endif |
7 | 7711 } |
14284
7cd8298c4c04
patch 8.1.0158: GUI: input() fails if CTRL-C was pressed before
Christian Brabandt <cb@256bit.org>
parents:
14266
diff
changeset
|
7712 |
7cd8298c4c04
patch 8.1.0158: GUI: input() fails if CTRL-C was pressed before
Christian Brabandt <cb@256bit.org>
parents:
14266
diff
changeset
|
7713 // 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
|
7714 // 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
|
7715 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
|
7716 (void)vpeekc(); |
7 | 7717 } |
7718 | |
7719 /* | |
7720 * ":winsize" command (obsolete). | |
7721 */ | |
7722 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7723 ex_winsize(exarg_T *eap) |
7 | 7724 { |
7725 int w, h; | |
7726 char_u *arg = eap->arg; | |
7727 char_u *p; | |
7728 | |
7729 w = getdigits(&arg); | |
7730 arg = skipwhite(arg); | |
7731 p = arg; | |
7732 h = getdigits(&arg); | |
7733 if (*p != NUL && *arg == NUL) | |
7734 set_shellsize(w, h, TRUE); | |
7735 else | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7736 emsg(_("E465: :winsize requires two number arguments")); |
7 | 7737 } |
7738 | |
7739 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7740 ex_wincmd(exarg_T *eap) |
7 | 7741 { |
7742 int xchar = NUL; | |
7743 char_u *p; | |
7744 | |
7745 if (*eap->arg == 'g' || *eap->arg == Ctrl_G) | |
7746 { | |
7747 /* CTRL-W g and CTRL-W CTRL-G have an extra command character */ | |
7748 if (eap->arg[1] == NUL) | |
7749 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7750 emsg(_(e_invarg)); |
7 | 7751 return; |
7752 } | |
7753 xchar = eap->arg[1]; | |
7754 p = eap->arg + 2; | |
7755 } | |
7756 else | |
7757 p = eap->arg + 1; | |
7758 | |
7759 eap->nextcmd = check_nextcmd(p); | |
7760 p = skipwhite(p); | |
7761 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
|
7762 emsg(_(e_invarg)); |
2887 | 7763 else if (!eap->skip) |
7 | 7764 { |
7765 /* Pass flags on for ":vertical wincmd ]". */ | |
7766 postponed_split_flags = cmdmod.split; | |
1090 | 7767 postponed_split_tab = cmdmod.tab; |
7 | 7768 do_window(*eap->arg, eap->addr_count > 0 ? eap->line2 : 0L, xchar); |
7769 postponed_split_flags = 0; | |
1090 | 7770 postponed_split_tab = 0; |
7 | 7771 } |
7772 } | |
7773 | |
11 | 7774 #if defined(FEAT_GUI) || defined(UNIX) || defined(VMS) || defined(MSWIN) |
7 | 7775 /* |
7776 * ":winpos". | |
7777 */ | |
7778 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7779 ex_winpos(exarg_T *eap) |
7 | 7780 { |
7781 int x, y; | |
7782 char_u *arg = eap->arg; | |
7783 char_u *p; | |
7784 | |
7785 if (*arg == NUL) | |
7786 { | |
11 | 7787 # 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
|
7788 # 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
|
7789 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
|
7790 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
|
7791 # elif defined(FEAT_GUI) |
7 | 7792 if (gui.in_use && gui_mch_get_winpos(&x, &y) != FAIL) |
11 | 7793 # else |
7794 if (mch_get_winpos(&x, &y) != FAIL) | |
7795 # endif | |
7 | 7796 { |
7797 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
|
7798 msg((char *)IObuff); |
7 | 7799 } |
7800 else | |
7801 # endif | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7802 emsg(_("E188: Obtaining window position not implemented for this platform")); |
7 | 7803 } |
7804 else | |
7805 { | |
7806 x = getdigits(&arg); | |
7807 arg = skipwhite(arg); | |
7808 p = arg; | |
7809 y = getdigits(&arg); | |
7810 if (*p == NUL || *arg != NUL) | |
7811 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7812 emsg(_("E466: :winpos requires two number arguments")); |
7 | 7813 return; |
7814 } | |
7815 # ifdef FEAT_GUI | |
7816 if (gui.in_use) | |
7817 gui_mch_set_winpos(x, y); | |
7818 else if (gui.starting) | |
7819 { | |
7820 /* Remember the coordinates for when the window is opened. */ | |
7821 gui_win_x = x; | |
7822 gui_win_y = y; | |
7823 } | |
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
|
7824 # if defined(HAVE_TGETENT) || defined(VIMDLL) |
7 | 7825 else |
7826 # 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
|
7827 # 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
|
7828 # if defined(MSWIN) && (!defined(FEAT_GUI) || defined(VIMDLL)) |
11 | 7829 mch_set_winpos(x, y); |
7 | 7830 # endif |
7831 # ifdef HAVE_TGETENT | |
7832 if (*T_CWP) | |
7833 term_set_winpos(x, y); | |
7834 # endif | |
7835 } | |
7836 } | |
7837 #endif | |
7838 | |
7839 /* | |
7840 * Handle command that work like operators: ":delete", ":yank", ":>" and ":<". | |
7841 */ | |
7842 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7843 ex_operators(exarg_T *eap) |
7 | 7844 { |
7845 oparg_T oa; | |
7846 | |
7847 clear_oparg(&oa); | |
7848 oa.regname = eap->regname; | |
7849 oa.start.lnum = eap->line1; | |
7850 oa.end.lnum = eap->line2; | |
7851 oa.line_count = eap->line2 - eap->line1 + 1; | |
7852 oa.motion_type = MLINE; | |
7853 virtual_op = FALSE; | |
7854 if (eap->cmdidx != CMD_yank) /* position cursor for undo */ | |
7855 { | |
7856 setpcmark(); | |
7857 curwin->w_cursor.lnum = eap->line1; | |
7858 beginline(BL_SOL | BL_FIX); | |
7859 } | |
7860 | |
5498 | 7861 if (VIsual_active) |
7862 end_visual_mode(); | |
7863 | |
7 | 7864 switch (eap->cmdidx) |
7865 { | |
7866 case CMD_delete: | |
7867 oa.op_type = OP_DELETE; | |
7868 op_delete(&oa); | |
7869 break; | |
7870 | |
7871 case CMD_yank: | |
7872 oa.op_type = OP_YANK; | |
7873 (void)op_yank(&oa, FALSE, TRUE); | |
7874 break; | |
7875 | |
7876 default: /* CMD_rshift or CMD_lshift */ | |
4889
25d64a4edc0b
updated for version 7.3.1190
Bram Moolenaar <bram@vim.org>
parents:
4857
diff
changeset
|
7877 if ( |
7 | 7878 #ifdef FEAT_RIGHTLEFT |
4889
25d64a4edc0b
updated for version 7.3.1190
Bram Moolenaar <bram@vim.org>
parents:
4857
diff
changeset
|
7879 (eap->cmdidx == CMD_rshift) ^ curwin->w_p_rl |
25d64a4edc0b
updated for version 7.3.1190
Bram Moolenaar <bram@vim.org>
parents:
4857
diff
changeset
|
7880 #else |
25d64a4edc0b
updated for version 7.3.1190
Bram Moolenaar <bram@vim.org>
parents:
4857
diff
changeset
|
7881 eap->cmdidx == CMD_rshift |
25d64a4edc0b
updated for version 7.3.1190
Bram Moolenaar <bram@vim.org>
parents:
4857
diff
changeset
|
7882 #endif |
25d64a4edc0b
updated for version 7.3.1190
Bram Moolenaar <bram@vim.org>
parents:
4857
diff
changeset
|
7883 ) |
7 | 7884 oa.op_type = OP_RSHIFT; |
7885 else | |
7886 oa.op_type = OP_LSHIFT; | |
7887 op_shift(&oa, FALSE, eap->amount); | |
7888 break; | |
7889 } | |
7890 virtual_op = MAYBE; | |
167 | 7891 ex_may_print(eap); |
7 | 7892 } |
7893 | |
7894 /* | |
7895 * ":put". | |
7896 */ | |
7897 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7898 ex_put(exarg_T *eap) |
7 | 7899 { |
7900 /* ":0put" works like ":1put!". */ | |
7901 if (eap->line2 == 0) | |
7902 { | |
7903 eap->line2 = 1; | |
7904 eap->forceit = TRUE; | |
7905 } | |
7906 curwin->w_cursor.lnum = eap->line2; | |
167 | 7907 do_put(eap->regname, eap->forceit ? BACKWARD : FORWARD, 1L, |
7908 PUT_LINE|PUT_CURSLINE); | |
7 | 7909 } |
7910 | |
7911 /* | |
7912 * Handle ":copy" and ":move". | |
7913 */ | |
7914 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7915 ex_copymove(exarg_T *eap) |
7 | 7916 { |
7917 long n; | |
7918 | |
14760
fd69edd2c67e
patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents:
14700
diff
changeset
|
7919 n = get_address(eap, &eap->arg, eap->addr_type, FALSE, FALSE, FALSE, 1); |
7 | 7920 if (eap->arg == NULL) /* error detected */ |
7921 { | |
7922 eap->nextcmd = NULL; | |
7923 return; | |
7924 } | |
167 | 7925 get_flags(eap); |
7 | 7926 |
7927 /* | |
7928 * move or copy lines from 'eap->line1'-'eap->line2' to below line 'n' | |
7929 */ | |
7930 if (n == MAXLNUM || n < 0 || n > curbuf->b_ml.ml_line_count) | |
7931 { | |
17650
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
7932 emsg(_(e_invrange)); |
7 | 7933 return; |
7934 } | |
7935 | |
7936 if (eap->cmdidx == CMD_move) | |
7937 { | |
7938 if (do_move(eap->line1, eap->line2, n) == FAIL) | |
7939 return; | |
7940 } | |
7941 else | |
7942 ex_copy(eap->line1, eap->line2, n); | |
7943 u_clearline(); | |
7944 beginline(BL_SOL | BL_FIX); | |
167 | 7945 ex_may_print(eap); |
7946 } | |
7947 | |
7948 /* | |
7949 * Print the current line if flags were given to the Ex command. | |
7950 */ | |
5776 | 7951 void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7952 ex_may_print(exarg_T *eap) |
167 | 7953 { |
7954 if (eap->flags != 0) | |
7955 { | |
7956 print_line(curwin->w_cursor.lnum, (eap->flags & EXFLAG_NR), | |
7957 (eap->flags & EXFLAG_LIST)); | |
7958 ex_no_reprint = TRUE; | |
7959 } | |
7 | 7960 } |
7961 | |
7962 /* | |
7963 * ":smagic" and ":snomagic". | |
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_submagic(exarg_T *eap) |
7 | 7967 { |
7968 int magic_save = p_magic; | |
7969 | |
7970 p_magic = (eap->cmdidx == CMD_smagic); | |
7971 do_sub(eap); | |
7972 p_magic = magic_save; | |
7973 } | |
7974 | |
7975 /* | |
7976 * ":join". | |
7977 */ | |
7978 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7979 ex_join(exarg_T *eap) |
7 | 7980 { |
7981 curwin->w_cursor.lnum = eap->line1; | |
7982 if (eap->line1 == eap->line2) | |
7983 { | |
7984 if (eap->addr_count >= 2) /* :2,2join does nothing */ | |
7985 return; | |
7986 if (eap->line2 == curbuf->b_ml.ml_line_count) | |
7987 { | |
7988 beep_flush(); | |
7989 return; | |
7990 } | |
7991 ++eap->line2; | |
7992 } | |
5848 | 7993 (void)do_join(eap->line2 - eap->line1 + 1, !eap->forceit, TRUE, TRUE, TRUE); |
7 | 7994 beginline(BL_WHITE | BL_FIX); |
167 | 7995 ex_may_print(eap); |
7 | 7996 } |
7997 | |
7998 /* | |
7999 * ":[addr]@r" or ":[addr]*r": execute register | |
8000 */ | |
8001 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8002 ex_at(exarg_T *eap) |
7 | 8003 { |
8004 int c; | |
1973 | 8005 int prev_len = typebuf.tb_len; |
7 | 8006 |
8007 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
|
8008 check_cursor_col(); |
7 | 8009 |
8010 #ifdef USE_ON_FLY_SCROLL | |
8011 dont_scroll = TRUE; /* disallow scrolling here */ | |
8012 #endif | |
8013 | |
8014 /* get the register name. No name means to use the previous one */ | |
8015 c = *eap->arg; | |
8016 if (c == NUL || (c == '*' && *eap->cmd == '*')) | |
8017 c = '@'; | |
1034 | 8018 /* Put the register in the typeahead buffer with the "silent" flag. */ |
8019 if (do_execreg(c, TRUE, vim_strchr(p_cpo, CPO_EXECBUF) != NULL, TRUE) | |
8020 == FAIL) | |
167 | 8021 { |
7 | 8022 beep_flush(); |
167 | 8023 } |
7 | 8024 else |
8025 { | |
8026 int save_efr = exec_from_reg; | |
8027 | |
8028 exec_from_reg = TRUE; | |
8029 | |
8030 /* | |
8031 * Execute from the typeahead buffer. | |
1973 | 8032 * Continue until the stuff buffer is empty and all added characters |
8033 * have been consumed. | |
7 | 8034 */ |
1973 | 8035 while (!stuff_empty() || typebuf.tb_len > prev_len) |
7 | 8036 (void)do_cmdline(NULL, getexline, NULL, DOCMD_NOWAIT|DOCMD_VERBOSE); |
8037 | |
8038 exec_from_reg = save_efr; | |
8039 } | |
8040 } | |
8041 | |
8042 /* | |
8043 * ":!". | |
8044 */ | |
8045 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8046 ex_bang(exarg_T *eap) |
7 | 8047 { |
8048 do_bang(eap->addr_count, eap, eap->forceit, TRUE, TRUE); | |
8049 } | |
8050 | |
8051 /* | |
8052 * ":undo". | |
8053 */ | |
8054 static void | |
8368
db2a07b710ed
commit https://github.com/vim/vim/commit/f1d2501ebe33e148886c2914acd33140e20ee222
Christian Brabandt <cb@256bit.org>
parents:
8281
diff
changeset
|
8055 ex_undo(exarg_T *eap) |
7 | 8056 { |
771 | 8057 if (eap->addr_count == 1) /* :undo 123 */ |
2281
e41433ea71df
Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents:
2276
diff
changeset
|
8058 undo_time(eap->line2, FALSE, FALSE, TRUE); |
771 | 8059 else |
8060 u_undo(1); | |
7 | 8061 } |
8062 | |
2214
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
8063 #ifdef FEAT_PERSISTENT_UNDO |
2340
99c1eba60b2d
Make automatic prototype generation work with more interfaces.
Bram Moolenaar <bram@vim.org>
parents:
2333
diff
changeset
|
8064 static void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8065 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
|
8066 { |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
8067 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
|
8068 |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
8069 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
|
8070 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
|
8071 } |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
8072 |
2340
99c1eba60b2d
Make automatic prototype generation work with more interfaces.
Bram Moolenaar <bram@vim.org>
parents:
2333
diff
changeset
|
8073 static void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8074 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
|
8075 { |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
8076 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
|
8077 |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
8078 u_compute_hash(hash); |
2238
3d0a7beb0d75
Made reading/writing undo info a bit more robust.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
8079 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
|
8080 } |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
8081 #endif |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
8082 |
7 | 8083 /* |
8084 * ":redo". | |
8085 */ | |
8086 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8087 ex_redo(exarg_T *eap UNUSED) |
7 | 8088 { |
8089 u_redo(1); | |
8090 } | |
8091 | |
8092 /* | |
756 | 8093 * ":earlier" and ":later". |
8094 */ | |
8095 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8096 ex_later(exarg_T *eap) |
756 | 8097 { |
8098 long count = 0; | |
8099 int sec = FALSE; | |
2281
e41433ea71df
Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents:
2276
diff
changeset
|
8100 int file = FALSE; |
756 | 8101 char_u *p = eap->arg; |
8102 | |
8103 if (*p == NUL) | |
8104 count = 1; | |
8105 else if (isdigit(*p)) | |
8106 { | |
8107 count = getdigits(&p); | |
8108 switch (*p) | |
8109 { | |
8110 case 's': ++p; sec = TRUE; break; | |
8111 case 'm': ++p; sec = TRUE; count *= 60; break; | |
8112 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
|
8113 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
|
8114 case 'f': ++p; file = TRUE; break; |
756 | 8115 } |
8116 } | |
8117 | |
8118 if (*p != NUL) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8119 semsg(_(e_invarg2), eap->arg); |
756 | 8120 else |
2281
e41433ea71df
Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents:
2276
diff
changeset
|
8121 undo_time(eap->cmdidx == CMD_earlier ? -count : count, |
e41433ea71df
Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents:
2276
diff
changeset
|
8122 sec, file, FALSE); |
756 | 8123 } |
8124 | |
8125 /* | |
7 | 8126 * ":redir": start/stop redirection. |
8127 */ | |
8128 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8129 ex_redir(exarg_T *eap) |
7 | 8130 { |
8131 char *mode; | |
8132 char_u *fname; | |
122 | 8133 char_u *arg = eap->arg; |
7 | 8134 |
9440
73c0d07cc15e
commit https://github.com/vim/vim/commit/ba768495c2e6bae74e49d22d489fbf211ecad55e
Christian Brabandt <cb@256bit.org>
parents:
9438
diff
changeset
|
8135 #ifdef FEAT_EVAL |
9454
9da0cb39cbee
commit https://github.com/vim/vim/commit/79815f1ec77406f2f21a618c053e5793b597db7a
Christian Brabandt <cb@256bit.org>
parents:
9440
diff
changeset
|
8136 if (redir_execute) |
9da0cb39cbee
commit https://github.com/vim/vim/commit/79815f1ec77406f2f21a618c053e5793b597db7a
Christian Brabandt <cb@256bit.org>
parents:
9440
diff
changeset
|
8137 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8138 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
|
8139 return; |
7897b1e4f3e7
commit https://github.com/vim/vim/commit/245a7cb6d33e556415c9fcaa874b784a6d8f0ef3
Christian Brabandt <cb@256bit.org>
parents:
9432
diff
changeset
|
8140 } |
9440
73c0d07cc15e
commit https://github.com/vim/vim/commit/ba768495c2e6bae74e49d22d489fbf211ecad55e
Christian Brabandt <cb@256bit.org>
parents:
9438
diff
changeset
|
8141 #endif |
9438
7897b1e4f3e7
commit https://github.com/vim/vim/commit/245a7cb6d33e556415c9fcaa874b784a6d8f0ef3
Christian Brabandt <cb@256bit.org>
parents:
9432
diff
changeset
|
8142 |
7 | 8143 if (STRICMP(eap->arg, "END") == 0) |
8144 close_redir(); | |
8145 else | |
8146 { | |
122 | 8147 if (*arg == '>') |
8148 { | |
8149 ++arg; | |
8150 if (*arg == '>') | |
8151 { | |
8152 ++arg; | |
7 | 8153 mode = "a"; |
8154 } | |
8155 else | |
8156 mode = "w"; | |
122 | 8157 arg = skipwhite(arg); |
7 | 8158 |
8159 close_redir(); | |
8160 | |
8161 /* Expand environment variables and "~/". */ | |
122 | 8162 fname = expand_env_save(arg); |
7 | 8163 if (fname == NULL) |
8164 return; | |
8165 #ifdef FEAT_BROWSE | |
8166 if (cmdmod.browse) | |
8167 { | |
8168 char_u *browseFile; | |
8169 | |
28 | 8170 browseFile = do_browse(BROWSE_SAVE, |
8171 (char_u *)_("Save Redirection"), | |
13802
378f9f8e6d8f
patch 8.0.1773: dialog messages are not translated
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
8172 fname, NULL, NULL, |
378f9f8e6d8f
patch 8.0.1773: dialog messages are not translated
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
8173 (char_u *)_(BROWSE_FILTER_ALL_FILES), curbuf); |
7 | 8174 if (browseFile == NULL) |
8175 return; /* operation cancelled */ | |
8176 vim_free(fname); | |
8177 fname = browseFile; | |
8178 eap->forceit = TRUE; /* since dialog already asked */ | |
8179 } | |
8180 #endif | |
8181 | |
8182 redir_fd = open_exfile(fname, eap->forceit, mode); | |
8183 vim_free(fname); | |
8184 } | |
8185 #ifdef FEAT_EVAL | |
122 | 8186 else if (*arg == '@') |
7 | 8187 { |
8188 /* redirect to a register a-z (resp. A-Z for appending) */ | |
8189 close_redir(); | |
122 | 8190 ++arg; |
8191 if (ASCII_ISALPHA(*arg) | |
7 | 8192 # ifdef FEAT_CLIPBOARD |
122 | 8193 || *arg == '*' |
1038 | 8194 || *arg == '+' |
7 | 8195 # endif |
122 | 8196 || *arg == '"') |
8197 { | |
8198 redir_reg = *arg++; | |
1427 | 8199 if (*arg == '>' && arg[1] == '>') /* append */ |
268 | 8200 arg += 2; |
1427 | 8201 else |
7 | 8202 { |
1427 | 8203 /* Can use both "@a" and "@a>". */ |
296 | 8204 if (*arg == '>') |
8205 arg++; | |
1427 | 8206 /* Make register empty when not using @A-@Z and the |
8207 * command is valid. */ | |
8208 if (*arg == NUL && !isupper(redir_reg)) | |
8209 write_reg_contents(redir_reg, (char_u *)"", -1, FALSE); | |
7 | 8210 } |
167 | 8211 } |
8212 if (*arg != NUL) | |
8213 { | |
268 | 8214 redir_reg = 0; |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8215 semsg(_(e_invarg2), eap->arg); |
167 | 8216 } |
8217 } | |
8218 else if (*arg == '=' && arg[1] == '>') | |
8219 { | |
8220 int append; | |
8221 | |
8222 /* redirect to a variable */ | |
8223 close_redir(); | |
8224 arg += 2; | |
8225 | |
8226 if (*arg == '>') | |
8227 { | |
8228 ++arg; | |
8229 append = TRUE; | |
7 | 8230 } |
8231 else | |
167 | 8232 append = FALSE; |
8233 | |
8234 if (var_redir_start(skipwhite(arg), append) == OK) | |
8235 redir_vname = 1; | |
7 | 8236 } |
8237 #endif | |
8238 | |
8239 /* TODO: redirect to a buffer */ | |
8240 | |
8241 else | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8242 semsg(_(e_invarg2), eap->arg); |
7 | 8243 } |
972 | 8244 |
8245 /* Make sure redirection is not off. Can happen for cmdline completion | |
8246 * that indirectly invokes a command to catch its output. */ | |
8247 if (redir_fd != NULL | |
8248 #ifdef FEAT_EVAL | |
8249 || redir_reg || redir_vname | |
8250 #endif | |
8251 ) | |
8252 redir_off = FALSE; | |
7 | 8253 } |
8254 | |
8255 /* | |
8256 * ":redraw": force redraw | |
8257 */ | |
7864
6b0891de44a9
commit https://github.com/vim/vim/commit/fb1f62691eae7c79a28b3b17a60e72ce198c71a2
Christian Brabandt <cb@256bit.org>
parents:
7850
diff
changeset
|
8258 void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8259 ex_redraw(exarg_T *eap) |
7 | 8260 { |
8261 int r = RedrawingDisabled; | |
8262 int p = p_lz; | |
8263 | |
8264 RedrawingDisabled = 0; | |
8265 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
|
8266 validate_cursor(); |
7 | 8267 update_topline(); |
5735 | 8268 update_screen(eap->forceit ? CLEAR : VIsual_active ? INVERTED : 0); |
7 | 8269 #ifdef FEAT_TITLE |
8270 if (need_maketitle) | |
8271 maketitle(); | |
8272 #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
|
8273 #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
|
8274 # 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
|
8275 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
|
8276 # 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
|
8277 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
|
8278 #endif |
7 | 8279 RedrawingDisabled = r; |
8280 p_lz = p; | |
8281 | |
8282 /* Reset msg_didout, so that a message that's there is overwritten. */ | |
8283 msg_didout = FALSE; | |
8284 msg_col = 0; | |
8285 | |
5198
1b89e3f916c5
updated for version 7.4a.025
Bram Moolenaar <bram@vim.org>
parents:
4928
diff
changeset
|
8286 /* No need to wait after an intentional redraw. */ |
1b89e3f916c5
updated for version 7.4a.025
Bram Moolenaar <bram@vim.org>
parents:
4928
diff
changeset
|
8287 need_wait_return = FALSE; |
1b89e3f916c5
updated for version 7.4a.025
Bram Moolenaar <bram@vim.org>
parents:
4928
diff
changeset
|
8288 |
7 | 8289 out_flush(); |
8290 } | |
8291 | |
8292 /* | |
8293 * ":redrawstatus": force redraw of status line(s) | |
8294 */ | |
8295 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8296 ex_redrawstatus(exarg_T *eap UNUSED) |
7 | 8297 { |
8298 int r = RedrawingDisabled; | |
8299 int p = p_lz; | |
8300 | |
8301 RedrawingDisabled = 0; | |
8302 p_lz = FALSE; | |
8303 if (eap->forceit) | |
8304 status_redraw_all(); | |
8305 else | |
8306 status_redraw_curbuf(); | |
5735 | 8307 update_screen(VIsual_active ? INVERTED : 0); |
7 | 8308 RedrawingDisabled = r; |
8309 p_lz = p; | |
8310 out_flush(); | |
8311 } | |
8312 | |
15396
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
8313 /* |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
8314 * ":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
|
8315 */ |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
8316 static void |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
8317 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
|
8318 { |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
8319 int r = RedrawingDisabled; |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
8320 int p = p_lz; |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
8321 |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
8322 RedrawingDisabled = 0; |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
8323 p_lz = FALSE; |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
8324 |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
8325 draw_tabline(); |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
8326 |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
8327 RedrawingDisabled = r; |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
8328 p_lz = p; |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
8329 out_flush(); |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
8330 } |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
8331 |
7 | 8332 static void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8333 close_redir(void) |
7 | 8334 { |
8335 if (redir_fd != NULL) | |
8336 { | |
8337 fclose(redir_fd); | |
8338 redir_fd = NULL; | |
8339 } | |
8340 #ifdef FEAT_EVAL | |
8341 redir_reg = 0; | |
167 | 8342 if (redir_vname) |
8343 { | |
8344 var_redir_stop(); | |
8345 redir_vname = 0; | |
8346 } | |
7 | 8347 #endif |
8348 } | |
8349 | |
17539
554240b9574b
patch 8.1.1767: FEAT_SESSION defined separately
Bram Moolenaar <Bram@vim.org>
parents:
17536
diff
changeset
|
8350 #if (defined(FEAT_SESSION) || defined(FEAT_EVAL)) || defined(PROTO) |
167 | 8351 int |
8368
db2a07b710ed
commit https://github.com/vim/vim/commit/f1d2501ebe33e148886c2914acd33140e20ee222
Christian Brabandt <cb@256bit.org>
parents:
8281
diff
changeset
|
8352 vim_mkdir_emsg(char_u *name, int prot) |
167 | 8353 { |
8354 if (vim_mkdir(name, prot) != 0) | |
8355 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8356 semsg(_("E739: Cannot create directory: %s"), name); |
167 | 8357 return FAIL; |
8358 } | |
8359 return OK; | |
8360 } | |
8361 #endif | |
8362 | |
7 | 8363 /* |
8364 * Open a file for writing for an Ex command, with some checks. | |
8365 * Return file descriptor, or NULL on failure. | |
8366 */ | |
8367 FILE * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8368 open_exfile( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8369 char_u *fname, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8370 int forceit, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8371 char *mode) /* "w" for create new file or "a" for append */ |
7 | 8372 { |
8373 FILE *fd; | |
8374 | |
8375 #ifdef UNIX | |
8376 /* with Unix it is possible to open a directory */ | |
8377 if (mch_isdir(fname)) | |
8378 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8379 semsg(_(e_isadir2), fname); |
7 | 8380 return NULL; |
8381 } | |
8382 #endif | |
8383 if (!forceit && *mode != 'a' && vim_fexists(fname)) | |
8384 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8385 semsg(_("E189: \"%s\" exists (add ! to override)"), fname); |
7 | 8386 return NULL; |
8387 } | |
8388 | |
8389 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
|
8390 semsg(_("E190: Cannot open \"%s\" for writing"), fname); |
7 | 8391 |
8392 return fd; | |
8393 } | |
8394 | |
8395 /* | |
8396 * ":mark" and ":k". | |
8397 */ | |
8398 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8399 ex_mark(exarg_T *eap) |
7 | 8400 { |
8401 pos_T pos; | |
8402 | |
8403 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
|
8404 emsg(_(e_argreq)); |
7 | 8405 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
|
8406 emsg(_(e_trailing)); |
7 | 8407 else |
8408 { | |
8409 pos = curwin->w_cursor; /* save curwin->w_cursor */ | |
8410 curwin->w_cursor.lnum = eap->line2; | |
8411 beginline(BL_WHITE | BL_FIX); | |
8412 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
|
8413 emsg(_("E191: Argument must be a letter or forward/backward quote")); |
7 | 8414 curwin->w_cursor = pos; /* restore curwin->w_cursor */ |
8415 } | |
8416 } | |
8417 | |
8418 /* | |
8419 * Update w_topline, w_leftcol and the cursor position. | |
8420 */ | |
8421 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8422 update_topline_cursor(void) |
7 | 8423 { |
8424 check_cursor(); /* put cursor on valid line */ | |
8425 update_topline(); | |
8426 if (!curwin->w_p_wrap) | |
8427 validate_cursor(); | |
8428 update_curswant(); | |
8429 } | |
8430 | |
8431 /* | |
12521
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8432 * 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
|
8433 * 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
|
8434 */ |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8435 int |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8436 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
|
8437 { |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8438 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
|
8439 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
|
8440 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
|
8441 sst->save_State = State; |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8442 sst->save_insertmode = p_im; |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8443 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
|
8444 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
|
8445 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
|
8446 |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8447 msg_scroll = FALSE; /* no msg scrolling in Normal mode */ |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8448 restart_edit = 0; /* don't go to Insert mode */ |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8449 p_im = FALSE; /* don't use 'insertmode' */ |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8450 |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8451 /* |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8452 * 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
|
8453 * 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
|
8454 * ends with half a command. |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8455 */ |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8456 save_typeahead(&sst->tabuf); |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8457 return sst->tabuf.typebuf_valid; |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8458 } |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8459 |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8460 void |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8461 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
|
8462 { |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8463 /* Restore the previous typeahead. */ |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8464 restore_typeahead(&sst->tabuf); |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8465 |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8466 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
|
8467 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
|
8468 p_im = sst->save_insertmode; |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8469 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
|
8470 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
|
8471 reg_executing = sst->save_reg_executing; |
12521
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8472 msg_didout |= sst->save_msg_didout; /* don't reset msg_didout now */ |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8473 |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8474 /* Restore the state (needed when called from a function executed for |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8475 * 'indentexpr'). Update the mouse and cursor, they may have changed. */ |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8476 State = sst->save_State; |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8477 #ifdef CURSOR_SHAPE |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8478 ui_cursor_shape(); /* may show different cursor shape */ |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8479 #endif |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8480 } |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8481 |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8482 /* |
7 | 8483 * ":normal[!] {commands}": Execute normal mode commands. |
8484 */ | |
7840
28f569c7dab9
commit https://github.com/vim/vim/commit/20fb9f346497daca4d19402fdfa5de7958642477
Christian Brabandt <cb@256bit.org>
parents:
7819
diff
changeset
|
8485 void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8486 ex_normal(exarg_T *eap) |
7 | 8487 { |
12521
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8488 save_state_T save_state; |
7 | 8489 char_u *arg = NULL; |
8490 int l; | |
8491 char_u *p; | |
8492 | |
856 | 8493 if (ex_normal_lock > 0) |
8494 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8495 emsg(_(e_secure)); |
856 | 8496 return; |
8497 } | |
7 | 8498 if (ex_normal_busy >= p_mmd) |
8499 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8500 emsg(_("E192: Recursive use of :normal too deep")); |
7 | 8501 return; |
8502 } | |
8503 | |
8504 /* | |
8505 * vgetc() expects a CSI and K_SPECIAL to have been escaped. Don't do | |
8506 * this for the K_SPECIAL leading byte, otherwise special keys will not | |
8507 * work. | |
8508 */ | |
8509 if (has_mbyte) | |
8510 { | |
8511 int len = 0; | |
8512 | |
8513 /* Count the number of characters to be escaped. */ | |
8514 for (p = eap->arg; *p != NUL; ++p) | |
8515 { | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
8516 #ifdef FEAT_GUI |
7 | 8517 if (*p == CSI) /* leadbyte CSI */ |
8518 len += 2; | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
8519 #endif |
474 | 8520 for (l = (*mb_ptr2len)(p) - 1; l > 0; --l) |
7 | 8521 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
|
8522 #ifdef FEAT_GUI |
7 | 8523 || *p == CSI |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
8524 #endif |
7 | 8525 ) |
8526 len += 2; | |
8527 } | |
8528 if (len > 0) | |
8529 { | |
16764
ef00b6bc186b
patch 8.1.1384: using "int" for alloc() often results in compiler warnings
Bram Moolenaar <Bram@vim.org>
parents:
16738
diff
changeset
|
8530 arg = alloc(STRLEN(eap->arg) + len + 1); |
7 | 8531 if (arg != NULL) |
8532 { | |
8533 len = 0; | |
8534 for (p = eap->arg; *p != NUL; ++p) | |
8535 { | |
8536 arg[len++] = *p; | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
8537 #ifdef FEAT_GUI |
7 | 8538 if (*p == CSI) |
8539 { | |
8540 arg[len++] = KS_EXTRA; | |
8541 arg[len++] = (int)KE_CSI; | |
8542 } | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
8543 #endif |
474 | 8544 for (l = (*mb_ptr2len)(p) - 1; l > 0; --l) |
7 | 8545 { |
8546 arg[len++] = *++p; | |
8547 if (*p == K_SPECIAL) | |
8548 { | |
8549 arg[len++] = KS_SPECIAL; | |
8550 arg[len++] = KE_FILLER; | |
8551 } | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
8552 #ifdef FEAT_GUI |
7 | 8553 else if (*p == CSI) |
8554 { | |
8555 arg[len++] = KS_EXTRA; | |
8556 arg[len++] = (int)KE_CSI; | |
8557 } | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
8558 #endif |
7 | 8559 } |
8560 arg[len] = NUL; | |
8561 } | |
8562 } | |
8563 } | |
8564 } | |
8565 | |
12521
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8566 ++ex_normal_busy; |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8567 if (save_current_state(&save_state)) |
7 | 8568 { |
8569 /* | |
8570 * Repeat the :normal command for each line in the range. When no | |
8571 * range given, execute it just once, without positioning the cursor | |
8572 * first. | |
8573 */ | |
8574 do | |
8575 { | |
8576 if (eap->addr_count != 0) | |
8577 { | |
8578 curwin->w_cursor.lnum = eap->line1++; | |
8579 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
|
8580 check_cursor_moved(curwin); |
7 | 8581 } |
8582 | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
8583 exec_normal_cmd(arg != NULL |
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
8584 ? arg |
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
8585 : eap->arg, eap->forceit ? REMAP_NONE : REMAP_YES, FALSE); |
7 | 8586 } |
8587 while (eap->addr_count > 0 && eap->line1 <= eap->line2 && !got_int); | |
8588 } | |
8589 | |
8590 /* Might not return to the main loop when in an event handler. */ | |
8591 update_topline_cursor(); | |
8592 | |
12521
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8593 restore_current_state(&save_state); |
7 | 8594 --ex_normal_busy; |
6322 | 8595 #ifdef FEAT_MOUSE |
8596 setmouse(); | |
8597 #endif | |
8598 #ifdef CURSOR_SHAPE | |
8599 ui_cursor_shape(); /* may show different cursor shape */ | |
8600 #endif | |
8601 | |
7 | 8602 vim_free(arg); |
8603 } | |
8604 | |
8605 /* | |
598 | 8606 * ":startinsert", ":startreplace" and ":startgreplace" |
7 | 8607 */ |
8608 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8609 ex_startinsert(exarg_T *eap) |
7 | 8610 { |
98 | 8611 if (eap->forceit) |
8612 { | |
12545
241fbf588b95
patch 8.0.1151: "vim -c startinsert!" doesn't append
Christian Brabandt <cb@256bit.org>
parents:
12521
diff
changeset
|
8613 /* cursor line can be zero on startup */ |
241fbf588b95
patch 8.0.1151: "vim -c startinsert!" doesn't append
Christian Brabandt <cb@256bit.org>
parents:
12521
diff
changeset
|
8614 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
|
8615 curwin->w_cursor.lnum = 1; |
98 | 8616 coladvance((colnr_T)MAXCOL); |
8617 curwin->w_curswant = MAXCOL; | |
8618 curwin->w_set_curswant = FALSE; | |
8619 } | |
8620 | |
89 | 8621 /* Ignore the command when already in Insert mode. Inserting an |
8622 * expression register that invokes a function can do this. */ | |
8623 if (State & INSERT) | |
8624 return; | |
8625 | |
598 | 8626 if (eap->cmdidx == CMD_startinsert) |
8627 restart_edit = 'a'; | |
8628 else if (eap->cmdidx == CMD_startreplace) | |
8629 restart_edit = 'R'; | |
7 | 8630 else |
598 | 8631 restart_edit = 'V'; |
8632 | |
8633 if (!eap->forceit) | |
7 | 8634 { |
14 | 8635 if (eap->cmdidx == CMD_startinsert) |
8636 restart_edit = 'i'; | |
7 | 8637 curwin->w_curswant = 0; /* avoid MAXCOL */ |
8638 } | |
8639 } | |
8640 | |
8641 /* | |
8642 * ":stopinsert" | |
8643 */ | |
8644 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8645 ex_stopinsert(exarg_T *eap UNUSED) |
7 | 8646 { |
8647 restart_edit = 0; | |
8648 stop_insert_mode = TRUE; | |
8817
b7eb7bbd71d0
commit https://github.com/vim/vim/commit/fd773e9e88add7d1ffef890fb9f3a00d613b4326
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
8649 clearmode(); |
7 | 8650 } |
7850
10f17a228661
commit https://github.com/vim/vim/commit/e2c3810c2ae290bbc2cba18eb47cc2d44e4b9797
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
8651 |
36 | 8652 /* |
8653 * Execute normal mode command "cmd". | |
8654 * "remap" can be REMAP_NONE or REMAP_YES. | |
8655 */ | |
8656 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8657 exec_normal_cmd(char_u *cmd, int remap, int silent) |
36 | 8658 { |
7703
39251e981d1f
commit https://github.com/vim/vim/commit/25281634cda03ce302aaf9f906a9520b5f81f91e
Christian Brabandt <cb@256bit.org>
parents:
7549
diff
changeset
|
8659 /* Stuff the argument into the typeahead buffer. */ |
39251e981d1f
commit https://github.com/vim/vim/commit/25281634cda03ce302aaf9f906a9520b5f81f91e
Christian Brabandt <cb@256bit.org>
parents:
7549
diff
changeset
|
8660 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
|
8661 exec_normal(FALSE, FALSE, FALSE); |
7703
39251e981d1f
commit https://github.com/vim/vim/commit/25281634cda03ce302aaf9f906a9520b5f81f91e
Christian Brabandt <cb@256bit.org>
parents:
7549
diff
changeset
|
8662 } |
7850
10f17a228661
commit https://github.com/vim/vim/commit/e2c3810c2ae290bbc2cba18eb47cc2d44e4b9797
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
8663 |
7703
39251e981d1f
commit https://github.com/vim/vim/commit/25281634cda03ce302aaf9f906a9520b5f81f91e
Christian Brabandt <cb@256bit.org>
parents:
7549
diff
changeset
|
8664 /* |
39251e981d1f
commit https://github.com/vim/vim/commit/25281634cda03ce302aaf9f906a9520b5f81f91e
Christian Brabandt <cb@256bit.org>
parents:
7549
diff
changeset
|
8665 * 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
|
8666 * 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
|
8667 */ |
39251e981d1f
commit https://github.com/vim/vim/commit/25281634cda03ce302aaf9f906a9520b5f81f91e
Christian Brabandt <cb@256bit.org>
parents:
7549
diff
changeset
|
8668 void |
14871
f20df682c8af
patch 8.1.0447: GUI scrollbar test fails with Athena and Motif
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
8669 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
|
8670 { |
36 | 8671 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
|
8672 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
|
8673 |
d3377393e3d9
patch 8.1.1136: decoding of mouse click escape sequence is not tested
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
8674 // 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
|
8675 // is nothing to get, so also check for Ctrl_C. |
36 | 8676 clear_oparg(&oa); |
8677 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
|
8678 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
|
8679 || ((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
|
8680 || (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
|
8681 && !got_int) |
36 | 8682 { |
8683 update_topline_cursor(); | |
13829
044337cbf854
patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents:
13802
diff
changeset
|
8684 #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
|
8685 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
|
8686 && 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
|
8687 && !VIsual_active) |
044337cbf854
patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents:
13802
diff
changeset
|
8688 { |
044337cbf854
patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents:
13802
diff
changeset
|
8689 /* If terminal_loop() returns OK we got a key that is handled |
044337cbf854
patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents:
13802
diff
changeset
|
8690 * in Normal model. With FAIL we first need to position the |
044337cbf854
patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents:
13802
diff
changeset
|
8691 * cursor and the screen needs to be redrawn. */ |
044337cbf854
patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents:
13802
diff
changeset
|
8692 if (terminal_loop(TRUE) == OK) |
044337cbf854
patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents:
13802
diff
changeset
|
8693 normal_cmd(&oa, TRUE); |
044337cbf854
patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents:
13802
diff
changeset
|
8694 } |
044337cbf854
patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents:
13802
diff
changeset
|
8695 else |
044337cbf854
patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents:
13802
diff
changeset
|
8696 #endif |
044337cbf854
patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents:
13802
diff
changeset
|
8697 /* execute a Normal mode cmd */ |
044337cbf854
patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents:
13802
diff
changeset
|
8698 normal_cmd(&oa, TRUE); |
36 | 8699 } |
8700 } | |
8701 | |
7 | 8702 #ifdef FEAT_FIND_ID |
8703 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8704 ex_checkpath(exarg_T *eap) |
7 | 8705 { |
8706 find_pattern_in_path(NULL, 0, 0, FALSE, FALSE, CHECK_PATH, 1L, | |
8707 eap->forceit ? ACTION_SHOW_ALL : ACTION_SHOW, | |
8708 (linenr_T)1, (linenr_T)MAXLNUM); | |
8709 } | |
8710 | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
8711 #if defined(FEAT_QUICKFIX) |
7 | 8712 /* |
8713 * ":psearch" | |
8714 */ | |
8715 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8716 ex_psearch(exarg_T *eap) |
7 | 8717 { |
8718 g_do_tagpreview = p_pvh; | |
8719 ex_findpat(eap); | |
8720 g_do_tagpreview = 0; | |
8721 } | |
8722 #endif | |
8723 | |
8724 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8725 ex_findpat(exarg_T *eap) |
7 | 8726 { |
8727 int whole = TRUE; | |
8728 long n; | |
8729 char_u *p; | |
8730 int action; | |
8731 | |
8732 switch (cmdnames[eap->cmdidx].cmd_name[2]) | |
8733 { | |
8734 case 'e': /* ":psearch", ":isearch" and ":dsearch" */ | |
8735 if (cmdnames[eap->cmdidx].cmd_name[0] == 'p') | |
8736 action = ACTION_GOTO; | |
8737 else | |
8738 action = ACTION_SHOW; | |
8739 break; | |
8740 case 'i': /* ":ilist" and ":dlist" */ | |
8741 action = ACTION_SHOW_ALL; | |
8742 break; | |
8743 case 'u': /* ":ijump" and ":djump" */ | |
8744 action = ACTION_GOTO; | |
8745 break; | |
8746 default: /* ":isplit" and ":dsplit" */ | |
8747 action = ACTION_SPLIT; | |
8748 break; | |
8749 } | |
8750 | |
8751 n = 1; | |
8752 if (vim_isdigit(*eap->arg)) /* get count */ | |
8753 { | |
8754 n = getdigits(&eap->arg); | |
8755 eap->arg = skipwhite(eap->arg); | |
8756 } | |
8757 if (*eap->arg == '/') /* Match regexp, not just whole words */ | |
8758 { | |
8759 whole = FALSE; | |
8760 ++eap->arg; | |
8761 p = skip_regexp(eap->arg, '/', p_magic, NULL); | |
8762 if (*p) | |
8763 { | |
8764 *p++ = NUL; | |
8765 p = skipwhite(p); | |
8766 | |
8767 /* Check for trailing illegal characters */ | |
8768 if (!ends_excmd(*p)) | |
8769 eap->errmsg = e_trailing; | |
8770 else | |
8771 eap->nextcmd = check_nextcmd(p); | |
8772 } | |
8773 } | |
8774 if (!eap->skip) | |
8775 find_pattern_in_path(eap->arg, 0, (int)STRLEN(eap->arg), | |
8776 whole, !eap->forceit, | |
8777 *eap->cmd == 'd' ? FIND_DEFINE : FIND_ANY, | |
8778 n, action, eap->line1, eap->line2); | |
8779 } | |
8780 #endif | |
8781 | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
8782 |
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
8783 #ifdef FEAT_QUICKFIX |
7 | 8784 /* |
8785 * ":ptag", ":ptselect", ":ptjump", ":ptnext", etc. | |
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_ptag(exarg_T *eap) |
7 | 8789 { |
2633 | 8790 g_do_tagpreview = p_pvh; /* will be reset to 0 in ex_tag_cmd() */ |
7 | 8791 ex_tag_cmd(eap, cmdnames[eap->cmdidx].cmd_name + 1); |
8792 } | |
8793 | |
8794 /* | |
8795 * ":pedit" | |
8796 */ | |
8797 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8798 ex_pedit(exarg_T *eap) |
7 | 8799 { |
8800 win_T *curwin_save = curwin; | |
8801 | |
8802 g_do_tagpreview = p_pvh; | |
815 | 8803 prepare_tagpreview(TRUE); |
17644
daa1dea1c1b3
patch 8.1.1819: :pedit does not work with a popup preview window
Bram Moolenaar <Bram@vim.org>
parents:
17622
diff
changeset
|
8804 |
11806
1c1cb1e9b7b3
patch 8.0.0785: wildcards are not expanded for :terminal
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
8805 keep_help_flag = bt_help(curwin_save->w_buffer); |
7 | 8806 do_exedit(eap, NULL); |
8807 keep_help_flag = 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
|
8808 |
7 | 8809 if (curwin != curwin_save && win_valid(curwin_save)) |
8810 { | |
8811 /* Return cursor to where we were */ | |
8812 validate_cursor(); | |
8813 redraw_later(VALID); | |
8814 win_enter(curwin_save, TRUE); | |
8815 } | |
17644
daa1dea1c1b3
patch 8.1.1819: :pedit does not work with a popup preview window
Bram Moolenaar <Bram@vim.org>
parents:
17622
diff
changeset
|
8816 # ifdef FEAT_TEXT_PROP |
daa1dea1c1b3
patch 8.1.1819: :pedit does not work with a popup preview window
Bram Moolenaar <Bram@vim.org>
parents:
17622
diff
changeset
|
8817 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
|
8818 { |
daa1dea1c1b3
patch 8.1.1819: :pedit does not work with a popup preview window
Bram Moolenaar <Bram@vim.org>
parents:
17622
diff
changeset
|
8819 // 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
|
8820 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
|
8821 } |
daa1dea1c1b3
patch 8.1.1819: :pedit does not work with a popup preview window
Bram Moolenaar <Bram@vim.org>
parents:
17622
diff
changeset
|
8822 # endif |
7 | 8823 g_do_tagpreview = 0; |
8824 } | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
8825 #endif |
7 | 8826 |
8827 /* | |
8828 * ":stag", ":stselect" and ":stjump". | |
8829 */ | |
8830 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8831 ex_stag(exarg_T *eap) |
7 | 8832 { |
8833 postponed_split = -1; | |
8834 postponed_split_flags = cmdmod.split; | |
1090 | 8835 postponed_split_tab = cmdmod.tab; |
7 | 8836 ex_tag_cmd(eap, cmdnames[eap->cmdidx].cmd_name + 1); |
8837 postponed_split_flags = 0; | |
1090 | 8838 postponed_split_tab = 0; |
7 | 8839 } |
8840 | |
8841 /* | |
8842 * ":tag", ":tselect", ":tjump", ":tnext", etc. | |
8843 */ | |
8844 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8845 ex_tag(exarg_T *eap) |
7 | 8846 { |
8847 ex_tag_cmd(eap, cmdnames[eap->cmdidx].cmd_name); | |
8848 } | |
8849 | |
8850 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8851 ex_tag_cmd(exarg_T *eap, char_u *name) |
7 | 8852 { |
8853 int cmd; | |
8854 | |
8855 switch (name[1]) | |
8856 { | |
8857 case 'j': cmd = DT_JUMP; /* ":tjump" */ | |
8858 break; | |
8859 case 's': cmd = DT_SELECT; /* ":tselect" */ | |
8860 break; | |
8861 case 'p': cmd = DT_PREV; /* ":tprevious" */ | |
8862 break; | |
8863 case 'N': cmd = DT_PREV; /* ":tNext" */ | |
8864 break; | |
8865 case 'n': cmd = DT_NEXT; /* ":tnext" */ | |
8866 break; | |
8867 case 'o': cmd = DT_POP; /* ":pop" */ | |
8868 break; | |
8869 case 'f': /* ":tfirst" */ | |
8870 case 'r': cmd = DT_FIRST; /* ":trewind" */ | |
8871 break; | |
8872 case 'l': cmd = DT_LAST; /* ":tlast" */ | |
8873 break; | |
8874 default: /* ":tag" */ | |
8875 #ifdef FEAT_CSCOPE | |
1603 | 8876 if (p_cst && *eap->arg != NUL) |
7 | 8877 { |
10373
bd674706408a
commit https://github.com/vim/vim/commit/d4db7719bdfbc54df396eac08d8cbb2389feacf4
Christian Brabandt <cb@256bit.org>
parents:
10361
diff
changeset
|
8878 ex_cstag(eap); |
7 | 8879 return; |
8880 } | |
8881 #endif | |
8882 cmd = DT_TAG; | |
8883 break; | |
8884 } | |
8885 | |
649 | 8886 if (name[0] == 'l') |
8887 { | |
8888 #ifndef FEAT_QUICKFIX | |
8889 ex_ni(eap); | |
8890 return; | |
8891 #else | |
8892 cmd = DT_LTAG; | |
8893 #endif | |
8894 } | |
8895 | |
7 | 8896 do_tag(eap->arg, cmd, eap->addr_count > 0 ? (int)eap->line2 : 1, |
8897 eap->forceit, TRUE); | |
8898 } | |
8899 | |
8900 /* | |
1661 | 8901 * Check "str" for starting with a special cmdline variable. |
8902 * If found return one of the SPEC_ values and set "*usedlen" to the length of | |
8903 * the variable. Otherwise return -1 and "*usedlen" is unchanged. | |
8904 */ | |
8905 int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8906 find_cmdline_var(char_u *src, int *usedlen) |
1661 | 8907 { |
8908 int len; | |
8909 int i; | |
1879 | 8910 static char *(spec_str[]) = { |
1661 | 8911 "%", |
8912 #define SPEC_PERC 0 | |
8913 "#", | |
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
|
8914 #define SPEC_HASH (SPEC_PERC + 1) |
1661 | 8915 "<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
|
8916 #define SPEC_CWORD (SPEC_HASH + 1) |
1661 | 8917 "<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
|
8918 #define SPEC_CCWORD (SPEC_CWORD + 1) |
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
|
8919 "<cexpr>", /* expr under cursor */ |
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
|
8920 #define SPEC_CEXPR (SPEC_CCWORD + 1) |
1661 | 8921 "<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
|
8922 #define SPEC_CFILE (SPEC_CEXPR + 1) |
1661 | 8923 "<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
|
8924 #define SPEC_SFILE (SPEC_CFILE + 1) |
2645 | 8925 "<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
|
8926 #define SPEC_SLNUM (SPEC_SFILE + 1) |
1661 | 8927 "<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
|
8928 #define SPEC_AFILE (SPEC_SLNUM + 1) |
1661 | 8929 "<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
|
8930 #define SPEC_ABUF (SPEC_AFILE + 1) |
1661 | 8931 "<amatch>", /* autocommand match name */ |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
8932 #define SPEC_AMATCH (SPEC_ABUF + 1) |
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
|
8933 "<sflnum>", /* script file line number */ |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14677
diff
changeset
|
8934 #define SPEC_SFLNUM (SPEC_AMATCH + 1) |
1661 | 8935 #ifdef FEAT_CLIENTSERVER |
8936 "<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
|
8937 # define SPEC_CLIENT (SPEC_SFLNUM + 1) |
1661 | 8938 #endif |
8939 }; | |
1872 | 8940 |
8941 for (i = 0; i < (int)(sizeof(spec_str) / sizeof(char *)); ++i) | |
1661 | 8942 { |
8943 len = (int)STRLEN(spec_str[i]); | |
8944 if (STRNCMP(src, spec_str[i], len) == 0) | |
8945 { | |
8946 *usedlen = len; | |
8947 return i; | |
8948 } | |
8949 } | |
8950 return -1; | |
8951 } | |
8952 | |
8953 /* | |
7 | 8954 * Evaluate cmdline variables. |
8955 * | |
8956 * change '%' to curbuf->b_ffname | |
8957 * '#' to curwin->w_altfile | |
8958 * '<cword>' to word under the cursor | |
8959 * '<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
|
8960 * '<cexpr>' to C-expression under the cursor |
7 | 8961 * '<cfile>' to path name under the cursor |
8962 * '<sfile>' to sourced file name | |
2645 | 8963 * '<slnum>' to sourced file line number |
7 | 8964 * '<afile>' to file name for autocommand |
8965 * '<abuf>' to buffer number for autocommand | |
8966 * '<amatch>' to matching name for autocommand | |
8967 * | |
8968 * When an error is detected, "errormsg" is set to a non-NULL pointer (may be | |
8969 * "" for error without a message) and NULL is returned. | |
8970 * Returns an allocated string if a valid match was found. | |
8971 * Returns NULL if no match was found. "usedlen" then still contains the | |
8972 * number of characters to skip. | |
8973 */ | |
8974 char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8975 eval_vars( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8976 char_u *src, /* pointer into commandline */ |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8977 char_u *srcstart, /* beginning of valid memory for src */ |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8978 int *usedlen, /* characters after src that are used */ |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8979 linenr_T *lnump, /* line number for :e command, or NULL */ |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8980 char **errormsg, /* pointer to error message */ |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8981 int *escaped) /* return value has escaped white space (can |
1098 | 8982 * be NULL) */ |
7 | 8983 { |
8984 int i; | |
8985 char_u *s; | |
8986 char_u *result; | |
8987 char_u *resultbuf = NULL; | |
8988 int resultlen; | |
8989 buf_T *buf; | |
8990 int valid = VALID_HEAD + VALID_PATH; /* assume valid result */ | |
8991 int spec_idx; | |
8992 #ifdef FEAT_MODIFY_FNAME | |
14405
289b850d2cbf
patch 8.1.0217: compiler warning for variable set but not used
Christian Brabandt <cb@256bit.org>
parents:
14393
diff
changeset
|
8993 int tilde_file = FALSE; |
7 | 8994 int skip_mod = FALSE; |
8995 #endif | |
8996 char_u strbuf[30]; | |
8997 | |
8998 *errormsg = NULL; | |
1098 | 8999 if (escaped != NULL) |
9000 *escaped = FALSE; | |
7 | 9001 |
9002 /* | |
9003 * Check if there is something to do. | |
9004 */ | |
1661 | 9005 spec_idx = find_cmdline_var(src, usedlen); |
9006 if (spec_idx < 0) /* no match */ | |
7 | 9007 { |
9008 *usedlen = 1; | |
9009 return NULL; | |
9010 } | |
9011 | |
9012 /* | |
9013 * Skip when preceded with a backslash "\%" and "\#". | |
9014 * Note: In "\\%" the % is also not recognized! | |
9015 */ | |
9016 if (src > srcstart && src[-1] == '\\') | |
9017 { | |
9018 *usedlen = 0; | |
1619 | 9019 STRMOVE(src - 1, src); /* remove backslash */ |
7 | 9020 return NULL; |
9021 } | |
9022 | |
9023 /* | |
9024 * word or WORD under cursor | |
9025 */ | |
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
|
9026 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
|
9027 || 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
|
9028 { |
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
|
9029 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
|
9030 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
|
9031 : 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
|
9032 : FIND_STRING); |
7 | 9033 if (resultlen == 0) |
9034 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
9035 *errormsg = ""; |
7 | 9036 return NULL; |
9037 } | |
9038 } | |
9039 | |
9040 /* | |
9041 * '#': Alternate file name | |
9042 * '%': Current file name | |
9043 * File name under the cursor | |
9044 * File name for autocommand | |
9045 * and following modifiers | |
9046 */ | |
9047 else | |
9048 { | |
9049 switch (spec_idx) | |
9050 { | |
9051 case SPEC_PERC: /* '%': current file */ | |
9052 if (curbuf->b_fname == NULL) | |
9053 { | |
9054 result = (char_u *)""; | |
9055 valid = 0; /* Must have ":p:h" to be valid */ | |
9056 } | |
9057 else | |
14393
c62601adad69
patch 8.1.0211: expanding a file name "~" results in $HOME
Christian Brabandt <cb@256bit.org>
parents:
14286
diff
changeset
|
9058 { |
7 | 9059 result = curbuf->b_fname; |
14405
289b850d2cbf
patch 8.1.0217: compiler warning for variable set but not used
Christian Brabandt <cb@256bit.org>
parents:
14393
diff
changeset
|
9060 #ifdef FEAT_MODIFY_FNAME |
14393
c62601adad69
patch 8.1.0211: expanding a file name "~" results in $HOME
Christian Brabandt <cb@256bit.org>
parents:
14286
diff
changeset
|
9061 tilde_file = STRCMP(result, "~") == 0; |
14405
289b850d2cbf
patch 8.1.0217: compiler warning for variable set but not used
Christian Brabandt <cb@256bit.org>
parents:
14393
diff
changeset
|
9062 #endif |
14393
c62601adad69
patch 8.1.0211: expanding a file name "~" results in $HOME
Christian Brabandt <cb@256bit.org>
parents:
14286
diff
changeset
|
9063 } |
7 | 9064 break; |
9065 | |
9066 case SPEC_HASH: /* '#' or "#99": alternate file */ | |
9067 if (src[1] == '#') /* "##": the argument list */ | |
9068 { | |
9069 result = arg_all(); | |
9070 resultbuf = result; | |
9071 *usedlen = 2; | |
1098 | 9072 if (escaped != NULL) |
9073 *escaped = TRUE; | |
7 | 9074 #ifdef FEAT_MODIFY_FNAME |
9075 skip_mod = TRUE; | |
9076 #endif | |
9077 break; | |
9078 } | |
9079 s = src + 1; | |
1733 | 9080 if (*s == '<') /* "#<99" uses v:oldfiles */ |
9081 ++s; | |
7 | 9082 i = (int)getdigits(&s); |
12706
9b882316aa63
patch 8.0.1231: expanding file name drops dash
Christian Brabandt <cb@256bit.org>
parents:
12674
diff
changeset
|
9083 if (s == src + 2 && src[1] == '-') |
9b882316aa63
patch 8.0.1231: expanding file name drops dash
Christian Brabandt <cb@256bit.org>
parents:
12674
diff
changeset
|
9084 /* just a minus sign, don't skip over it */ |
9b882316aa63
patch 8.0.1231: expanding file name drops dash
Christian Brabandt <cb@256bit.org>
parents:
12674
diff
changeset
|
9085 s--; |
7 | 9086 *usedlen = (int)(s - src); /* length of what we expand */ |
9087 | |
12706
9b882316aa63
patch 8.0.1231: expanding file name drops dash
Christian Brabandt <cb@256bit.org>
parents:
12674
diff
changeset
|
9088 if (src[1] == '<' && i != 0) |
7 | 9089 { |
1733 | 9090 if (*usedlen < 2) |
9091 { | |
9092 /* Should we give an error message for #<text? */ | |
9093 *usedlen = 1; | |
9094 return NULL; | |
9095 } | |
9096 #ifdef FEAT_EVAL | |
9097 result = list_find_str(get_vim_var_list(VV_OLDFILES), | |
9098 (long)i); | |
9099 if (result == NULL) | |
9100 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
9101 *errormsg = ""; |
1733 | 9102 return NULL; |
9103 } | |
9104 #else | |
15488
da8b98c008bf
patch 8.1.0752: one more compiler warning for signed/unsigned string
Bram Moolenaar <Bram@vim.org>
parents:
15474
diff
changeset
|
9105 *errormsg = _("E809: #< is not available without the +eval feature"); |
7 | 9106 return NULL; |
1733 | 9107 #endif |
7 | 9108 } |
9109 else | |
1733 | 9110 { |
12706
9b882316aa63
patch 8.0.1231: expanding file name drops dash
Christian Brabandt <cb@256bit.org>
parents:
12674
diff
changeset
|
9111 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
|
9112 *usedlen = 1; |
1733 | 9113 buf = buflist_findnr(i); |
9114 if (buf == NULL) | |
9115 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
9116 *errormsg = _("E194: No alternate file name to substitute for '#'"); |
1733 | 9117 return NULL; |
9118 } | |
9119 if (lnump != NULL) | |
9120 *lnump = ECMD_LAST; | |
9121 if (buf->b_fname == NULL) | |
9122 { | |
9123 result = (char_u *)""; | |
9124 valid = 0; /* Must have ":p:h" to be valid */ | |
9125 } | |
9126 else | |
14393
c62601adad69
patch 8.1.0211: expanding a file name "~" results in $HOME
Christian Brabandt <cb@256bit.org>
parents:
14286
diff
changeset
|
9127 { |
1733 | 9128 result = buf->b_fname; |
14405
289b850d2cbf
patch 8.1.0217: compiler warning for variable set but not used
Christian Brabandt <cb@256bit.org>
parents:
14393
diff
changeset
|
9129 #ifdef FEAT_MODIFY_FNAME |
14393
c62601adad69
patch 8.1.0211: expanding a file name "~" results in $HOME
Christian Brabandt <cb@256bit.org>
parents:
14286
diff
changeset
|
9130 tilde_file = STRCMP(result, "~") == 0; |
14405
289b850d2cbf
patch 8.1.0217: compiler warning for variable set but not used
Christian Brabandt <cb@256bit.org>
parents:
14393
diff
changeset
|
9131 #endif |
14393
c62601adad69
patch 8.1.0211: expanding a file name "~" results in $HOME
Christian Brabandt <cb@256bit.org>
parents:
14286
diff
changeset
|
9132 } |
1733 | 9133 } |
7 | 9134 break; |
9135 | |
9136 #ifdef FEAT_SEARCHPATH | |
9137 case SPEC_CFILE: /* file name under cursor */ | |
681 | 9138 result = file_name_at_cursor(FNAME_MESS|FNAME_HYP, 1L, NULL); |
7 | 9139 if (result == NULL) |
9140 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
9141 *errormsg = ""; |
7 | 9142 return NULL; |
9143 } | |
9144 resultbuf = result; /* remember allocated string */ | |
9145 break; | |
9146 #endif | |
9147 | |
9148 case SPEC_AFILE: /* file name for autocommand */ | |
9149 result = autocmd_fname; | |
1723 | 9150 if (result != NULL && !autocmd_fname_full) |
9151 { | |
9152 /* Still need to turn the fname into a full path. It is | |
9153 * postponed to avoid a delay when <afile> is not used. */ | |
9154 autocmd_fname_full = TRUE; | |
9155 result = FullName_save(autocmd_fname, FALSE); | |
9156 vim_free(autocmd_fname); | |
9157 autocmd_fname = result; | |
9158 } | |
7 | 9159 if (result == NULL) |
9160 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
9161 *errormsg = _("E495: no autocommand file name to substitute for \"<afile>\""); |
7 | 9162 return NULL; |
9163 } | |
1471 | 9164 result = shorten_fname1(result); |
7 | 9165 break; |
9166 | |
9167 case SPEC_ABUF: /* buffer number for autocommand */ | |
9168 if (autocmd_bufnr <= 0) | |
9169 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
9170 *errormsg = _("E496: no autocommand buffer number to substitute for \"<abuf>\""); |
7 | 9171 return NULL; |
9172 } | |
9173 sprintf((char *)strbuf, "%d", autocmd_bufnr); | |
9174 result = strbuf; | |
9175 break; | |
9176 | |
9177 case SPEC_AMATCH: /* match name for autocommand */ | |
9178 result = autocmd_match; | |
9179 if (result == NULL) | |
9180 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
9181 *errormsg = _("E497: no autocommand match name to substitute for \"<amatch>\""); |
7 | 9182 return NULL; |
9183 } | |
9184 break; | |
9185 | |
9186 case SPEC_SFILE: /* file name for ":so" command */ | |
9187 result = sourcing_name; | |
9188 if (result == NULL) | |
9189 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
9190 *errormsg = _("E498: no :source file name to substitute for \"<sfile>\""); |
7 | 9191 return NULL; |
9192 } | |
9193 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
|
9194 |
2645 | 9195 case SPEC_SLNUM: /* line in file for ":so" command */ |
9196 if (sourcing_name == NULL || sourcing_lnum == 0) | |
9197 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
9198 *errormsg = _("E842: no line number to use for \"<slnum>\""); |
2645 | 9199 return NULL; |
9200 } | |
9201 sprintf((char *)strbuf, "%ld", (long)sourcing_lnum); | |
9202 result = strbuf; | |
9203 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
|
9204 |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14677
diff
changeset
|
9205 #ifdef FEAT_EVAL |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14677
diff
changeset
|
9206 case SPEC_SFLNUM: /* line in script file */ |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14677
diff
changeset
|
9207 if (current_sctx.sc_lnum + sourcing_lnum == 0) |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14677
diff
changeset
|
9208 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
9209 *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
|
9210 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
|
9211 } |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14677
diff
changeset
|
9212 sprintf((char *)strbuf, "%ld", |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14677
diff
changeset
|
9213 (long)(current_sctx.sc_lnum + sourcing_lnum)); |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14677
diff
changeset
|
9214 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
|
9215 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
|
9216 #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
|
9217 |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14677
diff
changeset
|
9218 #ifdef FEAT_CLIENTSERVER |
7 | 9219 case SPEC_CLIENT: /* Source of last submitted input */ |
840 | 9220 sprintf((char *)strbuf, PRINTF_HEX_LONG_U, |
9221 (long_u)clientWindow); | |
7 | 9222 result = strbuf; |
9223 break; | |
9224 #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
|
9225 |
11428
346168f2a6cb
patch 8.0.0598: building with gcc 7.1 yields new warnings
Christian Brabandt <cb@256bit.org>
parents:
11374
diff
changeset
|
9226 default: |
346168f2a6cb
patch 8.0.0598: building with gcc 7.1 yields new warnings
Christian Brabandt <cb@256bit.org>
parents:
11374
diff
changeset
|
9227 result = (char_u *)""; /* avoid gcc warning */ |
346168f2a6cb
patch 8.0.0598: building with gcc 7.1 yields new warnings
Christian Brabandt <cb@256bit.org>
parents:
11374
diff
changeset
|
9228 break; |
7 | 9229 } |
9230 | |
9231 resultlen = (int)STRLEN(result); /* length of new string */ | |
9232 if (src[*usedlen] == '<') /* remove the file name extension */ | |
9233 { | |
9234 ++*usedlen; | |
9235 if ((s = vim_strrchr(result, '.')) != NULL && s >= gettail(result)) | |
9236 resultlen = (int)(s - result); | |
9237 } | |
9238 #ifdef FEAT_MODIFY_FNAME | |
9239 else if (!skip_mod) | |
9240 { | |
14393
c62601adad69
patch 8.1.0211: expanding a file name "~" results in $HOME
Christian Brabandt <cb@256bit.org>
parents:
14286
diff
changeset
|
9241 valid |= modify_fname(src, tilde_file, usedlen, &result, &resultbuf, |
7 | 9242 &resultlen); |
9243 if (result == NULL) | |
9244 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
9245 *errormsg = ""; |
7 | 9246 return NULL; |
9247 } | |
9248 } | |
9249 #endif | |
9250 } | |
9251 | |
9252 if (resultlen == 0 || valid != VALID_HEAD + VALID_PATH) | |
9253 { | |
9254 if (valid != VALID_HEAD + VALID_PATH) | |
9255 /* 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
|
9256 *errormsg = _("E499: Empty file name for '%' or '#', only works with \":p:h\""); |
7 | 9257 else |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
9258 *errormsg = _("E500: Evaluates to an empty string"); |
7 | 9259 result = NULL; |
9260 } | |
9261 else | |
9262 result = vim_strnsave(result, resultlen); | |
9263 vim_free(resultbuf); | |
9264 return result; | |
9265 } | |
9266 | |
9267 /* | |
9268 * Concatenate all files in the argument list, separated by spaces, and return | |
9269 * it in one allocated string. | |
9270 * Spaces and backslashes in the file names are escaped with a backslash. | |
9271 * Returns NULL when out of memory. | |
9272 */ | |
9273 static char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
9274 arg_all(void) |
7 | 9275 { |
9276 int len; | |
9277 int idx; | |
9278 char_u *retval = NULL; | |
9279 char_u *p; | |
9280 | |
9281 /* | |
9282 * Do this loop two times: | |
9283 * first time: compute the total length | |
9284 * second time: concatenate the names | |
9285 */ | |
9286 for (;;) | |
9287 { | |
9288 len = 0; | |
9289 for (idx = 0; idx < ARGCOUNT; ++idx) | |
9290 { | |
9291 p = alist_name(&ARGLIST[idx]); | |
9292 if (p != NULL) | |
9293 { | |
9294 if (len > 0) | |
9295 { | |
9296 /* insert a space in between names */ | |
9297 if (retval != NULL) | |
9298 retval[len] = ' '; | |
9299 ++len; | |
9300 } | |
9301 for ( ; *p != NUL; ++p) | |
9302 { | |
6832 | 9303 if (*p == ' ' |
9304 #ifndef BACKSLASH_IN_FILENAME | |
9305 || *p == '\\' | |
9306 #endif | |
14409
9ffce640d0d3
patch 8.1.0219: expanding ## fails to escape backtick
Christian Brabandt <cb@256bit.org>
parents:
14405
diff
changeset
|
9307 || *p == '`') |
7 | 9308 { |
9309 /* insert a backslash */ | |
9310 if (retval != NULL) | |
9311 retval[len] = '\\'; | |
9312 ++len; | |
9313 } | |
9314 if (retval != NULL) | |
9315 retval[len] = *p; | |
9316 ++len; | |
9317 } | |
9318 } | |
9319 } | |
9320 | |
9321 /* second time: break here */ | |
9322 if (retval != NULL) | |
9323 { | |
9324 retval[len] = NUL; | |
9325 break; | |
9326 } | |
9327 | |
9328 /* allocate memory */ | |
16764
ef00b6bc186b
patch 8.1.1384: using "int" for alloc() often results in compiler warnings
Bram Moolenaar <Bram@vim.org>
parents:
16738
diff
changeset
|
9329 retval = alloc(len + 1); |
7 | 9330 if (retval == NULL) |
9331 break; | |
9332 } | |
9333 | |
9334 return retval; | |
9335 } | |
9336 | |
9337 /* | |
9338 * Expand the <sfile> string in "arg". | |
9339 * | |
9340 * Returns an allocated string, or NULL for any error. | |
9341 */ | |
9342 char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
9343 expand_sfile(char_u *arg) |
7 | 9344 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
9345 char *errormsg; |
7 | 9346 int len; |
9347 char_u *result; | |
9348 char_u *newres; | |
9349 char_u *repl; | |
9350 int srclen; | |
9351 char_u *p; | |
9352 | |
9353 result = vim_strsave(arg); | |
9354 if (result == NULL) | |
9355 return NULL; | |
9356 | |
9357 for (p = result; *p; ) | |
9358 { | |
9359 if (STRNCMP(p, "<sfile>", 7) != 0) | |
9360 ++p; | |
9361 else | |
9362 { | |
9363 /* replace "<sfile>" with the sourced file name, and do ":" stuff */ | |
1098 | 9364 repl = eval_vars(p, result, &srclen, NULL, &errormsg, NULL); |
7 | 9365 if (errormsg != NULL) |
9366 { | |
9367 if (*errormsg) | |
9368 emsg(errormsg); | |
9369 vim_free(result); | |
9370 return NULL; | |
9371 } | |
9372 if (repl == NULL) /* no match (cannot happen) */ | |
9373 { | |
9374 p += srclen; | |
9375 continue; | |
9376 } | |
9377 len = (int)STRLEN(result) - srclen + (int)STRLEN(repl) + 1; | |
9378 newres = alloc(len); | |
9379 if (newres == NULL) | |
9380 { | |
9381 vim_free(repl); | |
9382 vim_free(result); | |
9383 return NULL; | |
9384 } | |
9385 mch_memmove(newres, result, (size_t)(p - result)); | |
9386 STRCPY(newres + (p - result), repl); | |
9387 len = (int)STRLEN(newres); | |
9388 STRCAT(newres, p + srclen); | |
9389 vim_free(repl); | |
9390 vim_free(result); | |
9391 result = newres; | |
9392 p = newres + len; /* continue after the match */ | |
9393 } | |
9394 } | |
9395 | |
9396 return result; | |
9397 } | |
9398 | |
9399 #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) || defined(PROTO) | |
272 | 9400 /* |
2770 | 9401 * Make a dialog message in "buff[DIALOG_MSG_SIZE]". |
310 | 9402 * "format" must contain "%s". |
272 | 9403 */ |
7 | 9404 void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
9405 dialog_msg(char_u *buff, char *format, char_u *fname) |
7 | 9406 { |
9407 if (fname == NULL) | |
9408 fname = (char_u *)_("Untitled"); | |
2770 | 9409 vim_snprintf((char *)buff, DIALOG_MSG_SIZE, format, fname); |
7 | 9410 } |
9411 #endif | |
9412 | |
9413 /* | |
9414 * ":behave {mswin,xterm}" | |
9415 */ | |
9416 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
9417 ex_behave(exarg_T *eap) |
7 | 9418 { |
9419 if (STRCMP(eap->arg, "mswin") == 0) | |
9420 { | |
9421 set_option_value((char_u *)"selection", 0L, (char_u *)"exclusive", 0); | |
9422 set_option_value((char_u *)"selectmode", 0L, (char_u *)"mouse,key", 0); | |
9423 set_option_value((char_u *)"mousemodel", 0L, (char_u *)"popup", 0); | |
9424 set_option_value((char_u *)"keymodel", 0L, | |
9425 (char_u *)"startsel,stopsel", 0); | |
9426 } | |
9427 else if (STRCMP(eap->arg, "xterm") == 0) | |
9428 { | |
9429 set_option_value((char_u *)"selection", 0L, (char_u *)"inclusive", 0); | |
9430 set_option_value((char_u *)"selectmode", 0L, (char_u *)"", 0); | |
9431 set_option_value((char_u *)"mousemodel", 0L, (char_u *)"extend", 0); | |
9432 set_option_value((char_u *)"keymodel", 0L, (char_u *)"", 0); | |
9433 } | |
9434 else | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
9435 semsg(_(e_invarg2), eap->arg); |
7 | 9436 } |
9437 | |
2097
8f72e3512b43
updated for version 7.2.381
Bram Moolenaar <bram@zimbu.org>
parents:
2068
diff
changeset
|
9438 #if defined(FEAT_CMDL_COMPL) || defined(PROTO) |
8f72e3512b43
updated for version 7.2.381
Bram Moolenaar <bram@zimbu.org>
parents:
2068
diff
changeset
|
9439 /* |
8f72e3512b43
updated for version 7.2.381
Bram Moolenaar <bram@zimbu.org>
parents:
2068
diff
changeset
|
9440 * Function given to ExpandGeneric() to obtain the possible arguments of the |
8f72e3512b43
updated for version 7.2.381
Bram Moolenaar <bram@zimbu.org>
parents:
2068
diff
changeset
|
9441 * ":behave {mswin,xterm}" command. |
8f72e3512b43
updated for version 7.2.381
Bram Moolenaar <bram@zimbu.org>
parents:
2068
diff
changeset
|
9442 */ |
8f72e3512b43
updated for version 7.2.381
Bram Moolenaar <bram@zimbu.org>
parents:
2068
diff
changeset
|
9443 char_u * |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
9444 get_behave_arg(expand_T *xp UNUSED, int idx) |
2097
8f72e3512b43
updated for version 7.2.381
Bram Moolenaar <bram@zimbu.org>
parents:
2068
diff
changeset
|
9445 { |
8f72e3512b43
updated for version 7.2.381
Bram Moolenaar <bram@zimbu.org>
parents:
2068
diff
changeset
|
9446 if (idx == 0) |
8f72e3512b43
updated for version 7.2.381
Bram Moolenaar <bram@zimbu.org>
parents:
2068
diff
changeset
|
9447 return (char_u *)"mswin"; |
8f72e3512b43
updated for version 7.2.381
Bram Moolenaar <bram@zimbu.org>
parents:
2068
diff
changeset
|
9448 if (idx == 1) |
8f72e3512b43
updated for version 7.2.381
Bram Moolenaar <bram@zimbu.org>
parents:
2068
diff
changeset
|
9449 return (char_u *)"xterm"; |
8f72e3512b43
updated for version 7.2.381
Bram Moolenaar <bram@zimbu.org>
parents:
2068
diff
changeset
|
9450 return NULL; |
8f72e3512b43
updated for version 7.2.381
Bram Moolenaar <bram@zimbu.org>
parents:
2068
diff
changeset
|
9451 } |
10275
6d8b2da002e9
commit https://github.com/vim/vim/commit/9e507ca8a3e1535e62de4bd86374b0fcd18ef5b8
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
9452 |
6d8b2da002e9
commit https://github.com/vim/vim/commit/9e507ca8a3e1535e62de4bd86374b0fcd18ef5b8
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
9453 /* |
6d8b2da002e9
commit https://github.com/vim/vim/commit/9e507ca8a3e1535e62de4bd86374b0fcd18ef5b8
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
9454 * Function given to ExpandGeneric() to obtain the possible arguments of the |
6d8b2da002e9
commit https://github.com/vim/vim/commit/9e507ca8a3e1535e62de4bd86374b0fcd18ef5b8
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
9455 * ":messages {clear}" command. |
6d8b2da002e9
commit https://github.com/vim/vim/commit/9e507ca8a3e1535e62de4bd86374b0fcd18ef5b8
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
9456 */ |
6d8b2da002e9
commit https://github.com/vim/vim/commit/9e507ca8a3e1535e62de4bd86374b0fcd18ef5b8
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
9457 char_u * |
6d8b2da002e9
commit https://github.com/vim/vim/commit/9e507ca8a3e1535e62de4bd86374b0fcd18ef5b8
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
9458 get_messages_arg(expand_T *xp UNUSED, int idx) |
6d8b2da002e9
commit https://github.com/vim/vim/commit/9e507ca8a3e1535e62de4bd86374b0fcd18ef5b8
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
9459 { |
6d8b2da002e9
commit https://github.com/vim/vim/commit/9e507ca8a3e1535e62de4bd86374b0fcd18ef5b8
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
9460 if (idx == 0) |
6d8b2da002e9
commit https://github.com/vim/vim/commit/9e507ca8a3e1535e62de4bd86374b0fcd18ef5b8
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
9461 return (char_u *)"clear"; |
6d8b2da002e9
commit https://github.com/vim/vim/commit/9e507ca8a3e1535e62de4bd86374b0fcd18ef5b8
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
9462 return NULL; |
6d8b2da002e9
commit https://github.com/vim/vim/commit/9e507ca8a3e1535e62de4bd86374b0fcd18ef5b8
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
9463 } |
2097
8f72e3512b43
updated for version 7.2.381
Bram Moolenaar <bram@zimbu.org>
parents:
2068
diff
changeset
|
9464 #endif |
8f72e3512b43
updated for version 7.2.381
Bram Moolenaar <bram@zimbu.org>
parents:
2068
diff
changeset
|
9465 |
15555
d89c5b339c2a
patch 8.1.0785: depending on the configuration some functions are unused
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
9466 #if defined(FEAT_CMDL_COMPL) || defined(PROTO) |
11995
7df3dd3c0ac1
patch 8.0.0878: no completion for :mapclear
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
9467 char_u * |
7df3dd3c0ac1
patch 8.0.0878: no completion for :mapclear
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
9468 get_mapclear_arg(expand_T *xp UNUSED, int idx) |
7df3dd3c0ac1
patch 8.0.0878: no completion for :mapclear
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
9469 { |
7df3dd3c0ac1
patch 8.0.0878: no completion for :mapclear
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
9470 if (idx == 0) |
7df3dd3c0ac1
patch 8.0.0878: no completion for :mapclear
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
9471 return (char_u *)"<buffer>"; |
7df3dd3c0ac1
patch 8.0.0878: no completion for :mapclear
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
9472 return NULL; |
7df3dd3c0ac1
patch 8.0.0878: no completion for :mapclear
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
9473 } |
15555
d89c5b339c2a
patch 8.1.0785: depending on the configuration some functions are unused
Bram Moolenaar <Bram@vim.org>
parents:
15543
diff
changeset
|
9474 #endif |
11995
7df3dd3c0ac1
patch 8.0.0878: no completion for :mapclear
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
9475 |
7 | 9476 static int filetype_detect = FALSE; |
9477 static int filetype_plugin = FALSE; | |
9478 static int filetype_indent = FALSE; | |
9479 | |
9480 /* | |
9481 * ":filetype [plugin] [indent] {on,off,detect}" | |
9482 * on: Load the filetype.vim file to install autocommands for file types. | |
9483 * off: Load the ftoff.vim file to remove all autocommands for file types. | |
9484 * plugin on: load filetype.vim and ftplugin.vim | |
9485 * plugin off: load ftplugof.vim | |
9486 * indent on: load filetype.vim and indent.vim | |
9487 * indent off: load indoff.vim | |
9488 */ | |
9489 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
9490 ex_filetype(exarg_T *eap) |
7 | 9491 { |
9492 char_u *arg = eap->arg; | |
9493 int plugin = FALSE; | |
9494 int indent = FALSE; | |
9495 | |
9496 if (*eap->arg == NUL) | |
9497 { | |
9498 /* Print current status. */ | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
9499 smsg("filetype detection:%s plugin:%s indent:%s", |
7 | 9500 filetype_detect ? "ON" : "OFF", |
9501 filetype_plugin ? (filetype_detect ? "ON" : "(on)") : "OFF", | |
9502 filetype_indent ? (filetype_detect ? "ON" : "(on)") : "OFF"); | |
9503 return; | |
9504 } | |
9505 | |
9506 /* Accept "plugin" and "indent" in any order. */ | |
9507 for (;;) | |
9508 { | |
9509 if (STRNCMP(arg, "plugin", 6) == 0) | |
9510 { | |
9511 plugin = TRUE; | |
9512 arg = skipwhite(arg + 6); | |
9513 continue; | |
9514 } | |
9515 if (STRNCMP(arg, "indent", 6) == 0) | |
9516 { | |
9517 indent = TRUE; | |
9518 arg = skipwhite(arg + 6); | |
9519 continue; | |
9520 } | |
9521 break; | |
9522 } | |
9523 if (STRCMP(arg, "on") == 0 || STRCMP(arg, "detect") == 0) | |
9524 { | |
9525 if (*arg == 'o' || !filetype_detect) | |
9526 { | |
8524
2f57bbe870ea
commit https://github.com/vim/vim/commit/7f8989dd8a627af2185df381195351a913f3777f
Christian Brabandt <cb@256bit.org>
parents:
8402
diff
changeset
|
9527 source_runtime((char_u *)FILETYPE_FILE, DIP_ALL); |
7 | 9528 filetype_detect = TRUE; |
9529 if (plugin) | |
9530 { | |
8524
2f57bbe870ea
commit https://github.com/vim/vim/commit/7f8989dd8a627af2185df381195351a913f3777f
Christian Brabandt <cb@256bit.org>
parents:
8402
diff
changeset
|
9531 source_runtime((char_u *)FTPLUGIN_FILE, DIP_ALL); |
7 | 9532 filetype_plugin = TRUE; |
9533 } | |
9534 if (indent) | |
9535 { | |
8524
2f57bbe870ea
commit https://github.com/vim/vim/commit/7f8989dd8a627af2185df381195351a913f3777f
Christian Brabandt <cb@256bit.org>
parents:
8402
diff
changeset
|
9536 source_runtime((char_u *)INDENT_FILE, DIP_ALL); |
7 | 9537 filetype_indent = TRUE; |
9538 } | |
9539 } | |
9540 if (*arg == 'd') | |
9541 { | |
9260
ac8180818504
commit https://github.com/vim/vim/commit/1610d052413e0ed664498853a47acc2d677a22d1
Christian Brabandt <cb@256bit.org>
parents:
9230
diff
changeset
|
9542 (void)do_doautocmd((char_u *)"filetypedetect BufRead", TRUE, NULL); |
717 | 9543 do_modelines(0); |
7 | 9544 } |
9545 } | |
9546 else if (STRCMP(arg, "off") == 0) | |
9547 { | |
9548 if (plugin || indent) | |
9549 { | |
9550 if (plugin) | |
9551 { | |
8524
2f57bbe870ea
commit https://github.com/vim/vim/commit/7f8989dd8a627af2185df381195351a913f3777f
Christian Brabandt <cb@256bit.org>
parents:
8402
diff
changeset
|
9552 source_runtime((char_u *)FTPLUGOF_FILE, DIP_ALL); |
7 | 9553 filetype_plugin = FALSE; |
9554 } | |
9555 if (indent) | |
9556 { | |
8524
2f57bbe870ea
commit https://github.com/vim/vim/commit/7f8989dd8a627af2185df381195351a913f3777f
Christian Brabandt <cb@256bit.org>
parents:
8402
diff
changeset
|
9557 source_runtime((char_u *)INDOFF_FILE, DIP_ALL); |
7 | 9558 filetype_indent = FALSE; |
9559 } | |
9560 } | |
9561 else | |
9562 { | |
8524
2f57bbe870ea
commit https://github.com/vim/vim/commit/7f8989dd8a627af2185df381195351a913f3777f
Christian Brabandt <cb@256bit.org>
parents:
8402
diff
changeset
|
9563 source_runtime((char_u *)FTOFF_FILE, DIP_ALL); |
7 | 9564 filetype_detect = FALSE; |
9565 } | |
9566 } | |
9567 else | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
9568 semsg(_(e_invarg2), arg); |
7 | 9569 } |
9570 | |
9571 /* | |
11459
561b76ed9d12
patch 8.0.0613: the conf filetype is used before ftdetect from packages
Christian Brabandt <cb@256bit.org>
parents:
11428
diff
changeset
|
9572 * ":setfiletype [FALLBACK] {name}" |
7 | 9573 */ |
9574 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
9575 ex_setfiletype(exarg_T *eap) |
7 | 9576 { |
9577 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
|
9578 { |
561b76ed9d12
patch 8.0.0613: the conf filetype is used before ftdetect from packages
Christian Brabandt <cb@256bit.org>
parents:
11428
diff
changeset
|
9579 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
|
9580 |
561b76ed9d12
patch 8.0.0613: the conf filetype is used before ftdetect from packages
Christian Brabandt <cb@256bit.org>
parents:
11428
diff
changeset
|
9581 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
|
9582 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
|
9583 |
561b76ed9d12
patch 8.0.0613: the conf filetype is used before ftdetect from packages
Christian Brabandt <cb@256bit.org>
parents:
11428
diff
changeset
|
9584 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
|
9585 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
|
9586 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
|
9587 } |
7 | 9588 } |
9589 | |
9590 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
9591 ex_digraphs(exarg_T *eap UNUSED) |
7 | 9592 { |
9593 #ifdef FEAT_DIGRAPHS | |
9594 if (*eap->arg != NUL) | |
9595 putdigraph(eap->arg); | |
9596 else | |
15152
1ef429366fd4
patch 8.1.0586: :digraph output is not easy to read
Bram Moolenaar <Bram@vim.org>
parents:
15125
diff
changeset
|
9597 listdigraphs(eap->forceit); |
7 | 9598 #else |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
9599 emsg(_("E196: No digraphs in this version")); |
7 | 9600 #endif |
9601 } | |
9602 | |
9603 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
9604 ex_set(exarg_T *eap) |
7 | 9605 { |
9606 int flags = 0; | |
9607 | |
9608 if (eap->cmdidx == CMD_setlocal) | |
9609 flags = OPT_LOCAL; | |
9610 else if (eap->cmdidx == CMD_setglobal) | |
9611 flags = OPT_GLOBAL; | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
9612 #if defined(FEAT_EVAL) && defined(FEAT_BROWSE) |
7 | 9613 if (cmdmod.browse && flags == 0) |
9614 ex_options(eap); | |
9615 else | |
9616 #endif | |
9617 (void)do_set(eap->arg, flags); | |
9618 } | |
9619 | |
13792
0e9b2971d7c3
patch 8.0.1768: SET_NO_HLSEARCH() used in a wrong way
Christian Brabandt <cb@256bit.org>
parents:
13581
diff
changeset
|
9620 #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
|
9621 void |
0e9b2971d7c3
patch 8.0.1768: SET_NO_HLSEARCH() used in a wrong way
Christian Brabandt <cb@256bit.org>
parents:
13581
diff
changeset
|
9622 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
|
9623 { |
0e9b2971d7c3
patch 8.0.1768: SET_NO_HLSEARCH() used in a wrong way
Christian Brabandt <cb@256bit.org>
parents:
13581
diff
changeset
|
9624 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
|
9625 # 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
|
9626 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
|
9627 # endif |
0e9b2971d7c3
patch 8.0.1768: SET_NO_HLSEARCH() used in a wrong way
Christian Brabandt <cb@256bit.org>
parents:
13581
diff
changeset
|
9628 } |
0e9b2971d7c3
patch 8.0.1768: SET_NO_HLSEARCH() used in a wrong way
Christian Brabandt <cb@256bit.org>
parents:
13581
diff
changeset
|
9629 |
7 | 9630 /* |
9631 * ":nohlsearch" | |
9632 */ | |
9633 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
9634 ex_nohlsearch(exarg_T *eap UNUSED) |
7 | 9635 { |
13792
0e9b2971d7c3
patch 8.0.1768: SET_NO_HLSEARCH() used in a wrong way
Christian Brabandt <cb@256bit.org>
parents:
13581
diff
changeset
|
9636 set_no_hlsearch(TRUE); |
737 | 9637 redraw_all_later(SOME_VALID); |
7 | 9638 } |
9639 #endif | |
9640 | |
9641 #ifdef FEAT_CRYPT | |
9642 /* | |
9643 * ":X": Get crypt key | |
9644 */ | |
9645 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
9646 ex_X(exarg_T *eap UNUSED) |
7 | 9647 { |
6353 | 9648 crypt_check_current_method(); |
6122 | 9649 (void)crypt_get_key(TRUE, TRUE); |
7 | 9650 } |
9651 #endif | |
9652 | |
9653 #ifdef FEAT_FOLDING | |
9654 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
9655 ex_fold(exarg_T *eap) |
7 | 9656 { |
9657 if (foldManualAllowed(TRUE)) | |
9658 foldCreate(eap->line1, eap->line2); | |
9659 } | |
9660 | |
9661 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
9662 ex_foldopen(exarg_T *eap) |
7 | 9663 { |
9664 opFoldRange(eap->line1, eap->line2, eap->cmdidx == CMD_foldopen, | |
9665 eap->forceit, FALSE); | |
9666 } | |
9667 | |
9668 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
9669 ex_folddo(exarg_T *eap) |
7 | 9670 { |
9671 linenr_T lnum; | |
9672 | |
6116 | 9673 #ifdef FEAT_CLIPBOARD |
9674 start_global_changes(); | |
9675 #endif | |
9676 | |
7 | 9677 /* First set the marks for all lines closed/open. */ |
9678 for (lnum = eap->line1; lnum <= eap->line2; ++lnum) | |
9679 if (hasFolding(lnum, NULL, NULL) == (eap->cmdidx == CMD_folddoclosed)) | |
9680 ml_setmarked(lnum); | |
9681 | |
9682 /* Execute the command on the marked lines. */ | |
9683 global_exe(eap->arg); | |
9684 ml_clearmarked(); /* clear rest of the marks */ | |
6116 | 9685 #ifdef FEAT_CLIPBOARD |
9686 end_global_changes(); | |
9687 #endif | |
9688 } | |
9689 #endif | |
12459
937356f8f8d6
patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents:
12457
diff
changeset
|
9690 |
14550
60b9b6196644
patch 8.1.0288: quickfix code uses cmdidx too often
Christian Brabandt <cb@256bit.org>
parents:
14538
diff
changeset
|
9691 #ifdef FEAT_QUICKFIX |
60b9b6196644
patch 8.1.0288: quickfix code uses cmdidx too often
Christian Brabandt <cb@256bit.org>
parents:
14538
diff
changeset
|
9692 /* |
60b9b6196644
patch 8.1.0288: quickfix code uses cmdidx too often
Christian Brabandt <cb@256bit.org>
parents:
14538
diff
changeset
|
9693 * 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
|
9694 * 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
|
9695 */ |
60b9b6196644
patch 8.1.0288: quickfix code uses cmdidx too often
Christian Brabandt <cb@256bit.org>
parents:
14538
diff
changeset
|
9696 int |
60b9b6196644
patch 8.1.0288: quickfix code uses cmdidx too often
Christian Brabandt <cb@256bit.org>
parents:
14538
diff
changeset
|
9697 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
|
9698 { |
14621
89cc3e7ecb68
patch 8.1.0324: off-by-one error in cmdidx check
Christian Brabandt <cb@256bit.org>
parents:
14591
diff
changeset
|
9699 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
|
9700 return FALSE; |
60b9b6196644
patch 8.1.0288: quickfix code uses cmdidx too often
Christian Brabandt <cb@256bit.org>
parents:
14538
diff
changeset
|
9701 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
|
9702 } |
60b9b6196644
patch 8.1.0288: quickfix code uses cmdidx too often
Christian Brabandt <cb@256bit.org>
parents:
14538
diff
changeset
|
9703 #endif |
60b9b6196644
patch 8.1.0288: quickfix code uses cmdidx too often
Christian Brabandt <cb@256bit.org>
parents:
14538
diff
changeset
|
9704 |
12459
937356f8f8d6
patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents:
12457
diff
changeset
|
9705 # if defined(FEAT_TIMERS) || defined(PROTO) |
937356f8f8d6
patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents:
12457
diff
changeset
|
9706 int |
937356f8f8d6
patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents:
12457
diff
changeset
|
9707 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
|
9708 { |
937356f8f8d6
patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents:
12457
diff
changeset
|
9709 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
|
9710 } |
937356f8f8d6
patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents:
12457
diff
changeset
|
9711 |
937356f8f8d6
patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents:
12457
diff
changeset
|
9712 void |
937356f8f8d6
patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents:
12457
diff
changeset
|
9713 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
|
9714 { |
937356f8f8d6
patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents:
12457
diff
changeset
|
9715 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
|
9716 } |
937356f8f8d6
patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents:
12457
diff
changeset
|
9717 #endif |