Mercurial > vim
annotate src/ex_docmd.c @ 17781:04245f071792 v8.1.1887
patch 8.1.1887: the +cmdline_compl feature is not in the tiny version
commit https://github.com/vim/vim/commit/0a52df50a0e8fce6f5e0eb5f5373dcd0fa24d83a
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Aug 18 22:26:31 2019 +0200
patch 8.1.1887: the +cmdline_compl feature is not in the tiny version
Problem: The +cmdline_compl feature is not in the tiny version.
Solution: Graduate the +cmdline_compl feature.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 18 Aug 2019 22:30:04 +0200 |
parents | c75da1064e33 |
children | e8a7029efa40 |
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 |
17536
e00d12c085a5
patch 8.1.1766: code for writing session file is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17496
diff
changeset
|
307 #ifndef FEAT_SESSION |
7 | 308 # define ex_loadview ex_ni |
309 #endif | |
17458
cfdef48743ed
patch 8.1.1727: code for viminfo support is spread out
Bram Moolenaar <Bram@vim.org>
parents:
17431
diff
changeset
|
310 #ifndef FEAT_VIMINFO |
7 | 311 # define ex_viminfo ex_ni |
312 #endif | |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
313 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
|
314 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
|
315 static void ex_setfiletype(exarg_T *eap); |
7 | 316 #ifndef FEAT_DIFF |
16 | 317 # define ex_diffoff ex_ni |
7 | 318 # define ex_diffpatch ex_ni |
319 # define ex_diffgetput ex_ni | |
320 # define ex_diffsplit ex_ni | |
321 # define ex_diffthis ex_ni | |
322 # define ex_diffupdate ex_ni | |
323 #endif | |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
324 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
|
325 static void ex_set(exarg_T *eap); |
7 | 326 #ifdef FEAT_SEARCH_EXTRA |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
327 static void ex_nohlsearch(exarg_T *eap); |
7 | 328 #else |
329 # define ex_nohlsearch ex_ni | |
330 # define ex_match ex_ni | |
331 #endif | |
332 #ifdef FEAT_CRYPT | |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
333 static void ex_X(exarg_T *eap); |
7 | 334 #else |
335 # define ex_X ex_ni | |
336 #endif | |
337 #ifdef FEAT_FOLDING | |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
338 static void ex_fold(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
339 static void ex_foldopen(exarg_T *eap); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
340 static void ex_folddo(exarg_T *eap); |
7 | 341 #else |
342 # define ex_fold ex_ni | |
343 # define ex_foldopen ex_ni | |
344 # define ex_folddo ex_ni | |
345 #endif | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
346 #if !(defined(HAVE_LOCALE_H) || defined(X_LOCALE)) |
7 | 347 # define ex_language ex_ni |
348 #endif | |
349 #ifndef FEAT_SIGNS | |
350 # define ex_sign ex_ni | |
351 #endif | |
33 | 352 #ifndef FEAT_NETBEANS_INTG |
2210 | 353 # define ex_nbclose ex_ni |
33 | 354 # define ex_nbkey ex_ni |
2210 | 355 # define ex_nbstart ex_ni |
33 | 356 #endif |
7 | 357 |
358 #ifndef FEAT_JUMPLIST | |
359 # define ex_jumps ex_ni | |
9284
78712a2f687a
commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1
Christian Brabandt <cb@256bit.org>
parents:
9260
diff
changeset
|
360 # define ex_clearjumps ex_ni |
7 | 361 # define ex_changes ex_ni |
362 #endif | |
363 | |
170 | 364 #ifndef FEAT_PROFILE |
365 # define ex_profile ex_ni | |
366 #endif | |
11621
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
11547
diff
changeset
|
367 #ifndef FEAT_TERMINAL |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
11547
diff
changeset
|
368 # define ex_terminal ex_ni |
b8299e742f41
patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents:
11547
diff
changeset
|
369 #endif |
16608
0422b14bce58
patch 8.1.1307: cannot reconnect to the X server after it restarted
Bram Moolenaar <Bram@vim.org>
parents:
16576
diff
changeset
|
370 #if !defined(FEAT_X11) || !defined(FEAT_XCLIPBOARD) |
0422b14bce58
patch 8.1.1307: cannot reconnect to the X server after it restarted
Bram Moolenaar <Bram@vim.org>
parents:
16576
diff
changeset
|
371 # define ex_xrestore ex_ni |
0422b14bce58
patch 8.1.1307: cannot reconnect to the X server after it restarted
Bram Moolenaar <Bram@vim.org>
parents:
16576
diff
changeset
|
372 #endif |
16780
491c01280a5d
patch 8.1.1392: build failure in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
373 #if !defined(FEAT_TEXT_PROP) |
491c01280a5d
patch 8.1.1392: build failure in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
374 # define ex_popupclear ex_ni |
491c01280a5d
patch 8.1.1392: build failure in tiny version
Bram Moolenaar <Bram@vim.org>
parents:
16764
diff
changeset
|
375 #endif |
170 | 376 |
7 | 377 /* |
378 * Declare cmdnames[]. | |
379 */ | |
380 #define DO_DECLARE_EXCMD | |
381 #include "ex_cmds.h" | |
11374
889da8649221
patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents:
11258
diff
changeset
|
382 #include "ex_cmdidxs.h" |
11236
62c96fee518e
patch 8.0.0504: looking up an Ex command is a bit slow
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
383 |
7 | 384 static char_u dollar_command[2] = {'$', 0}; |
385 | |
386 | |
387 #ifdef FEAT_EVAL | |
72 | 388 /* Struct for storing a line inside a while/for loop */ |
7 | 389 typedef struct |
390 { | |
391 char_u *line; /* command line */ | |
392 linenr_T lnum; /* sourcing_lnum of the line */ | |
393 } wcmd_T; | |
394 | |
395 /* | |
72 | 396 * Structure used to store info for line position in a while or for loop. |
7 | 397 * This is required, because do_one_cmd() may invoke ex_function(), which |
72 | 398 * reads more lines that may come from the while/for loop. |
399 */ | |
400 struct loop_cookie | |
7 | 401 { |
402 garray_T *lines_gap; /* growarray with line info */ | |
403 int current_line; /* last read line from growarray */ | |
404 int repeating; /* TRUE when looping a second time */ | |
405 /* When "repeating" is FALSE use "getline" and "cookie" to get lines */ | |
17178
40c4cb095d53
patch 8.1.1588: in :let-heredoc line continuation is recognized
Bram Moolenaar <Bram@vim.org>
parents:
17111
diff
changeset
|
406 char_u *(*getline)(int, void *, int, int); |
7 | 407 void *cookie; |
408 }; | |
409 | |
17178
40c4cb095d53
patch 8.1.1588: in :let-heredoc line continuation is recognized
Bram Moolenaar <Bram@vim.org>
parents:
17111
diff
changeset
|
410 static char_u *get_loop_line(int c, void *cookie, int indent, int do_concat); |
7799
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
411 static int store_loop_line(garray_T *gap, char_u *line); |
af3c41a3c53f
commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents:
7703
diff
changeset
|
412 static void free_cmdlines(garray_T *gap); |
8 | 413 |
414 /* Struct to save a few things while debugging. Used in do_cmdline() only. */ | |
415 struct dbg_stuff | |
416 { | |
417 int trylevel; | |
418 int force_abort; | |
419 except_T *caught_stack; | |
420 char_u *vv_exception; | |
421 char_u *vv_throwpoint; | |
422 int did_emsg; | |
423 int got_int; | |
424 int did_throw; | |
425 int need_rethrow; | |
426 int check_cstack; | |
427 except_T *current_exception; | |
428 }; | |
429 | |
430 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
431 save_dbg_stuff(struct dbg_stuff *dsp) |
8 | 432 { |
433 dsp->trylevel = trylevel; trylevel = 0; | |
434 dsp->force_abort = force_abort; force_abort = FALSE; | |
435 dsp->caught_stack = caught_stack; caught_stack = NULL; | |
436 dsp->vv_exception = v_exception(NULL); | |
437 dsp->vv_throwpoint = v_throwpoint(NULL); | |
438 | |
439 /* Necessary for debugging an inactive ":catch", ":finally", ":endtry" */ | |
440 dsp->did_emsg = did_emsg; did_emsg = FALSE; | |
441 dsp->got_int = got_int; got_int = FALSE; | |
442 dsp->did_throw = did_throw; did_throw = FALSE; | |
443 dsp->need_rethrow = need_rethrow; need_rethrow = FALSE; | |
444 dsp->check_cstack = check_cstack; check_cstack = FALSE; | |
445 dsp->current_exception = current_exception; current_exception = NULL; | |
446 } | |
447 | |
448 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
449 restore_dbg_stuff(struct dbg_stuff *dsp) |
8 | 450 { |
451 suppress_errthrow = FALSE; | |
452 trylevel = dsp->trylevel; | |
453 force_abort = dsp->force_abort; | |
454 caught_stack = dsp->caught_stack; | |
455 (void)v_exception(dsp->vv_exception); | |
456 (void)v_throwpoint(dsp->vv_throwpoint); | |
457 did_emsg = dsp->did_emsg; | |
458 got_int = dsp->got_int; | |
459 did_throw = dsp->did_throw; | |
460 need_rethrow = dsp->need_rethrow; | |
461 check_cstack = dsp->check_cstack; | |
462 current_exception = dsp->current_exception; | |
463 } | |
7 | 464 #endif |
465 | |
466 /* | |
467 * do_exmode(): Repeatedly get commands for the "Ex" mode, until the ":vi" | |
468 * command is given. | |
469 */ | |
470 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
471 do_exmode( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
472 int improved) /* TRUE for "improved Ex" mode */ |
7 | 473 { |
474 int save_msg_scroll; | |
475 int prev_msg_row; | |
476 linenr_T prev_line; | |
10889
5780bd3a5a7e
patch 8.0.0334: can't access b:changedtick from a dict reference
Christian Brabandt <cb@256bit.org>
parents:
10875
diff
changeset
|
477 varnumber_T changedtick; |
167 | 478 |
479 if (improved) | |
480 exmode_active = EXMODE_VIM; | |
481 else | |
482 exmode_active = EXMODE_NORMAL; | |
483 State = NORMAL; | |
484 | |
485 /* When using ":global /pat/ visual" and then "Q" we return to continue | |
486 * the :global command. */ | |
487 if (global_busy) | |
488 return; | |
7 | 489 |
490 save_msg_scroll = msg_scroll; | |
491 ++RedrawingDisabled; /* don't redisplay the window */ | |
492 ++no_wait_return; /* don't wait for return */ | |
493 #ifdef FEAT_GUI | |
494 /* Ignore scrollbar and mouse events in Ex mode */ | |
495 ++hold_gui_events; | |
496 #endif | |
497 | |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15510
diff
changeset
|
498 msg(_("Entering Ex mode. Type \"visual\" to go to Normal mode.")); |
7 | 499 while (exmode_active) |
500 { | |
161 | 501 /* Check for a ":normal" command and no more characters left. */ |
502 if (ex_normal_busy > 0 && typebuf.tb_len == 0) | |
503 { | |
504 exmode_active = FALSE; | |
505 break; | |
506 } | |
7 | 507 msg_scroll = TRUE; |
508 need_wait_return = FALSE; | |
509 ex_pressedreturn = FALSE; | |
510 ex_no_reprint = FALSE; | |
10952
835604f3c37a
patch 8.0.0365: might free a dict item that wasn't allocated
Christian Brabandt <cb@256bit.org>
parents:
10889
diff
changeset
|
511 changedtick = CHANGEDTICK(curbuf); |
7 | 512 prev_msg_row = msg_row; |
513 prev_line = curwin->w_cursor.lnum; | |
514 if (improved) | |
515 { | |
516 cmdline_row = msg_row; | |
517 do_cmdline(NULL, getexline, NULL, 0); | |
518 } | |
519 else | |
520 do_cmdline(NULL, getexmodeline, NULL, DOCMD_NOWAIT); | |
521 lines_left = Rows - 1; | |
522 | |
167 | 523 if ((prev_line != curwin->w_cursor.lnum |
10952
835604f3c37a
patch 8.0.0365: might free a dict item that wasn't allocated
Christian Brabandt <cb@256bit.org>
parents:
10889
diff
changeset
|
524 || changedtick != CHANGEDTICK(curbuf)) && !ex_no_reprint) |
167 | 525 { |
526 if (curbuf->b_ml.ml_flags & ML_EMPTY) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
527 emsg(_(e_emptybuf)); |
167 | 528 else |
529 { | |
530 if (ex_pressedreturn) | |
531 { | |
532 /* go up one line, to overwrite the ":<CR>" line, so the | |
1441 | 533 * output doesn't contain empty lines. */ |
167 | 534 msg_row = prev_msg_row; |
535 if (prev_msg_row == Rows - 1) | |
536 msg_row--; | |
537 } | |
538 msg_col = 0; | |
539 print_line_no_prefix(curwin->w_cursor.lnum, FALSE, FALSE); | |
540 msg_clr_eos(); | |
541 } | |
542 } | |
543 else if (ex_pressedreturn && !ex_no_reprint) /* must be at EOF */ | |
544 { | |
545 if (curbuf->b_ml.ml_flags & ML_EMPTY) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
546 emsg(_(e_emptybuf)); |
167 | 547 else |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
548 emsg(_("E501: At end-of-file")); |
167 | 549 } |
7 | 550 } |
551 | |
552 #ifdef FEAT_GUI | |
553 --hold_gui_events; | |
554 #endif | |
555 --RedrawingDisabled; | |
556 --no_wait_return; | |
557 update_screen(CLEAR); | |
558 need_wait_return = FALSE; | |
559 msg_scroll = save_msg_scroll; | |
560 } | |
561 | |
562 /* | |
563 * Execute a simple command line. Used for translated commands like "*". | |
564 */ | |
565 int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
566 do_cmdline_cmd(char_u *cmd) |
7 | 567 { |
568 return do_cmdline(cmd, NULL, NULL, | |
569 DOCMD_VERBOSE|DOCMD_NOWAIT|DOCMD_KEYTYPED); | |
570 } | |
571 | |
572 /* | |
573 * do_cmdline(): execute one Ex command line | |
574 * | |
575 * 1. Execute "cmdline" when it is not NULL. | |
2635 | 576 * If "cmdline" is NULL, or more lines are needed, fgetline() is used. |
7 | 577 * 2. Split up in parts separated with '|'. |
578 * | |
579 * This function can be called recursively! | |
580 * | |
581 * flags: | |
582 * DOCMD_VERBOSE - The command will be included in the error message. | |
583 * DOCMD_NOWAIT - Don't call wait_return() and friends. | |
2635 | 584 * DOCMD_REPEAT - Repeat execution until fgetline() returns NULL. |
7 | 585 * DOCMD_KEYTYPED - Don't reset KeyTyped. |
586 * DOCMD_EXCRESET - Reset the exception environment (used for debugging). | |
587 * DOCMD_KEEPLINE - Store first typed line (for repeating with "."). | |
588 * | |
589 * return FAIL if cmdline could not be executed, OK otherwise | |
590 */ | |
591 int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
592 do_cmdline( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
593 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
|
594 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
|
595 void *cookie, /* argument for fgetline() */ |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
596 int flags) |
7 | 597 { |
598 char_u *next_cmdline; /* next cmd to execute */ | |
599 char_u *cmdline_copy = NULL; /* copy of cmd line */ | |
2635 | 600 int used_getline = FALSE; /* used "fgetline" to obtain command */ |
7 | 601 static int recursive = 0; /* recursive depth */ |
602 int msg_didout_before_start = 0; | |
603 int count = 0; /* line number count */ | |
604 int did_inc = FALSE; /* incremented RedrawingDisabled */ | |
605 int retval = OK; | |
606 #ifdef FEAT_EVAL | |
607 struct condstack cstack; /* conditional stack */ | |
72 | 608 garray_T lines_ga; /* keep lines for ":while"/":for" */ |
7 | 609 int current_line = 0; /* active line in lines_ga */ |
610 char_u *fname = NULL; /* function or script name */ | |
611 linenr_T *breakpoint = NULL; /* ptr to breakpoint field in cookie */ | |
612 int *dbg_tick = NULL; /* ptr to dbg_tick field in cookie */ | |
8 | 613 struct dbg_stuff debug_saved; /* saved things for debug mode */ |
7 | 614 int initial_trylevel; |
615 struct msglist **saved_msg_list = NULL; | |
616 struct msglist *private_msg_list; | |
617 | |
2635 | 618 /* "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
|
619 char_u *(*cmd_getline)(int, void *, int, int); |
7 | 620 void *cmd_cookie; |
72 | 621 struct loop_cookie cmd_loop_cookie; |
7 | 622 void *real_cookie; |
170 | 623 int getline_is_func; |
7 | 624 #else |
2635 | 625 # define cmd_getline fgetline |
7 | 626 # define cmd_cookie cookie |
627 #endif | |
628 static int call_depth = 0; /* recursiveness */ | |
629 | |
630 #ifdef FEAT_EVAL | |
631 /* For every pair of do_cmdline()/do_one_cmd() calls, use an extra memory | |
632 * location for storing error messages to be converted to an exception. | |
84 | 633 * This ensures that the do_errthrow() call in do_one_cmd() does not |
634 * combine the messages stored by an earlier invocation of do_one_cmd() | |
635 * with the command name of the later one. This would happen when | |
636 * BufWritePost autocommands are executed after a write error. */ | |
7 | 637 saved_msg_list = msg_list; |
638 msg_list = &private_msg_list; | |
639 private_msg_list = NULL; | |
640 #endif | |
641 | |
642 /* 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
|
643 * 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
|
644 * 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
|
645 if (call_depth >= 200 |
8f2191b56d52
commit https://github.com/vim/vim/commit/b094ff4b2be4d8b7364c566a1cc7e27aa4452a50
Christian Brabandt <cb@256bit.org>
parents:
10488
diff
changeset
|
646 #ifdef FEAT_EVAL |
8f2191b56d52
commit https://github.com/vim/vim/commit/b094ff4b2be4d8b7364c566a1cc7e27aa4452a50
Christian Brabandt <cb@256bit.org>
parents:
10488
diff
changeset
|
647 && call_depth >= p_mfd |
8f2191b56d52
commit https://github.com/vim/vim/commit/b094ff4b2be4d8b7364c566a1cc7e27aa4452a50
Christian Brabandt <cb@256bit.org>
parents:
10488
diff
changeset
|
648 #endif |
8f2191b56d52
commit https://github.com/vim/vim/commit/b094ff4b2be4d8b7364c566a1cc7e27aa4452a50
Christian Brabandt <cb@256bit.org>
parents:
10488
diff
changeset
|
649 ) |
7 | 650 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
651 emsg(_("E169: Command too recursive")); |
7 | 652 #ifdef FEAT_EVAL |
653 /* When converting to an exception, we do not include the command name | |
654 * since this is not an error of the specific command. */ | |
655 do_errthrow((struct condstack *)NULL, (char_u *)NULL); | |
656 msg_list = saved_msg_list; | |
657 #endif | |
658 return FAIL; | |
659 } | |
660 ++call_depth; | |
661 | |
662 #ifdef FEAT_EVAL | |
663 cstack.cs_idx = -1; | |
72 | 664 cstack.cs_looplevel = 0; |
7 | 665 cstack.cs_trylevel = 0; |
666 cstack.cs_emsg_silent_list = NULL; | |
72 | 667 cstack.cs_lflags = 0; |
7 | 668 ga_init2(&lines_ga, (int)sizeof(wcmd_T), 10); |
669 | |
2635 | 670 real_cookie = getline_cookie(fgetline, cookie); |
7 | 671 |
672 /* Inside a function use a higher nesting level. */ | |
2635 | 673 getline_is_func = getline_equal(fgetline, cookie, get_func_line); |
170 | 674 if (getline_is_func && ex_nesting_level == func_level(real_cookie)) |
7 | 675 ++ex_nesting_level; |
676 | |
677 /* Get the function or script name and the address where the next breakpoint | |
678 * line and the debug tick for a function or script are stored. */ | |
170 | 679 if (getline_is_func) |
7 | 680 { |
681 fname = func_name(real_cookie); | |
682 breakpoint = func_breakpoint(real_cookie); | |
683 dbg_tick = func_dbg_tick(real_cookie); | |
684 } | |
2635 | 685 else if (getline_equal(fgetline, cookie, getsourceline)) |
7 | 686 { |
687 fname = sourcing_name; | |
688 breakpoint = source_breakpoint(real_cookie); | |
689 dbg_tick = source_dbg_tick(real_cookie); | |
690 } | |
691 | |
692 /* | |
693 * Initialize "force_abort" and "suppress_errthrow" at the top level. | |
694 */ | |
695 if (!recursive) | |
696 { | |
697 force_abort = FALSE; | |
698 suppress_errthrow = FALSE; | |
699 } | |
700 | |
701 /* | |
702 * If requested, store and reset the global values controlling the | |
944 | 703 * exception handling (used when debugging). Otherwise clear it to avoid |
704 * a bogus compiler warning when the optimizer uses inline functions... | |
7 | 705 */ |
878 | 706 if (flags & DOCMD_EXCRESET) |
8 | 707 save_dbg_stuff(&debug_saved); |
944 | 708 else |
7133
48ce650e8a27
commit https://github.com/vim/vim/commit/69b67f7e774dc212e8c97495ee81c601b8a89ac2
Christian Brabandt <cb@256bit.org>
parents:
7109
diff
changeset
|
709 vim_memset(&debug_saved, 0, sizeof(debug_saved)); |
7 | 710 |
711 initial_trylevel = trylevel; | |
712 | |
713 /* | |
714 * "did_throw" will be set to TRUE when an exception is being thrown. | |
715 */ | |
716 did_throw = FALSE; | |
717 #endif | |
718 /* | |
719 * "did_emsg" will be set to TRUE when emsg() is used, in which case we | |
72 | 720 * cancel the whole command line, and any if/endif or loop. |
7 | 721 * If force_abort is set, we cancel everything. |
722 */ | |
723 did_emsg = FALSE; | |
724 | |
725 /* | |
726 * KeyTyped is only set when calling vgetc(). Reset it here when not | |
727 * calling vgetc() (sourced command lines). | |
728 */ | |
2635 | 729 if (!(flags & DOCMD_KEYTYPED) |
730 && !getline_equal(fgetline, cookie, getexline)) | |
7 | 731 KeyTyped = FALSE; |
732 | |
733 /* | |
734 * Continue executing command lines: | |
72 | 735 * - when inside an ":if", ":while" or ":for" |
7 | 736 * - for multiple commands on one line, separated with '|' |
737 * - when repeating until there are no more lines (for ":source") | |
738 */ | |
739 next_cmdline = cmdline; | |
740 do | |
741 { | |
170 | 742 #ifdef FEAT_EVAL |
2635 | 743 getline_is_func = getline_equal(fgetline, cookie, get_func_line); |
170 | 744 #endif |
745 | |
72 | 746 /* stop skipping cmds for an error msg after all endif/while/for */ |
7 | 747 if (next_cmdline == NULL |
748 #ifdef FEAT_EVAL | |
749 && !force_abort | |
750 && cstack.cs_idx < 0 | |
170 | 751 && !(getline_is_func && func_has_abort(real_cookie)) |
7 | 752 #endif |
753 ) | |
754 did_emsg = FALSE; | |
755 | |
756 /* | |
72 | 757 * 1. If repeating a line in a loop, get a line from lines_ga. |
2635 | 758 * 2. If no line given: Get an allocated line with fgetline(). |
7 | 759 * 3. If a line is given: Make a copy, so we can mess with it. |
760 */ | |
761 | |
762 #ifdef FEAT_EVAL | |
763 /* 1. If repeating, get a previous line from lines_ga. */ | |
72 | 764 if (cstack.cs_looplevel > 0 && current_line < lines_ga.ga_len) |
7 | 765 { |
766 /* Each '|' separated command is stored separately in lines_ga, to | |
767 * 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
|
768 VIM_CLEAR(cmdline_copy); |
7 | 769 |
770 /* Check if a function has returned or, unless it has an unclosed | |
771 * try conditional, aborted. */ | |
170 | 772 if (getline_is_func) |
773 { | |
774 # ifdef FEAT_PROFILE | |
788 | 775 if (do_profiling == PROF_YES) |
170 | 776 func_line_end(real_cookie); |
777 # endif | |
778 if (func_has_ended(real_cookie)) | |
779 { | |
780 retval = FAIL; | |
781 break; | |
782 } | |
783 } | |
784 #ifdef FEAT_PROFILE | |
788 | 785 else if (do_profiling == PROF_YES |
2635 | 786 && getline_equal(fgetline, cookie, getsourceline)) |
170 | 787 script_line_end(); |
788 #endif | |
7 | 789 |
790 /* Check if a sourced file hit a ":finish" command. */ | |
2635 | 791 if (source_finished(fgetline, cookie)) |
7 | 792 { |
793 retval = FAIL; | |
794 break; | |
795 } | |
796 | |
797 /* If breakpoints have been added/deleted need to check for it. */ | |
798 if (breakpoint != NULL && dbg_tick != NULL | |
799 && *dbg_tick != debug_tick) | |
800 { | |
801 *breakpoint = dbg_find_breakpoint( | |
2635 | 802 getline_equal(fgetline, cookie, getsourceline), |
7 | 803 fname, sourcing_lnum); |
804 *dbg_tick = debug_tick; | |
805 } | |
806 | |
807 next_cmdline = ((wcmd_T *)(lines_ga.ga_data))[current_line].line; | |
808 sourcing_lnum = ((wcmd_T *)(lines_ga.ga_data))[current_line].lnum; | |
809 | |
810 /* Did we encounter a breakpoint? */ | |
811 if (breakpoint != NULL && *breakpoint != 0 | |
812 && *breakpoint <= sourcing_lnum) | |
813 { | |
814 dbg_breakpoint(fname, sourcing_lnum); | |
815 /* Find next breakpoint. */ | |
816 *breakpoint = dbg_find_breakpoint( | |
2635 | 817 getline_equal(fgetline, cookie, getsourceline), |
7 | 818 fname, sourcing_lnum); |
819 *dbg_tick = debug_tick; | |
820 } | |
170 | 821 # ifdef FEAT_PROFILE |
788 | 822 if (do_profiling == PROF_YES) |
170 | 823 { |
824 if (getline_is_func) | |
825 func_line_start(real_cookie); | |
2635 | 826 else if (getline_equal(fgetline, cookie, getsourceline)) |
170 | 827 script_line_start(); |
828 } | |
829 # endif | |
7 | 830 } |
831 | |
72 | 832 if (cstack.cs_looplevel > 0) |
833 { | |
834 /* Inside a while/for loop we need to store the lines and use them | |
2635 | 835 * again. Pass a different "fgetline" function to do_one_cmd() |
7 | 836 * below, so that it stores lines in or reads them from |
837 * "lines_ga". Makes it possible to define a function inside a | |
72 | 838 * while/for loop. */ |
839 cmd_getline = get_loop_line; | |
840 cmd_cookie = (void *)&cmd_loop_cookie; | |
841 cmd_loop_cookie.lines_gap = &lines_ga; | |
842 cmd_loop_cookie.current_line = current_line; | |
2635 | 843 cmd_loop_cookie.getline = fgetline; |
72 | 844 cmd_loop_cookie.cookie = cookie; |
845 cmd_loop_cookie.repeating = (current_line < lines_ga.ga_len); | |
7 | 846 } |
847 else | |
848 { | |
2635 | 849 cmd_getline = fgetline; |
7 | 850 cmd_cookie = cookie; |
851 } | |
852 #endif | |
853 | |
2635 | 854 /* 2. If no line given, get an allocated line with fgetline(). */ |
7 | 855 if (next_cmdline == NULL) |
856 { | |
857 /* | |
858 * Need to set msg_didout for the first line after an ":if", | |
859 * otherwise the ":if" will be overwritten. | |
860 */ | |
2635 | 861 if (count == 1 && getline_equal(fgetline, cookie, getexline)) |
7 | 862 msg_didout = TRUE; |
2635 | 863 if (fgetline == NULL || (next_cmdline = fgetline(':', cookie, |
7 | 864 #ifdef FEAT_EVAL |
865 cstack.cs_idx < 0 ? 0 : (cstack.cs_idx + 1) * 2 | |
866 #else | |
867 0 | |
868 #endif | |
17178
40c4cb095d53
patch 8.1.1588: in :let-heredoc line continuation is recognized
Bram Moolenaar <Bram@vim.org>
parents:
17111
diff
changeset
|
869 , TRUE)) == NULL) |
7 | 870 { |
871 /* Don't call wait_return for aborted command line. The NULL | |
872 * returned for the end of a sourced file or executed function | |
873 * doesn't do this. */ | |
874 if (KeyTyped && !(flags & DOCMD_REPEAT)) | |
875 need_wait_return = FALSE; | |
876 retval = FAIL; | |
877 break; | |
878 } | |
879 used_getline = TRUE; | |
880 | |
881 /* | |
882 * Keep the first typed line. Clear it when more lines are typed. | |
883 */ | |
884 if (flags & DOCMD_KEEPLINE) | |
885 { | |
886 vim_free(repeat_cmdline); | |
887 if (count == 0) | |
888 repeat_cmdline = vim_strsave(next_cmdline); | |
889 else | |
890 repeat_cmdline = NULL; | |
891 } | |
892 } | |
893 | |
894 /* 3. Make a copy of the command so we can mess with it. */ | |
895 else if (cmdline_copy == NULL) | |
896 { | |
897 next_cmdline = vim_strsave(next_cmdline); | |
898 if (next_cmdline == NULL) | |
899 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
900 emsg(_(e_outofmem)); |
7 | 901 retval = FAIL; |
902 break; | |
903 } | |
904 } | |
905 cmdline_copy = next_cmdline; | |
906 | |
907 #ifdef FEAT_EVAL | |
908 /* | |
72 | 909 * Save the current line when inside a ":while" or ":for", and when |
910 * the command looks like a ":while" or ":for", because we may need it | |
911 * later. When there is a '|' and another command, it is stored | |
912 * separately, because we need to be able to jump back to it from an | |
913 * :endwhile/:endfor. | |
7 | 914 */ |
72 | 915 if (current_line == lines_ga.ga_len |
916 && (cstack.cs_looplevel || has_loop_cmd(next_cmdline))) | |
917 { | |
918 if (store_loop_line(&lines_ga, next_cmdline) == FAIL) | |
7 | 919 { |
920 retval = FAIL; | |
921 break; | |
922 } | |
923 } | |
924 did_endif = FALSE; | |
925 #endif | |
926 | |
927 if (count++ == 0) | |
928 { | |
929 /* | |
930 * All output from the commands is put below each other, without | |
931 * waiting for a return. Don't do this when executing commands | |
932 * from a script or when being called recursive (e.g. for ":e | |
933 * +command file"). | |
934 */ | |
935 if (!(flags & DOCMD_NOWAIT) && !recursive) | |
936 { | |
937 msg_didout_before_start = msg_didout; | |
938 msg_didany = FALSE; /* no output yet */ | |
939 msg_start(); | |
940 msg_scroll = TRUE; /* put messages below each other */ | |
4352 | 941 ++no_wait_return; /* don't wait for return until finished */ |
7 | 942 ++RedrawingDisabled; |
943 did_inc = TRUE; | |
944 } | |
945 } | |
946 | |
947 if (p_verbose >= 15 && sourcing_name != NULL) | |
948 { | |
949 ++no_wait_return; | |
291 | 950 verbose_enter_scroll(); |
951 | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
952 smsg(_("line %ld: %s"), |
7 | 953 (long)sourcing_lnum, cmdline_copy); |
291 | 954 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
|
955 msg_puts("\n"); /* don't overwrite this */ |
291 | 956 |
957 verbose_leave_scroll(); | |
7 | 958 --no_wait_return; |
959 } | |
960 | |
961 /* | |
962 * 2. Execute one '|' separated command. | |
963 * do_one_cmd() will return NULL if there is no trailing '|'. | |
964 * "cmdline_copy" can change, e.g. for '%' and '#' expansion. | |
965 */ | |
966 ++recursive; | |
967 next_cmdline = do_one_cmd(&cmdline_copy, flags & DOCMD_VERBOSE, | |
968 #ifdef FEAT_EVAL | |
969 &cstack, | |
970 #endif | |
971 cmd_getline, cmd_cookie); | |
972 --recursive; | |
973 | |
974 #ifdef FEAT_EVAL | |
72 | 975 if (cmd_cookie == (void *)&cmd_loop_cookie) |
976 /* Use "current_line" from "cmd_loop_cookie", it may have been | |
7 | 977 * incremented when defining a function. */ |
72 | 978 current_line = cmd_loop_cookie.current_line; |
7 | 979 #endif |
980 | |
981 if (next_cmdline == NULL) | |
982 { | |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13221
diff
changeset
|
983 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
|
984 |
7 | 985 /* |
986 * If the command was typed, remember it for the ':' register. | |
987 * Do this AFTER executing the command to make :@: work. | |
988 */ | |
2635 | 989 if (getline_equal(fgetline, cookie, getexline) |
7 | 990 && new_last_cmdline != NULL) |
991 { | |
992 vim_free(last_cmdline); | |
993 last_cmdline = new_last_cmdline; | |
994 new_last_cmdline = NULL; | |
995 } | |
996 } | |
997 else | |
998 { | |
999 /* need to copy the command after the '|' to cmdline_copy, for the | |
1000 * next do_one_cmd() */ | |
1619 | 1001 STRMOVE(cmdline_copy, next_cmdline); |
7 | 1002 next_cmdline = cmdline_copy; |
1003 } | |
1004 | |
1005 | |
1006 #ifdef FEAT_EVAL | |
1007 /* reset did_emsg for a function that is not aborted by an error */ | |
1008 if (did_emsg && !force_abort | |
2635 | 1009 && getline_equal(fgetline, cookie, get_func_line) |
7 | 1010 && !func_has_abort(real_cookie)) |
1011 did_emsg = FALSE; | |
1012 | |
72 | 1013 if (cstack.cs_looplevel > 0) |
7 | 1014 { |
1015 ++current_line; | |
1016 | |
1017 /* | |
72 | 1018 * An ":endwhile", ":endfor" and ":continue" is handled here. |
1019 * If we were executing commands, jump back to the ":while" or | |
1020 * ":for". | |
1021 * If we were not executing commands, decrement cs_looplevel. | |
7 | 1022 */ |
72 | 1023 if (cstack.cs_lflags & (CSL_HAD_CONT | CSL_HAD_ENDLOOP)) |
1024 { | |
1025 cstack.cs_lflags &= ~(CSL_HAD_CONT | CSL_HAD_ENDLOOP); | |
1026 | |
1027 /* Jump back to the matching ":while" or ":for". Be careful | |
1028 * not to use a cs_line[] from an entry that isn't a ":while" | |
1029 * or ":for": It would make "current_line" invalid and can | |
1030 * cause a crash. */ | |
7 | 1031 if (!did_emsg && !got_int && !did_throw |
1032 && cstack.cs_idx >= 0 | |
72 | 1033 && (cstack.cs_flags[cstack.cs_idx] |
1034 & (CSF_WHILE | CSF_FOR)) | |
7 | 1035 && cstack.cs_line[cstack.cs_idx] >= 0 |
1036 && (cstack.cs_flags[cstack.cs_idx] & CSF_ACTIVE)) | |
1037 { | |
1038 current_line = cstack.cs_line[cstack.cs_idx]; | |
72 | 1039 /* remember we jumped there */ |
1040 cstack.cs_lflags |= CSL_HAD_LOOP; | |
7 | 1041 line_breakcheck(); /* check if CTRL-C typed */ |
1042 | |
72 | 1043 /* Check for the next breakpoint at or after the ":while" |
1044 * or ":for". */ | |
7 | 1045 if (breakpoint != NULL) |
1046 { | |
1047 *breakpoint = dbg_find_breakpoint( | |
2635 | 1048 getline_equal(fgetline, cookie, getsourceline), |
7 | 1049 fname, |
1050 ((wcmd_T *)lines_ga.ga_data)[current_line].lnum-1); | |
1051 *dbg_tick = debug_tick; | |
1052 } | |
1053 } | |
72 | 1054 else |
7 | 1055 { |
72 | 1056 /* can only get here with ":endwhile" or ":endfor" */ |
7 | 1057 if (cstack.cs_idx >= 0) |
77 | 1058 rewind_conditionals(&cstack, cstack.cs_idx - 1, |
1059 CSF_WHILE | CSF_FOR, &cstack.cs_looplevel); | |
7 | 1060 } |
1061 } | |
1062 | |
1063 /* | |
72 | 1064 * For a ":while" or ":for" we need to remember the line number. |
7 | 1065 */ |
72 | 1066 else if (cstack.cs_lflags & CSL_HAD_LOOP) |
1067 { | |
1068 cstack.cs_lflags &= ~CSL_HAD_LOOP; | |
7 | 1069 cstack.cs_line[cstack.cs_idx] = current_line - 1; |
1070 } | |
1071 } | |
1072 | |
13262
69278c25429d
patch 8.0.1505: debugger can't break on a condition
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
1073 /* 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
|
1074 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
|
1075 { |
69278c25429d
patch 8.0.1505: debugger can't break on a condition
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
1076 *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
|
1077 *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
|
1078 } |
69278c25429d
patch 8.0.1505: debugger can't break on a condition
Christian Brabandt <cb@256bit.org>
parents:
13244
diff
changeset
|
1079 |
7 | 1080 /* |
1081 * When not inside any ":while" loop, clear remembered lines. | |
1082 */ | |
72 | 1083 if (cstack.cs_looplevel == 0) |
7 | 1084 { |
1085 if (lines_ga.ga_len > 0) | |
1086 { | |
1087 sourcing_lnum = | |
1088 ((wcmd_T *)lines_ga.ga_data)[lines_ga.ga_len - 1].lnum; | |
1089 free_cmdlines(&lines_ga); | |
1090 } | |
1091 current_line = 0; | |
1092 } | |
1093 | |
1094 /* | |
72 | 1095 * A ":finally" makes did_emsg, got_int, and did_throw pending for |
1096 * being restored at the ":endtry". Reset them here and set the | |
1097 * ACTIVE and FINALLY flags, so that the finally clause gets executed. | |
1098 * This includes the case where a missing ":endif", ":endwhile" or | |
1099 * ":endfor" was detected by the ":finally" itself. | |
7 | 1100 */ |
72 | 1101 if (cstack.cs_lflags & CSL_HAD_FINA) |
1102 { | |
1103 cstack.cs_lflags &= ~CSL_HAD_FINA; | |
1104 report_make_pending(cstack.cs_pending[cstack.cs_idx] | |
1105 & (CSTP_ERROR | CSTP_INTERRUPT | CSTP_THROW), | |
7 | 1106 did_throw ? (void *)current_exception : NULL); |
1107 did_emsg = got_int = did_throw = FALSE; | |
1108 cstack.cs_flags[cstack.cs_idx] |= CSF_ACTIVE | CSF_FINALLY; | |
1109 } | |
1110 | |
1111 /* Update global "trylevel" for recursive calls to do_cmdline() from | |
1112 * within this loop. */ | |
1113 trylevel = initial_trylevel + cstack.cs_trylevel; | |
1114 | |
1115 /* | |
1190 | 1116 * If the outermost try conditional (across function calls and sourced |
7 | 1117 * files) is aborted because of an error, an interrupt, or an uncaught |
1118 * exception, cancel everything. If it is left normally, reset | |
1119 * force_abort to get the non-EH compatible abortion behavior for | |
1120 * the rest of the script. | |
1121 */ | |
1122 if (trylevel == 0 && !did_emsg && !got_int && !did_throw) | |
1123 force_abort = FALSE; | |
1124 | |
1125 /* Convert an interrupt to an exception if appropriate. */ | |
1126 (void)do_intthrow(&cstack); | |
1127 #endif /* FEAT_EVAL */ | |
1128 | |
1129 } | |
1130 /* | |
1131 * Continue executing command lines when: | |
1132 * - no CTRL-C typed, no aborting error, no exception thrown or try | |
1133 * conditionals need to be checked for executing finally clauses or | |
1134 * catching an interrupt exception | |
1135 * - didn't get an error message or lines are not typed | |
72 | 1136 * - there is a command after '|', inside a :if, :while, :for or :try, or |
7 | 1137 * looping for ":source" command or function call. |
1138 */ | |
1139 while (!((got_int | |
1140 #ifdef FEAT_EVAL | |
1141 || (did_emsg && force_abort) || did_throw | |
1142 #endif | |
1143 ) | |
1144 #ifdef FEAT_EVAL | |
1145 && cstack.cs_trylevel == 0 | |
1146 #endif | |
1147 ) | |
3757 | 1148 && !(did_emsg |
1149 #ifdef FEAT_EVAL | |
1150 /* Keep going when inside try/catch, so that the error can be | |
4352 | 1151 * deal with, except when it is a syntax error, it may cause |
3757 | 1152 * the :endtry to be missed. */ |
1153 && (cstack.cs_trylevel == 0 || did_emsg_syntax) | |
1154 #endif | |
1155 && used_getline | |
2635 | 1156 && (getline_equal(fgetline, cookie, getexmodeline) |
1157 || getline_equal(fgetline, cookie, getexline))) | |
7 | 1158 && (next_cmdline != NULL |
1159 #ifdef FEAT_EVAL | |
1160 || cstack.cs_idx >= 0 | |
1161 #endif | |
1162 || (flags & DOCMD_REPEAT))); | |
1163 | |
1164 vim_free(cmdline_copy); | |
3757 | 1165 did_emsg_syntax = FALSE; |
7 | 1166 #ifdef FEAT_EVAL |
1167 free_cmdlines(&lines_ga); | |
1168 ga_clear(&lines_ga); | |
1169 | |
1170 if (cstack.cs_idx >= 0) | |
1171 { | |
1172 /* | |
1173 * If a sourced file or executed function ran to its end, report the | |
1174 * unclosed conditional. | |
1175 */ | |
1176 if (!got_int && !did_throw | |
2635 | 1177 && ((getline_equal(fgetline, cookie, getsourceline) |
1178 && !source_finished(fgetline, cookie)) | |
1179 || (getline_equal(fgetline, cookie, get_func_line) | |
7 | 1180 && !func_has_ended(real_cookie)))) |
1181 { | |
1182 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
|
1183 emsg(_(e_endtry)); |
7 | 1184 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
|
1185 emsg(_(e_endwhile)); |
72 | 1186 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
|
1187 emsg(_(e_endfor)); |
7 | 1188 else |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
1189 emsg(_(e_endif)); |
7 | 1190 } |
1191 | |
1192 /* | |
1193 * Reset "trylevel" in case of a ":finish" or ":return" or a missing | |
1194 * ":endtry" in a sourced file or executed function. If the try | |
1195 * conditional is in its finally clause, ignore anything pending. | |
1196 * If it is in a catch clause, finish the caught exception. | |
77 | 1197 * Also cleanup any "cs_forinfo" structures. |
7 | 1198 */ |
1199 do | |
77 | 1200 { |
1201 int idx = cleanup_conditionals(&cstack, 0, TRUE); | |
1202 | |
111 | 1203 if (idx >= 0) |
1204 --idx; /* remove try block not in its finally clause */ | |
77 | 1205 rewind_conditionals(&cstack, idx, CSF_WHILE | CSF_FOR, |
1206 &cstack.cs_looplevel); | |
1207 } | |
1208 while (cstack.cs_idx >= 0); | |
7 | 1209 trylevel = initial_trylevel; |
1210 } | |
1211 | |
72 | 1212 /* If a missing ":endtry", ":endwhile", ":endfor", or ":endif" or a memory |
1213 * lack was reported above and the error message is to be converted to an | |
7 | 1214 * exception, do this now after rewinding the cstack. */ |
2635 | 1215 do_errthrow(&cstack, getline_equal(fgetline, cookie, get_func_line) |
7 | 1216 ? (char_u *)"endfunction" : (char_u *)NULL); |
1217 | |
1218 if (trylevel == 0) | |
1219 { | |
1220 /* | |
1221 * When an exception is being thrown out of the outermost try | |
1222 * conditional, discard the uncaught exception, disable the conversion | |
1223 * of interrupts or errors to exceptions, and ensure that no more | |
1224 * commands are executed. | |
1225 */ | |
1226 if (did_throw) | |
1227 { | |
1228 void *p = NULL; | |
1229 char_u *saved_sourcing_name; | |
1230 int saved_sourcing_lnum; | |
1231 struct msglist *messages = NULL, *next; | |
1232 | |
1233 /* | |
1234 * If the uncaught exception is a user exception, report it as an | |
1235 * error. If it is an error exception, display the saved error | |
1236 * message now. For an interrupt exception, do nothing; the | |
1237 * interrupt message is given elsewhere. | |
1238 */ | |
1239 switch (current_exception->type) | |
1240 { | |
1241 case ET_USER: | |
272 | 1242 vim_snprintf((char *)IObuff, IOSIZE, |
1243 _("E605: Exception not caught: %s"), | |
7 | 1244 current_exception->value); |
1245 p = vim_strsave(IObuff); | |
1246 break; | |
1247 case ET_ERROR: | |
1248 messages = current_exception->messages; | |
1249 current_exception->messages = NULL; | |
1250 break; | |
1251 case ET_INTERRUPT: | |
1252 break; | |
1253 } | |
1254 | |
1255 saved_sourcing_name = sourcing_name; | |
1256 saved_sourcing_lnum = sourcing_lnum; | |
1257 sourcing_name = current_exception->throw_name; | |
1258 sourcing_lnum = current_exception->throw_lnum; | |
1259 current_exception->throw_name = NULL; | |
1260 | |
1261 discard_current_exception(); /* uses IObuff if 'verbose' */ | |
1262 suppress_errthrow = TRUE; | |
1263 force_abort = TRUE; | |
1264 | |
1265 if (messages != NULL) | |
1266 { | |
1267 do | |
1268 { | |
1269 next = messages->next; | |
1270 emsg(messages->msg); | |
1271 vim_free(messages->msg); | |
1272 vim_free(messages); | |
1273 messages = next; | |
1274 } | |
1275 while (messages != NULL); | |
1276 } | |
1277 else if (p != NULL) | |
1278 { | |
15490
98c35d312987
patch 8.1.0753: printf format not checked for semsg()
Bram Moolenaar <Bram@vim.org>
parents:
15488
diff
changeset
|
1279 emsg(p); |
7 | 1280 vim_free(p); |
1281 } | |
1282 vim_free(sourcing_name); | |
1283 sourcing_name = saved_sourcing_name; | |
1284 sourcing_lnum = saved_sourcing_lnum; | |
1285 } | |
1286 | |
1287 /* | |
1288 * On an interrupt or an aborting error not converted to an exception, | |
1289 * disable the conversion of errors to exceptions. (Interrupts are not | |
1290 * converted any more, here.) This enables also the interrupt message | |
1291 * when force_abort is set and did_emsg unset in case of an interrupt | |
1292 * from a finally clause after an error. | |
1293 */ | |
1294 else if (got_int || (did_emsg && force_abort)) | |
1295 suppress_errthrow = TRUE; | |
1296 } | |
1297 | |
1298 /* | |
1299 * The current cstack will be freed when do_cmdline() returns. An uncaught | |
1300 * exception will have to be rethrown in the previous cstack. If a function | |
1301 * has just returned or a script file was just finished and the previous | |
1302 * cstack belongs to the same function or, respectively, script file, it | |
1303 * will have to be checked for finally clauses to be executed due to the | |
1304 * ":return" or ":finish". This is done in do_one_cmd(). | |
1305 */ | |
1306 if (did_throw) | |
1307 need_rethrow = TRUE; | |
2635 | 1308 if ((getline_equal(fgetline, cookie, getsourceline) |
7 | 1309 && ex_nesting_level > source_level(real_cookie)) |
2635 | 1310 || (getline_equal(fgetline, cookie, get_func_line) |
7 | 1311 && ex_nesting_level > func_level(real_cookie) + 1)) |
1312 { | |
1313 if (!did_throw) | |
1314 check_cstack = TRUE; | |
1315 } | |
1316 else | |
1317 { | |
1318 /* When leaving a function, reduce nesting level. */ | |
2635 | 1319 if (getline_equal(fgetline, cookie, get_func_line)) |
7 | 1320 --ex_nesting_level; |
1321 /* | |
1322 * Go to debug mode when returning from a function in which we are | |
1323 * single-stepping. | |
1324 */ | |
2635 | 1325 if ((getline_equal(fgetline, cookie, getsourceline) |
1326 || getline_equal(fgetline, cookie, get_func_line)) | |
7 | 1327 && ex_nesting_level + 1 <= debug_break_level) |
2635 | 1328 do_debug(getline_equal(fgetline, cookie, getsourceline) |
7 | 1329 ? (char_u *)_("End of sourced file") |
1330 : (char_u *)_("End of function")); | |
1331 } | |
1332 | |
1333 /* | |
1334 * Restore the exception environment (done after returning from the | |
1335 * debugger). | |
1336 */ | |
1337 if (flags & DOCMD_EXCRESET) | |
8 | 1338 restore_dbg_stuff(&debug_saved); |
7 | 1339 |
1340 msg_list = saved_msg_list; | |
1341 #endif /* FEAT_EVAL */ | |
1342 | |
1343 /* | |
1344 * If there was too much output to fit on the command line, ask the user to | |
1345 * hit return before redrawing the screen. With the ":global" command we do | |
1346 * this only once after the command is finished. | |
1347 */ | |
1348 if (did_inc) | |
1349 { | |
1350 --RedrawingDisabled; | |
1351 --no_wait_return; | |
1352 msg_scroll = FALSE; | |
1353 | |
1354 /* | |
1355 * When just finished an ":if"-":else" which was typed, no need to | |
1356 * wait for hit-return. Also for an error situation. | |
1357 */ | |
1358 if (retval == FAIL | |
1359 #ifdef FEAT_EVAL | |
1360 || (did_endif && KeyTyped && !did_emsg) | |
1361 #endif | |
1362 ) | |
1363 { | |
1364 need_wait_return = FALSE; | |
1365 msg_didany = FALSE; /* don't wait when restarting edit */ | |
1366 } | |
1367 else if (need_wait_return) | |
1368 { | |
1369 /* | |
1370 * The msg_start() above clears msg_didout. The wait_return we do | |
1371 * here should not overwrite the command that may be shown before | |
1372 * doing that. | |
1373 */ | |
1374 msg_didout |= msg_didout_before_start; | |
1375 wait_return(FALSE); | |
1376 } | |
1377 } | |
1378 | |
3976 | 1379 #ifdef FEAT_EVAL |
1380 did_endif = FALSE; /* in case do_cmdline used recursively */ | |
1381 #else | |
7 | 1382 /* |
1383 * Reset if_level, in case a sourced script file contains more ":if" than | |
1384 * ":endif" (could be ":if x | foo | endif"). | |
1385 */ | |
1386 if_level = 0; | |
3972 | 1387 #endif |
3963 | 1388 |
7 | 1389 --call_depth; |
1390 return retval; | |
1391 } | |
1392 | |
1393 #ifdef FEAT_EVAL | |
1394 /* | |
72 | 1395 * Obtain a line when inside a ":while" or ":for" loop. |
7 | 1396 */ |
1397 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
|
1398 get_loop_line(int c, void *cookie, int indent, int do_concat) |
7 | 1399 { |
72 | 1400 struct loop_cookie *cp = (struct loop_cookie *)cookie; |
7 | 1401 wcmd_T *wp; |
1402 char_u *line; | |
1403 | |
1404 if (cp->current_line + 1 >= cp->lines_gap->ga_len) | |
1405 { | |
1406 if (cp->repeating) | |
72 | 1407 return NULL; /* trying to read past ":endwhile"/":endfor" */ |
1408 | |
1409 /* First time inside the ":while"/":for": get line normally. */ | |
7 | 1410 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
|
1411 line = getcmdline(c, 0L, indent, do_concat); |
7 | 1412 else |
17178
40c4cb095d53
patch 8.1.1588: in :let-heredoc line continuation is recognized
Bram Moolenaar <Bram@vim.org>
parents:
17111
diff
changeset
|
1413 line = cp->getline(c, cp->cookie, indent, do_concat); |
857 | 1414 if (line != NULL && store_loop_line(cp->lines_gap, line) == OK) |
7 | 1415 ++cp->current_line; |
1416 | |
1417 return line; | |
1418 } | |
1419 | |
1420 KeyTyped = FALSE; | |
1421 ++cp->current_line; | |
1422 wp = (wcmd_T *)(cp->lines_gap->ga_data) + cp->current_line; | |
1423 sourcing_lnum = wp->lnum; | |
1424 return vim_strsave(wp->line); | |
1425 } | |
1426 | |
1427 /* | |
1428 * Store a line in "gap" so that a ":while" loop can execute it again. | |
1429 */ | |
1430 static int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
1431 store_loop_line(garray_T *gap, char_u *line) |
7 | 1432 { |
1433 if (ga_grow(gap, 1) == FAIL) | |
1434 return FAIL; | |
1435 ((wcmd_T *)(gap->ga_data))[gap->ga_len].line = vim_strsave(line); | |
1436 ((wcmd_T *)(gap->ga_data))[gap->ga_len].lnum = sourcing_lnum; | |
1437 ++gap->ga_len; | |
1438 return OK; | |
1439 } | |
1440 | |
1441 /* | |
72 | 1442 * Free the lines stored for a ":while" or ":for" loop. |
7 | 1443 */ |
1444 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
1445 free_cmdlines(garray_T *gap) |
7 | 1446 { |
1447 while (gap->ga_len > 0) | |
1448 { | |
1449 vim_free(((wcmd_T *)(gap->ga_data))[gap->ga_len - 1].line); | |
1450 --gap->ga_len; | |
1451 } | |
1452 } | |
1453 #endif | |
1454 | |
1455 /* | |
944 | 1456 * If "fgetline" is get_loop_line(), return TRUE if the getline it uses equals |
1457 * "func". * Otherwise return TRUE when "fgetline" equals "func". | |
7 | 1458 */ |
1459 int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
1460 getline_equal( |
17178
40c4cb095d53
patch 8.1.1588: in :let-heredoc line continuation is recognized
Bram Moolenaar <Bram@vim.org>
parents:
17111
diff
changeset
|
1461 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
|
1462 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
|
1463 char_u *(*func)(int, void *, int, int)) |
7 | 1464 { |
1465 #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
|
1466 char_u *(*gp)(int, void *, int, int); |
72 | 1467 struct loop_cookie *cp; |
1468 | |
944 | 1469 /* When "fgetline" is "get_loop_line()" use the "cookie" to find the |
1190 | 1470 * function that's originally used to obtain the lines. This may be |
1471 * nested several levels. */ | |
944 | 1472 gp = fgetline; |
72 | 1473 cp = (struct loop_cookie *)cookie; |
1474 while (gp == get_loop_line) | |
7 | 1475 { |
1476 gp = cp->getline; | |
1477 cp = cp->cookie; | |
1478 } | |
1479 return gp == func; | |
1480 #else | |
944 | 1481 return fgetline == func; |
7 | 1482 #endif |
1483 } | |
1484 | |
1485 /* | |
944 | 1486 * If "fgetline" is get_loop_line(), return the cookie used by the original |
7 | 1487 * getline function. Otherwise return "cookie". |
1488 */ | |
1489 void * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
1490 getline_cookie( |
17178
40c4cb095d53
patch 8.1.1588: in :let-heredoc line continuation is recognized
Bram Moolenaar <Bram@vim.org>
parents:
17111
diff
changeset
|
1491 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
|
1492 void *cookie) /* argument for fgetline() */ |
7 | 1493 { |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
1494 #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
|
1495 char_u *(*gp)(int, void *, int, int); |
72 | 1496 struct loop_cookie *cp; |
1497 | |
944 | 1498 /* When "fgetline" is "get_loop_line()" use the "cookie" to find the |
1190 | 1499 * cookie that's originally used to obtain the lines. This may be nested |
7 | 1500 * several levels. */ |
944 | 1501 gp = fgetline; |
72 | 1502 cp = (struct loop_cookie *)cookie; |
1503 while (gp == get_loop_line) | |
7 | 1504 { |
1505 gp = cp->getline; | |
1506 cp = cp->cookie; | |
1507 } | |
1508 return cp; | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
1509 #else |
7 | 1510 return cookie; |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
1511 #endif |
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
1512 } |
7 | 1513 |
6398 | 1514 |
1515 /* | |
1516 * Helper function to apply an offset for buffer commands, i.e. ":bdelete", | |
1517 * ":bwipeout", etc. | |
1518 * Returns the buffer number. | |
1519 */ | |
1520 static int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
1521 compute_buffer_local_count(int addr_type, int lnum, int offset) |
6398 | 1522 { |
1523 buf_T *buf; | |
6417 | 1524 buf_T *nextbuf; |
6398 | 1525 int count = offset; |
1526 | |
1527 buf = firstbuf; | |
1528 while (buf->b_next != NULL && buf->b_fnum < lnum) | |
1529 buf = buf->b_next; | |
1530 while (count != 0) | |
1531 { | |
6417 | 1532 count += (offset < 0) ? 1 : -1; |
1533 nextbuf = (offset < 0) ? buf->b_prev : buf->b_next; | |
1534 if (nextbuf == NULL) | |
6398 | 1535 break; |
6417 | 1536 buf = nextbuf; |
6398 | 1537 if (addr_type == ADDR_LOADED_BUFFERS) |
1538 /* skip over unloaded buffers */ | |
6417 | 1539 while (buf->b_ml.ml_mfp == NULL) |
1540 { | |
1541 nextbuf = (offset < 0) ? buf->b_prev : buf->b_next; | |
1542 if (nextbuf == NULL) | |
1543 break; | |
1544 buf = nextbuf; | |
1545 } | |
1546 } | |
1547 /* we might have gone too far, last buffer is not loadedd */ | |
1548 if (addr_type == ADDR_LOADED_BUFFERS) | |
1549 while (buf->b_ml.ml_mfp == NULL) | |
1550 { | |
1551 nextbuf = (offset >= 0) ? buf->b_prev : buf->b_next; | |
1552 if (nextbuf == NULL) | |
1553 break; | |
1554 buf = nextbuf; | |
1555 } | |
6398 | 1556 return buf->b_fnum; |
1557 } | |
1558 | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
1559 /* |
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
1560 * 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
|
1561 * 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
|
1562 */ |
6409 | 1563 static int |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
1564 current_win_nr(win_T *win) |
6409 | 1565 { |
1566 win_T *wp; | |
1567 int nr = 0; | |
1568 | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9538
diff
changeset
|
1569 FOR_ALL_WINDOWS(wp) |
6409 | 1570 { |
1571 ++nr; | |
1572 if (wp == win) | |
1573 break; | |
1574 } | |
1575 return nr; | |
1576 } | |
1577 | |
1578 static int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
1579 current_tab_nr(tabpage_T *tab) |
6409 | 1580 { |
1581 tabpage_T *tp; | |
1582 int nr = 0; | |
1583 | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9538
diff
changeset
|
1584 FOR_ALL_TABPAGES(tp) |
6409 | 1585 { |
1586 ++nr; | |
1587 if (tp == tab) | |
1588 break; | |
1589 } | |
1590 return nr; | |
1591 } | |
1592 | |
1593 # define CURRENT_WIN_NR current_win_nr(curwin) | |
1594 # define LAST_WIN_NR current_win_nr(NULL) | |
1595 # define CURRENT_TAB_NR current_tab_nr(curtab) | |
1596 # define LAST_TAB_NR current_tab_nr(NULL) | |
6398 | 1597 |
7 | 1598 /* |
1599 * Execute one Ex command. | |
1600 * | |
1601 * If 'sourcing' is TRUE, the command will be included in the error message. | |
1602 * | |
1603 * 1. skip comment lines and leading space | |
1604 * 2. handle command modifiers | |
6400 | 1605 * 3. find the command |
6398 | 1606 * 4. parse range |
6400 | 1607 * 5. Parse the command. |
6398 | 1608 * 6. parse arguments |
1609 * 7. switch on command name | |
7 | 1610 * |
944 | 1611 * Note: "fgetline" can be NULL. |
7 | 1612 * |
1613 * This function may be called recursively! | |
1614 */ | |
1615 #if (_MSC_VER == 1200) | |
1616 /* | |
8 | 1617 * Avoid optimisation bug in VC++ version 6.0 |
7 | 1618 */ |
128 | 1619 #pragma optimize( "g", off ) |
7 | 1620 #endif |
1621 static char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
1622 do_one_cmd( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
1623 char_u **cmdlinep, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
1624 int sourcing, |
7 | 1625 #ifdef FEAT_EVAL |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
1626 struct condstack *cstack, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
1627 #endif |
17178
40c4cb095d53
patch 8.1.1588: in :let-heredoc line continuation is recognized
Bram Moolenaar <Bram@vim.org>
parents:
17111
diff
changeset
|
1628 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
|
1629 void *cookie) /* argument for fgetline() */ |
7 | 1630 { |
1631 char_u *p; | |
1632 linenr_T lnum; | |
1633 long n; | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
1634 char *errormsg = NULL; /* error message */ |
9941
e975914c17e9
commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
9927
diff
changeset
|
1635 char_u *after_modifier = NULL; |
7 | 1636 exarg_T ea; /* Ex command arguments */ |
1926 | 1637 int save_msg_scroll = msg_scroll; |
7 | 1638 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
|
1639 int save_reg_executing = reg_executing; |
7 | 1640 int ni; /* set when Not Implemented */ |
6398 | 1641 char_u *cmd; |
7 | 1642 |
1643 vim_memset(&ea, 0, sizeof(ea)); | |
1644 ea.line1 = 1; | |
1645 ea.line2 = 1; | |
1646 #ifdef FEAT_EVAL | |
1647 ++ex_nesting_level; | |
1648 #endif | |
1649 | |
3997 | 1650 /* When the last file has not been edited :q has to be typed twice. */ |
7 | 1651 if (quitmore |
1652 #ifdef FEAT_EVAL | |
1653 /* avoid that a function call in 'statusline' does this */ | |
944 | 1654 && !getline_equal(fgetline, cookie, get_func_line) |
4133 | 1655 #endif |
3997 | 1656 /* 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
|
1657 && !getline_equal(fgetline, cookie, getnextac)) |
7 | 1658 --quitmore; |
1659 | |
1660 /* | |
1661 * Reset browse, confirm, etc.. They are restored when returning, for | |
1662 * recursive calls. | |
1663 */ | |
1664 save_cmdmod = cmdmod; | |
1665 | |
930 | 1666 /* "#!anything" is handled like a comment. */ |
1667 if ((*cmdlinep)[0] == '#' && (*cmdlinep)[1] == '!') | |
1668 goto doend; | |
1669 | |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
1670 /* |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
1671 * 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
|
1672 * 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
|
1673 */ |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
1674 // The "ea" structure holds the arguments that can be used. |
7 | 1675 ea.cmd = *cmdlinep; |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
1676 ea.cmdlinep = cmdlinep; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
1677 ea.getline = fgetline; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
1678 ea.cookie = cookie; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
1679 #ifdef FEAT_EVAL |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
1680 ea.cstack = cstack; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
1681 #endif |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
1682 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
|
1683 goto doend; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
1684 |
9941
e975914c17e9
commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
9927
diff
changeset
|
1685 after_modifier = ea.cmd; |
7 | 1686 |
1687 #ifdef FEAT_EVAL | |
1688 ea.skip = did_emsg || got_int || did_throw || (cstack->cs_idx >= 0 | |
1689 && !(cstack->cs_flags[cstack->cs_idx] & CSF_ACTIVE)); | |
1690 #else | |
1691 ea.skip = (if_level > 0); | |
1692 #endif | |
1693 | |
1694 /* | |
6398 | 1695 * 3. Skip over the range to find the command. Let "p" point to after it. |
1696 * | |
1697 * We need the command to know what kind of range it uses. | |
1698 */ | |
1699 cmd = ea.cmd; | |
1700 ea.cmd = skip_range(ea.cmd, NULL); | |
1701 if (*ea.cmd == '*' && vim_strchr(p_cpo, CPO_STAR) == NULL) | |
1702 ea.cmd = skipwhite(ea.cmd + 1); | |
1703 p = find_command(&ea, NULL); | |
1704 | |
14591
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1705 #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
|
1706 # 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
|
1707 // 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
|
1708 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
|
1709 && (!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
|
1710 && (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
|
1711 { |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1712 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
|
1713 |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1714 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
|
1715 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
|
1716 && (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
|
1717 && !(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
|
1718 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
|
1719 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
|
1720 && !(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
|
1721 & (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
|
1722 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
|
1723 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
|
1724 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
|
1725 && 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
|
1726 && 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
|
1727 && 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
|
1728 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
|
1729 |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1730 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
|
1731 { |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1732 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
|
1733 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
|
1734 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
|
1735 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
|
1736 } |
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 # endif |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1739 |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1740 /* 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
|
1741 * 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
|
1742 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
|
1743 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
|
1744 { |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1745 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
|
1746 (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
|
1747 } |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1748 #endif |
96878f6f5d4c
patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents:
14585
diff
changeset
|
1749 |
6398 | 1750 /* |
1751 * 4. parse a range specifier of the form: addr [,addr] [;addr] .. | |
7 | 1752 * |
1753 * where 'addr' is: | |
1754 * | |
1755 * % (entire file) | |
1756 * $ [+-NUM] | |
1757 * 'x [+-NUM] (where x denotes a currently defined mark) | |
1758 * . [+-NUM] | |
1759 * [+-NUM].. | |
1760 * NUM | |
1761 * | |
1762 * The ea.cmd pointer is updated to point to the first character following the | |
1763 * range spec. If an initial address is found, but no second, the upper bound | |
1764 * is equal to the lower. | |
1765 */ | |
1766 | |
16515
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
1767 // ea.addr_type for user commands is set by find_ucmd |
6489 | 1768 if (!IS_USER_CMDIDX(ea.cmdidx)) |
1769 { | |
1770 if (ea.cmdidx != CMD_SIZE) | |
1771 ea.addr_type = cmdnames[(int)ea.cmdidx].cmd_addr_type; | |
1772 else | |
1773 ea.addr_type = ADDR_LINES; | |
1774 | |
16515
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
1775 // :wincmd range depends on the argument. |
6506 | 1776 if (ea.cmdidx == CMD_wincmd && p != NULL) |
1777 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
|
1778 #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
|
1779 // :.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
|
1780 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
|
1781 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
|
1782 #endif |
6489 | 1783 } |
6398 | 1784 |
6489 | 1785 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
|
1786 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
|
1787 goto doend; |
7 | 1788 |
1789 /* | |
6398 | 1790 * 5. Parse the command. |
7 | 1791 */ |
1792 | |
1793 /* | |
1794 * Skip ':' and any white space | |
1795 */ | |
1796 ea.cmd = skipwhite(ea.cmd); | |
1797 while (*ea.cmd == ':') | |
1798 ea.cmd = skipwhite(ea.cmd + 1); | |
1799 | |
1800 /* | |
1801 * If we got a line, but no command, then go to the line. | |
1802 * If we find a '|' or '\n' we set ea.nextcmd. | |
1803 */ | |
6398 | 1804 if (*ea.cmd == NUL || *ea.cmd == '"' |
1805 || (ea.nextcmd = check_nextcmd(ea.cmd)) != NULL) | |
7 | 1806 { |
1807 /* | |
1808 * strange vi behaviour: | |
1809 * ":3" jumps to line 3 | |
1810 * ":3|..." prints line 3 | |
1811 * ":|" prints current line | |
1812 */ | |
1813 if (ea.skip) /* skip this if inside :if */ | |
1814 goto doend; | |
167 | 1815 if (*ea.cmd == '|' || (exmode_active && ea.line1 != ea.line2)) |
7 | 1816 { |
1817 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
|
1818 ea.argt = EX_RANGE+EX_COUNT+EX_TRLBAR; |
7 | 1819 if ((errormsg = invalid_range(&ea)) == NULL) |
1820 { | |
1821 correct_range(&ea); | |
1822 ex_print(&ea); | |
1823 } | |
1824 } | |
1825 else if (ea.addr_count != 0) | |
1826 { | |
631 | 1827 if (ea.line2 > curbuf->b_ml.ml_line_count) |
1828 { | |
1829 /* With '-' in 'cpoptions' a line number past the file is an | |
1830 * error, otherwise put it at the end of the file. */ | |
1831 if (vim_strchr(p_cpo, CPO_MINUS) != NULL) | |
1832 ea.line2 = -1; | |
1833 else | |
1834 ea.line2 = curbuf->b_ml.ml_line_count; | |
1835 } | |
1836 | |
1837 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
|
1838 errormsg = _(e_invrange); |
7 | 1839 else |
1840 { | |
1841 if (ea.line2 == 0) | |
1842 curwin->w_cursor.lnum = 1; | |
1843 else | |
1844 curwin->w_cursor.lnum = ea.line2; | |
1845 beginline(BL_SOL | BL_FIX); | |
1846 } | |
1847 } | |
1848 goto doend; | |
1849 } | |
1850 | |
6154 | 1851 /* If this looks like an undefined user command and there are CmdUndefined |
1852 * autocommands defined, trigger the matching autocommands. */ | |
1853 if (p != NULL && ea.cmdidx == CMD_SIZE && !ea.skip | |
1854 && ASCII_ISUPPER(*ea.cmd) | |
1855 && has_cmdundefined()) | |
1856 { | |
1857 int ret; | |
1858 | |
6156 | 1859 p = ea.cmd; |
6154 | 1860 while (ASCII_ISALNUM(*p)) |
1861 ++p; | |
6191 | 1862 p = vim_strnsave(ea.cmd, (int)(p - ea.cmd)); |
6154 | 1863 ret = apply_autocmds(EVENT_CMDUNDEFINED, p, p, TRUE, NULL); |
1864 vim_free(p); | |
6965 | 1865 /* If the autocommands did something and didn't cause an error, try |
1866 * finding the command again. */ | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
1867 p = (ret |
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
1868 #ifdef FEAT_EVAL |
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
1869 && !aborting() |
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
1870 #endif |
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
1871 ) ? find_command(&ea, NULL) : ea.cmd; |
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
1872 } |
6154 | 1873 |
7 | 1874 if (p == NULL) |
1875 { | |
1876 if (!ea.skip) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
1877 errormsg = _("E464: Ambiguous use of user-defined command"); |
7 | 1878 goto doend; |
1879 } | |
16411
5b5c5daf57de
patch 8.1.1210: support for user commands is spread out
Bram Moolenaar <Bram@vim.org>
parents:
16399
diff
changeset
|
1880 // 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
|
1881 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
|
1882 && !IS_USER_CMDIDX(ea.cmdidx)) |
7 | 1883 { |
1884 errormsg = uc_fun_cmd(); | |
1885 goto doend; | |
1886 } | |
16411
5b5c5daf57de
patch 8.1.1210: support for user commands is spread out
Bram Moolenaar <Bram@vim.org>
parents:
16399
diff
changeset
|
1887 |
7 | 1888 if (ea.cmdidx == CMD_SIZE) |
1889 { | |
1890 if (!ea.skip) | |
1891 { | |
1892 STRCPY(IObuff, _("E492: Not an editor command")); | |
1893 if (!sourcing) | |
9941
e975914c17e9
commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
9927
diff
changeset
|
1894 { |
e975914c17e9
commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
9927
diff
changeset
|
1895 /* 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
|
1896 * following command */ |
e975914c17e9
commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
9927
diff
changeset
|
1897 if (after_modifier != NULL) |
e975914c17e9
commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
9927
diff
changeset
|
1898 append_command(after_modifier); |
e975914c17e9
commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
9927
diff
changeset
|
1899 else |
e975914c17e9
commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
9927
diff
changeset
|
1900 append_command(*cmdlinep); |
e975914c17e9
commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
9927
diff
changeset
|
1901 } |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
1902 errormsg = (char *)IObuff; |
3757 | 1903 did_emsg_syntax = TRUE; |
7 | 1904 } |
1905 goto doend; | |
1906 } | |
1907 | |
6305 | 1908 ni = (!IS_USER_CMDIDX(ea.cmdidx) |
1909 && (cmdnames[ea.cmdidx].cmd_func == ex_ni | |
1315 | 1910 #ifdef HAVE_EX_SCRIPT_NI |
1911 || cmdnames[ea.cmdidx].cmd_func == ex_script_ni | |
1912 #endif | |
1913 )); | |
7 | 1914 |
1915 #ifndef FEAT_EVAL | |
1916 /* | |
1917 * When the expression evaluation is disabled, recognize the ":if" and | |
1918 * ":endif" commands and ignore everything in between it. | |
1919 */ | |
1920 if (ea.cmdidx == CMD_if) | |
1921 ++if_level; | |
1922 if (if_level) | |
1923 { | |
1924 if (ea.cmdidx == CMD_endif) | |
1925 --if_level; | |
1926 goto doend; | |
1927 } | |
1928 | |
1929 #endif | |
1930 | |
1613 | 1931 /* forced commands */ |
1932 if (*p == '!' && ea.cmdidx != CMD_substitute | |
1933 && ea.cmdidx != CMD_smagic && ea.cmdidx != CMD_snomagic) | |
7 | 1934 { |
1935 ++p; | |
1936 ea.forceit = TRUE; | |
1937 } | |
1938 else | |
1939 ea.forceit = FALSE; | |
1940 | |
1941 /* | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
1942 * 6. Parse arguments. Then check for errors. |
7 | 1943 */ |
6305 | 1944 if (!IS_USER_CMDIDX(ea.cmdidx)) |
835 | 1945 ea.argt = (long)cmdnames[(int)ea.cmdidx].cmd_argt; |
7 | 1946 |
1947 if (!ea.skip) | |
1948 { | |
1949 #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
|
1950 if (sandbox != 0 && !(ea.argt & EX_SBOXOK)) |
7 | 1951 { |
15748
93b78c4a7cd5
patch 8.1.0881: can execute shell commands in rvim through interfaces
Bram Moolenaar <Bram@vim.org>
parents:
15713
diff
changeset
|
1952 // 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
|
1953 errormsg = _(e_sandbox); |
7 | 1954 goto doend; |
1955 } | |
1956 #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
|
1957 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
|
1958 { |
93b78c4a7cd5
patch 8.1.0881: can execute shell commands in rvim through interfaces
Bram Moolenaar <Bram@vim.org>
parents:
15713
diff
changeset
|
1959 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
|
1960 goto doend; |
93b78c4a7cd5
patch 8.1.0881: can execute shell commands in rvim through interfaces
Bram Moolenaar <Bram@vim.org>
parents:
15713
diff
changeset
|
1961 } |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
1962 if (!curbuf->b_p_ma && (ea.argt & EX_MODIFY)) |
7 | 1963 { |
1964 /* 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
|
1965 errormsg = _(e_modifiable); |
7 | 1966 goto doend; |
1967 } | |
631 | 1968 |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
1969 if (text_locked() && !(ea.argt & EX_CMDWIN) |
6305 | 1970 && !IS_USER_CMDIDX(ea.cmdidx)) |
7 | 1971 { |
631 | 1972 /* 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
|
1973 errormsg = _(get_text_locked_msg()); |
7 | 1974 goto doend; |
1975 } | |
14648
c3222a7342ab
patch 8.1.0337: :file fails in quickfix command
Christian Brabandt <cb@256bit.org>
parents:
14640
diff
changeset
|
1976 |
822 | 1977 /* 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
|
1978 * 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
|
1979 * 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
|
1980 * 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
|
1981 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
|
1982 && ea.cmdidx != CMD_checktime |
822 | 1983 && ea.cmdidx != CMD_edit |
14648
c3222a7342ab
patch 8.1.0337: :file fails in quickfix command
Christian Brabandt <cb@256bit.org>
parents:
14640
diff
changeset
|
1984 && ea.cmdidx != CMD_file |
6305 | 1985 && !IS_USER_CMDIDX(ea.cmdidx) |
819 | 1986 && curbuf_locked()) |
1987 goto doend; | |
7 | 1988 |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
1989 if (!ni && !(ea.argt & EX_RANGE) && ea.addr_count > 0) |
7 | 1990 { |
1991 /* no range allowed */ | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
1992 errormsg = _(e_norange); |
7 | 1993 goto doend; |
1994 } | |
1995 } | |
1996 | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
1997 if (!ni && !(ea.argt & EX_BANG) && ea.forceit) // no <!> allowed |
7 | 1998 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
1999 errormsg = _(e_nobang); |
7 | 2000 goto doend; |
2001 } | |
2002 | |
2003 /* | |
2004 * Don't complain about the range if it is not used | |
2005 * (could happen if line_count is accidentally set to 0). | |
2006 */ | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2007 if (!ea.skip && !ni && (ea.argt & EX_RANGE)) |
7 | 2008 { |
2009 /* | |
2010 * If the range is backwards, ask for confirmation and, if given, swap | |
2011 * ea.line1 & ea.line2 so it's forwards again. | |
2012 * When global command is busy, don't ask, will fail below. | |
2013 */ | |
2014 if (!global_busy && ea.line1 > ea.line2) | |
2015 { | |
557 | 2016 if (msg_silent == 0) |
2017 { | |
2018 if (sourcing || exmode_active) | |
2019 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2020 errormsg = _("E493: Backwards range given"); |
557 | 2021 goto doend; |
2022 } | |
7 | 2023 if (ask_yesno((char_u *) |
2024 _("Backwards range given, OK to swap"), FALSE) != 'y') | |
557 | 2025 goto doend; |
7 | 2026 } |
2027 lnum = ea.line1; | |
2028 ea.line1 = ea.line2; | |
2029 ea.line2 = lnum; | |
2030 } | |
2031 if ((errormsg = invalid_range(&ea)) != NULL) | |
2032 goto doend; | |
2033 } | |
2034 | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
2035 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
|
2036 // default is 1, not cursor |
7 | 2037 ea.line2 = 1; |
2038 | |
2039 correct_range(&ea); | |
2040 | |
2041 #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
|
2042 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
|
2043 && ea.addr_type == ADDR_LINES) |
7 | 2044 { |
2045 /* Put the first line at the start of a closed fold, put the last line | |
2046 * at the end of a closed fold. */ | |
2047 (void)hasFolding(ea.line1, &ea.line1, NULL); | |
2048 (void)hasFolding(ea.line2, NULL, &ea.line2); | |
2049 } | |
2050 #endif | |
2051 | |
2052 #ifdef FEAT_QUICKFIX | |
2053 /* | |
41 | 2054 * For the ":make" and ":grep" commands we insert the 'makeprg'/'grepprg' |
7 | 2055 * option here, so things like % get expanded. |
2056 */ | |
344 | 2057 p = replace_makeprg(&ea, p, cmdlinep); |
2058 if (p == NULL) | |
2059 goto doend; | |
7 | 2060 #endif |
2061 | |
2062 /* | |
2063 * Skip to start of argument. | |
2064 * Don't do this for the ":!" command, because ":!! -l" needs the space. | |
2065 */ | |
2066 if (ea.cmdidx == CMD_bang) | |
2067 ea.arg = p; | |
2068 else | |
2069 ea.arg = skipwhite(p); | |
2070 | |
14648
c3222a7342ab
patch 8.1.0337: :file fails in quickfix command
Christian Brabandt <cb@256bit.org>
parents:
14640
diff
changeset
|
2071 // ":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
|
2072 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
|
2073 goto doend; |
c3222a7342ab
patch 8.1.0337: :file fails in quickfix command
Christian Brabandt <cb@256bit.org>
parents:
14640
diff
changeset
|
2074 |
7 | 2075 /* |
2076 * Check for "++opt=val" argument. | |
2077 * Must be first, allow ":w ++enc=utf8 !cmd" | |
2078 */ | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2079 if (ea.argt & EX_ARGOPT) |
7 | 2080 while (ea.arg[0] == '+' && ea.arg[1] == '+') |
2081 if (getargopt(&ea) == FAIL && !ni) | |
2082 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2083 errormsg = _(e_invarg); |
7 | 2084 goto doend; |
2085 } | |
2086 | |
2087 if (ea.cmdidx == CMD_write || ea.cmdidx == CMD_update) | |
2088 { | |
2089 if (*ea.arg == '>') /* append */ | |
2090 { | |
2091 if (*++ea.arg != '>') /* typed wrong */ | |
2092 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2093 errormsg = _("E494: Use w or w>>"); |
7 | 2094 goto doend; |
2095 } | |
2096 ea.arg = skipwhite(ea.arg + 1); | |
2097 ea.append = TRUE; | |
2098 } | |
2099 else if (*ea.arg == '!' && ea.cmdidx == CMD_write) /* :w !filter */ | |
2100 { | |
2101 ++ea.arg; | |
2102 ea.usefilter = TRUE; | |
2103 } | |
2104 } | |
2105 | |
2106 if (ea.cmdidx == CMD_read) | |
2107 { | |
2108 if (ea.forceit) | |
2109 { | |
2110 ea.usefilter = TRUE; /* :r! filter if ea.forceit */ | |
2111 ea.forceit = FALSE; | |
2112 } | |
2113 else if (*ea.arg == '!') /* :r !filter */ | |
2114 { | |
2115 ++ea.arg; | |
2116 ea.usefilter = TRUE; | |
2117 } | |
2118 } | |
2119 | |
2120 if (ea.cmdidx == CMD_lshift || ea.cmdidx == CMD_rshift) | |
2121 { | |
2122 ea.amount = 1; | |
2123 while (*ea.arg == *ea.cmd) /* count number of '>' or '<' */ | |
2124 { | |
2125 ++ea.arg; | |
2126 ++ea.amount; | |
2127 } | |
2128 ea.arg = skipwhite(ea.arg); | |
2129 } | |
2130 | |
2131 /* | |
2132 * Check for "+command" argument, before checking for next command. | |
2133 * Don't do this for ":read !cmd" and ":write !cmd". | |
2134 */ | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2135 if ((ea.argt & EX_CMDARG) && !ea.usefilter) |
7 | 2136 ea.do_ecmd_cmd = getargcmd(&ea.arg); |
2137 | |
2138 /* | |
2139 * Check for '|' to separate commands and '"' to start comments. | |
2140 * Don't do this for ":read !cmd" and ":write !cmd". | |
2141 */ | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2142 if ((ea.argt & EX_TRLBAR) && !ea.usefilter) |
7 | 2143 separate_nextcmd(&ea); |
2144 | |
2145 /* | |
2146 * Check for <newline> to end a shell command. | |
167 | 2147 * Also do this for ":read !cmd", ":write !cmd" and ":global". |
2148 * Any others? | |
7 | 2149 */ |
167 | 2150 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
|
2151 || ea.cmdidx == CMD_terminal |
167 | 2152 || ea.cmdidx == CMD_global |
2153 || ea.cmdidx == CMD_vglobal | |
2154 || ea.usefilter) | |
7 | 2155 { |
2156 for (p = ea.arg; *p; ++p) | |
2157 { | |
2158 /* Remove one backslash before a newline, so that it's possible to | |
2159 * pass a newline to the shell and also a newline that is preceded | |
2160 * with a backslash. This makes it impossible to end a shell | |
2161 * command in a backslash, but that doesn't appear useful. | |
2162 * Halving the number of backslashes is incompatible with previous | |
2163 * versions. */ | |
2164 if (*p == '\\' && p[1] == '\n') | |
1619 | 2165 STRMOVE(p, p + 1); |
7 | 2166 else if (*p == '\n') |
2167 { | |
2168 ea.nextcmd = p + 1; | |
2169 *p = NUL; | |
2170 break; | |
2171 } | |
2172 } | |
2173 } | |
2174 | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2175 if ((ea.argt & EX_DFLALL) && ea.addr_count == 0) |
7 | 2176 { |
6424 | 2177 buf_T *buf; |
2178 | |
7 | 2179 ea.line1 = 1; |
6424 | 2180 switch (ea.addr_type) |
2181 { | |
2182 case ADDR_LINES: | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
2183 case ADDR_OTHER: |
6424 | 2184 ea.line2 = curbuf->b_ml.ml_line_count; |
2185 break; | |
2186 case ADDR_LOADED_BUFFERS: | |
2187 buf = firstbuf; | |
2188 while (buf->b_next != NULL && buf->b_ml.ml_mfp == NULL) | |
2189 buf = buf->b_next; | |
2190 ea.line1 = buf->b_fnum; | |
2191 buf = lastbuf; | |
2192 while (buf->b_prev != NULL && buf->b_ml.ml_mfp == NULL) | |
2193 buf = buf->b_prev; | |
2194 ea.line2 = buf->b_fnum; | |
2195 break; | |
2196 case ADDR_BUFFERS: | |
2197 ea.line1 = firstbuf->b_fnum; | |
2198 ea.line2 = lastbuf->b_fnum; | |
2199 break; | |
2200 case ADDR_WINDOWS: | |
2201 ea.line2 = LAST_WIN_NR; | |
2202 break; | |
2203 case ADDR_TABS: | |
2204 ea.line2 = LAST_TAB_NR; | |
2205 break; | |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
2206 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
|
2207 ea.line2 = 1; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
2208 break; |
6424 | 2209 case ADDR_ARGUMENTS: |
2210 if (ARGCOUNT == 0) | |
2211 ea.line1 = ea.line2 = 0; | |
2212 else | |
2213 ea.line2 = ARGCOUNT; | |
2214 break; | |
16515
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
2215 case ADDR_QUICKFIX_VALID: |
7105
f4456e686406
commit https://github.com/vim/vim/commit/e906c502079770ae0e0071c74cefb802689ff193
Christian Brabandt <cb@256bit.org>
parents:
7092
diff
changeset
|
2216 #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
|
2217 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
|
2218 if (ea.line2 == 0) |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
2219 ea.line2 = 1; |
16479
7dcf301d1432
patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents:
16475
diff
changeset
|
2220 #endif |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
2221 break; |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
2222 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
|
2223 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
|
2224 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
|
2225 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
|
2226 break; |
6424 | 2227 } |
7 | 2228 } |
2229 | |
2230 /* 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
|
2231 if ( (ea.argt & EX_REGSTR) |
7 | 2232 && *ea.arg != NUL |
6305 | 2233 /* Do not allow register = for user commands */ |
2234 && (!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
|
2235 && !((ea.argt & EX_COUNT) && VIM_ISDIGIT(*ea.arg))) |
7 | 2236 { |
2791 | 2237 #ifndef FEAT_CLIPBOARD |
2238 /* check these explicitly for a more specific error message */ | |
2239 if (*ea.arg == '*' || *ea.arg == '+') | |
2240 { | |
15474
79e3dcc5aa50
patch 8.1.0745: compiler warnings for signed/unsigned string
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
2241 errormsg = _(e_invalidreg); |
2791 | 2242 goto doend; |
2243 } | |
2244 #endif | |
6305 | 2245 if (valid_yank_reg(*ea.arg, (ea.cmdidx != CMD_put |
2246 && !IS_USER_CMDIDX(ea.cmdidx)))) | |
2791 | 2247 { |
2248 ea.regname = *ea.arg++; | |
7 | 2249 #ifdef FEAT_EVAL |
2791 | 2250 /* for '=' register: accept the rest of the line as an expression */ |
2251 if (ea.arg[-1] == '=' && ea.arg[0] != NUL) | |
2252 { | |
2253 set_expr_line(vim_strsave(ea.arg)); | |
2254 ea.arg += STRLEN(ea.arg); | |
2255 } | |
2256 #endif | |
2257 ea.arg = skipwhite(ea.arg); | |
2258 } | |
7 | 2259 } |
2260 | |
2261 /* | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2262 * Check for a count. When accepting a EX_BUFNAME, don't use "123foo" as a |
7 | 2263 * count, it's a buffer name. |
2264 */ | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2265 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
|
2266 && (!(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
|
2267 || VIM_ISWHITE(*p))) |
7 | 2268 { |
2269 n = getdigits(&ea.arg); | |
2270 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
|
2271 if (n <= 0 && !ni && (ea.argt & EX_ZEROR) == 0) |
7 | 2272 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2273 errormsg = _(e_zerocount); |
7 | 2274 goto doend; |
2275 } | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
2276 if (ea.addr_type != ADDR_LINES) // e.g. :buffer 2, :sleep 3 |
7 | 2277 { |
2278 ea.line2 = n; | |
2279 if (ea.addr_count == 0) | |
2280 ea.addr_count = 1; | |
2281 } | |
2282 else | |
2283 { | |
2284 ea.line1 = ea.line2; | |
2285 ea.line2 += n - 1; | |
2286 ++ea.addr_count; | |
2287 /* | |
2288 * Be vi compatible: no error message for out of range. | |
2289 */ | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
2290 if (ea.line2 > curbuf->b_ml.ml_line_count) |
7 | 2291 ea.line2 = curbuf->b_ml.ml_line_count; |
2292 } | |
2293 } | |
167 | 2294 |
2295 /* | |
2296 * Check for flags: 'l', 'p' and '#'. | |
2297 */ | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2298 if (ea.argt & EX_FLAGS) |
167 | 2299 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
|
2300 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
|
2301 && *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
|
2302 { |
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2303 // 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
|
2304 errormsg = _(e_trailing); |
7 | 2305 goto doend; |
2306 } | |
2307 | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2308 if (!ni && (ea.argt & EX_NEEDARG) && *ea.arg == NUL) |
7 | 2309 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2310 errormsg = _(e_argreq); |
7 | 2311 goto doend; |
2312 } | |
2313 | |
2314 #ifdef FEAT_EVAL | |
2315 /* | |
2316 * Skip the command when it's not going to be executed. | |
2317 * The commands like :if, :endif, etc. always need to be executed. | |
2318 * Also make an exception for commands that handle a trailing command | |
2319 * themselves. | |
2320 */ | |
2321 if (ea.skip) | |
2322 { | |
2323 switch (ea.cmdidx) | |
2324 { | |
2325 /* commands that need evaluation */ | |
2326 case CMD_while: | |
2327 case CMD_endwhile: | |
72 | 2328 case CMD_for: |
2329 case CMD_endfor: | |
7 | 2330 case CMD_if: |
2331 case CMD_elseif: | |
2332 case CMD_else: | |
2333 case CMD_endif: | |
2334 case CMD_try: | |
2335 case CMD_catch: | |
2336 case CMD_finally: | |
2337 case CMD_endtry: | |
2338 case CMD_function: | |
2339 break; | |
2340 | |
2341 /* 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
|
2342 * either have the EX_TRLBAR flag, appear in this list or appear in |
7 | 2343 * the list at ":help :bar". */ |
2344 case CMD_aboveleft: | |
2345 case CMD_and: | |
2346 case CMD_belowright: | |
2347 case CMD_botright: | |
2348 case CMD_browse: | |
2349 case CMD_call: | |
2350 case CMD_confirm: | |
2351 case CMD_delfunction: | |
2352 case CMD_djump: | |
2353 case CMD_dlist: | |
2354 case CMD_dsearch: | |
2355 case CMD_dsplit: | |
2356 case CMD_echo: | |
2357 case CMD_echoerr: | |
2358 case CMD_echomsg: | |
2359 case CMD_echon: | |
2360 case CMD_execute: | |
9941
e975914c17e9
commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
9927
diff
changeset
|
2361 case CMD_filter: |
7 | 2362 case CMD_help: |
2363 case CMD_hide: | |
2364 case CMD_ijump: | |
2365 case CMD_ilist: | |
2366 case CMD_isearch: | |
2367 case CMD_isplit: | |
22 | 2368 case CMD_keepalt: |
7 | 2369 case CMD_keepjumps: |
2370 case CMD_keepmarks: | |
5467 | 2371 case CMD_keeppatterns: |
7 | 2372 case CMD_leftabove: |
2373 case CMD_let: | |
2374 case CMD_lockmarks: | |
2320
966a5609669e
Added Lua interfae. (Luis Carvalho)
Bram Moolenaar <bram@vim.org>
parents:
2311
diff
changeset
|
2375 case CMD_lua: |
7 | 2376 case CMD_match: |
14 | 2377 case CMD_mzscheme: |
5737 | 2378 case CMD_noautocmd: |
2379 case CMD_noswapfile: | |
7 | 2380 case CMD_perl: |
2381 case CMD_psearch: | |
2382 case CMD_python: | |
2350
06feaf4fe36a
Rename some "python3" symbols to "py3", as the command name.
Bram Moolenaar <bram@vim.org>
parents:
2340
diff
changeset
|
2383 case CMD_py3: |
2366
7a57fe6a5157
Fix that :py3file was not working.
Bram Moolenaar <bram@vim.org>
parents:
2360
diff
changeset
|
2384 case CMD_python3: |
7 | 2385 case CMD_return: |
2386 case CMD_rightbelow: | |
2387 case CMD_ruby: | |
2388 case CMD_silent: | |
2389 case CMD_smagic: | |
2390 case CMD_snomagic: | |
2391 case CMD_substitute: | |
2392 case CMD_syntax: | |
690 | 2393 case CMD_tab: |
7 | 2394 case CMD_tcl: |
2395 case CMD_throw: | |
2396 case CMD_tilde: | |
2397 case CMD_topleft: | |
2398 case CMD_unlet: | |
2399 case CMD_verbose: | |
2400 case CMD_vertical: | |
2887 | 2401 case CMD_wincmd: |
7 | 2402 break; |
2403 | |
2404 default: goto doend; | |
2405 } | |
2406 } | |
2407 #endif | |
2408 | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2409 if (ea.argt & EX_XFILE) |
7 | 2410 { |
2411 if (expand_filename(&ea, cmdlinep, &errormsg) == FAIL) | |
2412 goto doend; | |
2413 } | |
2414 | |
2415 /* | |
2416 * Accept buffer name. Cannot be used at the same time with a buffer | |
2417 * number. Don't do this for a user command. | |
2418 */ | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2419 if ((ea.argt & EX_BUFNAME) && *ea.arg != NUL && ea.addr_count == 0 |
6305 | 2420 && !IS_USER_CMDIDX(ea.cmdidx)) |
7 | 2421 { |
2422 /* | |
2423 * :bdelete, :bwipeout and :bunload take several arguments, separated | |
2424 * by spaces: find next space (skipping over escaped characters). | |
2425 * The others take one argument: ignore trailing spaces. | |
2426 */ | |
2427 if (ea.cmdidx == CMD_bdelete || ea.cmdidx == CMD_bwipeout | |
2428 || ea.cmdidx == CMD_bunload) | |
2429 p = skiptowhite_esc(ea.arg); | |
2430 else | |
2431 { | |
2432 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
|
2433 while (p > ea.arg && VIM_ISWHITE(p[-1])) |
7 | 2434 --p; |
2435 } | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
2436 ea.line2 = buflist_findpat(ea.arg, p, (ea.argt & EX_BUFUNL) != 0, |
4236 | 2437 FALSE, FALSE); |
7 | 2438 if (ea.line2 < 0) /* failed */ |
2439 goto doend; | |
2440 ea.addr_count = 1; | |
2441 ea.arg = skipwhite(p); | |
2442 } | |
2443 | |
13288
530943a23d3f
patch 8.0.1518: error messages suppressed after ":silent! try"
Christian Brabandt <cb@256bit.org>
parents:
13268
diff
changeset
|
2444 /* 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
|
2445 * ":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
|
2446 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
|
2447 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2448 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
|
2449 if (emsg_silent < 0) |
530943a23d3f
patch 8.0.1518: error messages suppressed after ":silent! try"
Christian Brabandt <cb@256bit.org>
parents:
13268
diff
changeset
|
2450 emsg_silent = 0; |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2451 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
|
2452 } |
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 * 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
|
2456 */ |
7 | 2457 |
6305 | 2458 if (IS_USER_CMDIDX(ea.cmdidx)) |
7 | 2459 { |
2460 /* | |
2461 * Execute a user-defined command. | |
2462 */ | |
2463 do_ucmd(&ea); | |
2464 } | |
2465 else | |
2466 { | |
2467 /* | |
16411
5b5c5daf57de
patch 8.1.1210: support for user commands is spread out
Bram Moolenaar <Bram@vim.org>
parents:
16399
diff
changeset
|
2468 * Call the function to execute the builtin command. |
7 | 2469 */ |
2470 ea.errmsg = NULL; | |
2471 (cmdnames[ea.cmdidx].cmd_func)(&ea); | |
2472 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
|
2473 errormsg = _(ea.errmsg); |
7 | 2474 } |
2475 | |
2476 #ifdef FEAT_EVAL | |
2477 /* | |
2478 * If the command just executed called do_cmdline(), any throw or ":return" | |
2479 * or ":finish" encountered there must also check the cstack of the still | |
2480 * active do_cmdline() that called this do_one_cmd(). Rethrow an uncaught | |
2481 * exception, or reanimate a returned function or finished script file and | |
2482 * return or finish it again. | |
2483 */ | |
2484 if (need_rethrow) | |
2485 do_throw(cstack); | |
2486 else if (check_cstack) | |
2487 { | |
944 | 2488 if (source_finished(fgetline, cookie)) |
7 | 2489 do_finish(&ea, TRUE); |
944 | 2490 else if (getline_equal(fgetline, cookie, get_func_line) |
7 | 2491 && current_func_returned()) |
2492 do_return(&ea, TRUE, FALSE, NULL); | |
2493 } | |
2494 need_rethrow = check_cstack = FALSE; | |
2495 #endif | |
2496 | |
2497 doend: | |
2498 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
|
2499 { |
7 | 2500 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
|
2501 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
|
2502 } |
7 | 2503 |
2504 if (errormsg != NULL && *errormsg != NUL && !did_emsg) | |
2505 { | |
2506 if (sourcing) | |
2507 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2508 if (errormsg != (char *)IObuff) |
7 | 2509 { |
2510 STRCPY(IObuff, errormsg); | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2511 errormsg = (char *)IObuff; |
7 | 2512 } |
3097 | 2513 append_command(*cmdlinep); |
7 | 2514 } |
2515 emsg(errormsg); | |
2516 } | |
2517 #ifdef FEAT_EVAL | |
2518 do_errthrow(cstack, | |
6305 | 2519 (ea.cmdidx != CMD_SIZE && !IS_USER_CMDIDX(ea.cmdidx)) |
2520 ? cmdnames[(int)ea.cmdidx].cmd_name : (char_u *)NULL); | |
7 | 2521 #endif |
2522 | |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2523 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
|
2524 p_verbose = ea.verbose_save; |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
2525 |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2526 free_cmdmod(); |
7 | 2527 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
|
2528 reg_executing = save_reg_executing; |
7 | 2529 |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2530 if (ea.save_msg_silent != -1) |
7 | 2531 { |
2532 /* messages could be enabled for a serious error, need to check if the | |
2533 * 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
|
2534 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
|
2535 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 emsg_silent -= ea.did_esilent; |
7 | 2537 if (emsg_silent < 0) |
2538 emsg_silent = 0; | |
2539 /* Restore msg_scroll, it's set by file I/O commands, even when no | |
2540 * message is actually displayed. */ | |
2541 msg_scroll = save_msg_scroll; | |
1854 | 2542 |
2543 /* "silent reg" or "silent echo x" inside "redir" leaves msg_col | |
2544 * somewhere in the line. Put it back in the first column. */ | |
2545 if (redirecting()) | |
2546 msg_col = 0; | |
7 | 2547 } |
2548 | |
28 | 2549 #ifdef HAVE_SANDBOX |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2550 if (ea.did_sandbox) |
28 | 2551 --sandbox; |
2552 #endif | |
2553 | |
7 | 2554 if (ea.nextcmd && *ea.nextcmd == NUL) /* not really a next command */ |
2555 ea.nextcmd = NULL; | |
2556 | |
2557 #ifdef FEAT_EVAL | |
2558 --ex_nesting_level; | |
2559 #endif | |
2560 | |
2561 return ea.nextcmd; | |
2562 } | |
2563 #if (_MSC_VER == 1200) | |
128 | 2564 #pragma optimize( "", on ) |
7 | 2565 #endif |
2566 | |
2567 /* | |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2568 * 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
|
2569 * - update eap->cmd |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2570 * - store flags in "cmdmod". |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2571 * - 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
|
2572 * - 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
|
2573 * - 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
|
2574 * - 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
|
2575 * - 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
|
2576 * 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
|
2577 * "cmdmod". |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2578 * 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
|
2579 * 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
|
2580 */ |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2581 int |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2582 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
|
2583 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2584 char_u *p; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2585 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2586 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
|
2587 eap->verbose_save = -1; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2588 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
|
2589 |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2590 // 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
|
2591 for (;;) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2592 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2593 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
|
2594 ++eap->cmd; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2595 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2596 /* 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
|
2597 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
|
2598 && (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
|
2599 || 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
|
2600 && 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
|
2601 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2602 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
|
2603 if (!skip_only) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2604 ex_pressedreturn = TRUE; |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2605 } |
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 /* 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
|
2608 if (*eap->cmd == '"') |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2609 return FAIL; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2610 if (*eap->cmd == NUL) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2611 { |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2612 if (!skip_only) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2613 ex_pressedreturn = TRUE; |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2614 return FAIL; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2615 } |
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 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
|
2618 switch (*p) |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2619 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2620 /* 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
|
2621 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
|
2622 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2623 cmdmod.split |= WSP_ABOVE; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2624 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2625 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2626 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
|
2627 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2628 cmdmod.split |= WSP_BELOW; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2629 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2630 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2631 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
|
2632 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2633 #ifdef FEAT_BROWSE_CMD |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2634 cmdmod.browse = TRUE; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2635 #endif |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2636 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2637 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2638 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
|
2639 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2640 cmdmod.split |= WSP_BOT; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2641 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2642 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2643 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
|
2644 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2645 #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
|
2646 cmdmod.confirm = TRUE; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2647 #endif |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2648 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2649 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2650 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
|
2651 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2652 cmdmod.keepmarks = TRUE; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2653 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2654 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2655 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
|
2656 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2657 cmdmod.keepalt = TRUE; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2658 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2659 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2660 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
|
2661 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2662 cmdmod.keeppatterns = TRUE; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2663 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2664 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2665 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
|
2666 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2667 cmdmod.keepjumps = TRUE; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2668 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2669 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2670 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
|
2671 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2672 char_u *reg_pat; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2673 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2674 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
|
2675 || *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
|
2676 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2677 if (*p == '!') |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2678 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2679 cmdmod.filter_force = TRUE; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2680 p = skipwhite(p + 1); |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2681 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
|
2682 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2683 } |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2684 if (skip_only) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2685 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
|
2686 else |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2687 // 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
|
2688 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
|
2689 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
|
2690 break; |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2691 if (!skip_only) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2692 { |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2693 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
|
2694 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
|
2695 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
|
2696 break; |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2697 } |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2698 eap->cmd = p; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2699 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2700 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2701 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2702 /* ":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
|
2703 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
|
2704 || *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
|
2705 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2706 eap->cmd = p; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2707 cmdmod.hide = TRUE; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2708 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2709 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2710 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
|
2711 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2712 cmdmod.lockmarks = TRUE; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2713 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2714 } |
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 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
|
2717 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2718 cmdmod.split |= WSP_ABOVE; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2719 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2720 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2721 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
|
2722 { |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2723 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
|
2724 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2725 /* 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
|
2726 * existing option value later. */ |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2727 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
|
2728 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
|
2729 (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
|
2730 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2731 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2732 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2733 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
|
2734 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2735 cmdmod.noswapfile = TRUE; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2736 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2737 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2738 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
|
2739 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2740 cmdmod.split |= WSP_BELOW; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2741 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2742 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2743 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
|
2744 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2745 #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
|
2746 if (!skip_only) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2747 { |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2748 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
|
2749 ++sandbox; |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2750 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
|
2751 } |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2752 #endif |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2753 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2754 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2755 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
|
2756 break; |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2757 if (!skip_only) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2758 { |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2759 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
|
2760 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
|
2761 ++msg_silent; |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2762 } |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2763 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
|
2764 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2765 /* ":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
|
2766 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
|
2767 if (!skip_only) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2768 { |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2769 ++emsg_silent; |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2770 ++eap->did_esilent; |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2771 } |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2772 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2773 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2774 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2775 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
|
2776 { |
15263
ad065b8123e8
patch 8.1.0640: get E14 while typing command :tab with 'incsearch' set
Bram Moolenaar <Bram@vim.org>
parents:
15239
diff
changeset
|
2777 if (!skip_only) |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2778 { |
15263
ad065b8123e8
patch 8.1.0640: get E14 while typing command :tab with 'incsearch' set
Bram Moolenaar <Bram@vim.org>
parents:
15239
diff
changeset
|
2779 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
|
2780 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
|
2781 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
|
2782 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
|
2783 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
|
2784 else |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2785 { |
15263
ad065b8123e8
patch 8.1.0640: get E14 while typing command :tab with 'incsearch' set
Bram Moolenaar <Bram@vim.org>
parents:
15239
diff
changeset
|
2786 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
|
2787 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2788 *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
|
2789 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
|
2790 } |
ad065b8123e8
patch 8.1.0640: get E14 while typing command :tab with 'incsearch' set
Bram Moolenaar <Bram@vim.org>
parents:
15239
diff
changeset
|
2791 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
|
2792 } |
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 eap->cmd = p; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2795 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2796 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2797 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
|
2798 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2799 cmdmod.split |= WSP_TOP; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2800 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2801 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2802 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
|
2803 break; |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2804 if (!skip_only) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2805 { |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2806 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
|
2807 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
|
2808 msg_silent = 0; |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2809 } |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2810 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2811 |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2812 case '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
|
2813 { |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2814 cmdmod.split |= WSP_VERT; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2815 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2816 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2817 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
|
2818 break; |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2819 if (!skip_only) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2820 { |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2821 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
|
2822 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
|
2823 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
|
2824 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
|
2825 else |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2826 p_verbose = 1; |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2827 } |
14536
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2828 eap->cmd = p; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2829 continue; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2830 } |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2831 break; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2832 } |
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 return OK; |
4caa51067cb8
patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents:
14505
diff
changeset
|
2835 } |
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 /* |
14538
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2838 * 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
|
2839 */ |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2840 static void |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2841 free_cmdmod(void) |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2842 { |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2843 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
|
2844 { |
213f1a519378
patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents:
14536
diff
changeset
|
2845 /* 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
|
2846 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
|
2847 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
|
2848 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
|
2849 } |
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 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
|
2852 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
|
2853 } |
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 /* |
14505
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2856 * 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
|
2857 * 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
|
2858 * 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
|
2859 */ |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2860 int |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2861 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
|
2862 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2863 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
|
2864 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
|
2865 |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2866 // 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
|
2867 for (;;) |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2868 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2869 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
|
2870 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
|
2871 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2872 case ADDR_LINES: |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
2873 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
|
2874 // 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
|
2875 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
|
2876 break; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2877 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
|
2878 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
|
2879 break; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2880 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
|
2881 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
|
2882 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
|
2883 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 break; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2885 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
|
2886 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
|
2887 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
|
2888 break; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2889 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
|
2890 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
|
2891 break; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2892 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
|
2893 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
|
2894 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
|
2895 break; |
16479
7dcf301d1432
patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents:
16475
diff
changeset
|
2896 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
|
2897 #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
|
2898 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
|
2899 #endif |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
2900 break; |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
2901 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
|
2902 #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
|
2903 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
|
2904 #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
|
2905 break; |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
2906 case ADDR_NONE: |
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
2907 // 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
|
2908 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
|
2909 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2910 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
|
2911 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
|
2912 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
|
2913 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
|
2914 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
|
2915 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
|
2916 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2917 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
|
2918 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2919 ++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
|
2920 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
|
2921 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2922 case ADDR_LINES: |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
2923 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
|
2924 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
|
2925 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
|
2926 break; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2927 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
|
2928 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2929 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
|
2930 |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2931 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
|
2932 && 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
|
2933 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
|
2934 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
|
2935 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
|
2936 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
|
2937 && 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
|
2938 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
|
2939 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
|
2940 break; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2941 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2942 case ADDR_BUFFERS: |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2943 eap->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
|
2944 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
|
2945 break; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2946 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
|
2947 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
|
2948 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
|
2949 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2950 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
|
2951 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
|
2952 ? 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
|
2953 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2954 else |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2955 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2956 // 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
|
2957 // 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
|
2958 *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
|
2959 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
|
2960 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2961 break; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2962 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
|
2963 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
|
2964 case ADDR_QUICKFIX: |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2965 *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
|
2966 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
|
2967 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
|
2968 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
|
2969 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
|
2970 else |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2971 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2972 eap->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
|
2973 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
|
2974 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2975 break; |
16515
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
2976 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
|
2977 #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
|
2978 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
|
2979 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
|
2980 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
|
2981 eap->line2 = 1; |
16479
7dcf301d1432
patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents:
16475
diff
changeset
|
2982 #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
|
2983 break; |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
2984 case ADDR_NONE: |
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
2985 // 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
|
2986 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
|
2987 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2988 ++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
|
2989 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2990 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
|
2991 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2992 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
|
2993 |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
2994 // '*' - 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
|
2995 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
|
2996 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
2997 *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
|
2998 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
|
2999 } |
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 ++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
|
3002 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
|
3003 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3004 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
|
3005 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
|
3006 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
|
3007 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
|
3008 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
|
3009 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
|
3010 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
|
3011 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
|
3012 ++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
|
3013 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3014 } |
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 else |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3017 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
|
3018 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
|
3019 |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3020 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
|
3021 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3022 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
|
3023 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3024 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
|
3025 // 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
|
3026 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
|
3027 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3028 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3029 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
|
3030 break; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3031 ++eap->cmd; |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3032 } |
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 // 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
|
3035 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
|
3036 { |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3037 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
|
3038 // ... 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
|
3039 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
|
3040 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
|
3041 } |
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
3042 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
|
3043 } |
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 /* |
93 | 3046 * Check for an Ex command with optional tail. |
7 | 3047 * If there is a match advance "pp" to the argument and return TRUE. |
3048 */ | |
93 | 3049 int |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3050 checkforcmd( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3051 char_u **pp, /* start of command */ |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3052 char *cmd, /* name of command */ |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3053 int len) /* required length */ |
7 | 3054 { |
3055 int i; | |
3056 | |
3057 for (i = 0; cmd[i] != NUL; ++i) | |
1872 | 3058 if (((char_u *)cmd)[i] != (*pp)[i]) |
7 | 3059 break; |
3060 if (i >= len && !isalpha((*pp)[i])) | |
3061 { | |
3062 *pp = skipwhite(*pp + i); | |
3063 return TRUE; | |
3064 } | |
3065 return FALSE; | |
3066 } | |
3067 | |
3068 /* | |
3097 | 3069 * Append "cmd" to the error message in IObuff. |
3070 * Takes care of limiting the length and handling 0xa0, which would be | |
3071 * invisible otherwise. | |
3072 */ | |
3073 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3074 append_command(char_u *cmd) |
3097 | 3075 { |
3076 char_u *s = cmd; | |
3077 char_u *d; | |
3078 | |
3079 STRCAT(IObuff, ": "); | |
3080 d = IObuff + STRLEN(IObuff); | |
3081 while (*s != NUL && d - IObuff < IOSIZE - 7) | |
3082 { | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
3083 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
|
3084 { |
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
3085 s += enc_utf8 ? 2 : 1; |
3097 | 3086 STRCPY(d, "<a0>"); |
3087 d += 4; | |
3088 } | |
3089 else | |
3090 MB_COPY_CHAR(s, d); | |
3091 } | |
3092 *d = NUL; | |
3093 } | |
3094 | |
3095 /* | |
7 | 3096 * Find an Ex command by its name, either built-in or user. |
184 | 3097 * 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
|
3098 * Sets eap->cmdidx and returns a pointer to char after the command name. |
184 | 3099 * "full" is set to TRUE if the whole command name matched. |
7 | 3100 * Returns NULL for an ambiguous user command. |
3101 */ | |
3102 static char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3103 find_command(exarg_T *eap, int *full UNUSED) |
7 | 3104 { |
3105 int len; | |
3106 char_u *p; | |
167 | 3107 int i; |
7 | 3108 |
3109 /* | |
3110 * Isolate the command and search for it in the command table. | |
1441 | 3111 * Exceptions: |
7 | 3112 * - the 'k' command can directly be followed by any character. |
3113 * - the 's' command can be followed directly by 'c', 'g', 'i', 'I' or 'r' | |
6472 | 3114 * but :sre[wind] is another command, as are :scr[iptnames], |
7 | 3115 * :scs[cope], :sim[alt], :sig[ns] and :sil[ent]. |
167 | 3116 * - the "d" command can directly be followed by 'l' or 'p' flag. |
7 | 3117 */ |
3118 p = eap->cmd; | |
3119 if (*p == 'k') | |
3120 { | |
3121 eap->cmdidx = CMD_k; | |
3122 ++p; | |
3123 } | |
3124 else if (p[0] == 's' | |
6987 | 3125 && ((p[1] == 'c' && (p[2] == NUL || (p[2] != 's' && p[2] != 'r' |
3126 && (p[3] == NUL || (p[3] != 'i' && p[4] != 'p'))))) | |
7 | 3127 || p[1] == 'g' |
3128 || (p[1] == 'i' && p[2] != 'm' && p[2] != 'l' && p[2] != 'g') | |
3129 || p[1] == 'I' | |
3130 || (p[1] == 'r' && p[2] != 'e'))) | |
3131 { | |
3132 eap->cmdidx = CMD_substitute; | |
3133 ++p; | |
3134 } | |
3135 else | |
3136 { | |
3137 while (ASCII_ISALPHA(*p)) | |
3138 ++p; | |
2366
7a57fe6a5157
Fix that :py3file was not working.
Bram Moolenaar <bram@vim.org>
parents:
2360
diff
changeset
|
3139 /* for python 3.x support ":py3", ":python3", ":py3file", etc. */ |
2330 | 3140 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
|
3141 while (ASCII_ISALNUM(*p)) |
7a57fe6a5157
Fix that :py3file was not working.
Bram Moolenaar <bram@vim.org>
parents:
2360
diff
changeset
|
3142 ++p; |
2329
ad2889f48843
Added support for Python 3. (Roland Puntaier)
Bram Moolenaar <bram@vim.org>
parents:
2320
diff
changeset
|
3143 |
7 | 3144 /* check for non-alpha command */ |
3145 if (p == eap->cmd && vim_strchr((char_u *)"@*!=><&~#", *p) != NULL) | |
3146 ++p; | |
3147 len = (int)(p - eap->cmd); | |
167 | 3148 if (*eap->cmd == 'd' && (p[-1] == 'l' || p[-1] == 'p')) |
3149 { | |
3150 /* Check for ":dl", ":dell", etc. to ":deletel": that's | |
3151 * :delete with the 'l' flag. Same for 'p'. */ | |
3152 for (i = 0; i < len; ++i) | |
1872 | 3153 if (eap->cmd[i] != ((char_u *)"delete")[i]) |
167 | 3154 break; |
3155 if (i == len - 1) | |
3156 { | |
3157 --len; | |
3158 if (p[-1] == 'l') | |
3159 eap->flags |= EXFLAG_LIST; | |
3160 else | |
3161 eap->flags |= EXFLAG_PRINT; | |
3162 } | |
3163 } | |
7 | 3164 |
11236
62c96fee518e
patch 8.0.0504: looking up an Ex command is a bit slow
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
3165 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
|
3166 { |
11240
06307d812ca7
patch 8.0.0506: can't build with ANSI C
Christian Brabandt <cb@256bit.org>
parents:
11236
diff
changeset
|
3167 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
|
3168 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
|
3169 |
11236
62c96fee518e
patch 8.0.0504: looking up an Ex command is a bit slow
Christian Brabandt <cb@256bit.org>
parents:
11158
diff
changeset
|
3170 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
|
3171 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
3172 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
|
3173 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
|
3174 } |
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 /* 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
|
3177 * 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
|
3178 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
|
3179 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
|
3180 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
|
3181 } |
7 | 3182 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
|
3183 eap->cmdidx = CMD_bang; |
7 | 3184 |
3185 for ( ; (int)eap->cmdidx < (int)CMD_SIZE; | |
3186 eap->cmdidx = (cmdidx_T)((int)eap->cmdidx + 1)) | |
3187 if (STRNCMP(cmdnames[(int)eap->cmdidx].cmd_name, (char *)eap->cmd, | |
3188 (size_t)len) == 0) | |
3189 { | |
3190 #ifdef FEAT_EVAL | |
3191 if (full != NULL | |
3192 && cmdnames[(int)eap->cmdidx].cmd_name[len] == NUL) | |
3193 *full = TRUE; | |
3194 #endif | |
3195 break; | |
3196 } | |
3197 | |
16411
5b5c5daf57de
patch 8.1.1210: support for user commands is spread out
Bram Moolenaar <Bram@vim.org>
parents:
16399
diff
changeset
|
3198 // 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
|
3199 // overruled by a user defined command. |
2633 | 3200 if ((eap->cmdidx == CMD_SIZE || eap->cmdidx == CMD_Print) |
3201 && *eap->cmd >= 'A' && *eap->cmd <= 'Z') | |
7 | 3202 { |
16411
5b5c5daf57de
patch 8.1.1210: support for user commands is spread out
Bram Moolenaar <Bram@vim.org>
parents:
16399
diff
changeset
|
3203 // User defined commands may contain digits. |
7 | 3204 while (ASCII_ISALNUM(*p)) |
3205 ++p; | |
184 | 3206 p = find_ucmd(eap, p, full, NULL, NULL); |
3207 } | |
3208 if (p == eap->cmd) | |
7 | 3209 eap->cmdidx = CMD_SIZE; |
3210 } | |
3211 | |
3212 return p; | |
3213 } | |
3214 | |
3215 #if defined(FEAT_EVAL) || defined(PROTO) | |
1447 | 3216 static struct cmdmod |
3217 { | |
3218 char *name; | |
3219 int minlen; | |
3220 int has_count; /* :123verbose :3tab */ | |
3221 } cmdmods[] = { | |
3222 {"aboveleft", 3, FALSE}, | |
3223 {"belowright", 3, FALSE}, | |
3224 {"botright", 2, FALSE}, | |
3225 {"browse", 3, FALSE}, | |
3226 {"confirm", 4, FALSE}, | |
9941
e975914c17e9
commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents:
9927
diff
changeset
|
3227 {"filter", 4, FALSE}, |
1447 | 3228 {"hide", 3, FALSE}, |
3229 {"keepalt", 5, FALSE}, | |
3230 {"keepjumps", 5, FALSE}, | |
3231 {"keepmarks", 3, FALSE}, | |
5467 | 3232 {"keeppatterns", 5, FALSE}, |
1447 | 3233 {"leftabove", 5, FALSE}, |
3234 {"lockmarks", 3, FALSE}, | |
1721 | 3235 {"noautocmd", 3, FALSE}, |
5737 | 3236 {"noswapfile", 3, FALSE}, |
1447 | 3237 {"rightbelow", 6, FALSE}, |
3238 {"sandbox", 3, FALSE}, | |
3239 {"silent", 3, FALSE}, | |
3240 {"tab", 3, TRUE}, | |
3241 {"topleft", 2, FALSE}, | |
1926 | 3242 {"unsilent", 3, FALSE}, |
1447 | 3243 {"verbose", 4, TRUE}, |
3244 {"vertical", 4, FALSE}, | |
3245 }; | |
3246 | |
3247 /* | |
3248 * Return length of a command modifier (including optional count). | |
3249 * Return zero when it's not a modifier. | |
3250 */ | |
3251 int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3252 modifier_len(char_u *cmd) |
1447 | 3253 { |
3254 int i, j; | |
3255 char_u *p = cmd; | |
3256 | |
3257 if (VIM_ISDIGIT(*cmd)) | |
3258 p = skipwhite(skipdigits(cmd)); | |
1880 | 3259 for (i = 0; i < (int)(sizeof(cmdmods) / sizeof(struct cmdmod)); ++i) |
1447 | 3260 { |
3261 for (j = 0; p[j] != NUL; ++j) | |
3262 if (p[j] != cmdmods[i].name[j]) | |
3263 break; | |
4857
84a8d1ba81c3
updated for version 7.3.1175
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3264 if (!ASCII_ISALPHA(p[j]) && j >= cmdmods[i].minlen |
1447 | 3265 && (p == cmd || cmdmods[i].has_count)) |
1570 | 3266 return j + (int)(p - cmd); |
1447 | 3267 } |
3268 return 0; | |
3269 } | |
3270 | |
7 | 3271 /* |
3272 * Return > 0 if an Ex command "name" exists. | |
3273 * Return 2 if there is an exact match. | |
3274 * Return 3 if there is an ambiguous match. | |
3275 */ | |
3276 int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3277 cmd_exists(char_u *name) |
7 | 3278 { |
3279 exarg_T ea; | |
3280 int full = FALSE; | |
3281 int i; | |
3282 int j; | |
866 | 3283 char_u *p; |
7 | 3284 |
3285 /* Check command modifiers. */ | |
1880 | 3286 for (i = 0; i < (int)(sizeof(cmdmods) / sizeof(struct cmdmod)); ++i) |
7 | 3287 { |
3288 for (j = 0; name[j] != NUL; ++j) | |
3289 if (name[j] != cmdmods[i].name[j]) | |
3290 break; | |
3291 if (name[j] == NUL && j >= cmdmods[i].minlen) | |
3292 return (cmdmods[i].name[j] == NUL ? 2 : 1); | |
3293 } | |
3294 | |
862 | 3295 /* Check built-in commands and user defined commands. |
3296 * For ":2match" and ":3match" we need to skip the number. */ | |
3297 ea.cmd = (*name == '2' || *name == '3') ? name + 1 : name; | |
7 | 3298 ea.cmdidx = (cmdidx_T)0; |
866 | 3299 p = find_command(&ea, &full); |
3300 if (p == NULL) | |
7 | 3301 return 3; |
862 | 3302 if (vim_isdigit(*name) && ea.cmdidx != CMD_match) |
3303 return 0; | |
866 | 3304 if (*skipwhite(p) != NUL) |
3305 return 0; /* trailing garbage */ | |
7 | 3306 return (ea.cmdidx == CMD_SIZE ? 0 : (full ? 2 : 1)); |
3307 } | |
3308 #endif | |
3309 | |
3310 /* | |
3311 * This is all pretty much copied from do_one_cmd(), with all the extra stuff | |
3312 * we don't need/want deleted. Maybe this could be done better if we didn't | |
3313 * repeat all this stuff. The only problem is that they may not stay | |
3314 * perfectly compatible with each other, but then the command line syntax | |
3315 * probably won't change that much -- webb. | |
3316 */ | |
3317 char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3318 set_one_cmd_context( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3319 expand_T *xp, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
3320 char_u *buff) /* buffer for command string */ |
7 | 3321 { |
3322 char_u *p; | |
3323 char_u *cmd, *arg; | |
184 | 3324 int len = 0; |
3325 exarg_T ea; | |
7 | 3326 int compl = EXPAND_NOTHING; |
3327 int delim; | |
3328 int forceit = FALSE; | |
3329 int usefilter = FALSE; /* filter instead of file name */ | |
3330 | |
631 | 3331 ExpandInit(xp); |
7 | 3332 xp->xp_pattern = buff; |
3333 xp->xp_context = EXPAND_COMMANDS; /* Default until we get past command */ | |
184 | 3334 ea.argt = 0; |
7 | 3335 |
3336 /* | |
6400 | 3337 * 1. skip comment lines and leading space, colons or bars |
7 | 3338 */ |
3339 for (cmd = buff; vim_strchr((char_u *)" \t:|", *cmd) != NULL; cmd++) | |
3340 ; | |
3341 xp->xp_pattern = cmd; | |
3342 | |
3343 if (*cmd == NUL) | |
3344 return NULL; | |
3345 if (*cmd == '"') /* ignore comment lines */ | |
3346 { | |
3347 xp->xp_context = EXPAND_NOTHING; | |
3348 return NULL; | |
3349 } | |
3350 | |
3351 /* | |
6400 | 3352 * 3. Skip over the range to find the command. |
7 | 3353 */ |
3354 cmd = skip_range(cmd, &xp->xp_context); | |
3355 xp->xp_pattern = cmd; | |
3356 if (*cmd == NUL) | |
3357 return NULL; | |
3358 if (*cmd == '"') | |
3359 { | |
3360 xp->xp_context = EXPAND_NOTHING; | |
3361 return NULL; | |
3362 } | |
3363 | |
3364 if (*cmd == '|' || *cmd == '\n') | |
3365 return cmd + 1; /* There's another command */ | |
3366 | |
3367 /* | |
3368 * Isolate the command and search for it in the command table. | |
3369 * Exceptions: | |
3370 * - the 'k' command can directly be followed by any character, but | |
22 | 3371 * do accept "keepmarks", "keepalt" and "keepjumps". |
7 | 3372 * - the 's' command can be followed directly by 'c', 'g', 'i', 'I' or 'r' |
3373 */ | |
3374 if (*cmd == 'k' && cmd[1] != 'e') | |
3375 { | |
184 | 3376 ea.cmdidx = CMD_k; |
7 | 3377 p = cmd + 1; |
3378 } | |
3379 else | |
3380 { | |
3381 p = cmd; | |
3382 while (ASCII_ISALPHA(*p) || *p == '*') /* Allow * wild card */ | |
3383 ++p; | |
7168
0f2807c05687
commit https://github.com/vim/vim/commit/23d1b62746dce048c80cc19e7e5af1d513b6b4cf
Christian Brabandt <cb@256bit.org>
parents:
7133
diff
changeset
|
3384 /* a user command may contain digits */ |
0f2807c05687
commit https://github.com/vim/vim/commit/23d1b62746dce048c80cc19e7e5af1d513b6b4cf
Christian Brabandt <cb@256bit.org>
parents:
7133
diff
changeset
|
3385 if (ASCII_ISUPPER(cmd[0])) |
0f2807c05687
commit https://github.com/vim/vim/commit/23d1b62746dce048c80cc19e7e5af1d513b6b4cf
Christian Brabandt <cb@256bit.org>
parents:
7133
diff
changeset
|
3386 while (ASCII_ISALNUM(*p) || *p == '*') |
0f2807c05687
commit https://github.com/vim/vim/commit/23d1b62746dce048c80cc19e7e5af1d513b6b4cf
Christian Brabandt <cb@256bit.org>
parents:
7133
diff
changeset
|
3387 ++p; |
4710
1c5da99d1b70
updated for version 7.3.1102
Bram Moolenaar <bram@vim.org>
parents:
4704
diff
changeset
|
3388 /* for python 3.x: ":py3*" commands completion */ |
1c5da99d1b70
updated for version 7.3.1102
Bram Moolenaar <bram@vim.org>
parents:
4704
diff
changeset
|
3389 if (cmd[0] == 'p' && cmd[1] == 'y' && p == cmd + 2 && *p == '3') |
5545 | 3390 { |
4710
1c5da99d1b70
updated for version 7.3.1102
Bram Moolenaar <bram@vim.org>
parents:
4704
diff
changeset
|
3391 ++p; |
5545 | 3392 while (ASCII_ISALPHA(*p) || *p == '*') |
3393 ++p; | |
3394 } | |
7168
0f2807c05687
commit https://github.com/vim/vim/commit/23d1b62746dce048c80cc19e7e5af1d513b6b4cf
Christian Brabandt <cb@256bit.org>
parents:
7133
diff
changeset
|
3395 /* check for non-alpha command */ |
0f2807c05687
commit https://github.com/vim/vim/commit/23d1b62746dce048c80cc19e7e5af1d513b6b4cf
Christian Brabandt <cb@256bit.org>
parents:
7133
diff
changeset
|
3396 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
|
3397 ++p; |
184 | 3398 len = (int)(p - cmd); |
3399 | |
3400 if (len == 0) | |
7 | 3401 { |
3402 xp->xp_context = EXPAND_UNSUCCESSFUL; | |
3403 return NULL; | |
3404 } | |
184 | 3405 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
|
3406 ea.cmdidx = (cmdidx_T)((int)ea.cmdidx + 1)) |
8f72e3512b43
updated for version 7.2.381
Bram Moolenaar <bram@zimbu.org>
parents:
2068
diff
changeset
|
3407 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
|
3408 (size_t)len) == 0) |
7 | 3409 break; |
3410 | |
3411 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
|
3412 while (ASCII_ISALNUM(*p) || *p == '*') // Allow * wild card |
7 | 3413 ++p; |
3414 } | |
3415 | |
3416 /* | |
3417 * If the cursor is touching the command, and it ends in an alpha-numeric | |
3418 * character, complete the command name. | |
3419 */ | |
3420 if (*p == NUL && ASCII_ISALNUM(p[-1])) | |
3421 return NULL; | |
3422 | |
184 | 3423 if (ea.cmdidx == CMD_SIZE) |
7 | 3424 { |
3425 if (*cmd == 's' && vim_strchr((char_u *)"cgriI", cmd[1]) != NULL) | |
3426 { | |
184 | 3427 ea.cmdidx = CMD_substitute; |
7 | 3428 p = cmd + 1; |
3429 } | |
3430 else if (cmd[0] >= 'A' && cmd[0] <= 'Z') | |
3431 { | |
184 | 3432 ea.cmd = cmd; |
17781
04245f071792
patch 8.1.1887: the +cmdline_compl feature is not in the tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17767
diff
changeset
|
3433 p = find_ucmd(&ea, p, NULL, xp, &compl); |
620 | 3434 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
|
3435 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
|
3436 } |
184 | 3437 } |
3438 if (ea.cmdidx == CMD_SIZE) | |
7 | 3439 { |
3440 /* Not still touching the command and it was an illegal one */ | |
3441 xp->xp_context = EXPAND_UNSUCCESSFUL; | |
3442 return NULL; | |
3443 } | |
3444 | |
3445 xp->xp_context = EXPAND_NOTHING; /* Default now that we're past command */ | |
3446 | |
3447 if (*p == '!') /* forced commands */ | |
3448 { | |
3449 forceit = TRUE; | |
3450 ++p; | |
3451 } | |
3452 | |
3453 /* | |
6400 | 3454 * 6. parse arguments |
7 | 3455 */ |
6305 | 3456 if (!IS_USER_CMDIDX(ea.cmdidx)) |
835 | 3457 ea.argt = (long)cmdnames[(int)ea.cmdidx].cmd_argt; |
7 | 3458 |
3459 arg = skipwhite(p); | |
3460 | |
184 | 3461 if (ea.cmdidx == CMD_write || ea.cmdidx == CMD_update) |
7 | 3462 { |
3463 if (*arg == '>') /* append */ | |
3464 { | |
3465 if (*++arg == '>') | |
3466 ++arg; | |
3467 arg = skipwhite(arg); | |
3468 } | |
184 | 3469 else if (*arg == '!' && ea.cmdidx == CMD_write) /* :w !filter */ |
7 | 3470 { |
3471 ++arg; | |
3472 usefilter = TRUE; | |
3473 } | |
3474 } | |
3475 | |
184 | 3476 if (ea.cmdidx == CMD_read) |
7 | 3477 { |
3478 usefilter = forceit; /* :r! filter if forced */ | |
3479 if (*arg == '!') /* :r !filter */ | |
3480 { | |
3481 ++arg; | |
3482 usefilter = TRUE; | |
3483 } | |
3484 } | |
3485 | |
184 | 3486 if (ea.cmdidx == CMD_lshift || ea.cmdidx == CMD_rshift) |
7 | 3487 { |
3488 while (*arg == *cmd) /* allow any number of '>' or '<' */ | |
3489 ++arg; | |
3490 arg = skipwhite(arg); | |
3491 } | |
3492 | |
3493 /* 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
|
3494 if ((ea.argt & EX_CMDARG) && !usefilter && *arg == '+') |
7 | 3495 { |
3496 /* Check if we're in the +command */ | |
3497 p = arg + 1; | |
3498 arg = skip_cmd_arg(arg, FALSE); | |
3499 | |
3500 /* Still touching the command after '+'? */ | |
3501 if (*arg == NUL) | |
3502 return p; | |
3503 | |
3504 /* Skip space(s) after +command to get to the real argument */ | |
3505 arg = skipwhite(arg); | |
3506 } | |
3507 | |
3508 /* | |
3509 * Check for '|' to separate commands and '"' to start comments. | |
3510 * Don't do this for ":read !cmd" and ":write !cmd". | |
3511 */ | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
3512 if ((ea.argt & EX_TRLBAR) && !usefilter) |
7 | 3513 { |
3514 p = arg; | |
3515 /* ":redir @" is not the start of a comment */ | |
184 | 3516 if (ea.cmdidx == CMD_redir && p[0] == '@' && p[1] == '"') |
7 | 3517 p += 2; |
3518 while (*p) | |
3519 { | |
3520 if (*p == Ctrl_V) | |
3521 { | |
3522 if (p[1] != NUL) | |
3523 ++p; | |
3524 } | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
3525 else if ( (*p == '"' && !(ea.argt & EX_NOTRLCOM)) |
7 | 3526 || *p == '|' || *p == '\n') |
3527 { | |
3528 if (*(p - 1) != '\\') | |
3529 { | |
3530 if (*p == '|' || *p == '\n') | |
3531 return p + 1; | |
3532 return NULL; /* It's a comment */ | |
3533 } | |
3534 } | |
11127
506f5d8b7d8b
patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11010
diff
changeset
|
3535 MB_PTR_ADV(p); |
7 | 3536 } |
3537 } | |
3538 | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
3539 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
|
3540 && 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
|
3541 // no arguments allowed but there is something |
7 | 3542 return NULL; |
3543 | |
3544 /* Find start of last argument (argument just before cursor): */ | |
3711 | 3545 p = buff; |
7 | 3546 xp->xp_pattern = p; |
3724 | 3547 len = (int)STRLEN(buff); |
3711 | 3548 while (*p && p < buff + len) |
3549 { | |
3550 if (*p == ' ' || *p == TAB) | |
3551 { | |
3552 /* argument starts after a space */ | |
3553 xp->xp_pattern = ++p; | |
3554 } | |
3555 else | |
3556 { | |
3557 if (*p == '\\' && *(p + 1) != NUL) | |
3558 ++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
|
3559 MB_PTR_ADV(p); |
3711 | 3560 } |
3561 } | |
7 | 3562 |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
3563 if (ea.argt & EX_XFILE) |
7 | 3564 { |
1367 | 3565 int c; |
3566 int in_quote = FALSE; | |
3567 char_u *bow = NULL; /* Beginning of word */ | |
7 | 3568 |
3569 /* | |
3570 * Allow spaces within back-quotes to count as part of the argument | |
3571 * being expanded. | |
3572 */ | |
3573 xp->xp_pattern = skipwhite(arg); | |
1367 | 3574 p = xp->xp_pattern; |
3575 while (*p != NUL) | |
3576 { | |
3577 if (has_mbyte) | |
3578 c = mb_ptr2char(p); | |
3579 else | |
3580 c = *p; | |
3581 if (c == '\\' && p[1] != NUL) | |
7 | 3582 ++p; |
1367 | 3583 else if (c == '`') |
7 | 3584 { |
3585 if (!in_quote) | |
3586 { | |
3587 xp->xp_pattern = p; | |
3588 bow = p + 1; | |
3589 } | |
3590 in_quote = !in_quote; | |
3591 } | |
1511 | 3592 /* An argument can contain just about everything, except |
3593 * 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
|
3594 else if (c == '|' || c == '\n' || c == '"' || (VIM_ISWHITE(c) |
1367 | 3595 #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
|
3596 && (!(ea.argt & EX_NOSPC) || usefilter) |
1511 | 3597 #endif |
3598 )) | |
1367 | 3599 { |
1551 | 3600 len = 0; /* avoid getting stuck when space is in 'isfname' */ |
1367 | 3601 while (*p != NUL) |
3602 { | |
3603 if (has_mbyte) | |
3604 c = mb_ptr2char(p); | |
3605 else | |
3606 c = *p; | |
1369 | 3607 if (c == '`' || vim_isfilec_or_wc(c)) |
1367 | 3608 break; |
3609 if (has_mbyte) | |
3610 len = (*mb_ptr2len)(p); | |
3611 else | |
3612 len = 1; | |
11127
506f5d8b7d8b
patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11010
diff
changeset
|
3613 MB_PTR_ADV(p); |
1367 | 3614 } |
3615 if (in_quote) | |
3616 bow = p; | |
3617 else | |
3618 xp->xp_pattern = p; | |
3619 p -= len; | |
3620 } | |
11127
506f5d8b7d8b
patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11010
diff
changeset
|
3621 MB_PTR_ADV(p); |
7 | 3622 } |
3623 | |
3624 /* | |
3625 * If we are still inside the quotes, and we passed a space, just | |
3626 * expand from there. | |
3627 */ | |
3628 if (bow != NULL && in_quote) | |
3629 xp->xp_pattern = bow; | |
3630 xp->xp_context = EXPAND_FILES; | |
714 | 3631 |
631 | 3632 /* 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
|
3633 if (usefilter || ea.cmdidx == CMD_bang || ea.cmdidx == CMD_terminal) |
714 | 3634 { |
2511
2f5b709a6470
Fixed: on MS-Windows completion of shell commands didn't work.
Bram Moolenaar <bram@vim.org>
parents:
2444
diff
changeset
|
3635 #ifndef BACKSLASH_IN_FILENAME |
631 | 3636 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
|
3637 #endif |
714 | 3638 /* When still after the command name expand executables. */ |
3639 if (xp->xp_pattern == skipwhite(arg)) | |
1132 | 3640 xp->xp_context = EXPAND_SHELLCMD; |
714 | 3641 } |
7 | 3642 |
3643 /* Check for environment variable */ | |
3644 if (*xp->xp_pattern == '$' | |
8212
05b88224cea1
commit https://github.com/vim/vim/commit/48e330aff911be1c798c88a973af6437a8141fce
Christian Brabandt <cb@256bit.org>
parents:
7864
diff
changeset
|
3645 #if defined(MSWIN) |
7 | 3646 || *xp->xp_pattern == '%' |
3647 #endif | |
3648 ) | |
3649 { | |
3650 for (p = xp->xp_pattern + 1; *p != NUL; ++p) | |
3651 if (!vim_isIDc(*p)) | |
3652 break; | |
3653 if (*p == NUL) | |
3654 { | |
3655 xp->xp_context = EXPAND_ENV_VARS; | |
3656 ++xp->xp_pattern; | |
17 | 3657 /* Avoid that the assignment uses EXPAND_FILES again. */ |
406 | 3658 if (compl != EXPAND_USER_DEFINED && compl != EXPAND_USER_LIST) |
17 | 3659 compl = EXPAND_ENV_VARS; |
7 | 3660 } |
3661 } | |
3744 | 3662 /* Check for user names */ |
3663 if (*xp->xp_pattern == '~') | |
3664 { | |
3665 for (p = xp->xp_pattern + 1; *p != NUL && *p != '/'; ++p) | |
3666 ; | |
3667 /* Complete ~user only if it partially matches a user name. | |
3668 * A full match ~user<Tab> will be replaced by user's home | |
3669 * directory i.e. something like ~user<Tab> -> /home/user/ */ | |
3670 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
|
3671 && match_user(xp->xp_pattern + 1) >= 1) |
3744 | 3672 { |
3673 xp->xp_context = EXPAND_USER; | |
3674 ++xp->xp_pattern; | |
3675 } | |
3676 } | |
7 | 3677 } |
3678 | |
3679 /* | |
6400 | 3680 * 6. Switch on command name. |
7 | 3681 */ |
184 | 3682 switch (ea.cmdidx) |
7 | 3683 { |
2311
ccda151dde4e
Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
3684 case CMD_find: |
ccda151dde4e
Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
3685 case CMD_sfind: |
ccda151dde4e
Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
3686 case CMD_tabfind: |
2575 | 3687 if (xp->xp_context == EXPAND_FILES) |
3688 xp->xp_context = EXPAND_FILES_IN_PATH; | |
2311
ccda151dde4e
Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents:
2294
diff
changeset
|
3689 break; |
7 | 3690 case CMD_cd: |
3691 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
|
3692 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
|
3693 case CMD_tchdir: |
7 | 3694 case CMD_lcd: |
3695 case CMD_lchdir: | |
3696 if (xp->xp_context == EXPAND_FILES) | |
3697 xp->xp_context = EXPAND_DIRECTORIES; | |
3698 break; | |
3699 case CMD_help: | |
3700 xp->xp_context = EXPAND_HELP; | |
3701 xp->xp_pattern = arg; | |
3702 break; | |
3703 | |
198 | 3704 /* Command modifiers: return the argument. |
3705 * Also for commands with an argument that is a command. */ | |
7 | 3706 case CMD_aboveleft: |
198 | 3707 case CMD_argdo: |
7 | 3708 case CMD_belowright: |
3709 case CMD_botright: | |
3710 case CMD_browse: | |
198 | 3711 case CMD_bufdo: |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
3712 case CMD_cdo: |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
3713 case CMD_cfdo: |
7 | 3714 case CMD_confirm: |
167 | 3715 case CMD_debug: |
7 | 3716 case CMD_folddoclosed: |
3717 case CMD_folddoopen: | |
3718 case CMD_hide: | |
22 | 3719 case CMD_keepalt: |
7 | 3720 case CMD_keepjumps: |
3721 case CMD_keepmarks: | |
5467 | 3722 case CMD_keeppatterns: |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
3723 case CMD_ldo: |
7 | 3724 case CMD_leftabove: |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
3725 case CMD_lfdo: |
7 | 3726 case CMD_lockmarks: |
5737 | 3727 case CMD_noautocmd: |
3728 case CMD_noswapfile: | |
7 | 3729 case CMD_rightbelow: |
198 | 3730 case CMD_sandbox: |
7 | 3731 case CMD_silent: |
690 | 3732 case CMD_tab: |
4928
afb00cc8caac
updated for version 7.3.1209
Bram Moolenaar <bram@vim.org>
parents:
4889
diff
changeset
|
3733 case CMD_tabdo: |
7 | 3734 case CMD_topleft: |
3735 case CMD_verbose: | |
3736 case CMD_vertical: | |
198 | 3737 case CMD_windo: |
7 | 3738 return arg; |
3739 | |
10520
4b152b5f414f
commit https://github.com/vim/vim/commit/7069bf18e1b1b7bc7640335e07d1022b5acc9048
Christian Brabandt <cb@256bit.org>
parents:
10492
diff
changeset
|
3740 case CMD_filter: |
4b152b5f414f
commit https://github.com/vim/vim/commit/7069bf18e1b1b7bc7640335e07d1022b5acc9048
Christian Brabandt <cb@256bit.org>
parents:
10492
diff
changeset
|
3741 if (*arg != NUL) |
4b152b5f414f
commit https://github.com/vim/vim/commit/7069bf18e1b1b7bc7640335e07d1022b5acc9048
Christian Brabandt <cb@256bit.org>
parents:
10492
diff
changeset
|
3742 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
|
3743 if (arg == NULL || *arg == NUL) |
4b152b5f414f
commit https://github.com/vim/vim/commit/7069bf18e1b1b7bc7640335e07d1022b5acc9048
Christian Brabandt <cb@256bit.org>
parents:
10492
diff
changeset
|
3744 { |
4b152b5f414f
commit https://github.com/vim/vim/commit/7069bf18e1b1b7bc7640335e07d1022b5acc9048
Christian Brabandt <cb@256bit.org>
parents:
10492
diff
changeset
|
3745 xp->xp_context = EXPAND_NOTHING; |
4b152b5f414f
commit https://github.com/vim/vim/commit/7069bf18e1b1b7bc7640335e07d1022b5acc9048
Christian Brabandt <cb@256bit.org>
parents:
10492
diff
changeset
|
3746 return NULL; |
4b152b5f414f
commit https://github.com/vim/vim/commit/7069bf18e1b1b7bc7640335e07d1022b5acc9048
Christian Brabandt <cb@256bit.org>
parents:
10492
diff
changeset
|
3747 } |
4b152b5f414f
commit https://github.com/vim/vim/commit/7069bf18e1b1b7bc7640335e07d1022b5acc9048
Christian Brabandt <cb@256bit.org>
parents:
10492
diff
changeset
|
3748 return skipwhite(arg); |
4b152b5f414f
commit https://github.com/vim/vim/commit/7069bf18e1b1b7bc7640335e07d1022b5acc9048
Christian Brabandt <cb@256bit.org>
parents:
10492
diff
changeset
|
3749 |
17781
04245f071792
patch 8.1.1887: the +cmdline_compl feature is not in the tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17767
diff
changeset
|
3750 #ifdef FEAT_SEARCH_EXTRA |
7 | 3751 case CMD_match: |
3752 if (*arg == NUL || !ends_excmd(*arg)) | |
3753 { | |
1322 | 3754 /* also complete "None" */ |
3755 set_context_in_echohl_cmd(xp, arg); | |
7 | 3756 arg = skipwhite(skiptowhite(arg)); |
3757 if (*arg != NUL) | |
3758 { | |
3759 xp->xp_context = EXPAND_NOTHING; | |
3760 arg = skip_regexp(arg + 1, *arg, p_magic, NULL); | |
3761 } | |
3762 } | |
3763 return find_nextcmd(arg); | |
17781
04245f071792
patch 8.1.1887: the +cmdline_compl feature is not in the tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17767
diff
changeset
|
3764 #endif |
1322 | 3765 |
7 | 3766 /* |
3767 * All completion for the +cmdline_compl feature goes here. | |
3768 */ | |
3769 | |
3770 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
|
3771 return set_context_in_user_cmd(xp, arg); |
7 | 3772 |
3773 case CMD_delcommand: | |
3774 xp->xp_context = EXPAND_USER_COMMANDS; | |
3775 xp->xp_pattern = arg; | |
3776 break; | |
3777 | |
3778 case CMD_global: | |
3779 case CMD_vglobal: | |
3780 delim = *arg; /* get the delimiter */ | |
3781 if (delim) | |
3782 ++arg; /* skip delimiter if there is one */ | |
3783 | |
3784 while (arg[0] != NUL && arg[0] != delim) | |
3785 { | |
3786 if (arg[0] == '\\' && arg[1] != NUL) | |
3787 ++arg; | |
3788 ++arg; | |
3789 } | |
3790 if (arg[0] != NUL) | |
3791 return arg + 1; | |
3792 break; | |
3793 case CMD_and: | |
3794 case CMD_substitute: | |
3795 delim = *arg; | |
3796 if (delim) | |
3797 { | |
3798 /* skip "from" part */ | |
3799 ++arg; | |
3800 arg = skip_regexp(arg, delim, p_magic, NULL); | |
3801 } | |
3802 /* skip "to" part */ | |
3803 while (arg[0] != NUL && arg[0] != delim) | |
3804 { | |
3805 if (arg[0] == '\\' && arg[1] != NUL) | |
3806 ++arg; | |
3807 ++arg; | |
3808 } | |
3809 if (arg[0] != NUL) /* skip delimiter */ | |
3810 ++arg; | |
3811 while (arg[0] && vim_strchr((char_u *)"|\"#", arg[0]) == NULL) | |
3812 ++arg; | |
3813 if (arg[0] != NUL) | |
3814 return arg; | |
3815 break; | |
3816 case CMD_isearch: | |
3817 case CMD_dsearch: | |
3818 case CMD_ilist: | |
3819 case CMD_dlist: | |
3820 case CMD_ijump: | |
3821 case CMD_psearch: | |
3822 case CMD_djump: | |
3823 case CMD_isplit: | |
3824 case CMD_dsplit: | |
3825 arg = skipwhite(skipdigits(arg)); /* skip count */ | |
3826 if (*arg == '/') /* Match regexp, not just whole words */ | |
3827 { | |
3828 for (++arg; *arg && *arg != '/'; arg++) | |
3829 if (*arg == '\\' && arg[1] != NUL) | |
3830 arg++; | |
3831 if (*arg) | |
3832 { | |
3833 arg = skipwhite(arg + 1); | |
3834 | |
3835 /* Check for trailing illegal characters */ | |
3836 if (*arg && vim_strchr((char_u *)"|\"\n", *arg) == NULL) | |
3837 xp->xp_context = EXPAND_NOTHING; | |
3838 else | |
3839 return arg; | |
3840 } | |
3841 } | |
3842 break; | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
3843 |
7 | 3844 case CMD_autocmd: |
3845 return set_context_in_autocmd(xp, arg, FALSE); | |
3846 case CMD_doautocmd: | |
1731 | 3847 case CMD_doautoall: |
7 | 3848 return set_context_in_autocmd(xp, arg, TRUE); |
3849 case CMD_set: | |
3850 set_context_in_set_cmd(xp, arg, 0); | |
3851 break; | |
3852 case CMD_setglobal: | |
3853 set_context_in_set_cmd(xp, arg, OPT_GLOBAL); | |
3854 break; | |
3855 case CMD_setlocal: | |
3856 set_context_in_set_cmd(xp, arg, OPT_LOCAL); | |
3857 break; | |
3858 case CMD_tag: | |
3859 case CMD_stag: | |
3860 case CMD_ptag: | |
649 | 3861 case CMD_ltag: |
7 | 3862 case CMD_tselect: |
3863 case CMD_stselect: | |
3864 case CMD_ptselect: | |
3865 case CMD_tjump: | |
3866 case CMD_stjump: | |
3867 case CMD_ptjump: | |
40 | 3868 if (*p_wop != NUL) |
3869 xp->xp_context = EXPAND_TAGS_LISTFILES; | |
3870 else | |
3871 xp->xp_context = EXPAND_TAGS; | |
7 | 3872 xp->xp_pattern = arg; |
3873 break; | |
3874 case CMD_augroup: | |
3875 xp->xp_context = EXPAND_AUGROUP; | |
3876 xp->xp_pattern = arg; | |
3877 break; | |
3878 #ifdef FEAT_SYN_HL | |
3879 case CMD_syntax: | |
3880 set_context_in_syntax_cmd(xp, arg); | |
3881 break; | |
3882 #endif | |
3883 #ifdef FEAT_EVAL | |
3884 case CMD_let: | |
3885 case CMD_if: | |
3886 case CMD_elseif: | |
3887 case CMD_while: | |
72 | 3888 case CMD_for: |
7 | 3889 case CMD_echo: |
3890 case CMD_echon: | |
3891 case CMD_execute: | |
3892 case CMD_echomsg: | |
3893 case CMD_echoerr: | |
3894 case CMD_call: | |
3895 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
|
3896 case CMD_cexpr: |
4762bd300564
patch 8.0.0218: no completion for :cexpr and similar commands
Christian Brabandt <cb@256bit.org>
parents:
10575
diff
changeset
|
3897 case CMD_caddexpr: |
4762bd300564
patch 8.0.0218: no completion for :cexpr and similar commands
Christian Brabandt <cb@256bit.org>
parents:
10575
diff
changeset
|
3898 case CMD_cgetexpr: |
4762bd300564
patch 8.0.0218: no completion for :cexpr and similar commands
Christian Brabandt <cb@256bit.org>
parents:
10575
diff
changeset
|
3899 case CMD_lexpr: |
4762bd300564
patch 8.0.0218: no completion for :cexpr and similar commands
Christian Brabandt <cb@256bit.org>
parents:
10575
diff
changeset
|
3900 case CMD_laddexpr: |
4762bd300564
patch 8.0.0218: no completion for :cexpr and similar commands
Christian Brabandt <cb@256bit.org>
parents:
10575
diff
changeset
|
3901 case CMD_lgetexpr: |
184 | 3902 set_context_for_expression(xp, arg, ea.cmdidx); |
7 | 3903 break; |
3904 | |
3905 case CMD_unlet: | |
3906 while ((xp->xp_pattern = vim_strchr(arg, ' ')) != NULL) | |
3907 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
|
3908 |
7 | 3909 xp->xp_context = EXPAND_USER_VARS; |
3910 xp->xp_pattern = arg; | |
14059
a94bc6a7b29e
patch 8.1.0047: no completion for :unlet $VAR
Christian Brabandt <cb@256bit.org>
parents:
14051
diff
changeset
|
3911 |
a94bc6a7b29e
patch 8.1.0047: no completion for :unlet $VAR
Christian Brabandt <cb@256bit.org>
parents:
14051
diff
changeset
|
3912 if (*xp->xp_pattern == '$') |
a94bc6a7b29e
patch 8.1.0047: no completion for :unlet $VAR
Christian Brabandt <cb@256bit.org>
parents:
14051
diff
changeset
|
3913 { |
a94bc6a7b29e
patch 8.1.0047: no completion for :unlet $VAR
Christian Brabandt <cb@256bit.org>
parents:
14051
diff
changeset
|
3914 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
|
3915 ++xp->xp_pattern; |
a94bc6a7b29e
patch 8.1.0047: no completion for :unlet $VAR
Christian Brabandt <cb@256bit.org>
parents:
14051
diff
changeset
|
3916 } |
a94bc6a7b29e
patch 8.1.0047: no completion for :unlet $VAR
Christian Brabandt <cb@256bit.org>
parents:
14051
diff
changeset
|
3917 |
7 | 3918 break; |
3919 | |
3920 case CMD_function: | |
3921 case CMD_delfunction: | |
3922 xp->xp_context = EXPAND_USER_FUNC; | |
3923 xp->xp_pattern = arg; | |
3924 break; | |
3925 | |
3926 case CMD_echohl: | |
1322 | 3927 set_context_in_echohl_cmd(xp, arg); |
7 | 3928 break; |
3929 #endif | |
3930 case CMD_highlight: | |
3931 set_context_in_highlight_cmd(xp, arg); | |
3932 break; | |
1845 | 3933 #ifdef FEAT_CSCOPE |
3934 case CMD_cscope: | |
1858 | 3935 case CMD_lcscope: |
3936 case CMD_scscope: | |
3937 set_context_in_cscope_cmd(xp, arg, ea.cmdidx); | |
1845 | 3938 break; |
3939 #endif | |
1868 | 3940 #ifdef FEAT_SIGNS |
3941 case CMD_sign: | |
3942 set_context_in_sign_cmd(xp, arg); | |
3943 break; | |
3944 #endif | |
7 | 3945 case CMD_bdelete: |
3946 case CMD_bwipeout: | |
3947 case CMD_bunload: | |
3948 while ((xp->xp_pattern = vim_strchr(arg, ' ')) != NULL) | |
3949 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
|
3950 /* FALLTHROUGH */ |
7 | 3951 case CMD_buffer: |
3952 case CMD_sbuffer: | |
3953 case CMD_checktime: | |
3954 xp->xp_context = EXPAND_BUFFERS; | |
3955 xp->xp_pattern = arg; | |
3956 break; | |
16411
5b5c5daf57de
patch 8.1.1210: support for user commands is spread out
Bram Moolenaar <Bram@vim.org>
parents:
16399
diff
changeset
|
3957 |
7 | 3958 case CMD_USER: |
3959 case CMD_USER_BUF: | |
3960 if (compl != EXPAND_NOTHING) | |
3961 { | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
3962 // 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
|
3963 if (!(ea.argt & EX_XFILE)) |
7 | 3964 { |
16411
5b5c5daf57de
patch 8.1.1210: support for user commands is spread out
Bram Moolenaar <Bram@vim.org>
parents:
16399
diff
changeset
|
3965 #ifdef FEAT_MENU |
7 | 3966 if (compl == EXPAND_MENUS) |
3967 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
|
3968 #endif |
7 | 3969 if (compl == EXPAND_COMMANDS) |
3970 return arg; | |
3971 if (compl == EXPAND_MAPPINGS) | |
3972 return set_context_in_map_cmd(xp, (char_u *)"map", | |
3973 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
|
3974 // Find start of last argument. |
3711 | 3975 p = arg; |
3976 while (*p) | |
3977 { | |
3978 if (*p == ' ') | |
16411
5b5c5daf57de
patch 8.1.1210: support for user commands is spread out
Bram Moolenaar <Bram@vim.org>
parents:
16399
diff
changeset
|
3979 // argument starts after a space |
3711 | 3980 arg = p + 1; |
3716 | 3981 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
|
3982 ++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
|
3983 MB_PTR_ADV(p); |
3711 | 3984 } |
7 | 3985 xp->xp_pattern = arg; |
3986 } | |
3987 xp->xp_context = compl; | |
3988 } | |
3989 break; | |
16411
5b5c5daf57de
patch 8.1.1210: support for user commands is spread out
Bram Moolenaar <Bram@vim.org>
parents:
16399
diff
changeset
|
3990 |
7 | 3991 case CMD_map: case CMD_noremap: |
3992 case CMD_nmap: case CMD_nnoremap: | |
3993 case CMD_vmap: case CMD_vnoremap: | |
3994 case CMD_omap: case CMD_onoremap: | |
3995 case CMD_imap: case CMD_inoremap: | |
3996 case CMD_cmap: case CMD_cnoremap: | |
2405
84c9bf950ed4
Add completion for :lmap and :lunmap.
Bram Moolenaar <bram@vim.org>
parents:
2366
diff
changeset
|
3997 case CMD_lmap: case CMD_lnoremap: |
4365 | 3998 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
|
3999 case CMD_tmap: case CMD_tnoremap: |
4365 | 4000 case CMD_xmap: case CMD_xnoremap: |
7 | 4001 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
|
4002 FALSE, FALSE, ea.cmdidx); |
7 | 4003 case CMD_unmap: |
4004 case CMD_nunmap: | |
4005 case CMD_vunmap: | |
4006 case CMD_ounmap: | |
4007 case CMD_iunmap: | |
4008 case CMD_cunmap: | |
2405
84c9bf950ed4
Add completion for :lmap and :lunmap.
Bram Moolenaar <bram@vim.org>
parents:
2366
diff
changeset
|
4009 case CMD_lunmap: |
4365 | 4010 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
|
4011 case CMD_tunmap: |
4365 | 4012 case CMD_xunmap: |
7 | 4013 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
|
4014 FALSE, TRUE, ea.cmdidx); |
11995
7df3dd3c0ac1
patch 8.0.0878: no completion for :mapclear
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
4015 case CMD_mapclear: |
7df3dd3c0ac1
patch 8.0.0878: no completion for :mapclear
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
4016 case CMD_nmapclear: |
7df3dd3c0ac1
patch 8.0.0878: no completion for :mapclear
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
4017 case CMD_vmapclear: |
7df3dd3c0ac1
patch 8.0.0878: no completion for :mapclear
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
4018 case CMD_omapclear: |
7df3dd3c0ac1
patch 8.0.0878: no completion for :mapclear
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
4019 case CMD_imapclear: |
7df3dd3c0ac1
patch 8.0.0878: no completion for :mapclear
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
4020 case CMD_cmapclear: |
7df3dd3c0ac1
patch 8.0.0878: no completion for :mapclear
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
4021 case CMD_lmapclear: |
7df3dd3c0ac1
patch 8.0.0878: no completion for :mapclear
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
4022 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
|
4023 case CMD_tmapclear: |
11995
7df3dd3c0ac1
patch 8.0.0878: no completion for :mapclear
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
4024 case CMD_xmapclear: |
7df3dd3c0ac1
patch 8.0.0878: no completion for :mapclear
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
4025 xp->xp_context = EXPAND_MAPCLEAR; |
7df3dd3c0ac1
patch 8.0.0878: no completion for :mapclear
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
4026 xp->xp_pattern = arg; |
7df3dd3c0ac1
patch 8.0.0878: no completion for :mapclear
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
4027 break; |
7df3dd3c0ac1
patch 8.0.0878: no completion for :mapclear
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
4028 |
7 | 4029 case CMD_abbreviate: case CMD_noreabbrev: |
4030 case CMD_cabbrev: case CMD_cnoreabbrev: | |
4031 case CMD_iabbrev: case CMD_inoreabbrev: | |
4032 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
|
4033 TRUE, FALSE, ea.cmdidx); |
7 | 4034 case CMD_unabbreviate: |
4035 case CMD_cunabbrev: | |
4036 case CMD_iunabbrev: | |
4037 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
|
4038 TRUE, TRUE, ea.cmdidx); |
7 | 4039 #ifdef FEAT_MENU |
4040 case CMD_menu: case CMD_noremenu: case CMD_unmenu: | |
4041 case CMD_amenu: case CMD_anoremenu: case CMD_aunmenu: | |
4042 case CMD_nmenu: case CMD_nnoremenu: case CMD_nunmenu: | |
4043 case CMD_vmenu: case CMD_vnoremenu: case CMD_vunmenu: | |
4044 case CMD_omenu: case CMD_onoremenu: case CMD_ounmenu: | |
4045 case CMD_imenu: case CMD_inoremenu: case CMD_iunmenu: | |
4046 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
|
4047 case CMD_tlmenu: case CMD_tlnoremenu: case CMD_tlunmenu: |
7 | 4048 case CMD_tmenu: case CMD_tunmenu: |
4049 case CMD_popup: case CMD_tearoff: case CMD_emenu: | |
4050 return set_context_in_menu_cmd(xp, cmd, arg, forceit); | |
4051 #endif | |
4052 | |
4053 case CMD_colorscheme: | |
4054 xp->xp_context = EXPAND_COLORS; | |
4055 xp->xp_pattern = arg; | |
4056 break; | |
4057 | |
4058 case CMD_compiler: | |
4059 xp->xp_context = EXPAND_COMPILER; | |
4060 xp->xp_pattern = arg; | |
4061 break; | |
4062 | |
2433
98b9a6b9e7d5
Add completion for ":ownsyntax" and improve completion for ":filetype".
Bram Moolenaar <bram@vim.org>
parents:
2406
diff
changeset
|
4063 case CMD_ownsyntax: |
98b9a6b9e7d5
Add completion for ":ownsyntax" and improve completion for ":filetype".
Bram Moolenaar <bram@vim.org>
parents:
2406
diff
changeset
|
4064 xp->xp_context = EXPAND_OWNSYNTAX; |
98b9a6b9e7d5
Add completion for ":ownsyntax" and improve completion for ":filetype".
Bram Moolenaar <bram@vim.org>
parents:
2406
diff
changeset
|
4065 xp->xp_pattern = arg; |
98b9a6b9e7d5
Add completion for ":ownsyntax" and improve completion for ":filetype".
Bram Moolenaar <bram@vim.org>
parents:
2406
diff
changeset
|
4066 break; |
98b9a6b9e7d5
Add completion for ":ownsyntax" and improve completion for ":filetype".
Bram Moolenaar <bram@vim.org>
parents:
2406
diff
changeset
|
4067 |
2406
bbff28ebfc7a
Add completion for :setfiletype. (Dominique Pelle)
Bram Moolenaar <bram@vim.org>
parents:
2405
diff
changeset
|
4068 case CMD_setfiletype: |
2268
aafed4a4866f
Command line completion for :ownsyntax. (Dominique Pelle)
Bram Moolenaar <bram@vim.org>
parents:
2250
diff
changeset
|
4069 xp->xp_context = EXPAND_FILETYPE; |
aafed4a4866f
Command line completion for :ownsyntax. (Dominique Pelle)
Bram Moolenaar <bram@vim.org>
parents:
2250
diff
changeset
|
4070 xp->xp_pattern = arg; |
aafed4a4866f
Command line completion for :ownsyntax. (Dominique Pelle)
Bram Moolenaar <bram@vim.org>
parents:
2250
diff
changeset
|
4071 break; |
aafed4a4866f
Command line completion for :ownsyntax. (Dominique Pelle)
Bram Moolenaar <bram@vim.org>
parents:
2250
diff
changeset
|
4072 |
8402
eed1ca42f9aa
commit https://github.com/vim/vim/commit/35ca0e7a1cb6e6daef8e0052a8437801226cef19
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
4073 case CMD_packadd: |
eed1ca42f9aa
commit https://github.com/vim/vim/commit/35ca0e7a1cb6e6daef8e0052a8437801226cef19
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
4074 xp->xp_context = EXPAND_PACKADD; |
eed1ca42f9aa
commit https://github.com/vim/vim/commit/35ca0e7a1cb6e6daef8e0052a8437801226cef19
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
4075 xp->xp_pattern = arg; |
eed1ca42f9aa
commit https://github.com/vim/vim/commit/35ca0e7a1cb6e6daef8e0052a8437801226cef19
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
4076 break; |
eed1ca42f9aa
commit https://github.com/vim/vim/commit/35ca0e7a1cb6e6daef8e0052a8437801226cef19
Christian Brabandt <cb@256bit.org>
parents:
8368
diff
changeset
|
4077 |
15597
536dd2bc5ac9
patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15595
diff
changeset
|
4078 #if defined(HAVE_LOCALE_H) || defined(X_LOCALE) |
7 | 4079 case CMD_language: |
2853 | 4080 p = skiptowhite(arg); |
4081 if (*p == NUL) | |
7 | 4082 { |
4083 xp->xp_context = EXPAND_LANGUAGE; | |
4084 xp->xp_pattern = arg; | |
4085 } | |
4086 else | |
2853 | 4087 { |
4088 if ( STRNCMP(arg, "messages", p - arg) == 0 | |
4089 || STRNCMP(arg, "ctype", p - arg) == 0 | |
4090 || STRNCMP(arg, "time", p - arg) == 0) | |
4091 { | |
4092 xp->xp_context = EXPAND_LOCALES; | |
4093 xp->xp_pattern = skipwhite(p); | |
4094 } | |
4095 else | |
4096 xp->xp_context = EXPAND_NOTHING; | |
4097 } | |
7 | 4098 break; |
4099 #endif | |
2068
98a2a6e6b966
updated for version 7.2.353
Bram Moolenaar <bram@zimbu.org>
parents:
1973
diff
changeset
|
4100 #if defined(FEAT_PROFILE) |
98a2a6e6b966
updated for version 7.2.353
Bram Moolenaar <bram@zimbu.org>
parents:
1973
diff
changeset
|
4101 case CMD_profile: |
98a2a6e6b966
updated for version 7.2.353
Bram Moolenaar <bram@zimbu.org>
parents:
1973
diff
changeset
|
4102 set_context_in_profile_cmd(xp, arg); |
98a2a6e6b966
updated for version 7.2.353
Bram Moolenaar <bram@zimbu.org>
parents:
1973
diff
changeset
|
4103 break; |
98a2a6e6b966
updated for version 7.2.353
Bram Moolenaar <bram@zimbu.org>
parents:
1973
diff
changeset
|
4104 #endif |
2097
8f72e3512b43
updated for version 7.2.381
Bram Moolenaar <bram@zimbu.org>
parents:
2068
diff
changeset
|
4105 case CMD_behave: |
8f72e3512b43
updated for version 7.2.381
Bram Moolenaar <bram@zimbu.org>
parents:
2068
diff
changeset
|
4106 xp->xp_context = EXPAND_BEHAVE; |
3503 | 4107 xp->xp_pattern = arg; |
2097
8f72e3512b43
updated for version 7.2.381
Bram Moolenaar <bram@zimbu.org>
parents:
2068
diff
changeset
|
4108 break; |
7 | 4109 |
10275
6d8b2da002e9
commit https://github.com/vim/vim/commit/9e507ca8a3e1535e62de4bd86374b0fcd18ef5b8
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
4110 case CMD_messages: |
6d8b2da002e9
commit https://github.com/vim/vim/commit/9e507ca8a3e1535e62de4bd86374b0fcd18ef5b8
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
4111 xp->xp_context = EXPAND_MESSAGES; |
6d8b2da002e9
commit https://github.com/vim/vim/commit/9e507ca8a3e1535e62de4bd86374b0fcd18ef5b8
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
4112 xp->xp_pattern = arg; |
6d8b2da002e9
commit https://github.com/vim/vim/commit/9e507ca8a3e1535e62de4bd86374b0fcd18ef5b8
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
4113 break; |
6d8b2da002e9
commit https://github.com/vim/vim/commit/9e507ca8a3e1535e62de4bd86374b0fcd18ef5b8
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
4114 |
3503 | 4115 case CMD_history: |
4116 xp->xp_context = EXPAND_HISTORY; | |
4117 xp->xp_pattern = arg; | |
4118 break; | |
4803
220bdea4f579
updated for version 7.3.1148
Bram Moolenaar <bram@vim.org>
parents:
4766
diff
changeset
|
4119 #if defined(FEAT_PROFILE) |
220bdea4f579
updated for version 7.3.1148
Bram Moolenaar <bram@vim.org>
parents:
4766
diff
changeset
|
4120 case CMD_syntime: |
220bdea4f579
updated for version 7.3.1148
Bram Moolenaar <bram@vim.org>
parents:
4766
diff
changeset
|
4121 xp->xp_context = EXPAND_SYNTIME; |
220bdea4f579
updated for version 7.3.1148
Bram Moolenaar <bram@vim.org>
parents:
4766
diff
changeset
|
4122 xp->xp_pattern = arg; |
220bdea4f579
updated for version 7.3.1148
Bram Moolenaar <bram@vim.org>
parents:
4766
diff
changeset
|
4123 break; |
220bdea4f579
updated for version 7.3.1148
Bram Moolenaar <bram@vim.org>
parents:
4766
diff
changeset
|
4124 #endif |
3503 | 4125 |
13551
1fd0f8392946
patch 8.0.1649: no completion for argument list commands
Christian Brabandt <cb@256bit.org>
parents:
13442
diff
changeset
|
4126 case CMD_argdelete: |
1fd0f8392946
patch 8.0.1649: no completion for argument list commands
Christian Brabandt <cb@256bit.org>
parents:
13442
diff
changeset
|
4127 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
|
4128 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
|
4129 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
|
4130 xp->xp_pattern = arg; |
1fd0f8392946
patch 8.0.1649: no completion for argument list commands
Christian Brabandt <cb@256bit.org>
parents:
13442
diff
changeset
|
4131 break; |
1fd0f8392946
patch 8.0.1649: no completion for argument list commands
Christian Brabandt <cb@256bit.org>
parents:
13442
diff
changeset
|
4132 |
7 | 4133 default: |
4134 break; | |
4135 } | |
4136 return NULL; | |
4137 } | |
4138 | |
4139 /* | |
14505
3f1a17863b73
patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents:
14479
diff
changeset
|
4140 * Skip a range specifier of the form: addr [,addr] [;addr] .. |
7 | 4141 * |
4142 * Backslashed delimiters after / or ? will be skipped, and commands will | |
4143 * not be expanded between /'s and ?'s or after "'". | |
4144 * | |
167 | 4145 * Also skip white space and ":" characters. |
7 | 4146 * Returns the "cmd" pointer advanced to beyond the range. |
4147 */ | |
4148 char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4149 skip_range( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4150 char_u *cmd, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4151 int *ctx) /* pointer to xp_context or NULL */ |
7 | 4152 { |
1872 | 4153 unsigned delim; |
7 | 4154 |
10817
cc8079703414
patch 8.0.0298: Ex command range with repeated search does not work
Christian Brabandt <cb@256bit.org>
parents:
10809
diff
changeset
|
4155 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
|
4156 { |
cc8079703414
patch 8.0.0298: Ex command range with repeated search does not work
Christian Brabandt <cb@256bit.org>
parents:
10809
diff
changeset
|
4157 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
|
4158 { |
cc8079703414
patch 8.0.0298: Ex command range with repeated search does not work
Christian Brabandt <cb@256bit.org>
parents:
10809
diff
changeset
|
4159 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
|
4160 ++cmd; |
cc8079703414
patch 8.0.0298: Ex command range with repeated search does not work
Christian Brabandt <cb@256bit.org>
parents:
10809
diff
changeset
|
4161 else |
cc8079703414
patch 8.0.0298: Ex command range with repeated search does not work
Christian Brabandt <cb@256bit.org>
parents:
10809
diff
changeset
|
4162 break; |
cc8079703414
patch 8.0.0298: Ex command range with repeated search does not work
Christian Brabandt <cb@256bit.org>
parents:
10809
diff
changeset
|
4163 } |
cc8079703414
patch 8.0.0298: Ex command range with repeated search does not work
Christian Brabandt <cb@256bit.org>
parents:
10809
diff
changeset
|
4164 else if (*cmd == '\'') |
7 | 4165 { |
4166 if (*++cmd == NUL && ctx != NULL) | |
4167 *ctx = EXPAND_NOTHING; | |
4168 } | |
4169 else if (*cmd == '/' || *cmd == '?') | |
4170 { | |
4171 delim = *cmd++; | |
4172 while (*cmd != NUL && *cmd != delim) | |
4173 if (*cmd++ == '\\' && *cmd != NUL) | |
4174 ++cmd; | |
4175 if (*cmd == NUL && ctx != NULL) | |
4176 *ctx = EXPAND_NOTHING; | |
4177 } | |
4178 if (*cmd != NUL) | |
4179 ++cmd; | |
4180 } | |
167 | 4181 |
4182 /* Skip ":" and white space. */ | |
4183 while (*cmd == ':') | |
4184 cmd = skipwhite(cmd + 1); | |
4185 | |
7 | 4186 return cmd; |
4187 } | |
4188 | |
17650
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
4189 static void |
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
4190 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
|
4191 { |
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
4192 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
|
4193 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
|
4194 else |
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
4195 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
|
4196 } |
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
4197 |
7 | 4198 /* |
14677
7771a1ff8b99
patch 8.1.0351: 'incsearch' for :/foo/s//<Esc> changes last search pattern
Christian Brabandt <cb@256bit.org>
parents:
14648
diff
changeset
|
4199 * Get a single EX address. |
7 | 4200 * |
4201 * Set ptr to the next character after the part that was interpreted. | |
4202 * 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
|
4203 * This may set the last used search pattern. |
7 | 4204 * |
4205 * Return MAXLNUM when no Ex address was found. | |
4206 */ | |
4207 static linenr_T | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4208 get_address( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4209 exarg_T *eap UNUSED, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4210 char_u **ptr, |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
4211 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
|
4212 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
|
4213 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
|
4214 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
|
4215 int address_count UNUSED) // 1 for first address, >1 after comma |
7 | 4216 { |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
4217 cmd_addr_T addr_type = addr_type_arg; |
7 | 4218 int c; |
4219 int i; | |
4220 long n; | |
4221 char_u *cmd; | |
4222 pos_T pos; | |
4223 pos_T *fp; | |
4224 linenr_T lnum; | |
6424 | 4225 buf_T *buf; |
7 | 4226 |
4227 cmd = skipwhite(*ptr); | |
4228 lnum = MAXLNUM; | |
4229 do | |
4230 { | |
4231 switch (*cmd) | |
4232 { | |
4233 case '.': /* '.' - Cursor position */ | |
6398 | 4234 ++cmd; |
4235 switch (addr_type) | |
4236 { | |
4237 case ADDR_LINES: | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
4238 case ADDR_OTHER: |
7 | 4239 lnum = curwin->w_cursor.lnum; |
4240 break; | |
6398 | 4241 case ADDR_WINDOWS: |
6409 | 4242 lnum = CURRENT_WIN_NR; |
6398 | 4243 break; |
4244 case ADDR_ARGUMENTS: | |
4245 lnum = curwin->w_arg_idx + 1; | |
4246 break; | |
4247 case ADDR_LOADED_BUFFERS: | |
6424 | 4248 case ADDR_BUFFERS: |
6398 | 4249 lnum = curbuf->b_fnum; |
4250 break; | |
4251 case ADDR_TABS: | |
6409 | 4252 lnum = CURRENT_TAB_NR; |
6398 | 4253 break; |
17650
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
4254 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
|
4255 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
|
4256 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
|
4257 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
|
4258 cmd = NULL; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
4259 goto error; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
4260 break; |
16479
7dcf301d1432
patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents:
16475
diff
changeset
|
4261 case ADDR_QUICKFIX: |
7105
f4456e686406
commit https://github.com/vim/vim/commit/e906c502079770ae0e0071c74cefb802689ff193
Christian Brabandt <cb@256bit.org>
parents:
7092
diff
changeset
|
4262 #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
|
4263 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
|
4264 #endif |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
4265 break; |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
4266 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
|
4267 #ifdef FEAT_QUICKFIX |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
4268 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
|
4269 #endif |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
4270 break; |
6398 | 4271 } |
4272 break; | |
7 | 4273 |
4274 case '$': /* '$' - last line */ | |
6398 | 4275 ++cmd; |
4276 switch (addr_type) | |
4277 { | |
4278 case ADDR_LINES: | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
4279 case ADDR_OTHER: |
7 | 4280 lnum = curbuf->b_ml.ml_line_count; |
4281 break; | |
6398 | 4282 case ADDR_WINDOWS: |
6409 | 4283 lnum = LAST_WIN_NR; |
6398 | 4284 break; |
4285 case ADDR_ARGUMENTS: | |
4286 lnum = ARGCOUNT; | |
4287 break; | |
4288 case ADDR_LOADED_BUFFERS: | |
6424 | 4289 buf = lastbuf; |
4290 while (buf->b_ml.ml_mfp == NULL) | |
4291 { | |
4292 if (buf->b_prev == NULL) | |
4293 break; | |
4294 buf = buf->b_prev; | |
4295 } | |
4296 lnum = buf->b_fnum; | |
4297 break; | |
4298 case ADDR_BUFFERS: | |
6398 | 4299 lnum = lastbuf->b_fnum; |
4300 break; | |
4301 case ADDR_TABS: | |
6409 | 4302 lnum = LAST_TAB_NR; |
6398 | 4303 break; |
17650
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
4304 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
|
4305 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
|
4306 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
|
4307 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
|
4308 cmd = NULL; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
4309 goto error; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
4310 break; |
16479
7dcf301d1432
patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents:
16475
diff
changeset
|
4311 case ADDR_QUICKFIX: |
7105
f4456e686406
commit https://github.com/vim/vim/commit/e906c502079770ae0e0071c74cefb802689ff193
Christian Brabandt <cb@256bit.org>
parents:
7092
diff
changeset
|
4312 #ifdef FEAT_QUICKFIX |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
4313 lnum = qf_get_size(eap); |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
4314 if (lnum == 0) |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
4315 lnum = 1; |
16479
7dcf301d1432
patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents:
16475
diff
changeset
|
4316 #endif |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
4317 break; |
16515
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
4318 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
|
4319 #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
|
4320 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
|
4321 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
|
4322 lnum = 1; |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
4323 #endif |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
4324 break; |
6398 | 4325 } |
4326 break; | |
7 | 4327 |
4328 case '\'': /* ''' - mark */ | |
6398 | 4329 if (*++cmd == NUL) |
4330 { | |
4331 cmd = NULL; | |
4332 goto error; | |
4333 } | |
4334 if (addr_type != ADDR_LINES) | |
4335 { | |
17650
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
4336 addr_error(addr_type); |
6581 | 4337 cmd = NULL; |
6398 | 4338 goto error; |
4339 } | |
4340 if (skip) | |
4341 ++cmd; | |
4342 else | |
4343 { | |
4344 /* Only accept a mark in another file when it is | |
4345 * used by itself: ":'M". */ | |
4346 fp = getmark(*cmd, to_other_file && cmd[1] == NUL); | |
4347 ++cmd; | |
4348 if (fp == (pos_T *)-1) | |
4349 /* Jumped to another file. */ | |
4350 lnum = curwin->w_cursor.lnum; | |
4351 else | |
4352 { | |
4353 if (check_mark(fp) == FAIL) | |
7 | 4354 { |
4355 cmd = NULL; | |
4356 goto error; | |
4357 } | |
6398 | 4358 lnum = fp->lnum; |
4359 } | |
4360 } | |
4361 break; | |
7 | 4362 |
4363 case '/': | |
4364 case '?': /* '/' or '?' - search */ | |
6398 | 4365 c = *cmd++; |
4366 if (addr_type != ADDR_LINES) | |
4367 { | |
17650
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
4368 addr_error(addr_type); |
6581 | 4369 cmd = NULL; |
6398 | 4370 goto error; |
4371 } | |
4372 if (skip) /* skip "/pat/" */ | |
4373 { | |
4374 cmd = skip_regexp(cmd, c, (int)p_magic, NULL); | |
4375 if (*cmd == c) | |
4376 ++cmd; | |
4377 } | |
4378 else | |
4379 { | |
14760
fd69edd2c67e
patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents:
14700
diff
changeset
|
4380 int flags; |
fd69edd2c67e
patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents:
14700
diff
changeset
|
4381 |
fd69edd2c67e
patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents:
14700
diff
changeset
|
4382 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
|
4383 |
fd69edd2c67e
patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents:
14700
diff
changeset
|
4384 // 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
|
4385 // there. |
6398 | 4386 if (lnum != MAXLNUM) |
4387 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
|
4388 |
fd69edd2c67e
patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents:
14700
diff
changeset
|
4389 // 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
|
4390 // 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
|
4391 // 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
|
4392 // 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
|
4393 // 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
|
4394 // next/previous line. |
13082
a80082fd1a1d
patch 8.0.1416: crash when searching for a sentence
Christian Brabandt <cb@256bit.org>
parents:
12824
diff
changeset
|
4395 if (c == '/' && curwin->w_cursor.lnum > 0) |
6398 | 4396 curwin->w_cursor.col = MAXCOL; |
4397 else | |
4398 curwin->w_cursor.col = 0; | |
4399 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
|
4400 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
|
4401 if (!do_search(NULL, c, cmd, 1L, flags, NULL, NULL)) |
6398 | 4402 { |
4403 curwin->w_cursor = pos; | |
4404 cmd = NULL; | |
4405 goto error; | |
4406 } | |
4407 lnum = curwin->w_cursor.lnum; | |
4408 curwin->w_cursor = pos; | |
4409 /* adjust command string pointer */ | |
4410 cmd += searchcmdlen; | |
4411 } | |
4412 break; | |
7 | 4413 |
4414 case '\\': /* "\?", "\/" or "\&", repeat search */ | |
6398 | 4415 ++cmd; |
4416 if (addr_type != ADDR_LINES) | |
4417 { | |
17650
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
4418 addr_error(addr_type); |
6581 | 4419 cmd = NULL; |
6398 | 4420 goto error; |
4421 } | |
4422 if (*cmd == '&') | |
4423 i = RE_SUBST; | |
4424 else if (*cmd == '?' || *cmd == '/') | |
4425 i = RE_SEARCH; | |
4426 else | |
4427 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
4428 emsg(_(e_backslash)); |
6398 | 4429 cmd = NULL; |
4430 goto error; | |
4431 } | |
4432 | |
4433 if (!skip) | |
4434 { | |
4435 /* | |
4436 * When search follows another address, start from | |
4437 * there. | |
4438 */ | |
4439 if (lnum != MAXLNUM) | |
4440 pos.lnum = lnum; | |
4441 else | |
4442 pos.lnum = curwin->w_cursor.lnum; | |
4443 | |
4444 /* | |
4445 * Start the search just like for the above | |
4446 * do_search(). | |
4447 */ | |
4448 if (*cmd != '?') | |
4449 pos.col = MAXCOL; | |
4450 else | |
4451 pos.col = 0; | |
7007 | 4452 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
|
4453 if (searchit(curwin, curbuf, &pos, NULL, |
6398 | 4454 *cmd == '?' ? BACKWARD : FORWARD, |
4455 (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
|
4456 i, (linenr_T)0, NULL, NULL) != FAIL) |
6398 | 4457 lnum = pos.lnum; |
4458 else | |
4459 { | |
4460 cmd = NULL; | |
4461 goto error; | |
4462 } | |
4463 } | |
4464 ++cmd; | |
4465 break; | |
7 | 4466 |
4467 default: | |
6398 | 4468 if (VIM_ISDIGIT(*cmd)) /* absolute line number */ |
4469 lnum = getdigits(&cmd); | |
7 | 4470 } |
4471 | |
4472 for (;;) | |
4473 { | |
4474 cmd = skipwhite(cmd); | |
4475 if (*cmd != '-' && *cmd != '+' && !VIM_ISDIGIT(*cmd)) | |
4476 break; | |
4477 | |
4478 if (lnum == MAXLNUM) | |
6398 | 4479 { |
4480 switch (addr_type) | |
4481 { | |
4482 case ADDR_LINES: | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
4483 case ADDR_OTHER: |
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
4484 // "+1" is same as ".+1" |
6409 | 4485 lnum = curwin->w_cursor.lnum; |
6398 | 4486 break; |
4487 case ADDR_WINDOWS: | |
6409 | 4488 lnum = CURRENT_WIN_NR; |
6398 | 4489 break; |
4490 case ADDR_ARGUMENTS: | |
4491 lnum = curwin->w_arg_idx + 1; | |
4492 break; | |
4493 case ADDR_LOADED_BUFFERS: | |
6424 | 4494 case ADDR_BUFFERS: |
6398 | 4495 lnum = curbuf->b_fnum; |
4496 break; | |
4497 case ADDR_TABS: | |
6409 | 4498 lnum = CURRENT_TAB_NR; |
6398 | 4499 break; |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
4500 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
|
4501 lnum = 1; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
4502 break; |
16479
7dcf301d1432
patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents:
16475
diff
changeset
|
4503 case ADDR_QUICKFIX: |
7105
f4456e686406
commit https://github.com/vim/vim/commit/e906c502079770ae0e0071c74cefb802689ff193
Christian Brabandt <cb@256bit.org>
parents:
7092
diff
changeset
|
4504 #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
|
4505 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
|
4506 #endif |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
4507 break; |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
4508 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
|
4509 #ifdef FEAT_QUICKFIX |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
4510 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
|
4511 #endif |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
4512 break; |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
4513 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
|
4514 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
|
4515 lnum = 0; |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
4516 break; |
6398 | 4517 } |
4518 } | |
4519 | |
7 | 4520 if (VIM_ISDIGIT(*cmd)) |
4521 i = '+'; /* "number" is same as "+number" */ | |
4522 else | |
4523 i = *cmd++; | |
4524 if (!VIM_ISDIGIT(*cmd)) /* '+' is '+1', but '+0' is not '+1' */ | |
4525 n = 1; | |
4526 else | |
4527 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
|
4528 |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
4529 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
|
4530 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
4531 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
|
4532 cmd = NULL; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
4533 goto error; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
4534 } |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
4535 else if (addr_type == ADDR_LOADED_BUFFERS |
6424 | 4536 || addr_type == ADDR_BUFFERS) |
6581 | 4537 lnum = compute_buffer_local_count( |
4538 addr_type, lnum, (i == '-') ? -1 * n : n); | |
7 | 4539 else |
10484
c7de1536780a
commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
10480
diff
changeset
|
4540 { |
c7de1536780a
commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
10480
diff
changeset
|
4541 #ifdef FEAT_FOLDING |
c7de1536780a
commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
10480
diff
changeset
|
4542 /* 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
|
4543 * 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
|
4544 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
|
4545 && address_count >= 2) |
c7de1536780a
commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
10480
diff
changeset
|
4546 (void)hasFolding(lnum, NULL, &lnum); |
c7de1536780a
commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
10480
diff
changeset
|
4547 #endif |
c7de1536780a
commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
10480
diff
changeset
|
4548 if (i == '-') |
c7de1536780a
commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
10480
diff
changeset
|
4549 lnum -= n; |
c7de1536780a
commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
10480
diff
changeset
|
4550 else |
c7de1536780a
commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
10480
diff
changeset
|
4551 lnum += n; |
c7de1536780a
commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents:
10480
diff
changeset
|
4552 } |
7 | 4553 } |
4554 } while (*cmd == '/' || *cmd == '?'); | |
4555 | |
4556 error: | |
4557 *ptr = cmd; | |
4558 return lnum; | |
4559 } | |
4560 | |
4561 /* | |
167 | 4562 * Get flags from an Ex command argument. |
4563 */ | |
4564 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4565 get_flags(exarg_T *eap) |
167 | 4566 { |
4567 while (vim_strchr((char_u *)"lp#", *eap->arg) != NULL) | |
4568 { | |
4569 if (*eap->arg == 'l') | |
4570 eap->flags |= EXFLAG_LIST; | |
4571 else if (*eap->arg == 'p') | |
4572 eap->flags |= EXFLAG_PRINT; | |
4573 else | |
4574 eap->flags |= EXFLAG_NR; | |
4575 eap->arg = skipwhite(eap->arg + 1); | |
4576 } | |
4577 } | |
4578 | |
4579 /* | |
7 | 4580 * Function called for command which is Not Implemented. NI! |
4581 */ | |
4582 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4583 ex_ni(exarg_T *eap) |
7 | 4584 { |
4585 if (!eap->skip) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
4586 eap->errmsg = N_("E319: Sorry, the command is not available in this version"); |
7 | 4587 } |
4588 | |
1315 | 4589 #ifdef HAVE_EX_SCRIPT_NI |
7 | 4590 /* |
4591 * Function called for script command which is Not Implemented. NI! | |
4592 * Skips over ":perl <<EOF" constructs. | |
4593 */ | |
4594 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4595 ex_script_ni(exarg_T *eap) |
7 | 4596 { |
4597 if (!eap->skip) | |
4598 ex_ni(eap); | |
4599 else | |
4600 vim_free(script_get(eap, eap->arg)); | |
4601 } | |
4602 #endif | |
4603 | |
4604 /* | |
4605 * Check range in Ex command for validity. | |
4606 * Return NULL when valid, error message when invalid. | |
4607 */ | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
4608 static char * |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4609 invalid_range(exarg_T *eap) |
7 | 4610 { |
6472 | 4611 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
|
4612 |
7 | 4613 if ( eap->line1 < 0 |
4614 || eap->line2 < 0 | |
6472 | 4615 || 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
|
4616 return _(e_invrange); |
6472 | 4617 |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
4618 if (eap->argt & EX_RANGE) |
6472 | 4619 { |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
4620 switch (eap->addr_type) |
6472 | 4621 { |
4622 case ADDR_LINES: | |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
4623 if (eap->line2 > curbuf->b_ml.ml_line_count |
7 | 4624 #ifdef FEAT_DIFF |
6472 | 4625 + (eap->cmdidx == CMD_diffget) |
4626 #endif | |
4627 ) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
4628 return _(e_invrange); |
6472 | 4629 break; |
4630 case ADDR_ARGUMENTS: | |
6581 | 4631 /* add 1 if ARGCOUNT is 0 */ |
4632 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
|
4633 return _(e_invrange); |
6472 | 4634 break; |
4635 case ADDR_BUFFERS: | |
4636 if (eap->line1 < firstbuf->b_fnum | |
4637 || 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
|
4638 return _(e_invrange); |
6472 | 4639 break; |
4640 case ADDR_LOADED_BUFFERS: | |
4641 buf = firstbuf; | |
4642 while (buf->b_ml.ml_mfp == NULL) | |
4643 { | |
4644 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
|
4645 return _(e_invrange); |
6472 | 4646 buf = buf->b_next; |
4647 } | |
4648 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
|
4649 return _(e_invrange); |
6472 | 4650 buf = lastbuf; |
4651 while (buf->b_ml.ml_mfp == NULL) | |
4652 { | |
4653 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
|
4654 return _(e_invrange); |
6472 | 4655 buf = buf->b_prev; |
4656 } | |
4657 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
|
4658 return _(e_invrange); |
6472 | 4659 break; |
4660 case ADDR_WINDOWS: | |
6480 | 4661 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
|
4662 return _(e_invrange); |
6472 | 4663 break; |
4664 case ADDR_TABS: | |
4665 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
|
4666 return _(e_invrange); |
6472 | 4667 break; |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
4668 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
|
4669 case ADDR_OTHER: |
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
4670 // 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
|
4671 break; |
16479
7dcf301d1432
patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents:
16475
diff
changeset
|
4672 case ADDR_QUICKFIX: |
7105
f4456e686406
commit https://github.com/vim/vim/commit/e906c502079770ae0e0071c74cefb802689ff193
Christian Brabandt <cb@256bit.org>
parents:
7092
diff
changeset
|
4673 #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
|
4674 // 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
|
4675 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
|
4676 return _(e_invrange); |
16479
7dcf301d1432
patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents:
16475
diff
changeset
|
4677 #endif |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7007
diff
changeset
|
4678 break; |
16515
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
4679 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
|
4680 #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
|
4681 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
|
4682 || 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
|
4683 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
|
4684 #endif |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
4685 break; |
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16505
diff
changeset
|
4686 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
|
4687 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
|
4688 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
|
4689 break; |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
4690 case ADDR_NONE: |
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
16451
diff
changeset
|
4691 // 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
|
4692 break; |
6472 | 4693 } |
4694 } | |
7 | 4695 return NULL; |
4696 } | |
4697 | |
4698 /* | |
4699 * Correct the range for zero line number, if required. | |
4700 */ | |
4701 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4702 correct_range(exarg_T *eap) |
7 | 4703 { |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
4704 if (!(eap->argt & EX_ZEROR)) // zero in range not allowed |
7 | 4705 { |
4706 if (eap->line1 == 0) | |
4707 eap->line1 = 1; | |
4708 if (eap->line2 == 0) | |
4709 eap->line2 = 1; | |
4710 } | |
4711 } | |
4712 | |
153 | 4713 #ifdef FEAT_QUICKFIX |
4714 /* | |
4715 * For a ":vimgrep" or ":vimgrepadd" command return a pointer past the | |
4716 * pattern. Otherwise return eap->arg. | |
4717 */ | |
4718 static char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4719 skip_grep_pat(exarg_T *eap) |
153 | 4720 { |
4721 char_u *p = eap->arg; | |
4722 | |
655 | 4723 if (*p != NUL && (eap->cmdidx == CMD_vimgrep || eap->cmdidx == CMD_lvimgrep |
4724 || eap->cmdidx == CMD_vimgrepadd | |
4725 || eap->cmdidx == CMD_lvimgrepadd | |
4726 || grep_internal(eap->cmdidx))) | |
153 | 4727 { |
170 | 4728 p = skip_vimgrep_pat(p, NULL, NULL); |
153 | 4729 if (p == NULL) |
4730 p = eap->arg; | |
4731 } | |
4732 return p; | |
4733 } | |
344 | 4734 |
4735 /* | |
4736 * For the ":make" and ":grep" commands insert the 'makeprg'/'grepprg' option | |
4737 * in the command line, so that things like % get expanded. | |
4738 */ | |
4739 static char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4740 replace_makeprg(exarg_T *eap, char_u *p, char_u **cmdlinep) |
344 | 4741 { |
4742 char_u *new_cmdline; | |
4743 char_u *program; | |
4744 char_u *pos; | |
4745 char_u *ptr; | |
4746 int len; | |
4747 int i; | |
4748 | |
4749 /* | |
4750 * Don't do it when ":vimgrep" is used for ":grep". | |
4751 */ | |
655 | 4752 if ((eap->cmdidx == CMD_make || eap->cmdidx == CMD_lmake |
4753 || eap->cmdidx == CMD_grep || eap->cmdidx == CMD_lgrep | |
4754 || eap->cmdidx == CMD_grepadd | |
4755 || eap->cmdidx == CMD_lgrepadd) | |
344 | 4756 && !grep_internal(eap->cmdidx)) |
4757 { | |
655 | 4758 if (eap->cmdidx == CMD_grep || eap->cmdidx == CMD_lgrep |
4759 || eap->cmdidx == CMD_grepadd || eap->cmdidx == CMD_lgrepadd) | |
344 | 4760 { |
4761 if (*curbuf->b_p_gp == NUL) | |
4762 program = p_gp; | |
4763 else | |
4764 program = curbuf->b_p_gp; | |
4765 } | |
4766 else | |
4767 { | |
4768 if (*curbuf->b_p_mp == NUL) | |
4769 program = p_mp; | |
4770 else | |
4771 program = curbuf->b_p_mp; | |
4772 } | |
4773 | |
4774 p = skipwhite(p); | |
4775 | |
4776 if ((pos = (char_u *)strstr((char *)program, "$*")) != NULL) | |
4777 { | |
4778 /* replace $* by given arguments */ | |
4779 i = 1; | |
4780 while ((pos = (char_u *)strstr((char *)pos + 2, "$*")) != NULL) | |
4781 ++i; | |
4782 len = (int)STRLEN(p); | |
16782
fc58fee685e2
patch 8.1.1393: unnecessary type casts
Bram Moolenaar <Bram@vim.org>
parents:
16780
diff
changeset
|
4783 new_cmdline = alloc(STRLEN(program) + i * (len - 2) + 1); |
344 | 4784 if (new_cmdline == NULL) |
4785 return NULL; /* out of memory */ | |
4786 ptr = new_cmdline; | |
4787 while ((pos = (char_u *)strstr((char *)program, "$*")) != NULL) | |
4788 { | |
4789 i = (int)(pos - program); | |
4790 STRNCPY(ptr, program, i); | |
4791 STRCPY(ptr += i, p); | |
4792 ptr += len; | |
4793 program = pos + 2; | |
4794 } | |
4795 STRCPY(ptr, program); | |
4796 } | |
4797 else | |
4798 { | |
16782
fc58fee685e2
patch 8.1.1393: unnecessary type casts
Bram Moolenaar <Bram@vim.org>
parents:
16780
diff
changeset
|
4799 new_cmdline = alloc(STRLEN(program) + STRLEN(p) + 2); |
344 | 4800 if (new_cmdline == NULL) |
4801 return NULL; /* out of memory */ | |
4802 STRCPY(new_cmdline, program); | |
4803 STRCAT(new_cmdline, " "); | |
4804 STRCAT(new_cmdline, p); | |
4805 } | |
4806 msg_make(p); | |
4807 | |
4808 /* 'eap->cmd' is not set here, because it is not used at CMD_make */ | |
4809 vim_free(*cmdlinep); | |
4810 *cmdlinep = new_cmdline; | |
4811 p = new_cmdline; | |
4812 } | |
4813 return p; | |
4814 } | |
153 | 4815 #endif |
4816 | |
7 | 4817 /* |
4818 * 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
|
4819 * When an error is detected, "errormsgp" is set to a non-NULL pointer. |
7 | 4820 * Return FAIL for failure, OK otherwise. |
4821 */ | |
4822 int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4823 expand_filename( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4824 exarg_T *eap, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
4825 char_u **cmdlinep, |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
4826 char **errormsgp) |
7 | 4827 { |
4828 int has_wildcards; /* need to expand wildcards */ | |
4829 char_u *repl; | |
4830 int srclen; | |
4831 char_u *p; | |
4832 int n; | |
1098 | 4833 int escaped; |
7 | 4834 |
153 | 4835 #ifdef FEAT_QUICKFIX |
4836 /* Skip a regexp pattern for ":vimgrep[add] pat file..." */ | |
4837 p = skip_grep_pat(eap); | |
4838 #else | |
4839 p = eap->arg; | |
4840 #endif | |
4841 | |
7 | 4842 /* |
4843 * Decide to expand wildcards *before* replacing '%', '#', etc. If | |
4844 * the file name contains a wildcard it should not cause expanding. | |
4845 * (it will be expanded anyway if there is a wildcard before replacing). | |
4846 */ | |
153 | 4847 has_wildcards = mch_has_wildcard(p); |
4848 while (*p != NUL) | |
7 | 4849 { |
9 | 4850 #ifdef FEAT_EVAL |
4851 /* Skip over `=expr`, wildcards in it are not expanded. */ | |
4852 if (p[0] == '`' && p[1] == '=') | |
4853 { | |
4854 p += 2; | |
4855 (void)skip_expr(&p); | |
4856 if (*p == '`') | |
4857 ++p; | |
4858 continue; | |
4859 } | |
4860 #endif | |
7 | 4861 /* |
4862 * Quick check if this cannot be the start of a special string. | |
4863 * Also removes backslash before '%', '#' and '<'. | |
4864 */ | |
4865 if (vim_strchr((char_u *)"%#<", *p) == NULL) | |
4866 { | |
4867 ++p; | |
4868 continue; | |
4869 } | |
4870 | |
4871 /* | |
4872 * Try to find a match at this position. | |
4873 */ | |
1098 | 4874 repl = eval_vars(p, eap->arg, &srclen, &(eap->do_ecmd_lnum), |
4875 errormsgp, &escaped); | |
7 | 4876 if (*errormsgp != NULL) /* error detected */ |
4877 return FAIL; | |
4878 if (repl == NULL) /* no match found */ | |
4879 { | |
4880 p += srclen; | |
4881 continue; | |
4882 } | |
4883 | |
37 | 4884 /* Wildcards won't be expanded below, the replacement is taken |
4885 * literally. But do expand "~/file", "~user/file" and "$HOME/file". */ | |
4886 if (vim_strchr(repl, '$') != NULL || vim_strchr(repl, '~') != NULL) | |
4887 { | |
4888 char_u *l = repl; | |
4889 | |
4890 repl = expand_env_save(repl); | |
4891 vim_free(l); | |
4892 } | |
4893 | |
1098 | 4894 /* Need to escape white space et al. with a backslash. |
4895 * Don't do this for: | |
4896 * - replacement that already has been escaped: "##" | |
4897 * - shell commands (may have to use quotes instead). | |
4898 * - non-unix systems when there is a single argument (spaces don't | |
4899 * separate arguments then). | |
4900 */ | |
7 | 4901 if (!eap->usefilter |
1098 | 4902 && !escaped |
7 | 4903 && eap->cmdidx != CMD_bang |
4904 && 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
|
4905 && eap->cmdidx != CMD_grepadd |
1c1cb1e9b7b3
patch 8.0.0785: wildcards are not expanded for :terminal
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
4906 && eap->cmdidx != CMD_hardcopy |
655 | 4907 && eap->cmdidx != CMD_lgrep |
4908 && 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
|
4909 && eap->cmdidx != CMD_lmake |
1c1cb1e9b7b3
patch 8.0.0785: wildcards are not expanded for :terminal
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
4910 && eap->cmdidx != CMD_make |
1c1cb1e9b7b3
patch 8.0.0785: wildcards are not expanded for :terminal
Christian Brabandt <cb@256bit.org>
parents:
11757
diff
changeset
|
4911 && eap->cmdidx != CMD_terminal |
7 | 4912 #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
|
4913 && !(eap->argt & EX_NOSPC) |
7 | 4914 #endif |
4915 ) | |
4916 { | |
4917 char_u *l; | |
4918 #ifdef BACKSLASH_IN_FILENAME | |
4919 /* Don't escape a backslash here, because rem_backslash() doesn't | |
4920 * remove it later. */ | |
4921 static char_u *nobslash = (char_u *)" \t\"|"; | |
4922 # define ESCAPE_CHARS nobslash | |
4923 #else | |
4924 # define ESCAPE_CHARS escape_chars | |
4925 #endif | |
4926 | |
4927 for (l = repl; *l; ++l) | |
4928 if (vim_strchr(ESCAPE_CHARS, *l) != NULL) | |
4929 { | |
4930 l = vim_strsave_escaped(repl, ESCAPE_CHARS); | |
4931 if (l != NULL) | |
4932 { | |
4933 vim_free(repl); | |
4934 repl = l; | |
4935 } | |
4936 break; | |
4937 } | |
4938 } | |
4939 | |
4940 /* 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
|
4941 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
|
4942 || eap->cmdidx == CMD_terminal) |
5778 | 4943 && vim_strpbrk(repl, (char_u *)"!") != NULL) |
7 | 4944 { |
4945 char_u *l; | |
4946 | |
5778 | 4947 l = vim_strsave_escaped(repl, (char_u *)"!"); |
7 | 4948 if (l != NULL) |
4949 { | |
4950 vim_free(repl); | |
4951 repl = l; | |
4952 } | |
4953 } | |
4954 | |
4955 p = repl_cmdline(eap, p, srclen, repl, cmdlinep); | |
4956 vim_free(repl); | |
4957 if (p == NULL) | |
4958 return FAIL; | |
4959 } | |
4960 | |
4961 /* | |
4962 * One file argument: Expand wildcards. | |
4963 * Don't do this with ":r !command" or ":w !command". | |
4964 */ | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
4965 if ((eap->argt & EX_NOSPC) && !eap->usefilter) |
7 | 4966 { |
4967 /* | |
4968 * May do this twice: | |
4969 * 1. Replace environment variables. | |
4970 * 2. Replace any other wildcards, remove backslashes. | |
4971 */ | |
4972 for (n = 1; n <= 2; ++n) | |
4973 { | |
4974 if (n == 2) | |
4975 { | |
4976 /* | |
4977 * Halve the number of backslashes (this is Vi compatible). | |
4978 * For Unix and OS/2, when wildcards are expanded, this is | |
4979 * done by ExpandOne() below. | |
4980 */ | |
7408
1886f2863437
commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents:
7262
diff
changeset
|
4981 #if defined(UNIX) |
7 | 4982 if (!has_wildcards) |
4983 #endif | |
4984 backslash_halve(eap->arg); | |
4985 } | |
4986 | |
4987 if (has_wildcards) | |
4988 { | |
4989 if (n == 1) | |
4990 { | |
4991 /* | |
4992 * First loop: May expand environment variables. This | |
4993 * can be done much faster with expand_env() than with | |
4994 * something else (e.g., calling a shell). | |
4995 * After expanding environment variables, check again | |
4996 * if there are still wildcards present. | |
4997 */ | |
4998 if (vim_strchr(eap->arg, '$') != NULL | |
4999 || vim_strchr(eap->arg, '~') != NULL) | |
5000 { | |
372 | 5001 expand_env_esc(eap->arg, NameBuff, MAXPATHL, |
1408 | 5002 TRUE, TRUE, NULL); |
7 | 5003 has_wildcards = mch_has_wildcard(NameBuff); |
5004 p = NameBuff; | |
5005 } | |
5006 else | |
5007 p = NULL; | |
5008 } | |
5009 else /* n == 2 */ | |
5010 { | |
5011 expand_T xpc; | |
2652 | 5012 int options = WILD_LIST_NOTFOUND|WILD_ADD_SLASH; |
7 | 5013 |
5014 ExpandInit(&xpc); | |
5015 xpc.xp_context = EXPAND_FILES; | |
2652 | 5016 if (p_wic) |
5017 options += WILD_ICASE; | |
7 | 5018 p = ExpandOne(&xpc, eap->arg, NULL, |
2652 | 5019 options, WILD_EXPAND_FREE); |
7 | 5020 if (p == NULL) |
5021 return FAIL; | |
5022 } | |
5023 if (p != NULL) | |
5024 { | |
5025 (void)repl_cmdline(eap, eap->arg, (int)STRLEN(eap->arg), | |
5026 p, cmdlinep); | |
5027 if (n == 2) /* p came from ExpandOne() */ | |
5028 vim_free(p); | |
5029 } | |
5030 } | |
5031 } | |
5032 } | |
5033 return OK; | |
5034 } | |
5035 | |
5036 /* | |
5037 * Replace part of the command line, keeping eap->cmd, eap->arg and | |
5038 * eap->nextcmd correct. | |
5039 * "src" points to the part that is to be replaced, of length "srclen". | |
5040 * "repl" is the replacement string. | |
5041 * Returns a pointer to the character after the replaced string. | |
5042 * Returns NULL for failure. | |
5043 */ | |
5044 static char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5045 repl_cmdline( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5046 exarg_T *eap, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5047 char_u *src, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5048 int srclen, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5049 char_u *repl, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5050 char_u **cmdlinep) |
7 | 5051 { |
5052 int len; | |
5053 int i; | |
5054 char_u *new_cmdline; | |
5055 | |
5056 /* | |
5057 * The new command line is build in new_cmdline[]. | |
5058 * First allocate it. | |
5059 * Careful: a "+cmd" argument may have been NUL terminated. | |
5060 */ | |
5061 len = (int)STRLEN(repl); | |
5062 i = (int)(src - *cmdlinep) + (int)STRLEN(src + srclen) + len + 3; | |
698 | 5063 if (eap->nextcmd != NULL) |
7 | 5064 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
|
5065 if ((new_cmdline = alloc(i)) == NULL) |
7 | 5066 return NULL; /* out of memory! */ |
5067 | |
5068 /* | |
5069 * Copy the stuff before the expanded part. | |
5070 * Copy the expanded stuff. | |
5071 * Copy what came after the expanded part. | |
5072 * Copy the next commands, if there are any. | |
5073 */ | |
5074 i = (int)(src - *cmdlinep); /* length of part before match */ | |
5075 mch_memmove(new_cmdline, *cmdlinep, (size_t)i); | |
434 | 5076 |
7 | 5077 mch_memmove(new_cmdline + i, repl, (size_t)len); |
5078 i += len; /* remember the end of the string */ | |
5079 STRCPY(new_cmdline + i, src + srclen); | |
5080 src = new_cmdline + i; /* remember where to continue */ | |
5081 | |
698 | 5082 if (eap->nextcmd != NULL) /* append next command */ |
7 | 5083 { |
5084 i = (int)STRLEN(new_cmdline) + 1; | |
5085 STRCPY(new_cmdline + i, eap->nextcmd); | |
5086 eap->nextcmd = new_cmdline + i; | |
5087 } | |
5088 eap->cmd = new_cmdline + (eap->cmd - *cmdlinep); | |
5089 eap->arg = new_cmdline + (eap->arg - *cmdlinep); | |
5090 if (eap->do_ecmd_cmd != NULL && eap->do_ecmd_cmd != dollar_command) | |
5091 eap->do_ecmd_cmd = new_cmdline + (eap->do_ecmd_cmd - *cmdlinep); | |
5092 vim_free(*cmdlinep); | |
5093 *cmdlinep = new_cmdline; | |
5094 | |
5095 return src; | |
5096 } | |
5097 | |
5098 /* | |
5099 * Check for '|' to separate commands and '"' to start comments. | |
5100 */ | |
5101 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5102 separate_nextcmd(exarg_T *eap) |
7 | 5103 { |
5104 char_u *p; | |
5105 | |
153 | 5106 #ifdef FEAT_QUICKFIX |
5107 p = skip_grep_pat(eap); | |
5108 #else | |
41 | 5109 p = eap->arg; |
5110 #endif | |
5111 | |
11127
506f5d8b7d8b
patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11010
diff
changeset
|
5112 for ( ; *p; MB_PTR_ADV(p)) |
7 | 5113 { |
5114 if (*p == Ctrl_V) | |
5115 { | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
5116 if (eap->argt & (EX_CTRLV | EX_XFILE)) |
7 | 5117 ++p; /* skip CTRL-V and next char */ |
5118 else | |
1362 | 5119 /* remove CTRL-V and skip next char */ |
1619 | 5120 STRMOVE(p, p + 1); |
7 | 5121 if (*p == NUL) /* stop at NUL after CTRL-V */ |
5122 break; | |
5123 } | |
9 | 5124 |
5125 #ifdef FEAT_EVAL | |
5126 /* 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
|
5127 else if (p[0] == '`' && p[1] == '=' && (eap->argt & EX_XFILE)) |
9 | 5128 { |
5129 p += 2; | |
5130 (void)skip_expr(&p); | |
5131 } | |
5132 #endif | |
5133 | |
7 | 5134 /* Check for '"': start of comment or '|': next command */ |
5135 /* :@" and :*" do not start a comment! | |
5136 * :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
|
5137 else if ((*p == '"' && !(eap->argt & EX_NOTRLCOM) |
7 | 5138 && ((eap->cmdidx != CMD_at && eap->cmdidx != CMD_star) |
5139 || p != eap->arg) | |
5140 && (eap->cmdidx != CMD_redir | |
5141 || p != eap->arg + 1 || p[-1] != '@')) | |
5142 || *p == '|' || *p == '\n') | |
5143 { | |
5144 /* | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
5145 * We remove the '\' before the '|', unless EX_CTRLV is used |
7 | 5146 * AND 'b' is present in 'cpoptions'. |
5147 */ | |
5148 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
|
5149 || !(eap->argt & EX_CTRLV)) && *(p - 1) == '\\') |
7 | 5150 { |
1619 | 5151 STRMOVE(p - 1, p); /* remove the '\' */ |
7 | 5152 --p; |
5153 } | |
5154 else | |
5155 { | |
5156 eap->nextcmd = check_nextcmd(p); | |
5157 *p = NUL; | |
5158 break; | |
5159 } | |
5160 } | |
41 | 5161 } |
5162 | |
17336
81705f4d9e03
patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents:
17178
diff
changeset
|
5163 if (!(eap->argt & EX_NOTRLCOM)) /* remove trailing spaces */ |
7 | 5164 del_trailing_spaces(eap->arg); |
5165 } | |
5166 | |
5167 /* | |
5168 * get + command from ex argument | |
5169 */ | |
5170 static char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5171 getargcmd(char_u **argp) |
7 | 5172 { |
5173 char_u *arg = *argp; | |
5174 char_u *command = NULL; | |
5175 | |
5176 if (*arg == '+') /* +[command] */ | |
5177 { | |
5178 ++arg; | |
5790 | 5179 if (vim_isspace(*arg) || *arg == NUL) |
7 | 5180 command = dollar_command; |
5181 else | |
5182 { | |
5183 command = arg; | |
5184 arg = skip_cmd_arg(command, TRUE); | |
5185 if (*arg != NUL) | |
5186 *arg++ = NUL; /* terminate command with NUL */ | |
5187 } | |
5188 | |
5189 arg = skipwhite(arg); /* skip over spaces */ | |
5190 *argp = arg; | |
5191 } | |
5192 return command; | |
5193 } | |
5194 | |
5195 /* | |
5196 * Find end of "+command" argument. Skip over "\ " and "\\". | |
5197 */ | |
5198 static char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5199 skip_cmd_arg( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5200 char_u *p, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5201 int rembs) /* TRUE to halve the number of backslashes */ |
7 | 5202 { |
5203 while (*p && !vim_isspace(*p)) | |
5204 { | |
5205 if (*p == '\\' && p[1] != NUL) | |
5206 { | |
5207 if (rembs) | |
1619 | 5208 STRMOVE(p, p + 1); |
7 | 5209 else |
5210 ++p; | |
5211 } | |
11127
506f5d8b7d8b
patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11010
diff
changeset
|
5212 MB_PTR_ADV(p); |
7 | 5213 } |
5214 return p; | |
5215 } | |
5216 | |
13575
4df23d9bad47
patch 8.0.1660: the terminal API "drop" command doesn't support options
Christian Brabandt <cb@256bit.org>
parents:
13553
diff
changeset
|
5217 int |
4df23d9bad47
patch 8.0.1660: the terminal API "drop" command doesn't support options
Christian Brabandt <cb@256bit.org>
parents:
13553
diff
changeset
|
5218 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
|
5219 { |
4df23d9bad47
patch 8.0.1660: the terminal API "drop" command doesn't support options
Christian Brabandt <cb@256bit.org>
parents:
13553
diff
changeset
|
5220 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
|
5221 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
|
5222 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
|
5223 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
|
5224 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
|
5225 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
|
5226 else |
c1ead25ed819
patch 8.1.0043: ++bad argument of :edit does not work properly
Christian Brabandt <cb@256bit.org>
parents:
14035
diff
changeset
|
5227 return FAIL; |
c1ead25ed819
patch 8.1.0043: ++bad argument of :edit does not work properly
Christian Brabandt <cb@256bit.org>
parents:
14035
diff
changeset
|
5228 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
|
5229 } |
4df23d9bad47
patch 8.0.1660: the terminal API "drop" command doesn't support options
Christian Brabandt <cb@256bit.org>
parents:
13553
diff
changeset
|
5230 |
7 | 5231 /* |
5232 * Get "++opt=arg" argument. | |
5233 * Return FAIL or OK. | |
5234 */ | |
5235 static int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5236 getargopt(exarg_T *eap) |
7 | 5237 { |
5238 char_u *arg = eap->arg + 2; | |
5239 int *pp = NULL; | |
2168 | 5240 int bad_char_idx; |
7 | 5241 char_u *p; |
5242 | |
5243 /* ":edit ++[no]bin[ary] file" */ | |
5244 if (STRNCMP(arg, "bin", 3) == 0 || STRNCMP(arg, "nobin", 5) == 0) | |
5245 { | |
5246 if (*arg == 'n') | |
5247 { | |
5248 arg += 2; | |
5249 eap->force_bin = FORCE_NOBIN; | |
5250 } | |
5251 else | |
5252 eap->force_bin = FORCE_BIN; | |
5253 if (!checkforcmd(&arg, "binary", 3)) | |
5254 return FAIL; | |
5255 eap->arg = skipwhite(arg); | |
5256 return OK; | |
5257 } | |
5258 | |
819 | 5259 /* ":read ++edit file" */ |
5260 if (STRNCMP(arg, "edit", 4) == 0) | |
5261 { | |
5262 eap->read_edit = TRUE; | |
5263 eap->arg = skipwhite(arg + 4); | |
5264 return OK; | |
5265 } | |
5266 | |
7 | 5267 if (STRNCMP(arg, "ff", 2) == 0) |
5268 { | |
5269 arg += 2; | |
5270 pp = &eap->force_ff; | |
5271 } | |
5272 else if (STRNCMP(arg, "fileformat", 10) == 0) | |
5273 { | |
5274 arg += 10; | |
5275 pp = &eap->force_ff; | |
5276 } | |
5277 else if (STRNCMP(arg, "enc", 3) == 0) | |
5278 { | |
3208 | 5279 if (STRNCMP(arg, "encoding", 8) == 0) |
5280 arg += 8; | |
5281 else | |
5282 arg += 3; | |
7 | 5283 pp = &eap->force_enc; |
5284 } | |
595 | 5285 else if (STRNCMP(arg, "bad", 3) == 0) |
5286 { | |
5287 arg += 3; | |
2168 | 5288 pp = &bad_char_idx; |
595 | 5289 } |
7 | 5290 |
5291 if (pp == NULL || *arg != '=') | |
5292 return FAIL; | |
5293 | |
5294 ++arg; | |
5295 *pp = (int)(arg - eap->cmd); | |
5296 arg = skip_cmd_arg(arg, FALSE); | |
5297 eap->arg = skipwhite(arg); | |
5298 *arg = NUL; | |
5299 | |
5300 if (pp == &eap->force_ff) | |
5301 { | |
5302 if (check_ff_value(eap->cmd + eap->force_ff) == FAIL) | |
5303 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
|
5304 eap->force_ff = eap->cmd[eap->force_ff]; |
7 | 5305 } |
595 | 5306 else if (pp == &eap->force_enc) |
7 | 5307 { |
5308 /* Make 'fileencoding' lower case. */ | |
5309 for (p = eap->cmd + eap->force_enc; *p != NUL; ++p) | |
5310 *p = TOLOWER_ASC(*p); | |
5311 } | |
595 | 5312 else |
5313 { | |
5314 /* Check ++bad= argument. Must be a single-byte character, "keep" or | |
5315 * "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
|
5316 if (get_bad_opt(eap->cmd + bad_char_idx, eap) == FAIL) |
595 | 5317 return FAIL; |
5318 } | |
7 | 5319 |
5320 return OK; | |
5321 } | |
5322 | |
5323 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5324 ex_autocmd(exarg_T *eap) |
7 | 5325 { |
5326 /* | |
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
|
5327 * Disallow autocommands from .exrc and .vimrc in current |
7 | 5328 * directory for security reasons. |
5329 */ | |
5330 if (secure) | |
5331 { | |
5332 secure = 2; | |
5333 eap->errmsg = e_curdir; | |
5334 } | |
5335 else if (eap->cmdidx == CMD_autocmd) | |
5336 do_autocmd(eap->arg, eap->forceit); | |
5337 else | |
5338 do_augroup(eap->arg, eap->forceit); | |
5339 } | |
5340 | |
5341 /* | |
5342 * ":doautocmd": Apply the automatic commands to the current buffer. | |
5343 */ | |
5344 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5345 ex_doautocmd(exarg_T *eap) |
7 | 5346 { |
3350 | 5347 char_u *arg = eap->arg; |
5348 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
|
5349 int did_aucmd; |
ac8180818504
commit https://github.com/vim/vim/commit/1610d052413e0ed664498853a47acc2d677a22d1
Christian Brabandt <cb@256bit.org>
parents:
9230
diff
changeset
|
5350 |
ac8180818504
commit https://github.com/vim/vim/commit/1610d052413e0ed664498853a47acc2d677a22d1
Christian Brabandt <cb@256bit.org>
parents:
9230
diff
changeset
|
5351 (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
|
5352 /* Only when there is no <nomodeline>. */ |
ac8180818504
commit https://github.com/vim/vim/commit/1610d052413e0ed664498853a47acc2d677a22d1
Christian Brabandt <cb@256bit.org>
parents:
9230
diff
changeset
|
5353 if (call_do_modelines && did_aucmd) |
3350 | 5354 do_modelines(0); |
7 | 5355 } |
5356 | |
5357 /* | |
5358 * :[N]bunload[!] [N] [bufname] unload buffer | |
5359 * :[N]bdelete[!] [N] [bufname] delete buffer from buffer list | |
5360 * :[N]bwipeout[!] [N] [bufname] delete buffer really | |
5361 */ | |
5362 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5363 ex_bunload(exarg_T *eap) |
7 | 5364 { |
17111
af861fccc309
patch 8.1.1555: NOT_IN_POPUP_WINDOW is confusing
Bram Moolenaar <Bram@vim.org>
parents:
17095
diff
changeset
|
5365 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
|
5366 return; |
7 | 5367 eap->errmsg = do_bufdel( |
5368 eap->cmdidx == CMD_bdelete ? DOBUF_DEL | |
5369 : eap->cmdidx == CMD_bwipeout ? DOBUF_WIPE | |
5370 : DOBUF_UNLOAD, eap->arg, | |
5371 eap->addr_count, (int)eap->line1, (int)eap->line2, eap->forceit); | |
5372 } | |
5373 | |
5374 /* | |
5375 * :[N]buffer [N] to buffer N | |
5376 * :[N]sbuffer [N] to buffer N | |
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_buffer(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 if (*eap->arg) |
5384 eap->errmsg = e_trailing; | |
5385 else | |
5386 { | |
5387 if (eap->addr_count == 0) /* default is current buffer */ | |
5388 goto_buffer(eap, DOBUF_CURRENT, FORWARD, 0); | |
5389 else | |
5390 goto_buffer(eap, DOBUF_FIRST, FORWARD, (int)eap->line2); | |
6230 | 5391 if (eap->do_ecmd_cmd != NULL) |
5392 do_cmdline_cmd(eap->do_ecmd_cmd); | |
7 | 5393 } |
5394 } | |
5395 | |
5396 /* | |
5397 * :[N]bmodified [N] to next mod. buffer | |
5398 * :[N]sbmodified [N] to next mod. buffer | |
5399 */ | |
5400 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5401 ex_bmodified(exarg_T *eap) |
7 | 5402 { |
5403 goto_buffer(eap, DOBUF_MOD, FORWARD, (int)eap->line2); | |
6230 | 5404 if (eap->do_ecmd_cmd != NULL) |
5405 do_cmdline_cmd(eap->do_ecmd_cmd); | |
7 | 5406 } |
5407 | |
5408 /* | |
5409 * :[N]bnext [N] to next buffer | |
5410 * :[N]sbnext [N] split and to next buffer | |
5411 */ | |
5412 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5413 ex_bnext(exarg_T *eap) |
7 | 5414 { |
5415 goto_buffer(eap, DOBUF_CURRENT, FORWARD, (int)eap->line2); | |
6230 | 5416 if (eap->do_ecmd_cmd != NULL) |
5417 do_cmdline_cmd(eap->do_ecmd_cmd); | |
7 | 5418 } |
5419 | |
5420 /* | |
5421 * :[N]bNext [N] to previous buffer | |
5422 * :[N]bprevious [N] to previous buffer | |
5423 * :[N]sbNext [N] split and to previous buffer | |
5424 * :[N]sbprevious [N] split and to previous buffer | |
5425 */ | |
5426 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5427 ex_bprevious(exarg_T *eap) |
7 | 5428 { |
5429 goto_buffer(eap, DOBUF_CURRENT, BACKWARD, (int)eap->line2); | |
6230 | 5430 if (eap->do_ecmd_cmd != NULL) |
5431 do_cmdline_cmd(eap->do_ecmd_cmd); | |
7 | 5432 } |
5433 | |
5434 /* | |
5435 * :brewind to first buffer | |
5436 * :bfirst to first buffer | |
5437 * :sbrewind split and to first buffer | |
5438 * :sbfirst split and to first buffer | |
5439 */ | |
5440 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5441 ex_brewind(exarg_T *eap) |
7 | 5442 { |
5443 goto_buffer(eap, DOBUF_FIRST, FORWARD, 0); | |
6230 | 5444 if (eap->do_ecmd_cmd != NULL) |
5445 do_cmdline_cmd(eap->do_ecmd_cmd); | |
7 | 5446 } |
5447 | |
5448 /* | |
5449 * :blast to last buffer | |
5450 * :sblast split and to last buffer | |
5451 */ | |
5452 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5453 ex_blast(exarg_T *eap) |
7 | 5454 { |
5455 goto_buffer(eap, DOBUF_LAST, BACKWARD, 0); | |
6230 | 5456 if (eap->do_ecmd_cmd != NULL) |
5457 do_cmdline_cmd(eap->do_ecmd_cmd); | |
7 | 5458 } |
5459 | |
5460 int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5461 ends_excmd(int c) |
7 | 5462 { |
5463 return (c == NUL || c == '|' || c == '"' || c == '\n'); | |
5464 } | |
5465 | |
5466 #if defined(FEAT_SYN_HL) || defined(FEAT_SEARCH_EXTRA) || defined(FEAT_EVAL) \ | |
5467 || defined(PROTO) | |
5468 /* | |
5469 * Return the next command, after the first '|' or '\n'. | |
5470 * Return NULL if not found. | |
5471 */ | |
5472 char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5473 find_nextcmd(char_u *p) |
7 | 5474 { |
5475 while (*p != '|' && *p != '\n') | |
5476 { | |
5477 if (*p == NUL) | |
5478 return NULL; | |
5479 ++p; | |
5480 } | |
5481 return (p + 1); | |
5482 } | |
5483 #endif | |
5484 | |
5485 /* | |
10383
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5486 * 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
|
5487 * Return NULL if it isn't, the following character if it is. |
7 | 5488 */ |
5489 char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5490 check_nextcmd(char_u *p) |
7 | 5491 { |
10383
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5492 char_u *s = skipwhite(p); |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5493 |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5494 if (*s == '|' || *s == '\n') |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
5495 return (s + 1); |
7 | 5496 else |
5497 return NULL; | |
5498 } | |
5499 | |
5500 /* | |
5501 * - if there are more files to edit | |
5502 * - and this is the last window | |
5503 * - and forceit not used | |
5504 * - and not repeated twice on a row | |
5505 * return FAIL and give error message if 'message' TRUE | |
5506 * return OK otherwise | |
5507 */ | |
5508 static int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5509 check_more( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5510 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
|
5511 int forceit) |
7 | 5512 { |
5513 int n = ARGCOUNT - curwin->w_arg_idx - 1; | |
5514 | |
672 | 5515 if (!forceit && only_one_window() |
5516 && ARGCOUNT > 1 && !arg_had_last && n >= 0 && quitmore == 0) | |
7 | 5517 { |
5518 if (message) | |
5519 { | |
5520 #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) | |
5521 if ((p_confirm || cmdmod.confirm) && curbuf->b_fname != NULL) | |
5522 { | |
2770 | 5523 char_u buff[DIALOG_MSG_SIZE]; |
7 | 5524 |
14585
c8f07e8b273e
patch 8.1.0306: plural messages are not translated properly
Christian Brabandt <cb@256bit.org>
parents:
14550
diff
changeset
|
5525 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
|
5526 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
|
5527 "%d more files to edit. Quit anyway?", n), n); |
7 | 5528 if (vim_dialog_yesno(VIM_QUESTION, NULL, buff, 1) == VIM_YES) |
5529 return OK; | |
5530 return FAIL; | |
5531 } | |
5532 #endif | |
15490
98c35d312987
patch 8.1.0753: printf format not checked for semsg()
Bram Moolenaar <Bram@vim.org>
parents:
15488
diff
changeset
|
5533 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
|
5534 "E173: %d more files to edit", n), n); |
7 | 5535 quitmore = 2; /* next try to quit is allowed */ |
5536 } | |
5537 return FAIL; | |
5538 } | |
5539 return OK; | |
5540 } | |
5541 | |
5542 /* | |
5543 * Function given to ExpandGeneric() to obtain the list of command names. | |
5544 */ | |
5545 char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5546 get_command_name(expand_T *xp UNUSED, int idx) |
7 | 5547 { |
5548 if (idx >= (int)CMD_SIZE) | |
5549 return get_user_command_name(idx); | |
5550 return cmdnames[idx].cmd_name; | |
5551 } | |
5552 | |
5553 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5554 ex_colorscheme(exarg_T *eap) |
7 | 5555 { |
2142
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
5556 if (*eap->arg == NUL) |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
5557 { |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
5558 #ifdef FEAT_EVAL |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
5559 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
|
5560 char_u *p = NULL; |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
5561 |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
5562 if (expr != NULL) |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
5563 { |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
5564 ++emsg_off; |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
5565 p = eval_to_string(expr, NULL, FALSE); |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
5566 --emsg_off; |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
5567 vim_free(expr); |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
5568 } |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
5569 if (p != NULL) |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
5570 { |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15510
diff
changeset
|
5571 msg((char *)p); |
2142
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
5572 vim_free(p); |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
5573 } |
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
5574 else |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15510
diff
changeset
|
5575 msg("default"); |
2142
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
5576 #else |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15510
diff
changeset
|
5577 msg(_("unknown")); |
2142
c60d231453cf
updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents:
2097
diff
changeset
|
5578 #endif |
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 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
|
5581 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
|
5582 |
61448894376e
patch 8.1.0839: when using VTP wrong colors after a color scheme change
Bram Moolenaar <Bram@vim.org>
parents:
15643
diff
changeset
|
5583 #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
|
5584 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
|
5585 { |
61448894376e
patch 8.1.0839: when using VTP wrong colors after a color scheme change
Bram Moolenaar <Bram@vim.org>
parents:
15643
diff
changeset
|
5586 // 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
|
5587 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
|
5588 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
|
5589 } |
61448894376e
patch 8.1.0839: when using VTP wrong colors after a color scheme change
Bram Moolenaar <Bram@vim.org>
parents:
15643
diff
changeset
|
5590 #endif |
7 | 5591 } |
5592 | |
5593 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5594 ex_highlight(exarg_T *eap) |
7 | 5595 { |
5596 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
|
5597 msg(_("Greetings, Vim user!")); |
7 | 5598 do_highlight(eap->arg, eap->forceit, FALSE); |
5599 } | |
5600 | |
5601 | |
5602 /* | |
5603 * Call this function if we thought we were going to exit, but we won't | |
5604 * (because of an error). May need to restore the terminal mode. | |
5605 */ | |
5606 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5607 not_exiting(void) |
7 | 5608 { |
5609 exiting = FALSE; | |
5610 settmode(TMODE_RAW); | |
5611 } | |
5612 | |
13442
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5613 static int |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5614 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
|
5615 { |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5616 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
|
5617 |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5618 /* 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
|
5619 * 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
|
5620 * only happen in autocommands). */ |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5621 if (!win_valid(wp) |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5622 || curbuf_locked() |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5623 || (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
|
5624 return TRUE; |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5625 |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5626 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
|
5627 { |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5628 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
|
5629 /* 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
|
5630 * 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
|
5631 if (curbuf_locked() |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5632 || (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
|
5633 return TRUE; |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5634 } |
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 return FALSE; |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5637 } |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5638 |
7 | 5639 /* |
6409 | 5640 * ":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
|
5641 * ":{nr}quit": quit window {nr} |
7 | 5642 */ |
5643 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5644 ex_quit(exarg_T *eap) |
7 | 5645 { |
6398 | 5646 win_T *wp; |
5647 | |
7 | 5648 #ifdef FEAT_CMDWIN |
5649 if (cmdwin_type != 0) | |
5650 { | |
5651 cmdwin_result = Ctrl_C; | |
5652 return; | |
5653 } | |
5654 #endif | |
631 | 5655 /* Don't quit while editing the command line. */ |
633 | 5656 if (text_locked()) |
5657 { | |
5658 text_locked_msg(); | |
631 | 5659 return; |
5660 } | |
6398 | 5661 if (eap->addr_count > 0) |
5662 { | |
6409 | 5663 int wnr = eap->line2; |
5664 | |
5665 for (wp = firstwin; wp->w_next != NULL; wp = wp->w_next) | |
5666 if (--wnr <= 0) | |
6398 | 5667 break; |
5668 } | |
5669 else | |
5670 wp = curwin; | |
6409 | 5671 |
12652
272ecbaf1b4f
patch 8.0.1204: a QuitPre autocommand may get the wrong file name
Christian Brabandt <cb@256bit.org>
parents:
12624
diff
changeset
|
5672 /* 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
|
5673 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
|
5674 return; |
13442
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5675 |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5676 /* Trigger QuitPre and maybe ExitPre */ |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5677 if (before_quit_autocmds(wp, FALSE, eap->forceit)) |
819 | 5678 return; |
7 | 5679 |
5680 #ifdef FEAT_NETBEANS_INTG | |
5681 netbeansForcedQuit = eap->forceit; | |
5682 #endif | |
5683 | |
5684 /* | |
5685 * If there are more files or windows we won't exit. | |
5686 */ | |
5687 if (check_more(FALSE, eap->forceit) == OK && only_one_window()) | |
5688 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
|
5689 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
|
5690 && check_changed(wp->w_buffer, (p_awa ? CCGD_AW : 0) |
5464 | 5691 | (eap->forceit ? CCGD_FORCEIT : 0) |
5692 | CCGD_EXCMD)) | |
7 | 5693 || 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
|
5694 || (only_one_window() && check_changed_any(eap->forceit, TRUE))) |
7 | 5695 { |
5696 not_exiting(); | |
5697 } | |
5698 else | |
5699 { | |
6838 | 5700 /* quit last window |
5701 * Note: only_one_window() returns true, even so a help window is | |
5702 * still open. In that case only quit, if no address has been | |
5703 * specified. Example: | |
5704 * :h|wincmd w|1q - don't quit | |
5705 * :h|wincmd w|q - quit | |
5706 */ | |
10349
cf988222b150
commit https://github.com/vim/vim/commit/a1f4cb93ba50ea9e40cd4b1f5592b8a6d1398660
Christian Brabandt <cb@256bit.org>
parents:
10275
diff
changeset
|
5707 if (only_one_window() && (ONE_WINDOW || eap->addr_count == 0)) |
7 | 5708 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
|
5709 not_exiting(); |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5710 #ifdef FEAT_GUI |
7 | 5711 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
|
5712 #endif |
7 | 5713 /* 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
|
5714 win_close(wp, !buf_hide(wp->w_buffer) || eap->forceit); |
7 | 5715 } |
5716 } | |
5717 | |
5718 /* | |
5719 * ":cquit". | |
5720 */ | |
5721 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5722 ex_cquit(exarg_T *eap UNUSED) |
7 | 5723 { |
5724 getout(1); /* this does not always pass on the exit code to the Manx | |
5725 compiler. why? */ | |
5726 } | |
5727 | |
5728 /* | |
5729 * ":qall": try to quit all windows | |
5730 */ | |
5731 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5732 ex_quit_all(exarg_T *eap) |
7 | 5733 { |
5734 # ifdef FEAT_CMDWIN | |
5735 if (cmdwin_type != 0) | |
5736 { | |
5737 if (eap->forceit) | |
5738 cmdwin_result = K_XF1; /* ex_window() takes care of this */ | |
5739 else | |
5740 cmdwin_result = K_XF2; | |
5741 return; | |
5742 } | |
5743 # endif | |
631 | 5744 |
5745 /* Don't quit while editing the command line. */ | |
633 | 5746 if (text_locked()) |
5747 { | |
5748 text_locked_msg(); | |
631 | 5749 return; |
5750 } | |
13442
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5751 |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
5752 if (before_quit_autocmds(curwin, TRUE, eap->forceit)) |
819 | 5753 return; |
631 | 5754 |
7 | 5755 exiting = TRUE; |
7469
15eefe1b0dad
commit https://github.com/vim/vim/commit/027387f70c671f62e3e08e0bdd09ec05b0232735
Christian Brabandt <cb@256bit.org>
parents:
7465
diff
changeset
|
5756 if (eap->forceit || !check_changed_any(FALSE, FALSE)) |
7 | 5757 getout(0); |
5758 not_exiting(); | |
5759 } | |
5760 | |
5761 /* | |
5762 * ":close": close current window, unless it is the last one | |
5763 */ | |
5764 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5765 ex_close(exarg_T *eap) |
7 | 5766 { |
6398 | 5767 win_T *win; |
5768 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
|
5769 #ifdef FEAT_CMDWIN |
7 | 5770 if (cmdwin_type != 0) |
2839 | 5771 cmdwin_result = Ctrl_C; |
7 | 5772 else |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5773 #endif |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
5774 if (!text_locked() && !curbuf_locked()) |
6398 | 5775 { |
5776 if (eap->addr_count == 0) | |
5777 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
|
5778 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
|
5779 { |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9538
diff
changeset
|
5780 FOR_ALL_WINDOWS(win) |
6398 | 5781 { |
5782 winnr++; | |
5783 if (winnr == eap->line2) | |
5784 break; | |
5785 } | |
5786 if (win == NULL) | |
5787 win = lastwin; | |
5788 ex_win_close(eap->forceit, win, NULL); | |
5789 } | |
5790 } | |
667 | 5791 } |
5792 | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5793 #ifdef FEAT_QUICKFIX |
667 | 5794 /* |
5795 * ":pclose": Close any preview window. | |
5796 */ | |
5797 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5798 ex_pclose(exarg_T *eap) |
667 | 5799 { |
5800 win_T *win; | |
5801 | |
17431
ce35cdbe9f74
patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
17336
diff
changeset
|
5802 // First close any normal window. |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9538
diff
changeset
|
5803 FOR_ALL_WINDOWS(win) |
667 | 5804 if (win->w_p_pvw) |
5805 { | |
671 | 5806 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
|
5807 return; |
ce35cdbe9f74
patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
17336
diff
changeset
|
5808 } |
ce35cdbe9f74
patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
17336
diff
changeset
|
5809 # 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
|
5810 // Also when 'previewpopup' is empty, it might have been cleared. |
17767
c75da1064e33
patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
17746
diff
changeset
|
5811 popup_close_preview(FALSE); |
17431
ce35cdbe9f74
patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
17336
diff
changeset
|
5812 # endif |
667 | 5813 } |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5814 #endif |
667 | 5815 |
671 | 5816 /* |
5817 * Close window "win" and take care of handling closing the last window for a | |
5818 * modified buffer. | |
5819 */ | |
5820 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5821 ex_win_close( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5822 int forceit, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5823 win_T *win, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5824 tabpage_T *tp) /* NULL or the tab page "win" is in */ |
7 | 5825 { |
5826 int need_hide; | |
5827 buf_T *buf = win->w_buffer; | |
5828 | |
5829 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
|
5830 if (need_hide && !buf_hide(buf) && !forceit) |
7 | 5831 { |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5832 #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) |
7 | 5833 if ((p_confirm || cmdmod.confirm) && p_write) |
5834 { | |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9460
diff
changeset
|
5835 bufref_T bufref; |
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9460
diff
changeset
|
5836 |
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9460
diff
changeset
|
5837 set_bufref(&bufref, buf); |
7 | 5838 dialog_changed(buf, FALSE); |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9460
diff
changeset
|
5839 if (bufref_valid(&bufref) && bufIsChanged(buf)) |
7 | 5840 return; |
5841 need_hide = FALSE; | |
5842 } | |
5843 else | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5844 #endif |
7 | 5845 { |
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
|
5846 no_write_message(); |
7 | 5847 return; |
5848 } | |
5849 } | |
5850 | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
5851 #ifdef FEAT_GUI |
7 | 5852 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
|
5853 #endif |
671 | 5854 |
7 | 5855 /* free buffer when not hiding it or when it's a scratch buffer */ |
671 | 5856 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
|
5857 win_close(win, !need_hide && !buf_hide(buf)); |
671 | 5858 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
|
5859 win_close_othertab(win, !need_hide && !buf_hide(buf), tp); |
671 | 5860 } |
5861 | |
5862 /* | |
10741
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5863 * 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
|
5864 * Returns a tabpage number. |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5865 * 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
|
5866 */ |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5867 static int |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5868 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
|
5869 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5870 int tab_number; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5871 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
|
5872 |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5873 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
|
5874 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5875 char_u *p = eap->arg; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5876 char_u *p_save; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5877 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
|
5878 * 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
|
5879 |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5880 if (*p == '-') |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5881 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5882 relative = -1; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5883 p++; |
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 else if (*p == '+') |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5886 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5887 relative = 1; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5888 p++; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5889 } |
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 p_save = p; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5892 tab_number = getdigits(&p); |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5893 |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5894 if (relative == 0) |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5895 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5896 if (STRCMP(p, "$") == 0) |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5897 tab_number = LAST_TAB_NR; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5898 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
|
5899 || tab_number > LAST_TAB_NR) |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5900 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5901 /* No numbers as argument. */ |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5902 eap->errmsg = e_invarg; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5903 goto theend; |
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 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5906 else |
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 if (*p_save == NUL) |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5909 tab_number = 1; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5910 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
|
5911 || tab_number == 0) |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5912 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5913 /* No numbers as argument. */ |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5914 eap->errmsg = e_invarg; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5915 goto theend; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5916 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5917 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
|
5918 if (!unaccept_arg0 && relative == -1) |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5919 --tab_number; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5920 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5921 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
|
5922 eap->errmsg = e_invarg; |
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 if (eap->addr_count > 0) |
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 (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
|
5927 { |
10741
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5928 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
|
5929 tab_number = 0; |
4961e7acdd8c
patch 8.0.0266: compiler warning for using uninitialized variable
Christian Brabandt <cb@256bit.org>
parents:
10741
diff
changeset
|
5930 } |
10741
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5931 else |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5932 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5933 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
|
5934 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
|
5935 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5936 --tab_number; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5937 if (tab_number < unaccept_arg0) |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5938 eap->errmsg = e_invarg; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5939 } |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5940 } |
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 |
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 switch (eap->cmdidx) |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5945 { |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5946 case CMD_tabnext: |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5947 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
|
5948 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
|
5949 tab_number = 1; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5950 break; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5951 case CMD_tabmove: |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5952 tab_number = LAST_TAB_NR; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5953 break; |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5954 default: |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5955 tab_number = tabpage_index(curtab); |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5956 } |
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 theend: |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5960 return tab_number; |
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 |
3f70b142e8da
patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents:
10739
diff
changeset
|
5963 /* |
671 | 5964 * ":tabclose": close current tab page, unless it is the last one. |
5965 * ":tabclose N": close tab page N. | |
667 | 5966 */ |
5967 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
5968 ex_tabclose(exarg_T *eap) |
667 | 5969 { |
671 | 5970 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
|
5971 int tab_number; |
671 | 5972 |
667 | 5973 # ifdef FEAT_CMDWIN |
5974 if (cmdwin_type != 0) | |
5975 cmdwin_result = K_IGNORE; | |
5976 else | |
5977 # endif | |
671 | 5978 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
|
5979 emsg(_("E784: Cannot close last tab page")); |
671 | 5980 else |
5981 { | |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5982 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
|
5983 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
|
5984 { |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
5985 tp = find_tabpage(tab_number); |
671 | 5986 if (tp == NULL) |
5987 { | |
5988 beep_flush(); | |
5989 return; | |
5990 } | |
674 | 5991 if (tp != curtab) |
671 | 5992 { |
5993 tabpage_close_other(tp, eap->forceit); | |
5994 return; | |
5995 } | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
5996 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
|
5997 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
|
5998 } |
671 | 5999 } |
672 | 6000 } |
6001 | |
6002 /* | |
6003 * ":tabonly": close all tab pages except the current one | |
6004 */ | |
6005 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6006 ex_tabonly(exarg_T *eap) |
672 | 6007 { |
6008 tabpage_T *tp; | |
6009 int done; | |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6010 int tab_number; |
672 | 6011 |
6012 # ifdef FEAT_CMDWIN | |
6013 if (cmdwin_type != 0) | |
6014 cmdwin_result = K_IGNORE; | |
6015 else | |
6016 # endif | |
6017 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
|
6018 msg(_("Already only one tab page")); |
672 | 6019 else |
6020 { | |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6021 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
|
6022 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
|
6023 { |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6024 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
|
6025 /* 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
|
6026 * 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
|
6027 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
|
6028 { |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6029 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
|
6030 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
|
6031 { |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6032 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
|
6033 /* 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
|
6034 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
|
6035 done = 1000; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6036 /* 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
|
6037 break; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6038 } |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6039 if (first_tabpage->tp_next == NULL) |
672 | 6040 break; |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6041 } |
672 | 6042 } |
6043 } | |
671 | 6044 } |
6045 | |
6046 /* | |
6047 * Close the current tab page. | |
6048 */ | |
6049 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6050 tabpage_close(int forceit) |
671 | 6051 { |
6052 /* First close all the windows but the current one. If that worked then | |
6053 * 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
|
6054 if (!ONE_WINDOW) |
675 | 6055 close_others(TRUE, forceit); |
10357
59d01e335858
commit https://github.com/vim/vim/commit/459ca563128f2edb7e3bb190090bbb755a56dd55
Christian Brabandt <cb@256bit.org>
parents:
10349
diff
changeset
|
6056 if (ONE_WINDOW) |
671 | 6057 ex_win_close(forceit, curwin, NULL); |
6058 # ifdef FEAT_GUI | |
6059 need_mouse_correct = TRUE; | |
6060 # endif | |
6061 } | |
6062 | |
6063 /* | |
6064 * Close tab page "tp", which is not the current tab page. | |
6065 * Note that autocommands may make "tp" invalid. | |
971 | 6066 * Also takes care of the tab pages line disappearing when closing the |
6067 * last-but-one tab page. | |
671 | 6068 */ |
6069 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6070 tabpage_close_other(tabpage_T *tp, int forceit) |
671 | 6071 { |
6072 int done = 0; | |
672 | 6073 win_T *wp; |
971 | 6074 int h = tabline_height(); |
671 | 6075 |
6076 /* Limit to 1000 windows, autocommands may add a window while we close | |
6077 * one. OK, so I'm paranoid... */ | |
6078 while (++done < 1000) | |
6079 { | |
672 | 6080 wp = tp->tp_firstwin; |
6081 ex_win_close(forceit, wp, tp); | |
6082 | |
6083 /* Autocommands may delete the tab page under our fingers and we may | |
6084 * fail to close a window with a modified buffer. */ | |
6085 if (!valid_tabpage(tp) || tp->tp_firstwin == wp) | |
671 | 6086 break; |
6087 } | |
971 | 6088 |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9538
diff
changeset
|
6089 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
|
6090 |
672 | 6091 redraw_tabline = TRUE; |
971 | 6092 if (h != tabline_height()) |
6093 shell_new_rows(); | |
667 | 6094 } |
7 | 6095 |
6096 /* | |
6097 * ":only". | |
6098 */ | |
6099 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6100 ex_only(exarg_T *eap) |
7 | 6101 { |
6398 | 6102 win_T *wp; |
6103 int wnr; | |
7 | 6104 # ifdef FEAT_GUI |
6105 need_mouse_correct = TRUE; | |
6106 # endif | |
6398 | 6107 if (eap->addr_count > 0) |
6108 { | |
6109 wnr = eap->line2; | |
6110 for (wp = firstwin; --wnr > 0; ) | |
6111 { | |
6112 if (wp->w_next == NULL) | |
6113 break; | |
6114 else | |
6115 wp = wp->w_next; | |
6116 } | |
6117 win_goto(wp); | |
6118 } | |
7 | 6119 close_others(TRUE, eap->forceit); |
6120 } | |
6121 | |
6122 static void | |
10492
b2cd5a71f4bb
commit https://github.com/vim/vim/commit/5e1e6d265d26ee2952c4a018a5ff72c950d2d700
Christian Brabandt <cb@256bit.org>
parents:
10490
diff
changeset
|
6123 ex_hide(exarg_T *eap UNUSED) |
7 | 6124 { |
10383
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
6125 /* ":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
|
6126 if (!eap->skip) |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
6127 { |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
6128 #ifdef FEAT_GUI |
10383
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
6129 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
|
6130 #endif |
10383
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
6131 if (eap->addr_count == 0) |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
6132 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
|
6133 else |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
6134 { |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
6135 int winnr = 0; |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
6136 win_T *win; |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
6137 |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
6138 FOR_ALL_WINDOWS(win) |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
6139 { |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
6140 winnr++; |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
6141 if (winnr == eap->line2) |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
6142 break; |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
6143 } |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
6144 if (win == NULL) |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
6145 win = lastwin; |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
6146 win_close(win, FALSE); |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
6147 } |
b59df2194b01
commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents:
10373
diff
changeset
|
6148 } |
7 | 6149 } |
6150 | |
6151 /* | |
6152 * ":stop" and ":suspend": Suspend Vim. | |
6153 */ | |
6154 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6155 ex_stop(exarg_T *eap) |
7 | 6156 { |
6157 /* | |
6158 * Disallow suspending for "rvim". | |
6159 */ | |
10264
c036c0f636d5
commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents:
10240
diff
changeset
|
6160 if (!check_restricted()) |
7 | 6161 { |
6162 if (!eap->forceit) | |
6163 autowrite_all(); | |
6164 windgoto((int)Rows - 1, 0); | |
6165 out_char('\n'); | |
6166 out_flush(); | |
6167 stoptermcap(); | |
6168 out_flush(); /* needed for SUN to restore xterm buffer */ | |
6169 #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
|
6170 mch_restore_title(SAVE_RESTORE_BOTH); /* restore window titles */ |
7 | 6171 #endif |
6172 ui_suspend(); /* call machine specific function */ | |
6173 #ifdef FEAT_TITLE | |
6174 maketitle(); | |
6175 resettitle(); /* force updating the title */ | |
6176 #endif | |
6177 starttermcap(); | |
6178 scroll_start(); /* scroll screen before redrawing */ | |
6179 redraw_later_clear(); | |
6180 shell_resized(); /* may have resized window */ | |
6181 } | |
6182 } | |
6183 | |
6184 /* | |
13442
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
6185 * ":exit", ":xit" and ":wq": Write file and quite the current window. |
7 | 6186 */ |
6187 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6188 ex_exit(exarg_T *eap) |
7 | 6189 { |
6190 #ifdef FEAT_CMDWIN | |
6191 if (cmdwin_type != 0) | |
6192 { | |
6193 cmdwin_result = Ctrl_C; | |
6194 return; | |
6195 } | |
6196 #endif | |
631 | 6197 /* Don't quit while editing the command line. */ |
633 | 6198 if (text_locked()) |
6199 { | |
6200 text_locked_msg(); | |
631 | 6201 return; |
6202 } | |
13442
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
6203 |
94e638936d3e
patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents:
13435
diff
changeset
|
6204 if (before_quit_autocmds(curwin, FALSE, eap->forceit)) |
819 | 6205 return; |
7 | 6206 |
6207 /* | |
6208 * if more files or windows we won't exit | |
6209 */ | |
6210 if (check_more(FALSE, eap->forceit) == OK && only_one_window()) | |
6211 exiting = TRUE; | |
6212 if ( ((eap->cmdidx == CMD_wq | |
6213 || curbufIsChanged()) | |
6214 && do_write(eap) == FAIL) | |
6215 || 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
|
6216 || (only_one_window() && check_changed_any(eap->forceit, FALSE))) |
7 | 6217 { |
6218 not_exiting(); | |
6219 } | |
6220 else | |
6221 { | |
6222 if (only_one_window()) /* quit last window, exit Vim */ | |
6223 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
|
6224 not_exiting(); |
7 | 6225 # ifdef FEAT_GUI |
6226 need_mouse_correct = TRUE; | |
6227 # endif | |
5245
8c6615a30951
updated for version 7.4a.047
Bram Moolenaar <bram@vim.org>
parents:
5198
diff
changeset
|
6228 /* 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
|
6229 win_close(curwin, !buf_hide(curwin->w_buffer)); |
7 | 6230 } |
6231 } | |
6232 | |
6233 /* | |
6234 * ":print", ":list", ":number". | |
6235 */ | |
6236 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6237 ex_print(exarg_T *eap) |
7 | 6238 { |
167 | 6239 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
|
6240 emsg(_(e_emptybuf)); |
167 | 6241 else |
6242 { | |
6243 for ( ;!got_int; ui_breakcheck()) | |
6244 { | |
6245 print_line(eap->line1, | |
6246 (eap->cmdidx == CMD_number || eap->cmdidx == CMD_pound | |
6247 || (eap->flags & EXFLAG_NR)), | |
6248 eap->cmdidx == CMD_list || (eap->flags & EXFLAG_LIST)); | |
6249 if (++eap->line1 > eap->line2) | |
6250 break; | |
6251 out_flush(); /* show one line at a time */ | |
6252 } | |
6253 setpcmark(); | |
6254 /* put cursor at last line */ | |
6255 curwin->w_cursor.lnum = eap->line2; | |
6256 beginline(BL_SOL | BL_FIX); | |
6257 } | |
7 | 6258 |
6259 ex_no_reprint = TRUE; | |
6260 } | |
6261 | |
6262 #ifdef FEAT_BYTEOFF | |
6263 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6264 ex_goto(exarg_T *eap) |
7 | 6265 { |
6266 goto_byte(eap->line2); | |
6267 } | |
6268 #endif | |
6269 | |
6270 /* | |
6271 * ":shell". | |
6272 */ | |
6273 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6274 ex_shell(exarg_T *eap UNUSED) |
7 | 6275 { |
6276 do_shell(NULL, 0); | |
6277 } | |
6278 | |
14428
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6279 #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
|
6280 |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6281 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
|
6282 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
|
6283 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
|
6284 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
|
6285 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
|
6286 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
|
6287 |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6288 static void |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6289 handle_drop_internal(void) |
7 | 6290 { |
6291 exarg_T ea; | |
6292 int save_msg_scroll = msg_scroll; | |
6293 | |
14428
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6294 // 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
|
6295 // 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
|
6296 drop_busy = TRUE; |
7 | 6297 |
6298 /* Check whether the current buffer is changed. If so, we will need | |
6299 * to split the current window or data could be lost. | |
6300 * We don't need to check if the 'hidden' option is set, as in this | |
6301 * case the buffer won't be lost. | |
6302 */ | |
14428
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6303 if (!buf_hide(curbuf) && !drop_split) |
7 | 6304 { |
6305 ++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
|
6306 drop_split = check_changed(curbuf, CCGD_AW); |
7 | 6307 --emsg_off; |
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 (drop_split) |
7 | 6310 { |
6311 if (win_split(0, 0) == FAIL) | |
6312 return; | |
2583 | 6313 RESET_BINDING(curwin); |
7 | 6314 |
6315 /* When splitting the window, create a new alist. Otherwise the | |
6316 * existing one is overwritten. */ | |
6317 alist_unlink(curwin->w_alist); | |
6318 alist_new(); | |
6319 } | |
6320 | |
6321 /* | |
6322 * Set up the new argument list. | |
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 alist_set(ALIST(curwin), drop_filec, drop_filev, FALSE, NULL, 0); |
7 | 6325 |
6326 /* | |
6327 * Move to the first file. | |
6328 */ | |
6329 /* Fake up a minimal "next" command for do_argfile() */ | |
6330 vim_memset(&ea, 0, sizeof(ea)); | |
6331 ea.cmd = (char_u *)"next"; | |
6332 do_argfile(&ea, 0); | |
6333 | |
6334 /* do_ecmd() may set need_start_insertmode, but since we never left Insert | |
6335 * mode that is not needed here. */ | |
6336 need_start_insertmode = FALSE; | |
6337 | |
6338 /* Restore msg_scroll, otherwise a following command may cause scrolling | |
6339 * unexpectedly. The screen will be redrawn by the caller, thus | |
6340 * msg_scroll being set by displaying a message is irrelevant. */ | |
6341 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
|
6342 |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6343 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
|
6344 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
|
6345 |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6346 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
|
6347 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
|
6348 } |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6349 |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6350 /* |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6351 * 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
|
6352 * :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
|
6353 * 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
|
6354 * 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
|
6355 * 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
|
6356 * |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6357 * 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
|
6358 * 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
|
6359 * list. |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6360 */ |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6361 void |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6362 handle_drop( |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6363 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
|
6364 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
|
6365 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
|
6366 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
|
6367 // list |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6368 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
|
6369 { |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6370 // 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
|
6371 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
|
6372 { |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6373 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
|
6374 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
|
6375 return; |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6376 } |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6377 |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6378 // 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
|
6379 // one. |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6380 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
|
6381 { |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6382 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
|
6383 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
|
6384 } |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6385 |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6386 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
|
6387 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
|
6388 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
|
6389 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
|
6390 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
|
6391 |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6392 // 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
|
6393 // - 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
|
6394 // - 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
|
6395 // - 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
|
6396 // 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
|
6397 // 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
|
6398 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
|
6399 return; |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6400 |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6401 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
|
6402 } |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6403 |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6404 /* |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6405 * 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
|
6406 * 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
|
6407 */ |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6408 void |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6409 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
|
6410 { |
aab5947be7c5
patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents:
14409
diff
changeset
|
6411 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
|
6412 && !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
|
6413 handle_drop_internal(); |
7 | 6414 } |
6415 #endif | |
6416 | |
6417 /* | |
6418 * ":preserve". | |
6419 */ | |
6420 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6421 ex_preserve(exarg_T *eap UNUSED) |
7 | 6422 { |
164 | 6423 curbuf->b_flags |= BF_PRESERVED; |
7 | 6424 ml_preserve(curbuf, TRUE); |
6425 } | |
6426 | |
6427 /* | |
6428 * ":recover". | |
6429 */ | |
6430 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6431 ex_recover(exarg_T *eap) |
7 | 6432 { |
6433 /* Set recoverymode right away to avoid the ATTENTION prompt. */ | |
6434 recoverymode = TRUE; | |
5464 | 6435 if (!check_changed(curbuf, (p_awa ? CCGD_AW : 0) |
6436 | CCGD_MULTWIN | |
6437 | (eap->forceit ? CCGD_FORCEIT : 0) | |
6438 | CCGD_EXCMD) | |
6439 | |
7 | 6440 && (*eap->arg == NUL |
6441 || 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
|
6442 ml_recover(TRUE); |
7 | 6443 recoverymode = FALSE; |
6444 } | |
6445 | |
6446 /* | |
6447 * Command modifier used in a wrong way. | |
6448 */ | |
6449 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6450 ex_wrongmodifier(exarg_T *eap) |
7 | 6451 { |
6452 eap->errmsg = e_invcmd; | |
6453 } | |
6454 | |
6455 /* | |
6456 * :sview [+command] file split window with new file, read-only | |
6457 * :split [[+command] file] split window with current or new file | |
6458 * :vsplit [[+command] file] split window vertically with current or new file | |
6459 * :new [[+command] file] split window with no or new file | |
6460 * :vnew [[+command] file] split vertically window with no or new file | |
6461 * :sfind [+command] file split window with file in 'path' | |
675 | 6462 * |
6463 * :tabedit open new Tab page with empty window | |
6464 * :tabedit [+command] file open new Tab page and edit "file" | |
6465 * :tabnew [[+command] file] just like :tabedit | |
6466 * :tabfind [+command] file open new Tab page and find "file" | |
7 | 6467 */ |
6468 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6469 ex_splitview(exarg_T *eap) |
7 | 6470 { |
675 | 6471 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
|
6472 #if defined(FEAT_SEARCHPATH) || defined(FEAT_BROWSE) |
7 | 6473 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
|
6474 #endif |
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
6475 #ifdef FEAT_BROWSE |
7 | 6476 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
|
6477 #endif |
14155
da09e29e59d9
patch 8.1.0095: dialog for ":browse tabnew" says "new window"
Christian Brabandt <cb@256bit.org>
parents:
14059
diff
changeset
|
6478 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
|
6479 || 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
|
6480 || 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
|
6481 |
17111
af861fccc309
patch 8.1.1555: NOT_IN_POPUP_WINDOW is confusing
Bram Moolenaar <Bram@vim.org>
parents:
17095
diff
changeset
|
6482 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
|
6483 return; |
da5f5836e90c
patch 8.1.1438: some commands cause trouble in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
6484 |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
6485 #ifdef FEAT_GUI |
7 | 6486 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
|
6487 #endif |
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
6488 |
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
6489 #ifdef FEAT_QUICKFIX |
7 | 6490 /* A ":split" in the quickfix window works like ":new". Don't want two |
1661 | 6491 * quickfix windows. But it's OK when doing ":tab split". */ |
6492 if (bt_quickfix(curbuf) && cmdmod.tab == 0) | |
7 | 6493 { |
6494 if (eap->cmdidx == CMD_split) | |
6495 eap->cmdidx = CMD_new; | |
6496 if (eap->cmdidx == CMD_vsplit) | |
6497 eap->cmdidx = CMD_vnew; | |
667 | 6498 } |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
6499 #endif |
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
6500 |
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
6501 #ifdef FEAT_SEARCHPATH |
675 | 6502 if (eap->cmdidx == CMD_sfind || eap->cmdidx == CMD_tabfind) |
7 | 6503 { |
6504 fname = find_file_in_path(eap->arg, (int)STRLEN(eap->arg), | |
6505 FNAME_MESS, TRUE, curbuf->b_ffname); | |
6506 if (fname == NULL) | |
6507 goto theend; | |
6508 eap->arg = fname; | |
6509 } | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
6510 # ifdef FEAT_BROWSE |
7 | 6511 else |
6512 # endif | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
6513 #endif |
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
6514 #ifdef FEAT_BROWSE |
7 | 6515 if (cmdmod.browse |
6516 && eap->cmdidx != CMD_vnew | |
6517 && eap->cmdidx != CMD_new) | |
6518 { | |
461 | 6519 if ( |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
6520 # ifdef FEAT_GUI |
461 | 6521 !gui.in_use && |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
6522 # endif |
461 | 6523 au_has_group((char_u *)"FileExplorer")) |
6524 { | |
6525 /* No browsing supported but we do have the file explorer: | |
6526 * Edit the directory. */ | |
6527 if (*eap->arg == NUL || !mch_isdir(eap->arg)) | |
6528 eap->arg = (char_u *)"."; | |
6529 } | |
6530 else | |
6531 { | |
14155
da09e29e59d9
patch 8.1.0095: dialog for ":browse tabnew" says "new window"
Christian Brabandt <cb@256bit.org>
parents:
14059
diff
changeset
|
6532 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
|
6533 ? _("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
|
6534 : _("Edit File in new window")), |
7 | 6535 eap->arg, NULL, NULL, NULL, curbuf); |
461 | 6536 if (fname == NULL) |
6537 goto theend; | |
6538 eap->arg = fname; | |
6539 } | |
7 | 6540 } |
6541 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
|
6542 #endif |
7 | 6543 |
675 | 6544 /* |
6545 * Either open new tab page or split the window. | |
6546 */ | |
14155
da09e29e59d9
patch 8.1.0095: dialog for ":browse tabnew" says "new window"
Christian Brabandt <cb@256bit.org>
parents:
14059
diff
changeset
|
6547 if (use_tab) |
675 | 6548 { |
820 | 6549 if (win_new_tabpage(cmdmod.tab != 0 ? cmdmod.tab |
6550 : eap->addr_count == 0 ? 0 | |
6551 : (int)eap->line2 + 1) != FAIL) | |
675 | 6552 { |
1498 | 6553 do_exedit(eap, old_curwin); |
675 | 6554 |
6555 /* set the alternate buffer for the window we came from */ | |
6556 if (curwin != old_curwin | |
6557 && win_valid(old_curwin) | |
6558 && old_curwin->w_buffer != curbuf | |
6559 && !cmdmod.keepalt) | |
6560 old_curwin->w_alt_fnum = curbuf->b_fnum; | |
6561 } | |
6562 } | |
6563 else if (win_split(eap->addr_count > 0 ? (int)eap->line2 : 0, | |
7 | 6564 *eap->cmd == 'v' ? WSP_VERT : 0) != FAIL) |
6565 { | |
6566 /* Reset 'scrollbind' when editing another file, but keep it when | |
6567 * doing ":split" without arguments. */ | |
6568 if (*eap->arg != NUL | |
13384
6740c499de13
patch 8.0.1566: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13380
diff
changeset
|
6569 # ifdef FEAT_BROWSE |
7 | 6570 || cmdmod.browse |
13384
6740c499de13
patch 8.0.1566: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13380
diff
changeset
|
6571 # endif |
7 | 6572 ) |
2583 | 6573 RESET_BINDING(curwin); |
7 | 6574 else |
6575 do_check_scrollbind(FALSE); | |
6576 do_exedit(eap, old_curwin); | |
6577 } | |
6578 | |
667 | 6579 # ifdef FEAT_BROWSE |
7 | 6580 cmdmod.browse = browse_flag; |
667 | 6581 # endif |
6582 | |
6583 # if defined(FEAT_SEARCHPATH) || defined(FEAT_BROWSE) | |
7 | 6584 theend: |
6585 vim_free(fname); | |
667 | 6586 # endif |
6587 } | |
6588 | |
6589 /* | |
682 | 6590 * Open a new tab page. |
667 | 6591 */ |
6592 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6593 tabpage_new(void) |
682 | 6594 { |
6595 exarg_T ea; | |
6596 | |
6597 vim_memset(&ea, 0, sizeof(ea)); | |
6598 ea.cmdidx = CMD_tabnew; | |
6599 ea.cmd = (char_u *)"tabn"; | |
6600 ea.arg = (char_u *)""; | |
6601 ex_splitview(&ea); | |
6602 } | |
6603 | |
6604 /* | |
6605 * :tabnext command | |
6606 */ | |
6607 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6608 ex_tabnext(exarg_T *eap) |
682 | 6609 { |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6610 int tab_number; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6611 |
17111
af861fccc309
patch 8.1.1555: NOT_IN_POPUP_WINDOW is confusing
Bram Moolenaar <Bram@vim.org>
parents:
17095
diff
changeset
|
6612 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
|
6613 return; |
685 | 6614 switch (eap->cmdidx) |
6615 { | |
6616 case CMD_tabfirst: | |
6617 case CMD_tabrewind: | |
6618 goto_tabpage(1); | |
6619 break; | |
6620 case CMD_tablast: | |
6621 goto_tabpage(9999); | |
6622 break; | |
6623 case CMD_tabprevious: | |
6624 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
|
6625 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
|
6626 { |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6627 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
|
6628 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
|
6629 |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6630 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
|
6631 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
|
6632 || tab_number == 0) |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6633 { |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6634 /* 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
|
6635 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
|
6636 return; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6637 } |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6638 } |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6639 else |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6640 { |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6641 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
|
6642 tab_number = 1; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6643 else |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6644 { |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6645 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
|
6646 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
|
6647 { |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6648 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
|
6649 return; |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6650 } |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6651 } |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6652 } |
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6653 goto_tabpage(-tab_number); |
685 | 6654 break; |
6655 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
|
6656 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
|
6657 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
|
6658 goto_tabpage(tab_number); |
685 | 6659 break; |
6660 } | |
682 | 6661 } |
6662 | |
6663 /* | |
6664 * :tabmove command | |
6665 */ | |
6666 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6667 ex_tabmove(exarg_T *eap) |
682 | 6668 { |
6775 | 6669 int tab_number; |
3662 | 6670 |
10739
380e706814da
patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents:
10726
diff
changeset
|
6671 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
|
6672 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
|
6673 tabpage_move(tab_number); |
667 | 6674 } |
6675 | |
6676 /* | |
6677 * :tabs command: List tabs and their contents. | |
6678 */ | |
6679 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6680 ex_tabs(exarg_T *eap UNUSED) |
667 | 6681 { |
6682 tabpage_T *tp; | |
6683 win_T *wp; | |
6684 int tabcount = 1; | |
6685 | |
6686 msg_start(); | |
6687 msg_scroll = TRUE; | |
6688 for (tp = first_tabpage; tp != NULL && !got_int; tp = tp->tp_next) | |
6689 { | |
6690 msg_putchar('\n'); | |
6691 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
|
6692 msg_outtrans_attr(IObuff, HL_ATTR(HLF_T)); |
667 | 6693 out_flush(); /* output one line at a time */ |
6694 ui_breakcheck(); | |
6695 | |
678 | 6696 if (tp == curtab) |
667 | 6697 wp = firstwin; |
6698 else | |
6699 wp = tp->tp_firstwin; | |
6700 for ( ; wp != NULL && !got_int; wp = wp->w_next) | |
6701 { | |
682 | 6702 msg_putchar('\n'); |
6703 msg_putchar(wp == curwin ? '>' : ' '); | |
6704 msg_putchar(' '); | |
672 | 6705 msg_putchar(bufIsChanged(wp->w_buffer) ? '+' : ' '); |
6706 msg_putchar(' '); | |
667 | 6707 if (buf_spname(wp->w_buffer) != NULL) |
3839 | 6708 vim_strncpy(IObuff, buf_spname(wp->w_buffer), IOSIZE - 1); |
667 | 6709 else |
6710 home_replace(wp->w_buffer, wp->w_buffer->b_fname, | |
6711 IObuff, IOSIZE, TRUE); | |
6712 msg_outtrans(IObuff); | |
6713 out_flush(); /* output one line at a time */ | |
6714 ui_breakcheck(); | |
6715 } | |
6716 } | |
6717 } | |
6718 | |
7 | 6719 /* |
6720 * ":mode": Set screen mode. | |
6721 * If no argument given, just get the screen size and redraw. | |
6722 */ | |
6723 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6724 ex_mode(exarg_T *eap) |
7 | 6725 { |
6726 if (*eap->arg == NUL) | |
6727 shell_resized(); | |
6728 else | |
6729 mch_screenmode(eap->arg); | |
6730 } | |
6731 | |
6732 /* | |
6733 * ":resize". | |
6734 * set, increment or decrement current window height | |
6735 */ | |
6736 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6737 ex_resize(exarg_T *eap) |
7 | 6738 { |
6739 int n; | |
6740 win_T *wp = curwin; | |
6741 | |
6742 if (eap->addr_count > 0) | |
6743 { | |
6744 n = eap->line2; | |
6745 for (wp = firstwin; wp->w_next != NULL && --n > 0; wp = wp->w_next) | |
6746 ; | |
6747 } | |
6748 | |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8577
diff
changeset
|
6749 # ifdef FEAT_GUI |
7 | 6750 need_mouse_correct = TRUE; |
8643
24b43dd167eb
commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents:
8577
diff
changeset
|
6751 # endif |
7 | 6752 n = atol((char *)eap->arg); |
6753 if (cmdmod.split & WSP_VERT) | |
6754 { | |
6755 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
|
6756 n += curwin->w_width; |
7 | 6757 else if (n == 0 && eap->arg[0] == NUL) /* default is very wide */ |
6758 n = 9999; | |
6759 win_setwidth_win((int)n, wp); | |
6760 } | |
6761 else | |
6762 { | |
6763 if (*eap->arg == '-' || *eap->arg == '+') | |
6764 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
|
6765 else if (n == 0 && eap->arg[0] == NUL) /* default is very high */ |
7 | 6766 n = 9999; |
6767 win_setheight_win((int)n, wp); | |
6768 } | |
6769 } | |
6770 | |
6771 /* | |
6772 * ":find [+command] <file>" command. | |
6773 */ | |
6774 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6775 ex_find(exarg_T *eap) |
7 | 6776 { |
6777 #ifdef FEAT_SEARCHPATH | |
6778 char_u *fname; | |
6779 int count; | |
6780 | |
6781 fname = find_file_in_path(eap->arg, (int)STRLEN(eap->arg), FNAME_MESS, | |
6782 TRUE, curbuf->b_ffname); | |
6783 if (eap->addr_count > 0) | |
6784 { | |
6785 /* Repeat finding the file "count" times. This matters when it | |
6786 * appears several times in the path. */ | |
6787 count = eap->line2; | |
6788 while (fname != NULL && --count > 0) | |
6789 { | |
6790 vim_free(fname); | |
6791 fname = find_file_in_path(NULL, 0, FNAME_MESS, | |
6792 FALSE, curbuf->b_ffname); | |
6793 } | |
6794 } | |
6795 | |
6796 if (fname != NULL) | |
6797 { | |
6798 eap->arg = fname; | |
6799 #endif | |
6800 do_exedit(eap, NULL); | |
6801 #ifdef FEAT_SEARCHPATH | |
6802 vim_free(fname); | |
6803 } | |
6804 #endif | |
6805 } | |
6806 | |
6807 /* | |
167 | 6808 * ":open" simulation: for now just work like ":visual". |
6809 */ | |
6810 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6811 ex_open(exarg_T *eap) |
167 | 6812 { |
6813 regmatch_T regmatch; | |
6814 char_u *p; | |
6815 | |
6816 curwin->w_cursor.lnum = eap->line2; | |
6817 beginline(BL_SOL | BL_FIX); | |
6818 if (*eap->arg == '/') | |
6819 { | |
6820 /* ":open /pattern/": put cursor in column found with pattern */ | |
6821 ++eap->arg; | |
6822 p = skip_regexp(eap->arg, '/', p_magic, NULL); | |
6823 *p = NUL; | |
6824 regmatch.regprog = vim_regcomp(eap->arg, p_magic ? RE_MAGIC : 0); | |
6825 if (regmatch.regprog != NULL) | |
6826 { | |
6827 regmatch.rm_ic = p_ic; | |
6828 p = ml_get_curline(); | |
6829 if (vim_regexec(®match, p, (colnr_T)0)) | |
835 | 6830 curwin->w_cursor.col = (colnr_T)(regmatch.startp[0] - p); |
167 | 6831 else |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
6832 emsg(_(e_nomatch)); |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4803
diff
changeset
|
6833 vim_regfree(regmatch.regprog); |
167 | 6834 } |
6835 /* Move to the NUL, ignore any other arguments. */ | |
6836 eap->arg += STRLEN(eap->arg); | |
6837 } | |
6838 check_cursor(); | |
6839 | |
6840 eap->cmdidx = CMD_visual; | |
6841 do_exedit(eap, NULL); | |
6842 } | |
6843 | |
6844 /* | |
6845 * ":edit", ":badd", ":visual". | |
7 | 6846 */ |
6847 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6848 ex_edit(exarg_T *eap) |
7 | 6849 { |
6850 do_exedit(eap, NULL); | |
6851 } | |
6852 | |
6853 /* | |
6854 * ":edit <file>" command and alikes. | |
6855 */ | |
6856 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6857 do_exedit( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6858 exarg_T *eap, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
6859 win_T *old_curwin) /* curwin before doing a split or NULL */ |
7 | 6860 { |
6861 int n; | |
6862 int need_hide; | |
167 | 6863 int exmode_was = exmode_active; |
7 | 6864 |
17644
daa1dea1c1b3
patch 8.1.1819: :pedit does not work with a popup preview window
Bram Moolenaar <Bram@vim.org>
parents:
17622
diff
changeset
|
6865 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
|
6866 return; |
7 | 6867 /* |
6868 * ":vi" command ends Ex mode. | |
6869 */ | |
6870 if (exmode_active && (eap->cmdidx == CMD_visual | |
6871 || eap->cmdidx == CMD_view)) | |
6872 { | |
6873 exmode_active = FALSE; | |
6874 if (*eap->arg == NUL) | |
167 | 6875 { |
6876 /* Special case: ":global/pat/visual\NLvi-commands" */ | |
6877 if (global_busy) | |
6878 { | |
6879 int rd = RedrawingDisabled; | |
6880 int nwr = no_wait_return; | |
6881 int ms = msg_scroll; | |
6882 #ifdef FEAT_GUI | |
6883 int he = hold_gui_events; | |
6884 #endif | |
6885 | |
6886 if (eap->nextcmd != NULL) | |
6887 { | |
6888 stuffReadbuff(eap->nextcmd); | |
6889 eap->nextcmd = NULL; | |
6890 } | |
6891 | |
6892 if (exmode_was != EXMODE_VIM) | |
6893 settmode(TMODE_RAW); | |
6894 RedrawingDisabled = 0; | |
6895 no_wait_return = 0; | |
6896 need_wait_return = FALSE; | |
6897 msg_scroll = 0; | |
6898 #ifdef FEAT_GUI | |
6899 hold_gui_events = 0; | |
6900 #endif | |
6901 must_redraw = CLEAR; | |
6902 | |
6903 main_loop(FALSE, TRUE); | |
6904 | |
6905 RedrawingDisabled = rd; | |
6906 no_wait_return = nwr; | |
6907 msg_scroll = ms; | |
6908 #ifdef FEAT_GUI | |
6909 hold_gui_events = he; | |
6910 #endif | |
6911 } | |
7 | 6912 return; |
167 | 6913 } |
7 | 6914 } |
6915 | |
6916 if ((eap->cmdidx == CMD_new | |
675 | 6917 || eap->cmdidx == CMD_tabnew |
6918 || 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
|
6919 || eap->cmdidx == CMD_vnew) && *eap->arg == NUL) |
7 | 6920 { |
675 | 6921 /* ":new" or ":tabnew" without argument: edit an new empty buffer */ |
7 | 6922 setpcmark(); |
6923 (void)do_ecmd(0, NULL, NULL, eap, ECMD_ONE, | |
1743 | 6924 ECMD_HIDE + (eap->forceit ? ECMD_FORCEIT : 0), |
6925 old_curwin == NULL ? curwin : NULL); | |
7 | 6926 } |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
6927 else if ((eap->cmdidx != CMD_split && eap->cmdidx != CMD_vsplit) |
7 | 6928 || *eap->arg != NUL |
6929 #ifdef FEAT_BROWSE | |
6930 || cmdmod.browse | |
6931 #endif | |
6932 ) | |
6933 { | |
822 | 6934 /* Can't edit another file when "curbuf_lock" is set. Only ":edit" |
6935 * can bring us here, others are stopped earlier. */ | |
6936 if (*eap->arg != NUL && curbuf_locked()) | |
6937 return; | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
6938 |
7 | 6939 n = readonlymode; |
6940 if (eap->cmdidx == CMD_view || eap->cmdidx == CMD_sview) | |
6941 readonlymode = TRUE; | |
6942 else if (eap->cmdidx == CMD_enew) | |
6943 readonlymode = FALSE; /* 'readonly' doesn't make sense in an | |
6944 empty buffer */ | |
6945 setpcmark(); | |
6946 if (do_ecmd(0, (eap->cmdidx == CMD_enew ? NULL : eap->arg), | |
6947 NULL, eap, | |
6948 /* ":edit" goes to first line if Vi compatible */ | |
6949 (*eap->arg == NUL && eap->do_ecmd_lnum == 0 | |
6950 && vim_strchr(p_cpo, CPO_GOTO1) != NULL) | |
6951 ? 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
|
6952 (buf_hide(curbuf) ? ECMD_HIDE : 0) |
7 | 6953 + (eap->forceit ? ECMD_FORCEIT : 0) |
5741 | 6954 /* after a split we can use an existing buffer */ |
6955 + (old_curwin != NULL ? ECMD_OLDBUF : 0) | |
7 | 6956 + (eap->cmdidx == CMD_badd ? ECMD_ADDBUF : 0 ) |
1743 | 6957 , old_curwin == NULL ? curwin : NULL) == FAIL) |
7 | 6958 { |
6959 /* Editing the file failed. If the window was split, close it. */ | |
6960 if (old_curwin != NULL) | |
6961 { | |
6962 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
|
6963 if (!need_hide || buf_hide(curbuf)) |
7 | 6964 { |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
6965 #if defined(FEAT_EVAL) |
24 | 6966 cleanup_T cs; |
6967 | |
6968 /* Reset the error/interrupt/exception state here so that | |
6969 * aborting() returns FALSE when closing a window. */ | |
6970 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
|
6971 #endif |
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
6972 #ifdef FEAT_GUI |
7 | 6973 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
|
6974 #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
|
6975 win_close(curwin, !need_hide && !buf_hide(curbuf)); |
24 | 6976 |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
6977 #if defined(FEAT_EVAL) |
24 | 6978 /* Restore the error/interrupt/exception state if not |
6979 * discarded by a new aborting error, interrupt, or | |
6980 * uncaught exception. */ | |
6981 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
|
6982 #endif |
7 | 6983 } |
6984 } | |
6985 } | |
6986 else if (readonlymode && curbuf->b_nwindows == 1) | |
6987 { | |
6988 /* When editing an already visited buffer, 'readonly' won't be set | |
6989 * but the previous value is kept. With ":view" and ":sview" we | |
6990 * want the file to be readonly, except when another window is | |
6991 * editing the same buffer. */ | |
6992 curbuf->b_p_ro = TRUE; | |
6993 } | |
6994 readonlymode = n; | |
6995 } | |
6996 else | |
6997 { | |
6998 if (eap->do_ecmd_cmd != NULL) | |
6999 do_cmdline_cmd(eap->do_ecmd_cmd); | |
7000 #ifdef FEAT_TITLE | |
7001 n = curwin->w_arg_idx_invalid; | |
7002 #endif | |
7003 check_arg_idx(curwin); | |
7004 #ifdef FEAT_TITLE | |
7005 if (n != curwin->w_arg_idx_invalid) | |
7006 maketitle(); | |
7007 #endif | |
7008 } | |
7009 | |
7010 /* | |
7011 * if ":split file" worked, set alternate file name in old window to new | |
7012 * file | |
7013 */ | |
7014 if (old_curwin != NULL | |
7015 && *eap->arg != NUL | |
7016 && curwin != old_curwin | |
7017 && win_valid(old_curwin) | |
22 | 7018 && old_curwin->w_buffer != curbuf |
7019 && !cmdmod.keepalt) | |
7 | 7020 old_curwin->w_alt_fnum = curbuf->b_fnum; |
7021 | |
7022 ex_no_reprint = TRUE; | |
7023 } | |
7024 | |
7025 #ifndef FEAT_GUI | |
7026 /* | |
7027 * ":gui" and ":gvim" when there is no GUI. | |
7028 */ | |
7029 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7030 ex_nogui(exarg_T *eap) |
7 | 7031 { |
7032 eap->errmsg = e_nogvim; | |
7033 } | |
7034 #endif | |
7035 | |
15868
7fad90423bd2
patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15866
diff
changeset
|
7036 #if defined(FEAT_GUI_MSWIN) && defined(FEAT_MENU) && defined(FEAT_TEAROFF) |
7 | 7037 static void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7038 ex_tearoff(exarg_T *eap) |
7 | 7039 { |
7040 gui_make_tearoff(eap->arg); | |
7041 } | |
7042 #endif | |
7043 | |
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
|
7044 #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
|
7045 || defined(FEAT_TERM_POPUP_MENU)) && defined(FEAT_MENU) |
7 | 7046 static void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7047 ex_popup(exarg_T *eap) |
7 | 7048 { |
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
|
7049 # 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
|
7050 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
|
7051 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
|
7052 # 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
|
7053 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
|
7054 # 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
|
7055 # 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
|
7056 # 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
|
7057 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
|
7058 # endif |
7 | 7059 } |
7060 #endif | |
7061 | |
7062 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7063 ex_swapname(exarg_T *eap UNUSED) |
7 | 7064 { |
7065 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
|
7066 msg(_("No swap file")); |
7 | 7067 else |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15510
diff
changeset
|
7068 msg((char *)curbuf->b_ml.ml_mfp->mf_fname); |
7 | 7069 } |
7070 | |
7071 /* | |
7072 * ":syncbind" forces all 'scrollbind' windows to have the same relative | |
7073 * offset. | |
7074 * (1998-11-02 16:21:01 R. Edward Ralston <eralston@computer.org>) | |
7075 */ | |
7076 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7077 ex_syncbind(exarg_T *eap UNUSED) |
7 | 7078 { |
7079 win_T *wp; | |
5566 | 7080 win_T *save_curwin = curwin; |
7081 buf_T *save_curbuf = curbuf; | |
7 | 7082 long topline; |
7083 long y; | |
7084 linenr_T old_linenr = curwin->w_cursor.lnum; | |
7085 | |
7086 setpcmark(); | |
7087 | |
7088 /* | |
7089 * determine max topline | |
7090 */ | |
7091 if (curwin->w_p_scb) | |
7092 { | |
7093 topline = curwin->w_topline; | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9538
diff
changeset
|
7094 FOR_ALL_WINDOWS(wp) |
7 | 7095 { |
7096 if (wp->w_p_scb && wp->w_buffer) | |
7097 { | |
15713
ad8b2c109b22
patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents:
15663
diff
changeset
|
7098 y = wp->w_buffer->b_ml.ml_line_count - get_scrolloff_value(); |
7 | 7099 if (topline > y) |
7100 topline = y; | |
7101 } | |
7102 } | |
7103 if (topline < 1) | |
7104 topline = 1; | |
7105 } | |
7106 else | |
7107 { | |
7108 topline = 1; | |
7109 } | |
7110 | |
7111 | |
7112 /* | |
5566 | 7113 * Set all scrollbind windows to the same topline. |
7 | 7114 */ |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9538
diff
changeset
|
7115 FOR_ALL_WINDOWS(curwin) |
7 | 7116 { |
7117 if (curwin->w_p_scb) | |
7118 { | |
5566 | 7119 curbuf = curwin->w_buffer; |
7 | 7120 y = topline - curwin->w_topline; |
7121 if (y > 0) | |
7122 scrollup(y, TRUE); | |
7123 else | |
7124 scrolldown(-y, TRUE); | |
7125 curwin->w_scbind_pos = topline; | |
7126 redraw_later(VALID); | |
7127 cursor_correct(); | |
7128 curwin->w_redr_status = TRUE; | |
7129 } | |
7130 } | |
5566 | 7131 curwin = save_curwin; |
7132 curbuf = save_curbuf; | |
7 | 7133 if (curwin->w_p_scb) |
7134 { | |
7135 did_syncbind = TRUE; | |
7136 checkpcmark(); | |
7137 if (old_linenr != curwin->w_cursor.lnum) | |
7138 { | |
7139 char_u ctrl_o[2]; | |
7140 | |
7141 ctrl_o[0] = Ctrl_O; | |
7142 ctrl_o[1] = 0; | |
7143 ins_typebuf(ctrl_o, REMAP_NONE, 0, TRUE, FALSE); | |
7144 } | |
7145 } | |
7146 } | |
7147 | |
7148 | |
7149 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7150 ex_read(exarg_T *eap) |
7 | 7151 { |
167 | 7152 int i; |
7153 int empty = (curbuf->b_ml.ml_flags & ML_EMPTY); | |
7154 linenr_T lnum; | |
7 | 7155 |
7156 if (eap->usefilter) /* :r!cmd */ | |
7157 do_bang(1, eap, FALSE, FALSE, TRUE); | |
7158 else | |
7159 { | |
7160 if (u_save(eap->line2, (linenr_T)(eap->line2 + 1)) == FAIL) | |
7161 return; | |
7162 | |
7163 #ifdef FEAT_BROWSE | |
7164 if (cmdmod.browse) | |
7165 { | |
7166 char_u *browseFile; | |
7167 | |
28 | 7168 browseFile = do_browse(0, (char_u *)_("Append File"), eap->arg, |
7 | 7169 NULL, NULL, NULL, curbuf); |
7170 if (browseFile != NULL) | |
7171 { | |
7172 i = readfile(browseFile, NULL, | |
7173 eap->line2, (linenr_T)0, (linenr_T)MAXLNUM, eap, 0); | |
7174 vim_free(browseFile); | |
7175 } | |
7176 else | |
7177 i = OK; | |
7178 } | |
7179 else | |
7180 #endif | |
7181 if (*eap->arg == NUL) | |
7182 { | |
7183 if (check_fname() == FAIL) /* check for no file name */ | |
7184 return; | |
7185 i = readfile(curbuf->b_ffname, curbuf->b_fname, | |
7186 eap->line2, (linenr_T)0, (linenr_T)MAXLNUM, eap, 0); | |
7187 } | |
7188 else | |
7189 { | |
7190 if (vim_strchr(p_cpo, CPO_ALTREAD) != NULL) | |
7191 (void)setaltfname(eap->arg, eap->arg, (linenr_T)1); | |
7192 i = readfile(eap->arg, NULL, | |
7193 eap->line2, (linenr_T)0, (linenr_T)MAXLNUM, eap, 0); | |
7194 | |
7195 } | |
10575
01a5f64a7a20
patch 8.0.0177: BufEnter autocommand not fired for a directory
Christian Brabandt <cb@256bit.org>
parents:
10520
diff
changeset
|
7196 if (i != OK) |
7 | 7197 { |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
7198 #if defined(FEAT_EVAL) |
7 | 7199 if (!aborting()) |
7200 #endif | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7201 semsg(_(e_notopen), eap->arg); |
7 | 7202 } |
7203 else | |
167 | 7204 { |
7205 if (empty && exmode_active) | |
7206 { | |
7207 /* Delete the empty line that remains. Historically ex does | |
7208 * this but vi doesn't. */ | |
7209 if (eap->line2 == 0) | |
7210 lnum = curbuf->b_ml.ml_line_count; | |
7211 else | |
7212 lnum = 1; | |
573 | 7213 if (*ml_get(lnum) == NUL && u_savedel(lnum, 1L) == OK) |
167 | 7214 { |
7215 ml_delete(lnum, FALSE); | |
573 | 7216 if (curwin->w_cursor.lnum > 1 |
7217 && curwin->w_cursor.lnum >= lnum) | |
167 | 7218 --curwin->w_cursor.lnum; |
1929 | 7219 deleted_lines_mark(lnum, 1L); |
167 | 7220 } |
7221 } | |
7 | 7222 redraw_curbuf_later(VALID); |
167 | 7223 } |
7 | 7224 } |
7225 } | |
7226 | |
358 | 7227 static char_u *prev_dir = NULL; |
7228 | |
7229 #if defined(EXITFREE) || defined(PROTO) | |
7230 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7231 free_cd_dir(void) |
358 | 7232 { |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13221
diff
changeset
|
7233 VIM_CLEAR(prev_dir); |
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13221
diff
changeset
|
7234 VIM_CLEAR(globaldir); |
358 | 7235 } |
7236 #endif | |
7237 | |
4704
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
7238 /* |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
7239 * 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
|
7240 * 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
|
7241 * 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
|
7242 */ |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
7243 void |
16576
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7244 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
|
7245 { |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7246 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
|
7247 // 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
|
7248 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
|
7249 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
|
7250 if (scope != CDSCOPE_GLOBAL) |
4704
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
7251 { |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
7252 /* 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
|
7253 * directory as global directory. */ |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
7254 if (globaldir == NULL && prev_dir != NULL) |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
7255 globaldir = vim_strsave(prev_dir); |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
7256 /* Remember this local directory for the window. */ |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
7257 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
|
7258 { |
16576
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7259 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
|
7260 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
|
7261 else |
8c3a1bd270bb
patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents:
16411
diff
changeset
|
7262 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
|
7263 } |
4704
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
7264 } |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
7265 else |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
7266 { |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
7267 /* 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
|
7268 * name. */ |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13221
diff
changeset
|
7269 VIM_CLEAR(globaldir); |
4704
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
7270 } |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
7271 |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
7272 shorten_fnames(TRUE); |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
7273 } |
542af01979be
updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents:
4435
diff
changeset
|
7274 |
16576
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7275 /* |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7276 * 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
|
7277 * 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
|
7278 * 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
|
7279 * 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
|
7280 * 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
|
7281 */ |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7282 int |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7283 changedir_func( |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7284 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
|
7285 int forceit, |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7286 cdscope_T scope) |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7287 { |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7288 char_u *tofree; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7289 int dir_differs; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7290 int retval = FALSE; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7291 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7292 if (allbuf_locked()) |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7293 return FALSE; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7294 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7295 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
|
7296 { |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7297 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
|
7298 return FALSE; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7299 } |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7300 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7301 // ":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
|
7302 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
|
7303 { |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7304 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
|
7305 { |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7306 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
|
7307 return FALSE; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7308 } |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7309 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
|
7310 } |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7311 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7312 // 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
|
7313 tofree = prev_dir; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7314 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
|
7315 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
|
7316 else |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7317 prev_dir = NULL; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7318 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7319 #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
|
7320 // 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
|
7321 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
|
7322 { |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7323 // 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
|
7324 # ifdef VMS |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7325 char_u *p; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7326 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7327 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
|
7328 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
|
7329 NameBuff[0] = NUL; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7330 else |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7331 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
|
7332 # else |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7333 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
|
7334 # endif |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7335 new_dir = NameBuff; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7336 } |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7337 #endif |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7338 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
|
7339 || 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
|
7340 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
|
7341 emsg(_(e_failed)); |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7342 else |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7343 { |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7344 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
|
7345 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7346 post_chdir(scope); |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7347 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7348 if (dir_differs) |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7349 { |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7350 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
|
7351 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
|
7352 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
|
7353 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
|
7354 else |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7355 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
|
7356 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
|
7357 curbuf); |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7358 } |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7359 retval = TRUE; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7360 } |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7361 vim_free(tofree); |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7362 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7363 return retval; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7364 } |
358 | 7365 |
7 | 7366 /* |
16427
8c3a1bd270bb
patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents:
16411
diff
changeset
|
7367 * ":cd", ":tcd", ":lcd", ":chdir" ":tchdir" and ":lchdir". |
7 | 7368 */ |
1411 | 7369 void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7370 ex_cd(exarg_T *eap) |
7 | 7371 { |
15184
90ab2d3ce11d
patch 8.1.0602: DirChanged is also triggered when directory didn't change
Bram Moolenaar <Bram@vim.org>
parents:
15152
diff
changeset
|
7372 char_u *new_dir; |
7 | 7373 |
7374 new_dir = eap->arg; | |
7375 #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
|
7376 // for non-UNIX ":cd" means: print current directory |
7 | 7377 if (*new_dir == NUL) |
7378 ex_pwd(NULL); | |
7379 else | |
7380 #endif | |
7381 { | |
16576
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7382 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
|
7383 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7384 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
|
7385 scope = CDSCOPE_WINDOW; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7386 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
|
7387 scope = CDSCOPE_TABPAGE; |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7388 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7389 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
|
7390 { |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
16515
diff
changeset
|
7391 // Echo the new current directory if the command was typed. |
1930 | 7392 if (KeyTyped || p_verbose >= 5) |
7 | 7393 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
|
7394 } |
7 | 7395 } |
7396 } | |
7397 | |
7398 /* | |
7399 * ":pwd". | |
7400 */ | |
7401 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7402 ex_pwd(exarg_T *eap UNUSED) |
7 | 7403 { |
7404 if (mch_dirname(NameBuff, MAXPATHL) == OK) | |
7405 { | |
7406 #ifdef BACKSLASH_IN_FILENAME | |
7407 slash_adjust(NameBuff); | |
7408 #endif | |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15510
diff
changeset
|
7409 msg((char *)NameBuff); |
7 | 7410 } |
7411 else | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7412 emsg(_("E187: Unknown")); |
7 | 7413 } |
7414 | |
7415 /* | |
7416 * ":=". | |
7417 */ | |
7418 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7419 ex_equal(exarg_T *eap) |
7 | 7420 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7421 smsg("%ld", (long)eap->line2); |
167 | 7422 ex_may_print(eap); |
7 | 7423 } |
7424 | |
7425 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7426 ex_sleep(exarg_T *eap) |
7 | 7427 { |
236 | 7428 int n; |
7429 long len; | |
7 | 7430 |
7431 if (cursor_valid()) | |
7432 { | |
7433 n = W_WINROW(curwin) + curwin->w_wrow - msg_scrolled; | |
7434 if (n >= 0) | |
12513
3ca08bf99396
patch 8.0.1135: W_WINCOL() is always the same
Christian Brabandt <cb@256bit.org>
parents:
12477
diff
changeset
|
7435 windgoto((int)n, curwin->w_wincol + curwin->w_wcol); |
7 | 7436 } |
236 | 7437 |
7438 len = eap->line2; | |
7439 switch (*eap->arg) | |
7440 { | |
7441 case 'm': break; | |
7442 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
|
7443 default: semsg(_(e_invarg2), eap->arg); return; |
236 | 7444 } |
7445 do_sleep(len); | |
7 | 7446 } |
7447 | |
7448 /* | |
7449 * Sleep for "msec" milliseconds, but keep checking for a CTRL-C every second. | |
7450 */ | |
7451 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7452 do_sleep(long msec) |
7 | 7453 { |
17712
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
7454 long done = 0; |
8577
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
7455 long wait_now; |
17712
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
7456 # ifdef ELAPSED_FUNC |
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
7457 elapsed_T start_tv; |
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
7458 |
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
7459 // Remember at what time we started, so that we know how much longer we |
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
7460 // should wait after waiting for a bit. |
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
7461 ELAPSED_INIT(start_tv); |
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
7462 # endif |
7 | 7463 |
7464 cursor_on(); | |
14860
ac5d0d27aef9
patch 8.1.0442: GUI: cursor not drawn after ":redraw | sleep"
Christian Brabandt <cb@256bit.org>
parents:
14760
diff
changeset
|
7465 out_flush_cursor(FALSE, FALSE); |
17712
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
7466 while (!got_int && done < msec) |
8577
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
7467 { |
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
7468 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
|
7469 #ifdef FEAT_TIMERS |
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
7470 { |
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
7471 long due_time = check_due_timer(); |
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
7472 |
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
7473 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
|
7474 wait_now = due_time; |
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
7475 } |
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
7476 #endif |
10240
175b1116f96a
commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents:
10184
diff
changeset
|
7477 #ifdef FEAT_JOB_CHANNEL |
17708
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17652
diff
changeset
|
7478 if (has_any_channel() && wait_now > 20L) |
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17652
diff
changeset
|
7479 wait_now = 20L; |
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17652
diff
changeset
|
7480 #endif |
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17652
diff
changeset
|
7481 #ifdef FEAT_SOUND |
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17652
diff
changeset
|
7482 if (has_any_sound_callback() && wait_now > 20L) |
10696f279e20
patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents:
17652
diff
changeset
|
7483 wait_now = 20L; |
10240
175b1116f96a
commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents:
10184
diff
changeset
|
7484 #endif |
8577
63dc856bd13d
commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents:
8524
diff
changeset
|
7485 ui_delay(wait_now, TRUE); |
17712
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
7486 |
10240
175b1116f96a
commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents:
10184
diff
changeset
|
7487 #ifdef FEAT_JOB_CHANNEL |
175b1116f96a
commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents:
10184
diff
changeset
|
7488 if (has_any_channel()) |
175b1116f96a
commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents:
10184
diff
changeset
|
7489 ui_breakcheck_force(TRUE); |
175b1116f96a
commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents:
10184
diff
changeset
|
7490 else |
175b1116f96a
commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents:
10184
diff
changeset
|
7491 #endif |
175b1116f96a
commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents:
10184
diff
changeset
|
7492 ui_breakcheck(); |
7109
fa95595fbc52
commit https://github.com/vim/vim/commit/93c88e0f6a4a8f7634ed84721daf4af46fc0d5db
Christian Brabandt <cb@256bit.org>
parents:
7105
diff
changeset
|
7493 #ifdef MESSAGE_QUEUE |
17712
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
7494 // Process the netbeans and clientserver messages that may have been |
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
7495 // received in the call to ui_breakcheck() when the GUI is in use. This |
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
7496 // may occur when running a test case. |
7109
fa95595fbc52
commit https://github.com/vim/vim/commit/93c88e0f6a4a8f7634ed84721daf4af46fc0d5db
Christian Brabandt <cb@256bit.org>
parents:
7105
diff
changeset
|
7497 parse_queued_messages(); |
3151 | 7498 #endif |
17712
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
7499 |
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
7500 # ifdef ELAPSED_FUNC |
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
7501 // actual time passed |
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
7502 done = ELAPSED_FUNC(start_tv); |
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
7503 # else |
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
7504 // guestimate time passed (will actually be more) |
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
7505 done += wait_now; |
316ae5631c1d
patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents:
17708
diff
changeset
|
7506 # endif |
7 | 7507 } |
14284
7cd8298c4c04
patch 8.1.0158: GUI: input() fails if CTRL-C was pressed before
Christian Brabandt <cb@256bit.org>
parents:
14266
diff
changeset
|
7508 |
7cd8298c4c04
patch 8.1.0158: GUI: input() fails if CTRL-C was pressed before
Christian Brabandt <cb@256bit.org>
parents:
14266
diff
changeset
|
7509 // 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
|
7510 // 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
|
7511 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
|
7512 (void)vpeekc(); |
7 | 7513 } |
7514 | |
7515 /* | |
7516 * ":winsize" command (obsolete). | |
7517 */ | |
7518 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7519 ex_winsize(exarg_T *eap) |
7 | 7520 { |
7521 int w, h; | |
7522 char_u *arg = eap->arg; | |
7523 char_u *p; | |
7524 | |
7525 w = getdigits(&arg); | |
7526 arg = skipwhite(arg); | |
7527 p = arg; | |
7528 h = getdigits(&arg); | |
7529 if (*p != NUL && *arg == NUL) | |
7530 set_shellsize(w, h, TRUE); | |
7531 else | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7532 emsg(_("E465: :winsize requires two number arguments")); |
7 | 7533 } |
7534 | |
7535 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7536 ex_wincmd(exarg_T *eap) |
7 | 7537 { |
7538 int xchar = NUL; | |
7539 char_u *p; | |
7540 | |
7541 if (*eap->arg == 'g' || *eap->arg == Ctrl_G) | |
7542 { | |
7543 /* CTRL-W g and CTRL-W CTRL-G have an extra command character */ | |
7544 if (eap->arg[1] == NUL) | |
7545 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7546 emsg(_(e_invarg)); |
7 | 7547 return; |
7548 } | |
7549 xchar = eap->arg[1]; | |
7550 p = eap->arg + 2; | |
7551 } | |
7552 else | |
7553 p = eap->arg + 1; | |
7554 | |
7555 eap->nextcmd = check_nextcmd(p); | |
7556 p = skipwhite(p); | |
7557 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
|
7558 emsg(_(e_invarg)); |
2887 | 7559 else if (!eap->skip) |
7 | 7560 { |
7561 /* Pass flags on for ":vertical wincmd ]". */ | |
7562 postponed_split_flags = cmdmod.split; | |
1090 | 7563 postponed_split_tab = cmdmod.tab; |
7 | 7564 do_window(*eap->arg, eap->addr_count > 0 ? eap->line2 : 0L, xchar); |
7565 postponed_split_flags = 0; | |
1090 | 7566 postponed_split_tab = 0; |
7 | 7567 } |
7568 } | |
7569 | |
11 | 7570 #if defined(FEAT_GUI) || defined(UNIX) || defined(VMS) || defined(MSWIN) |
7 | 7571 /* |
7572 * ":winpos". | |
7573 */ | |
7574 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7575 ex_winpos(exarg_T *eap) |
7 | 7576 { |
7577 int x, y; | |
7578 char_u *arg = eap->arg; | |
7579 char_u *p; | |
7580 | |
7581 if (*arg == NUL) | |
7582 { | |
11 | 7583 # 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
|
7584 # 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
|
7585 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
|
7586 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
|
7587 # elif defined(FEAT_GUI) |
7 | 7588 if (gui.in_use && gui_mch_get_winpos(&x, &y) != FAIL) |
11 | 7589 # else |
7590 if (mch_get_winpos(&x, &y) != FAIL) | |
7591 # endif | |
7 | 7592 { |
7593 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
|
7594 msg((char *)IObuff); |
7 | 7595 } |
7596 else | |
7597 # endif | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7598 emsg(_("E188: Obtaining window position not implemented for this platform")); |
7 | 7599 } |
7600 else | |
7601 { | |
7602 x = getdigits(&arg); | |
7603 arg = skipwhite(arg); | |
7604 p = arg; | |
7605 y = getdigits(&arg); | |
7606 if (*p == NUL || *arg != NUL) | |
7607 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7608 emsg(_("E466: :winpos requires two number arguments")); |
7 | 7609 return; |
7610 } | |
7611 # ifdef FEAT_GUI | |
7612 if (gui.in_use) | |
7613 gui_mch_set_winpos(x, y); | |
7614 else if (gui.starting) | |
7615 { | |
7616 /* Remember the coordinates for when the window is opened. */ | |
7617 gui_win_x = x; | |
7618 gui_win_y = y; | |
7619 } | |
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
|
7620 # if defined(HAVE_TGETENT) || defined(VIMDLL) |
7 | 7621 else |
7622 # 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
|
7623 # 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
|
7624 # if defined(MSWIN) && (!defined(FEAT_GUI) || defined(VIMDLL)) |
11 | 7625 mch_set_winpos(x, y); |
7 | 7626 # endif |
7627 # ifdef HAVE_TGETENT | |
7628 if (*T_CWP) | |
7629 term_set_winpos(x, y); | |
7630 # endif | |
7631 } | |
7632 } | |
7633 #endif | |
7634 | |
7635 /* | |
7636 * Handle command that work like operators: ":delete", ":yank", ":>" and ":<". | |
7637 */ | |
7638 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7639 ex_operators(exarg_T *eap) |
7 | 7640 { |
7641 oparg_T oa; | |
7642 | |
7643 clear_oparg(&oa); | |
7644 oa.regname = eap->regname; | |
7645 oa.start.lnum = eap->line1; | |
7646 oa.end.lnum = eap->line2; | |
7647 oa.line_count = eap->line2 - eap->line1 + 1; | |
7648 oa.motion_type = MLINE; | |
7649 virtual_op = FALSE; | |
7650 if (eap->cmdidx != CMD_yank) /* position cursor for undo */ | |
7651 { | |
7652 setpcmark(); | |
7653 curwin->w_cursor.lnum = eap->line1; | |
7654 beginline(BL_SOL | BL_FIX); | |
7655 } | |
7656 | |
5498 | 7657 if (VIsual_active) |
7658 end_visual_mode(); | |
7659 | |
7 | 7660 switch (eap->cmdidx) |
7661 { | |
7662 case CMD_delete: | |
7663 oa.op_type = OP_DELETE; | |
7664 op_delete(&oa); | |
7665 break; | |
7666 | |
7667 case CMD_yank: | |
7668 oa.op_type = OP_YANK; | |
7669 (void)op_yank(&oa, FALSE, TRUE); | |
7670 break; | |
7671 | |
7672 default: /* CMD_rshift or CMD_lshift */ | |
4889
25d64a4edc0b
updated for version 7.3.1190
Bram Moolenaar <bram@vim.org>
parents:
4857
diff
changeset
|
7673 if ( |
7 | 7674 #ifdef FEAT_RIGHTLEFT |
4889
25d64a4edc0b
updated for version 7.3.1190
Bram Moolenaar <bram@vim.org>
parents:
4857
diff
changeset
|
7675 (eap->cmdidx == CMD_rshift) ^ curwin->w_p_rl |
25d64a4edc0b
updated for version 7.3.1190
Bram Moolenaar <bram@vim.org>
parents:
4857
diff
changeset
|
7676 #else |
25d64a4edc0b
updated for version 7.3.1190
Bram Moolenaar <bram@vim.org>
parents:
4857
diff
changeset
|
7677 eap->cmdidx == CMD_rshift |
25d64a4edc0b
updated for version 7.3.1190
Bram Moolenaar <bram@vim.org>
parents:
4857
diff
changeset
|
7678 #endif |
25d64a4edc0b
updated for version 7.3.1190
Bram Moolenaar <bram@vim.org>
parents:
4857
diff
changeset
|
7679 ) |
7 | 7680 oa.op_type = OP_RSHIFT; |
7681 else | |
7682 oa.op_type = OP_LSHIFT; | |
7683 op_shift(&oa, FALSE, eap->amount); | |
7684 break; | |
7685 } | |
7686 virtual_op = MAYBE; | |
167 | 7687 ex_may_print(eap); |
7 | 7688 } |
7689 | |
7690 /* | |
7691 * ":put". | |
7692 */ | |
7693 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7694 ex_put(exarg_T *eap) |
7 | 7695 { |
7696 /* ":0put" works like ":1put!". */ | |
7697 if (eap->line2 == 0) | |
7698 { | |
7699 eap->line2 = 1; | |
7700 eap->forceit = TRUE; | |
7701 } | |
7702 curwin->w_cursor.lnum = eap->line2; | |
167 | 7703 do_put(eap->regname, eap->forceit ? BACKWARD : FORWARD, 1L, |
7704 PUT_LINE|PUT_CURSLINE); | |
7 | 7705 } |
7706 | |
7707 /* | |
7708 * Handle ":copy" and ":move". | |
7709 */ | |
7710 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7711 ex_copymove(exarg_T *eap) |
7 | 7712 { |
7713 long n; | |
7714 | |
14760
fd69edd2c67e
patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents:
14700
diff
changeset
|
7715 n = get_address(eap, &eap->arg, eap->addr_type, FALSE, FALSE, FALSE, 1); |
7 | 7716 if (eap->arg == NULL) /* error detected */ |
7717 { | |
7718 eap->nextcmd = NULL; | |
7719 return; | |
7720 } | |
167 | 7721 get_flags(eap); |
7 | 7722 |
7723 /* | |
7724 * move or copy lines from 'eap->line1'-'eap->line2' to below line 'n' | |
7725 */ | |
7726 if (n == MAXLNUM || n < 0 || n > curbuf->b_ml.ml_line_count) | |
7727 { | |
17650
a1437b8f2fac
patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents:
17644
diff
changeset
|
7728 emsg(_(e_invrange)); |
7 | 7729 return; |
7730 } | |
7731 | |
7732 if (eap->cmdidx == CMD_move) | |
7733 { | |
7734 if (do_move(eap->line1, eap->line2, n) == FAIL) | |
7735 return; | |
7736 } | |
7737 else | |
7738 ex_copy(eap->line1, eap->line2, n); | |
7739 u_clearline(); | |
7740 beginline(BL_SOL | BL_FIX); | |
167 | 7741 ex_may_print(eap); |
7742 } | |
7743 | |
7744 /* | |
7745 * Print the current line if flags were given to the Ex command. | |
7746 */ | |
5776 | 7747 void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7748 ex_may_print(exarg_T *eap) |
167 | 7749 { |
7750 if (eap->flags != 0) | |
7751 { | |
7752 print_line(curwin->w_cursor.lnum, (eap->flags & EXFLAG_NR), | |
7753 (eap->flags & EXFLAG_LIST)); | |
7754 ex_no_reprint = TRUE; | |
7755 } | |
7 | 7756 } |
7757 | |
7758 /* | |
7759 * ":smagic" and ":snomagic". | |
7760 */ | |
7761 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7762 ex_submagic(exarg_T *eap) |
7 | 7763 { |
7764 int magic_save = p_magic; | |
7765 | |
7766 p_magic = (eap->cmdidx == CMD_smagic); | |
7767 do_sub(eap); | |
7768 p_magic = magic_save; | |
7769 } | |
7770 | |
7771 /* | |
7772 * ":join". | |
7773 */ | |
7774 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7775 ex_join(exarg_T *eap) |
7 | 7776 { |
7777 curwin->w_cursor.lnum = eap->line1; | |
7778 if (eap->line1 == eap->line2) | |
7779 { | |
7780 if (eap->addr_count >= 2) /* :2,2join does nothing */ | |
7781 return; | |
7782 if (eap->line2 == curbuf->b_ml.ml_line_count) | |
7783 { | |
7784 beep_flush(); | |
7785 return; | |
7786 } | |
7787 ++eap->line2; | |
7788 } | |
5848 | 7789 (void)do_join(eap->line2 - eap->line1 + 1, !eap->forceit, TRUE, TRUE, TRUE); |
7 | 7790 beginline(BL_WHITE | BL_FIX); |
167 | 7791 ex_may_print(eap); |
7 | 7792 } |
7793 | |
7794 /* | |
7795 * ":[addr]@r" or ":[addr]*r": execute register | |
7796 */ | |
7797 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7798 ex_at(exarg_T *eap) |
7 | 7799 { |
7800 int c; | |
1973 | 7801 int prev_len = typebuf.tb_len; |
7 | 7802 |
7803 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
|
7804 check_cursor_col(); |
7 | 7805 |
7806 #ifdef USE_ON_FLY_SCROLL | |
7807 dont_scroll = TRUE; /* disallow scrolling here */ | |
7808 #endif | |
7809 | |
7810 /* get the register name. No name means to use the previous one */ | |
7811 c = *eap->arg; | |
7812 if (c == NUL || (c == '*' && *eap->cmd == '*')) | |
7813 c = '@'; | |
1034 | 7814 /* Put the register in the typeahead buffer with the "silent" flag. */ |
7815 if (do_execreg(c, TRUE, vim_strchr(p_cpo, CPO_EXECBUF) != NULL, TRUE) | |
7816 == FAIL) | |
167 | 7817 { |
7 | 7818 beep_flush(); |
167 | 7819 } |
7 | 7820 else |
7821 { | |
7822 int save_efr = exec_from_reg; | |
7823 | |
7824 exec_from_reg = TRUE; | |
7825 | |
7826 /* | |
7827 * Execute from the typeahead buffer. | |
1973 | 7828 * Continue until the stuff buffer is empty and all added characters |
7829 * have been consumed. | |
7 | 7830 */ |
1973 | 7831 while (!stuff_empty() || typebuf.tb_len > prev_len) |
7 | 7832 (void)do_cmdline(NULL, getexline, NULL, DOCMD_NOWAIT|DOCMD_VERBOSE); |
7833 | |
7834 exec_from_reg = save_efr; | |
7835 } | |
7836 } | |
7837 | |
7838 /* | |
7839 * ":!". | |
7840 */ | |
7841 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7842 ex_bang(exarg_T *eap) |
7 | 7843 { |
7844 do_bang(eap->addr_count, eap, eap->forceit, TRUE, TRUE); | |
7845 } | |
7846 | |
7847 /* | |
7848 * ":undo". | |
7849 */ | |
7850 static void | |
8368
db2a07b710ed
commit https://github.com/vim/vim/commit/f1d2501ebe33e148886c2914acd33140e20ee222
Christian Brabandt <cb@256bit.org>
parents:
8281
diff
changeset
|
7851 ex_undo(exarg_T *eap) |
7 | 7852 { |
771 | 7853 if (eap->addr_count == 1) /* :undo 123 */ |
2281
e41433ea71df
Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents:
2276
diff
changeset
|
7854 undo_time(eap->line2, FALSE, FALSE, TRUE); |
771 | 7855 else |
7856 u_undo(1); | |
7 | 7857 } |
7858 | |
2214
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
7859 #ifdef FEAT_PERSISTENT_UNDO |
2340
99c1eba60b2d
Make automatic prototype generation work with more interfaces.
Bram Moolenaar <bram@vim.org>
parents:
2333
diff
changeset
|
7860 static void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7861 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
|
7862 { |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
7863 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
|
7864 |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
7865 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
|
7866 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
|
7867 } |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
7868 |
2340
99c1eba60b2d
Make automatic prototype generation work with more interfaces.
Bram Moolenaar <bram@vim.org>
parents:
2333
diff
changeset
|
7869 static void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7870 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
|
7871 { |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
7872 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
|
7873 |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
7874 u_compute_hash(hash); |
2238
3d0a7beb0d75
Made reading/writing undo info a bit more robust.
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
7875 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
|
7876 } |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
7877 #endif |
f8222d1f9a73
Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents:
2210
diff
changeset
|
7878 |
7 | 7879 /* |
7880 * ":redo". | |
7881 */ | |
7882 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7883 ex_redo(exarg_T *eap UNUSED) |
7 | 7884 { |
7885 u_redo(1); | |
7886 } | |
7887 | |
7888 /* | |
756 | 7889 * ":earlier" and ":later". |
7890 */ | |
7891 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7892 ex_later(exarg_T *eap) |
756 | 7893 { |
7894 long count = 0; | |
7895 int sec = FALSE; | |
2281
e41433ea71df
Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents:
2276
diff
changeset
|
7896 int file = FALSE; |
756 | 7897 char_u *p = eap->arg; |
7898 | |
7899 if (*p == NUL) | |
7900 count = 1; | |
7901 else if (isdigit(*p)) | |
7902 { | |
7903 count = getdigits(&p); | |
7904 switch (*p) | |
7905 { | |
7906 case 's': ++p; sec = TRUE; break; | |
7907 case 'm': ++p; sec = TRUE; count *= 60; break; | |
7908 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
|
7909 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
|
7910 case 'f': ++p; file = TRUE; break; |
756 | 7911 } |
7912 } | |
7913 | |
7914 if (*p != NUL) | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7915 semsg(_(e_invarg2), eap->arg); |
756 | 7916 else |
2281
e41433ea71df
Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents:
2276
diff
changeset
|
7917 undo_time(eap->cmdidx == CMD_earlier ? -count : count, |
e41433ea71df
Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents:
2276
diff
changeset
|
7918 sec, file, FALSE); |
756 | 7919 } |
7920 | |
7921 /* | |
7 | 7922 * ":redir": start/stop redirection. |
7923 */ | |
7924 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
7925 ex_redir(exarg_T *eap) |
7 | 7926 { |
7927 char *mode; | |
7928 char_u *fname; | |
122 | 7929 char_u *arg = eap->arg; |
7 | 7930 |
9440
73c0d07cc15e
commit https://github.com/vim/vim/commit/ba768495c2e6bae74e49d22d489fbf211ecad55e
Christian Brabandt <cb@256bit.org>
parents:
9438
diff
changeset
|
7931 #ifdef FEAT_EVAL |
9454
9da0cb39cbee
commit https://github.com/vim/vim/commit/79815f1ec77406f2f21a618c053e5793b597db7a
Christian Brabandt <cb@256bit.org>
parents:
9440
diff
changeset
|
7932 if (redir_execute) |
9da0cb39cbee
commit https://github.com/vim/vim/commit/79815f1ec77406f2f21a618c053e5793b597db7a
Christian Brabandt <cb@256bit.org>
parents:
9440
diff
changeset
|
7933 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
7934 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
|
7935 return; |
7897b1e4f3e7
commit https://github.com/vim/vim/commit/245a7cb6d33e556415c9fcaa874b784a6d8f0ef3
Christian Brabandt <cb@256bit.org>
parents:
9432
diff
changeset
|
7936 } |
9440
73c0d07cc15e
commit https://github.com/vim/vim/commit/ba768495c2e6bae74e49d22d489fbf211ecad55e
Christian Brabandt <cb@256bit.org>
parents:
9438
diff
changeset
|
7937 #endif |
9438
7897b1e4f3e7
commit https://github.com/vim/vim/commit/245a7cb6d33e556415c9fcaa874b784a6d8f0ef3
Christian Brabandt <cb@256bit.org>
parents:
9432
diff
changeset
|
7938 |
7 | 7939 if (STRICMP(eap->arg, "END") == 0) |
7940 close_redir(); | |
7941 else | |
7942 { | |
122 | 7943 if (*arg == '>') |
7944 { | |
7945 ++arg; | |
7946 if (*arg == '>') | |
7947 { | |
7948 ++arg; | |
7 | 7949 mode = "a"; |
7950 } | |
7951 else | |
7952 mode = "w"; | |
122 | 7953 arg = skipwhite(arg); |
7 | 7954 |
7955 close_redir(); | |
7956 | |
7957 /* Expand environment variables and "~/". */ | |
122 | 7958 fname = expand_env_save(arg); |
7 | 7959 if (fname == NULL) |
7960 return; | |
7961 #ifdef FEAT_BROWSE | |
7962 if (cmdmod.browse) | |
7963 { | |
7964 char_u *browseFile; | |
7965 | |
28 | 7966 browseFile = do_browse(BROWSE_SAVE, |
7967 (char_u *)_("Save Redirection"), | |
13802
378f9f8e6d8f
patch 8.0.1773: dialog messages are not translated
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
7968 fname, NULL, NULL, |
378f9f8e6d8f
patch 8.0.1773: dialog messages are not translated
Christian Brabandt <cb@256bit.org>
parents:
13792
diff
changeset
|
7969 (char_u *)_(BROWSE_FILTER_ALL_FILES), curbuf); |
7 | 7970 if (browseFile == NULL) |
7971 return; /* operation cancelled */ | |
7972 vim_free(fname); | |
7973 fname = browseFile; | |
7974 eap->forceit = TRUE; /* since dialog already asked */ | |
7975 } | |
7976 #endif | |
7977 | |
7978 redir_fd = open_exfile(fname, eap->forceit, mode); | |
7979 vim_free(fname); | |
7980 } | |
7981 #ifdef FEAT_EVAL | |
122 | 7982 else if (*arg == '@') |
7 | 7983 { |
7984 /* redirect to a register a-z (resp. A-Z for appending) */ | |
7985 close_redir(); | |
122 | 7986 ++arg; |
7987 if (ASCII_ISALPHA(*arg) | |
7 | 7988 # ifdef FEAT_CLIPBOARD |
122 | 7989 || *arg == '*' |
1038 | 7990 || *arg == '+' |
7 | 7991 # endif |
122 | 7992 || *arg == '"') |
7993 { | |
7994 redir_reg = *arg++; | |
1427 | 7995 if (*arg == '>' && arg[1] == '>') /* append */ |
268 | 7996 arg += 2; |
1427 | 7997 else |
7 | 7998 { |
1427 | 7999 /* Can use both "@a" and "@a>". */ |
296 | 8000 if (*arg == '>') |
8001 arg++; | |
1427 | 8002 /* Make register empty when not using @A-@Z and the |
8003 * command is valid. */ | |
8004 if (*arg == NUL && !isupper(redir_reg)) | |
8005 write_reg_contents(redir_reg, (char_u *)"", -1, FALSE); | |
7 | 8006 } |
167 | 8007 } |
8008 if (*arg != NUL) | |
8009 { | |
268 | 8010 redir_reg = 0; |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8011 semsg(_(e_invarg2), eap->arg); |
167 | 8012 } |
8013 } | |
8014 else if (*arg == '=' && arg[1] == '>') | |
8015 { | |
8016 int append; | |
8017 | |
8018 /* redirect to a variable */ | |
8019 close_redir(); | |
8020 arg += 2; | |
8021 | |
8022 if (*arg == '>') | |
8023 { | |
8024 ++arg; | |
8025 append = TRUE; | |
7 | 8026 } |
8027 else | |
167 | 8028 append = FALSE; |
8029 | |
8030 if (var_redir_start(skipwhite(arg), append) == OK) | |
8031 redir_vname = 1; | |
7 | 8032 } |
8033 #endif | |
8034 | |
8035 /* TODO: redirect to a buffer */ | |
8036 | |
8037 else | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8038 semsg(_(e_invarg2), eap->arg); |
7 | 8039 } |
972 | 8040 |
8041 /* Make sure redirection is not off. Can happen for cmdline completion | |
8042 * that indirectly invokes a command to catch its output. */ | |
8043 if (redir_fd != NULL | |
8044 #ifdef FEAT_EVAL | |
8045 || redir_reg || redir_vname | |
8046 #endif | |
8047 ) | |
8048 redir_off = FALSE; | |
7 | 8049 } |
8050 | |
8051 /* | |
8052 * ":redraw": force redraw | |
8053 */ | |
7864
6b0891de44a9
commit https://github.com/vim/vim/commit/fb1f62691eae7c79a28b3b17a60e72ce198c71a2
Christian Brabandt <cb@256bit.org>
parents:
7850
diff
changeset
|
8054 void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8055 ex_redraw(exarg_T *eap) |
7 | 8056 { |
8057 int r = RedrawingDisabled; | |
8058 int p = p_lz; | |
8059 | |
8060 RedrawingDisabled = 0; | |
8061 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
|
8062 validate_cursor(); |
7 | 8063 update_topline(); |
5735 | 8064 update_screen(eap->forceit ? CLEAR : VIsual_active ? INVERTED : 0); |
7 | 8065 #ifdef FEAT_TITLE |
8066 if (need_maketitle) | |
8067 maketitle(); | |
8068 #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
|
8069 #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
|
8070 # 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
|
8071 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
|
8072 # 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
|
8073 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
|
8074 #endif |
7 | 8075 RedrawingDisabled = r; |
8076 p_lz = p; | |
8077 | |
8078 /* Reset msg_didout, so that a message that's there is overwritten. */ | |
8079 msg_didout = FALSE; | |
8080 msg_col = 0; | |
8081 | |
5198
1b89e3f916c5
updated for version 7.4a.025
Bram Moolenaar <bram@vim.org>
parents:
4928
diff
changeset
|
8082 /* No need to wait after an intentional redraw. */ |
1b89e3f916c5
updated for version 7.4a.025
Bram Moolenaar <bram@vim.org>
parents:
4928
diff
changeset
|
8083 need_wait_return = FALSE; |
1b89e3f916c5
updated for version 7.4a.025
Bram Moolenaar <bram@vim.org>
parents:
4928
diff
changeset
|
8084 |
7 | 8085 out_flush(); |
8086 } | |
8087 | |
8088 /* | |
8089 * ":redrawstatus": force redraw of status line(s) | |
8090 */ | |
8091 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8092 ex_redrawstatus(exarg_T *eap UNUSED) |
7 | 8093 { |
8094 int r = RedrawingDisabled; | |
8095 int p = p_lz; | |
8096 | |
8097 RedrawingDisabled = 0; | |
8098 p_lz = FALSE; | |
8099 if (eap->forceit) | |
8100 status_redraw_all(); | |
8101 else | |
8102 status_redraw_curbuf(); | |
5735 | 8103 update_screen(VIsual_active ? INVERTED : 0); |
7 | 8104 RedrawingDisabled = r; |
8105 p_lz = p; | |
8106 out_flush(); | |
8107 } | |
8108 | |
15396
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
8109 /* |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
8110 * ":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
|
8111 */ |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
8112 static void |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
8113 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
|
8114 { |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
8115 int r = RedrawingDisabled; |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
8116 int p = p_lz; |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
8117 |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
8118 RedrawingDisabled = 0; |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
8119 p_lz = FALSE; |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
8120 |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
8121 draw_tabline(); |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
8122 |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
8123 RedrawingDisabled = r; |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
8124 p_lz = p; |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
8125 out_flush(); |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
8126 } |
325e4a8ba1b6
patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents:
15263
diff
changeset
|
8127 |
7 | 8128 static void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8129 close_redir(void) |
7 | 8130 { |
8131 if (redir_fd != NULL) | |
8132 { | |
8133 fclose(redir_fd); | |
8134 redir_fd = NULL; | |
8135 } | |
8136 #ifdef FEAT_EVAL | |
8137 redir_reg = 0; | |
167 | 8138 if (redir_vname) |
8139 { | |
8140 var_redir_stop(); | |
8141 redir_vname = 0; | |
8142 } | |
7 | 8143 #endif |
8144 } | |
8145 | |
17539
554240b9574b
patch 8.1.1767: FEAT_SESSION defined separately
Bram Moolenaar <Bram@vim.org>
parents:
17536
diff
changeset
|
8146 #if (defined(FEAT_SESSION) || defined(FEAT_EVAL)) || defined(PROTO) |
167 | 8147 int |
8368
db2a07b710ed
commit https://github.com/vim/vim/commit/f1d2501ebe33e148886c2914acd33140e20ee222
Christian Brabandt <cb@256bit.org>
parents:
8281
diff
changeset
|
8148 vim_mkdir_emsg(char_u *name, int prot) |
167 | 8149 { |
8150 if (vim_mkdir(name, prot) != 0) | |
8151 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8152 semsg(_("E739: Cannot create directory: %s"), name); |
167 | 8153 return FAIL; |
8154 } | |
8155 return OK; | |
8156 } | |
8157 #endif | |
8158 | |
7 | 8159 /* |
8160 * Open a file for writing for an Ex command, with some checks. | |
8161 * Return file descriptor, or NULL on failure. | |
8162 */ | |
8163 FILE * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8164 open_exfile( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8165 char_u *fname, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8166 int forceit, |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8167 char *mode) /* "w" for create new file or "a" for append */ |
7 | 8168 { |
8169 FILE *fd; | |
8170 | |
8171 #ifdef UNIX | |
8172 /* with Unix it is possible to open a directory */ | |
8173 if (mch_isdir(fname)) | |
8174 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8175 semsg(_(e_isadir2), fname); |
7 | 8176 return NULL; |
8177 } | |
8178 #endif | |
8179 if (!forceit && *mode != 'a' && vim_fexists(fname)) | |
8180 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8181 semsg(_("E189: \"%s\" exists (add ! to override)"), fname); |
7 | 8182 return NULL; |
8183 } | |
8184 | |
8185 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
|
8186 semsg(_("E190: Cannot open \"%s\" for writing"), fname); |
7 | 8187 |
8188 return fd; | |
8189 } | |
8190 | |
8191 /* | |
8192 * ":mark" and ":k". | |
8193 */ | |
8194 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8195 ex_mark(exarg_T *eap) |
7 | 8196 { |
8197 pos_T pos; | |
8198 | |
8199 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
|
8200 emsg(_(e_argreq)); |
7 | 8201 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
|
8202 emsg(_(e_trailing)); |
7 | 8203 else |
8204 { | |
8205 pos = curwin->w_cursor; /* save curwin->w_cursor */ | |
8206 curwin->w_cursor.lnum = eap->line2; | |
8207 beginline(BL_WHITE | BL_FIX); | |
8208 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
|
8209 emsg(_("E191: Argument must be a letter or forward/backward quote")); |
7 | 8210 curwin->w_cursor = pos; /* restore curwin->w_cursor */ |
8211 } | |
8212 } | |
8213 | |
8214 /* | |
8215 * Update w_topline, w_leftcol and the cursor position. | |
8216 */ | |
8217 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8218 update_topline_cursor(void) |
7 | 8219 { |
8220 check_cursor(); /* put cursor on valid line */ | |
8221 update_topline(); | |
8222 if (!curwin->w_p_wrap) | |
8223 validate_cursor(); | |
8224 update_curswant(); | |
8225 } | |
8226 | |
8227 /* | |
12521
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8228 * 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
|
8229 * 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
|
8230 */ |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8231 int |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8232 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
|
8233 { |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8234 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
|
8235 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
|
8236 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
|
8237 sst->save_State = State; |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8238 sst->save_insertmode = p_im; |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8239 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
|
8240 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
|
8241 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
|
8242 |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8243 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
|
8244 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
|
8245 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
|
8246 |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8247 /* |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8248 * 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
|
8249 * 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
|
8250 * ends with half a command. |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8251 */ |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8252 save_typeahead(&sst->tabuf); |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8253 return sst->tabuf.typebuf_valid; |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8254 } |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8255 |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8256 void |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8257 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
|
8258 { |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8259 /* Restore the previous typeahead. */ |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8260 restore_typeahead(&sst->tabuf); |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8261 |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8262 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
|
8263 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
|
8264 p_im = sst->save_insertmode; |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8265 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
|
8266 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
|
8267 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
|
8268 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
|
8269 |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8270 /* 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
|
8271 * '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
|
8272 State = sst->save_State; |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8273 #ifdef CURSOR_SHAPE |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8274 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
|
8275 #endif |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8276 } |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8277 |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8278 /* |
7 | 8279 * ":normal[!] {commands}": Execute normal mode commands. |
8280 */ | |
7840
28f569c7dab9
commit https://github.com/vim/vim/commit/20fb9f346497daca4d19402fdfa5de7958642477
Christian Brabandt <cb@256bit.org>
parents:
7819
diff
changeset
|
8281 void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8282 ex_normal(exarg_T *eap) |
7 | 8283 { |
12521
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8284 save_state_T save_state; |
7 | 8285 char_u *arg = NULL; |
8286 int l; | |
8287 char_u *p; | |
8288 | |
856 | 8289 if (ex_normal_lock > 0) |
8290 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8291 emsg(_(e_secure)); |
856 | 8292 return; |
8293 } | |
7 | 8294 if (ex_normal_busy >= p_mmd) |
8295 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8296 emsg(_("E192: Recursive use of :normal too deep")); |
7 | 8297 return; |
8298 } | |
8299 | |
8300 /* | |
8301 * vgetc() expects a CSI and K_SPECIAL to have been escaped. Don't do | |
8302 * this for the K_SPECIAL leading byte, otherwise special keys will not | |
8303 * work. | |
8304 */ | |
8305 if (has_mbyte) | |
8306 { | |
8307 int len = 0; | |
8308 | |
8309 /* Count the number of characters to be escaped. */ | |
8310 for (p = eap->arg; *p != NUL; ++p) | |
8311 { | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
8312 #ifdef FEAT_GUI |
7 | 8313 if (*p == CSI) /* leadbyte CSI */ |
8314 len += 2; | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
8315 #endif |
474 | 8316 for (l = (*mb_ptr2len)(p) - 1; l > 0; --l) |
7 | 8317 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
|
8318 #ifdef FEAT_GUI |
7 | 8319 || *p == CSI |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
8320 #endif |
7 | 8321 ) |
8322 len += 2; | |
8323 } | |
8324 if (len > 0) | |
8325 { | |
16764
ef00b6bc186b
patch 8.1.1384: using "int" for alloc() often results in compiler warnings
Bram Moolenaar <Bram@vim.org>
parents:
16738
diff
changeset
|
8326 arg = alloc(STRLEN(eap->arg) + len + 1); |
7 | 8327 if (arg != NULL) |
8328 { | |
8329 len = 0; | |
8330 for (p = eap->arg; *p != NUL; ++p) | |
8331 { | |
8332 arg[len++] = *p; | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
8333 #ifdef FEAT_GUI |
7 | 8334 if (*p == CSI) |
8335 { | |
8336 arg[len++] = KS_EXTRA; | |
8337 arg[len++] = (int)KE_CSI; | |
8338 } | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
8339 #endif |
474 | 8340 for (l = (*mb_ptr2len)(p) - 1; l > 0; --l) |
7 | 8341 { |
8342 arg[len++] = *++p; | |
8343 if (*p == K_SPECIAL) | |
8344 { | |
8345 arg[len++] = KS_SPECIAL; | |
8346 arg[len++] = KE_FILLER; | |
8347 } | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
8348 #ifdef FEAT_GUI |
7 | 8349 else if (*p == CSI) |
8350 { | |
8351 arg[len++] = KS_EXTRA; | |
8352 arg[len++] = (int)KE_CSI; | |
8353 } | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
8354 #endif |
7 | 8355 } |
8356 arg[len] = NUL; | |
8357 } | |
8358 } | |
8359 } | |
8360 } | |
8361 | |
12521
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8362 ++ex_normal_busy; |
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8363 if (save_current_state(&save_state)) |
7 | 8364 { |
8365 /* | |
8366 * Repeat the :normal command for each line in the range. When no | |
8367 * range given, execute it just once, without positioning the cursor | |
8368 * first. | |
8369 */ | |
8370 do | |
8371 { | |
8372 if (eap->addr_count != 0) | |
8373 { | |
8374 curwin->w_cursor.lnum = eap->line1++; | |
8375 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
|
8376 check_cursor_moved(curwin); |
7 | 8377 } |
8378 | |
15595
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
8379 exec_normal_cmd(arg != NULL |
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
8380 ? arg |
1ec942f1b648
patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15591
diff
changeset
|
8381 : eap->arg, eap->forceit ? REMAP_NONE : REMAP_YES, FALSE); |
7 | 8382 } |
8383 while (eap->addr_count > 0 && eap->line1 <= eap->line2 && !got_int); | |
8384 } | |
8385 | |
8386 /* Might not return to the main loop when in an event handler. */ | |
8387 update_topline_cursor(); | |
8388 | |
12521
718787498836
patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents:
12515
diff
changeset
|
8389 restore_current_state(&save_state); |
7 | 8390 --ex_normal_busy; |
6322 | 8391 #ifdef FEAT_MOUSE |
8392 setmouse(); | |
8393 #endif | |
8394 #ifdef CURSOR_SHAPE | |
8395 ui_cursor_shape(); /* may show different cursor shape */ | |
8396 #endif | |
8397 | |
7 | 8398 vim_free(arg); |
8399 } | |
8400 | |
8401 /* | |
598 | 8402 * ":startinsert", ":startreplace" and ":startgreplace" |
7 | 8403 */ |
8404 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8405 ex_startinsert(exarg_T *eap) |
7 | 8406 { |
98 | 8407 if (eap->forceit) |
8408 { | |
12545
241fbf588b95
patch 8.0.1151: "vim -c startinsert!" doesn't append
Christian Brabandt <cb@256bit.org>
parents:
12521
diff
changeset
|
8409 /* 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
|
8410 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
|
8411 curwin->w_cursor.lnum = 1; |
98 | 8412 coladvance((colnr_T)MAXCOL); |
8413 curwin->w_curswant = MAXCOL; | |
8414 curwin->w_set_curswant = FALSE; | |
8415 } | |
8416 | |
89 | 8417 /* Ignore the command when already in Insert mode. Inserting an |
8418 * expression register that invokes a function can do this. */ | |
8419 if (State & INSERT) | |
8420 return; | |
8421 | |
598 | 8422 if (eap->cmdidx == CMD_startinsert) |
8423 restart_edit = 'a'; | |
8424 else if (eap->cmdidx == CMD_startreplace) | |
8425 restart_edit = 'R'; | |
7 | 8426 else |
598 | 8427 restart_edit = 'V'; |
8428 | |
8429 if (!eap->forceit) | |
7 | 8430 { |
14 | 8431 if (eap->cmdidx == CMD_startinsert) |
8432 restart_edit = 'i'; | |
7 | 8433 curwin->w_curswant = 0; /* avoid MAXCOL */ |
8434 } | |
8435 } | |
8436 | |
8437 /* | |
8438 * ":stopinsert" | |
8439 */ | |
8440 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8441 ex_stopinsert(exarg_T *eap UNUSED) |
7 | 8442 { |
8443 restart_edit = 0; | |
8444 stop_insert_mode = TRUE; | |
8817
b7eb7bbd71d0
commit https://github.com/vim/vim/commit/fd773e9e88add7d1ffef890fb9f3a00d613b4326
Christian Brabandt <cb@256bit.org>
parents:
8643
diff
changeset
|
8445 clearmode(); |
7 | 8446 } |
7850
10f17a228661
commit https://github.com/vim/vim/commit/e2c3810c2ae290bbc2cba18eb47cc2d44e4b9797
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
8447 |
36 | 8448 /* |
8449 * Execute normal mode command "cmd". | |
8450 * "remap" can be REMAP_NONE or REMAP_YES. | |
8451 */ | |
8452 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8453 exec_normal_cmd(char_u *cmd, int remap, int silent) |
36 | 8454 { |
7703
39251e981d1f
commit https://github.com/vim/vim/commit/25281634cda03ce302aaf9f906a9520b5f81f91e
Christian Brabandt <cb@256bit.org>
parents:
7549
diff
changeset
|
8455 /* 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
|
8456 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
|
8457 exec_normal(FALSE, FALSE, FALSE); |
7703
39251e981d1f
commit https://github.com/vim/vim/commit/25281634cda03ce302aaf9f906a9520b5f81f91e
Christian Brabandt <cb@256bit.org>
parents:
7549
diff
changeset
|
8458 } |
7850
10f17a228661
commit https://github.com/vim/vim/commit/e2c3810c2ae290bbc2cba18eb47cc2d44e4b9797
Christian Brabandt <cb@256bit.org>
parents:
7840
diff
changeset
|
8459 |
7703
39251e981d1f
commit https://github.com/vim/vim/commit/25281634cda03ce302aaf9f906a9520b5f81f91e
Christian Brabandt <cb@256bit.org>
parents:
7549
diff
changeset
|
8460 /* |
39251e981d1f
commit https://github.com/vim/vim/commit/25281634cda03ce302aaf9f906a9520b5f81f91e
Christian Brabandt <cb@256bit.org>
parents:
7549
diff
changeset
|
8461 * 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
|
8462 * 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
|
8463 */ |
39251e981d1f
commit https://github.com/vim/vim/commit/25281634cda03ce302aaf9f906a9520b5f81f91e
Christian Brabandt <cb@256bit.org>
parents:
7549
diff
changeset
|
8464 void |
14871
f20df682c8af
patch 8.1.0447: GUI scrollbar test fails with Athena and Motif
Christian Brabandt <cb@256bit.org>
parents:
14862
diff
changeset
|
8465 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
|
8466 { |
36 | 8467 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
|
8468 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
|
8469 |
d3377393e3d9
patch 8.1.1136: decoding of mouse click escape sequence is not tested
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
8470 // 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
|
8471 // is nothing to get, so also check for Ctrl_C. |
36 | 8472 clear_oparg(&oa); |
8473 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
|
8474 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
|
8475 || ((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
|
8476 || (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
|
8477 && !got_int) |
36 | 8478 { |
8479 update_topline_cursor(); | |
13829
044337cbf854
patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents:
13802
diff
changeset
|
8480 #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
|
8481 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
|
8482 && 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
|
8483 && !VIsual_active) |
044337cbf854
patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents:
13802
diff
changeset
|
8484 { |
044337cbf854
patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents:
13802
diff
changeset
|
8485 /* 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
|
8486 * 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
|
8487 * 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
|
8488 if (terminal_loop(TRUE) == OK) |
044337cbf854
patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents:
13802
diff
changeset
|
8489 normal_cmd(&oa, TRUE); |
044337cbf854
patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents:
13802
diff
changeset
|
8490 } |
044337cbf854
patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents:
13802
diff
changeset
|
8491 else |
044337cbf854
patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents:
13802
diff
changeset
|
8492 #endif |
044337cbf854
patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents:
13802
diff
changeset
|
8493 /* execute a Normal mode cmd */ |
044337cbf854
patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents:
13802
diff
changeset
|
8494 normal_cmd(&oa, TRUE); |
36 | 8495 } |
8496 } | |
8497 | |
7 | 8498 #ifdef FEAT_FIND_ID |
8499 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8500 ex_checkpath(exarg_T *eap) |
7 | 8501 { |
8502 find_pattern_in_path(NULL, 0, 0, FALSE, FALSE, CHECK_PATH, 1L, | |
8503 eap->forceit ? ACTION_SHOW_ALL : ACTION_SHOW, | |
8504 (linenr_T)1, (linenr_T)MAXLNUM); | |
8505 } | |
8506 | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
8507 #if defined(FEAT_QUICKFIX) |
7 | 8508 /* |
8509 * ":psearch" | |
8510 */ | |
8511 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8512 ex_psearch(exarg_T *eap) |
7 | 8513 { |
8514 g_do_tagpreview = p_pvh; | |
8515 ex_findpat(eap); | |
8516 g_do_tagpreview = 0; | |
8517 } | |
8518 #endif | |
8519 | |
8520 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8521 ex_findpat(exarg_T *eap) |
7 | 8522 { |
8523 int whole = TRUE; | |
8524 long n; | |
8525 char_u *p; | |
8526 int action; | |
8527 | |
8528 switch (cmdnames[eap->cmdidx].cmd_name[2]) | |
8529 { | |
8530 case 'e': /* ":psearch", ":isearch" and ":dsearch" */ | |
8531 if (cmdnames[eap->cmdidx].cmd_name[0] == 'p') | |
8532 action = ACTION_GOTO; | |
8533 else | |
8534 action = ACTION_SHOW; | |
8535 break; | |
8536 case 'i': /* ":ilist" and ":dlist" */ | |
8537 action = ACTION_SHOW_ALL; | |
8538 break; | |
8539 case 'u': /* ":ijump" and ":djump" */ | |
8540 action = ACTION_GOTO; | |
8541 break; | |
8542 default: /* ":isplit" and ":dsplit" */ | |
8543 action = ACTION_SPLIT; | |
8544 break; | |
8545 } | |
8546 | |
8547 n = 1; | |
8548 if (vim_isdigit(*eap->arg)) /* get count */ | |
8549 { | |
8550 n = getdigits(&eap->arg); | |
8551 eap->arg = skipwhite(eap->arg); | |
8552 } | |
8553 if (*eap->arg == '/') /* Match regexp, not just whole words */ | |
8554 { | |
8555 whole = FALSE; | |
8556 ++eap->arg; | |
8557 p = skip_regexp(eap->arg, '/', p_magic, NULL); | |
8558 if (*p) | |
8559 { | |
8560 *p++ = NUL; | |
8561 p = skipwhite(p); | |
8562 | |
8563 /* Check for trailing illegal characters */ | |
8564 if (!ends_excmd(*p)) | |
8565 eap->errmsg = e_trailing; | |
8566 else | |
8567 eap->nextcmd = check_nextcmd(p); | |
8568 } | |
8569 } | |
8570 if (!eap->skip) | |
8571 find_pattern_in_path(eap->arg, 0, (int)STRLEN(eap->arg), | |
8572 whole, !eap->forceit, | |
8573 *eap->cmd == 'd' ? FIND_DEFINE : FIND_ANY, | |
8574 n, action, eap->line1, eap->line2); | |
8575 } | |
8576 #endif | |
8577 | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
8578 |
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
8579 #ifdef FEAT_QUICKFIX |
7 | 8580 /* |
8581 * ":ptag", ":ptselect", ":ptjump", ":ptnext", etc. | |
8582 */ | |
8583 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8584 ex_ptag(exarg_T *eap) |
7 | 8585 { |
2633 | 8586 g_do_tagpreview = p_pvh; /* will be reset to 0 in ex_tag_cmd() */ |
7 | 8587 ex_tag_cmd(eap, cmdnames[eap->cmdidx].cmd_name + 1); |
8588 } | |
8589 | |
8590 /* | |
8591 * ":pedit" | |
8592 */ | |
8593 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8594 ex_pedit(exarg_T *eap) |
7 | 8595 { |
8596 win_T *curwin_save = curwin; | |
8597 | |
17746
a4e488a6655c
patch 8.1.1870: using :pedit from a help file sets help filetype
Bram Moolenaar <Bram@vim.org>
parents:
17744
diff
changeset
|
8598 // Open the preview window or popup and make it the current window. |
7 | 8599 g_do_tagpreview = p_pvh; |
17767
c75da1064e33
patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents:
17746
diff
changeset
|
8600 prepare_tagpreview(TRUE, TRUE, FALSE); |
17644
daa1dea1c1b3
patch 8.1.1819: :pedit does not work with a popup preview window
Bram Moolenaar <Bram@vim.org>
parents:
17622
diff
changeset
|
8601 |
17746
a4e488a6655c
patch 8.1.1870: using :pedit from a help file sets help filetype
Bram Moolenaar <Bram@vim.org>
parents:
17744
diff
changeset
|
8602 // Edit the file. |
7 | 8603 do_exedit(eap, NULL); |
17644
daa1dea1c1b3
patch 8.1.1819: :pedit does not work with a popup preview window
Bram Moolenaar <Bram@vim.org>
parents:
17622
diff
changeset
|
8604 |
7 | 8605 if (curwin != curwin_save && win_valid(curwin_save)) |
8606 { | |
17746
a4e488a6655c
patch 8.1.1870: using :pedit from a help file sets help filetype
Bram Moolenaar <Bram@vim.org>
parents:
17744
diff
changeset
|
8607 // Return cursor to where we were |
7 | 8608 validate_cursor(); |
8609 redraw_later(VALID); | |
8610 win_enter(curwin_save, TRUE); | |
8611 } | |
17644
daa1dea1c1b3
patch 8.1.1819: :pedit does not work with a popup preview window
Bram Moolenaar <Bram@vim.org>
parents:
17622
diff
changeset
|
8612 # 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
|
8613 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
|
8614 { |
daa1dea1c1b3
patch 8.1.1819: :pedit does not work with a popup preview window
Bram Moolenaar <Bram@vim.org>
parents:
17622
diff
changeset
|
8615 // 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
|
8616 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
|
8617 } |
daa1dea1c1b3
patch 8.1.1819: :pedit does not work with a popup preview window
Bram Moolenaar <Bram@vim.org>
parents:
17622
diff
changeset
|
8618 # endif |
7 | 8619 g_do_tagpreview = 0; |
8620 } | |
12477
68d7bc045dbe
patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
12459
diff
changeset
|
8621 #endif |
7 | 8622 |
8623 /* | |
8624 * ":stag", ":stselect" and ":stjump". | |
8625 */ | |
8626 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8627 ex_stag(exarg_T *eap) |
7 | 8628 { |
8629 postponed_split = -1; | |
8630 postponed_split_flags = cmdmod.split; | |
1090 | 8631 postponed_split_tab = cmdmod.tab; |
7 | 8632 ex_tag_cmd(eap, cmdnames[eap->cmdidx].cmd_name + 1); |
8633 postponed_split_flags = 0; | |
1090 | 8634 postponed_split_tab = 0; |
7 | 8635 } |
8636 | |
8637 /* | |
8638 * ":tag", ":tselect", ":tjump", ":tnext", etc. | |
8639 */ | |
8640 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8641 ex_tag(exarg_T *eap) |
7 | 8642 { |
8643 ex_tag_cmd(eap, cmdnames[eap->cmdidx].cmd_name); | |
8644 } | |
8645 | |
8646 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8647 ex_tag_cmd(exarg_T *eap, char_u *name) |
7 | 8648 { |
8649 int cmd; | |
8650 | |
8651 switch (name[1]) | |
8652 { | |
8653 case 'j': cmd = DT_JUMP; /* ":tjump" */ | |
8654 break; | |
8655 case 's': cmd = DT_SELECT; /* ":tselect" */ | |
8656 break; | |
8657 case 'p': cmd = DT_PREV; /* ":tprevious" */ | |
8658 break; | |
8659 case 'N': cmd = DT_PREV; /* ":tNext" */ | |
8660 break; | |
8661 case 'n': cmd = DT_NEXT; /* ":tnext" */ | |
8662 break; | |
8663 case 'o': cmd = DT_POP; /* ":pop" */ | |
8664 break; | |
8665 case 'f': /* ":tfirst" */ | |
8666 case 'r': cmd = DT_FIRST; /* ":trewind" */ | |
8667 break; | |
8668 case 'l': cmd = DT_LAST; /* ":tlast" */ | |
8669 break; | |
8670 default: /* ":tag" */ | |
8671 #ifdef FEAT_CSCOPE | |
1603 | 8672 if (p_cst && *eap->arg != NUL) |
7 | 8673 { |
10373
bd674706408a
commit https://github.com/vim/vim/commit/d4db7719bdfbc54df396eac08d8cbb2389feacf4
Christian Brabandt <cb@256bit.org>
parents:
10361
diff
changeset
|
8674 ex_cstag(eap); |
7 | 8675 return; |
8676 } | |
8677 #endif | |
8678 cmd = DT_TAG; | |
8679 break; | |
8680 } | |
8681 | |
649 | 8682 if (name[0] == 'l') |
8683 { | |
8684 #ifndef FEAT_QUICKFIX | |
8685 ex_ni(eap); | |
8686 return; | |
8687 #else | |
8688 cmd = DT_LTAG; | |
8689 #endif | |
8690 } | |
8691 | |
7 | 8692 do_tag(eap->arg, cmd, eap->addr_count > 0 ? (int)eap->line2 : 1, |
8693 eap->forceit, TRUE); | |
8694 } | |
8695 | |
8696 /* | |
1661 | 8697 * Check "str" for starting with a special cmdline variable. |
8698 * If found return one of the SPEC_ values and set "*usedlen" to the length of | |
8699 * the variable. Otherwise return -1 and "*usedlen" is unchanged. | |
8700 */ | |
8701 int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8702 find_cmdline_var(char_u *src, int *usedlen) |
1661 | 8703 { |
8704 int len; | |
8705 int i; | |
1879 | 8706 static char *(spec_str[]) = { |
1661 | 8707 "%", |
8708 #define SPEC_PERC 0 | |
8709 "#", | |
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
|
8710 #define SPEC_HASH (SPEC_PERC + 1) |
1661 | 8711 "<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
|
8712 #define SPEC_CWORD (SPEC_HASH + 1) |
1661 | 8713 "<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
|
8714 #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
|
8715 "<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
|
8716 #define SPEC_CEXPR (SPEC_CCWORD + 1) |
1661 | 8717 "<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
|
8718 #define SPEC_CFILE (SPEC_CEXPR + 1) |
1661 | 8719 "<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
|
8720 #define SPEC_SFILE (SPEC_CFILE + 1) |
2645 | 8721 "<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
|
8722 #define SPEC_SLNUM (SPEC_SFILE + 1) |
1661 | 8723 "<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
|
8724 #define SPEC_AFILE (SPEC_SLNUM + 1) |
1661 | 8725 "<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
|
8726 #define SPEC_ABUF (SPEC_AFILE + 1) |
1661 | 8727 "<amatch>", /* autocommand match name */ |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
8728 #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
|
8729 "<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
|
8730 #define SPEC_SFLNUM (SPEC_AMATCH + 1) |
1661 | 8731 #ifdef FEAT_CLIENTSERVER |
8732 "<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
|
8733 # define SPEC_CLIENT (SPEC_SFLNUM + 1) |
1661 | 8734 #endif |
8735 }; | |
1872 | 8736 |
8737 for (i = 0; i < (int)(sizeof(spec_str) / sizeof(char *)); ++i) | |
1661 | 8738 { |
8739 len = (int)STRLEN(spec_str[i]); | |
8740 if (STRNCMP(src, spec_str[i], len) == 0) | |
8741 { | |
8742 *usedlen = len; | |
8743 return i; | |
8744 } | |
8745 } | |
8746 return -1; | |
8747 } | |
8748 | |
8749 /* | |
7 | 8750 * Evaluate cmdline variables. |
8751 * | |
8752 * change '%' to curbuf->b_ffname | |
8753 * '#' to curwin->w_altfile | |
8754 * '<cword>' to word under the cursor | |
8755 * '<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
|
8756 * '<cexpr>' to C-expression under the cursor |
7 | 8757 * '<cfile>' to path name under the cursor |
8758 * '<sfile>' to sourced file name | |
2645 | 8759 * '<slnum>' to sourced file line number |
7 | 8760 * '<afile>' to file name for autocommand |
8761 * '<abuf>' to buffer number for autocommand | |
8762 * '<amatch>' to matching name for autocommand | |
8763 * | |
8764 * When an error is detected, "errormsg" is set to a non-NULL pointer (may be | |
8765 * "" for error without a message) and NULL is returned. | |
8766 * Returns an allocated string if a valid match was found. | |
8767 * Returns NULL if no match was found. "usedlen" then still contains the | |
8768 * number of characters to skip. | |
8769 */ | |
8770 char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8771 eval_vars( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8772 char_u *src, /* pointer into commandline */ |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
8773 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
|
8774 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
|
8775 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
|
8776 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
|
8777 int *escaped) /* return value has escaped white space (can |
1098 | 8778 * be NULL) */ |
7 | 8779 { |
8780 int i; | |
8781 char_u *s; | |
8782 char_u *result; | |
8783 char_u *resultbuf = NULL; | |
8784 int resultlen; | |
8785 buf_T *buf; | |
8786 int valid = VALID_HEAD + VALID_PATH; /* assume valid result */ | |
8787 int spec_idx; | |
8788 #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
|
8789 int tilde_file = FALSE; |
7 | 8790 int skip_mod = FALSE; |
8791 #endif | |
8792 char_u strbuf[30]; | |
8793 | |
8794 *errormsg = NULL; | |
1098 | 8795 if (escaped != NULL) |
8796 *escaped = FALSE; | |
7 | 8797 |
8798 /* | |
8799 * Check if there is something to do. | |
8800 */ | |
1661 | 8801 spec_idx = find_cmdline_var(src, usedlen); |
8802 if (spec_idx < 0) /* no match */ | |
7 | 8803 { |
8804 *usedlen = 1; | |
8805 return NULL; | |
8806 } | |
8807 | |
8808 /* | |
8809 * Skip when preceded with a backslash "\%" and "\#". | |
8810 * Note: In "\\%" the % is also not recognized! | |
8811 */ | |
8812 if (src > srcstart && src[-1] == '\\') | |
8813 { | |
8814 *usedlen = 0; | |
1619 | 8815 STRMOVE(src - 1, src); /* remove backslash */ |
7 | 8816 return NULL; |
8817 } | |
8818 | |
8819 /* | |
8820 * word or WORD under cursor | |
8821 */ | |
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
|
8822 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
|
8823 || 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
|
8824 { |
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
|
8825 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
|
8826 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
|
8827 : 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
|
8828 : FIND_STRING); |
7 | 8829 if (resultlen == 0) |
8830 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8831 *errormsg = ""; |
7 | 8832 return NULL; |
8833 } | |
8834 } | |
8835 | |
8836 /* | |
8837 * '#': Alternate file name | |
8838 * '%': Current file name | |
8839 * File name under the cursor | |
8840 * File name for autocommand | |
8841 * and following modifiers | |
8842 */ | |
8843 else | |
8844 { | |
8845 switch (spec_idx) | |
8846 { | |
8847 case SPEC_PERC: /* '%': current file */ | |
8848 if (curbuf->b_fname == NULL) | |
8849 { | |
8850 result = (char_u *)""; | |
8851 valid = 0; /* Must have ":p:h" to be valid */ | |
8852 } | |
8853 else | |
14393
c62601adad69
patch 8.1.0211: expanding a file name "~" results in $HOME
Christian Brabandt <cb@256bit.org>
parents:
14286
diff
changeset
|
8854 { |
7 | 8855 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
|
8856 #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
|
8857 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
|
8858 #endif |
14393
c62601adad69
patch 8.1.0211: expanding a file name "~" results in $HOME
Christian Brabandt <cb@256bit.org>
parents:
14286
diff
changeset
|
8859 } |
7 | 8860 break; |
8861 | |
8862 case SPEC_HASH: /* '#' or "#99": alternate file */ | |
8863 if (src[1] == '#') /* "##": the argument list */ | |
8864 { | |
8865 result = arg_all(); | |
8866 resultbuf = result; | |
8867 *usedlen = 2; | |
1098 | 8868 if (escaped != NULL) |
8869 *escaped = TRUE; | |
7 | 8870 #ifdef FEAT_MODIFY_FNAME |
8871 skip_mod = TRUE; | |
8872 #endif | |
8873 break; | |
8874 } | |
8875 s = src + 1; | |
1733 | 8876 if (*s == '<') /* "#<99" uses v:oldfiles */ |
8877 ++s; | |
7 | 8878 i = (int)getdigits(&s); |
12706
9b882316aa63
patch 8.0.1231: expanding file name drops dash
Christian Brabandt <cb@256bit.org>
parents:
12674
diff
changeset
|
8879 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
|
8880 /* 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
|
8881 s--; |
7 | 8882 *usedlen = (int)(s - src); /* length of what we expand */ |
8883 | |
12706
9b882316aa63
patch 8.0.1231: expanding file name drops dash
Christian Brabandt <cb@256bit.org>
parents:
12674
diff
changeset
|
8884 if (src[1] == '<' && i != 0) |
7 | 8885 { |
1733 | 8886 if (*usedlen < 2) |
8887 { | |
8888 /* Should we give an error message for #<text? */ | |
8889 *usedlen = 1; | |
8890 return NULL; | |
8891 } | |
8892 #ifdef FEAT_EVAL | |
8893 result = list_find_str(get_vim_var_list(VV_OLDFILES), | |
8894 (long)i); | |
8895 if (result == NULL) | |
8896 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8897 *errormsg = ""; |
1733 | 8898 return NULL; |
8899 } | |
8900 #else | |
15488
da8b98c008bf
patch 8.1.0752: one more compiler warning for signed/unsigned string
Bram Moolenaar <Bram@vim.org>
parents:
15474
diff
changeset
|
8901 *errormsg = _("E809: #< is not available without the +eval feature"); |
7 | 8902 return NULL; |
1733 | 8903 #endif |
7 | 8904 } |
8905 else | |
1733 | 8906 { |
12706
9b882316aa63
patch 8.0.1231: expanding file name drops dash
Christian Brabandt <cb@256bit.org>
parents:
12674
diff
changeset
|
8907 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
|
8908 *usedlen = 1; |
1733 | 8909 buf = buflist_findnr(i); |
8910 if (buf == NULL) | |
8911 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8912 *errormsg = _("E194: No alternate file name to substitute for '#'"); |
1733 | 8913 return NULL; |
8914 } | |
8915 if (lnump != NULL) | |
8916 *lnump = ECMD_LAST; | |
8917 if (buf->b_fname == NULL) | |
8918 { | |
8919 result = (char_u *)""; | |
8920 valid = 0; /* Must have ":p:h" to be valid */ | |
8921 } | |
8922 else | |
14393
c62601adad69
patch 8.1.0211: expanding a file name "~" results in $HOME
Christian Brabandt <cb@256bit.org>
parents:
14286
diff
changeset
|
8923 { |
1733 | 8924 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
|
8925 #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
|
8926 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
|
8927 #endif |
14393
c62601adad69
patch 8.1.0211: expanding a file name "~" results in $HOME
Christian Brabandt <cb@256bit.org>
parents:
14286
diff
changeset
|
8928 } |
1733 | 8929 } |
7 | 8930 break; |
8931 | |
8932 #ifdef FEAT_SEARCHPATH | |
8933 case SPEC_CFILE: /* file name under cursor */ | |
681 | 8934 result = file_name_at_cursor(FNAME_MESS|FNAME_HYP, 1L, NULL); |
7 | 8935 if (result == NULL) |
8936 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8937 *errormsg = ""; |
7 | 8938 return NULL; |
8939 } | |
8940 resultbuf = result; /* remember allocated string */ | |
8941 break; | |
8942 #endif | |
8943 | |
8944 case SPEC_AFILE: /* file name for autocommand */ | |
8945 result = autocmd_fname; | |
1723 | 8946 if (result != NULL && !autocmd_fname_full) |
8947 { | |
8948 /* Still need to turn the fname into a full path. It is | |
8949 * postponed to avoid a delay when <afile> is not used. */ | |
8950 autocmd_fname_full = TRUE; | |
8951 result = FullName_save(autocmd_fname, FALSE); | |
8952 vim_free(autocmd_fname); | |
8953 autocmd_fname = result; | |
8954 } | |
7 | 8955 if (result == NULL) |
8956 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8957 *errormsg = _("E495: no autocommand file name to substitute for \"<afile>\""); |
7 | 8958 return NULL; |
8959 } | |
1471 | 8960 result = shorten_fname1(result); |
7 | 8961 break; |
8962 | |
8963 case SPEC_ABUF: /* buffer number for autocommand */ | |
8964 if (autocmd_bufnr <= 0) | |
8965 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8966 *errormsg = _("E496: no autocommand buffer number to substitute for \"<abuf>\""); |
7 | 8967 return NULL; |
8968 } | |
8969 sprintf((char *)strbuf, "%d", autocmd_bufnr); | |
8970 result = strbuf; | |
8971 break; | |
8972 | |
8973 case SPEC_AMATCH: /* match name for autocommand */ | |
8974 result = autocmd_match; | |
8975 if (result == NULL) | |
8976 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8977 *errormsg = _("E497: no autocommand match name to substitute for \"<amatch>\""); |
7 | 8978 return NULL; |
8979 } | |
8980 break; | |
8981 | |
8982 case SPEC_SFILE: /* file name for ":so" command */ | |
8983 result = sourcing_name; | |
8984 if (result == NULL) | |
8985 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8986 *errormsg = _("E498: no :source file name to substitute for \"<sfile>\""); |
7 | 8987 return NULL; |
8988 } | |
8989 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
|
8990 |
2645 | 8991 case SPEC_SLNUM: /* line in file for ":so" command */ |
8992 if (sourcing_name == NULL || sourcing_lnum == 0) | |
8993 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
8994 *errormsg = _("E842: no line number to use for \"<slnum>\""); |
2645 | 8995 return NULL; |
8996 } | |
8997 sprintf((char *)strbuf, "%ld", (long)sourcing_lnum); | |
8998 result = strbuf; | |
8999 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
|
9000 |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14677
diff
changeset
|
9001 #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
|
9002 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
|
9003 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
|
9004 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
9005 *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
|
9006 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
|
9007 } |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14677
diff
changeset
|
9008 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
|
9009 (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
|
9010 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
|
9011 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
|
9012 #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
|
9013 |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
14677
diff
changeset
|
9014 #ifdef FEAT_CLIENTSERVER |
7 | 9015 case SPEC_CLIENT: /* Source of last submitted input */ |
840 | 9016 sprintf((char *)strbuf, PRINTF_HEX_LONG_U, |
9017 (long_u)clientWindow); | |
7 | 9018 result = strbuf; |
9019 break; | |
9020 #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
|
9021 |
11428
346168f2a6cb
patch 8.0.0598: building with gcc 7.1 yields new warnings
Christian Brabandt <cb@256bit.org>
parents:
11374
diff
changeset
|
9022 default: |
346168f2a6cb
patch 8.0.0598: building with gcc 7.1 yields new warnings
Christian Brabandt <cb@256bit.org>
parents:
11374
diff
changeset
|
9023 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
|
9024 break; |
7 | 9025 } |
9026 | |
9027 resultlen = (int)STRLEN(result); /* length of new string */ | |
9028 if (src[*usedlen] == '<') /* remove the file name extension */ | |
9029 { | |
9030 ++*usedlen; | |
9031 if ((s = vim_strrchr(result, '.')) != NULL && s >= gettail(result)) | |
9032 resultlen = (int)(s - result); | |
9033 } | |
9034 #ifdef FEAT_MODIFY_FNAME | |
9035 else if (!skip_mod) | |
9036 { | |
14393
c62601adad69
patch 8.1.0211: expanding a file name "~" results in $HOME
Christian Brabandt <cb@256bit.org>
parents:
14286
diff
changeset
|
9037 valid |= modify_fname(src, tilde_file, usedlen, &result, &resultbuf, |
7 | 9038 &resultlen); |
9039 if (result == NULL) | |
9040 { | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
9041 *errormsg = ""; |
7 | 9042 return NULL; |
9043 } | |
9044 } | |
9045 #endif | |
9046 } | |
9047 | |
9048 if (resultlen == 0 || valid != VALID_HEAD + VALID_PATH) | |
9049 { | |
9050 if (valid != VALID_HEAD + VALID_PATH) | |
9051 /* 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
|
9052 *errormsg = _("E499: Empty file name for '%' or '#', only works with \":p:h\""); |
7 | 9053 else |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
9054 *errormsg = _("E500: Evaluates to an empty string"); |
7 | 9055 result = NULL; |
9056 } | |
9057 else | |
9058 result = vim_strnsave(result, resultlen); | |
9059 vim_free(resultbuf); | |
9060 return result; | |
9061 } | |
9062 | |
9063 /* | |
9064 * Expand the <sfile> string in "arg". | |
9065 * | |
9066 * Returns an allocated string, or NULL for any error. | |
9067 */ | |
9068 char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
9069 expand_sfile(char_u *arg) |
7 | 9070 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
9071 char *errormsg; |
7 | 9072 int len; |
9073 char_u *result; | |
9074 char_u *newres; | |
9075 char_u *repl; | |
9076 int srclen; | |
9077 char_u *p; | |
9078 | |
9079 result = vim_strsave(arg); | |
9080 if (result == NULL) | |
9081 return NULL; | |
9082 | |
9083 for (p = result; *p; ) | |
9084 { | |
9085 if (STRNCMP(p, "<sfile>", 7) != 0) | |
9086 ++p; | |
9087 else | |
9088 { | |
9089 /* replace "<sfile>" with the sourced file name, and do ":" stuff */ | |
1098 | 9090 repl = eval_vars(p, result, &srclen, NULL, &errormsg, NULL); |
7 | 9091 if (errormsg != NULL) |
9092 { | |
9093 if (*errormsg) | |
9094 emsg(errormsg); | |
9095 vim_free(result); | |
9096 return NULL; | |
9097 } | |
9098 if (repl == NULL) /* no match (cannot happen) */ | |
9099 { | |
9100 p += srclen; | |
9101 continue; | |
9102 } | |
9103 len = (int)STRLEN(result) - srclen + (int)STRLEN(repl) + 1; | |
9104 newres = alloc(len); | |
9105 if (newres == NULL) | |
9106 { | |
9107 vim_free(repl); | |
9108 vim_free(result); | |
9109 return NULL; | |
9110 } | |
9111 mch_memmove(newres, result, (size_t)(p - result)); | |
9112 STRCPY(newres + (p - result), repl); | |
9113 len = (int)STRLEN(newres); | |
9114 STRCAT(newres, p + srclen); | |
9115 vim_free(repl); | |
9116 vim_free(result); | |
9117 result = newres; | |
9118 p = newres + len; /* continue after the match */ | |
9119 } | |
9120 } | |
9121 | |
9122 return result; | |
9123 } | |
9124 | |
9125 #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) || defined(PROTO) | |
272 | 9126 /* |
2770 | 9127 * Make a dialog message in "buff[DIALOG_MSG_SIZE]". |
310 | 9128 * "format" must contain "%s". |
272 | 9129 */ |
7 | 9130 void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
9131 dialog_msg(char_u *buff, char *format, char_u *fname) |
7 | 9132 { |
9133 if (fname == NULL) | |
9134 fname = (char_u *)_("Untitled"); | |
2770 | 9135 vim_snprintf((char *)buff, DIALOG_MSG_SIZE, format, fname); |
7 | 9136 } |
9137 #endif | |
9138 | |
9139 /* | |
9140 * ":behave {mswin,xterm}" | |
9141 */ | |
9142 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
9143 ex_behave(exarg_T *eap) |
7 | 9144 { |
9145 if (STRCMP(eap->arg, "mswin") == 0) | |
9146 { | |
9147 set_option_value((char_u *)"selection", 0L, (char_u *)"exclusive", 0); | |
9148 set_option_value((char_u *)"selectmode", 0L, (char_u *)"mouse,key", 0); | |
9149 set_option_value((char_u *)"mousemodel", 0L, (char_u *)"popup", 0); | |
9150 set_option_value((char_u *)"keymodel", 0L, | |
9151 (char_u *)"startsel,stopsel", 0); | |
9152 } | |
9153 else if (STRCMP(eap->arg, "xterm") == 0) | |
9154 { | |
9155 set_option_value((char_u *)"selection", 0L, (char_u *)"inclusive", 0); | |
9156 set_option_value((char_u *)"selectmode", 0L, (char_u *)"", 0); | |
9157 set_option_value((char_u *)"mousemodel", 0L, (char_u *)"extend", 0); | |
9158 set_option_value((char_u *)"keymodel", 0L, (char_u *)"", 0); | |
9159 } | |
9160 else | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
9161 semsg(_(e_invarg2), eap->arg); |
7 | 9162 } |
9163 | |
2097
8f72e3512b43
updated for version 7.2.381
Bram Moolenaar <bram@zimbu.org>
parents:
2068
diff
changeset
|
9164 /* |
8f72e3512b43
updated for version 7.2.381
Bram Moolenaar <bram@zimbu.org>
parents:
2068
diff
changeset
|
9165 * 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
|
9166 * ":behave {mswin,xterm}" command. |
8f72e3512b43
updated for version 7.2.381
Bram Moolenaar <bram@zimbu.org>
parents:
2068
diff
changeset
|
9167 */ |
8f72e3512b43
updated for version 7.2.381
Bram Moolenaar <bram@zimbu.org>
parents:
2068
diff
changeset
|
9168 char_u * |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
9169 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
|
9170 { |
8f72e3512b43
updated for version 7.2.381
Bram Moolenaar <bram@zimbu.org>
parents:
2068
diff
changeset
|
9171 if (idx == 0) |
8f72e3512b43
updated for version 7.2.381
Bram Moolenaar <bram@zimbu.org>
parents:
2068
diff
changeset
|
9172 return (char_u *)"mswin"; |
8f72e3512b43
updated for version 7.2.381
Bram Moolenaar <bram@zimbu.org>
parents:
2068
diff
changeset
|
9173 if (idx == 1) |
8f72e3512b43
updated for version 7.2.381
Bram Moolenaar <bram@zimbu.org>
parents:
2068
diff
changeset
|
9174 return (char_u *)"xterm"; |
8f72e3512b43
updated for version 7.2.381
Bram Moolenaar <bram@zimbu.org>
parents:
2068
diff
changeset
|
9175 return NULL; |
8f72e3512b43
updated for version 7.2.381
Bram Moolenaar <bram@zimbu.org>
parents:
2068
diff
changeset
|
9176 } |
10275
6d8b2da002e9
commit https://github.com/vim/vim/commit/9e507ca8a3e1535e62de4bd86374b0fcd18ef5b8
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
9177 |
6d8b2da002e9
commit https://github.com/vim/vim/commit/9e507ca8a3e1535e62de4bd86374b0fcd18ef5b8
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
9178 /* |
6d8b2da002e9
commit https://github.com/vim/vim/commit/9e507ca8a3e1535e62de4bd86374b0fcd18ef5b8
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
9179 * 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
|
9180 * ":messages {clear}" command. |
6d8b2da002e9
commit https://github.com/vim/vim/commit/9e507ca8a3e1535e62de4bd86374b0fcd18ef5b8
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
9181 */ |
6d8b2da002e9
commit https://github.com/vim/vim/commit/9e507ca8a3e1535e62de4bd86374b0fcd18ef5b8
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
9182 char_u * |
6d8b2da002e9
commit https://github.com/vim/vim/commit/9e507ca8a3e1535e62de4bd86374b0fcd18ef5b8
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
9183 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
|
9184 { |
6d8b2da002e9
commit https://github.com/vim/vim/commit/9e507ca8a3e1535e62de4bd86374b0fcd18ef5b8
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
9185 if (idx == 0) |
6d8b2da002e9
commit https://github.com/vim/vim/commit/9e507ca8a3e1535e62de4bd86374b0fcd18ef5b8
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
9186 return (char_u *)"clear"; |
6d8b2da002e9
commit https://github.com/vim/vim/commit/9e507ca8a3e1535e62de4bd86374b0fcd18ef5b8
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
9187 return NULL; |
6d8b2da002e9
commit https://github.com/vim/vim/commit/9e507ca8a3e1535e62de4bd86374b0fcd18ef5b8
Christian Brabandt <cb@256bit.org>
parents:
10264
diff
changeset
|
9188 } |
17781
04245f071792
patch 8.1.1887: the +cmdline_compl feature is not in the tiny version
Bram Moolenaar <Bram@vim.org>
parents:
17767
diff
changeset
|
9189 |
11995
7df3dd3c0ac1
patch 8.0.0878: no completion for :mapclear
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
9190 char_u * |
7df3dd3c0ac1
patch 8.0.0878: no completion for :mapclear
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
9191 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
|
9192 { |
7df3dd3c0ac1
patch 8.0.0878: no completion for :mapclear
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
9193 if (idx == 0) |
7df3dd3c0ac1
patch 8.0.0878: no completion for :mapclear
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
9194 return (char_u *)"<buffer>"; |
7df3dd3c0ac1
patch 8.0.0878: no completion for :mapclear
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
9195 return NULL; |
7df3dd3c0ac1
patch 8.0.0878: no completion for :mapclear
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
9196 } |
7df3dd3c0ac1
patch 8.0.0878: no completion for :mapclear
Christian Brabandt <cb@256bit.org>
parents:
11957
diff
changeset
|
9197 |
7 | 9198 static int filetype_detect = FALSE; |
9199 static int filetype_plugin = FALSE; | |
9200 static int filetype_indent = FALSE; | |
9201 | |
9202 /* | |
9203 * ":filetype [plugin] [indent] {on,off,detect}" | |
9204 * on: Load the filetype.vim file to install autocommands for file types. | |
9205 * off: Load the ftoff.vim file to remove all autocommands for file types. | |
9206 * plugin on: load filetype.vim and ftplugin.vim | |
9207 * plugin off: load ftplugof.vim | |
9208 * indent on: load filetype.vim and indent.vim | |
9209 * indent off: load indoff.vim | |
9210 */ | |
9211 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
9212 ex_filetype(exarg_T *eap) |
7 | 9213 { |
9214 char_u *arg = eap->arg; | |
9215 int plugin = FALSE; | |
9216 int indent = FALSE; | |
9217 | |
9218 if (*eap->arg == NUL) | |
9219 { | |
9220 /* Print current status. */ | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
9221 smsg("filetype detection:%s plugin:%s indent:%s", |
7 | 9222 filetype_detect ? "ON" : "OFF", |
9223 filetype_plugin ? (filetype_detect ? "ON" : "(on)") : "OFF", | |
9224 filetype_indent ? (filetype_detect ? "ON" : "(on)") : "OFF"); | |
9225 return; | |
9226 } | |
9227 | |
9228 /* Accept "plugin" and "indent" in any order. */ | |
9229 for (;;) | |
9230 { | |
9231 if (STRNCMP(arg, "plugin", 6) == 0) | |
9232 { | |
9233 plugin = TRUE; | |
9234 arg = skipwhite(arg + 6); | |
9235 continue; | |
9236 } | |
9237 if (STRNCMP(arg, "indent", 6) == 0) | |
9238 { | |
9239 indent = TRUE; | |
9240 arg = skipwhite(arg + 6); | |
9241 continue; | |
9242 } | |
9243 break; | |
9244 } | |
9245 if (STRCMP(arg, "on") == 0 || STRCMP(arg, "detect") == 0) | |
9246 { | |
9247 if (*arg == 'o' || !filetype_detect) | |
9248 { | |
8524
2f57bbe870ea
commit https://github.com/vim/vim/commit/7f8989dd8a627af2185df381195351a913f3777f
Christian Brabandt <cb@256bit.org>
parents:
8402
diff
changeset
|
9249 source_runtime((char_u *)FILETYPE_FILE, DIP_ALL); |
7 | 9250 filetype_detect = TRUE; |
9251 if (plugin) | |
9252 { | |
8524
2f57bbe870ea
commit https://github.com/vim/vim/commit/7f8989dd8a627af2185df381195351a913f3777f
Christian Brabandt <cb@256bit.org>
parents:
8402
diff
changeset
|
9253 source_runtime((char_u *)FTPLUGIN_FILE, DIP_ALL); |
7 | 9254 filetype_plugin = TRUE; |
9255 } | |
9256 if (indent) | |
9257 { | |
8524
2f57bbe870ea
commit https://github.com/vim/vim/commit/7f8989dd8a627af2185df381195351a913f3777f
Christian Brabandt <cb@256bit.org>
parents:
8402
diff
changeset
|
9258 source_runtime((char_u *)INDENT_FILE, DIP_ALL); |
7 | 9259 filetype_indent = TRUE; |
9260 } | |
9261 } | |
9262 if (*arg == 'd') | |
9263 { | |
9260
ac8180818504
commit https://github.com/vim/vim/commit/1610d052413e0ed664498853a47acc2d677a22d1
Christian Brabandt <cb@256bit.org>
parents:
9230
diff
changeset
|
9264 (void)do_doautocmd((char_u *)"filetypedetect BufRead", TRUE, NULL); |
717 | 9265 do_modelines(0); |
7 | 9266 } |
9267 } | |
9268 else if (STRCMP(arg, "off") == 0) | |
9269 { | |
9270 if (plugin || indent) | |
9271 { | |
9272 if (plugin) | |
9273 { | |
8524
2f57bbe870ea
commit https://github.com/vim/vim/commit/7f8989dd8a627af2185df381195351a913f3777f
Christian Brabandt <cb@256bit.org>
parents:
8402
diff
changeset
|
9274 source_runtime((char_u *)FTPLUGOF_FILE, DIP_ALL); |
7 | 9275 filetype_plugin = FALSE; |
9276 } | |
9277 if (indent) | |
9278 { | |
8524
2f57bbe870ea
commit https://github.com/vim/vim/commit/7f8989dd8a627af2185df381195351a913f3777f
Christian Brabandt <cb@256bit.org>
parents:
8402
diff
changeset
|
9279 source_runtime((char_u *)INDOFF_FILE, DIP_ALL); |
7 | 9280 filetype_indent = FALSE; |
9281 } | |
9282 } | |
9283 else | |
9284 { | |
8524
2f57bbe870ea
commit https://github.com/vim/vim/commit/7f8989dd8a627af2185df381195351a913f3777f
Christian Brabandt <cb@256bit.org>
parents:
8402
diff
changeset
|
9285 source_runtime((char_u *)FTOFF_FILE, DIP_ALL); |
7 | 9286 filetype_detect = FALSE; |
9287 } | |
9288 } | |
9289 else | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
9290 semsg(_(e_invarg2), arg); |
7 | 9291 } |
9292 | |
9293 /* | |
11459
561b76ed9d12
patch 8.0.0613: the conf filetype is used before ftdetect from packages
Christian Brabandt <cb@256bit.org>
parents:
11428
diff
changeset
|
9294 * ":setfiletype [FALLBACK] {name}" |
7 | 9295 */ |
9296 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
9297 ex_setfiletype(exarg_T *eap) |
7 | 9298 { |
9299 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
|
9300 { |
561b76ed9d12
patch 8.0.0613: the conf filetype is used before ftdetect from packages
Christian Brabandt <cb@256bit.org>
parents:
11428
diff
changeset
|
9301 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
|
9302 |
561b76ed9d12
patch 8.0.0613: the conf filetype is used before ftdetect from packages
Christian Brabandt <cb@256bit.org>
parents:
11428
diff
changeset
|
9303 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
|
9304 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
|
9305 |
561b76ed9d12
patch 8.0.0613: the conf filetype is used before ftdetect from packages
Christian Brabandt <cb@256bit.org>
parents:
11428
diff
changeset
|
9306 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
|
9307 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
|
9308 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
|
9309 } |
7 | 9310 } |
9311 | |
9312 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
9313 ex_digraphs(exarg_T *eap UNUSED) |
7 | 9314 { |
9315 #ifdef FEAT_DIGRAPHS | |
9316 if (*eap->arg != NUL) | |
9317 putdigraph(eap->arg); | |
9318 else | |
15152
1ef429366fd4
patch 8.1.0586: :digraph output is not easy to read
Bram Moolenaar <Bram@vim.org>
parents:
15125
diff
changeset
|
9319 listdigraphs(eap->forceit); |
7 | 9320 #else |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15452
diff
changeset
|
9321 emsg(_("E196: No digraphs in this version")); |
7 | 9322 #endif |
9323 } | |
9324 | |
9325 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
9326 ex_set(exarg_T *eap) |
7 | 9327 { |
9328 int flags = 0; | |
9329 | |
9330 if (eap->cmdidx == CMD_setlocal) | |
9331 flags = OPT_LOCAL; | |
9332 else if (eap->cmdidx == CMD_setglobal) | |
9333 flags = OPT_GLOBAL; | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13288
diff
changeset
|
9334 #if defined(FEAT_EVAL) && defined(FEAT_BROWSE) |
7 | 9335 if (cmdmod.browse && flags == 0) |
9336 ex_options(eap); | |
9337 else | |
9338 #endif | |
9339 (void)do_set(eap->arg, flags); | |
9340 } | |
9341 | |
13792
0e9b2971d7c3
patch 8.0.1768: SET_NO_HLSEARCH() used in a wrong way
Christian Brabandt <cb@256bit.org>
parents:
13581
diff
changeset
|
9342 #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
|
9343 void |
0e9b2971d7c3
patch 8.0.1768: SET_NO_HLSEARCH() used in a wrong way
Christian Brabandt <cb@256bit.org>
parents:
13581
diff
changeset
|
9344 set_no_hlsearch(int flag) |
0e9b2971d7c3
patch 8.0.1768: SET_NO_HLSEARCH() used in a wrong way
Christian Brabandt <cb@256bit.org>
parents:
13581
diff
changeset
|
9345 { |
0e9b2971d7c3
patch 8.0.1768: SET_NO_HLSEARCH() used in a wrong way
Christian Brabandt <cb@256bit.org>
parents:
13581
diff
changeset
|
9346 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
|
9347 # 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
|
9348 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
|
9349 # endif |
0e9b2971d7c3
patch 8.0.1768: SET_NO_HLSEARCH() used in a wrong way
Christian Brabandt <cb@256bit.org>
parents:
13581
diff
changeset
|
9350 } |
0e9b2971d7c3
patch 8.0.1768: SET_NO_HLSEARCH() used in a wrong way
Christian Brabandt <cb@256bit.org>
parents:
13581
diff
changeset
|
9351 |
7 | 9352 /* |
9353 * ":nohlsearch" | |
9354 */ | |
9355 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
9356 ex_nohlsearch(exarg_T *eap UNUSED) |
7 | 9357 { |
13792
0e9b2971d7c3
patch 8.0.1768: SET_NO_HLSEARCH() used in a wrong way
Christian Brabandt <cb@256bit.org>
parents:
13581
diff
changeset
|
9358 set_no_hlsearch(TRUE); |
737 | 9359 redraw_all_later(SOME_VALID); |
7 | 9360 } |
9361 #endif | |
9362 | |
9363 #ifdef FEAT_CRYPT | |
9364 /* | |
9365 * ":X": Get crypt key | |
9366 */ | |
9367 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
9368 ex_X(exarg_T *eap UNUSED) |
7 | 9369 { |
6353 | 9370 crypt_check_current_method(); |
6122 | 9371 (void)crypt_get_key(TRUE, TRUE); |
7 | 9372 } |
9373 #endif | |
9374 | |
9375 #ifdef FEAT_FOLDING | |
9376 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
9377 ex_fold(exarg_T *eap) |
7 | 9378 { |
9379 if (foldManualAllowed(TRUE)) | |
9380 foldCreate(eap->line1, eap->line2); | |
9381 } | |
9382 | |
9383 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
9384 ex_foldopen(exarg_T *eap) |
7 | 9385 { |
9386 opFoldRange(eap->line1, eap->line2, eap->cmdidx == CMD_foldopen, | |
9387 eap->forceit, FALSE); | |
9388 } | |
9389 | |
9390 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
9391 ex_folddo(exarg_T *eap) |
7 | 9392 { |
9393 linenr_T lnum; | |
9394 | |
6116 | 9395 #ifdef FEAT_CLIPBOARD |
9396 start_global_changes(); | |
9397 #endif | |
9398 | |
7 | 9399 /* First set the marks for all lines closed/open. */ |
9400 for (lnum = eap->line1; lnum <= eap->line2; ++lnum) | |
9401 if (hasFolding(lnum, NULL, NULL) == (eap->cmdidx == CMD_folddoclosed)) | |
9402 ml_setmarked(lnum); | |
9403 | |
9404 /* Execute the command on the marked lines. */ | |
9405 global_exe(eap->arg); | |
9406 ml_clearmarked(); /* clear rest of the marks */ | |
6116 | 9407 #ifdef FEAT_CLIPBOARD |
9408 end_global_changes(); | |
9409 #endif | |
9410 } | |
9411 #endif | |
12459
937356f8f8d6
patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents:
12457
diff
changeset
|
9412 |
14550
60b9b6196644
patch 8.1.0288: quickfix code uses cmdidx too often
Christian Brabandt <cb@256bit.org>
parents:
14538
diff
changeset
|
9413 #ifdef FEAT_QUICKFIX |
60b9b6196644
patch 8.1.0288: quickfix code uses cmdidx too often
Christian Brabandt <cb@256bit.org>
parents:
14538
diff
changeset
|
9414 /* |
60b9b6196644
patch 8.1.0288: quickfix code uses cmdidx too often
Christian Brabandt <cb@256bit.org>
parents:
14538
diff
changeset
|
9415 * 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
|
9416 * 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
|
9417 */ |
60b9b6196644
patch 8.1.0288: quickfix code uses cmdidx too often
Christian Brabandt <cb@256bit.org>
parents:
14538
diff
changeset
|
9418 int |
60b9b6196644
patch 8.1.0288: quickfix code uses cmdidx too often
Christian Brabandt <cb@256bit.org>
parents:
14538
diff
changeset
|
9419 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
|
9420 { |
14621
89cc3e7ecb68
patch 8.1.0324: off-by-one error in cmdidx check
Christian Brabandt <cb@256bit.org>
parents:
14591
diff
changeset
|
9421 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
|
9422 return FALSE; |
60b9b6196644
patch 8.1.0288: quickfix code uses cmdidx too often
Christian Brabandt <cb@256bit.org>
parents:
14538
diff
changeset
|
9423 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
|
9424 } |
60b9b6196644
patch 8.1.0288: quickfix code uses cmdidx too often
Christian Brabandt <cb@256bit.org>
parents:
14538
diff
changeset
|
9425 #endif |
60b9b6196644
patch 8.1.0288: quickfix code uses cmdidx too often
Christian Brabandt <cb@256bit.org>
parents:
14538
diff
changeset
|
9426 |
12459
937356f8f8d6
patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents:
12457
diff
changeset
|
9427 # 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
|
9428 int |
937356f8f8d6
patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents:
12457
diff
changeset
|
9429 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
|
9430 { |
937356f8f8d6
patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents:
12457
diff
changeset
|
9431 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
|
9432 } |
937356f8f8d6
patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents:
12457
diff
changeset
|
9433 |
937356f8f8d6
patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents:
12457
diff
changeset
|
9434 void |
937356f8f8d6
patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents:
12457
diff
changeset
|
9435 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
|
9436 { |
937356f8f8d6
patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents:
12457
diff
changeset
|
9437 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
|
9438 } |
937356f8f8d6
patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents:
12457
diff
changeset
|
9439 #endif |